-
+
{{ online }}
@@ -33,6 +38,8 @@
+
+
diff --git a/src/views/im/home/index.vue b/src/views/im/home/index.vue
index e310781..007a3a6 100644
--- a/src/views/im/home/index.vue
+++ b/src/views/im/home/index.vue
@@ -24,12 +24,7 @@
@@ -40,6 +35,7 @@
+
+
diff --git a/src/views/im/home/index.vue b/src/views/im/home/index.vue
index 43f1998..1d8d72e 100644
--- a/src/views/im/home/index.vue
+++ b/src/views/im/home/index.vue
@@ -43,9 +43,9 @@
import DateRange from './dateRange.vue';
const store = useStore();
const loading = ref(false);
- const opts = computed(() => store.state.chatStore.opts);
+ const opts = computed(() => store.state.imStore.opts);
if (!unref(opts).init) {
- store.dispatch('chatStore/load');
+ store.dispatch('imStore/load');
}
const systemId = ref(null);
@@ -58,11 +58,11 @@
},
{ immediate: true }
);
- const online = computed(() => store.state.chatHome.online);
+ const online = computed(() => store.state.imHome.online);
const handleLoadOnline = async () => {
loading.value = true;
if (unref(systemId)) {
- await store.dispatch('chatHome/loadOnline', { systemId: unref(systemId) });
+ await store.dispatch('imHome/loadOnline', { systemId: unref(systemId) });
}
loading.value = false;
};
@@ -140,10 +140,10 @@
const date1 = ref(dayjs(new Date()).format('YYYY-MM-DD'));
const handleLoadSingle = async () => {
loading.value = true;
- store.commit('chatHome/setSingle', []);
+ store.commit('imHome/setSingle', []);
if (unref(systemId)) {
if (unref(date1)) {
- await store.dispatch('chatHome/loadSingle', {
+ await store.dispatch('imHome/loadSingle', {
systemId: unref(systemId),
days: unref(date1),
});
@@ -154,7 +154,7 @@
watch(date1, handleLoadSingle, { immediate: true });
watch(systemId, handleLoadSingle);
watch(
- () => store.state.chatHome.single,
+ () => store.state.imHome.single,
(value) => {
handleChart(
'.chart-1',
@@ -174,10 +174,10 @@
const date2 = ref([]);
const handleLoadRange = async () => {
loading.value = true;
- store.commit('chatHome/setRange', []);
+ store.commit('imHome/setRange', []);
if (unref(systemId)) {
if (unref(date2)?.length) {
- await store.dispatch('chatHome/loadRange', {
+ await store.dispatch('imHome/loadRange', {
systemId: unref(systemId),
start: unref(date2)[0],
end: unref(date2)[1],
@@ -189,7 +189,7 @@
watch(date2, handleLoadRange);
watch(systemId, handleLoadRange);
watch(
- () => store.state.chatHome.range,
+ () => store.state.imHome.range,
(value) => {
handleChart(
'.chart-2',
diff --git a/src/views/im/store/index.vue b/src/views/im/store/index.vue
index 508f7ce..29bc429 100644
--- a/src/views/im/store/index.vue
+++ b/src/views/im/store/index.vue
@@ -64,12 +64,12 @@
const router = useRouter();
const { proxy } = getCurrentInstance();
const loading = ref(false);
- const code = computed(() => store.state.chatStore.code);
- const list = computed(() => store.state.chatStore.list);
- const total = computed(() => store.state.chatStore.total);
- const opts = computed(() => store.state.chatStore.opts);
+ const code = computed(() => store.state.imStore.code);
+ const list = computed(() => store.state.imStore.list);
+ const total = computed(() => store.state.imStore.total);
+ const opts = computed(() => store.state.imStore.opts);
if (!unref(opts).init) {
- store.dispatch('chatStore/load');
+ store.dispatch('imStore/load');
}
const state = reactive({
condition: {
@@ -83,13 +83,13 @@
};
const handleSearch = async () => {
loading.value = true;
- await store.dispatch('chatStore/search');
+ await store.dispatch('imStore/search');
loading.value = false;
};
watch(
() => state.condition,
(value) => {
- store.commit('chatStore/setCondition', _.cloneDeep(value));
+ store.commit('imStore/setCondition', _.cloneDeep(value));
handleSearch();
},
{ immediate: true, deep: true }
@@ -139,7 +139,7 @@
try {
await proxy.$validate(refsForm);
let data = _.cloneDeep(formState.form);
- await store.dispatch('chatStore/save', data);
+ await store.dispatch('imStore/save', data);
formState.formVisible = false;
} catch (e) {
console.info('取消保存', e);
@@ -148,7 +148,7 @@
};
const handleRemove = async (rows) => {
store.dispatch(
- 'chatStore/remove',
+ 'imStore/remove',
rows.map((item) => item.id)
);
};
diff --git a/src/views/im/system/index.vue b/src/views/im/system/index.vue
index 3f1f30e..c605698 100644
--- a/src/views/im/system/index.vue
+++ b/src/views/im/system/index.vue
@@ -53,12 +53,12 @@
const router = useRouter();
const { proxy } = getCurrentInstance();
const loading = ref(false);
- const code = computed(() => store.state.chatSystem.code);
- const list = computed(() => store.state.chatSystem.list);
- const total = computed(() => store.state.chatSystem.total);
- const opts = computed(() => store.state.chatSystem.opts);
+ const code = computed(() => store.state.imSystem.code);
+ const list = computed(() => store.state.imSystem.list);
+ const total = computed(() => store.state.imSystem.total);
+ const opts = computed(() => store.state.imSystem.opts);
if (!unref(opts).init) {
- store.dispatch('chatSystem/load');
+ store.dispatch('imSystem/load');
}
const state = reactive({
condition: {
@@ -68,7 +68,7 @@
watch(
() => state.condition,
(value) => {
- store.commit('chatSystem/setCondition', _.cloneDeep(value));
+ store.commit('imSystem/setCondition', _.cloneDeep(value));
},
{ immediate: true, deep: true }
);
@@ -79,7 +79,7 @@
};
const handleSearch = async () => {
loading.value = true;
- await store.dispatch('chatSystem/search');
+ await store.dispatch('imSystem/search');
loading.value = false;
};
onActivated(handleSearch);
@@ -117,7 +117,7 @@
try {
await proxy.$validate(refsForm);
let data = _.cloneDeep(formState.form);
- await store.dispatch('chatSystem/save', data);
+ await store.dispatch('imSystem/save', data);
formState.formVisible = false;
} catch (e) {
console.info('取消保存', e);
@@ -126,7 +126,7 @@
};
const handleRemove = async (rows) => {
store.dispatch(
- 'chatSystem/remove',
+ 'imSystem/remove',
rows.map((item) => item.id)
);
};
diff --git a/src/views/im/waiter/index.vue b/src/views/im/waiter/index.vue
index 08614ff..2cbc990 100644
--- a/src/views/im/waiter/index.vue
+++ b/src/views/im/waiter/index.vue
@@ -5,7 +5,7 @@
:code="code"
:config="config"
:data="list"
- :operation="['create', 'search', 'remove']"
+ :operation="['search']"
:reset="handleReset"
title="客服"
:total="total"
@@ -31,7 +31,7 @@
-
+
From 4789117bf127e77094d842febf2e6a3a28001f9d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com>
Date: Mon, 13 Jun 2022 10:39:33 +0800
Subject: [PATCH 14/14] =?UTF-8?q?refactor:=20IM=E5=AE=A2=E6=9C=8D=E9=87=8D?=
=?UTF-8?q?=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/chat/waiter.js | 36 +++++++++++
src/store/modules/chat/chatWaiter.js | 28 ++++----
src/views/chat/waiter.vue | 97 ++++++----------------------
src/views/im/store/index.vue | 2 +-
src/views/im/system/index.vue | 2 +-
src/views/im/waiter/index.vue | 4 --
6 files changed, 72 insertions(+), 97 deletions(-)
create mode 100644 src/api/chat/waiter.js
diff --git a/src/api/chat/waiter.js b/src/api/chat/waiter.js
new file mode 100644
index 0000000..03004fc
--- /dev/null
+++ b/src/api/chat/waiter.js
@@ -0,0 +1,36 @@
+import request from '@/utils/request.js';
+export const search = (params) => {
+ return request({
+ url: '/mall/im/admin/waiterUser',
+ method: 'get',
+ params,
+ });
+};
+export const detail = (userId) => {
+ return request({
+ url: '/mall/im/admin/waiterUser/getWaiterByUserId',
+ method: 'get',
+ params: { userId },
+ });
+};
+export const create = (data) => {
+ return request({
+ url: '/mall/im/admin/waiterUser',
+ method: 'post',
+ data,
+ });
+};
+export const update = (data) => {
+ return request({
+ url: '/mall/im/admin/waiterUser',
+ method: 'put',
+ data,
+ });
+};
+export const remove = (ids) => {
+ return request({
+ url: '/mall/im/admin/waiterUser',
+ method: 'delete',
+ data: { ids },
+ });
+};
diff --git a/src/store/modules/chat/chatWaiter.js b/src/store/modules/chat/chatWaiter.js
index 3d4c0d7..7451300 100644
--- a/src/store/modules/chat/chatWaiter.js
+++ b/src/store/modules/chat/chatWaiter.js
@@ -1,4 +1,5 @@
-import * as api from '@/api/im/index.js';
+import * as api from '@/api/chat/waiter.js';
+import * as EmployeeAPI from '@/api/permission/employee.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({
code: 'ChatWaiter',
@@ -7,7 +8,7 @@ const state = () => ({
total: 0,
opts: {
init: false,
- store: [],
+ employee: [],
},
});
const getters = {};
@@ -21,27 +22,26 @@ const mutations = {
const actions = {
search: async ({ state, commit, rootGetters }) => {
let data = { ...state.condition };
- let res = await api.searchWaiter({ ...rootGetters['local/page'](state.code), ...data });
- if (res) {
- commit('setList', res.records);
- commit('setTotal', res.total);
- } else {
+ let res = await api.search({ ...rootGetters['local/page'](state.code), ...data });
+ commit('setList', res?.records || []);
+ commit('setTotal', res?.total || 0);
+ if (!res) {
ElMessage.error('查询失败');
- commit('setList', []);
}
return res;
},
- load: async ({ commit }) => {
+ load: async ({ state, commit }) => {
commit('setOpts', {
+ ...state.opts,
init: true,
- store: (await api.searchStore({ pageIndex: 1, length: 9999 }))?.records || [],
+ employee: (await EmployeeAPI.search({ pageIndex: 1, length: 9999 }))?.records || [],
});
},
save: async ({ state, dispatch }, data) => {
if (data.id) {
data.systemId = state.condition.systemid;
}
- let save = data.id ? api.updateWaiter : api.createWaiter;
+ let save = data.id ? api.update : api.create;
let res = await save(data);
if (res) {
ElMessage.success('保存成功');
@@ -51,13 +51,13 @@ const actions = {
}
return res;
},
- remove: async ({ dispatch }, data) => {
- if (!data.waiterIds.length) {
+ remove: async ({ dispatch }, ids) => {
+ if (!ids.length) {
ElMessage.warning('请选择要删除的数据');
} else {
try {
await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
- let res = await api.removeWaiter(data);
+ let res = await api.remove(ids);
if (res) {
ElMessage.success('删除成功');
dispatch('search');
diff --git a/src/views/chat/waiter.vue b/src/views/chat/waiter.vue
index 08614ff..4d15ea3 100644
--- a/src/views/chat/waiter.vue
+++ b/src/views/chat/waiter.vue
@@ -15,16 +15,6 @@
>
-
-
-
-
-
-
@@ -39,23 +29,17 @@
:model="formState.form"
:rules="formState.rules"
>
-
+
-
-
-
-
-
-
@@ -72,7 +56,6 @@
import ElButton from '@/components/extra/ElButton.vue';
import ElImage from '@/components/extra/ElImage.vue';
const store = useStore();
- const route = useRoute();
const { proxy } = getCurrentInstance();
const loading = ref(false);
const code = computed(() => store.state.chatWaiter.code);
@@ -84,36 +67,19 @@
}
const state = reactive({
condition: {
- storeId: null,
- waiterId: null,
waiterNickname: null,
},
});
const handleReset = () => {
state.condition = {
- storeId: unref(opts).store?.[0]?.id,
- waiterId: null,
waiterNickname: null,
};
};
const handleSearch = async () => {
- if (state.condition.storeId) {
- loading.value = true;
- await store.dispatch('chatWaiter/search');
- loading.value = false;
- } else {
- store.commit('chatWaiter/setList', []);
- store.commit('chatWaiter/setTotal', 0);
- }
+ 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) => {
@@ -121,20 +87,7 @@
},
{ immediate: true, deep: true }
);
- watch(
- () => state.condition.storeId,
- () => {
- handleSearch();
- }
- );
- onActivated(() => {
- let storeId = route.query.storeId;
- if (storeId) {
- state.condition.storeId = +storeId;
- } else {
- handleSearch();
- }
- });
+ onActivated(handleSearch);
/* 表单 */
const refsForm = ref(null);
@@ -143,17 +96,13 @@
submitting: false,
form: {
id: null,
- storeId: null,
- type: null,
waiterAvatar: null,
- waiterId: null,
+ userId: null,
waiterNickname: null,
},
rules: {
- storeId: [{ required: true, message: '所属店铺不能为空' }],
- type: [{ required: true, message: '客服类型不能为空' }],
waiterAvatar: [{ required: true, message: '客服头像不能为空' }],
- waiterId: [{ required: true, message: '客服ID不能为空' }],
+ userId: [{ required: true, message: '客服员工不能为空' }],
waiterNickname: [{ required: true, message: '客服昵称不能为空' }],
},
});
@@ -163,10 +112,8 @@
formState.form,
row || {
id: null,
- storeId: null,
- type: null,
waiterAvatar: null,
- waiterId: null,
+ userId: null,
waiterNickname: null,
}
);
@@ -189,10 +136,10 @@
formState.submitting = false;
};
const handleRemove = async (rows) => {
- store.dispatch('chatWaiter/remove', {
- storeId: state.condition.storeId,
- waiterIds: rows.map((item) => item.waiterId),
- });
+ store.dispatch(
+ 'chatWaiter/remove',
+ rows.map((row) => row.id)
+ );
};
const config = reactive({
// 表格列配置
@@ -202,23 +149,19 @@
width: 60,
},
{
- label: '所属店铺',
- width: 160,
+ label: '客服员工',
slots: {
- default: ({ row }) => proxy.$dict(unref(opts).store, row.storeId, { label: 'name', value: 'id' }),
+ default: ({ row }) =>
+ proxy.$dict(unref(opts).employee, row.userId, { label: 'employeeName', value: 'id' }),
},
},
{
label: '客服头像',
width: 160,
slots: {
- default: ({ row }) => ,
+ default: ({ row }) => ,
},
},
- {
- label: '客服ID',
- prop: 'waiterId',
- },
{
label: '客服昵称',
prop: 'waiterNickname',
diff --git a/src/views/im/store/index.vue b/src/views/im/store/index.vue
index 29bc429..4dd7193 100644
--- a/src/views/im/store/index.vue
+++ b/src/views/im/store/index.vue
@@ -154,7 +154,7 @@
};
const handleWaiter = (row) => {
router.push({
- name: 'ChatWaiter',
+ name: 'ImWaiter',
query: {
storeId: row.id,
},
diff --git a/src/views/im/system/index.vue b/src/views/im/system/index.vue
index c605698..607f4c6 100644
--- a/src/views/im/system/index.vue
+++ b/src/views/im/system/index.vue
@@ -131,7 +131,7 @@
);
};
const handleStore = (row) => {
- router.push({ name: 'ChatStore', query: { sysId: row.id } });
+ router.push({ name: 'ImStore', query: { sysId: row.id } });
};
const config = reactive({
// 表格列配置
diff --git a/src/views/im/waiter/index.vue b/src/views/im/waiter/index.vue
index 2cbc990..cc7ee15 100644
--- a/src/views/im/waiter/index.vue
+++ b/src/views/im/waiter/index.vue
@@ -196,10 +196,6 @@
const config = reactive({
// 表格列配置
columns: [
- {
- type: 'selection',
- width: 60,
- },
{
label: '所属店铺',
width: 160,