|
|
@@ -23,6 +23,7 @@
|
|
|
placeholder="请输入"
|
|
|
disabled
|
|
|
></el-input>
|
|
|
+ <!-- -->
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
@@ -55,22 +56,13 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item
|
|
|
- label="预计售后时长"
|
|
|
- prop="duration"
|
|
|
- :rules="{
|
|
|
- required: true,
|
|
|
- message: '请输入预计售后时长',
|
|
|
- trigger: 'change'
|
|
|
- }"
|
|
|
- >
|
|
|
+ <el-form-item label="预计售后时长" prop="duration">
|
|
|
<div style="display: flex">
|
|
|
<el-input
|
|
|
type="number"
|
|
|
v-model="addForm.duration"
|
|
|
size="small"
|
|
|
placeholder="请输入"
|
|
|
- min="1"
|
|
|
@input="formDataDurationTime"
|
|
|
>
|
|
|
<template #suffix>
|
|
|
@@ -133,15 +125,7 @@
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item
|
|
|
- label="紧急程度"
|
|
|
- prop="urgent"
|
|
|
- :rules="{
|
|
|
- required: true,
|
|
|
- message: '请选择紧急程度',
|
|
|
- trigger: 'change'
|
|
|
- }"
|
|
|
- >
|
|
|
+ <el-form-item label="紧急程度" prop="urgent">
|
|
|
<DictSelection
|
|
|
dictName="紧急程度"
|
|
|
clearable
|
|
|
@@ -171,17 +155,16 @@
|
|
|
</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;
|
|
|
}
|
|
|
@@ -190,156 +173,141 @@ export default {
|
|
|
return {
|
|
|
dispatchDialog: false,
|
|
|
addForm: {
|
|
|
- code: '', // 编码
|
|
|
- name: '', // 计划名称
|
|
|
- isSyncBill: 1, // 是否自动派单
|
|
|
- duration: null, // 原始时长值
|
|
|
- durationUnit: '1', // 时长单位(1:分钟 2:小时 3:天)
|
|
|
- executeGroupId: '', // 执行部门ID
|
|
|
- executeGroupName: '', // 执行部门名称
|
|
|
- executeUserId: '', // 执行人ID
|
|
|
- executeUserName: '', // 执行人名称
|
|
|
- urgent: null, // 紧急程度
|
|
|
- remark: '' // 备注
|
|
|
+ executeUserId: '',
|
|
|
+ executeGroupId: '',
|
|
|
+ name: '',
|
|
|
+ isSyncBill: 1,
|
|
|
+ durationUnit: '1',
|
|
|
+ remark: ''
|
|
|
},
|
|
|
loading: false,
|
|
|
executorList: [],
|
|
|
- submitSource: 1 // 1:新增;2:修改
|
|
|
+ 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: ''
|
|
|
+ executeUserId: ''
|
|
|
};
|
|
|
- this.$refs.addFormRef?.resetFields();
|
|
|
+ this.$refs.addFormRef.resetFields();
|
|
|
},
|
|
|
open(data, type) {
|
|
|
- this.submitSource = type === 'add' ? 1 : 2;
|
|
|
+ this.submitSource = type == 'add' ? 1 : 2;
|
|
|
this.dispatchDialog = true;
|
|
|
- submitData = { ...data }; // 深拷贝避免原数据污染
|
|
|
-
|
|
|
- const currentUser = getCurrentUser();
|
|
|
+ submitData = data;
|
|
|
+ let currentUser = getCurrentUser();
|
|
|
if (
|
|
|
this.loginChangeGroupVOList &&
|
|
|
this.loginChangeGroupVOList.length > 0
|
|
|
) {
|
|
|
- const obj = this.loginChangeGroupVOList.find(
|
|
|
- (el) => el.groupId === currentUser.currentGroupId
|
|
|
+ let obj = this.loginChangeGroupVOList.find(
|
|
|
+ (el) => el.groupId == currentUser.currentGroupId
|
|
|
);
|
|
|
this.addForm.executeGroupId = currentUser.currentGroupId || '';
|
|
|
this.searchDeptNodeClick(currentUser.currentGroupId, {
|
|
|
- name: obj?.groupName || ''
|
|
|
+ name: obj.groupName
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
- // 选择部门后获取部门人员
|
|
|
- searchDeptNodeClick(groupId, data) {
|
|
|
- if (groupId) {
|
|
|
- this.addForm.executeGroupId = groupId;
|
|
|
- this.addForm.executeGroupName = data?.name || '';
|
|
|
- // 获取部门下的人员列表
|
|
|
- this.getUserList({ groupId });
|
|
|
+ //选择部门(搜索)
|
|
|
+ searchDeptNodeClick(info, data) {
|
|
|
+ if (info) {
|
|
|
+ // 根据部门获取人员
|
|
|
+ this.addForm.executeGroupName = data.name;
|
|
|
+ const params = { groupId: info };
|
|
|
+ this.getUserList(params);
|
|
|
} else {
|
|
|
- this.addForm.executeGroupId = '';
|
|
|
- this.addForm.executeGroupName = '';
|
|
|
- this.executorList = [];
|
|
|
- this.addForm.executeUserId = '';
|
|
|
- this.addForm.executeUserName = '';
|
|
|
+ this.addForm.executeGroupId = null;
|
|
|
}
|
|
|
},
|
|
|
- // 获取部门人员列表
|
|
|
+ // 获取审核人列表、巡点检人员
|
|
|
async getUserList(params) {
|
|
|
try {
|
|
|
- const res = await getUserPage({
|
|
|
- pageNum: 1,
|
|
|
- size: -1,
|
|
|
- ...params
|
|
|
- });
|
|
|
- this.executorList = res.list || [];
|
|
|
- } catch (error) {
|
|
|
- this.executorList = [];
|
|
|
- console.error('获取人员列表失败:', error);
|
|
|
- }
|
|
|
+ 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) {
|
|
|
- if (!val) {
|
|
|
- this.addForm.executeUserName = '';
|
|
|
- return;
|
|
|
- }
|
|
|
- const user = this.executorList.find((item) => item.id === val);
|
|
|
- this.addForm.executeUserName = user?.name || '';
|
|
|
+ this.executorList.map((item) => {
|
|
|
+ if (item.id == val) {
|
|
|
+ this.addForm.executeUserName = item.name;
|
|
|
+ this.addForm.executeUserId = item.id;
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
- // 处理时长输入(去除前置0)
|
|
|
formDataDurationTime(value) {
|
|
|
- if (value && value > 0) {
|
|
|
- this.addForm.duration = Number(value.toString().replace(/^0+/, ''));
|
|
|
+ if (value > 0) {
|
|
|
+ this.addForm.duration = value.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;
|
|
|
+ this.addForm.duration = 0;
|
|
|
}
|
|
|
},
|
|
|
handleSubmit() {
|
|
|
- this.$refs.addFormRef.validate(async (valid) => {
|
|
|
+ this.$refs.addFormRef.validate((valid) => {
|
|
|
if (valid) {
|
|
|
- const submitParams = {
|
|
|
- ...submitData, // 原有基础数据
|
|
|
- workOrderExecuteUserId: this.addForm.executeUserId
|
|
|
- ? Number(this.addForm.executeUserId)
|
|
|
- : null,
|
|
|
- workOrderExecuteUserName: this.addForm.executeUserName,
|
|
|
+ // 处理预计售后时长(转换为小时)
|
|
|
+ let durationInHours = 0;
|
|
|
+ const { duration, durationUnit } = this.addForm;
|
|
|
+ if (duration && duration > 0) {
|
|
|
+ switch (durationUnit) {
|
|
|
+ case '1': // 分钟转小时
|
|
|
+ durationInHours = Math.round(duration / 60);
|
|
|
+ break;
|
|
|
+ case '2': // 小时直接使用
|
|
|
+ durationInHours = duration;
|
|
|
+ break;
|
|
|
+ case '3': // 天转小时
|
|
|
+ durationInHours = duration * 24;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ durationInHours = 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let data = {
|
|
|
+ ...submitData,
|
|
|
+ submitSource: this.submitSource,
|
|
|
+ workOrderExecuteUserId: this.addForm.executeUserId || '',
|
|
|
+ workOrderExecuteUserName: this.addForm.executeUserName || '',
|
|
|
workOrderExecuteGroupId: this.addForm.executeGroupId
|
|
|
? Number(this.addForm.executeGroupId)
|
|
|
: null,
|
|
|
- workOrderExecuteGroupName: this.addForm.executeGroupName,
|
|
|
+ workOrderExecuteGroupName: this.addForm.executeGroupName || '',
|
|
|
workOrderUrgent: this.addForm.urgent
|
|
|
? Number(this.addForm.urgent)
|
|
|
: null,
|
|
|
- workOrderRemark: this.addForm.remark,
|
|
|
- duration: this.calculateDuration(), // 转换为小时
|
|
|
- submitSource: this.submitSource
|
|
|
+ workOrderRemark: this.addForm.remark || '',
|
|
|
+ duration: durationInHours,
|
|
|
+ name: this.addForm.name,
|
|
|
+ isSyncBill: this.addForm.isSyncBill,
|
|
|
+ code: this.addForm.code
|
|
|
};
|
|
|
|
|
|
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;
|
|
|
- }
|
|
|
+ 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 {
|
|
|
- this.$message.warning('请完善表单信息');
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
@@ -354,7 +322,4 @@ export default {
|
|
|
padding-bottom: 13px;
|
|
|
}
|
|
|
}
|
|
|
-.footer {
|
|
|
- text-align: center;
|
|
|
-}
|
|
|
-</style>
|
|
|
+</style>
|