wsx 11 meses atrás
pai
commit
6ebd2f80d3

+ 3 - 1
src/views/salesServiceManagement/demandList/components/dispatchDialog.vue

@@ -100,7 +100,7 @@
         </el-col>
         <el-col :span="12">
           <el-form-item
-            label="执行人"
+            label="工单执行人"
             prop="executeUserId"
             :rules="{
               required: true,
@@ -258,6 +258,8 @@
               submitSource: this.submitSource
             };
             this.loading = true;
+            console.log(data);
+            
             demanDispatch(data)
               .then((res) => {
                 if (res) {

+ 3 - 3
src/views/salesServiceManagement/demandList/components/submitDialog.vue

@@ -4,11 +4,11 @@
     :visible.sync="auditDialog"
     title="提交"
     :close-on-click-modal="false"
-    width="25%"
+    width="30%"
     append-to-body
     @close="handleClose"
   >
-    <el-form ref="form" :model="formData" label-width="80px" style="height: 200px;">
+    <el-form ref="form" :model="formData" label-width="100px" style="height: 200px;">
       <el-form-item
         label="部门"
         prop="planExecuteGroupId"
@@ -24,7 +24,7 @@
         />
       </el-form-item>
       <el-form-item
-        label="执行人"
+        label="计划执行人"
         prop="planExecuteUserId"
         :rules="{
           required: true,

+ 183 - 6
src/views/salesServiceManagement/demandList/index.vue

@@ -34,7 +34,7 @@
             @click="openEdit(row, 'view')"
             >{{ row.code }}</el-link
           >
-        </template> 
+        </template>
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
           <el-link
@@ -77,7 +77,7 @@
               >
             </template>
           </el-popconfirm> -->
-          <el-popconfirm 
+          <el-popconfirm
             v-if="btnShow(row) && $hasPermission('eom:aftersalesdemand:close')"
             class="ele-action"
             title="确定要关闭此售后需求吗?"
@@ -101,6 +101,14 @@
               <el-dropdown-item command="handleAudit">提交</el-dropdown-item>
             </el-dropdown-menu>
           </el-dropdown> -->
+
+          <el-link
+            v-if="dispatchShow(row)"
+            type="primary"
+            :underline="false"
+            @click="dispatchFn(row)"
+            >派单</el-link
+          >
         </template>
       </ele-pro-table>
     </el-card>
@@ -167,6 +175,8 @@
       </div>
     </ele-modal> -->
     <SubmitDialog ref="submitRef" @savExit="reload" />
+
+    <dispatchDialog ref="dispatchRef" @savExit="reload" />
   </div>
 </template>
 
@@ -185,19 +195,25 @@
     deleteSalesDemand,
     auditSalesDemand,
     revokeSalesDemand,
-    closeDemand
+    closeDemand,
+    getSalesDemandById
   } from '@/api/salesServiceManagement/index.js';
   import search from './components/searchTable.vue';
   import AddDialog from './components/addDialog.vue';
   import { getByCode } from '@/api/system/dictionary-data';
   import dictMixins from '@/mixins/dictMixins';
   import SubmitDialog from './components/submitDialog.vue';
+
+  import dispatchDialog from './components/dispatchDialog.vue';
+
+  import { contactDetail } from '@/api/saleManage/contact';
   export default {
     mixins: [dictMixins],
     components: {
       search,
       AddDialog,
-      SubmitDialog
+      SubmitDialog,
+      dispatchDialog
     },
     data() {
       return {
@@ -337,7 +353,16 @@
           { label: '同意', value: 1 }
         ],
         levelData: {},
-        levelList: []
+        levelList: [],
+        contractInfo: {},
+        dispatchForm: {
+          contractInfo: {},
+          tableList: [],
+          contactInfoVOS: [],
+          faultDetailList: [],
+          associationType: '1'
+        },
+        kkform: {}
       };
     },
     computed: {
@@ -346,6 +371,12 @@
           // let flag = row.demandStatus  == 0;
           return row.demandStatus == 0;
         };
+      },
+      dispatchShow() {
+        return (row) => {
+          return !row.planStatus;
+          // console.log(row);
+        };
       }
     },
     created() {
@@ -402,7 +433,7 @@
         });
       },
       handleAudit(row) {
-        this.$refs.submitRef.open(row, 'list','列表');
+        this.$refs.submitRef.open(row, 'list', '列表');
         // this.auditDialog = true;
         // this.rowData = row;
       },
@@ -450,6 +481,152 @@
         if (command === 'handleAudit') {
           this.handleAudit(row);
         }
+      },
+      async dispatchFormFn(id) {
+        const res = await getSalesDemandById(id);
+
+        this.dispatchForm = res;
+        // detailForm = res;
+        let productDetail = res.productDetail ? res.productDetail : [];
+        let faultLevel = res.faultLevel ? String(res.faultLevel) : '';
+        let faultDetailList = res.faultDetailList ? res.faultDetailList : [];
+
+        this.$set(this.dispatchForm, 'tableList', productDetail);
+        this.$set(this.dispatchForm, 'orderCode', res.orderCode);
+        this.$set(this.dispatchForm, 'orderId', res.orderId);
+        this.$set(this.dispatchForm, 'contactInfoVOS', res.contactInfoVOS);
+        this.$set(this.dispatchForm, 'name', res.name);
+        this.$set(this.dispatchForm, 'faultLevel', faultLevel);
+        this.$set(this.dispatchForm, 'code', res.code);
+        this.$set(this.dispatchForm, 'expectedTime', res.expectedTime);
+        if (res.contactAddress) {
+          this.$set(this.dispatchForm, 'contactAddress', res.contactAddress);
+        }
+        this.contactDetail(res.contactId, 'init');
+        this.dispatchForm.associationType = res.associationType
+          ? String(res.associationType)
+          : '1';
+        this.$set(this.dispatchForm, 'faultDetailList', faultDetailList);
+        // if (faultDetailList.length > 0) {
+        //   this.isOrder = true;
+        // }
+      },
+
+      async dispatchFn(row) {
+        const res = await getSalesDemandById(row.id);
+        this.kkform = res;
+        let productDetail = res.productDetail ? res.productDetail : [];
+        let faultLevel = res.faultLevel ? String(res.faultLevel) : '';
+        let faultDetailList = res.faultDetailList ? res.faultDetailList : [];
+
+        this.$set(this.dispatchForm, 'tableList', productDetail);
+        this.$set(this.dispatchForm, 'orderCode', res.orderCode);
+        this.$set(this.dispatchForm, 'orderId', res.orderId);
+        this.$set(this.dispatchForm, 'contactInfoVOS', res.contactInfoVOS);
+        this.$set(this.dispatchForm, 'name', res.name);
+        this.$set(this.dispatchForm, 'faultLevel', faultLevel);
+        this.$set(this.dispatchForm, 'code', res.code);
+        this.$set(this.dispatchForm, 'expectedTime', res.expectedTime);
+        if (res.contactAddress) {
+          this.$set(this.dispatchForm, 'contactAddress', res.contactAddress);
+        }
+        this.contactDetail(res.contactId, 'init');
+        this.dispatchForm.associationType = res.associationType
+          ? String(res.associationType)
+          : '1';
+        this.$set(this.dispatchForm, 'faultDetailList', faultDetailList);
+
+        // await this.dispatchFormFn(row.id);
+        let pData = await this.handleParameter();
+
+        if (!pData) {
+          return;
+        }
+
+        console.log(pData);
+
+        this.$refs.dispatchRef.open(pData, 'dispatch');
+
+        // console.log(this.$refs.addDialogRef);
+      },
+      savExit() {
+
+      },
+      async contactDetail(id, type) {
+        if (!id) {
+          // this.contractInfo = {};
+          return;
+        }
+        let { base, other, linkList } = await contactDetail(id);
+        base.contactName = base.name;
+        let addressName = '';
+        if (other.addressName) {
+          addressName += other.addressName;
+        }
+        if (other.address) {
+          addressName += other.address;
+        }
+        this.$set(this.dispatchForm, 'contractInfo', base);
+      },
+      async handleParameter() {
+        let data = this.dispatchForm;
+        if (!data.contactInfoVOS?.length) {
+          this.$message.warning('联系人信息至少有1条');
+          return false;
+        }
+        try {
+          // let valid = await this.$refs.infoRef.getValidate();
+          let expectedTime = data.expectedTime
+            ? this.formatDate(data.expectedTime)
+            : '';
+          let pData = {
+            ...this.kkform,
+            name: data.name,
+            faultLevel: data.faultLevel,
+            expectedTime: expectedTime,
+            contactId: data.contractInfo.id,
+            contactCode: data.contractInfo.code,
+            contactName: data.contractInfo.name,
+            orderCode: data.orderCode,
+            orderId: data.orderId,
+            contactAddress: data.contactAddress,
+            productDetail: data.tableList.map((item) => {
+              item['produceTime'] = item['produceTime'] || null;
+              return item;
+            }),
+            contactInfoVOS: data.contactInfoVOS,
+            associationType: data.associationType
+          };
+          // 如果选的销售订单并且 没有售后对象数据
+          if (pData.associationType == '2' && pData.productDetail.length == 0) {
+            delete pData.productDetail;
+            pData.faultDetailList = data.faultDetailList;
+          }
+          if (pData.associationType == '3' && pData.productDetail.length == 0) {
+            delete pData.productDetail;
+            pData.faultDetailList = data.faultDetailList;
+          }
+          return pData;
+        } catch (err) {}
+      },
+      // 标准时间函数 ***
+      formatDate(dateString) {
+        const isStandardFormat = /^\d{4}-\d{1,2}-\d{1,2}$/.test(dateString);
+        if (isStandardFormat) {
+          return dateString;
+        }
+        try {
+          const date = new Date(dateString);
+          if (isNaN(date.getTime())) {
+            throw new Error('Invalid date');
+          }
+          const year = date.getFullYear();
+          const month = String(date.getMonth() + 1).padStart(2, '0');
+          const day = String(date.getDate()).padStart(2, '0');
+          return `${year}-${month}-${day}`;
+        } catch (error) {
+          return dateString; // 转换失败时返回原始字符串
+        }
       }
     }
   };