Merge branch 'feat-im-0607-xwk' into msb_test

msb_test
向文可 3 years ago
commit 51cf0b0520

@ -1,91 +0,0 @@
import * as api from '@/api/chat/index.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({
code: 'CustomerServiceManagement',
condition: {},
list: [],
total: 0,
opts: {
init: false,
customerServiceType: [
{
label: '售前',
value: 1,
},
{
label: '售后',
value: 2,
},
{
label: '发货',
value: 3,
},
],
},
});
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 ({ commit }) => {
let res = await api.searchService(1);
commit('setList', res || []);
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,
};

@ -1,7 +1,7 @@
import * as api from '@/api/im/index.js'; import * as api from '@/api/im/index.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({ const state = () => ({
code: 'ChatStore', code: 'ImStore',
condition: {}, condition: {},
list: [], list: [],
total: 0, total: 0,

@ -1,7 +1,7 @@
import * as api from '@/api/im/index.js'; import * as api from '@/api/im/index.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
const state = () => ({ const state = () => ({
code: 'ChatSystem', code: 'ImSystem',
condition: {}, condition: {},
list: [], list: [],
total: 0, total: 0,

@ -1,13 +1,14 @@
import * as api from '@/api/system/notify.js'; import * as api from '@/api/im/index.js';
import { ElMessage, ElMessageBox } from '@/plugins/element-plus'; import { ElMessage, ElMessageBox } from '@/plugins/element-plus';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
const state = () => ({ const state = () => ({
code: 'NotifyManagement', code: 'ImWaiter',
condition: {}, condition: {},
list: [], list: [],
total: 0, total: 0,
opts: { opts: {
init: false, init: false,
store: [],
}, },
sessionData: [], sessionData: [],
@ -122,10 +123,7 @@ const mutations = {
const actions = { const actions = {
search: async ({ state, commit, rootGetters }) => { search: async ({ state, commit, rootGetters }) => {
let data = { ...state.condition }; let data = { ...state.condition };
data.startReleaseTime = data.dateRange?.[0]; let res = await api.searchWaiter({ ...rootGetters['local/page'](state.code), ...data });
data.endReleaseTime = data.dateRange?.[1];
delete data.dateRange;
let res = await api.search({ ...rootGetters['local/page'](state.code), ...state.condition });
if (res) { if (res) {
commit('setList', res.records); commit('setList', res.records);
commit('setTotal', res.total); commit('setTotal', res.total);
@ -138,17 +136,14 @@ const actions = {
load: async ({ commit }) => { load: async ({ commit }) => {
commit('setOpts', { commit('setOpts', {
init: true, init: true,
store: (await api.searchStore({ pageIndex: 1, length: 9999 }))?.records || [],
}); });
}, },
detail: async (context, id) => { save: async ({ state, dispatch }, data) => {
let res = await api.detail(id); if (data.id) {
if (!res) { data.systemId = state.condition.systemid;
ElMessage.error('加载详情失败');
} }
return res; let save = data.id ? api.updateWaiter : api.createWaiter;
},
save: async ({ dispatch }, data) => {
let save = data.id ? api.update : api.create;
let res = await save(data); let res = await save(data);
if (res) { if (res) {
ElMessage.success('保存成功'); ElMessage.success('保存成功');
@ -158,13 +153,13 @@ const actions = {
} }
return res; return res;
}, },
remove: async ({ dispatch }, idList) => { remove: async ({ dispatch }, data) => {
if (!idList.length) { if (!data.waiterIds.length) {
ElMessage.warning('请选择要删除的数据'); ElMessage.warning('请选择要删除的数据');
} else { } else {
try { try {
await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作'); await ElMessageBox.confirm('数据删除后无法恢复,确定要删除吗?', '危险操作');
let res = await api.remove(idList.join(',')); let res = await api.removeWaiter(data);
if (res) { if (res) {
ElMessage.success('删除成功'); ElMessage.success('删除成功');
dispatch('search'); dispatch('search');

@ -0,0 +1,247 @@
<template>
<div class="list-container">
<table-list
v-loading="loading"
:code="code"
:config="config"
:data="list"
:operation="['create', 'search', 'remove']"
:reset="handleReset"
title="客服"
:total="total"
@create="handleCreate()"
@remove="handleRemove"
@search="handleSearch"
>
<template #search>
<el-form inline>
<el-form-item label="所属店铺" prop="storeId">
<el-select
v-model="state.condition.storeId"
:config="{ label: 'name', value: 'id' }"
:opts="opts.store"
/>
</el-form-item>
<el-form-item label="客服ID" prop="waiterId">
<el-input v-model="state.condition.waiterId" />
</el-form-item>
<el-form-item label="客服昵称" prop="waiterNickname">
<el-input v-model="state.condition.waiterNickname" />
</el-form-item>
</el-form>
</template>
</table-list>
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '店铺'" width="480px">
<el-form
ref="refsForm"
v-loading="formState.submitting"
label-width="100px"
:model="formState.form"
:rules="formState.rules"
>
<el-form-item label="所属店铺" prop="storeId">
<el-select
v-model="formState.form.storeId"
:config="{ label: 'name', value: 'id' }"
:disabled="formState.form.id"
:opts="opts.store"
/>
</el-form-item>
<el-form-item label="客服类型" prop="type">
<el-input v-model="formState.form.type" maxlength="20" />
</el-form-item>
<el-form-item label="客服头像" prop="waiterAvatar">
<el-upload-image v-model="formState.form.waiterAvatar" config-id="im/" />
</el-form-item>
<el-form-item label="客服ID" prop="waiterId">
<el-input v-model="formState.form.waiterId" :disabled="!!formState.form.id" maxlength="20" />
</el-form-item>
<el-form-item label="客服昵称" prop="waiterNickname">
<el-input v-model="formState.form.waiterNickname" maxlength="20" />
</el-form-item>
</el-form>
<template #footer>
<el-button @click="formState.formVisible = false">取消</el-button>
<el-button :loading="formState.submitting" type="primary" @click="handleSave"></el-button>
</template>
</el-dialog>
</div>
</template>
<script setup lang="jsx">
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);
const list = computed(() => store.state.chatWaiter.list);
const total = computed(() => store.state.chatWaiter.total);
const opts = computed(() => store.state.chatWaiter.opts);
if (!unref(opts).init) {
store.dispatch('chatWaiter/load');
}
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);
}
};
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));
},
{ immediate: true, deep: true }
);
watch(
() => state.condition.storeId,
() => {
handleSearch();
}
);
onActivated(() => {
let storeId = route.query.storeId;
if (storeId) {
state.condition.storeId = +storeId;
} else {
handleSearch();
}
});
/* 表单 */
const refsForm = ref(null);
const formState = reactive({
formVisible: false,
submitting: false,
form: {
id: null,
storeId: null,
type: null,
waiterAvatar: null,
waiterId: null,
waiterNickname: null,
},
rules: {
storeId: [{ required: true, message: '所属店铺不能为空' }],
type: [{ required: true, message: '客服类型不能为空' }],
waiterAvatar: [{ required: true, message: '客服头像不能为空' }],
waiterId: [{ required: true, message: '客服ID不能为空' }],
waiterNickname: [{ required: true, message: '客服昵称不能为空' }],
},
});
// /
const handleCreate = (row) => {
Object.assign(
formState.form,
row || {
id: null,
storeId: null,
type: null,
waiterAvatar: null,
waiterId: null,
waiterNickname: null,
}
);
if (!formState.form.storeId) {
formState.form.storeId = state.condition.storeId;
}
formState.formVisible = true;
};
//
const handleSave = async () => {
formState.submitting = true;
try {
await proxy.$validate(refsForm);
let data = _.cloneDeep(formState.form);
await store.dispatch('chatWaiter/save', data);
formState.formVisible = false;
} catch (e) {
console.info('取消保存', e);
}
formState.submitting = false;
};
const handleRemove = async (rows) => {
store.dispatch('chatWaiter/remove', {
storeId: state.condition.storeId,
waiterIds: rows.map((item) => item.waiterId),
});
};
const config = reactive({
//
columns: [
{
type: 'selection',
width: 60,
},
{
label: '所属店铺',
width: 160,
slots: {
default: ({ row }) => proxy.$dict(unref(opts).store, row.storeId, { label: 'name', value: 'id' }),
},
},
{
label: '客服头像',
width: 160,
slots: {
default: ({ row }) => <ElImage src={row.waiterAvatar} alt={row.waiterNickname} />,
},
},
{
label: '客服ID',
prop: 'waiterId',
},
{
label: '客服昵称',
prop: 'waiterNickname',
},
{
label: '操作',
fixed: 'right',
slots: {
default: ({ row }) => (
<div>
<ElButton type="text" onClick={() => handleCreate(row)}>
编辑
</ElButton>
<ElButton type="text" onClick={() => handleRemove([row])}>
删除
</ElButton>
</div>
),
},
width: 120,
},
],
});
</script>
<style lang="less" scoped></style>

@ -43,9 +43,9 @@
import DateRange from './dateRange.vue'; import DateRange from './dateRange.vue';
const store = useStore(); const store = useStore();
const loading = ref(false); const loading = ref(false);
const opts = computed(() => store.state.chatStore.opts); const opts = computed(() => store.state.imStore.opts);
if (!unref(opts).init) { if (!unref(opts).init) {
store.dispatch('chatStore/load'); store.dispatch('imStore/load');
} }
const systemId = ref(null); const systemId = ref(null);
@ -58,11 +58,11 @@
}, },
{ immediate: true } { immediate: true }
); );
const online = computed(() => store.state.chatHome.online); const online = computed(() => store.state.imHome.online);
const handleLoadOnline = async () => { const handleLoadOnline = async () => {
loading.value = true; loading.value = true;
if (unref(systemId)) { if (unref(systemId)) {
await store.dispatch('chatHome/loadOnline', { systemId: unref(systemId) }); await store.dispatch('imHome/loadOnline', { systemId: unref(systemId) });
} }
loading.value = false; loading.value = false;
}; };
@ -140,10 +140,10 @@
const date1 = ref(dayjs(new Date()).format('YYYY-MM-DD')); const date1 = ref(dayjs(new Date()).format('YYYY-MM-DD'));
const handleLoadSingle = async () => { const handleLoadSingle = async () => {
loading.value = true; loading.value = true;
store.commit('chatHome/setSingle', []); store.commit('imHome/setSingle', []);
if (unref(systemId)) { if (unref(systemId)) {
if (unref(date1)) { if (unref(date1)) {
await store.dispatch('chatHome/loadSingle', { await store.dispatch('imHome/loadSingle', {
systemId: unref(systemId), systemId: unref(systemId),
days: unref(date1), days: unref(date1),
}); });
@ -154,7 +154,7 @@
watch(date1, handleLoadSingle, { immediate: true }); watch(date1, handleLoadSingle, { immediate: true });
watch(systemId, handleLoadSingle); watch(systemId, handleLoadSingle);
watch( watch(
() => store.state.chatHome.single, () => store.state.imHome.single,
(value) => { (value) => {
handleChart( handleChart(
'.chart-1', '.chart-1',
@ -174,10 +174,10 @@
const date2 = ref([]); const date2 = ref([]);
const handleLoadRange = async () => { const handleLoadRange = async () => {
loading.value = true; loading.value = true;
store.commit('chatHome/setRange', []); store.commit('imHome/setRange', []);
if (unref(systemId)) { if (unref(systemId)) {
if (unref(date2)?.length) { if (unref(date2)?.length) {
await store.dispatch('chatHome/loadRange', { await store.dispatch('imHome/loadRange', {
systemId: unref(systemId), systemId: unref(systemId),
start: unref(date2)[0], start: unref(date2)[0],
end: unref(date2)[1], end: unref(date2)[1],
@ -189,7 +189,7 @@
watch(date2, handleLoadRange); watch(date2, handleLoadRange);
watch(systemId, handleLoadRange); watch(systemId, handleLoadRange);
watch( watch(
() => store.state.chatHome.range, () => store.state.imHome.range,
(value) => { (value) => {
handleChart( handleChart(
'.chart-2', '.chart-2',

@ -64,12 +64,12 @@
const router = useRouter(); const router = useRouter();
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const loading = ref(false); const loading = ref(false);
const code = computed(() => store.state.chatStore.code); const code = computed(() => store.state.imStore.code);
const list = computed(() => store.state.chatStore.list); const list = computed(() => store.state.imStore.list);
const total = computed(() => store.state.chatStore.total); const total = computed(() => store.state.imStore.total);
const opts = computed(() => store.state.chatStore.opts); const opts = computed(() => store.state.imStore.opts);
if (!unref(opts).init) { if (!unref(opts).init) {
store.dispatch('chatStore/load'); store.dispatch('imStore/load');
} }
const state = reactive({ const state = reactive({
condition: { condition: {
@ -83,13 +83,13 @@
}; };
const handleSearch = async () => { const handleSearch = async () => {
loading.value = true; loading.value = true;
await store.dispatch('chatStore/search'); await store.dispatch('imStore/search');
loading.value = false; loading.value = false;
}; };
watch( watch(
() => state.condition, () => state.condition,
(value) => { (value) => {
store.commit('chatStore/setCondition', _.cloneDeep(value)); store.commit('imStore/setCondition', _.cloneDeep(value));
handleSearch(); handleSearch();
}, },
{ immediate: true, deep: true } { immediate: true, deep: true }
@ -139,7 +139,7 @@
try { try {
await proxy.$validate(refsForm); await proxy.$validate(refsForm);
let data = _.cloneDeep(formState.form); let data = _.cloneDeep(formState.form);
await store.dispatch('chatStore/save', data); await store.dispatch('imStore/save', data);
formState.formVisible = false; formState.formVisible = false;
} catch (e) { } catch (e) {
console.info('取消保存', e); console.info('取消保存', e);
@ -148,7 +148,7 @@
}; };
const handleRemove = async (rows) => { const handleRemove = async (rows) => {
store.dispatch( store.dispatch(
'chatStore/remove', 'imStore/remove',
rows.map((item) => item.id) rows.map((item) => item.id)
); );
}; };

@ -53,12 +53,12 @@
const router = useRouter(); const router = useRouter();
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const loading = ref(false); const loading = ref(false);
const code = computed(() => store.state.chatSystem.code); const code = computed(() => store.state.imSystem.code);
const list = computed(() => store.state.chatSystem.list); const list = computed(() => store.state.imSystem.list);
const total = computed(() => store.state.chatSystem.total); const total = computed(() => store.state.imSystem.total);
const opts = computed(() => store.state.chatSystem.opts); const opts = computed(() => store.state.imSystem.opts);
if (!unref(opts).init) { if (!unref(opts).init) {
store.dispatch('chatSystem/load'); store.dispatch('imSystem/load');
} }
const state = reactive({ const state = reactive({
condition: { condition: {
@ -68,7 +68,7 @@
watch( watch(
() => state.condition, () => state.condition,
(value) => { (value) => {
store.commit('chatSystem/setCondition', _.cloneDeep(value)); store.commit('imSystem/setCondition', _.cloneDeep(value));
}, },
{ immediate: true, deep: true } { immediate: true, deep: true }
); );
@ -79,7 +79,7 @@
}; };
const handleSearch = async () => { const handleSearch = async () => {
loading.value = true; loading.value = true;
await store.dispatch('chatSystem/search'); await store.dispatch('imSystem/search');
loading.value = false; loading.value = false;
}; };
onActivated(handleSearch); onActivated(handleSearch);
@ -117,7 +117,7 @@
try { try {
await proxy.$validate(refsForm); await proxy.$validate(refsForm);
let data = _.cloneDeep(formState.form); let data = _.cloneDeep(formState.form);
await store.dispatch('chatSystem/save', data); await store.dispatch('imSystem/save', data);
formState.formVisible = false; formState.formVisible = false;
} catch (e) { } catch (e) {
console.info('取消保存', e); console.info('取消保存', e);
@ -126,7 +126,7 @@
}; };
const handleRemove = async (rows) => { const handleRemove = async (rows) => {
store.dispatch( store.dispatch(
'chatSystem/remove', 'imSystem/remove',
rows.map((item) => item.id) rows.map((item) => item.id)
); );
}; };

@ -5,7 +5,7 @@
:code="code" :code="code"
:config="config" :config="config"
:data="list" :data="list"
:operation="['create', 'search', 'remove']" :operation="['search']"
:reset="handleReset" :reset="handleReset"
title="客服" title="客服"
:total="total" :total="total"
@ -31,7 +31,7 @@
</el-form> </el-form>
</template> </template>
</table-list> </table-list>
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '店铺'" width="480px"> <el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '客服'" width="480px">
<el-form <el-form
ref="refsForm" ref="refsForm"
v-loading="formState.submitting" v-loading="formState.submitting"
@ -69,18 +69,17 @@
</template> </template>
<script setup lang="jsx"> <script setup lang="jsx">
import ElButton from '@/components/extra/ElButton.vue';
import ElImage from '@/components/extra/ElImage.vue'; import ElImage from '@/components/extra/ElImage.vue';
const store = useStore(); const store = useStore();
const route = useRoute(); const route = useRoute();
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const loading = ref(false); const loading = ref(false);
const code = computed(() => store.state.chatWaiter.code); const code = computed(() => store.state.imWaiter.code);
const list = computed(() => store.state.chatWaiter.list); const list = computed(() => store.state.imWaiter.list);
const total = computed(() => store.state.chatWaiter.total); const total = computed(() => store.state.imWaiter.total);
const opts = computed(() => store.state.chatWaiter.opts); const opts = computed(() => store.state.imWaiter.opts);
if (!unref(opts).init) { if (!unref(opts).init) {
store.dispatch('chatWaiter/load'); store.dispatch('imWaiter/load');
} }
const state = reactive({ const state = reactive({
condition: { condition: {
@ -99,11 +98,11 @@
const handleSearch = async () => { const handleSearch = async () => {
if (state.condition.storeId) { if (state.condition.storeId) {
loading.value = true; loading.value = true;
await store.dispatch('chatWaiter/search'); await store.dispatch('imWaiter/search');
loading.value = false; loading.value = false;
} else { } else {
store.commit('chatWaiter/setList', []); store.commit('imWaiter/setList', []);
store.commit('chatWaiter/setTotal', 0); store.commit('imWaiter/setTotal', 0);
} }
}; };
watch( watch(
@ -117,7 +116,7 @@
watch( watch(
() => state.condition, () => state.condition,
(value) => { (value) => {
store.commit('chatWaiter/setCondition', _.cloneDeep(value)); store.commit('imWaiter/setCondition', _.cloneDeep(value));
}, },
{ immediate: true, deep: true } { immediate: true, deep: true }
); );
@ -181,7 +180,7 @@
try { try {
await proxy.$validate(refsForm); await proxy.$validate(refsForm);
let data = _.cloneDeep(formState.form); let data = _.cloneDeep(formState.form);
await store.dispatch('chatWaiter/save', data); await store.dispatch('imWaiter/save', data);
formState.formVisible = false; formState.formVisible = false;
} catch (e) { } catch (e) {
console.info('取消保存', e); console.info('取消保存', e);
@ -189,7 +188,7 @@
formState.submitting = false; formState.submitting = false;
}; };
const handleRemove = async (rows) => { const handleRemove = async (rows) => {
store.dispatch('chatWaiter/remove', { store.dispatch('imWaiter/remove', {
storeId: state.condition.storeId, storeId: state.condition.storeId,
waiterIds: rows.map((item) => item.waiterId), waiterIds: rows.map((item) => item.waiterId),
}); });
@ -223,23 +222,6 @@
label: '客服昵称', label: '客服昵称',
prop: 'waiterNickname', prop: 'waiterNickname',
}, },
{
label: '操作',
fixed: 'right',
slots: {
default: ({ row }) => (
<div>
<ElButton type="text" onClick={() => handleCreate(row)}>
编辑
</ElButton>
<ElButton type="text" onClick={() => handleRemove([row])}>
删除
</ElButton>
</div>
),
},
width: 120,
},
], ],
}); });
</script> </script>

Loading…
Cancel
Save