jingshuyong 1 год назад
Родитель
Сommit
36f5354520

+ 47 - 23
src/api/salesServiceManagement/index.js

@@ -289,8 +289,6 @@ export async function accessoryDelete(data) {
   return Promise.reject(new Error(res.data.message));
 }
 
-
-
 // 故障知识库 表格
 export async function knowledgePage(data) {
   const res = await request.get('/eom/faultKnowledgeBase/page', {
@@ -304,21 +302,16 @@ export async function knowledgePage(data) {
 
 // 故障知识库 表格 新增
 export async function faultKnowledgeSave(data) {
-  const res = await request.post('/eom/faultKnowledgeBase/saveBatch',
-    data
-  );
+  const res = await request.post('/eom/faultKnowledgeBase/saveBatch', data);
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 故障知识库 表格 修改
 export async function faultKnowledgeUpdate(data) {
-  const res = await request.put('/eom/faultKnowledgeBase/update',
-    data
-  );
+  const res = await request.put('/eom/faultKnowledgeBase/update', data);
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -327,9 +320,7 @@ export async function faultKnowledgeUpdate(data) {
 
 // 故障知识库 表格 删除
 export async function faultDelete(data) {
-  const res = await request.delete('/eom/faultKnowledgeBase/delete',
-    { data }
-  );
+  const res = await request.delete('/eom/faultKnowledgeBase/delete', { data });
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -349,9 +340,7 @@ export async function recyclePage(data) {
 
 // 配件回收记录 表格 新增
 export async function recycleSave(data) {
-  const res = await request.post('/eom/afterSalesAccessoryApply/save',
-    data
-  );
+  const res = await request.post('/eom/afterSalesAccessoryApply/save', data);
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -360,9 +349,7 @@ export async function recycleSave(data) {
 
 // 配件回收记录 表格 修改
 export async function recycleUpdate(data) {
-  const res = await request.put('/eom/afterSalesAccessoryApply/update',
-    data
-  );
+  const res = await request.put('/eom/afterSalesAccessoryApply/update', data);
   if (res.data.code == 0) {
     return res.data.data;
   }
@@ -380,16 +367,15 @@ export async function recycleDetails(id) {
 
 // 配件回收记录 表格 删除
 export async function recycleDelete(data) {
-  const res = await request.delete('/eom/afterSalesAccessoryApply/delete',
-    { data }
-  );
+  const res = await request.delete('/eom/afterSalesAccessoryApply/delete', {
+    data
+  });
   if (res.data.code == 0) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
 }
 
-
 // 配件申请记录 表格 详情
 export async function spareParDetails(id) {
   const res = await request.get(`/eom/sparePartsApply/getById/${id}`);
@@ -397,4 +383,42 @@ export async function spareParDetails(id) {
     return res.data.data;
   }
   return Promise.reject(new Error(res.data.message));
-}
+}
+
+// 需求提交
+export async function demandSubmit(data) {
+  const res = await request.post('/eom/afterSalesDemand/audit', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 需求派单
+export async function demanDispatch(data) {
+  const res = await request.post('/eom/afterSalesDemand/dispatch', data);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 计划 按钮 权限
+export async function checkByPlanId(id) {
+  const res = await request.get(`/eom/afterSalesPlan/checkByPlanId/${id}`);
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
+
+// 需求 按钮 权限
+export async function checkByWorkId(id) {
+  const res = await request.get(
+    `/eom/afterSalesWorkOrder/checkByWorkId/${id}`
+  );
+  if (res.data.code == 0) {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 0 - 3
src/views/salesServiceManagement/accessory/components/accessoryDialog.vue

@@ -191,7 +191,6 @@ export default {
     init(row, type) {
       // let currentUser = JSON.parse(sessionStorage['currentUser']);
       let currentUser = getCurrentUser();
-      console.log(currentUser,'currentUser')
       this.form.receivingDeptId = currentUser.currentGroupId; // 部门id
       this.roleVOListData();
       this.addRepairNotesDialog = true;
@@ -201,11 +200,9 @@ export default {
         this.getDetail(row);
       } else {
         this.form.recipientId = currentUser.currentRoleId; // 领用人Id
-        console.log(currentUser.currentRoleId,'currentUser.currentRoleId')
         // 下拉数据 name 赋值
         this.echoData();
       }
-      console.log(this.form,'form --')
     },
     async getDetail(data) {
       const row = JSON.parse(JSON.stringify(data));

+ 36 - 2
src/views/salesServiceManagement/accessory/index.vue

@@ -37,6 +37,13 @@
             @click="openEdit(row, 'edit')"
             >修改</el-link
           >
+          <!-- <el-link
+            type="primary"
+            v-if="row.source == 0"
+            :underline="false"
+            @click="openProcess(row)"
+            >发起流程</el-link
+          > -->
           <el-popconfirm
             v-if="row.source == 0"
             class="ele-action"
@@ -52,6 +59,13 @@
         </template>
       </ele-pro-table>
     </el-card>
+    <process-submit-dialog
+      :isNotNeedProcess="false"
+      :processSubmitDialogFlag.sync="processSubmitDialogFlag"
+      v-if="processSubmitDialogFlag"
+      ref="processSubmitDialogRef"
+      @reload="reload"
+    ></process-submit-dialog>
     <!-- 新建或编辑弹窗 -->
     <accessoryDialog ref="accessoryDialog" @refresh="reload" />
   </div>
@@ -60,6 +74,8 @@
 <script>
   import search from './components/search.vue';
   import accessoryDialog from './components/accessoryDialog.vue';
+  import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
+
   import {
     accessoryPage,
     accessoryDelete
@@ -70,12 +86,14 @@
     //   mixins: [dictMixins],
     components: {
       search,
-      accessoryDialog
+      accessoryDialog,
+      processSubmitDialog
     },
     data() {
       return {
         // 加载状态
-        loading: false
+        loading: false,
+        processSubmitDialogFlag: false // 加载状态 弹窗
       };
     },
     computed: {
@@ -225,6 +243,22 @@
             this.reload();
           }
         });
+      },
+      openProcess(data) {
+        this.processSubmitDialogFlag = true;
+        this.$nextTick(() => {
+          let params = {
+            businessId: data.id,
+            businessKey: 'eom_sh_bpbj',
+            formCreateUserId: data.createUserId,
+            variables: {
+              businessCode: data.code,
+              businessName: data.receivingDeptName,
+              businessType: '申请备品备件'
+            }
+          };
+          this.$refs.processSubmitDialogRef.init(params);
+        });
       }
     }
   };

+ 18 - 7
src/views/salesServiceManagement/components/applyForSpare.vue

@@ -173,6 +173,13 @@
         >提交</el-button
       >
     </template>
+    <process-submit-dialog
+      :isNotNeedProcess="false"
+      :processSubmitDialogFlag.sync="processSubmitDialogFlag"
+      v-if="processSubmitDialogFlag"
+      ref="processSubmitDialogRef"
+      @reload="reload"
+    ></process-submit-dialog>
     <AssetsDialog
       ref="selectStockLedgerDialogRef"
       :assetType="6"
@@ -190,6 +197,8 @@
 </template>
 
 <script>
+  import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
+
   import {
     saveOrUpdateSalesWorkOrder,
     saveOrUpdateSalesPlan,
@@ -203,7 +212,8 @@
   export default {
     components: {
       AssetsDialog,
-      deptSelect
+      deptSelect,
+      processSubmitDialog
       // productList
     },
     props: {
@@ -217,6 +227,7 @@
         visible: false,
         loading: false,
         title: '配件申请单',
+         processSubmitDialogFlag: false, // 加载状态
         type: '',
         form: {
           code: '',
@@ -344,9 +355,9 @@
         }
       },
       // 使用人
-      changeUser(e){
-        let data = this.executorList.find((item)=>item.id == e);
-        this.form.userName = data.name
+      changeUser(e) {
+        let data = this.executorList.find((item) => item.id == e);
+        this.form.userName = data.name;
       },
       //选择部门(搜索)
       searchDeptNodeClick(info, data) {
@@ -394,7 +405,7 @@
         this.form = {};
         this.visible = false;
         this.executorList = [];
-         this.$refs['form'].resetFields();
+        this.$refs['form'].resetFields();
       },
       async addEquipment() {
         // const res = await parameterGetByCode({code: 'after_sales_accessory_source'});
@@ -408,8 +419,8 @@
       },
       /* 保存编辑 */
       async save() {
-        if(this.tableList.length == 0){
-          this.$message.warning('请至少添加一条配件信息')
+        if (this.tableList.length == 0) {
+          this.$message.warning('请至少添加一条配件信息');
           return;
         }
         this.$refs.form.validate(async (valid) => {

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

@@ -28,11 +28,28 @@
           prop="name"
           :rules="{
             required: true,
-            message: '请填写需求名称',
+            message: '请选择/填写需求名称',
             trigger: 'blur'
           }"
         >
-          <el-input :readonly="type == 'view'" v-model="form.name" />
+          <el-select
+            style="width: 100%"
+            :disabled="type == 'view'"
+            v-model="form.name"
+            filterable
+            allow-create
+            default-first-option
+            placeholder="请选择需求名称"
+          >
+            <el-option
+              v-for="item in demandList"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
+          <!-- <el-input :readonly="type == 'view'" v-model="form.name" /> -->
         </el-form-item>
       </el-col>
       <el-col :span="6">
@@ -496,9 +513,7 @@
   import invoiceDialog from './invoiceDialog.vue';
   export default {
     mixins: [dictMixins],
-    components: { 
-      // fileMain, 
-      parentList, invoiceDialog, PhotoList },
+    components: { parentList, invoiceDialog, PhotoList },
     computed: {
       ...mapGetters(['getDictValue']),
       bankColumns() {
@@ -888,11 +903,24 @@
       isReportDetails: {
         default: false,
         type: Boolean
+      },
+
+      demandList: {
+        type: Array,
+        default: () => []
       }
     },
     watch: {
       type(val) {
         console.log(val, 'val ---');
+      },
+
+      demandList: {
+        handler(val) {
+          this.demandList = val;
+        },
+        deep: true,
+        immediate: true
       }
     },
     data() {
@@ -1103,6 +1131,7 @@
           orderCode: '',
           orderId: ''
         };
+        this.$refs.form.resetFields();
       }
     }
   };

+ 484 - 444
src/views/salesServiceManagement/components/sparePartsList.vue

@@ -2,7 +2,7 @@
   <div class="ele-body">
     <!-- <el-card shadow="never" v-loading="loading"> -->
     <!-- 数据表格 -->
-     <!-- :rules="[]" -->
+    <!-- :rules="[]" -->
     <el-form ref="form" :model="form" label-width="100px" class="create-form">
       <ele-pro-table
         ref="tableRef2"
@@ -14,13 +14,18 @@
         height="300px"
       >
         <template v-slot:toolbar>
-          <div class="toobar" :class="buttonJud?'':'toobar_r'">
-            <el-button v-if="buttonJud" type="primary" @click="addBank">添加</el-button>
+          <div class="toobar" :class="buttonJud ? '' : 'toobar_r'">
+            <el-button v-if="buttonJud" type="primary" @click="addBank"
+              >添加</el-button
+            >
             <span class="total_price">总计: {{ totalPrice }} (元)</span>
           </div>
         </template>
         <template v-slot:typeId="scope">
-          <el-form-item style="margin-bottom: 20px" :prop="'tableList.' + scope.$index + '.typeId'">
+          <el-form-item
+            style="margin-bottom: 20px"
+            :prop="'tableList.' + scope.$index + '.typeId'"
+          >
             <el-select
               v-model="scope.row.typeId"
               placeholder="请选择"
@@ -39,7 +44,10 @@
           </el-form-item>
         </template>
         <template v-slot:code="scope">
-          <el-form-item style="margin-bottom: 20px" :prop="'tableList.' + scope.$index + '.code'">
+          <el-form-item
+            style="margin-bottom: 20px"
+            :prop="'tableList.' + scope.$index + '.code'"
+          >
             <el-input
               v-if="scope.row.typeId != 2"
               :disabled="type == 'view'"
@@ -54,7 +62,10 @@
             :prop="'tableList.' + scope.$index + '.name'"
             :rules="{
               required: true,
-              message: source == '配件回收'? '配件回收清单名称不能为空':'项目名称不能为空',
+              message:
+                source == '配件回收'
+                  ? '配件回收清单名称不能为空'
+                  : '项目名称不能为空',
               trigger: 'change'
             }"
           >
@@ -68,14 +79,13 @@
                 scope.row.isApply != 1 &&
             type == 'edit'-->
             <el-button
-              v-if="
-              chooseShow(scope)
-              "
+              v-if="chooseShow(scope)"
               size="small"
               type="primary"
               style="margin-left: 4px"
               @click.native="addEquipment(row, scope.$index)"
-            >选择</el-button>
+              >选择</el-button
+            >
           </el-form-item>
         </template>
         <template v-slot:categoryModel="scope">
@@ -89,9 +99,7 @@
               v-model="scope.row.categoryModel"
             ></el-input>
             <span v-if="scope.row.typeId == 2">
-              {{
-              scope.row.categoryModel
-              }}
+              {{ scope.row.categoryModel }}
             </span>
           </el-form-item>
         </template>
@@ -106,9 +114,7 @@
               v-model="scope.row.specification"
             ></el-input>
             <span v-if="scope.row.typeId == 2">
-              {{
-              scope.row.specification
-              }}
+              {{ scope.row.specification }}
             </span>
           </el-form-item>
         </template>
@@ -117,7 +123,10 @@
             style="margin-bottom: 20px"
             :prop="'tableList.' + scope.$index + '.content'"
           >
-            <el-input v-model="scope.row.content" :disabled="inputOperate(scope.row)"></el-input>
+            <el-input
+              v-model="scope.row.content"
+              :disabled="inputOperate(scope.row)"
+            ></el-input>
           </el-form-item>
         </template>
         <template v-slot:totalCount="scope">
@@ -127,7 +136,7 @@
           >
             <el-input
               v-model="scope.row.totalCount"
-              @input="totalCountChange(scope.$index,scope.row,'totalCount')"
+              @input="totalCountChange(scope.$index, scope.row, 'totalCount')"
               :disabled="schemeTableTool(scope.row)"
               type="number"
               :min="1"
@@ -146,9 +155,7 @@
               :disabled="type == 'view'"
             ></el-input>
             <span v-if="scope.row.typeId == 2">
-              {{
-              scope.row.measureUnit
-              }}
+              {{ scope.row.measureUnit }}
             </span>
           </el-form-item>
         </template>
@@ -159,7 +166,7 @@
           >
             <el-input
               v-model="scope.row.singlePrice"
-              @input="totalCountChange(scope.$index,scope.row,'singlePrice')"
+              @input="totalCountChange(scope.$index, scope.row, 'singlePrice')"
               :disabled="inputOperate(scope.row)"
               type="number"
               :min="0"
@@ -189,7 +196,11 @@
               ></el-option>
               <!-- :disabled="type == 'view' || scope.row.isApply == 1" -->
             </el-select>
-            <el-input v-model="scope.row.warehouseName" disabled v-else></el-input>
+            <el-input
+              v-model="scope.row.warehouseName"
+              disabled
+              v-else
+            ></el-input>
           </el-form-item>
           <el-form-item
             v-else
@@ -220,7 +231,8 @@
             icon="el-icon-delete"
             v-if="schemeOperate(row)"
             @click="del(row, $index)"
-          >删除</el-link>
+            >删除</el-link
+          >
           <!--  v-if="type != 'view' && row.isApply != 1 && source != '报工信息'" -->
         </template>
         <template v-slot:headerName="{ column }">
@@ -239,7 +251,7 @@
       classType="1"
       :is-get-inventory-total="true"
       @changeParent="confirmChoose"
-      :itemType="5"
+      itemType="5"
       :isFirstRefreshTable="true"
     ></product-list>
     <!-- <applyForSpare ref="edit" :inlet="1" /> -->
@@ -247,460 +259,488 @@
 </template>
 
 <script>
-import {
-  getWarehouseOutStock,
-  getIdWarehouseList
-} from '@/api/saleManage/saleorder';
-import { parameterGetByCode } from '@/api/main/index.js';
-import AssetsDialog from './AssetsDialog.vue';
-import productList from '@/BIZComponents/product-list.vue';
+  import {
+    getWarehouseOutStock,
+    getIdWarehouseList
+  } from '@/api/saleManage/saleorder';
+  import { parameterGetByCode } from '@/api/main/index.js';
+  import AssetsDialog from './AssetsDialog.vue';
+  import { getByCode } from '@/api/system/dictionary-data';
+  import productList from '@/BIZComponents/product-list.vue';
 
-export default {
-  components: {
-    //   applyForSpare,
-    AssetsDialog,
-    productList
-  },
-  props: {
-    type: '',
-    // 数据来源
-    source: {
-      default: '',
-      type: String
+  export default {
+    components: {
+      //   applyForSpare,
+      AssetsDialog,
+      productList
     },
-    // 表格权限操作 状态
-    state: {
-      default: '',
-      type: String
+    props: {
+      type: '',
+      // 数据来源
+      source: {
+        default: '',
+        type: String
+      },
+      // 表格权限操作 状态
+      state: {
+        default: '',
+        type: String
+      },
+      detailList: {
+        type: Array,
+        default: () => []
+      },
+      obtain: {
+        type: String,
+        default: '主数据'
+      }
     },
-    detailList: {
-      type: Array,
-      default: () => []
+    data() {
+      return {
+        loading: false,
+        form: {
+          tableList: []
+        },
+        totalPrice: 0,
+        typeIdList: [
+          // {
+          //   label: '工时',
+          //   value: '1'
+          // },
+          // {
+          //   label: '零配件',
+          //   value: '2'
+          // },
+          // {
+          //   label: '差旅费',
+          //   value: '3'
+          // }
+        ]
+      };
     },
-    obtain: {
-      type: String,
-      default: '主数据'
+    created() {
+      console.log('请求');
+      this.getLevelCode('after_sales_project');
     },
-  },
-  data() {
-    return {
-      loading: false,
-      form: {
-        tableList: []
-      },
-      totalPrice: 0,
-      typeIdList: [
-        {
-          label: '工时',
-          value: '1'
-        },
-        {
-          label: '零配件',
-          value: '2'
-        },
-        {
-          label: '差旅费',
-          value: '3'
-        }
-      ]
-    };
-  },
-  computed: {
-    columnsDetail() {
-      return [
-        {
-          columnKey: 'index',
-          label: '序号',
-          type: 'index',
-          width: 55,
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'typeId',
-          label: '项目',
-          align: 'center',
-          width: 120,
-          slot: 'typeId',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'code',
-          label: '编码',
-          align: 'center',
-          slot: 'code',
-          minWidth: 150,
-          showOverflowTooltip: true
-        },
+    computed: {
+      columnsDetail() {
+        return [
+          {
+            columnKey: 'index',
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'typeId',
+            label: '项目',
+            align: 'center',
+            width: 120,
+            slot: 'typeId',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'code',
+            label: '编码',
+            align: 'center',
+            slot: 'code',
+            minWidth: 150,
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'name',
-          label: '名称',
-          align: 'center',
-          minWidth: 250,
-          slot: 'name',
-          showOverflowTooltip: true,
-          headerSlot: 'headerName'
-        },
-        {
-          prop: 'categoryModel',
-          label: '型号',
-          width: 150,
-          align: 'center',
-          slot: 'categoryModel',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'specification',
-          width: 150,
-          label: '规格',
-          slot: 'specification',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'content',
-          minWidth: 300,
-          slot: 'content',
-          label: '详细内容',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'warehouseId',
-          minWidth: 170,
-          slot: 'warehouseId',
-          label: '仓库',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'warehouseNum',
-          minWidth: 100,
-          label: '库存',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'totalCount',
-          slot: 'totalCount',
-          width: 100,
-          label: '数量',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          prop: 'measureUnit',
-          width: 120,
-          slot: 'measureUnit',
-          label: '单位',
-          align: 'center',
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'name',
+            label: '名称',
+            align: 'center',
+            minWidth: 250,
+            slot: 'name',
+            showOverflowTooltip: true,
+            headerSlot: 'headerName'
+          },
+          {
+            prop: 'categoryModel',
+            label: '型号',
+            width: 150,
+            align: 'center',
+            slot: 'categoryModel',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'specification',
+            width: 150,
+            label: '规格',
+            slot: 'specification',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'content',
+            minWidth: 300,
+            slot: 'content',
+            label: '详细内容',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'warehouseId',
+            minWidth: 170,
+            slot: 'warehouseId',
+            label: '仓库',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'warehouseNum',
+            minWidth: 100,
+            label: '库存',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'totalCount',
+            slot: 'totalCount',
+            width: 100,
+            label: '数量',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            prop: 'measureUnit',
+            width: 120,
+            slot: 'measureUnit',
+            label: '单位',
+            align: 'center',
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'singlePrice',
-          slot: 'singlePrice',
-          width: 120,
-          label: '单价(元)',
-          align: 'center',
-          showOverflowTooltip: true
-        },
+          {
+            prop: 'singlePrice',
+            slot: 'singlePrice',
+            width: 120,
+            label: '单价(元)',
+            align: 'center',
+            showOverflowTooltip: true
+          },
 
-        {
-          prop: 'settlementPrice',
-          width: 80,
-          label: '合计(元)',
-          align: 'center',
-          showOverflowTooltip: true
-        },
-        {
-          columnKey: 'action',
-          label: '操作',
-          width: 150,
-          align: 'center',
-          resizable: false,
-          slot: 'action',
-          fixed: 'right',
-          showOverflowTooltip: true,
-          show: this.type != 'view'
-        }
-      ];
-    },
+          {
+            prop: 'settlementPrice',
+            width: 80,
+            label: '合计(元)',
+            align: 'center',
+            showOverflowTooltip: true
+          },
+          {
+            columnKey: 'action',
+            label: '操作',
+            width: 150,
+            align: 'center',
+            resizable: false,
+            slot: 'action',
+            fixed: 'right',
+            showOverflowTooltip: true,
+            show: this.type != 'view'
+          }
+        ];
+      },
+      // 选择按钮显示
+      chooseShow() {
+        return (scope) => {
+          if (this.source == '配件回收') {
+            return true;
+          }
+          // if (scope.row.demandId && this.state == '可操作') {
+          //   return false;
+          // }
+          let flag =
+            scope.row.typeId == 2 &&
+            scope.row.isApply != 1 &&
+            this.type == 'edit';
+          return flag;
+        };
+      },
 
-    // 选择按钮显示
-    chooseShow() {
-      return (scope) => {
-        if (this.source == '配件回收') {
+      // 添加 按钮显示权限
+      buttonJud() {
+        if (this.source == '派单进来') {
           return true;
         }
-        if (scope.row.demandId && this.state == '可操作') {
-          return false;
-        }
-        let flag =
-          scope.row.typeId == 2 &&
-          scope.row.isApply != 1 &&
-          this.type == 'edit';
+        let flag = this.type != 'view' && this.source != '报工信息';
         return flag;
-      };
-    },
+      },
+      // 方案列表删除权限
+      schemeOperate() {
+        return (row) => {
+          if (this.source == '配件回收') {
+            return true;
+          }
+          // if (row.demandId && this.state == '可操作') {
+          //   return false;
+          // }
+          let flag =
+            this.type != 'view' &&
+            row.isApply != 1 &&
+            this.source != '报工信息';
+          return flag;
+        };
+      },
+      // 方案表格操作权限
+      schemeTableTool() {
+        return (row) => {
+          // if (row.demandId && this.state == '可操作') {
+          //   return true;
+          // }
 
-    // 添加 按钮显示权限
-    buttonJud() {
-      if (this.source == '派单进来') {
-        return true;
+          let flag = this.type == 'view' || row.isApply == 1;
+          return flag;
+        };
+      },
+      // input输入权限
+      inputOperate() {
+        return (row) => {
+          // if (row.demandId && this.state == '可操作') {
+          //   return true;
+          // }
+          let flag = this.type == 'view' || row.isApply == 1;
+          return flag;
+        };
       }
-      let flag = this.type != 'view' && this.source != '报工信息';
-      return flag;
     },
-    // 方案列表删除权限
-    schemeOperate() {
-      return (row) => {
-        if (this.source == '配件回收') {
-          return true;
-        }
-        if (row.demandId && this.state == '可操作') {
-          return false;
-        }
-        let flag =
-          this.type != 'view' && row.isApply != 1 && this.source != '报工信息';
-        return flag;
-      };
+    watch: {
+      detailList: {
+        handler(newVal) {
+          this.form.tableList = newVal;
+        },
+        immediate: true
+      }
     },
-    // 方案表格操作权限
-    schemeTableTool() {
-      return (row) => {
-        if (row.demandId && this.state == '可操作') {
-          return true;
-        }
-
-        let flag = this.type == 'view' || row.isApply == 1;
-        return flag;
-      };
+    mounted() {
+      console.log(this.obtain, 'obtain');
+      if (this.source == '配件回收') {
+        this.typeIdList = [
+          {
+            label: '零配件',
+            value: '2'
+          }
+        ];
+      }
+      if (this.detailList.length > 0) {
+        this.form.tableList = this.detailList;
+      }
     },
-    // input输入权限
-    inputOperate() {
-      return (row) => {
-        if (row.demandId && this.state == '可操作') {
-          return true;
+    methods: {
+      init(row) {},
+      async getLevelCode(code) {
+        try {
+          const res = await getByCode(code);
+          if (res.code == 0) {
+            let list = Object.values(res.data).map((el) => {
+              let k = Object.keys(el)[0];
+              let v = Object.values(el)[0];
+              return {
+                label: v,
+                value: k
+              };
+            });
+            this.typeIdList = list;
+          }
+        } catch (err) {
+          this.$message.error(err.message);
         }
-        let flag = this.type == 'view';
-        return flag;
-      };
-    }
-  },
-  watch: {
-    detailList: {
-      handler(newVal) {
-        this.form.tableList = newVal;
       },
-      immediate: true
-    }
-  },
-  created() {},
-  mounted() {
-    console.log(this.obtain, 'obtain');
-    if (this.source == '配件回收') {
-      this.typeIdList = [
-        {
-          label: '零配件',
-          value: '2'
+      typeIdChange(row, index) {
+        let obj = {
+          typeId: row.typeId,
+          code: '',
+          name: '',
+          categoryModel: '',
+          specification: '',
+          content: '',
+          totalCount: 1,
+          measureUnit: '',
+          singlePrice: '',
+          settlementPrice: ''
+        };
+        let o = this.typeIdList.find(item=>item.value == row.typeId);
+        if(o.value != 2){
+          obj.name = o.label;
         }
-      ];
-    }
-    if (this.detailList.length > 0) {
-      this.form.tableList = this.detailList;
-    }
-  },
-  methods: {
-    init(row) {},
-    typeIdChange(row, index) {
-      this.$set(this.form.tableList, index, {
-        typeId: row.typeId,
-        code: '',
-        name: '',
-        categoryModel: '',
-        specification: '',
-        content: '',
-        totalCount: 1,
-        measureUnit: '',
-        singlePrice: '',
-        settlementPrice: ''
-      });
-    },
-    getValidate() {
-      return new Promise((resolve, reject) => {
-        this.$refs.form.validate((valid, obj) => {
-          if (obj) {
-            let messages = Object.keys(obj).map((key) => obj[key][0]);
-            if (messages.length > 0) {
-              this.$message.warning(messages[0].message);
+        this.$set(this.form.tableList, index, obj);
+      },
+      getValidate() {
+        return new Promise((resolve, reject) => {
+          this.$refs.form.validate((valid, obj) => {
+            if (obj) {
+              let messages = Object.keys(obj).map((key) => obj[key][0]);
+              if (messages.length > 0) {
+                this.$message.warning(messages[0].message);
+              }
             }
-          }
-          if (!valid) {
-            reject(false);
-          } else {
-            resolve(true);
-          }
+            if (!valid) {
+              reject(false);
+            } else {
+              resolve(true);
+            }
+          });
         });
-      });
-    },
-    addBank() {
-      this.form.tableList.push({
-        typeId: '2',
-        code: '',
-        name: '',
-        categoryModel: '',
-        specification: '',
-        content: '',
-        totalCount: 1,
-        measureUnit: '',
-        singlePrice: '',
-        settlementPrice: ''
-      });
-    },
-    async addEquipment(row, index) {
-      // const res = await parameterGetByCode({
-      //   code: 'after_sales_accessory_source'
-      // });
-      this.currentIndex = index;
-      if (this.obtain == '仓库') {
-        this.$refs.productListRef.open('', index, '0');
-      } else {
-        this.$refs.productListRef.open('', index, '1');
-      }
-    },
-    getTableValue() {
-      return this.form.tableList;
-    },
-    setTableValue(val) {
-      this.$set(this.form, 'tableList', val);
-      this.form.tableList.forEach(async (item, index) => {
-        if (item.typeId == 2) {
-          this.$set(
-            this.form.tableList[index],
-            'warehouseList',
-            await getIdWarehouseList({
-              categoryId: item.categoryId
-            })
-          );
-          if (item.warehouseId) {
+      },
+      addBank() {
+        this.form.tableList.push({
+          typeId: '2',
+          code: '',
+          name: '',
+          categoryModel: '',
+          specification: '',
+          content: '',
+          totalCount: 1,
+          measureUnit: '',
+          singlePrice: '',
+          settlementPrice: ''
+        });
+      },
+      async addEquipment(row, index) {
+        // const res = await parameterGetByCode({
+        //   code: 'after_sales_accessory_source'
+        // });
+        this.currentIndex = index;
+        if (this.obtain == '仓库') {
+          this.$refs.productListRef.open('', index, '0');
+        } else {
+          this.$refs.productListRef.open('', index, '1');
+        }
+      },
+      getTableValue() {
+        return this.form.tableList;
+      },
+      setTableValue(val) {
+        this.$set(this.form, 'tableList', val);
+        this.form.tableList.forEach(async (item, index) => {
+          if (item.typeId == 2) {
             this.$set(
               this.form.tableList[index],
-              'warehouseNum',
-              await getWarehouseOutStock({
-                warehouseId: item.warehouseId,
-                code: item.code
+              'warehouseList',
+              await getIdWarehouseList({
+                categoryId: item.categoryId
               })
             );
+            if (item.warehouseId) {
+              this.$set(
+                this.form.tableList[index],
+                'warehouseNum',
+                await getWarehouseOutStock({
+                  warehouseId: item.warehouseId,
+                  code: item.code
+                })
+              );
+            }
           }
+        });
+        // ***
+        this.calculatePrice();
+      },
+      totalCountChange(index, data, name) {
+        data[name] = data[name].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
+        let row = this.form.tableList[index];
+        if (row.totalCount && row.singlePrice) {
+          row.settlementPrice = row.totalCount * row.singlePrice;
+        } else {
+          row.settlementPrice = 0;
         }
-      });
-      // ***
-      this.calculatePrice();
-    },
-    totalCountChange(index, data, name) {
-      data[name] = data[name].replace(/[^\d]/g, '').replace(/^0+/, '') || '0';
-      let row = this.form.tableList[index];
-      if (row.totalCount && row.singlePrice) {
-        row.settlementPrice = row.totalCount * row.singlePrice;
-      } else {
-        row.settlementPrice = 0;
-      }
-      this.$set(
-        this.form.tableList[index],
-        'settlementPrice',
-        row.settlementPrice || 0
-      );
-      this.calculatePrice();
-    },
-    clearList() {
-      this.form.tableList = [];
-    },
-    // 计算汇总价格 ***
-    calculatePrice() {
-      let totlal = 0;
-      this.form.tableList.map((el) => (totlal += el.settlementPrice));
-      this.totalPrice = totlal;
-    },
-    del(row, index) {
-      this.form.tableList.splice(index, 1);
-    },
-    async confirmChoose(data) {
-      this.$set(this.form.tableList, this.currentIndex, data[0]);
-      this.$set(
-        this.form.tableList[this.currentIndex],
-        'categoryModel',
-        data[0].modelType
-      );
-      this.$set(
-        this.form.tableList[this.currentIndex],
-        'categoryId',
-        data[0].id
-      );
-      this.$set(
-        this.form.tableList[this.currentIndex],
-        'measureUnit',
-        data[0].measuringUnit
-      );
+        this.$set(
+          this.form.tableList[index],
+          'settlementPrice',
+          row.settlementPrice || 0
+        );
+        this.calculatePrice();
+      },
+      clearList() {
+        this.form.tableList = [];
+      },
+      // 计算汇总价格 ***
+      calculatePrice() {
+        let totlal = 0;
+        this.form.tableList.map((el) => (totlal += el.settlementPrice));
+        this.totalPrice = totlal;
+      },
+      del(row, index) {
+        this.form.tableList.splice(index, 1);
+      },
+      async confirmChoose(data) {
+        this.$set(this.form.tableList, this.currentIndex, data[0]);
+        this.$set(
+          this.form.tableList[this.currentIndex],
+          'categoryModel',
+          data[0].modelType
+        );
+        this.$set(
+          this.form.tableList[this.currentIndex],
+          'categoryId',
+          data[0].id
+        );
+        this.$set(
+          this.form.tableList[this.currentIndex],
+          'measureUnit',
+          data[0].measuringUnit
+        );
 
-      this.$set(
-        this.form.tableList[this.currentIndex],
-        'warehouseList',
-        await getIdWarehouseList({
-          categoryId: data[0].id
-        })
-      );
-      if (this.form.tableList[this.currentIndex]?.warehouseList?.length) {
-        this.warehouseChange(
-          this.form.tableList[this.currentIndex].warehouseList[0],
+        this.$set(
           this.form.tableList[this.currentIndex],
-          this.currentIndex
+          'warehouseList',
+          await getIdWarehouseList({
+            categoryId: data[0].id
+          })
         );
-      }
+        if (this.form.tableList[this.currentIndex]?.warehouseList?.length) {
+          this.warehouseChange(
+            this.form.tableList[this.currentIndex].warehouseList[0],
+            this.form.tableList[this.currentIndex],
+            this.currentIndex
+          );
+        }
 
-      this.$set(this.form.tableList[this.currentIndex], 'typeId', '2');
-      console.log(this.form.tableList,'----------------')
-      this.$forceUpdate();
-    },
-    async warehouseChange(item, row, index) {
-      this.$set(
-        this.form.tableList[index],
-        'warehouseName',
-        item.warehouseName
-      );
-      this.$set(this.form.tableList[index], 'warehouseId', item.warehouseId);
-      this.$set(
-        this.form.tableList[index],
-        'warehouseNum',
-        await getWarehouseOutStock({
-          warehouseId: item.warehouseId,
-          code: row.code
-        })
-      );
+        this.$set(this.form.tableList[this.currentIndex], 'typeId', '2');
+        console.log(this.form.tableList, '----------------');
+        this.$forceUpdate();
+      },
+      async warehouseChange(item, row, index) {
+        this.$set(
+          this.form.tableList[index],
+          'warehouseName',
+          item.warehouseName
+        );
+        this.$set(this.form.tableList[index], 'warehouseId', item.warehouseId);
+        this.$set(
+          this.form.tableList[index],
+          'warehouseNum',
+          await getWarehouseOutStock({
+            warehouseId: item.warehouseId,
+            code: row.code
+          })
+        );
+      }
     }
-  }
-};
+  };
 </script>
 <style lang="scss" scoped>
-:deep(.el-table__body .el-form-item__content) {
-  margin-left: 0px !important;
-}
-:deep(.el-table__body .el-form-item) {
-  margin-bottom: 0px !important;
-}
-.total_price {
-  margin-left: 24px;
-}
+  :deep(.el-table__body .el-form-item__content) {
+    margin-left: 0px !important;
+  }
+  :deep(.el-table__body .el-form-item) {
+    margin-bottom: 0px !important;
+  }
+  .total_price {
+    margin-left: 24px;
+  }
 
-.toobar {
-  display: flex;
-  align-items: center;
-  justify-content: space-between;
-  padding-right: 16px;
-}
+  .toobar {
+    display: flex;
+    align-items: center;
+    justify-content: space-between;
+    padding-right: 16px;
+  }
 
-.toobar_r {
-  justify-content: flex-end;
-}
+  .toobar_r {
+    justify-content: flex-end;
+  }
 </style>

+ 231 - 137
src/views/salesServiceManagement/demandList/components/addDialog.vue

@@ -11,165 +11,259 @@
     @close="handleClose"
   >
     <!-- :fullscreen="fullscreen" -->
-    <info ref="infoRef" :type="type"></info>
+    <info ref="infoRef" :demandList="demandList" :type="type"></info>
+    <SubmitDialog ref="submitRef" @savExit="savExit" />
+    <dispatchDialog ref="dispatchRef" @savExit="savExit" />
     <div slot="footer" class="footer">
-      <el-button type="primary" @click="submitAdd" v-if="type != 'view'">保存</el-button>
+      <el-button type="primary" @click="submitAdd" v-if="type != 'view'"
+        >保存</el-button
+      >
+      <el-button type="primary" @click="submit" v-if="type != 'view'"
+        >提交</el-button
+      >
+      <el-button type="primary" @click="dispatch" v-if="type != 'view'"
+        >派单</el-button
+      >
       <el-button @click="handleClose">返回</el-button>
     </div>
   </ele-modal>
 </template>
 
 <script>
-import { mapGetters, mapActions } from 'vuex';
+  import { mapGetters, mapActions } from 'vuex';
+  import modalTitle from '@/BIZComponents/modalTitle.vue';
+  import customerDialog from '@/views/financialManage/components/customerListDialog.vue';
+  import SubmitDialog from './submitDialog.vue';
+  import dispatchDialog from './dispatchDialog.vue';
+  import { getByCode } from '@/api/system/dictionary-data';
+  import {
+    saveSalesDemand,
+    updateSalesDemand,
+    getSalesDemandById
+  } from '@/api/salesServiceManagement/index';
 
-import modalTitle from '@/BIZComponents/modalTitle.vue';
-import customerDialog from '@/views/financialManage/components/customerListDialog.vue';
+  // import fileMain from '@/components/addDoc/index.vue';
+  import info from '@/views/salesServiceManagement/components/info.vue';
 
-import {
-  saveSalesDemand,
-  updateSalesDemand,
-  getSalesDemandById
-} from '@/api/salesServiceManagement/index';
-
-// import fileMain from '@/components/addDoc/index.vue';
-import info from '@/views/salesServiceManagement/components/info.vue';
-
-export default {
-  components: {
-    modalTitle,
-    customerDialog,
-    // fileMain,
-    info
-  },
-  watch: {},
-  computed: {
-    ...mapGetters(['getDictValue'])
-  },
-  data() {
-    return {
-      title: '新增',
-      addRepairNotesDialog: false,
-      type: 'add',
-      form: {}
-    };
-  },
-  created() {},
-  methods: {
-    // 初始化数据(父组件调用)
-    init(row, type) {
-      console.log(type,'type')
-      this.addRepairNotesDialog = true;
-      this.type = type;
-      this.title = type == 'add' ? '新增' : type == 'view' ? '详情' : '修改';
-      if (row?.id) {
-        this.getDetail(row.id);
-      } else {
-      }
+  export default {
+    components: {
+      modalTitle,
+      customerDialog,
+      // fileMain,
+      info,
+      SubmitDialog,
+      dispatchDialog
     },
-    async getDetail(id) {
-      const res = await getSalesDemandById(id);
-      this.$nextTick(() => {
-        this.$refs.infoRef.init(res);
-      });
-
-      this.form = res;
+    watch: {},
+    computed: {
+      ...mapGetters(['getDictValue'])
     },
-
-    handleClose() {
-      this.addRepairNotesDialog = false;
-      this.form = {};
-      this.$refs.infoRef.catch();
+    data() {
+      return {
+        title: '新增',
+        addRepairNotesDialog: false,
+        type: 'add',
+        form: {},
+        demandList: []
+      };
     },
-    // 标准时间函数 ***
-    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; // 转换失败时返回原始字符串
-      }
+    created() {
+      this.getLevelCode('requirement_name');
     },
-    async submitAdd() {
-      let data = this.$refs.infoRef.getValue();
-      if (!data.contactInfoVOS?.length) {
-        this.$message.warning('联系人信息至少有1条');
-        return;
-      }
-      try {
-        let valid = await this.$refs.infoRef.getValidate();
-        let expectedTime = data.expectedTime
-          ? this.formatDate(data.expectedTime)
-          : '';
-        let pData = {
-          ...this.form,
-          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
-        };
-        let requestname =
-          this.title === '新增' ? saveSalesDemand : updateSalesDemand;
-        const res = await requestname(pData);
-        if (res) {
-          this.$message.success('操作成功!');
-          this.$emit('refresh');
-          this.handleClose();
+    methods: {
+      // 初始化数据(父组件调用)
+      init(row, type) {
+        console.log(type, 'type');
+        this.addRepairNotesDialog = true;
+        this.type = type;
+        this.title = type == 'add' ? '新增' : type == 'view' ? '详情' : '修改';
+        if (row?.id) {
+          this.getDetail(row.id);
+        } else {
+        }
+      },
+      //
+      async getLevelCode(code) {
+        try {
+          const res = await getByCode(code);
+          if (res.code == 0) {
+            let list = Object.values(res.data).map((el) => {
+              let k = Object.keys(el)[0];
+              let v = Object.values(el)[0];
+              return {
+                label: v,
+                value: k
+              };
+            });
+            this.demandList = list;
+          }
+        } catch (err) {
+          this.$message.error(err.message);
         }
-      } catch (error) {}
+      },
+      // 提交
+      async submit() {
+        let pData = await this.handleParameter();
+        if (!pData) {
+          return;
+        }
+        this.$refs.submitRef.open(pData, this.type);
+      },
+      // 派单
+      async dispatch() {
+        let pData = await this.handleParameter();
+        if (!pData) {
+          return;
+        }
+        this.$refs.dispatchRef.open(pData, this.type);
+      },
+      async getDetail(id) {
+        const res = await getSalesDemandById(id);
+        this.$nextTick(() => {
+          this.$refs.infoRef.init(res);
+        });
+
+        this.form = res;
+      },
+
+      handleClose() {
+        this.addRepairNotesDialog = false;
+        this.form = {};
+        this.$refs.infoRef.catch();
+      },
+      // 标准时间函数 ***
+      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; // 转换失败时返回原始字符串
+        }
+      },
+      // 提取公共 参数
+      async handleParameter() {
+        let data = this.$refs.infoRef.getValue();
+        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.form,
+            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
+          };
+          return pData;
+        } catch (err) {}
+      },
+      savExit() {
+        console.log('执行')
+        this.$emit('refresh');
+        this.handleClose();
+      },
+      // 保存
+      async submitAdd() {
+        // let data = this.$refs.infoRef.getValue();
+        // if (!data.contactInfoVOS?.length) {
+        //   this.$message.warning('联系人信息至少有1条');
+        //   return;
+        // }
+        try {
+          let pData = await this.handleParameter();
+          console.log(pData, 'pData +++');
+          if (!pData) {
+            return;
+          }
+          // let valid = await this.$refs.infoRef.getValidate();
+          // let expectedTime = data.expectedTime
+          //   ? this.formatDate(data.expectedTime)
+          //   : '';
+          // let pData = {
+          //   ...this.form,
+          //   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
+          // };
+          let requestname =
+            this.title === '新增' ? saveSalesDemand : updateSalesDemand;
+          const res = await requestname(pData);
+          if (res) {
+            this.$message.success('操作成功!');
+            this.$emit('refresh');
+            this.handleClose();
+          }
+        } catch (error) {}
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.dialog_top {
-  margin-bottom: 10px;
-  display: flex;
-  align-items: center;
+  .dialog_top {
+    margin-bottom: 10px;
+    display: flex;
+    align-items: center;
 
-  span {
-    margin-left: 50px;
-  }
+    span {
+      margin-left: 50px;
+    }
 
-  .name {
-    font-weight: 800;
-    color: #40a9ff;
+    .name {
+      font-weight: 800;
+      color: #40a9ff;
+    }
   }
-}
 
-::v-deep .el-row {
-  display: flex;
-  flex-wrap: wrap;
-}
+  ::v-deep .el-row {
+    display: flex;
+    flex-wrap: wrap;
+  }
 
-.btns {
-  text-align: right;
-  // margin: 10px 0;
-}
+  .btns {
+    text-align: right;
+    // margin: 10px 0;
+  }
 
-.main_container {
-  width: 100%;
-  display: flex;
-  justify-content: space-between;
-}
+  .main_container {
+    width: 100%;
+    display: flex;
+    justify-content: space-between;
+  }
 </style>

+ 283 - 0
src/views/salesServiceManagement/demandList/components/dispatchDialog.vue

@@ -0,0 +1,283 @@
+<template>
+  <ele-modal
+    :centered="true"
+    :visible.sync="dispatchDialog"
+    title="派单"
+    :close-on-click-modal="false"
+    width="1000px"
+    append-to-body
+    @close="handleClose"
+  >
+    <el-form
+      ref="addFormRef"
+      :model="addForm"
+      label-width="120px"
+      class="add_form"
+    >
+      <el-row>
+        <el-col :span="12">
+          <el-form-item label="编码" prop="code">
+            <el-input
+              v-model="addForm.code"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
+            <!--  -->
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item
+            label="计划名称"
+            prop="name"
+            :rules="{
+              required: true,
+              message: '请输入计划名称',
+              trigger: 'change'
+            }"
+          >
+            <el-input
+              v-model="addForm.name"
+              size="small"
+              placeholder="请输入"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="自动派单" prop="isSyncBill">
+            <el-select
+              v-model="addForm.isSyncBill"
+              size="small"
+              style="width: 100%"
+            >
+              <el-option :value="1" label="是"></el-option>
+              <el-option :value="0" label="否"></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="预计售后时长" prop="duration">
+            <div style="display: flex">
+              <el-input
+                type="number"
+                v-model="addForm.duration"
+                size="small"
+                placeholder="请输入"
+                @input="formDataDurationTime"
+              >
+                <template #suffix>
+                  <el-select
+                    v-model="addForm.durationUnit"
+                    size="small"
+                    style="width: 120px"
+                  >
+                    <el-option :value="'1'" label="分钟"></el-option>
+                    <el-option :value="'2'" label="小时"></el-option>
+                    <el-option :value="'3'" label="天"></el-option>
+                  </el-select>
+                </template>
+              </el-input>
+            </div>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row>
+        <el-col :span="12">
+          <el-form-item
+            label="部门"
+            prop="executeGroupId"
+            :rules="{
+              required: true,
+              message: '请选择部门',
+              trigger: 'change'
+            }"
+          >
+            <deptSelect
+              v-model="addForm.executeGroupId"
+              @changeGroup="searchDeptNodeClick"
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item
+            label="执行人"
+            prop="executeUserId"
+            :rules="{
+              required: true,
+              message: '请选择执行人',
+              trigger: 'change'
+            }"
+          >
+            <el-select
+              v-model="addForm.executeUserId"
+              size="small"
+              style="width: 100%"
+              filterable
+              @change="changeUser"
+            >
+              <el-option
+                v-for="item in executorList"
+                :key="item.id"
+                :value="item.id"
+                :label="item.name"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="紧急程度" prop="urgent">
+            <DictSelection
+              dictName="紧急程度"
+              clearable
+              v-model="addForm.urgent"
+            ></DictSelection>
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="备注" prop="remark">
+            <el-input
+              type="textarea"
+              resize="none"
+              v-model="addForm.remark"
+              :rows="2"
+              placeholder="请详细说明"
+              size="small"
+            ></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <div slot="footer" class="footer">
+      <el-button type="primary" @click="handleSubmit">确认</el-button>
+      <el-button @click="handleClose">取消</el-button>
+    </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;
+      }
+    },
+    data() {
+      return {
+        dispatchDialog: false,
+        addForm: {
+          executeUserId: '',
+          executeGroupId: '',
+          name: '',
+          isSyncBill: 1,
+          durationUnit: '1',
+          remark: ''
+        },
+        executorList: [],
+        submitSource: 1 // 提交/派单来源(1:新增;2:修改)
+      };
+    },
+    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;
+          }
+        });
+      },
+      formDataDurationTime(value) {
+        if (value > 0) {
+          this.addForm.duration = value.replace(/^[0]+/, '');
+        } else {
+          this.addForm.duration = 0;
+        }
+      },
+      handleSubmit() {
+        this.$refs.addFormRef.validate((valid) => {
+          if (valid) {
+            let data = {
+              ...submitData,
+              planAddPO: this.addForm,
+              submitSource: this.submitSource
+            };
+            demanDispatch(data).then((res) => {
+              if (res) {
+                this.$message.success('操作成功');
+                this.handleClose();
+                this.$emit('savExit');
+              }
+            }).catch((err)=>{
+
+            })
+          } else {
+            return false;
+          }
+        });
+      }
+    }
+  };
+</script>
+
+<style scoped lang="scss">
+  .add_form {
+    .el-col-12 {
+      padding-bottom: 13px;
+    }
+  }
+</style>

+ 171 - 0
src/views/salesServiceManagement/demandList/components/submitDialog.vue

@@ -0,0 +1,171 @@
+<template>
+  <ele-modal
+    :centered="true"
+    :visible.sync="auditDialog"
+    title="提交"
+    :close-on-click-modal="false"
+    width="25%"
+    append-to-body
+    @close="handleClose"
+  >
+    <el-form ref="form" :model="formData" label-width="80px">
+      <el-form-item
+        label="部门"
+        prop="planExecuteGroupId"
+        :rules="{
+          required: true,
+          message: '请选择部门',
+          trigger: 'change'
+        }"
+      >
+        <deptSelect
+          v-model="formData.planExecuteGroupId"
+          @changeGroup="searchDeptNodeClick"
+        />
+      </el-form-item>
+      <el-form-item
+        label="执行人"
+        prop="planExecuteUserId"
+        :rules="{
+          required: true,
+          message: '请选择执行人',
+          trigger: 'change'
+        }"
+      >
+        <el-select
+          v-model="formData.planExecuteUserId"
+          size="small"
+          style="width: 100%"
+          filterable
+          @change="changeUser"
+        >
+          <el-option
+            v-for="item in executorList"
+            :key="item.id"
+            :value="item.id"
+            :label="item.name"
+          ></el-option>
+        </el-select>
+      </el-form-item>
+    </el-form>
+    <div slot="footer" class="footer">
+      <el-button type="primary" @click="handleSubmit">确认</el-button>
+      <el-button @click="handleClose">取消</el-button>
+    </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 { demandSubmit } from '@/api/salesServiceManagement/index';
+  let submitData = {};
+  export default {
+    components: { deptSelect },
+    computed: {
+      // 部门下拉
+      loginChangeGroupVOList() {
+        return this.$store.state.user?.info?.loginChangeGroupVOList;
+      }
+    },
+    data() {
+      return {
+        auditDialog: false,
+        formData: {
+          planExecuteUserId: '',
+          planExecuteGroupId: ''
+        },
+        executorList: [],
+        submitSource: 1 // 提交/派单来源(1:新增;2:修改) none( 不需要这个字段 )
+      };
+    },
+    methods: {
+      handleClose() {
+        this.auditDialog = false;
+        this.formData = {
+          planExecuteUserId: ''
+        };
+        this.$refs.form.resetFields();
+      },
+      open(data, type) {
+        this.submitSource = type == 'add' ? 1 : type == 'edit' ? 2 : 'none';
+        this.auditDialog = true;
+        submitData = data;
+        let currentUser = getCurrentUser();
+        console.log(currentUser, 'currentUser 123');
+        if (
+          this.loginChangeGroupVOList &&
+          this.loginChangeGroupVOList.length > 0
+        ) {
+          let obj = this.loginChangeGroupVOList.find(
+            (el) => el.groupId == currentUser.currentGroupId
+          );
+          this.formData.planExecuteGroupId = currentUser.currentGroupId || '';
+          this.searchDeptNodeClick(currentUser.currentGroupId, {
+            name: obj.groupName
+          });
+        }
+      },
+      //选择部门(搜索)
+      searchDeptNodeClick(info, data) {
+        console.log(info, 'info');
+        console.log(data, 'data data +++');
+        if (info) {
+          // 根据部门获取人员
+          this.formData.planExecuteGroupName = data.name;
+          const params = { groupId: info };
+          this.getUserList(params);
+        } else {
+          this.formData.planExecuteGroupId = 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.formData.planExecuteUserName = item.name;
+          }
+        });
+      },
+      handleSubmit() {
+        this.$refs.form.validate((valid) => {
+          if (valid) {
+            let data = {
+              ...submitData,
+              ...this.formData,
+              submitSource: this.submitSource
+            };
+            if (this.submitSource == 'none') {
+              delete data.submitSource;
+            }
+            demandSubmit(data)
+              .then((res) => {
+                if (res) {
+                  this.$message.success('操作成功');
+                  this.handleClose();
+                  this.$emit('savExit');
+                }
+              })
+              .catch((err) => {});
+          } else {
+            return false;
+          }
+        });
+      }
+    }
+  };
+</script>

+ 80 - 50
src/views/salesServiceManagement/demandList/index.vue

@@ -1,7 +1,11 @@
 <template>
   <div class="ele-body">
     <el-card shadow="never" v-loading="loading">
-      <search class="seep-search" :levelList="levelList" @search="reload"></search>
+      <search
+        class="seep-search"
+        :levelList="levelList"
+        @search="reload"
+      ></search>
       <!-- 数据表格 -->
       <ele-pro-table
         ref="table"
@@ -51,8 +55,29 @@
               >
             </template>
           </el-popconfirm>
+          <el-link
+            type="primary"
+            :underline="false"
+            @click="handleCommand('handleAudit', row)"
+            v-if="row.demandStatus != 1"
+            >提交</el-link
+          >
+          <el-popconfirm
+            v-if="row.demandStatus == 1"
+            class="ele-action"
+            title="确定要撤回此售后需求吗?"
+            @confirm="handleCommand('handleRevoke', row)"
+          >
+            <template v-slot:reference>
+              <el-link
+                type="primary"
+                :underline="false"
+                >撤回</el-link
+              >
+            </template>
+          </el-popconfirm>
 
-          <el-dropdown
+          <!-- <el-dropdown
             @command="(command) => handleCommand(command, row)"
             v-if="row.demandStatus == 0"
           >
@@ -64,7 +89,7 @@
               <el-dropdown-item command="handleRevoke">撤回</el-dropdown-item>
               <el-dropdown-item command="handleAudit">提交</el-dropdown-item>
             </el-dropdown-menu>
-          </el-dropdown>
+          </el-dropdown> -->
         </template>
       </ele-pro-table>
     </el-card>
@@ -76,7 +101,7 @@
       @refresh="reload"
     />
     <!-- 审核弹窗 -->
-    <ele-modal
+    <!-- <ele-modal
       :centered="true"
       :visible.sync="auditDialog"
       title="审核"
@@ -129,7 +154,8 @@
         <el-button type="primary" @click="handleSubmit">确认</el-button>
         <el-button @click="handleClose">取消</el-button>
       </div>
-    </ele-modal>
+    </ele-modal> -->
+    <SubmitDialog ref="submitRef" @savExit="reload" />
   </div>
 </template>
 
@@ -144,11 +170,13 @@
   import AddDialog from './components/addDialog.vue';
   import { getByCode } from '@/api/system/dictionary-data';
   import dictMixins from '@/mixins/dictMixins';
+  import SubmitDialog from './components/submitDialog.vue';
   export default {
     mixins: [dictMixins],
     components: {
       search,
-      AddDialog
+      AddDialog,
+      SubmitDialog
     },
     data() {
       return {
@@ -208,21 +236,21 @@
               return this.$util.toDateString(cellValue);
             }
           },
-          {
-            prop: 'approvalUserName',
-            label: '审核人',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'approvalTime',
-            label: '审核时间',
-            align: 'center',
-            showOverflowTooltip: true,
-            formatter: (_row, _column, cellValue) => {
-              return this.$util.toDateString(cellValue);
-            }
-          },
+          // {
+          //   prop: 'approvalUserName',
+          //   label: '审核人',
+          //   align: 'center',
+          //   showOverflowTooltip: true
+          // },
+          // {
+          //   prop: 'approvalTime',
+          //   label: '审核时间',
+          //   align: 'center',
+          //   showOverflowTooltip: true,
+          //   formatter: (_row, _column, cellValue) => {
+          //     return this.$util.toDateString(cellValue);
+          //   }
+          // },
           {
             prop: 'demandStatus',
             label: '状态',
@@ -230,11 +258,11 @@
             showOverflowTooltip: true,
             formatter: (_row, _column, cellValue) => {
               return cellValue == 0
-                ? '待审核'
+                ? '待提交'
                 : cellValue == 2
                 ? '已拒绝'
                 : cellValue == 1
-                ? '已通过'
+                ? '已提交'
                 : cellValue == 3
                 ? '已撤回'
                 : '';
@@ -255,7 +283,7 @@
         infoData: {},
         repairInfoLogs: [],
         addDialogTitle: '新建售后需求',
-        auditDialog: false,
+        // auditDialog: false,
 
         rowData: {},
         formData: {
@@ -326,34 +354,36 @@
           this.reload();
         });
       },
-      async handleAudit(row) {
-        this.auditDialog = true;
-        this.rowData = row;
+      handleAudit(row) {
+        console.log(this.$refs, '12345');
+        this.$refs.submitRef.open(row, 'edit');
+        // this.auditDialog = true;
+        // this.rowData = row;
       },
-      handleClose() {
-        this.auditDialog = false;
-      },
-      async handleSubmit() {
-        this.$refs.form.validate(async (valid) => {
-          if (valid) {
-            const data = this.$store.state.user.info;
+      // handleClose() {
+      //   this.auditDialog = false;
+      // },
+      // async handleSubmit() {
+      //   this.$refs.form.validate(async (valid) => {
+      //     if (valid) {
+      //       const data = this.$store.state.user.info;
 
-            let pdata = {
-              id: this.rowData.id,
-              approvalResult: this.formData.approvalResult,
-              rejectCause: this.formData.rejectCause,
-              approvalUserId: data.userId,
-              approvalUserName: data.name
-            };
-            const res = await auditSalesDemand(pdata);
-            if (res) {
-              this.$message.success('审核成功!');
-              this.auditDialog = false;
-              this.reload();
-            }
-          }
-        });
-      },
+      //       let pdata = {
+      //         id: this.rowData.id,
+      //         approvalResult: this.formData.approvalResult,
+      //         rejectCause: this.formData.rejectCause,
+      //         approvalUserId: data.userId,
+      //         approvalUserName: data.name
+      //       };
+      //       const res = await auditSalesDemand(pdata);
+      //       if (res) {
+      //         this.$message.success('审核成功!');
+      //         this.auditDialog = false;
+      //         this.reload();
+      //       }
+      //     }
+      //   });
+      // },
       async handleRevoke(row) {
         const res = await revokeSalesDemand({ id: row.id });
         if (!res) return;

+ 261 - 202
src/views/salesServiceManagement/toDoList/components/addOrUpdateDialog.vue

@@ -9,11 +9,21 @@
     @close="handleClose"
   >
     <header-title title="计划基本信息"></header-title>
-    <el-form ref="addFormRef" :model="addForm" :rules="addFormRules" label-width="120px">
+    <el-form
+      ref="addFormRef"
+      :model="addForm"
+      :rules="addFormRules"
+      label-width="120px"
+    >
       <el-row>
         <el-col :span="6">
           <el-form-item label="编码" prop="code">
-            <el-input v-model="addForm.code" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="addForm.code"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
             <!-- :disabled="type == 'view'" -->
           </el-form-item>
         </el-col>
@@ -150,12 +160,28 @@
     <div class="ele-body-custom">
       <el-tabs v-model="activeName" style="width: 100%" type="border-card">
         <el-tab-pane label="需求信息" name="需求信息">
-          <info ref="infoRef" v-if="operationalState" type="view" :isPurchaseNeed="false"></info>
-          <info ref="infoRef" v-else source="售后计划" type="view" state="可操作" :isPurchaseNeed="false"></info>
+          <info
+            ref="infoRef"
+            v-if="operationalState"
+            type="view"
+            :isPurchaseNeed="false"
+          ></info>
+          <info
+            ref="infoRef"
+            v-else
+            source="售后计划"
+            type="view"
+            state="可操作"
+            :isPurchaseNeed="false"
+          ></info>
         </el-tab-pane>
         <el-tab-pane label="方案" name="方案">
           <!-- :type="type" -->
-          <spareParts obtain="仓库" ref="sparePartsRef" :type="title=='详情'?'view':'edit'"></spareParts>
+          <spareParts
+            obtain="仓库"
+            ref="sparePartsRef"
+            :type="title == '详情' ? 'view' : 'edit'"
+          ></spareParts>
         </el-tab-pane>
       </el-tabs>
     </div>
@@ -165,229 +191,262 @@
 
     <template v-slot:footer>
       <el-button @click="handleClose">取消</el-button>
-      <el-button type="primary" @click="save('')" v-if="type != 'view'">保存</el-button>
-      <el-button type="primary" @click="save('派单')" v-if="type == 'edit'">派单</el-button>
-      <el-button type="primary" @click="save('')" v-if="isDispatch">派单</el-button>
+      <el-button type="primary" @click="save('')" v-if="type != 'view'"
+        >保存</el-button
+      >
+      <el-button type="primary" @click="save('派单')" v-if="type == 'edit'"
+        >派单</el-button
+      >
+      <el-button type="primary" @click="save('')" v-if="isDispatch"
+        >派单</el-button
+      >
     </template>
   </ele-modal>
 </template>
 
 <script>
-import {
-  getSalesPlanById,
-  updateSalesPlan,
-  dispatchOrders
-} from '@/api/salesServiceManagement/index';
-import { contactDetail } from '@/api/saleManage/contact';
-import { getUserPage } from '@/api/system/organization';
-
-import deptSelect from '@/components/CommomSelect/dept-select.vue';
-// import fileMain from '@/components/addDoc/index.vue';
-import spareParts from '@/views/salesServiceManagement/components/sparePartsList.vue';
-import info from '@/views/salesServiceManagement/components/info.vue';
+  import {
+    getSalesPlanById,
+    updateSalesPlan,
+    dispatchOrders
+  } from '@/api/salesServiceManagement/index';
+  import { contactDetail } from '@/api/saleManage/contact';
+  import { getUserPage } from '@/api/system/organization';
 
-import { mapGetters } from 'vuex';
-let def = {
-  name: '',
-  isSyncBill: 1,
-  duration: null,
-  executeGroupId: '',
-  executeGroupName: '',
-  executeUserId: '',
-  executeUserName: '',
-  urgent: null,
-  remark: '',
-  durationUnit: '2'
-};
-export default {
-  components: {
-    deptSelect,
-    // fileMain,
-    spareParts,
-    info
-  },
+  import deptSelect from '@/components/CommomSelect/dept-select.vue';
+  // import fileMain from '@/components/addDoc/index.vue';
+  import spareParts from '@/views/salesServiceManagement/components/sparePartsList.vue';
+  import info from '@/views/salesServiceManagement/components/info.vue';
+  import { getCurrentUser } from '@/utils/token-util';
+  import { mapGetters } from 'vuex';
+  let def = {
+    name: '',
+    isSyncBill: 1,
+    duration: null,
+    executeGroupId: '',
+    executeGroupName: '',
+    executeUserId: '',
+    executeUserName: '',
+    urgent: null,
+    remark: '',
+    durationUnit: '2'
+  };
+  export default {
+    components: {
+      deptSelect,
+      // fileMain,
+      spareParts,
+      info
+    },
 
-  props: {},
-  data() {
-    return {
-      activeName: '需求信息',
-      addForm: {
-        ...def
-      },
-      executorList: [], // 业务人员列表
-      // 表单验证规则
-      addFormRules: {},
-      visible: false,
+    props: {},
+    data() {
+      return {
+        activeName: '需求信息',
+        addForm: {
+          ...def
+        },
+        executorList: [], // 业务人员列表
+        // 表单验证规则
+        addFormRules: {},
+        visible: false,
 
-      statusList: [
-        { label: '草稿', value: -1 },
-        { label: '失效', value: 0 },
-        { label: '生效', value: 1 }
-      ],
+        statusList: [
+          { label: '草稿', value: -1 },
+          { label: '失效', value: 0 },
+          { label: '生效', value: 1 }
+        ],
 
-      // 提交状态
-      loading: false,
-      type: 'add',
-      title: '',
-      isDispatch: false,
-      detailList: []
-    };
-  },
-  computed: {
-    ...mapGetters(['getDictValue']),
-    // 是否开启响应式布局
-    styleResponsive() {
-      return this.$store.state.theme.styleResponsive;
-    },
-    // 需求信息操作状态
-    operationalState() {
-      if (this.title == '派单') {
-        return false;
-      }
-      let flag = this.type == 'view';
-      return flag;
-    }
-  },
-  watch: {},
-  methods: {
-    handleClose() {
-      this.addForm = { ...def };
-      this.visible = false;
-      this.$refs.addFormRef.resetFields();
-    },
-    // 初始化
-    async init(row, type, isDispatch) {
-      this.type = type;
-      this.title = isDispatch ? '派单' : type == 'view' ? '详情' : '修改';
-      this.isDispatch = isDispatch;
-      if (row) {
-        this.visible = true;
-        this.getInfo(row.id);
-        if (row.executeGroupId) {
-          this.getUserList({ groupId: row.executeGroupId });
-        }
-      }
+        // 提交状态
+        loading: false,
+        type: 'add',
+        title: '',
+        isDispatch: false,
+        detailList: []
+      };
     },
 
-    formDataDurationTime(value) {
-      if (value > 0) {
-        this.addForm.duration = value.replace(/^[0]+/, '');
-      } else {
-        this.addForm.duration = 0;
-      }
-    },
-    //选择部门(搜索)
-    searchDeptNodeClick(info, data) {
-      if (info) {
-        // 根据部门获取人员
-        this.addForm.executeGroupName = data.name;
-        const params = { groupId: info };
-        this.getUserList(params);
-      } else {
-        this.addForm.executeGroupId = null;
+    computed: {
+      ...mapGetters(['getDictValue']),
+      // 是否开启响应式布局
+      styleResponsive() {
+        return this.$store.state.theme.styleResponsive;
+      },
+      // 需求信息操作状态
+      operationalState() {
+        if (this.title == '派单') {
+          return false;
+        }
+        let flag = this.type == 'view';
+        return flag;
+      },
+      // 部门下拉
+      loginChangeGroupVOList() {
+        return this.$store.state.user?.info?.loginChangeGroupVOList;
       }
     },
-    // 获取审核人列表、巡点检人员
-    async getUserList(params) {
-      try {
-        let data = { pageNum: 1, size: -1 };
-        // 如果传了参数就是获取巡点检人员数据
-        if (params) {
-          data = Object.assign(data, params);
+    watch: {},
+    methods: {
+      handleClose() {
+        this.addForm = { ...def };
+        this.visible = false;
+        this.$refs.addFormRef.resetFields();
+      },
+      // 默认部门
+      departmentAss() {
+        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
+          });
         }
-        const res = await getUserPage(data);
-        if (params) {
-          this.executorList = res.list;
+      },
+      // 初始化
+      async init(row, type, isDispatch) {
+        this.type = type;
+        this.title = isDispatch ? '派单' : type == 'view' ? '详情' : '修改';
+        this.isDispatch = isDispatch;
+        if (row) {
+          this.visible = true;
+          this.getInfo(row.id);
+          if (row.executeGroupId) {
+            this.getUserList({ groupId: row.executeGroupId });
+          }
+        } else {
         }
-      } catch (error) {}
-    },
-    changeUser(val) {
-      this.executorList.map((item) => {
-        if (item.id == val) {
-          this.addForm.executeUserName = item.name;
+      },
+
+      formDataDurationTime(value) {
+        if (value > 0) {
+          this.addForm.duration = value.replace(/^[0]+/, '');
+        } else {
+          this.addForm.duration = 0;
         }
-      });
-    },
-    async save(paramName) {
-      try {
-        let valid = await this.$refs.infoRef.getValidate();
-        let data = this.$refs.infoRef.getValue();
-        await this.$refs.sparePartsRef.getValidate();
-        this.addForm.costListVOS = this.$refs.sparePartsRef.getTableValue();
-        this.$refs.addFormRef.validate(async (valid, obj) => {
-          if (obj) {
-            let messages = Object.keys(obj).map((key) => obj[key][0]);
-            if (messages.length > 0) {
-              this.$message.warning(messages[0].message);
-            }
+      },
+      //选择部门(搜索)
+      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);
           }
-          if (valid) {
-            let requestName = this.isDispatch
-              ? dispatchOrders
-              : updateSalesPlan;
-            // *** 修改的时候也可以直接派单
-            if (paramName) {
-              requestName = dispatchOrders;
-            }
-            // *** 新增参数
-            let obj = this.infoData(data);
-            this.addForm.salesDemandUpdatePO = obj;
-            const res = await requestName(this.addForm);
-            if (!res) return;
-            this.$message.success('操作成功');
-            this.visible = false;
-            this.$emit('reload');
+          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;
           }
         });
-      } catch (error) {}
-    },
-    // *** 需求信息参数
-    infoData(data) {
-      let obj = JSON.parse(JSON.stringify(data));
-      obj.productDetail = obj.tableList;
-      delete obj.tableList;
-      obj.id = this.addForm.afterSalesDemandVO.id;
-      obj.productDetail.map((el) => delete el.produceTime);
-      return obj;
-    },
-    async getInfo(id) {
-      const res = await getSalesPlanById(id);
-      if (!res) return;
-      this.addForm = res;
-      // 默认赋值 时间单位
-      this.addForm.durationUnit = this.addForm.durationUnit
-        ? this.addForm.durationUnit
-        : '2';
-      this.$nextTick(() => {
-        this.$refs.infoRef.init(res.afterSalesDemandVO);
-        this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
-      });
+      },
+      async save(paramName) {
+        try {
+          let valid = await this.$refs.infoRef.getValidate();
+          let data = this.$refs.infoRef.getValue();
+          await this.$refs.sparePartsRef.getValidate();
+          this.addForm.costListVOS = this.$refs.sparePartsRef.getTableValue();
+          this.$refs.addFormRef.validate(async (valid, obj) => {
+            if (obj) {
+              let messages = Object.keys(obj).map((key) => obj[key][0]);
+              if (messages.length > 0) {
+                this.$message.warning(messages[0].message);
+              }
+            }
+            if (valid) {
+              let requestName = this.isDispatch
+                ? dispatchOrders
+                : updateSalesPlan;
+              // *** 修改的时候也可以直接派单
+              if (paramName) {
+                requestName = dispatchOrders;
+              }
+              // *** 新增参数
+              let obj = this.infoData(data);
+              this.addForm.salesDemandUpdatePO = obj;
+              const res = await requestName(this.addForm);
+              if (!res) return;
+              this.$message.success('操作成功');
+              this.visible = false;
+              this.$emit('reload');
+            }
+          });
+        } catch (error) {}
+      },
+      // *** 需求信息参数
+      infoData(data) {
+        let obj = JSON.parse(JSON.stringify(data));
+        obj.productDetail = obj.tableList;
+        delete obj.tableList;
+        obj.id = this.addForm.afterSalesDemandVO.id;
+        obj.productDetail.map((el) => delete el.produceTime);
+        return obj;
+      },
+      async getInfo(id) {
+        const res = await getSalesPlanById(id);
+        if (!res) return;
+        this.addForm = res;
+        // 不存在部门就调用
+        if (!res.executeGroupId) {
+          this.departmentAss();
+        }
+        console.log('修改数据', res);
+        // 默认赋值 时间单位
+        this.addForm.durationUnit = this.addForm.durationUnit
+          ? this.addForm.durationUnit
+          : '2';
+        this.$nextTick(() => {
+          this.$refs.infoRef.init(res.afterSalesDemandVO);
+          this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
+        });
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.marginBto {
-  margin-bottom: 10px;
+  .marginBto {
+    margin-bottom: 10px;
 
-  span {
-    margin-left: 50px;
-  }
+    span {
+      margin-left: 50px;
+    }
 
-  .name {
-    font-weight: 800;
-    color: #40a9ff;
+    .name {
+      font-weight: 800;
+      color: #40a9ff;
+    }
+  }
+  :deep(.el-input__suffix .el-input__inner) {
+    border: none;
+    background: none;
   }
-}
-:deep(.el-input__suffix .el-input__inner) {
-  border: none;
-  background: none;
-}
 
-.ele-body-custom {
-  :deep(.divider) {
-    display: none;
+  .ele-body-custom {
+    :deep(.divider) {
+      display: none;
+    }
   }
-}
 </style>

+ 45 - 28
src/views/salesServiceManagement/toDoList/index.vue

@@ -113,7 +113,8 @@
   import {
     getSalesPlan,
     deleteSalesPlan,
-    planRevocation
+    planRevocation,
+    checkByPlanId
   } from '@/api/salesServiceManagement/index';
   import { getToken } from '@/utils/token-util';
   import dictMixins from '@/mixins/dictMixins';
@@ -160,6 +161,12 @@
             align: 'center',
             showOverflowTooltip: true
           },
+          {
+            prop: 'planExecuteUserName',
+            label: '执行人',
+            align: 'center',
+            showOverflowTooltip: true
+          },
           {
             prop: 'categoryName',
             label: '设备名称',
@@ -240,21 +247,21 @@
               }[item.urgent];
             }
           },
-          {
-            prop: 'createUserName',
-            label: '创建人',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'createTime',
-            label: '创建时间',
-            align: 'center',
-            showOverflowTooltip: true,
-            formatter: (_row, _column, cellValue) => {
-              return this.$util.toDateString(cellValue);
-            }
-          },
+          // {
+          //   prop: 'createUserName',
+          //   label: '创建人',
+          //   align: 'center',
+          //   showOverflowTooltip: true
+          // },
+          // {
+          //   prop: 'createTime',
+          //   label: '创建时间',
+          //   align: 'center',
+          //   showOverflowTooltip: true,
+          //   formatter: (_row, _column, cellValue) => {
+          //     return this.$util.toDateString(cellValue);
+          //   }
+          // },
           {
             columnKey: 'action',
             label: '操作',
@@ -289,13 +296,25 @@
         this.currentRow = {};
       },
       async cancel(row) {
+        let flag = await this.permission(row);
+        if (!flag) return;
         const res = await deleteSalesPlan([row.id]);
         if (res) {
           this.$message.success('删除成功');
           this.reload();
         }
       },
-      handleUpdate(row, type) {
+      async permission(row) {
+        try {
+          await checkByPlanId(row.id);
+          return true;
+        } catch {
+          return false;
+        }
+      },
+      async handleUpdate(row, type) {
+        let flag = await this.permission(row);
+        if (!flag) return;
         this.$nextTick(() => {
           this.$refs.addOrUpdateDialogRef.init(row, type);
         });
@@ -305,19 +324,15 @@
           this.$refs.addOrUpdateDialogRef.init(row, 'view');
         });
       },
-      handleDispatchOrders(row) {
+      async handleDispatchOrders(row) {
         this.$nextTick(() => {
           this.$refs.addOrUpdateDialogRef.init(row, 'view', true);
         });
       },
       async handleRevocation(row) {
-        try {
-          await planRevocation([row.id]);
-          this.$message.success('撤回成功');
-          this.reload();
-        } catch (err) {
-          // this.$message.error(err)
-        }
+        await planRevocation([row.id]);
+        this.$message.success('撤回成功');
+        this.reload();
       },
       addSpareItems(row) {
         let data = JSON.parse(JSON.stringify(row));
@@ -326,7 +341,9 @@
       async handleGenerate(row) {
         this.$refs.generateFormRef.open(row);
       },
-      handleCommand(command, row) {
+      async handleCommand(command, row) {
+        let flag = await this.permission(row);
+        if (!flag) return;
         if (command === 'handleRevocation') {
           this.handleRevocation(row);
         }
@@ -375,7 +392,7 @@
       padding: 0 5px 0 10px;
     }
     .el-input__inner::placeholder {
-    font-size: 13px;
-  }
+      font-size: 13px;
+    }
   }
 </style>

+ 451 - 400
src/views/salesServiceManagement/workOrder/components/declarationDialog.vue

@@ -13,35 +13,65 @@
       <el-row>
         <el-col :span="8">
           <el-form-item label="工单编码">
-            <el-input v-model="salesForm.code" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="salesForm.code"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
         <!-- 用计划名称 -->
         <el-col :span="8">
           <el-form-item label="名称">
-            <el-input v-model="salesForm.name" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="salesForm.name"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="接收人">
-            <el-input v-model="salesForm.receptionUserName" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="salesForm.receptionUserName"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
       </el-row>
       <el-row>
         <el-col :span="8">
           <el-form-item label="接收时间">
-            <el-input v-model="salesForm.receptionTime" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="salesForm.receptionTime"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="派单人">
-            <el-input v-model="salesForm.dispatchUserName" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="salesForm.dispatchUserName"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
         <el-col :span="8">
           <el-form-item label="派单时间">
-            <el-input v-model="salesForm.dispatchTime" size="small" placeholder="请输入" disabled></el-input>
+            <el-input
+              v-model="salesForm.dispatchTime"
+              size="small"
+              placeholder="请输入"
+              disabled
+            ></el-input>
           </el-form-item>
         </el-col>
       </el-row>
@@ -116,7 +146,12 @@
           <el-tabs v-model="activeName" style="width: 100%" type="border-card">
             <el-tab-pane label="需求信息" name="需求信息">
               <el-col :span="24" class="ele-body-customA">
-                <info ref="infoRef2" v-if="infoDisabled" type="view" :isPurchaseNeed="false"></info>
+                <info
+                  ref="infoRef2"
+                  v-if="infoDisabled"
+                  type="view"
+                  :isPurchaseNeed="false"
+                ></info>
                 <info
                   ref="infoRef2"
                   v-else
@@ -142,7 +177,12 @@
               </el-col>
             </el-tab-pane>
             <!-- v-if="type == 'report'" 标记 -->
-            <el-tab-pane v-if="infoShow" label="报工信息" name="报工信息" class="job_infor">
+            <el-tab-pane
+              v-if="infoShow"
+              label="报工信息"
+              name="报工信息"
+              class="job_infor"
+            >
               <el-col :span="12" class="timing">
                 <el-form-item
                   label="开始时间"
@@ -185,7 +225,11 @@
                 </el-form-item>
               </el-col>
               <el-col :span="12">
-                <el-form-item label="实际售后时长" prop="inFactDuration" class="after_sales">
+                <el-form-item
+                  label="实际售后时长"
+                  prop="inFactDuration"
+                  class="after_sales"
+                >
                   <el-input v-model="days" :disabled="true">
                     <template slot="append">天</template>
                   </el-input>
@@ -203,17 +247,21 @@
                   source="报工信息"
                   state="可操作"
                   type="view"
-                  :isReportDetails="type == 'view'? true : false "
+                  :isReportDetails="type == 'view' ? true : false"
                   :isPurchaseNeed="false"
                 ></info>
               </el-col>
               <el-col :span="24">
-                <headerTitle title="配件申请清单" style="margin-top: 10px"></headerTitle>
+                <headerTitle
+                  title="配件申请清单"
+                  style="margin-top: 10px"
+                ></headerTitle>
                 <spareParts
                   ref="sparePartsRef"
-                  source="报工信息"
+                  :state="type == 'edit' ? '可操作' : ''"
                   :type="type == 'edit' ? 'edit' : 'view'"
                 ></spareParts>
+                <!-- source="报工信息" -->
               </el-col>
               <el-col :span="24">
                 <spareInfo
@@ -271,267 +319,324 @@
     </el-form>
 
     <div slot="footer" class="footer">
-      <el-button
-        type="primary"
-        @click="submitAdd"
-        v-if="type != 'view'"
-      >{{ type == 'edit'? '提交' : '报工'}}</el-button>
+      <el-button type="primary" @click="submitAdd" v-if="type != 'view'">{{
+        type == 'edit' ? '提交' : '报工'
+      }}</el-button>
 
-      <el-button type="primary" @click="saveAdd" v-if="type == 'report'">保存</el-button>
+      <el-button type="primary" @click="saveAdd" v-if="type == 'report'"
+        >保存</el-button
+      >
       <el-button @click="handleClose">取消</el-button>
     </div>
   </ele-modal>
 </template>
 
 <script>
-import spareInfo from '@/views/salesServiceManagement/accessory/components/spareInfo.vue';
-// import fileMain from '@/components/addDoc/index.vue';
-import {
-  reportWorkingSalesWorkOrder,
-  updateScheme,
-  getSalesWorkOrderById
-} from '@/api/salesServiceManagement/index';
-import spareParts from '@/views/salesServiceManagement/components/sparePartsList.vue';
-import info from '@/views/salesServiceManagement/components/info.vue';
-import planDialog from './planDialog.vue';
-export default {
-  props: {},
-  components: {
-    // fileMain,
-    spareParts,
-    info,
-    planDialog,
-    spareInfo
-  },
-  watch: {},
-  computed: {
-    infoDisabled() {
-      let flag = this.type == 'view' || this.type == 'report';
-      return flag;
+  import spareInfo from '@/views/salesServiceManagement/accessory/components/spareInfo.vue';
+  // import fileMain from '@/components/addDoc/index.vue';
+  import {
+    reportWorkingSalesWorkOrder,
+    updateScheme,
+    getSalesWorkOrderById
+  } from '@/api/salesServiceManagement/index';
+  import spareParts from '@/views/salesServiceManagement/components/sparePartsList.vue';
+  import info from '@/views/salesServiceManagement/components/info.vue';
+  import planDialog from './planDialog.vue';
+  export default {
+    props: {},
+    components: {
+      // fileMain,
+      spareParts,
+      info,
+      planDialog,
+      spareInfo
     },
-    infoShow() {
-      let flag =
-        this.type == 'report' ||
-        this.addForm.orderStatus == 3 ||
-        this.addForm.orderStatus == 4 ||
-        this.addForm.orderStatus == 5;
-      return flag;
-    }
-  },
-  data() {
-    return {
-      activeName: '需求信息',
-      title: '',
-      visibleDialog: false,
-      addForm: {
-        id: '',
-        time: [],
-        attachments: [],
-        reason: ''
-      },
-      row: {},
-      type: '',
-      days: 0,
-      hours: 0,
-      minutes: 0,
-      endTime: '', // 结束时间
-      startTime: '', // 开始时间
-      endTimePickerOptions: {
-        disabledDate: (time) => {
-          // 如果开始时间已选择,禁用开始时间之前的日期
-          if (this.addForm.startTime) {
-            return time.getTime() < new Date(this.addForm.startTime).getTime();
-          }
-          return false;
-        }
-      },
-      salesForm: {
-        code: '',
-        name: '',
-        receptionUserName: '',
-        receptionTime: '',
-        dispatchUserName: '',
-        dispatchTime: ''
+    watch: {},
+    computed: {
+      infoDisabled() {
+        let flag = this.type == 'view' || this.type == 'report';
+        return flag;
       },
-      detailList: []
-    };
-  },
-  created() {},
-  methods: {
-    open(row, type) {
-      this.visibleDialog = true;
-      this.type = type;
-      this.title = type == 'edit' ? '修改' : type == 'view' ? '详情' : '报工';
-      if (type == 'report') {
-        this.activeName = '报工信息';
-      } else {
-        this.activeName = '需求信息';
+      infoShow() {
+        let flag =
+          this.type == 'report' ||
+          this.addForm.orderStatus == 3 ||
+          this.addForm.orderStatus == 4 ||
+          this.addForm.orderStatus == 5;
+        return flag;
       }
-      this.getDetail(row);
     },
-    async getDetail(row) {
-      const res = await getSalesWorkOrderById(row.id);
-      this.addForm = res;
-      this.salesForm = {
-        code: res.code || '',
-        receptionUserName: res.receptionUserName || '',
-        receptionTime: res.receptionTime || '',
-        dispatchUserName: res.afterSalesPlanVO.dispatchUserName || '',
-        dispatchTime: res.afterSalesPlanVO.dispatchTime || '',
-        name: res.afterSalesPlanVO.name || ''
+    data() {
+      return {
+        activeName: '需求信息',
+        title: '',
+        visibleDialog: false,
+        addForm: {
+          id: '',
+          time: [],
+          attachments: [],
+          reason: ''
+        },
+        row: {},
+        type: '',
+        days: 0,
+        hours: 0,
+        minutes: 0,
+        endTime: '', // 结束时间
+        startTime: '', // 开始时间
+        endTimePickerOptions: {
+          disabledDate: (time) => {
+            // 如果开始时间已选择,禁用开始时间之前的日期
+            if (this.addForm.startTime) {
+              return (
+                time.getTime() < new Date(this.addForm.startTime).getTime()
+              );
+            }
+            return false;
+          }
+        },
+        salesForm: {
+          code: '',
+          name: '',
+          receptionUserName: '',
+          receptionTime: '',
+          dispatchUserName: '',
+          dispatchTime: ''
+        },
+        detailList: []
       };
-      // if (this.addForm.acceptTime) {
-      //   this.$set(this.addForm, 'time', [
-      //     this.addForm.acceptTime,
-      //     this.addForm.finishTime
-      //   ]);
-      // }
-      // ***
-      this.$nextTick(() => {
-        // this.$refs.infoRef.init(res.afterSalesDemandVO);
-        // this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
-        // *** 报工信息的
-        if (this.infoShow) {
-          this.detailList = res.accessoryApply?.detailList;
-          this.$refs.infoRef.init(res.afterSalesDemandVO);
-          this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
-          this.$refs.infoRef2.init(res.afterSalesDemandVO);
-          this.$refs.sparePartsRef2.setTableValue(res?.costListVOS || []);
-          this.$set(this.addForm, 'startTime', this.addForm.acceptTime);
-          this.$set(this.addForm, 'endTime', this.addForm.finishTime);
-          this.calculateTimeConversion(res.inFactDuration);
+    },
+    created() {},
+    methods: {
+      open(row, type) {
+        this.visibleDialog = true;
+        this.type = type;
+        this.title = type == 'edit' ? '修改' : type == 'view' ? '详情' : '报工';
+        if (type == 'report') {
+          this.activeName = '报工信息';
         } else {
-          this.$refs.infoRef2.init(res.afterSalesDemandVO);
-          this.$refs.sparePartsRef2.setTableValue(res?.costListVOS || []);
+          this.activeName = '需求信息';
         }
-        this.$refs.plan.init(res.afterSalesPlanVO);
-        // afterSalesPlanVO
-      });
-    },
+        this.getDetail(row);
+      },
+      async getDetail(row) {
+        const res = await getSalesWorkOrderById(row.id);
+        this.addForm = res;
+        this.salesForm = {
+          code: res.code || '',
+          receptionUserName: res.receptionUserName || '',
+          receptionTime: res.receptionTime || '',
+          dispatchUserName: res.afterSalesPlanVO.dispatchUserName || '',
+          dispatchTime: res.afterSalesPlanVO.dispatchTime || '',
+          name: res.afterSalesPlanVO.name || ''
+        };
+        // if (this.addForm.acceptTime) {
+        //   this.$set(this.addForm, 'time', [
+        //     this.addForm.acceptTime,
+        //     this.addForm.finishTime
+        //   ]);
+        // }
+        // ***
+        this.$nextTick(() => {
+          // this.$refs.infoRef.init(res.afterSalesDemandVO);
+          // this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
+          // *** 报工信息的
+          if (this.infoShow) {
+            this.detailList = res.accessoryApply?.detailList;
+            this.$refs.infoRef.init(res.afterSalesDemandVO);
+            this.$refs.sparePartsRef.setTableValue(res?.costListVOS || []);
+            this.$refs.infoRef2.init(res.afterSalesDemandVO);
+            this.$refs.sparePartsRef2.setTableValue(res?.costListVOS || []);
+            this.$set(this.addForm, 'startTime', this.addForm.acceptTime);
+            this.$set(this.addForm, 'endTime', this.addForm.finishTime);
+            this.calculateTimeConversion(res.inFactDuration);
+          } else {
+            this.$refs.infoRef2.init(res.afterSalesDemandVO);
+            this.$refs.sparePartsRef2.setTableValue(res?.costListVOS || []);
+          }
+          this.$refs.plan.init(res.afterSalesPlanVO);
+          // afterSalesPlanVO
+        });
+      },
 
-    // 时间选择
-    handleTimeChange() {
-      // 如果结束时间早于开始时间,清空结束时间
-      if (this.addForm.startTime && this.addForm.endTime) {
-        const startTime = new Date(this.addForm.startTime).getTime();
-        const endTime = new Date(this.addForm.endTime).getTime();
-        if (startTime > endTime) {
-          this.addForm.endTime = '';
-          this.$message.warning('结束时间不能小于开始时间')
-          this.days = 0;
-          this.hours = 0;
-          this.minutes = 0;
+      // 时间选择
+      handleTimeChange() {
+        // 如果结束时间早于开始时间,清空结束时间
+        if (this.addForm.startTime && this.addForm.endTime) {
+          const startTime = new Date(this.addForm.startTime).getTime();
+          const endTime = new Date(this.addForm.endTime).getTime();
+          if (startTime > endTime) {
+            this.addForm.endTime = '';
+            this.$message.warning('结束时间不能小于开始时间');
+            this.days = 0;
+            this.hours = 0;
+            this.minutes = 0;
+            return;
+          }
+          if (this.addForm.startTime && this.addForm.endTime) {
+            this.calculateTimeDifference();
+          }
+        }
+      },
+      // 时间转换 分钟
+      calculateTimeConversion(minutes) {
+        if (!minutes && minutes != 0) {
+          this.timeAssignment(0, 0, 0);
           return;
         }
-        if (this.addForm.startTime && this.addForm.endTime) {
-          this.calculateTimeDifference();
+        // 确保输入是数字
+        const totalMinutes = parseFloat(minutes);
+        // 计算天、小时、分钟
+        const days = (totalMinutes / (24 * 60)).toFixed(1);
+        const hours = (totalMinutes / 60).toFixed(1);
+        this.days = days;
+        this.hours = hours;
+        this.minutes = minutes;
+      },
+      // 时间赋值
+      timeAssignment(days, hours, mins) {
+        // 格式化结果(保留一位小数)
+        let timeDifference = {
+          days: days.toFixed(1),
+          hours: hours.toFixed(1),
+          minutes: mins.toFixed(0)
+        };
+        this.days = timeDifference.days;
+        this.hours = timeDifference.hours;
+        this.minutes = timeDifference.minutes;
+      },
+      // 时间转换 年月日 时分秒
+      calculateTimeDifference() {
+        // 计算时间差
+        const startTime = new Date(this.addForm.startTime);
+        const endTime = new Date(this.addForm.endTime);
+        const timeDiff = endTime - startTime; // 毫秒数
+        // 转换为天、小时、分钟
+        const minutes = timeDiff / (1000 * 60);
+        const hours = minutes / 60;
+        const days = hours / 24;
+        this.timeAssignment(days, hours, minutes);
+      },
+      // 提交
+      async submitAdd() {
+        // *** 更改
+        let info = this.type == 'edit' ? 'infoRef2' : 'infoRef';
+        let spare = this.type == 'edit' ? 'sparePartsRef2' : 'sparePartsRef';
+        let validInfo = await this.$refs[info].getValidate();
+        let validSpare = await this.$refs[spare].getValidate();
+        // if (this.type == 'report') {
+        //   let validCycle = await this.$refs.spareCycleRef.getValidate();
+        // }
+        let dataA = this.$refs[info].getValue();
+        let obj = this.infoData(dataA);
+        this.finalSubmit(spare, this.type, obj);
+      },
+      // *** 需求信息参数
+      infoData(data) {
+        let obj = JSON.parse(JSON.stringify(data));
+        obj.productDetail = obj.tableList;
+        delete obj.tableList;
+        obj.id = this.addForm.afterSalesDemandVO.id;
+        obj.productDetail.map((el) => delete el.produceTime);
+        return obj;
+      },
+      listData(list) {
+        let arr = [];
+        if (list.length == 0) return list;
+        list.map((item) => {
+          this.addData(item, arr);
+        });
+        return arr;
+      },
+      addData(item, arr) {
+        let totalCount = item.totalCount ? item.totalCount - 0 : '';
+        if (!totalCount || totalCount == 1) {
+          arr.push(item);
+          return;
         }
-      }
-    },
-    // 时间转换 分钟
-    calculateTimeConversion(minutes) {
-      if (!minutes && minutes != 0) {
-        this.timeAssignment(0, 0, 0);
-        return;
-      }
-      // 确保输入是数字
-      const totalMinutes = parseFloat(minutes);
-      // 计算天、小时、分钟
-      const days = (totalMinutes / (24 * 60)).toFixed(1);
-      const hours = (totalMinutes / 60).toFixed(1);
-      this.days = days;
-      this.hours = hours;
-      this.minutes = minutes;
-    },
-    // 时间赋值
-    timeAssignment(days, hours, mins) {
-      // 格式化结果(保留一位小数)
-      let timeDifference = {
-        days: days.toFixed(1),
-        hours: hours.toFixed(1),
-        minutes: mins.toFixed(0)
-      };
-      this.days = timeDifference.days;
-      this.hours = timeDifference.hours;
-      this.minutes = timeDifference.minutes;
-    },
-    // 时间转换 年月日 时分秒
-    calculateTimeDifference() {
-      // 计算时间差
-      const startTime = new Date(this.addForm.startTime);
-      const endTime = new Date(this.addForm.endTime);
-      const timeDiff = endTime - startTime; // 毫秒数
-      // 转换为天、小时、分钟
-      const minutes = timeDiff / (1000 * 60);
-      const hours = minutes / 60;
-      const days = hours / 24;
-      this.timeAssignment(days, hours, minutes);
-    },
-    // 提交
-    async submitAdd() {
-      // *** 更改
-      let info = this.type == 'edit' ? 'infoRef2' : 'infoRef';
-      let spare = this.type == 'edit' ? 'sparePartsRef2' : 'sparePartsRef';
-      let validInfo = await this.$refs[info].getValidate();
-      let validSpare = await this.$refs[spare].getValidate();
-      // if (this.type == 'report') {
-      //   let validCycle = await this.$refs.spareCycleRef.getValidate();
-      // }
-      let dataA = this.$refs[info].getValue();
-      let obj = this.infoData(dataA);
-      this.finalSubmit(spare, this.type, obj);
-    },
-    // *** 需求信息参数
-    infoData(data) {
-      let obj = JSON.parse(JSON.stringify(data));
-      obj.productDetail = obj.tableList;
-      delete obj.tableList;
-      obj.id = this.addForm.afterSalesDemandVO.id;
-      obj.productDetail.map((el) => delete el.produceTime);
-      return obj;
-    },
-    listData(list) {
-      let arr = [];
-      if (list.length == 0) return list;
-      list.map((item) => {
-        this.addData(item, arr);
-      });
-      return arr;
-    },
-    addData(item, arr) {
-      let totalCount = item.totalCount ? item.totalCount - 0 : '';
-      if (!totalCount || totalCount == 1) {
-        arr.push(item);
-        return;
-      }
-      for (let i = 0; i < totalCount; i++) {
-        item.totalPrice = item.singlePrice || 0;
-        item.totalCount = 1;
-        arr.push(item);
-      }
-    },
-    // 最后提交 spare:具体的方案组件 obj:需求信息参数
-    finalSubmit(spare, type, obj) {
-      this.$refs.form.validate(async (valid) => {
-        if (valid) {
-          let data = {
-            acceptTime: this.addForm.startTime,
-            finishTime: this.addForm.endTime,
-            attachments: this.addForm.attachments,
-            maintenanceProcess: this.addForm.maintenanceProcess,
-            faultPhenomenon: this.addForm.faultPhenomenon,
-            faultReason: this.addForm.faultReason,
-            inFactDuration: this.minutes,
-            id: this.addForm.id,
-            costListVOS: this.$refs[spare].getTableValue(),
-            salesDemandUpdatePO: obj
-          };
-          // 报工 逻辑处理 配件申请清单数据
-          if (type == 'report') {
+        for (let i = 0; i < totalCount; i++) {
+          item.totalPrice = item.singlePrice || 0;
+          item.totalCount = 1;
+          arr.push(item);
+        }
+      },
+      // 最后提交 spare:具体的方案组件 obj:需求信息参数
+      finalSubmit(spare, type, obj) {
+        this.$refs.form.validate(async (valid) => {
+          if (valid) {
+            let data = {
+              acceptTime: this.addForm.startTime,
+              finishTime: this.addForm.endTime,
+              attachments: this.addForm.attachments,
+              maintenanceProcess: this.addForm.maintenanceProcess,
+              faultPhenomenon: this.addForm.faultPhenomenon,
+              faultReason: this.addForm.faultReason,
+              inFactDuration: this.minutes,
+              id: this.addForm.id,
+              costListVOS: this.$refs[spare].getTableValue(),
+              salesDemandUpdatePO: obj
+            };
+            // 报工 逻辑处理 配件申请清单数据
+            if (type == 'report') {
+              let list = this.$refs.spareCycleRef.getSpareData() || [];
+              let detailList = this.listData(list);
+              // 判断清单数据是否存在
+              if (detailList.length > 0) {
+                // 指定绑定第一条设备信息
+                let item = data.salesDemandUpdatePO.productDetail[0];
+                let accessoryApply = {
+                  demandDetailId: item.id,
+                  categoryCode: item.categoryCode,
+                  categoryName: item.categoryName,
+                  contactName: obj.contractInfo.name,
+                  contactCode: obj.contractInfo.code,
+                  detailList
+                };
+                data.accessoryApply = accessoryApply;
+              }
+            }
+            // let api = this.type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
+            let api =
+              type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
+            await api(data).then((res) => {
+              if (!res) return;
+              this.$message.success('操作成功');
+              this.visibleDialog = false;
+              this.$emit('reload');
+            });
+          } else {
+            return false;
+          }
+        });
+      },
+
+      // 保存
+      saveAdd() {
+        this.$refs.form.validate(async (valid) => {
+          if (valid) {
+            let dataA = this.$refs.infoRef2.getValue();
+            let obj = this.infoData(dataA);
+            let data = {
+              acceptTime: this.addForm.startTime,
+              finishTime: this.addForm.endTime,
+              attachments: this.addForm.attachments,
+              maintenanceProcess: this.addForm.maintenanceProcess,
+              faultPhenomenon: this.addForm.faultPhenomenon,
+              faultReason: this.addForm.faultReason,
+              inFactDuration: this.minutes,
+              id: this.addForm.id,
+              costListVOS: this.$refs.sparePartsRef2.getTableValue(),
+              salesDemandUpdatePO: obj
+            };
+            if (!data.acceptTime || !data.finishTime) {
+              data.acceptTime = '';
+              data.finishTime = '';
+              data.inFactDuration = 0;
+            }
+            // 报工 逻辑处理 配件申请清单数据
             let list = this.$refs.spareCycleRef.getSpareData() || [];
-            let detailList = this.listData(list);
-            // 判断清单数据是否存在
-            if (detailList.length > 0) {
+            if (list.length > 0) {
+              let detailList = this.listData(list);
               // 指定绑定第一条设备信息
               let item = data.salesDemandUpdatePO.productDetail[0];
               let accessoryApply = {
@@ -544,173 +649,119 @@ export default {
               };
               data.accessoryApply = accessoryApply;
             }
+            await updateScheme(data).then((res) => {
+              if (!res) return;
+              this.$message.success('操作成功');
+              this.visibleDialog = false;
+              this.$emit('reload');
+            });
           }
-          // let api = this.type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
-          let api = type == 'edit' ? updateScheme : reportWorkingSalesWorkOrder;
-          await api(data).then((res) => {
-            if (!res) return;
-            this.$message.success('操作成功');
-            this.visibleDialog = false;
-            this.$emit('reload');
-          });
-        } else {
-          return false;
-        }
-      });
-    },
-
-    // 保存
-    saveAdd() {
-      this.$refs.form.validate(async (valid) => {
-        if (valid) {
-          let dataA = this.$refs.infoRef2.getValue();
-          let obj = this.infoData(dataA);
-          let data = {
-            acceptTime: this.addForm.startTime,
-            finishTime: this.addForm.endTime,
-            attachments: this.addForm.attachments,
-            maintenanceProcess: this.addForm.maintenanceProcess,
-            faultPhenomenon: this.addForm.faultPhenomenon,
-            faultReason: this.addForm.faultReason,
-            inFactDuration: this.minutes,
-            id: this.addForm.id,
-            costListVOS: this.$refs.sparePartsRef2.getTableValue(),
-            salesDemandUpdatePO: obj
-          };
-          if (!data.acceptTime || !data.finishTime) {
-            data.acceptTime = '';
-            data.finishTime = '';
-            data.inFactDuration = 0;
-          }
-          // 报工 逻辑处理 配件申请清单数据
-          let list = this.$refs.spareCycleRef.getSpareData() || [];
-          if (list.length > 0) {
-            let detailList = this.listData(list);
-            // 指定绑定第一条设备信息
-            let item = data.salesDemandUpdatePO.productDetail[0];
-            let accessoryApply = {
-              demandDetailId: item.id,
-              categoryCode: item.categoryCode,
-              categoryName: item.categoryName,
-              contactName: obj.contractInfo.name,
-              contactCode: obj.contractInfo.code,
-              detailList
-            };
-            data.accessoryApply = accessoryApply;
-          }
-          await updateScheme(data).then((res) => {
-            if (!res) return;
-            this.$message.success('操作成功');
-            this.visibleDialog = false;
-            this.$emit('reload');
-          });
-        }
-      });
-    },
+        });
+      },
 
-    // calculateTimeDifference(totalMinutes) {
-    //   if (!totalMinutes) {
-    //     this.hours = 0;
-    //     this.minutes = 0;
-    //     return;
-    //   }
-    //   const hours = Math.floor(totalMinutes / 60);
-    //   const minutes = totalMinutes % 60;
-    //   this.hours = hours;
-    //   this.minutes = minutes;
-    // },
-    // getTime() {
-    //   if (this.addForm.time?.length) {
-    //     this.$set(
-    //       this.addForm,
-    //       'inFactDuration',
-    //       parseInt(
-    //         (new Date(this.addForm.time[1]).getTime() -
-    //           new Date(this.addForm.time[0]).getTime()) /
-    //           60000
-    //       )
-    //     );
-    //   }
-    // },
-    handleClose() {
-      this.visibleDialog = false;
+      // calculateTimeDifference(totalMinutes) {
+      //   if (!totalMinutes) {
+      //     this.hours = 0;
+      //     this.minutes = 0;
+      //     return;
+      //   }
+      //   const hours = Math.floor(totalMinutes / 60);
+      //   const minutes = totalMinutes % 60;
+      //   this.hours = hours;
+      //   this.minutes = minutes;
+      // },
+      // getTime() {
+      //   if (this.addForm.time?.length) {
+      //     this.$set(
+      //       this.addForm,
+      //       'inFactDuration',
+      //       parseInt(
+      //         (new Date(this.addForm.time[1]).getTime() -
+      //           new Date(this.addForm.time[0]).getTime()) /
+      //           60000
+      //       )
+      //     );
+      //   }
+      // },
+      handleClose() {
+        this.visibleDialog = false;
+      }
     }
-  }
-};
+  };
 </script>
 
 <style lang="scss" scoped>
-.dialog_top {
-  margin-bottom: 10px;
-  display: flex;
-  align-items: center;
+  .dialog_top {
+    margin-bottom: 10px;
+    display: flex;
+    align-items: center;
 
-  span {
-    margin-left: 50px;
-  }
+    span {
+      margin-left: 50px;
+    }
 
-  .name {
-    font-weight: 800;
-    color: #40a9ff;
+    .name {
+      font-weight: 800;
+      color: #40a9ff;
+    }
   }
-}
-
-::v-deep .el-row {
-  display: flex;
-  flex-wrap: wrap;
-}
 
-.btns {
-  text-align: right;
-  // margin: 10px 0;
-}
-
-.main_container {
-  width: 100%;
-  display: flex;
-  justify-content: space-between;
-}
+  ::v-deep .el-row {
+    display: flex;
+    flex-wrap: wrap;
+  }
 
-.ele-body-custom {
-  width: 100%;
-  margin-bottom: 24px;
-  // :deep(.divider){
-  //   display: none;
-  // }
-}
+  .btns {
+    text-align: right;
+    // margin: 10px 0;
+  }
 
-.ele-body-customA {
-  :deep(.divider) {
-    display: none;
+  .main_container {
+    width: 100%;
+    display: flex;
+    justify-content: space-between;
   }
-}
 
-.after_sales {
-  :deep(.el-input--medium) {
-    width: 30%;
+  .ele-body-custom {
+    width: 100%;
+    margin-bottom: 24px;
+    // :deep(.divider){
+    //   display: none;
+    // }
   }
-  :deep(.el-input--medium:nth-child(1)) {
-    margin-right: 5%;
+
+  .ele-body-customA {
+    :deep(.divider) {
+      display: none;
+    }
   }
-  :deep(.el-input--medium:nth-child(2)) {
-    margin-right: 5%;
+
+  .after_sales {
+    :deep(.el-input--medium) {
+      width: 30%;
+    }
+    :deep(.el-input--medium:nth-child(1)) {
+      margin-right: 5%;
+    }
+    :deep(.el-input--medium:nth-child(2)) {
+      margin-right: 5%;
+    }
   }
-}
 
-.job_infor {
-  :deep(.ele-body) {
-    padding: 15px 0;
+  .job_infor {
+    :deep(.ele-body) {
+      padding: 15px 0;
+    }
   }
-}
 
-.timing {
-  display: flex;
-  :deep(.el-form-item) {
-    width: 50%;
+  .timing {
+    display: flex;
+    :deep(.el-form-item) {
+      width: 50%;
 
-    .el-date-editor {
-      width: 100%;
+      .el-date-editor {
+        width: 100%;
+      }
     }
   }
-}
 </style>

+ 18 - 3
src/views/salesServiceManagement/workOrder/index.vue

@@ -198,7 +198,8 @@
     deleteSalesWorkOrder,
     receiveSalesWorkOrder,
     checkAndAccept,
-    getSalesWorkOrderById
+    getSalesWorkOrderById,
+    checkByWorkId
   } from '@/api/salesServiceManagement/index';
   import { getByCode } from '@/api/system/dictionary-data';
   import dictMixins from '@/mixins/dictMixins';
@@ -513,17 +514,31 @@
       },
 
       // 转派
-      toRedeploy(row) {
+      async toRedeploy(row) {
         this.$refs.redeployOtherRef.open(row, 'transfer');
       },
       //报工
-      declarationForm(row, type) {
+      async declarationForm(row, type) {
+        if (type !== 'view') {
+          let flag = await this.permission(row);
+          if (!flag) return;
+        }
         this.$refs.declarationDialogRef.open(row, type);
       },
+      async permission(row) {
+        try {
+          await checkByWorkId(row.id);
+          return true;
+        } catch {
+          return false;
+        }
+      },
       goDetail(row) {
         this.$refs.declarationDialogRef.open(row, 'view');
       },
       async handleCommand(command, row) {
+        let flag = await this.permission(row);
+        if (!flag) return;
         if (command === 'addSpareItems') {
           this.addSpareItems(row);
         }