From d7347883637c526c8a3176434adbe4201ff68574 Mon Sep 17 00:00:00 2001 From: xiaomlove <353856593@qq.com> Date: Fri, 16 Apr 2021 19:04:01 +0800 Subject: [PATCH] agent allow store + update + delete --- admin/src/main.js | 6 +- admin/src/router/index.js | 7 +- admin/src/utils/api.js | 15 +- admin/src/utils/axios.js | 5 +- admin/src/views/AgentAllow/form.vue | 282 ++++++++++-------- admin/src/views/AgentAllow/index.vue | 48 +-- app/Http/Controllers/AgentAllowController.php | 21 +- app/Http/Resources/AgentAllowResource.php | 2 + app/Models/AgentAllow.php | 2 +- config/cors.php | 2 +- 10 files changed, 240 insertions(+), 150 deletions(-) diff --git a/admin/src/main.js b/admin/src/main.js index 79cc600c..c59aae01 100644 --- a/admin/src/main.js +++ b/admin/src/main.js @@ -2,6 +2,8 @@ import { createApp } from 'vue' import { ElButton, ElContainer, ElAside, ElHeader, ElMain, ElFooter, ElMenu, ElSubmenu, ElMenuItemGroup, ElMenuItem, ElForm, ElFormItem, ElInput, ElPopover, ElTag, ElCard, ElTable, ElTableColumn, ElPagination, ElDialog, ElPopconfirm, ElUpload, ElLoading, ElSelect, ElOption, ElRadioGroup, ElRadio, ElCascader, ElCheckbox, ElInputNumber } from 'element-plus' import App from './App.vue' import router from './router/index' +import 'dayjs/locale/zh-cn' +import locale from 'element-plus/lib/locale/lang/zh-cn' // import 'element-plus/lib/theme-chalk/index.css' @@ -60,8 +62,8 @@ app.use(ElButton) .use(ElSubmenu) .use(ElMenuItemGroup) .use(ElMenuItem) - .use(ElForm) - .use(ElFormItem) + .use(ElForm, { locale }) + .use(ElFormItem, { locale }) .use(ElInput) .use(ElPopover) .use(ElTag) diff --git a/admin/src/router/index.js b/admin/src/router/index.js index 7a00dffc..b1065dfd 100644 --- a/admin/src/router/index.js +++ b/admin/src/router/index.js @@ -92,7 +92,12 @@ const router = createRouter({ { path: '/agent-allow', name: 'agent-allow', - component: () => import(/* webpackChunkName: "account" */ '../views/AgentAllow/index.vue') + component: () => import(/* webpackChunkName: "account" */ '../views/AgentAllow/index.vue'), + }, + { + path: '/agent-allow-form', + name: 'agent-allow-form', + component: () => import(/* webpackChunkName: "account" */ '../views/AgentAllow/form.vue'), } ] }) diff --git a/admin/src/utils/api.js b/admin/src/utils/api.js index 9166b429..befacd08 100644 --- a/admin/src/utils/api.js +++ b/admin/src/utils/api.js @@ -2,10 +2,23 @@ import axios from "./axios"; const baseUrl = 'http://nexus-php8.tinyhd.net/api/'; + const api = { listAllowAgent: (params = {}) => { return axios.get(baseUrl + 'agent-allow', {params: params}); - } + }, + storeAllowAgent: (params = {}) => { + return axios.post(baseUrl + 'agent-allow', params); + }, + updateAllowAgent: (id, params = {}) => { + return axios.put(baseUrl + 'agent-allow/' + id, params); + }, + getAllowAgent: (id) => { + return axios.get(baseUrl + 'agent-allow/' + id); + }, + deleteAllowAgent: (id) => { + return axios.delete(baseUrl + 'agent-allow/' + id); + }, } export default api diff --git a/admin/src/utils/axios.js b/admin/src/utils/axios.js index 839e460f..6ab33b99 100644 --- a/admin/src/utils/axios.js +++ b/admin/src/utils/axios.js @@ -22,6 +22,10 @@ axios.interceptors.response.use(res => { ElMessage.error('服务端异常!') return Promise.reject(res) } + if (res.data.data.ret && res.data.data.ret != 0) { + ElMessage.error(res.data.data.msg) + return Promise.reject(res) + } if (res.data.resultCode && res.data.resultCode != 200) { if (res.data.message) ElMessage.error(res.data.message) if (res.data.resultCode == 419) { @@ -29,7 +33,6 @@ axios.interceptors.response.use(res => { } return Promise.reject(res.data) } - return res.data.data }) diff --git a/admin/src/views/AgentAllow/form.vue b/admin/src/views/AgentAllow/form.vue index 0efa7299..b9e546d6 100644 --- a/admin/src/views/AgentAllow/form.vue +++ b/admin/src/views/AgentAllow/form.vue @@ -1,82 +1,170 @@ - - - - - - - - - - - - - - - - - - 取 消 - 确 定 - - - + + + + + + + + + + + + + + + + + + + + + 十进制 + 十六进制 + + + + + + + + + + + + + 十进制 + 十六进制 + + + + 是 + 否 + + + 是 + 否 + + + + + + {{ id ? '立即修改' : '立即创建' }} + + + +