From 6ca4914a18d1b1561e537674292cf9374791de7c Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 20 十二月 2022 17:23:40 +0800
Subject: [PATCH] Default Changelist

---
 src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue |  246 +++++++++++++++++++++++++++++-------------------
 1 files changed, 149 insertions(+), 97 deletions(-)

diff --git a/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue b/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue
index 3dbb18e..384515a 100644
--- a/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue
+++ b/src/views/specialWorkSystem/workTicket/zysq/components/materialDialog.vue
@@ -5,38 +5,54 @@
         <el-button @click="openList(item)" type="success">选用</el-button>
       </div>
 
-      <el-dialog v-model="equipDetailDialog" title="物资标准详情" width="40%" center @open="openDetail" >
-          <table class="table">
-            <tr>
-              <th class="w-20">物资名称</th>
-              <th class="w-20">出库部门(仓库)</th>
-              <th class="w-15">对应库存</th>
-              <th class="w-15">标准值</th>
-              <th class="w-15">级别</th>
-              <th class="w-15">实际使用</th>
-            </tr>
-            <tr v-for="(item,index) in materialDetail">
-              <td class="w-20">{{item.materialName}}</td>
-              <td class="w-20">
-                <el-select v-model="addList[index].depId" @change="changeDep($event,index)">
-                  <el-option
-                      v-for="i in item.msList"
-                      :key="i.depId"
-                      :label="i.depName"
-                      :value="i.depId"
-                  />
-                </el-select>
-              </td>
-              <td class="w-15">
-                  {{stockCount[index]}}
-              </td>
-              <td class="w-15">{{item.standVal}}</td>
-              <td class="w-15">{{item.configurationLevelName}}</td>
-              <td class="w-15">
-                <el-input type="number" v-model.number="addList[index].useCount"/>
-              </td>
-            </tr>
-          </table>
+      <el-dialog v-model="equipDetailDialog" title="物资标准详情" width="75%" center @open="openDetail">
+        <div class="choose-receiver">
+          <span>选择其他作业关联人员</span>
+          <el-select v-model="receiveUids" multiple @change="changeReceiver">
+            <el-option
+                v-for="item in workerList"
+                :key="item.uid"
+                :label="item.username"
+                :value="item.uid"
+            />
+          </el-select>
+        </div>
+        <table class="table">
+          <tr>
+            <th class="w-25">物资名称</th>
+            <th class="w-15">标准值</th>
+            <th class="w-15">级别</th>
+            <th class="w-30">关联人员与个数</th>
+            <th class="w-15">实际使用</th>
+          </tr>
+          <tr v-for="(item,index) in materialDetail">
+            <td class="w-25">{{item.materialName}}</td>
+<!--              <td class="w-1">-->
+<!--                <el-select v-model="addList[index].depId" @change="changeDep($event,index)">-->
+<!--                  <el-option-->
+<!--                      v-for="i in item.msList"-->
+<!--                      :key="i.depId"-->
+<!--                      :label="i.depName"-->
+<!--                      :value="i.depId"-->
+<!--                  />-->
+<!--                </el-select>-->
+<!--              </td>-->
+<!--              <td class="w-15">-->
+<!--                  {{stockCount[index]}}-->
+<!--              </td>-->
+            <td class="w-15">{{item.standVal}}</td>
+            <td class="w-15">{{item.configurationLevelName}}</td>
+            <td class="w-30">
+              {{item.receiveUnames}}
+            </td>
+<!--              <td class="w-15">-->
+<!--                <el-input type="number" v-model.number="addList[index].useCount"/>-->
+<!--              </td>-->
+            <td class="w-15">
+              {{item.receiveCount}}
+            </td>
+          </tr>
+        </table>
         <template #footer>
           <span class="dialog-footer">
             <el-button @click="closeChoose()" size="default">取消</el-button>
@@ -56,8 +72,8 @@
   equipDetailDialog: boolean
   materialDetail: Array<any>
   stockCount: Array<number>
-  addList: Array<any>
-  chosenId: number | null
+  chosenId: number | null,
+  receiveUids: Array<number>
 }
 
 
@@ -66,9 +82,10 @@
 import {ElMessage, ElMessageBox} from 'element-plus';
 import {useUserInfo} from "/@/stores/userInfo";
 import {storeToRefs} from "pinia";
+
 export default {
     name: 'materialDialog',
-    setup(props,context) {
+    setup(props: any, context: any) {
         const userInfo = useUserInfo()
         const { userInfos } = storeToRefs(userInfo);
         const approveBasicFormRef = ref();
@@ -79,7 +96,7 @@
           equipDetailDialog: false,
           materialDetail: [],
           stockCount: [],
-          addList: []
+          receiveUids: []
         });
 
       // 确认物资标准
@@ -89,85 +106,112 @@
           if (res.data.code === '200') {
             if(res.data.data && res.data.data.length>0){
               state.materialList = JSON.parse(JSON.stringify(res.data.data))
+              state.equipmentDialog = true
             }else{
               ElMessage({
                 type: 'warning',
                 message: '暂时查询不到物资标准信息'
               });
-              state.equipmentDialog = false
             }
           } else {
             ElMessage({
               type: 'warning',
               message: res.data.msg
             });
-            state.equipmentDialog = false
           }
       }
-      const openList =(item:object)=>{
+      const openList = async(item:object)=>{
         state.chosenId = item.id
-        state.addList = []
-        state.stockCount = []
-        if(item.mcList && item.mcList.length>0){
-          for(let j in item.mcList){
-            if(item.mcList[j].msList == null || item.mcList[j].msList.length==0){
-              item.mcList.splice(j,1)
-            }
+        const data = {maBaseId: state.chosenId,receiveUids:state.receiveUids}
+        const res = await workApplyApi().getMaterialDetail(data)
+        if (res.data.code === '200') {
+          if(res.data.data && res.data.data.length>0){
+            state.materialDetail = res.data.data
+            state.equipDetailDialog = true
+          }else{
+            ElMessage({
+              type: 'warning',
+              message: '暂时查询不到物资标准信息'
+            });
           }
-          state.materialDetail = item.mcList
-          for(let i in state.materialDetail){
-              state.addList.push(
-                  {
-                    materialId: state.materialDetail[i].materialId,
-                    depId: null,
-                    depName: '',
-                    useCount: null
-                  }
-              )
-            for(let x in state.materialDetail[i].msList){
-              if(state.materialDetail[i].msList[x].depId == userInfos.value.depId){
-                state.addList[i].depId = userInfos.value.depId
-                state.addList[i].depName = state.materialDetail[i].msList[x].depName
-                state.stockCount[i] = state.materialDetail[i].msList.find((e) => e.depId == state.addList[i].depId).stockCount
-              }
-            }
-          }
-        }
-        state.equipDetailDialog = true
-      }
-
-      const openDetail = ()=>{
-        console.log(state.addList,'打开弹窗')
-      }
-
-      const changeDep = (val:number,index:number)=>{
-        state.addList[index].depName = state.materialDetail[index].msList.find((i) => i.depId == val).depName
-        state.stockCount[index] = state.materialDetail[index].msList.find((i) => i.depId == val).stockCount
-      }
-      const submitMaterials = ()=>{
-        if(state.addList.length > 0 && (state.addList.some((e) => e.depId == null && e.useCount != null ) || state.addList.some((e) => e.useCount == null && e.depId != null))){
+        } else {
           ElMessage({
             type: 'warning',
-            message: '出库部门或实际使用值不可为空'
+            message: res.data.msg
           });
-          return
         }
-        for(let i in state.materialDetail){
-          if(state.materialDetail[i].configurationLevelName == '必选' && state.addList[i].depId != null && state.addList[i].useCount <= 0){
+        // state.stockCount = []
+        // if(item.mcList && item.mcList.length>0){
+        //   for(let j in item.mcList){
+        //     if(item.mcList[j].msList == null || item.mcList[j].msList.length==0){
+        //       item.mcList.splice(j,1)
+        //     }
+        //   }
+        //   state.materialDetail = item.mcList
+        //   for(let i in state.materialDetail){
+        //       state.addList.push(
+        //           {
+        //             materialId: state.materialDetail[i].materialId,
+        //             depId: null,
+        //             depName: '',
+        //             useCount: null
+        //           }
+        //       )
+        //     for(let x in state.materialDetail[i].msList){
+        //       if(state.materialDetail[i].msList[x].depId == userInfos.value.depId){
+        //         state.addList[i].depId = userInfos.value.depId
+        //         state.addList[i].depName = state.materialDetail[i].msList[x].depName
+        //         state.stockCount[i] = state.materialDetail[i].msList.find((e) => e.depId == state.addList[i].depId).stockCount
+        //       }
+        //     }
+        //   }
+        // }
+      }
+      const changeReceiver = async ()=>{
+        const data = {maBaseId: state.chosenId,receiveUids:state.receiveUids}
+        const res = await workApplyApi().getMaterialDetail(data)
+        if (res.data.code === '200') {
+          if(res.data.data && res.data.data.length>0){
+            state.materialDetail = res.data.data
+          }else{
             ElMessage({
               type: 'warning',
-              message: '必选物资数量不能小于等于0'
+              message: '暂时查询不到物资标准信息'
             });
-            return
           }
-          if((state.stockCount[i] !=null && state.addList[i].useCount !=null) && (state.stockCount[i] < state.addList[i].useCount)){
-            ElMessage({
-              type: 'warning',
-              message: '物资配置数量超出库存量,请重新配置'
-            });
-            return
-          }
+        } else {
+          ElMessage({
+            type: 'warning',
+            message: res.data.msg
+          });
         }
+      }
+      const openDetail = ()=>{
+      }
+      const submitMaterials = ()=>{
+        // if(state.addList.length > 0 && (state.addList.some((e) => e.depId == null && e.useCount != null ) || state.addList.some((e) => e.useCount == null && e.depId != null))){
+        //   ElMessage({
+        //     type: 'warning',
+        //     message: '出库部门或实际使用值不可为空'
+        //   });
+        //   return
+        // }
+        // for(let i in state.materialDetail){
+        //   if(state.materialDetail[i].configurationLevelName == '必选' && state.addList[i].depId != null && state.addList[i].useCount <= 0){
+        //     ElMessage({
+        //       type: 'warning',
+        //       message: '必选物资数量不能小于等于0'
+        //     });
+        //     return
+        //   }
+        //   if((state.stockCount[i] !=null && state.addList[i].useCount !=null) && (state.stockCount[i] < state.addList[i].useCount)){
+        //     ElMessage({
+        //       type: 'warning',
+        //       message: '物资配置数量超出库存量,请重新配置'
+        //     });
+        //     return
+        //   }
+        // }
         // if(state.addList.length > 0){
         //   for(let n in state.addList){
         //     if(state.addList[n].depId == null && state.addList[n].useCount == null){
@@ -175,8 +219,8 @@
         //     }
         //   }
         // }
-        console.log(state.addList,state.chosenId,'666666666')
-        context.emit('conFirmMaterials',state.addList,state.chosenId)
+        console.log(state.receiveUids,state.chosenId,'666666666')
+        context.emit('conFirmMaterials',state.receiveUids,state.chosenId)
         state.equipDetailDialog = false
         state.equipmentDialog = false
       }
@@ -186,13 +230,12 @@
       }
       const closeChoose = () =>{
         state.equipDetailDialog = false
-        state.equipmentDialog = false
       }
         return {
             ...toRefs(state),
-            changeDep,
             getMaList,
             openList,
+            changeReceiver,
             openDetail,
             closeChoose,
             closeMaterial,
@@ -214,17 +257,18 @@
   .table{
     width: 100%;
     border-collapse: collapse;
+    margin-top: 20px;
     tr{
       width: 100%;
       border: 1px solid #ccc;
       th,td{
+        padding: 6px 0;
         border-left: 1px solid #ccc;
         &:first-of-type{
           border-left: none;
         }
       }
-      th{
-        padding: 10px 0;
+      td{
         font-weight: bolder;
       }
 
@@ -236,6 +280,14 @@
         width: 20%;
         text-align: center;
       }
+      .w-25{
+        width: 25%;
+        text-align: center;
+      }
+      .w-30{
+        width: 30%;
+        text-align: center;
+      }
     }
   }
 </style>

--
Gitblit v1.9.2