Просмотр исходного кода

解决售后服务bug和优化

hezhanp 7 месяцев назад
Родитель
Сommit
b6d9605291

+ 5 - 5
src/views/salesServiceManagement/components/info.vue

@@ -98,11 +98,11 @@
         <el-form-item
           label="发货单:"
           prop="orderCode"
-          :rules="{
-            required: true,
-            message: '请选择发货单',
-            trigger: 'change'
-          }"
+          :rules="
+            type !== 'view'
+              ? { required: true, message: '请选择发货单', trigger: 'change' }
+              : []
+          "
         >
           <el-input
             v-model="form.orderCode"

+ 192 - 126
src/views/salesServiceManagement/demandList/components/dispatchDialog.vue

@@ -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>

+ 28 - 25
src/views/salesServiceManagement/demandList/index.vue

@@ -42,6 +42,7 @@
             :underline="false"
             @click="openEdit(row, 'edit')"
             v-if="btnShow(row) && $hasPermission('eom:aftersalesdemand:update')"
+                
             >修改</el-link
           >
           <el-popconfirm
@@ -254,7 +255,7 @@ export default {
           label: '客户名称',
           align: 'center',
           showOverflowTooltip: true
-        }, 
+        },
         {
           slot: 'faultLevel',
           prop: 'faultLevel',
@@ -272,8 +273,10 @@ export default {
           align: 'center',
           showOverflowTooltip: true,
           formatter: (row) => {
-    return this.afterSalesTypeMap[row.afterSalesType] || row.afterSalesType;
-  }
+            return (
+              this.afterSalesTypeMap[row.afterSalesType] || row.afterSalesType
+            );
+          }
         },
         {
           prop: 'createUserName',
@@ -372,9 +375,9 @@ export default {
         associationType: '1'
       },
       kkform: {},
-      
-    afterSalesTypeMap: {}, 
-    afterSalesTypeList: [] 
+
+      afterSalesTypeMap: {},
+      afterSalesTypeList: []
     };
   },
   computed: {
@@ -395,28 +398,28 @@ export default {
     this.requestDict('报修来源');
     this.requestDict('报修状态');
     this.getLevelCode('fault_level');
-  this.getAfterSalesTypeDict();
+    this.getAfterSalesTypeDict();
   },
   methods: {
     async getAfterSalesTypeDict() {
-    try {
-      const res = await getByCode('after_sales_type');
-      if (res?.code === '0') {
-        const typeMap = {};
-        const typeList = [];
-        res.data.forEach(el => {
-          const value = Object.keys(el)[0];
-          const label = Object.values(el)[0];
-          typeMap[value] = label;
-          typeList.push({ value, label });
-        });
-        this.afterSalesTypeMap = typeMap;
-        this.afterSalesTypeList = typeList;
+      try {
+        const res = await getByCode('after_sales_type');
+        if (res?.code === '0') {
+          const typeMap = {};
+          const typeList = [];
+          res.data.forEach((el) => {
+            const value = Object.keys(el)[0];
+            const label = Object.values(el)[0];
+            typeMap[value] = label;
+            typeList.push({ value, label });
+          });
+          this.afterSalesTypeMap = typeMap;
+          this.afterSalesTypeList = typeList;
+        }
+      } catch (err) {
+        this.$message.error(`获取售后类型字典失败:${err.message}`);
       }
-    } catch (err) {
-      this.$message.error(`获取售后类型字典失败:${err.message}`);
-    }
-  },
+    },
     /* 表格数据源 */
     datasource({ page, limit, where, order }) {
       return getPageSalesDemand({ pageNum: page, size: limit, ...where });
@@ -626,7 +629,7 @@ export default {
             return item;
           }),
           contactInfoVOS: data.contactInfoVOS,
-          associationType: data.associationType,
+          associationType: data.associationType
         };
         // 如果选的销售订单并且 没有售后对象数据
         if (pData.associationType == '2' && pData.productDetail.length == 0) {

+ 1 - 2
src/views/salesServiceManagement/workOrder/index.vue

@@ -121,8 +121,6 @@
             v-if="
               acceptShow(row) &&
               $hasPermission('eom:aftersalesworkorder:checkAndAccept')
-              
-                
             "
             :underline="false"
             @click="handleCommand('checkAndAccept', row)"
@@ -617,6 +615,7 @@ export default {
     },
     //验收
     async checkAndAccept(accepterStatus) {
+      console.log(accepterStatus)
       if (!this.form.accepterUserId) {
         this.$message.warning('请选择验收人!');
         return;