Files
smarthome/src/views/system/cssAgent/edit.vue
Zy 2ccce95d44 10/10
1. 设备管理界面完成
2. 用户管理界面完成
3. 会话列表完成
2026-10-10 17:02:31 +08:00

277 lines
7.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script lang="ts" setup>
import FormItemTip from "@/components/FormItemTip/index.vue";
import {getCsAgent, updateCsAgent} from "@/api/system/cssAgent";
import modal from '@/plugins/modal';
const router = useRouter();
const route = useRoute();
const form = ref({
"account": "",
"agentId": "",
"agentNo": "",
"avatarUrl": "",
"activeSessionCount": 0,
"createTime": "",
"jobNo": "",
"name": "",
"onlineStatus": "0",
"onlineStatusName": "离线",
"phone": null,
"status": "0",
"statusName": "启用",
"password": ''
})
const editForm = ref({...form.value})
const defaultImag = computed(() => {
if (form.value.avatarUrl) {
return form.value.avatarUrl
}
return import.meta.env.VITE_DEFAULT_USER_IMAGE
})
function init() {
if (route.query.id) {
getCsAgent(route.query.id as string).then(res => {
form.value = {
...form.value,
...res.data,
password: "",
}
editForm.value = JSON.parse(JSON.stringify(form.value))
})
}
}
init()
function handleBack() {
router.replace({
path: "/conversation/csAgent"
})
}
function handleSubmit() {
if (!editForm.value.account || editForm.value.account.trim() === '') {
modal.msgWarning('登录账号不能为空')
return;
}
if (!editForm.value.name || editForm.value.name.trim() === '') {
modal.msgWarning('客服姓名不能为空')
return;
}
editForm.value.phone = editForm.value.account;
updateCsAgent(editForm.value).then(() => {
handleBack()
})
}
function resetForm() {
editForm.value = JSON.parse(JSON.stringify(form.value))
}
</script>
<template>
<div class="edit">
<div class="flex justify-between" style="margin-top: 22px">
<pagecrumb></pagecrumb>
<el-button plain type="info" @click="handleBack"> 返回客服列表</el-button>
</div>
<!-- 用户信息-->
<section class="customerInfoBox commonCard flex justify-between flex-items-center">
<div class="flex infoBox">
<el-image :src="defaultImag" class="customer-Img"></el-image>
<div class="flex flex-col justify-between">
<div>
<span class="userName">{{ form.name }}</span>
<el-tag v-if="form.status === '0' " effect="light" round style="margin: 0 12px " type="success">
<div class="flex flex-items-center">
<span>启用</span></div>
</el-tag>
<el-tag v-else effect="light" round style="margin: 0 12px " type="danger">
<div class="flex flex-items-center">
<span>禁用</span></div>
</el-tag>
</div>
<div class="subInfoBox">
<span> {{ form.agentNo }} </span>
<span class="dat">·</span>
<span>工号 {{ form.account }} </span>
<span class="dat">·</span>
<span>138****6688</span>
<span class="dat">·</span>
<span>创建于 {{ form.createTime }}</span>
</div>
</div>
</div>
<div :class="{
offline:form.onlineStatus === '0'
}" class="onlineStatus">
<span>当前{{ form.onlineStatusName }}</span>
<span v-if="form.onlineStatus !== '0'">·接待中 {{ form.activeSessionCount }}</span>
</div>
</section>
<!-- form -->
<section class="commonCard">
<card-nav subTitle="工号唯一且不可重复;账号状态切换后该客服将无法登录工作台" title="客服账号信息"></card-nav>
<div class="formbox">
<el-form label-position="top">
<el-row :gutter="24">
<el-col :span="12">
<FormItemTip
v-model="editForm.jobNo"
:inputAttrs="{ placeholder: '请输入工号', disabled: true , showWordLimit:false ,maxlength:11}"
:required="true"
label="工号"
prop="jobNo"
tip="必填且全平台唯一,示例:8823"
>
<template #suffix>不可修改</template>
</FormItemTip>
</el-col>
<el-col :span="12">
<FormItemTip
v-model="editForm.name"
:inputAttrs="{ placeholder: '请输入客服姓名', disabled: false , showWordLimit:true ,maxlength:20}"
:required="true"
prop="name"
tip="必填,将在会话列表与用户端展示"
>
<template #label>
<span>客服姓名</span>
</template>
</FormItemTip>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<FormItemTip
v-model="editForm.account"
:inputAttrs="{ placeholder: '请输入登录账号', disabled: false , showWordLimit:true ,maxlength:20}"
:required="true"
prop="account"
tip="必填,手机号格式,全平台唯一,同时作为登录账号"
>
<template #label>
<span>登录账号</span>
</template>
</FormItemTip>
</el-col>
<el-col :span="12">
<FormItemTip
v-model="editForm.password"
:inputAttrs="{ placeholder: '不修改请留空', disabled: false , showWordLimit:true ,maxlength:20, minlength:8}"
:required="true"
prop="password"
tip="如需修改请重新输入,长度 8–20 位,含字母与数字"
>
<template #label>
<span>登录密码</span>
</template>
</FormItemTip>
</el-col>
</el-row>
<el-row :gutter="24">
<el-col :span="12">
<FormItemTip
v-model="editForm.status"
:inputAttrs="{ placeholder: '', disabled: false }"
:radioOptions="[
{label:'启用',value:'0'},
{label:'禁用',value:'1'},
]"
label="账号状态"
prop="status"
tip="禁用后该客服无法登录工作台,其接待中会话将转回排队"
type="radio"
>
</FormItemTip>
</el-col>
</el-row>
</el-form>
</div>
</section>
<div class="footer">
<el-button @click="resetForm">取消</el-button>
<el-button type="primary" @click="handleSubmit">保存</el-button>
</div>
</div>
</template>
<style lang="scss" scoped>
.edit {
.customerInfoBox {
.infoBox {
.customer-Img {
width: 73px;
height: 72px;
border-radius: 50%;
margin-right: 24px;
}
.userName {
height: 26px;
line-height: 26px;
font-weight: bold;
color: rgba(17, 24, 39, 1);
font-size: 22px;
}
.circle {
display: block;
width: 7px;
height: 6px;
border-radius: 3px;
margin-right: 6px;
background-color: rgba(22, 163, 74, 1);
}
}
.subInfoBox {
line-height: 20px;
color: rgba(107, 114, 128, 1);
font-size: 13px;
text-align: left;
.dat {
margin: 0 1px;
}
}
.onlineStatus {
line-height: 18px;
color: rgba(37, 99, 235, 1);
font-size: 12px;
&.offline {
color: red;
}
}
}
.subTitle {
line-height: 14px;
color: rgba(156, 163, 175, 1);
font-size: 12px;
text-align: left;
}
.formbox {
margin-top: 46px;
}
.footer {
margin-top: 27px;
text-align: right;
}
}
</style>