|
|
@@ -23,7 +23,6 @@
|
|
|
placeholder="请输入"
|
|
|
disabled
|
|
|
></el-input>
|
|
|
- <!-- -->
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
@@ -56,13 +55,22 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="预计售后时长" prop="duration">
|
|
|
+ <el-form-item
|
|
|
+ label="预计售后时长"
|
|
|
+ prop="duration"
|
|
|
+ :rules="{
|
|
|
+ required: true,
|
|
|
+ message: '请输入预计售后时长',
|
|
|
+ trigger: 'change'
|
|
|
+ }"
|
|
|
+ >
|
|
|
<div style="display: flex">
|
|
|
<el-input
|
|
|
type="number"
|
|
|
v-model="addForm.duration"
|
|
|
size="small"
|
|
|
placeholder="请输入"
|
|
|
+ min="1"
|
|
|
@input="formDataDurationTime"
|
|
|
>
|
|
|
<template #suffix>
|
|
|
@@ -125,7 +133,15 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="紧急程度" prop="urgent">
|
|
|
+ <el-form-item
|
|
|
+ label="紧急程度"
|
|
|
+ prop="urgent"
|
|
|
+ :rules="{
|
|
|
+ required: true,
|
|
|
+ message: '请选择紧急程度',
|
|
|
+ trigger: 'change'
|
|
|
+ }"
|
|
|
+ >
|
|
|
<DictSelection
|
|
|
dictName="紧急程度"
|
|
|
clearable
|
|
|
@@ -153,138 +169,188 @@
|
|
|
</div>
|
|
|
</ele-modal>
|
|
|
</template>
|
|
|
+
|
|
|
<script>
|
|
|
- import deptSelect from '@/components/CommomSelect/dept-select.vue';
|
|
|
- import { getUserPage } from '@/api/system/organization';
|
|
|
- import { getCurrentUser } from '@/utils/token-util';
|
|
|
- import { demanDispatch } from '@/api/salesServiceManagement/index';
|
|
|
- let submitData = {};
|
|
|
- export default {
|
|
|
- components: { deptSelect },
|
|
|
- computed: {
|
|
|
- // 部门下拉
|
|
|
- loginChangeGroupVOList() {
|
|
|
- return this.$store.state.user?.info?.loginChangeGroupVOList;
|
|
|
+import deptSelect from '@/components/CommomSelect/dept-select.vue';
|
|
|
+import { getUserPage } from '@/api/system/organization';
|
|
|
+import { getCurrentUser } from '@/utils/token-util';
|
|
|
+import { demanDispatch } from '@/api/salesServiceManagement/index';
|
|
|
+let submitData = {};
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: { deptSelect },
|
|
|
+ computed: {
|
|
|
+ loginChangeGroupVOList() {
|
|
|
+ return this.$store.state.user?.info?.loginChangeGroupVOList;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ dispatchDialog: false,
|
|
|
+ addForm: {
|
|
|
+ code: '', // 编码
|
|
|
+ name: '', // 计划名称
|
|
|
+ isSyncBill: 1, // 是否自动派单
|
|
|
+ duration: null, // 原始时长值
|
|
|
+ durationUnit: '1', // 时长单位(1:分钟 2:小时 3:天)
|
|
|
+ executeGroupId: '', // 执行部门ID
|
|
|
+ executeGroupName: '', // 执行部门名称
|
|
|
+ executeUserId: '', // 执行人ID
|
|
|
+ executeUserName: '', // 执行人名称
|
|
|
+ urgent: null, // 紧急程度
|
|
|
+ remark: '' // 备注
|
|
|
+ },
|
|
|
+ loading: false,
|
|
|
+ executorList: [],
|
|
|
+ submitSource: 1 // 1:新增;2:修改
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleClose() {
|
|
|
+ this.dispatchDialog = false;
|
|
|
+ this.addForm = {
|
|
|
+ code: '',
|
|
|
+ name: '',
|
|
|
+ isSyncBill: 1,
|
|
|
+ duration: null,
|
|
|
+ durationUnit: '1',
|
|
|
+ executeGroupId: '',
|
|
|
+ executeGroupName: '',
|
|
|
+ executeUserId: '',
|
|
|
+ executeUserName: '',
|
|
|
+ urgent: null,
|
|
|
+ remark: ''
|
|
|
+ };
|
|
|
+ this.$refs.addFormRef?.resetFields();
|
|
|
+ },
|
|
|
+ open(data, type) {
|
|
|
+ this.submitSource = type === 'add' ? 1 : 2;
|
|
|
+ this.dispatchDialog = true;
|
|
|
+ submitData = { ...data }; // 深拷贝避免原数据污染
|
|
|
+
|
|
|
+ const currentUser = getCurrentUser();
|
|
|
+ if (this.loginChangeGroupVOList && this.loginChangeGroupVOList.length > 0) {
|
|
|
+ const obj = this.loginChangeGroupVOList.find(
|
|
|
+ el => el.groupId === currentUser.currentGroupId
|
|
|
+ );
|
|
|
+ this.addForm.executeGroupId = currentUser.currentGroupId || '';
|
|
|
+ this.searchDeptNodeClick(currentUser.currentGroupId, {
|
|
|
+ name: obj?.groupName || ''
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
- data() {
|
|
|
- return {
|
|
|
- dispatchDialog: false,
|
|
|
- addForm: {
|
|
|
- executeUserId: '',
|
|
|
- executeGroupId: '',
|
|
|
- name: '',
|
|
|
- isSyncBill: 1,
|
|
|
- durationUnit: '1',
|
|
|
- remark: ''
|
|
|
- },
|
|
|
- loading:false,
|
|
|
- executorList: [],
|
|
|
- submitSource: 1 // 提交/派单来源(1:新增;2:修改)
|
|
|
- };
|
|
|
+ // 选择部门后获取部门人员
|
|
|
+ searchDeptNodeClick(groupId, data) {
|
|
|
+ if (groupId) {
|
|
|
+ this.addForm.executeGroupId = groupId;
|
|
|
+ this.addForm.executeGroupName = data?.name || '';
|
|
|
+ // 获取部门下的人员列表
|
|
|
+ this.getUserList({ groupId });
|
|
|
+ } else {
|
|
|
+ this.addForm.executeGroupId = '';
|
|
|
+ this.addForm.executeGroupName = '';
|
|
|
+ this.executorList = [];
|
|
|
+ this.addForm.executeUserId = '';
|
|
|
+ this.addForm.executeUserName = '';
|
|
|
+ }
|
|
|
},
|
|
|
- methods: {
|
|
|
- handleClose() {
|
|
|
- this.dispatchDialog = false;
|
|
|
- this.addForm = {
|
|
|
- executeUserId: ''
|
|
|
- };
|
|
|
- this.$refs.addFormRef.resetFields();
|
|
|
- },
|
|
|
- open(data, type) {
|
|
|
- this.submitSource = type == 'add' ? 1 : 2;
|
|
|
- this.dispatchDialog = true;
|
|
|
- submitData = data;
|
|
|
- let currentUser = getCurrentUser();
|
|
|
- if (
|
|
|
- this.loginChangeGroupVOList &&
|
|
|
- this.loginChangeGroupVOList.length > 0
|
|
|
- ) {
|
|
|
- let obj = this.loginChangeGroupVOList.find(
|
|
|
- (el) => el.groupId == currentUser.currentGroupId
|
|
|
- );
|
|
|
- this.addForm.executeGroupId = currentUser.currentGroupId || '';
|
|
|
- this.searchDeptNodeClick(currentUser.currentGroupId, {
|
|
|
- name: obj.groupName
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- //选择部门(搜索)
|
|
|
- searchDeptNodeClick(info, data) {
|
|
|
- if (info) {
|
|
|
- // 根据部门获取人员
|
|
|
- this.addForm.executeGroupName = data.name;
|
|
|
- const params = { groupId: info };
|
|
|
- this.getUserList(params);
|
|
|
- } else {
|
|
|
- this.addForm.executeGroupId = null;
|
|
|
- }
|
|
|
- },
|
|
|
- // 获取审核人列表、巡点检人员
|
|
|
- async getUserList(params) {
|
|
|
- try {
|
|
|
- let data = { pageNum: 1, size: -1 };
|
|
|
- // 如果传了参数就是获取巡点检人员数据
|
|
|
- if (params) {
|
|
|
- data = Object.assign(data, params);
|
|
|
- }
|
|
|
- const res = await getUserPage(data);
|
|
|
- if (params) {
|
|
|
- this.executorList = res.list;
|
|
|
- }
|
|
|
- } catch (error) {}
|
|
|
- },
|
|
|
- // 选择执行人
|
|
|
- changeUser(val) {
|
|
|
- this.executorList.map((item) => {
|
|
|
- if (item.id == val) {
|
|
|
- this.addForm.executeUserName = item.name;
|
|
|
- }
|
|
|
+ // 获取部门人员列表
|
|
|
+ async getUserList(params) {
|
|
|
+ try {
|
|
|
+ const res = await getUserPage({
|
|
|
+ pageNum: 1,
|
|
|
+ size: -1,
|
|
|
+ ...params
|
|
|
});
|
|
|
- },
|
|
|
- formDataDurationTime(value) {
|
|
|
- if (value > 0) {
|
|
|
- this.addForm.duration = value.replace(/^[0]+/, '');
|
|
|
+ this.executorList = res.list || [];
|
|
|
+ } catch (error) {
|
|
|
+ this.executorList = [];
|
|
|
+ console.error('获取人员列表失败:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 选择执行人
|
|
|
+ changeUser(val) {
|
|
|
+ if (!val) {
|
|
|
+ this.addForm.executeUserName = '';
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const user = this.executorList.find(item => item.id === val);
|
|
|
+ this.addForm.executeUserName = user?.name || '';
|
|
|
+ },
|
|
|
+ // 处理时长输入(去除前置0)
|
|
|
+ formDataDurationTime(value) {
|
|
|
+ if (value && value > 0) {
|
|
|
+ this.addForm.duration = Number(value.toString().replace(/^0+/, ''));
|
|
|
+ } else {
|
|
|
+ this.addForm.duration = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 转换时长为小时(后端要求)
|
|
|
+ calculateDuration() {
|
|
|
+ if (this.addForm.duration === null) return null;
|
|
|
+ const duration = Number(this.addForm.duration);
|
|
|
+ switch (this.addForm.durationUnit) {
|
|
|
+ case '1': // 分钟转小时(向上取整)
|
|
|
+ return Math.ceil(duration / 60);
|
|
|
+ case '2': // 小时直接使用
|
|
|
+ return duration;
|
|
|
+ case '3': // 天转小时
|
|
|
+ return duration * 24;
|
|
|
+ default:
|
|
|
+ return duration;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 提交表单
|
|
|
+ handleSubmit() {
|
|
|
+ this.$refs.addFormRef.validate(async (valid) => {
|
|
|
+ if (valid) {
|
|
|
+ // 构造后端要求的参数结构
|
|
|
+ const planAddPO = {
|
|
|
+ workOrderExecuteUserId: this.addForm.executeUserId ? Number(this.addForm.executeUserId) : null,
|
|
|
+ workOrderExecuteUserName: this.addForm.executeUserName,
|
|
|
+ workOrderExecuteGroupId: this.addForm.executeGroupId ? Number(this.addForm.executeGroupId) : null,
|
|
|
+ workOrderExecuteGroupName: this.addForm.executeGroupName,
|
|
|
+ workOrderUrgent: this.addForm.urgent ? Number(this.addForm.urgent) : null,
|
|
|
+ workOrderRemark: this.addForm.remark,
|
|
|
+ duration: this.calculateDuration() // 转换为小时
|
|
|
+ };
|
|
|
+
|
|
|
+ const submitParams = {
|
|
|
+ ...submitData,
|
|
|
+ planAddPO,
|
|
|
+ submitSource: this.submitSource
|
|
|
+ };
|
|
|
+
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ const res = await demanDispatch(submitParams);
|
|
|
+ if (res) {
|
|
|
+ this.$message.success('派单成功');
|
|
|
+ this.handleClose();
|
|
|
+ this.$emit('savExit');
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error('派单失败:' + (error.message || '未知错误'));
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
} else {
|
|
|
- this.addForm.duration = 0;
|
|
|
+ this.$message.warning('请完善表单信息');
|
|
|
+ return false;
|
|
|
}
|
|
|
- },
|
|
|
- handleSubmit() {
|
|
|
- this.$refs.addFormRef.validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- let data = {
|
|
|
- ...submitData,
|
|
|
- planAddPO: this.addForm,
|
|
|
- submitSource: this.submitSource
|
|
|
- };
|
|
|
- this.loading = true;
|
|
|
- console.log(data);
|
|
|
-
|
|
|
- demanDispatch(data)
|
|
|
- .then((res) => {
|
|
|
- if (res) {
|
|
|
- this.loading = false;
|
|
|
- this.$message.success('操作成功');
|
|
|
- this.handleClose();
|
|
|
- this.$emit('savExit');
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- this.loading = false;
|
|
|
- });
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
- };
|
|
|
+ }
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
- .add_form {
|
|
|
- .el-col-12 {
|
|
|
- padding-bottom: 13px;
|
|
|
- }
|
|
|
+.add_form {
|
|
|
+ .el-col-12 {
|
|
|
+ padding-bottom: 13px;
|
|
|
}
|
|
|
-</style>
|
|
|
+}
|
|
|
+.footer {
|
|
|
+ text-align: center;
|
|
|
+}
|
|
|
+</style>
|