diff --git a/src/api/search/config.js b/src/api/search/config.js new file mode 100644 index 0000000..069204f --- /dev/null +++ b/src/api/search/config.js @@ -0,0 +1,35 @@ +import request from '@/utils/request.js'; +export const search = (params) => { + return request({ + url: '/search/admin/searchConfig', + method: 'get', + params, + }); +}; +export const detail = (id) => { + return request({ + url: '/search/admin/searchConfig/' + id, + method: 'get', + }); +}; +export const create = (data) => { + return request({ + url: '/search/admin/searchConfig', + method: 'post', + data, + }); +}; +export const update = (data) => { + return request({ + url: '/search/admin/searchConfig', + method: 'put', + data, + }); +}; +export const remove = (id) => { + return request({ + url: '/search/admin/searchConfig', + method: 'delete', + params: { id }, + }); +}; diff --git a/src/api/search/system.js b/src/api/search/system.js new file mode 100644 index 0000000..c47358c --- /dev/null +++ b/src/api/search/system.js @@ -0,0 +1,35 @@ +import request from '@/utils/request.js'; +export const search = (params) => { + return request({ + url: '/search/admin/systemConfig', + method: 'get', + params, + }); +}; +export const detail = (id) => { + return request({ + url: '/search/admin/systemConfig/' + id, + method: 'get', + }); +}; +export const create = (data) => { + return request({ + url: '/search/admin/systemConfig', + method: 'post', + data, + }); +}; +export const update = (data) => { + return request({ + url: '/search/admin/systemConfig', + method: 'put', + data, + }); +}; +export const remove = (id) => { + return request({ + url: '/search/admin/systemConfig', + method: 'delete', + params: { id }, + }); +}; diff --git a/src/components/extra/ElTooltip.vue b/src/components/extra/ElTooltip.vue new file mode 100644 index 0000000..27068e6 --- /dev/null +++ b/src/components/extra/ElTooltip.vue @@ -0,0 +1,16 @@ + + + diff --git a/src/store/modules/sales/category.js b/src/store/modules/sales/category.js index 57b9eb1..c3fcb62 100644 --- a/src/store/modules/sales/category.js +++ b/src/store/modules/sales/category.js @@ -34,13 +34,10 @@ const actions = { } return res; }, - load: async ({ commit }) => { + load: async ({ state, commit }) => { commit('setOpts', { + ...state.opts, init: true, - visible: [ - { label: '显示', value: true }, - { label: '隐藏', value: false }, - ], }); }, detail: async ({ state, dispatch }, id) => { diff --git a/src/store/modules/sales/orderShip.js b/src/store/modules/sales/orderShip.js index 35989a6..ff458b7 100644 --- a/src/store/modules/sales/orderShip.js +++ b/src/store/modules/sales/orderShip.js @@ -11,7 +11,7 @@ const state = () => ({ summary: [], opts: { init: false, - company: [{ label: '顺丰', value: 'sf' }], + company: [], }, }); const getters = {}; @@ -31,8 +31,9 @@ const actions = { } return res; }, - load: async ({ commit }) => { + load: async ({ state, commit }) => { commit('setOpts', { + ...state.opts, init: true, company: await api.searchShip(), }); diff --git a/src/store/modules/search/searchConfig.js b/src/store/modules/search/searchConfig.js new file mode 100644 index 0000000..595ccef --- /dev/null +++ b/src/store/modules/search/searchConfig.js @@ -0,0 +1,82 @@ +import * as api from '@/api/search/config.js'; +import * as systemAPI from '@/api/search/system.js'; +import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; +const state = () => ({ + code: 'SearchConfig', + condition: {}, + list: [], + total: 0, + opts: { + init: false, + system: [], + }, +}); +const getters = {}; +const mutations = { + setCode: (state, data) => (state.code = data), + setCondition: (state, data) => (state.condition = data), + setList: (state, data) => (state.list = data), + setTotal: (state, data) => (state.total = data), + setOpts: (state, data) => (state.opts = data), +}; +const actions = { + search: async ({ state, commit, rootGetters }) => { + let data = { ...state.condition }; + let res = await api.search({ ...rootGetters['local/page'](state.code), ...data }); + commit('setList', res?.records || []); + commit('setTotal', res?.total || 0); + if (!res) { + ElMessage.error('查询失败'); + } + return res; + }, + load: async ({ state, commit }) => { + commit('setOpts', { + ...state.opts, + init: true, + system: (await systemAPI.search({ pageIndex: 1, length: 99999 }))?.records || [], + }); + }, + detail: async (context, id) => { + let res = await api.detail(id); + if (!res) { + ElMessage.error('加载详情失败'); + } + return res; + }, + save: async ({ dispatch }, data) => { + let save = data.id ? api.update : api.create; + let res = await save(data); + if (res) { + ElMessage.success('保存成功'); + dispatch('search'); + } else { + ElMessage.error('保存失败'); + } + return res; + }, + remove: async ({ dispatch }, idList) => { + if (!idList.length) { + ElMessage.warning('请选择要删除的数据'); + } else { + try { + await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); + let res = await api.remove(idList.join(',')); + if (res) { + ElMessage.success('删除成功'); + dispatch('search'); + } else { + ElMessage.error('删除失败'); + } + } catch (e) { + console.info('取消删除', e); + } + } + }, +}; +export default { + state, + getters, + mutations, + actions, +}; diff --git a/src/store/modules/search/searchSystem.js b/src/store/modules/search/searchSystem.js new file mode 100644 index 0000000..df1e3ff --- /dev/null +++ b/src/store/modules/search/searchSystem.js @@ -0,0 +1,85 @@ +import * as api from '@/api/search/system.js'; +import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; +const state = () => ({ + code: 'SearchSystem', + condition: {}, + list: [], + total: 0, + opts: { + init: false, + type: [ + { + label: 'MySQL', + value: 1, + }, + ], + }, +}); +const getters = {}; +const mutations = { + setCode: (state, data) => (state.code = data), + setCondition: (state, data) => (state.condition = data), + setList: (state, data) => (state.list = data), + setTotal: (state, data) => (state.total = data), + setOpts: (state, data) => (state.opts = data), +}; +const actions = { + search: async ({ state, commit, rootGetters }) => { + let data = { ...state.condition }; + let res = await api.search({ ...rootGetters['local/page'](state.code), ...data }); + commit('setList', res?.records || []); + commit('setTotal', res?.total || 0); + if (!res) { + ElMessage.error('查询失败'); + } + return res; + }, + load: async ({ state, commit }) => { + commit('setOpts', { + ...state.opts, + init: true, + }); + }, + detail: async (context, id) => { + let res = await api.detail(id); + if (!res) { + ElMessage.error('加载详情失败'); + } + return res; + }, + save: async ({ dispatch }, data) => { + let save = data.id ? api.update : api.create; + let res = await save(data); + if (res) { + ElMessage.success('保存成功'); + dispatch('search'); + } else { + ElMessage.error('保存失败'); + } + return res; + }, + remove: async ({ dispatch }, idList) => { + if (!idList.length) { + ElMessage.warning('请选择要删除的数据'); + } else { + try { + await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); + let res = await api.remove(idList.join(',')); + if (res) { + ElMessage.success('删除成功'); + dispatch('search'); + } else { + ElMessage.error('删除失败'); + } + } catch (e) { + console.info('取消删除', e); + } + } + }, +}; +export default { + state, + getters, + mutations, + actions, +}; diff --git a/src/store/modules/system/customer.js b/src/store/modules/system/customer.js index f39bdc7..dfabe3b 100644 --- a/src/store/modules/system/customer.js +++ b/src/store/modules/system/customer.js @@ -7,7 +7,10 @@ const state = () => ({ total: 0, opts: { init: false, - gender: [], + gender: [ + { label: '男', value: 1 }, + { label: '女', value: 2 }, + ], }, }); const getters = {}; @@ -36,13 +39,10 @@ const actions = { } return res; }, - load: async ({ commit }) => { + load: async ({ state, commit }) => { commit('setOpts', { + ...state.opts, init: true, - gender: [ - { label: '男', value: 1 }, - { label: '女', value: 2 }, - ], }); }, enable: async ({ dispatch }, data) => { diff --git a/src/store/modules/system/notify.js b/src/store/modules/system/notify.js index d4a1d55..d5265db 100644 --- a/src/store/modules/system/notify.js +++ b/src/store/modules/system/notify.js @@ -33,8 +33,9 @@ const actions = { } return res; }, - load: async ({ commit }) => { + load: async ({ state, commit }) => { commit('setOpts', { + ...state.opts, init: true, }); }, diff --git a/src/views/search/config/index.vue b/src/views/search/config/index.vue new file mode 100644 index 0000000..40167e0 --- /dev/null +++ b/src/views/search/config/index.vue @@ -0,0 +1,296 @@ + + + + + diff --git a/src/views/search/system/index.vue b/src/views/search/system/index.vue new file mode 100644 index 0000000..66b3bdc --- /dev/null +++ b/src/views/search/system/index.vue @@ -0,0 +1,191 @@ + + + + + diff --git a/vite.config.js b/vite.config.js index 6e19788..200c12e 100644 --- a/vite.config.js +++ b/vite.config.js @@ -22,11 +22,11 @@ export default (configEnv) => { '/api': { // target: 'http://192.168.10.109:8090/', // 显雨 // target: 'http://192.168.10.5:4500', // 高玉 - // target: 'http://192.168.10.67:8090', // 罗战 - // target: 'http://192.168.10.94:8090', // 周渺 + // target: 'http://192.168.10.87:8090', // 罗战 + // target: 'http://192.168.10.93:8090', // 周渺 // target: 'http://192.168.10.124:8090', // 舒梦娇 - target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址 - // target: 'https://you-gateway.mashibing.com', // 生产环境 + // target: 'https://k8s-horse-gateway.mashibing.cn/', // 测试地址 + target: 'https://you-gateway.mashibing.com', // 生产环境 changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), },