feat: 接口对接

feat-im-0607-xwk
向文可 2 years ago
parent 2d80b2f2ac
commit e2f84193cd

@ -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');

@ -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);
}

@ -26,7 +26,13 @@
</template>
</table-list>
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '店铺'">
<el-form ref="refsForm" label-width="100px" :model="formState.form" :rules="formState.rules">
<el-form
ref="refsForm"
v-loading="formState.submitting"
label-width="100px"
:model="formState.form"
:rules="formState.rules"
>
<el-form-item label="所属系统" prop="sysId">
<el-select
v-model="formState.form.sysId"
@ -55,6 +61,7 @@
import ElImage from '@/components/extra/ElImage.vue';
const store = useStore();
const route = useRoute();
const router = useRouter();
const { proxy } = getCurrentInstance();
const loading = ref(false);
const code = computed(() => 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 }) => (
<div>
<ElButton type="text" onClick={() => handleCreate(row)}>
编辑
</ElButton>
<ElButton type="text" onClick={() => handleWaiter(row)}>
客服
</ElButton>
<ElButton type="text" onClick={() => handleRemove([row])}>
删除
</ElButton>
</div>
),
},
width: 120,
},
],
});

@ -16,6 +16,7 @@
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '查看' : '添加' + '系统'">
<el-form
ref="refsForm"
v-loading="formState.submitting"
:disabled="!!formState.form.id"
label-width="100px"
:model="formState.form"

@ -15,11 +15,11 @@
>
<template #search>
<el-form inline>
<el-form-item label="所属系统" prop="systemId">
<el-form-item label="所属店铺" prop="storeId">
<el-select
v-model="state.condition.systemId"
v-model="state.condition.storeId"
:config="{ label: 'name', value: 'id' }"
:opts="opts.system"
:opts="opts.store"
/>
</el-form-item>
<el-form-item label="客服ID" prop="waiterId">
@ -32,23 +32,29 @@
</template>
</table-list>
<el-dialog v-model="formState.formVisible" :title="formState.form.id ? '编辑' : '添加' + '店铺'">
<el-form ref="refsForm" label-width="100px" :model="formState.form" :rules="formState.rules">
<el-form-item label="所属系统" prop="systemId">
<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.sysId"
v-model="formState.form.storeId"
:config="{ label: 'name', value: 'id' }"
:disabled="formState.form.id"
:opts="opts.system"
:opts="opts.store"
/>
</el-form-item>
<el-form-item label="客服类型" prop="type">
<el-radio-group v-model="formState.form.type" :opts="opts.type" />
<el-input v-model="formState.form.type" />
</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" />
<el-input v-model="formState.form.waiterId" :disabled="!!formState.form.id" />
</el-form-item>
<el-form-item label="客服昵称" prop="waiterNickname">
<el-input v-model="formState.form.waiterNickname" />
@ -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' }),
},
},
{

Loading…
Cancel
Save