diff --git a/src/store/modules/im/chatWaiter.js b/src/store/modules/im/chatWaiter.js index 9ac965e..3d4c0d7 100644 --- a/src/store/modules/im/chatWaiter.js +++ b/src/store/modules/im/chatWaiter.js @@ -7,7 +7,7 @@ const state = () => ({ total: 0, opts: { init: false, - system: [], + store: [], }, }); const getters = {}; @@ -34,12 +34,12 @@ const actions = { load: async ({ commit }) => { commit('setOpts', { init: true, - system: (await api.searchSystem({ pageIndex: 1, length: 9999 }))?.records || [], + store: (await api.searchStore({ pageIndex: 1, length: 9999 }))?.records || [], }); }, - save: async ({ dispatch }, data) => { + save: async ({ state, dispatch }, data) => { if (data.id) { - data.systemId = data.sysId; + data.systemId = state.condition.systemid; } let save = data.id ? api.updateWaiter : api.createWaiter; let res = await save(data); @@ -51,13 +51,13 @@ const actions = { } return res; }, - remove: async ({ dispatch }, ids) => { - if (!ids.length) { + remove: async ({ dispatch }, data) => { + if (!data.waiterIds.length) { ElMessage.warning('请选择要删除的数据'); } else { try { await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); - let res = await api.removeWaiter({ ids }); + let res = await api.removeWaiter(data); if (res) { ElMessage.success('删除成功'); dispatch('search'); diff --git a/src/utils/request.js b/src/utils/request.js index 034ba57..c25c604 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -61,6 +61,14 @@ instance.interceptors.request.use( if (token) { config.headers['Authorization'] = token; } + config.params = Object.fromEntries( + Object.entries(config.params || {}).filter( + (entry) => + entry[1] !== null && + typeof entry[1] !== 'undefined' && + (typeof entry[1] !== 'string' || entry[1].trim() !== '') + ) + ); if (config.data && config.headers['Content-Type'] === 'application/x-www-form-urlencoded;charset=UTF-8') { config.data = qs.stringify(config.data); } diff --git a/src/views/im/store/index.vue b/src/views/im/store/index.vue index 9706e0b..cf7cf76 100644 --- a/src/views/im/store/index.vue +++ b/src/views/im/store/index.vue @@ -26,7 +26,13 @@ - + store.state.chatStore.code); @@ -145,6 +152,14 @@ rows.map((item) => item.id) ); }; + const handleWaiter = (row) => { + router.push({ + name: 'ChatWaiter', + query: { + storeId: row.id, + }, + }); + }; const config = reactive({ // 表格列配置 columns: [ @@ -169,19 +184,22 @@ { label: '操作', fixed: 'right', + width: 160, slots: { default: ({ row }) => (
handleCreate(row)}> 编辑 + handleWaiter(row)}> + 客服 + handleRemove([row])}> 删除
), }, - width: 120, }, ], }); diff --git a/src/views/im/system/index.vue b/src/views/im/system/index.vue index 8f29ace..ec1496a 100644 --- a/src/views/im/system/index.vue +++ b/src/views/im/system/index.vue @@ -16,6 +16,7 @@ - - + + - + - + @@ -78,35 +84,50 @@ } const state = reactive({ condition: { - systemId: null, + storeId: null, waiterId: null, waiterNickname: null, }, }); const handleReset = () => { state.condition = { - systemId: null, + storeId: null, waiterId: null, waiterNickname: null, }; }; const handleSearch = async () => { - loading.value = true; - await store.dispatch('chatWaiter/search'); - loading.value = false; + if (state.condition.storeId) { + loading.value = true; + await store.dispatch('chatWaiter/search'); + loading.value = false; + } }; + watch( + () => unref(opts).store, + (value) => { + if (!state.condition.storeId) { + state.condition.storeId = value[0]?.id; + } + } + ); watch( () => state.condition, (value) => { store.commit('chatWaiter/setCondition', _.cloneDeep(value)); - handleSearch(); }, { immediate: true, deep: true } ); + watch( + () => state.condition.storeId, + () => { + handleSearch(); + } + ); onActivated(() => { - let sysId = route.query.sysId; - if (sysId) { - state.condition.sysId = +sysId; + let storeId = route.query.storeId; + if (storeId) { + state.condition.storeId = +storeId; } else { handleSearch(); } @@ -119,14 +140,14 @@ submitting: false, form: { id: null, - systemId: null, - type: 0, + storeId: null, + type: null, waiterAvatar: null, waiterId: null, waiterNickname: null, }, rules: { - systemId: [{ required: true, message: '所属系统不能为空' }], + storeId: [{ required: true, message: '所属店铺不能为空' }], type: [{ required: true, message: '客服类型不能为空' }], waiterAvatar: [{ required: true, message: '客服头像不能为空' }], waiterId: [{ required: true, message: '客服ID不能为空' }], @@ -139,13 +160,16 @@ formState.form, row || { id: null, - systemId: null, - type: 0, + storeId: null, + type: null, waiterAvatar: null, waiterId: null, waiterNickname: null, } ); + if (!formState.form.storeId) { + formState.form.storeId = state.condition.storeId; + } formState.formVisible = true; }; // 保存 @@ -162,19 +186,19 @@ formState.submitting = false; }; const handleRemove = async (rows) => { - store.dispatch( - 'chatWaiter/remove', - rows.map((item) => item.id) - ); + store.dispatch('chatWaiter/remove', { + storeId: state.condition.storeId, + waiterIds: rows.map((item) => item.waiterId), + }); }; const config = reactive({ // 表格列配置 columns: [ { - label: '所属系统', + label: '所属店铺', width: 160, slots: { - default: ({ row }) => proxy.$dict(unref(opts).system, row.sysId, { label: 'name', value: 'id' }), + default: ({ row }) => proxy.$dict(unref(opts).store, row.storeId, { label: 'name', value: 'id' }), }, }, {