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..ce103e4 --- /dev/null +++ b/src/store/modules/search/searchConfig.js @@ -0,0 +1,79 @@ +import * as api from '@/api/system/notify.js'; +import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; +const state = () => ({ + code: 'SearchConfig', + condition: {}, + list: [], + total: 0, + opts: { + init: false, + }, +}); +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/search/searchSystem.js b/src/store/modules/search/searchSystem.js index d45d247..1ace0e9 100644 --- a/src/store/modules/search/searchSystem.js +++ b/src/store/modules/search/searchSystem.js @@ -7,6 +7,12 @@ const state = () => ({ total: 0, opts: { init: false, + type: [ + { + label: 'MySQL', + value: 1, + }, + ], }, }); const getters = {}; @@ -28,8 +34,9 @@ const actions = { } return res; }, - load: async ({ commit }) => { + load: async ({ state, commit }) => { commit('setOpts', { + ...state.opts, init: true, }); }, 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 535c033..284c8b7 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 deleted file mode 100644 index 08614ff..0000000 --- a/src/views/search/config/index.vue +++ /dev/null @@ -1,247 +0,0 @@ - - - - - diff --git a/src/views/search/search/index.vue b/src/views/search/search/index.vue new file mode 100644 index 0000000..0584b6c --- /dev/null +++ b/src/views/search/search/index.vue @@ -0,0 +1,386 @@ + + + + + diff --git a/src/views/search/system/index.vue b/src/views/search/system/index.vue index fa0b63d..73dc77b 100644 --- a/src/views/search/system/index.vue +++ b/src/views/search/system/index.vue @@ -14,28 +14,25 @@ @search="handleSearch" > @@ -80,31 +51,25 @@ - - - - - + + - - + + - - + + - + - + - - - - - - - - - - - - - -