@@ -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' }),
},
},
{
From 56a45fb9bfdbe724e920b34a3451c49fe6cd94d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com>
Date: Wed, 8 Jun 2022 15:27:03 +0800
Subject: [PATCH 3/4] =?UTF-8?q?feat:=20=E9=A6=96=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/im/index.js | 3 +-
src/store/modules/im/chatHome.js | 45 +++++++++++
src/views/im/home/index.vue | 125 ++++++++++++++++++++++++++++++-
3 files changed, 169 insertions(+), 4 deletions(-)
create mode 100644 src/store/modules/im/chatHome.js
diff --git a/src/api/im/index.js b/src/api/im/index.js
index aa51360..52f51f7 100644
--- a/src/api/im/index.js
+++ b/src/api/im/index.js
@@ -1,8 +1,9 @@
import request from '@/utils/request.js';
-export const online = () => {
+export const online = (params) => {
return request({
url: '/im/admin/count/online',
method: 'get',
+ params,
});
};
export const hours = (params) => {
diff --git a/src/store/modules/im/chatHome.js b/src/store/modules/im/chatHome.js
new file mode 100644
index 0000000..81a9909
--- /dev/null
+++ b/src/store/modules/im/chatHome.js
@@ -0,0 +1,45 @@
+import * as api from '@/api/im/index.js';
+import { ElMessage } from '@/plugins/element-plus';
+const state = () => ({
+ online: 0,
+ single: [],
+ range: [],
+});
+const getters = {};
+const mutations = {
+ setOnline: (state, data) => (state.online = data),
+ setSingle: (state, data) => (state.single = data),
+ setRange: (state, data) => (state.range = data),
+};
+const actions = {
+ loadOnline: async ({ commit }, data) => {
+ let res = await api.online(data);
+ commit('setOnline', res || 0);
+ if (!res) {
+ ElMessage.error('查询失败');
+ }
+ return res;
+ },
+ loadSingle: async ({ commit }, data) => {
+ let res = await api.hours(data);
+ commit('setSingle', res || []);
+ if (!res) {
+ ElMessage.error('查询失败');
+ }
+ return res;
+ },
+ loadRange: async ({ commit }, data) => {
+ let res = await api.days(data);
+ commit('setRange', res || []);
+ if (!res) {
+ ElMessage.error('查询失败');
+ }
+ return res;
+ },
+};
+export default {
+ state,
+ getters,
+ mutations,
+ actions,
+};
diff --git a/src/views/im/home/index.vue b/src/views/im/home/index.vue
index 914fcd1..125e29f 100644
--- a/src/views/im/home/index.vue
+++ b/src/views/im/home/index.vue
@@ -1,7 +1,126 @@
- 在线人数
+
+
+
+
+
+
+
{{ online }}
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
From ffe1bb7690a30e756658427751df84b62ab5f1b5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=90=91=E6=96=87=E5=8F=AF?= <1041367524@qq.com>
Date: Wed, 8 Jun 2022 16:56:03 +0800
Subject: [PATCH 4/4] =?UTF-8?q?feat:=20=E6=8E=A5=E5=8F=A3=E5=AF=B9?=
=?UTF-8?q?=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/store/modules/im/chatHome.js | 2 +-
src/views/im/home/index.vue | 122 ++++++++++++++++++++++++++++---
2 files changed, 113 insertions(+), 11 deletions(-)
diff --git a/src/store/modules/im/chatHome.js b/src/store/modules/im/chatHome.js
index 81a9909..8f12d1e 100644
--- a/src/store/modules/im/chatHome.js
+++ b/src/store/modules/im/chatHome.js
@@ -15,7 +15,7 @@ const actions = {
loadOnline: async ({ commit }, data) => {
let res = await api.online(data);
commit('setOnline', res || 0);
- if (!res) {
+ if (!res && res !== 0) {
ElMessage.error('查询失败');
}
return res;
diff --git a/src/views/im/home/index.vue b/src/views/im/home/index.vue
index 125e29f..5029b89 100644
--- a/src/views/im/home/index.vue
+++ b/src/views/im/home/index.vue
@@ -2,7 +2,12 @@
-
+
{{ online }}
@@ -33,6 +38,8 @@