Kaynağa Gözat

Merge branch 'master' of http://120.46.159.163:7400/ezhizao/ezhizao_dms_vue

ezhizao_zx 1 yıl önce
ebeveyn
işleme
44b4830915

+ 53 - 0
src/api/business/drawing.js

@@ -0,0 +1,53 @@
+import request from '@/utils/request'
+const baseUrl = import.meta.env.VITE_APP_BASE_API
+
+// 查询电子图纸列表
+export function listDrawing(query) {
+  return request({
+   url: baseUrl +'/business/drawing/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询图纸名
+export function drawingByName(query) {
+  return request({
+   url: baseUrl +'/business/drawing/byName',
+    method: 'get',
+    params: query
+  })
+}
+// 查询电子图纸详细
+export function getDrawing(id) {
+  return request({
+   url: baseUrl +'/business/drawing/' + id,
+    method: 'get'
+  })
+}
+
+// 新增电子图纸
+export function addDrawing(data) {
+  return request({
+   url: baseUrl +'/business/drawing',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改电子图纸
+export function updateDrawing(data) {
+  return request({
+   url: baseUrl +'/business/drawing',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除电子图纸
+export function delDrawing(id) {
+  return request({
+   url: baseUrl +'/business/drawing/' + id,
+    method: 'delete'
+  })
+}

+ 44 - 0
src/api/business/drawingRecords.js

@@ -0,0 +1,44 @@
+import request from '@/utils/request'
+const baseUrl = import.meta.env.VITE_APP_BASE_API
+// 查询电子图纸操作记录列表
+export function listRecords(query) {
+  return request({
+    url: baseUrl +'/business/records/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询电子图纸操作记录详细
+export function getRecords(id) {
+  return request({
+    url: baseUrl +'/business/records/' + id,
+    method: 'get'
+  })
+}
+
+// 新增电子图纸操作记录
+export function addRecords(data) {
+  return request({
+    url: baseUrl +'/business/records',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改电子图纸操作记录
+export function updateRecords(data) {
+  return request({
+    url: baseUrl +'/business/records',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除电子图纸操作记录
+export function delRecords(id) {
+  return request({
+    url: baseUrl +'/business/records/' + id,
+    method: 'delete'
+  })
+}

+ 8 - 1
src/api/business/outsourcedOrder.js

@@ -37,7 +37,14 @@ export function saveOrder(data) {
 	})
 }
 
-
+// 保存外协单
+export function submitDetails(data) {
+	return request({
+		url: baseUrl + '/business/outsource/submitDetails',
+		method: 'post',
+		data: data
+	})
+}
 export function processesForOutsource(data) {
 	return request({
 		url: baseUrl + '/business/outsource/processesForOutsource',

+ 45 - 0
src/api/business/outsourcedRecords.js

@@ -0,0 +1,45 @@
+import request from '@/utils/request'
+const baseUrl = import.meta.env.VITE_APP_PRODUCTION_API
+
+// 查询外协发出单历史记录列表
+export function listOutsourcedRecords(query) {
+  return request({
+    url:baseUrl +  '/business/outsourcedRecords/list',
+    method: 'get',
+    params: query
+  })
+}
+
+// 查询外协发出单历史记录详细
+export function getOutsourcedRecords(id) {
+  return request({
+    url: baseUrl + '/business/outsourcedRecords/' + id,
+    method: 'get'
+  })
+}
+
+// 新增外协发出单历史记录
+export function addOutsourcedRecords(data) {
+  return request({
+    url:baseUrl +  '/business/outsourcedRecords',
+    method: 'post',
+    data: data
+  })
+}
+
+// 修改外协发出单历史记录
+export function updateOutsourcedRecords(data) {
+  return request({
+    url: baseUrl + '/business/outsourcedRecords',
+    method: 'put',
+    data: data
+  })
+}
+
+// 删除外协发出单历史记录
+export function delOutsourcedRecords(id) {
+  return request({
+    url:baseUrl +  '/business/outsourcedRecords/' + id,
+    method: 'delete'
+  })
+}

+ 12 - 7
src/views/business/daywork/index.vue

@@ -79,21 +79,19 @@
                 <dict-tag :options="daywork_status" :value="scope.row.status" />
               </template>
             </el-table-column>
-            <el-table-column fixed="right" label="操作" align="center" width="140px">
+            <el-table-column fixed="right" label="操作" align="center" width="200px">
               <template #default="scope">
                 <el-button v-show="scope.row.deptProcessStatus &&
         (scope.row.status == 2 || scope.row.status == 3) &&
-        scope.row.processId == latestProcessId
+        scope.row.id == latestProcessId && scope.row.deptId == latestDeptId && !(lastStatus == 4 || lastStatus == 5 ||lastStatus ==7)
         " link type="warning" icon="Edit" @click="handleUpdateDayworkItem(scope.row)">编辑
                 </el-button>
-                <el-button v-show="!(scope.row.deptProcessStatus &&
-        (scope.row.status == 2 || scope.row.status == 3) &&
-        scope.row.processId == latestProcessId)" link type="primary" icon="View"
+                <el-button  link type="primary" icon="View"
                   @click="handleCheckDayworkItem(scope.row)">查看
                 </el-button>
                 <el-button v-show="scope.row.deptProcessStatus &&
         (scope.row.status == 2 || scope.row.status == 3) &&
-        scope.row.processId == latestProcessId
+        scope.row.id == latestProcessId&& scope.row.deptId == latestDeptId &&!(lastStatus == 4 || lastStatus == 5 ||lastStatus ==7)
         " v-hasPermi="['business:daywork:remove']" link type="danger" icon="Delete"
                   @click="handleDeletedItem(scope.row.id)">删除
                 </el-button>
@@ -141,7 +139,9 @@ const loading = ref(false);
 const dayworkItemList = ref([]);
 const dayworkItemLoading = ref(false);
 const itemTotal = ref(0);
+const lastStatus = ref(null)
 const latestProcessId = ref(null);
+const latestDeptId = ref(null)
 const deptProcessList = ref([]);
 /**工序 */
 const processList = ref([]);
@@ -391,7 +391,11 @@ function getDayworkItems() {
       // }
     }
     if (res.others != null && res.others.latestProcessId != null) {
-      latestProcessId.value = latestProcessId
+      latestProcessId.value = res.others.latestProcessId
+    }
+    if (res.others != null && res.others.lastItem != null) {
+      latestDeptId.value = res.others.lastItem.deptId
+      lastStatus.value = res.others.lastItem.status
     }
     for (var i = 0; i < res.rows.length; i++) {
       let timeStamp = res.rows[i].workingHours;
@@ -407,6 +411,7 @@ function getDayworkItems() {
           res.rows[i].deptProcessStatus = true;
         }
       }
+      console.log(res.rows[i].deptProcessStatus)
     }
     dayworkItemList.value = res.rows;
     getProcess();

+ 56 - 0
src/views/business/outsource/DialogOutsourcedRecords.vue

@@ -0,0 +1,56 @@
+<template>
+	<el-dialog title="历史记录" v-model="visible" width="800px" height="400px" @close="close" append-to-body draggable  style="font-size: 14px;">
+		<el-table ref="dialogTable" :data="recordsList" size="small" v-loading="loading" border height="500px" header-row-class-name="list-header-row" row-class-name="list-row" >
+			<el-table-column type="index" label="序号" width="50" align="center" />
+			<el-table-column label="记录" align="center" prop="records" />
+		</el-table>
+	</el-dialog>
+</template>
+<script setup>
+import { listOutsourcedRecords } from "@/api/business/outsourcedRecords";
+/** 历史记录变量 */
+const recordsList = ref([])
+const visible = ref(false)
+const loading = ref(false)
+const data = reactive({
+	queryParams: {
+		masterId:null
+	}
+})
+const { queryParams } = toRefs(data)
+
+/**
+ * 对话框打开 事件
+ */
+function open(data) {
+	visible.value = true
+	queryParams.value.masterId = data
+	getList()
+}
+
+/**
+ * 对话框关闭 事件
+ */
+function close() {
+	visible.value = false
+}
+
+/**
+ * 加载数据
+ */
+function getList() {
+	loading.value = true
+	listOutsourcedRecords(queryParams.value).then((res) => {
+		recordsList.value = res.rows
+		loading.value = false
+	})
+}
+
+defineExpose({
+	open
+})
+</script>
+<style scoped>
+.el-table--small {
+    font-size: 14px;
+}</style>

+ 2 - 0
src/views/business/outsource/DialogProcesses.vue

@@ -124,7 +124,9 @@ const selections = ref([]);
  * 对话框打开 事件
  */
 function open(data) {
+  console.log(data)
   queryParams.value.lotId = data.lotId
+  queryParams.value.outsourceDetailId = data.id?data.id:0
   queryParams.value.pageNum = 1;
   queryParams.value.pageSize = 10;
   visible.value = true;

+ 246 - 98
src/views/business/outsource/form.vue

@@ -13,29 +13,45 @@
           <span>外协单信息</span>
         </span>
 
-        <el-button
+        <!-- <el-button
           v-if="editStatus"
           type="success"
           icon="check"
           @click="saveFrom"
         >
           暂存
-        </el-button>
+        </el-button> -->
 
         <el-button
-          v-if="!editStatus"
+          v-if="editStatus && form.isSubmit==1"
           type="primary"
           icon="Download"
           @click="handleExport"
           v-hasPermi="['business:outsource:export']"
           >导出</el-button
         >
+        <el-button
+          v-if="!editStatus"
+          type="warning"
+          icon="Download"
+          @click="handlePrint"
+          v-hasPermi="['business:outsource:export']"
+        >
+          打印
+        </el-button>
         <el-button
           v-if="editStatus"
           type="primary"
           icon="Finished"
-          @click="submitFrom"
-          >保存并提交</el-button
+          @click="handleSubmit"
+          >保存</el-button
+        >
+        <el-button
+        v-if="editStatus && form.isSubmit==1"
+          type="info"
+          icon="Calendar"
+          @click="handleViewRecords"
+          >历史记录</el-button
         >
         <div class="close-btn" @click="cancel">
           <i class="fa fa-times" aria-hidden="true" />
@@ -80,7 +96,7 @@
           <el-col :span="6">
             <el-form-item label="外协商名称" prop="supplierName">
               <el-input
-                v-if="editStatus"
+                v-if="editStatus && form.isSubmit == 0"
                 v-model="form.supplierName"
                 readonly
                 placeholder="请输入外协商名称"
@@ -179,7 +195,7 @@
             <el-form-item label="备注" prop="remark">
               <el-input
                 v-if="editStatus"
-                v-model="form.remark"
+                v-model.trim="form.remark"
                 placeholder="请输入备注"
               />
               <span v-else>{{ form.remark }}</span>
@@ -187,7 +203,7 @@
           </el-col>
           <el-col :span="6">
             <el-form-item label="总箱数" prop="remark">
-              <span >{{ totalCarriersNum }}</span>
+              <span>{{ totalCarriersNum }}</span>
             </el-form-item>
           </el-col>
         </el-row>
@@ -231,7 +247,12 @@
               prop="productDescription"
               width="320"
             />
-            <el-table-column label="产品数" align="center" width="160" prop="productNum">
+            <el-table-column
+              label="产品数"
+              align="center"
+              width="160"
+              prop="productNum"
+            >
               <template #default="scope">
                 <el-input-number
                   v-if="editStatus"
@@ -261,7 +282,14 @@
               width="320"
             >
               <template #default="scope">
-                <el-button link type="primary" icon="Refresh" v-if="!scope.row.editStatus && editStatus" @click="handleChangeCarrier(scope.row)">换箱</el-button>
+                <el-button
+                  link
+                  type="primary"
+                  icon="Refresh"
+                  v-if="!scope.row.editStatus && editStatus"
+                  @click="handleChangeCarrier(scope.row)"
+                  >换箱</el-button
+                >
                 <el-select
                   v-if="editStatus && scope.row.editStatus"
                   v-model="scope.row.carrierIds"
@@ -271,7 +299,8 @@
                   reserve-keyword
                   placeholder="请选择箱号"
                   :remote-method="
-                    (arg) => remoteCarriers(arg, scope.row.newCarriers,scope.row)
+                    (arg) =>
+                      remoteCarriers(arg, scope.row.newCarriers, scope.row)
                   "
                   :loading="loadingCarrier"
                   @change="(arg) => handleCarrierChange(arg, scope.row)"
@@ -375,9 +404,11 @@
       ref="dialogCarrierRef"
       :multiple-selected="handleMultipleSelectedOutsourceCarriers"
     />
-    <!-- 收回明细带回 -->
-    <!-- <form-details-recycling ref="formDetailsRecyclingRef" :singleSelected="handleSingleSelectedRecycling"/> -->
-  </el-drawer>
+    <!-- 历史记录弹窗 -->
+    <dialog-outsourced-records ref="dialogOutsourcedRecordsRef"/>
+   <!-- 收回明细带回 -->
+      <!-- <form-details-recycling ref="formDetailsRecyclingRef" :singleSelected="handleSingleSelectedRecycling"/> -->
+   </el-drawer>
 </template>
 <script setup>
 import {
@@ -386,11 +417,14 @@ import {
   carrierForOutsource,
   submitOrder,
   exportOutsource,
+  printOutsource,
+  submitDetails
 } from "@/api/business/outsourcedOrder";
 import dialogCarrier from "./DialogCarrier";
 import dialogSuppliers from "./DialogSuppliers";
 import dialogProducts from "./DialogProducts";
 import dialogProcesses from "./DialogProcesses";
+import dialogOutsourcedRecords from "./DialogOutsourcedRecords"
 // import FormDetailsRecycling from "./detailsRecyclingForm";
 const { proxy } = getCurrentInstance();
 /** 父组件传参 */
@@ -422,7 +456,8 @@ const multiple = ref(true);
 const visible = ref(false);
 const editStatus = ref(true);
 const isFullscreen = ref(false);
-const totalCarriersNum = ref(0)
+const totalCarriersNum = ref(0);
+const detailInfo = ref({});
 const loadingCarrier = ref(false);
 const carriers = ref([]);
 const webHost = import.meta.env.VITE_APP_BASE_API;
@@ -441,13 +476,20 @@ function handleExport() {
   exportOutsource({ id: form.value.id });
 }
 
+/** 打印按钮操作 */
+function handlePrint() {
+  printOutsource({ id: form.value.id });
+}
+
 /** 打开抽屉 */
-function open(id) {
+function open(row) {
   reset();
   totalCarriersNum.value = 0
   visible.value = true;
-  if (id) {
-    form.value.id = id;
+  if (row) {
+    console.log(row)
+    detailInfo.value = row
+    form.value.id = row.id;
     getForm();
   } else {
     editStatus.value = true;
@@ -458,23 +500,28 @@ function open(id) {
 function getForm() {
   loading.value = true;
   getOrder(form.value.id).then((response) => {
-    form.value = response.data
-    console.log(form.value.details)
-    form.value.details.forEach(item =>{
-      item.editStatus = false
-     if(!form.value.id) {
-        item.carrierNum = item.originalCarrier.split(",").length
-      }else {
-        if(item.newCarrier !=null) {
-        item.carrierNum = item.newCarrier.split(",").length
-      }else {
-        item.carrierNum = item.originalCarrier.split(",").length
-      }
+    form.value = response.data;
+    console.log(form.value.details);
+    form.value.details.forEach((item) => {
+      item.editStatus = false;
+      if (!form.value.id) {
+        item.carrierNum = item.originalCarrier.split(",").length;
+      } else {
+        if (item.newCarrier != null) {
+          item.carrierNum = item.newCarrier.split(",").length;
+        } else {
+          item.carrierNum = item.originalCarrier.split(",").length;
+        }
       }
-      totalCarriersNum.value += item.carrierNum
-    })
+      totalCarriersNum.value += item.carrierNum;
+    });
 
-    editStatus.value = form.value.isSubmit == 0;
+    editStatus.value = form.value.isSubmit == 1;
+    if(!detailInfo.value.flag) {
+      editStatus.value = false
+      console.log(editStatus.value)
+    }
+    console.log(editStatus.value)
     loading.value = false;
   });
 }
@@ -495,7 +542,11 @@ function handleChangePackagingMethod() {
     })
   }
 }else{
-  form.value.details.forEach(item =>{item.newCarriers = [];item.carrierIds = [];item.carriers = carriers.value})
+  form.value.details.forEach(item =>{
+    console.log(item.editStatus)
+    if(item.editStatus){
+    item.newCarriers = [];item.carrierIds = [];item.carriers = carriers.value}
+})
 }
   console.log(form.value.details)
   for(let i = 0;i<form.value.details.length;i++) {
@@ -510,13 +561,17 @@ function handleChangePackagingMethod() {
 }
 //改变送货方式
 function handleChangeDeliveryMethod() {
-  if(form.value.deliveryMethod == 1) {
-    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
-  }else {
-    form.value.freightAmount = 0.0
+  if (form.value.deliveryMethod == 1) {
+    form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
+  } else {
+    form.value.freightAmount = 0.0;
   }
  
 }
+//打开历史记录弹窗
+function handleViewRecords() {
+  proxy.$refs.dialogOutsourcedRecordsRef.open(form.value.id);
+}
 
 function selectText(value, data) {
   if (value) {
@@ -531,11 +586,11 @@ function cancel() {
 }
 
 const handleDelete = (index) => {
-  totalCarriersNum.value -=form.value.details[index].carrierNum
-  if(form.value.deliveryMethod == 1) {
-    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
-  }else {
-    form.value.freightAmount = 0.0
+  totalCarriersNum.value -= form.value.details[index].carrierNum;
+  if (form.value.deliveryMethod == 1) {
+    form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
+  } else {
+    form.value.freightAmount = 0.0;
   }
   form.value.details.splice(index, 1);
 };
@@ -555,6 +610,7 @@ function reset() {
     packagingMethod: "0",
     remark: null,
     details: [],
+    isSubmit:0
   };
   proxy.resetForm("formRef");
 }
@@ -625,7 +681,7 @@ function submitFrom() {
           }
         }
         if (valid) {
-          console.log(form.value)
+          console.log(form.value);
           submitOrder(form.value).then((response) => {
             proxy.$modal.msgSuccess("提交成功");
             visible.value = false;
@@ -636,6 +692,79 @@ function submitFrom() {
     })
     .catch(() => {});
 }
+//5.29保存
+function handleSubmit() {
+  if(form.value.isSubmit==0){
+  proxy.$modal
+    .confirm("是否确定保存,保存后外协商不可编辑!")
+    .then(function () {
+      return;
+    })
+    .then(() => {
+      if (!form.value.details || form.value.details.length == 0) {
+        proxy.$modal.msgError("请添加产品明细");
+        return;
+      }
+
+      proxy.$refs["formRef"].validate((valid) => {
+        for (const item of form.value.details) {
+          if (!item.processNames) {
+            proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
+            return;
+          }
+        }
+        if (form.value.packagingMethod == 1) {
+          console.log("form.value.details", form.value.details);
+          for (const item of form.value.details) {
+            if (item.newCarriers.length == 0) {
+              proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
+              return;
+            }
+          }
+        }
+        if (valid) {
+          console.log(form.value)
+          submitDetails(form.value).then((response) => {
+            proxy.$modal.msgSuccess("提交成功");
+            visible.value = false;
+            getList.value();
+          });
+        }
+      });
+    })
+  }else{
+    if (!form.value.details || form.value.details.length == 0) {
+        proxy.$modal.msgError("请添加产品明细");
+        return;
+      }
+
+      proxy.$refs["formRef"].validate((valid) => {
+        for (const item of form.value.details) {
+          if (!item.processNames) {
+            proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
+            return;
+          }
+        }
+        if (form.value.packagingMethod == 1) {
+          console.log("form.value.details", form.value.details);
+          for (const item of form.value.details) {
+            if (item.newCarriers.length == 0) {
+              proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
+              return;
+            }
+          }
+        }
+        if (valid) {
+          console.log(form.value)
+          submitDetails(form.value).then((response) => {
+            proxy.$modal.msgSuccess("提交成功");
+            visible.value = false;
+            getList.value();
+          });
+        }
+      });
+  }
+}
 
 /***************************** 外协商对话框相关 *****************************/
 // 打开外协商选择对话框
@@ -649,12 +778,12 @@ const handleSingleSelectedSupplier = (data) => {
   form.value.lossLimit = data.lossLimit;
   form.value.supplierName = data.name;
   form.value.deliveryMethod = data.deliveryMethod;
-  form.value.freightPrice = data.freightPrice
+  form.value.freightPrice = data.freightPrice;
   form.value.settlementType = data.settlementType;
-  if(form.value.deliveryMethod == 1) {
-    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
-  }else {
-    form.value.freightAmount = 0.0
+  if (form.value.deliveryMethod == 1) {
+    form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
+  } else {
+    form.value.freightAmount = 0.0;
   }
 };
 /***************************** 外协收回明细相关 *****************************/
@@ -662,9 +791,7 @@ const handleSingleSelectedSupplier = (data) => {
 function handleDetailsRecycling() {
   proxy.$refs.formDetailsRecyclingRef.open(row);
 }
-function handleSingleSelectedRecycling() {
-  
-}
+function handleSingleSelectedRecycling() {}
 /***************************** 产品对话框相关 *****************************/
 // 打开产品选择对话框
 const handleShowDialogProducts = () => {
@@ -685,12 +812,12 @@ const handleMultipleSelectedProducts = (selection) => {
       technologyVersion: item.technologyVersion,
       originalCarrier: item.originalCarrier,
       originalCarrierCount: item.originalCarrier.split(",").length,
-      carrierNum:item.originalCarrier.split(",").length,
-      originalCarrierList:item.originalCarrierList,
+      carrierNum: item.originalCarrier.split(",").length,
+      originalCarrierList: item.originalCarrierList,
       productNum: item.productNum,
       productCode: item.productCode,
       newCarrier: "",
-      carriers:[],
+      carriers: [],
       newCarrierCount: 0,
       newCarriers: [],
       processNames: "",
@@ -698,13 +825,14 @@ const handleMultipleSelectedProducts = (selection) => {
       processes: [],
     };
     form.value.details.push(newDetail);
-    console.log(newDetail)
-    totalCarriersNum.value += newDetail.originalCarrierCount
-    if(form.value.deliveryMethod == 1) {
-    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
-    }else {
-    form.value.freightAmount = 0.0
-  }
+    console.log(newDetail);
+    totalCarriersNum.value += newDetail.originalCarrierCount;
+    if (form.value.deliveryMethod == 1) {
+      form.value.freightAmount =
+        form.value.freightPrice * totalCarriersNum.value;
+    } else {
+      form.value.freightAmount = 0.0;
+    }
     // console.log("form.value.details", form.value.details);
   });
 };
@@ -713,13 +841,13 @@ const handleMultipleSelectedProducts = (selection) => {
 // 打开外协箱子选择对话框
 const handleShowDialogOutsourceCarriers = (row) => {};
 
-function remoteCarriers(code, newCarrier,row) {
+function remoteCarriers(code, newCarrier, row) {
   loadingCarrier.value = true;
   // console.log(row, carriers.value)
   console.log("row", row);
   // if (true) {
   //   carriers.value = [{ value: '"1747500987856662535"', label: '000319' }]
-  //   return 
+  //   return
   // }
   let categoryId;
   if (form.value.packagingMethod == 1) {
@@ -733,6 +861,7 @@ function remoteCarriers(code, newCarrier,row) {
   carrierForOutsource({
     categoryId: categoryId,
     code: code,
+    dayworkId:row.dayworkId
   }).then((res) => {
     if (res.code === 200) {
       carriers.value = res.rows.map((v) => ({ value: v.id, label: v.code }));
@@ -754,49 +883,67 @@ function remoteCarriers(code, newCarrier,row) {
 }
 //换箱
 function handleChangeCarrier(row) {
-  console.log(row)
-  if(editStatus.value && !form.value.id){
-  if(form.value.packagingMethod == 0) {
-    row.newCarriers.push(...row.originalCarrierList.map(v => ({ id: v.carrierId, code: v.carrierCode })))
-    row.carriers.push( ...row.originalCarrierList.map((v) => ({ value: v.carrierId, label: v.carrierCode })))
-    row.carrierIds = row.originalCarrierList.map(info => { return info.carrierId })
-  }else{
-    row.newCarriers = null
+  console.log(row);
+  if (editStatus.value && !form.value.id) {
+    if (form.value.packagingMethod == 0) {
+      row.newCarriers.push(
+        ...row.originalCarrierList.map((v) => ({
+          id: v.carrierId,
+          code: v.carrierCode,
+        }))
+      );
+      row.carriers.push(
+        ...row.originalCarrierList.map((v) => ({
+          value: v.carrierId,
+          label: v.carrierCode,
+        }))
+      );
+      row.carrierIds = row.originalCarrierList.map((info) => {
+        return info.carrierId;
+      });
+    } else {
+      row.newCarriers = null;
+    }
+  }
+  if (editStatus.value && form.value.id) {
+    row.carriers = [];
+    row.newCarriers.map((v) => ({ id: v.value, code: v.label }));
+    console.log(row.newCarriers);
+    row.carriers = row.newCarriers.map((v) => ({ value: v.id, label: v.code }));
+    row.carrierIds = row.newCarriers.map((info) => {
+      return info.id;
+    });
+    console.log(row);
   }
-}
-if(editStatus.value && form.value.id){
-  row.carriers = []
-    row.newCarriers.map(v => ({ id: v.value, code: v.label }))
-    console.log(row.newCarriers)
-    row.carriers = row.newCarriers.map((v) => ({ value: v.id, label: v.code }))
-    row.carrierIds = row.newCarriers.map(info => { return info.id })
-    console.log(row)
-}
   row.editStatus = true;
 }
 function handleCarrierChange(arg, item) {
-  totalCarriersNum.value = 0
+  totalCarriersNum.value = 0;
   item.newCarriers = item.carriers
     .filter((v) => arg.includes(v.value))
     .map((v) => ({ id: v.value, code: v.label }));
-    console.log(item.newCarriers)
-    item.carrierNum = item.newCarriers.length
+  console.log(item.newCarriers);
+  item.carrierNum = item.newCarriers.length;
 
-    for(let i = 0;i<form.value.details.length;i++) {
-    if(form.value.packagingMethod == 1) {
-        form.value.details[i].carrierNum =form.value.details[i].newCarriers? form.value.details[i].newCarriers.length:0
-      }else {
-        //原厂蓝箱
-        form.value.details[i].carrierNum =form.value.details[i].newCarriers? form.value.details[i].newCarriers.length:form.value.details[i].originalCarrier.split(",").length
-      }
-      console.log(form.value.details)
-      totalCarriersNum.value += form.value.details[i].carrierNum
+  for (let i = 0; i < form.value.details.length; i++) {
+    if (form.value.packagingMethod == 1) {
+      form.value.details[i].carrierNum = form.value.details[i].newCarriers
+        ? form.value.details[i].newCarriers.length
+        : 0;
+    } else {
+      //原厂蓝箱
+      form.value.details[i].carrierNum = form.value.details[i].newCarriers
+        ? form.value.details[i].newCarriers.length
+        : form.value.details[i].originalCarrier.split(",").length;
+    }
+    console.log(form.value.details);
+    totalCarriersNum.value += form.value.details[i].carrierNum;
+  }
+  if (form.value.deliveryMethod == 1) {
+    form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
+  } else {
+    form.value.freightAmount = 0.0;
   }
-       if(form.value.deliveryMethod == 1) {
-        form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
-        }else {
-          form.value.freightAmount = 0.0
-        }
 }
 
 /** 使用新方式 */
@@ -840,6 +987,7 @@ const handleShowDialogProcesses = (row) => {
 
 // 工序选择带回
 const handleMultipleSelectedProcesses = (selection) => {
+  currentDetail.value.processes = []
   const processNames = selection.map((item) => item.processAlias);
   // 使用join方法将数组转换为以逗号分隔的字符串
   let commaSeparatedString = processNames.join(",");

+ 937 - 0
src/views/business/outsource/formOld.vue

@@ -0,0 +1,937 @@
+<template>
+  <el-drawer
+    title="外协单信息"
+    :with-header="false"
+    v-model="visible"
+    direction="rtl"
+    size="100%"
+  >
+    <div class="form-container column-container">
+      <div class="form-btns-container">
+        <span class="title-label">
+          <el-icon><Document /></el-icon>
+          <span>外协单信息</span>
+        </span>
+
+        <!-- <el-button
+          v-if="editStatus"
+          type="success"
+          icon="check"
+          @click="saveFrom"
+        >
+          暂存
+        </el-button> -->
+
+        <el-button
+          v-if="editStatus && form.isSubmit==1"
+          type="primary"
+          icon="Download"
+          @click="handleExport"
+          v-hasPermi="['business:outsource:export']"
+          >导出</el-button
+        >
+        <el-button
+          v-if="editStatus"
+          type="primary"
+          icon="Finished"
+          @click="handleSubmit"
+          >保存</el-button
+        >
+        <div class="close-btn" @click="cancel">
+          <i class="fa fa-times" aria-hidden="true" />
+          <!-- <span>关闭</span> -->
+        </div>
+      </div>
+      <el-form
+        ref="formRef"
+        class="master-container"
+        :model="form"
+        v-loading="loading"
+        :rules="rules"
+        label-width="120px"
+      >
+        <el-row :gutter="20">
+          <el-col :span="6">
+            <el-form-item label="单据号" prop="formCode">
+              <el-input
+                v-if="editStatus"
+                v-model="form.formCode"
+                disabled
+                placeholder="系统自动生成"
+              />
+              <span v-else>{{ form.formCode }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="表单日期" prop="formDate">
+              <el-date-picker
+                v-if="editStatus"
+                clearable
+                v-model="form.formDate"
+                type="date"
+                value-format="YYYY-MM-DD"
+                placeholder="请选择表单日期"
+                style="width: 100%"
+              >
+              </el-date-picker>
+              <span v-else>{{ parseTime(form.formDate, "{y}-{m}-{d}") }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="外协商名称" prop="supplierName">
+              <el-input
+                v-if="editStatus && form.isSubmit == 0"
+                v-model="form.supplierName"
+                readonly
+                placeholder="请输入外协商名称"
+              >
+                <template #append>
+                  <el-button icon="Search" @click="handleShowDialogSuppliers" />
+                </template>
+              </el-input>
+              <span v-else>{{ form.supplierName }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="运费单价" prop="freightPrice">
+              <el-input-number
+                v-if="editStatus"
+                v-model="form.freightPrice"
+                :min="0"
+                :precision="2"
+                controls-position="right"
+              />
+              <span v-else>{{ form.freightPrice }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="运费总价" prop="freightAmount">
+              <el-input-number
+                v-if="editStatus"
+                v-model="form.freightAmount"
+                :min="0"
+                :precision="2"
+                controls-position="right"
+              />
+              <span v-else>{{ form.freightAmount }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="送货方式" prop="deliveryMethod">
+              <el-select
+                v-if="editStatus"
+                v-model="form.deliveryMethod"
+                placeholder="请选择"
+                @change="handleChangeDeliveryMethod"
+              >
+                <el-option
+                  v-for="dict in deliveryMethod"
+                  :key="dict.value"
+                  :label="dict.label"
+                  :value="dict.value"
+                />
+              </el-select>
+              <span v-else>{{
+                selectText(form.deliveryMethod, deliveryMethod)
+              }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="带箱方式" prop="packagingMethod">
+              <el-select
+                v-if="editStatus"
+                v-model="form.packagingMethod"
+                placeholder="请选择"
+                @change="handleChangePackagingMethod"
+              >
+                <el-option
+                  v-for="dict in packagingMethod"
+                  :key="dict.value"
+                  :label="dict.label"
+                  :value="dict.value"
+                />
+              </el-select>
+              <span v-else>{{
+                selectText(form.packagingMethod, packagingMethod)
+              }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="结算方式" prop="settlementType">
+              <el-select
+                v-if="editStatus"
+                v-model="form.settlementType"
+                placeholder="请选择"
+              >
+                <el-option
+                  v-for="dict in settlementType"
+                  :key="dict.value"
+                  :label="dict.label"
+                  :value="dict.value"
+                />
+              </el-select>
+              <span v-else>{{
+                selectText(form.settlementType, settlementType)
+              }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="备注" prop="remark">
+              <el-input
+                v-if="editStatus"
+                v-model.trim="form.remark"
+                placeholder="请输入备注"
+              />
+              <span v-else>{{ form.remark }}</span>
+            </el-form-item>
+          </el-col>
+          <el-col :span="6">
+            <el-form-item label="总箱数" prop="remark">
+              <span >{{ totalCarriersNum }}</span>
+            </el-form-item>
+          </el-col>
+        </el-row>
+      </el-form>
+      <!-- 渲染数据区 -->
+      <div class="form-details-btns-container">
+        <el-button
+          v-if="editStatus"
+          type="primary"
+          icon="Plus"
+          @click="handleShowDialogProducts"
+          v-hasPermi="['business:outsource:add']"
+        >
+          添加外协产品明细
+        </el-button>
+      </div>
+      <div class="el-table-container">
+        <div class="el-table-inner-container">
+          <el-table
+            v-loading="loading"
+            :data="form.details"
+            size="small"
+            border
+            height="100%"
+          >
+            <el-table-column
+              label="行号"
+              type="index"
+              align="center"
+              width="48"
+            />
+            <el-table-column
+              label="批次号"
+              align="center"
+              prop="lotCode"
+              width="104"
+            />
+            <el-table-column
+              label="产品描述"
+              align="center"
+              prop="productDescription"
+              width="320"
+            />
+            <el-table-column label="产品数" align="center" width="160" prop="productNum">
+              <template #default="scope">
+                <el-input-number
+                  v-if="editStatus"
+                  :min="0"
+                  v-model="scope.row.productNum"
+                  placeholder="产品数"
+                />
+                <span v-else>{{ scope.row.productNum }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="箱数"
+              align="center"
+              prop="carrierNum"
+              width="70"
+            />
+            <el-table-column
+              :label="form.packagingMethod === '0' ? '箱号' : '原箱号'"
+              align="center"
+              prop="originalCarrier"
+              width="320"
+            />
+            <el-table-column
+              label="新箱号"
+              align="center"
+              prop="newCarrier"
+              width="320"
+            >
+              <template #default="scope">
+                <el-button link type="primary" icon="Refresh" v-if="!scope.row.editStatus && editStatus" @click="handleChangeCarrier(scope.row)">换箱</el-button>
+                <el-select
+                  v-if="editStatus && scope.row.editStatus"
+                  v-model="scope.row.carrierIds"
+                  multiple
+                  filterable
+                  remote
+                  reserve-keyword
+                  placeholder="请选择箱号"
+                  :remote-method="
+                    (arg) => remoteCarriers(arg, scope.row.newCarriers,scope.row)
+                  "
+                  :loading="loadingCarrier"
+                  @change="(arg) => handleCarrierChange(arg, scope.row)"
+                >
+                  <el-option
+                    v-for="item in scope.row.carriers"
+                    :key="item.value"
+                    :label="item.label"
+                    :value="item.value"
+                  />
+                </el-select>
+                <span v-if="!editStatus">{{ scope.row.newCarrier }}</span>
+                <!-- <el-input
+                  v-if="editStatus"
+                  v-model="scope.row.newCarrier"
+                  readonly
+                  placeholder="请选择新箱号"
+                >
+                  <template #append>
+                    <el-button
+                      icon="Search"
+                      @click="handleShowDialogOutsourceCarriers(scope.row)"
+                    />
+                  </template>
+                </el-input>
+                <span v-else>{{ scope.row.newCarrier }}</span>-->
+              </template>
+            </el-table-column>
+            <el-table-column
+              label="外协工序"
+              align="center"
+              prop="processNames"
+              width="320"
+            >
+              <template #default="scope">
+                <el-input
+                  v-if="editStatus"
+                  v-model="scope.row.processNames"
+                  readonly
+                  placeholder="请选择工序"
+                >
+                  <template #append>
+                    <el-button
+                      icon="Search"
+                      @click="handleShowDialogProcesses(scope.row)"
+                    />
+                  </template>
+                </el-input>
+                <span v-else>{{ scope.row.processNames }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="备注" align="center" prop="remark">
+              <template #default="scope">
+                <el-input
+                  v-if="editStatus"
+                  v-model="scope.row.remark"
+                  placeholder="备注"
+                />
+                <span v-else>{{ scope.row.remark }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column
+              v-if="editStatus"
+              label="操作"
+              align="center"
+              class-name="small-padding fixed-width"
+              width="64"
+            >
+              <template #default="scope">
+                <el-button
+                  circle
+                  type="danger"
+                  icon="Delete"
+                  @click="handleDelete(scope.$index)"
+                  v-hasPermi="['business:outsource:remove']"
+                />
+              </template>
+            </el-table-column>
+          </el-table>
+        </div>
+      </div>
+    </div>
+    <!-- 外协商选择 -->
+    <dialog-suppliers
+      ref="dialogSuppliersRef"
+      :single-selected="handleSingleSelectedSupplier"
+    />
+    <!-- 产品选择 -->
+    <dialog-products
+      ref="dialogProductsRef"
+      :supplier-id="form.supplierId"
+      :multiple-selected="handleMultipleSelectedProducts"
+    />
+    <!-- 工序选择 -->
+    <dialog-processes
+      ref="dialogProcessesRef"
+      :multiple-selected="handleMultipleSelectedProcesses"
+    />
+    <!-- 新箱号选择 -->
+    <dialog-carrier
+      ref="dialogCarrierRef"
+      :multiple-selected="handleMultipleSelectedOutsourceCarriers"
+    />
+  </el-drawer>
+</template>
+<script setup>
+import {
+  getOrder,
+  saveOrder,
+  carrierForOutsource,
+  submitOrder,
+  exportOutsource,
+  submitDetails
+} from "@/api/business/outsourcedOrder";
+import dialogCarrier from "./DialogCarrier";
+import dialogSuppliers from "./DialogSuppliers";
+import dialogProducts from "./DialogProducts";
+import dialogProcesses from "./DialogProcesses";
+const { proxy } = getCurrentInstance();
+/** 父组件传参 */
+const props = defineProps({
+  getList: {
+    type: Function,
+    default: () => {},
+  },
+  deliveryMethod: {
+    type: Array,
+    default: [],
+  },
+  settlementType: {
+    type: Array,
+    default: [],
+  },
+  packagingMethod: {
+    type: Array,
+    default: [],
+  },
+});
+const { getList, deliveryMethod, packagingMethod, settlementType } =
+  toRefs(props);
+/** 字典数组区 */
+/** 表单抽屉 页变量 */
+
+const loading = ref(false);
+const multiple = ref(true);
+const visible = ref(false);
+const editStatus = ref(true);
+const detailInfo = ref({});
+const totalCarriersNum = ref(0)
+const loadingCarrier = ref(false);
+const carriers = ref([]);
+const webHost = import.meta.env.VITE_APP_BASE_API;
+const form = ref({});
+// const formatDetails = ref([])
+const currentDetail = ref({});
+const rules = {
+  supplierName: [
+    { required: true, message: "外协商名称不能为空", trigger: "change" },
+  ],
+};
+
+/***********************  方法区  ****************************/
+/** 导出按钮操作 */
+function handleExport() {
+  exportOutsource({ id: form.value.id });
+}
+
+/** 打开抽屉 */
+function open(row) {
+  reset();
+  totalCarriersNum.value = 0
+  visible.value = true;
+  if (row) {
+    console.log(row)
+    detailInfo.value = row
+    form.value.id = row.id;
+    getForm();
+  } else {
+    editStatus.value = true;
+  }
+}
+
+/** 查询表单信息  */
+function getForm() {
+  loading.value = true;
+  getOrder(form.value.id).then((response) => {
+    form.value = response.data
+    console.log(form.value.details)
+    form.value.details.forEach(item =>{
+      item.editStatus = false
+     if(!form.value.id) {
+        item.carrierNum = item.originalCarrier.split(",").length
+      }else {
+        if(item.newCarrier !=null) {
+        item.carrierNum = item.newCarrier.split(",").length
+      }else {
+        item.carrierNum = item.originalCarrier.split(",").length
+      }
+      }
+      totalCarriersNum.value += item.carrierNum
+    })
+
+    editStatus.value = form.value.isSubmit == 1;
+    if(!detailInfo.value.flag) {
+      editStatus.value = false
+      console.log(editStatus.value)
+    }
+    console.log(editStatus.value)
+    loading.value = false;
+  });
+}
+//改变带箱方式
+function handleChangePackagingMethod() {
+  totalCarriersNum.value = 0
+  if(!editStatus){
+  if(form.value.packagingMethod == 1 && form.value.details.length>0) {
+    form.value.details.forEach(item =>{item.newCarriers = [];item.carrierIds = [];item.carriers = carriers.value})
+  }if(form.value.packagingMethod == 0 &&form.value.details.length>0) {
+    form.value.details.forEach(item =>{
+      item.carriers = carriers.value;
+      item.newCarriers = [];
+      item.carrierIds = [];
+      item.newCarriers.push(...item.originalCarrierList.map(v => ({ id: v.carrierId, code: v.carrierCode })));
+      item.carriers.push( ...item.originalCarrierList.map((v) => ({ value: v.carrierId, label: v.carrierCode })));
+      item.carrierIds = item.originalCarrierList.map(info => { return info.carrierId }) 
+    })
+  }
+}else{
+  form.value.details.forEach(item =>{item.newCarriers = [];item.carrierIds = [];item.carriers = carriers.value})
+}
+  console.log(form.value.details)
+  for(let i = 0;i<form.value.details.length;i++) {
+    if(form.value.packagingMethod == 1) {
+        form.value.details[i].carrierNum =form.value.details[i].newCarriers? form.value.details[i].newCarriers.length:0
+      }else {
+        form.value.details[i].carrierNum = form.value.details[i].newCarriers && form.value.details[i].newCarriers.length>0? form.value.details[i].newCarriers.length:form.value.details[i].originalCarrier.split(",").length
+      }
+      console.log(form.value.details)
+      totalCarriersNum.value += form.value.details[i].carrierNum
+  }
+}
+//改变送货方式
+function handleChangeDeliveryMethod() {
+  if(form.value.deliveryMethod == 1) {
+    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
+  }else {
+    form.value.freightAmount = 0.0
+  }
+ 
+}
+
+function selectText(value, data) {
+  if (value) {
+    return data.filter((item) => item.value == value)[0].label;
+  }
+}
+
+/** 取消按钮 */
+function cancel() {
+  visible.value = false;
+  reset();
+}
+
+const handleDelete = (index) => {
+  totalCarriersNum.value -=form.value.details[index].carrierNum
+  if(form.value.deliveryMethod == 1) {
+    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
+  }else {
+    form.value.freightAmount = 0.0
+  }
+  form.value.details.splice(index, 1);
+};
+
+/** 表单重置 */
+function reset() {
+  form.value = {
+    id: null,
+    tenantId: null,
+    formCode: null,
+    formDate: proxy.parseTime(new Date(), "{y}-{m}-{d}"),
+    supplierId: "0",
+    supplierName: "",
+    deliveryMethod: "0",
+    freightPrice: 0.0,
+    freightAmount: 0.0,
+    packagingMethod: "0",
+    remark: null,
+    details: [],
+    isSubmit:0
+  };
+  proxy.resetForm("formRef");
+}
+/** 保存 */
+function saveFrom() {
+  if (!form.value.details || form.value.details.length == 0) {
+    proxy.$modal.msgError("请添加产品明细");
+    return;
+  }
+
+  proxy.$refs["formRef"].validate((valid) => {
+    for (const item of form.value.details) {
+      if (!item.processNames) {
+        proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
+        return;
+      }
+    }
+
+    if (form.value.packagingMethod == 1) {
+      console.log("form.value.details", form.value.details);
+      for (const item of form.value.details) {
+        if (item.newCarriers.length == 0) {
+          proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
+          return;
+        }
+      }
+    }
+    if (valid) {
+      saveOrder(form.value).then((response) => {
+        if (response.code == 200) {
+          proxy.$modal.msgSuccess("保存成功");
+          visible.value = false;
+          getList.value();
+        }
+      });
+    }
+  });
+}
+
+/** 保存并提交 */
+function submitFrom() {
+  console.log("from", form.value);
+  proxy.$modal
+    .confirm("是否确定提交,提交后不可修改,删除")
+    .then(function () {
+      return;
+    })
+    .then(() => {
+      if (!form.value.details || form.value.details.length == 0) {
+        proxy.$modal.msgError("请添加产品明细");
+        return;
+      }
+
+      proxy.$refs["formRef"].validate((valid) => {
+        for (const item of form.value.details) {
+          if (!item.processNames) {
+            proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
+            return;
+          }
+        }
+        if (form.value.packagingMethod == 1) {
+          console.log("form.value.details", form.value.details);
+          for (const item of form.value.details) {
+            if (item.newCarriers.length == 0) {
+              proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
+              return;
+            }
+          }
+        }
+        if (valid) {
+          console.log(form.value)
+          submitOrder(form.value).then((response) => {
+            proxy.$modal.msgSuccess("提交成功");
+            visible.value = false;
+            getList.value();
+          });
+        }
+      });
+    })
+    .catch(() => {});
+}
+//5.29保存
+function handleSubmit() {
+  if(form.value.isSubmit==0){
+  proxy.$modal
+    .confirm("是否确定保存,保存后外协商不可编辑!")
+    .then(function () {
+      return;
+    })
+    .then(() => {
+      if (!form.value.details || form.value.details.length == 0) {
+        proxy.$modal.msgError("请添加产品明细");
+        return;
+      }
+
+      proxy.$refs["formRef"].validate((valid) => {
+        for (const item of form.value.details) {
+          if (!item.processNames) {
+            proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
+            return;
+          }
+        }
+        if (form.value.packagingMethod == 1) {
+          console.log("form.value.details", form.value.details);
+          for (const item of form.value.details) {
+            if (item.newCarriers.length == 0) {
+              proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
+              return;
+            }
+          }
+        }
+        if (valid) {
+          console.log(form.value)
+          submitDetails(form.value).then((response) => {
+            proxy.$modal.msgSuccess("提交成功");
+            visible.value = false;
+            getList.value();
+          });
+        }
+      });
+    })
+  }else{
+    if (!form.value.details || form.value.details.length == 0) {
+        proxy.$modal.msgError("请添加产品明细");
+        return;
+      }
+
+      proxy.$refs["formRef"].validate((valid) => {
+        for (const item of form.value.details) {
+          if (!item.processNames) {
+            proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
+            return;
+          }
+        }
+        if (form.value.packagingMethod == 1) {
+          console.log("form.value.details", form.value.details);
+          for (const item of form.value.details) {
+            if (item.newCarriers.length == 0) {
+              proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
+              return;
+            }
+          }
+        }
+        if (valid) {
+          console.log(form.value)
+          submitDetails(form.value).then((response) => {
+            proxy.$modal.msgSuccess("提交成功");
+            visible.value = false;
+            getList.value();
+          });
+        }
+      });
+  }
+}
+
+/***************************** 外协商对话框相关 *****************************/
+// 打开外协商选择对话框
+const handleShowDialogSuppliers = () => {
+  proxy.$refs.dialogSuppliersRef.open();
+};
+// 外协商选择带回
+const handleSingleSelectedSupplier = (data) => {
+  console.log(data);
+  form.value.supplierId = data.id;
+  form.value.lossLimit = data.lossLimit;
+  form.value.supplierName = data.name;
+  form.value.deliveryMethod = data.deliveryMethod;
+  form.value.freightPrice = data.freightPrice
+  form.value.settlementType = data.settlementType;
+  if(form.value.deliveryMethod == 1) {
+    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
+  }else {
+    form.value.freightAmount = 0.0
+  }
+};
+/***************************** 产品对话框相关 *****************************/
+// 打开产品选择对话框
+const handleShowDialogProducts = () => {
+  const dayworkIds = form.value.details.map((item) => item.dayworkId);
+  // console.log(dayworkIds);
+  proxy.$refs.dialogProductsRef.open(dayworkIds);
+};
+// 产品选择带回
+const handleMultipleSelectedProducts = (selection) => {
+  selection.forEach((item) => {
+    const newDetail = {
+      lotId: item.lotId,
+      lotCode: item.lotCode,
+      dayworkId: item.id,
+      productId: item.productId,
+      productDescription: item.productDescription,
+      technologicalProcessId: item.technologicalProcessId,
+      technologyVersion: item.technologyVersion,
+      originalCarrier: item.originalCarrier,
+      originalCarrierCount: item.originalCarrier.split(",").length,
+      carrierNum:item.originalCarrier.split(",").length,
+      originalCarrierList:item.originalCarrierList,
+      productNum: item.productNum,
+      productCode: item.productCode,
+      newCarrier: "",
+      carriers:[],
+      newCarrierCount: 0,
+      newCarriers: [],
+      processNames: "",
+      remark: item.remark,
+      processes: [],
+    };
+    form.value.details.push(newDetail);
+    console.log(newDetail)
+    totalCarriersNum.value += newDetail.originalCarrierCount
+    if(form.value.deliveryMethod == 1) {
+    form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
+    }else {
+    form.value.freightAmount = 0.0
+  }
+    // console.log("form.value.details", form.value.details);
+  });
+};
+
+/***************************** 外协箱子对话框相关 *****************************/
+// 打开外协箱子选择对话框
+const handleShowDialogOutsourceCarriers = (row) => {};
+
+function remoteCarriers(code, newCarrier,row) {
+  loadingCarrier.value = true;
+  // console.log(row, carriers.value)
+  console.log("row", row);
+  // if (true) {
+  //   carriers.value = [{ value: '"1747500987856662535"', label: '000319' }]
+  //   return 
+  // }
+  let categoryId;
+  if (form.value.packagingMethod == 1) {
+    categoryId = "1783783697558847489";
+  } else {
+    categoryId = "2";
+  }
+  if (code == "") {
+    return;
+  }
+  carrierForOutsource({
+    categoryId: categoryId,
+    code: code,
+    dayworkId:row.dayworkId
+  }).then((res) => {
+    if (res.code === 200) {
+      carriers.value = res.rows.map((v) => ({ value: v.id, label: v.code }));
+      row.carriers = res.rows.map((v) => ({ value: v.id, label: v.code }));
+      if (Array.isArray(newCarrier)) {
+        // 安全地更新 carriers
+        row.carriers.push(
+          ...newCarrier
+            .filter((v) => !row.carriers.map((e) => e.value).includes(v.id))
+            .map((v) => ({ value: v.id, label: v.code }))
+        );
+      }
+    } else {
+      row.carriers = [];
+      row.carriers.push(...newCarrier);
+    }
+    loadingCarrier.value = false;
+  });
+}
+//换箱
+function handleChangeCarrier(row) {
+  console.log(row)
+  if(editStatus.value && !form.value.id){
+  if(form.value.packagingMethod == 0) {
+    row.newCarriers.push(...row.originalCarrierList.map(v => ({ id: v.carrierId, code: v.carrierCode })))
+    row.carriers.push( ...row.originalCarrierList.map((v) => ({ value: v.carrierId, label: v.carrierCode })))
+    row.carrierIds = row.originalCarrierList.map(info => { return info.carrierId })
+  }else{
+    row.newCarriers = null
+  }
+}
+if(editStatus.value && form.value.id){
+  row.carriers = []
+    row.newCarriers.map(v => ({ id: v.value, code: v.label }))
+    console.log(row.newCarriers)
+    row.carriers = row.newCarriers.map((v) => ({ value: v.id, label: v.code }))
+    row.carrierIds = row.newCarriers.map(info => { return info.id })
+    console.log(row)
+}
+  row.editStatus = true;
+}
+function handleCarrierChange(arg, item) {
+  totalCarriersNum.value = 0
+  item.newCarriers = item.carriers
+    .filter((v) => arg.includes(v.value))
+    .map((v) => ({ id: v.value, code: v.label }));
+    console.log(item.newCarriers)
+    item.carrierNum = item.newCarriers.length
+
+    for(let i = 0;i<form.value.details.length;i++) {
+    if(form.value.packagingMethod == 1) {
+        form.value.details[i].carrierNum =form.value.details[i].newCarriers? form.value.details[i].newCarriers.length:0
+      }else {
+        //原厂蓝箱
+        form.value.details[i].carrierNum =form.value.details[i].newCarriers? form.value.details[i].newCarriers.length:form.value.details[i].originalCarrier.split(",").length
+      }
+      console.log(form.value.details)
+      totalCarriersNum.value += form.value.details[i].carrierNum
+  }
+       if(form.value.deliveryMethod == 1) {
+        form.value.freightAmount= form.value.freightPrice * totalCarriersNum.value
+        }else {
+          form.value.freightAmount = 0.0
+        }
+}
+
+/** 使用新方式 */
+// const handleShowDialogOutsourceCarriers = (row) => {
+//   // 确保 form.details 存在且不是 undefined
+//   let allNewCarriers;
+//   if (form.value && form.value.details && Array.isArray(form.value.details)) {
+//     allNewCarriers = form.value.details
+//       .flatMap((detail) =>
+//         detail.newCarriers ? detail.newCarriers.filter((item) => item) : []
+//       )
+//       .filter(Boolean);
+
+//     // 现在 allNewCarriers 包含了所有非空的 newCarriers 数组的元素
+//   }
+//   // form.value.details.newCarriers
+//   // const allNewCarriers = form.details.flatMap((detail) => detail.newCarriers);
+//   console.log("allNewCarriers", allNewCarriers);
+//   proxy.$refs.dialogCarrierRef.open(row.lotId, from.value.deliveryMethod);
+// };
+
+// 箱子选择带回
+const handleMultipleSelectedOutsourceCarriers = (selection, lotId) => {
+  const carrierNames = selection.map((item) => item.code);
+  let carrierNamesString = carrierNames.join(",");
+  form.value.details.map((item) => {
+    if (item.lotId == lotId) {
+      item.newCarrier = carrierNamesString;
+      item.newCarrierCount = selection.length;
+      item.newCarriers = selection;
+    }
+  });
+};
+
+/***************************** 外协工序对话框相关 *****************************/
+// 打开外协工序选择对话框
+const handleShowDialogProcesses = (row) => {
+  currentDetail.value = row;
+  proxy.$refs.dialogProcessesRef.open(row);
+};
+
+// 工序选择带回
+const handleMultipleSelectedProcesses = (selection) => {
+  currentDetail.value.processes = []
+  const processNames = selection.map((item) => item.processAlias);
+  // 使用join方法将数组转换为以逗号分隔的字符串
+  let commaSeparatedString = processNames.join(",");
+  currentDetail.value.processes = [];
+  currentDetail.value.processNames = commaSeparatedString;
+  selection.forEach((item) => {
+    const newProcess = {
+      processId: item.processId,
+      processCode: item.processCode,
+      processAlias: item.processAlias,
+      processStepNumber: item.processStepNumber,
+      technologicalProcessDetailId: item.id,
+    };
+    currentDetail.value.processes.push(newProcess);
+  });
+};
+
+/** 暴露给父组件的方法 */
+defineExpose({
+  open,
+});
+</script>

+ 10 - 6
src/views/business/outsource/index.vue

@@ -192,11 +192,11 @@
             label="操作"
             align="center"
             class-name="small-padding fixed-width"
-            width="144"
+            width="200"
           >
             <template #default="scope">
               <el-button
-                v-if="scope.row.isSubmit == 0"
+                v-if="scope.row.isSubmit == 1"
                 link
                 type="warning"
                 icon="Edit"
@@ -206,17 +206,15 @@
                 编辑
               </el-button>
               <el-button
-                v-if="scope.row.isSubmit == 1"
                 link
                 type="primary"
                 icon="View"
-                @click="handleUpdate(scope.row)"
+                @click="handleView(scope.row)"
                 v-hasPermi="['business:outsource:query']"
               >
                 查看
               </el-button>
               <el-button
-                v-if="scope.row.isSubmit == 0"
                 link
                 type="danger"
                 icon="Delete"
@@ -328,7 +326,13 @@ function handleAdd() {
 /** 修改按钮操作 */
 function handleUpdate(row) {
   const id = row.id || ids.value;
-  proxy.$refs.orderRef.open(id);
+  row.flag = true
+  proxy.$refs.orderRef.open(row);
+}
+function handleView(row) {
+  const id = row.id || ids.value;
+  row.flag =false
+  proxy.$refs.orderRef.open(row);
 }
 
 /** 删除按钮操作 */

+ 331 - 0
src/views/business/product/drawingForm.vue

@@ -0,0 +1,331 @@
+<template>
+  <!-- 添加或修改项目信息对话框 -->
+  <el-drawer v-model="visible" size="30%" direction="rtl" :close-on-press-escape="false">
+    <div class="page-container form-container">
+      <div class="form-btns-container">
+        <span class="title-label"><el-icon>
+            <Document />
+          </el-icon>
+          电子工艺图纸</span>
+      </div>
+
+      <!-- 搜索区域 -->
+      <el-form class="list-search-container" :inline="true">
+        <el-form-item>
+          <el-upload :action="webHost + '/common/upload'" :headers="headers" :on-success="handleSuccess"
+            :on-exceed="handleExceed" :before-upload="beforeUpload" :show-file-list="false">
+            <el-button type="success" icon="Plus">上传图纸
+            </el-button>
+          </el-upload>
+          <el-button type="primary" icon="Search" @click="handleRecords" style="margin-left: 10px;">操作历史
+          </el-button>
+        </el-form-item>
+      </el-form>
+      <!-- 列表区 -->
+      <div class="el-table-container">
+        <el-table ref="equipmentTable" v-loading="loading" row-key="id" @selection-change="handleSelectionChange"
+          :data="form.drawingList" height="100%">
+          <!-- <el-table-column type="selection" width="40" align="center" /> -->
+          <el-table-column label="图纸" prop="drawingName" align="center" />
+          <el-table-column fixed="right" label="操作" align="center" width="140px">
+            <template #default="scope">
+              <el-button link type="primary" @click="handlePreview(scope.row)">预览
+              </el-button>
+              <el-button link type="success" plain @click="handleDownload(scope.row)">下载</el-button>
+
+              <el-button link type="danger" @click="handleDelete(scope.row.id)">删除
+              </el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <!-- 分页 -->
+      <pagination v-show="total > 0" :total="total" v-model:page="form.pageNum" v-model:limit="form.pageSize"
+        @pagination="open" />
+    </div>
+
+    <el-dialog v-model="dialogVisible" width="1500px">
+      <iframe :src="pdfCover" style="width: 100%; height: 800px"></iframe>
+    </el-dialog>
+
+    <!-- 添加或修改app版本管理对话框 -->
+    <el-dialog title="查询到有同名文件" v-model="openRecords" width="280px" append-to-body>
+
+      <template #footer>
+        <div>
+          <el-button type="primary" @click="coverDrawing">覆 盖</el-button>
+          <el-button type="success" @click="saveDrawing">不 覆 盖</el-button>
+          <el-button type="info" @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </el-drawer>
+  <!-- 图纸弹窗 -->
+  <redcord-dialog ref="redcordsForm" />
+  <!-- <pdf :src="pdfUrl" /> -->
+</template>
+<script setup>
+// import  PDF  from 'vue-pdf';
+import {
+  listDrawing,
+  addDrawing,
+  delDrawing,
+  updateDrawing,
+  drawingByName
+} from "@/api/business/drawing";
+import { addRecords } from '@/api/business/drawingRecords'
+import redcordDialog from './recordsDialog'
+import { getToken } from '@/utils/auth'
+import useUserStore from '@/store/modules/user'
+const webHost = import.meta.env.VITE_APP_BASE_API
+const { proxy } = getCurrentInstance();
+const total = ref(0)
+const emit = defineEmits(["handleSaveResourceSuccess"]);
+/** 表单抽屉 页变量 */
+const processDetail = ref({});
+/**覆盖对话框显示 */
+const openRecords = ref(false)
+const formLoading = ref(false)
+const pdfCover = ref('')
+const dialogVisible = ref(false)
+/**覆盖用对象 */
+const editRow = ref({})
+const pdfUrl = ref('')
+/**不覆盖文件名 */
+const coverName = ref('')
+const repeatingDrawings = ref([])
+const selections = ref([]);
+const headers = { Authorization: getToken() }
+const loading = ref(false);
+const visible = ref(false);
+/** 查询对象 */
+const data = reactive({
+  form: {
+    pageNum: 1,
+    pageSize: 10,
+    groupDetailList: [],
+    code: "",
+    remark: "",
+    type: false
+  },
+  rules: {
+    code: [{ required: true, message: "资源组编码不能为空", trigger: "blur" }],
+  },
+});
+const { form, rules } = toRefs(data);
+
+/***********************  方法区  ****************************/
+/** 打开抽屉 */
+function open(row) {
+
+  processDetail.value = row
+  loading.value = true;
+  form.value.technologicalProcessDetailId = row.id
+  listDrawing(form.value).then(res => {
+    form.value.drawingList = res.rows
+    total.value = res.total
+
+  })
+  loading.value = false;
+  visible.value = true;
+};
+/**
+ * 打开操作页面
+ */
+function handleRecords() {
+  proxy.$refs.redcordsForm.open(processDetail.value);
+}
+
+/**
+ * 列表checkbox列选择 事件
+ */
+function handleSelectionChange(selection) {
+  selections.value = selection;
+}
+
+
+
+/** 文件下载 */
+function handleDownload(row) {
+
+  return new Promise((resolve, reject) => {
+    const xhr = new XMLHttpRequest();
+    xhr.open('GET', webHost + row.url, true);
+    xhr.responseType = 'blob';
+    xhr.upload.onprogress = (e) => {
+      if (e.lengthComputable) {
+        let progress = e.loaded / e.total;
+      }
+    };
+    xhr.onload = function () {
+      const url = window.URL.createObjectURL(xhr.response);
+      const eleLink = document.createElement('a');
+      eleLink.href = webHost + row.url;
+      eleLink.download = `${row.drawingName}`;
+      eleLink.style.display = 'none';
+      document.body.appendChild(eleLink);
+      eleLink.click();
+      document.body.removeChild(eleLink);
+
+      var recordsItem = {}
+      recordsItem.technologicalProcessDetailId = row.technologicalProcessDetailId;
+      recordsItem.technologicalProcessDetailDrawingId = row.id
+      recordsItem.userId = useUserStore().user.userId
+      recordsItem.type = "下载"
+      recordsItem.drawingName = row.drawingName
+      addRecords(recordsItem).then(res => {
+        if (res.code == 200) {
+          resolve('success');
+        }
+      })
+
+    };
+    xhr.onerror = (e) => {
+      proxy.$modal.msgError('下载文件失败!')
+      reject(e);
+    };
+    xhr.send();
+  });
+
+  // window.location.href = webHost + url
+}
+/**删除 */
+function handleDelete(id) {
+  proxy.$modal
+    .confirm('是否确认删除选中的电子图纸?')
+    .then(function () {
+      return delDrawing(id)
+    })
+    .then(() => {
+      reset();
+      open(processDetail.value)
+      proxy.$modal.msgSuccess('删除成功!')
+    })
+
+}
+
+/**上传成功回调 */
+function handleSuccess(row) {
+  form.value.url = row.fileName
+  console.log(row.fileName, "上传成功")
+  var fileDrawing = {}
+  fileDrawing.drawingName = row.originalFilename
+  fileDrawing.technologicalProcessDetailId = processDetail.value.id
+  drawingByName(fileDrawing).then(res => {
+    // debugger;
+    if (res.code == 200) {
+      console.log(res, "数据库查询")
+      repeatingDrawings.value = res.data
+      if (repeatingDrawings.value.length == 0) {
+        coverName.value = row.originalFilename
+        saveDrawing();
+      } else {
+        /**覆盖对象 */
+        editRow.value = JSON.parse(JSON.stringify(repeatingDrawings.value[0]));
+        editRow.value.url = form.value.url
+        //有同名文件,询问是否覆盖
+        openRecords.value = true
+        coverName.value = row.originalFilename
+        // coverName.value = row.originalFilename.slice(0, -4) + "_" + row.newFileName.slice(-6, -4) + row.originalFilename.slice(-4);
+      }
+    }
+  })
+}
+//覆盖保存
+function coverDrawing() {
+  updateDrawing(editRow.value).then(res => {
+    if (res.code == 200) {
+      reset();
+      open(processDetail.value)
+      formLoading.value = false
+      openRecords.value = false
+      // form.value.type = true
+      // form.value.drawingName = coverName.value
+      // saveDrawing();
+
+    }
+  })
+}
+//不覆盖保存
+function saveDrawing() {
+
+  form.value.drawingName = coverName.value
+  addDrawing(form.value).then(res => {
+    if (res.code == 200) {
+      reset();
+      open(processDetail.value)
+      formLoading.value = false
+      openRecords.value = false
+    }
+  })
+}
+
+/**预览 */
+function handlePreview(row) {
+
+  //  pdfUrl.value = webHost +row.url
+  dialogVisible.value = true
+  pdfCover.value = webHost + row.url
+  // window.open((webHost + row.url))
+}
+
+// 取消按钮
+function cancel() {
+  openRecords.value = false
+}
+/**文件数量超出的回调 */
+function handleExceed(files) {
+  form.value.url = files[0].url
+}
+/** 文件上传前的 回调事件 */
+function beforeUpload(file) {
+  formLoading.value = true
+  const allowedTypes = ['application/pdf'];
+  const isAllowed = allowedTypes.includes(file.type);
+  if (!isAllowed) {
+    proxy.$modal.msgError('只能上传 PDF 格式的文件!')
+    return false
+  }
+
+}
+/**
+ * 对话框关闭 事件
+ */
+function close() {
+  reset();
+  visible.value = false;
+}
+
+/** 表单重置 */
+function reset() {
+  form.value = {
+    pageNum: 1,
+    pageSize: 10,
+    code: null,
+    remark: null,
+    groupDetailList: [],
+    url: null,
+    drawingName: null,
+    type: false
+  };
+  coverName.value = ''
+  repeatingDrawings.value = []
+  proxy.resetForm("formRef");
+}
+
+
+
+
+
+/** 取消按钮 */
+const handleCancel = () => {
+  visible.value = false;
+  reset();
+};
+
+/** 暴露给父组件的方法 */
+defineExpose({
+  open,
+});
+</script>
+  

+ 17 - 0
src/views/business/product/index.vue

@@ -160,6 +160,7 @@
 							<el-table-column label="工序简称" align="center" prop="processAlias" />
 							<el-table-column v-if="!editStatus" label="操作" width="140px" align="center">
 								<template #default="scope">
+									<el-button link type="primary" @click="handleShowResourceGroupDetailForm(scope.row)"  v-hasPermi="['business:product:add']"> 图纸 </el-button>
 									<el-button v-show="false" v-if="scope.row.editStatus && !editStatus" link type="primary" icon="Check" @click="handleSaveTechnologicalProcessDetail(scope.row)" v-hasPermi="['business:product:add']"> 保存 </el-button>
 									<el-button v-show="false" v-else-if="!editStatus && !scope.row.editStatus" link type="warning" icon="Edit" @click.prevent="scope.row.editStatus = true" v-hasPermi="['business:product:edit']"> 编辑 </el-button>
 									<el-button v-show="false" link type="danger" icon="Delete" @click="handleDeleteTechnologicalProcessDetail(scope.row, scope.$index)" v-hasPermi="['business:product:remove']"> 删除 </el-button>
@@ -174,6 +175,8 @@
 		<product-form ref="productRef" @handleSaveSuccess="handleQueryProduct"></product-form>
 		<!-- 工序弹窗 -->
 		<process-choice ref="processChoiceRef" :multiple-selected="handleProcessSelected"></process-choice>
+		<!-- 图纸弹窗 -->
+		<drawing ref="drawingForm" @handleSaveResourceSuccess="handleRefreshEquipment"/>
 	</div>
 </template>
 
@@ -182,6 +185,7 @@ import { listProduct, delProduct } from '@/api/business/product'
 import { getP2Product } from '@/api/business/p2.js'
 import productForm from './form'
 import processChoice from './DialogProcessChoice'
+import drawing from './drawingForm'
 import { listTechnologicalProcessDetail, saveTechnologicalProcessDetail, delTechnologicalProcessDetail, saveSingleTechnologicalProcessDetail } from '@/api/business/technologicalProcessDetail'
 import { listTechnologicalProcess, saveTechnologicalProcess, delTechnologicalProcess } from '@/api/business/technologicalProcess'
 import { ref } from 'vue'
@@ -526,6 +530,19 @@ function handleAddProcess() {
 	proxy.$refs.processChoiceRef.open()
 }
 
+/**
+ * 打开图纸抽屉
+ */
+function handleShowResourceGroupDetailForm(row) {
+	console.log(row)
+    proxy.$refs.drawingForm.open(row);
+ 
+}
+
+function handleRefreshEquipment(){
+
+}
+
 onMounted(() => {
 	getList()
 })

+ 100 - 0
src/views/business/product/recordsDialog.vue

@@ -0,0 +1,100 @@
+<template>
+  <el-dialog title="电子图纸操作记录" v-model="visible" :width="width" @close="close" append-to-body draggable>
+    <template #header>
+      <span style="color: #fff">电子图纸操作记录</span>
+    </template>
+    <div class="page-container column-container">
+      <el-table ref="dialogTable" :data="list" height="460px" row-key="id" align="center">
+        <el-table-column label="行号" type="index" width="50" align="center" />
+        <el-table-column label="操作人" prop="userName" align="center" />
+        <el-table-column label="操作图纸名称" prop="drawingName" align="center" />
+        <el-table-column label="产品描述"  align="center" >
+          <template #default="scope" >
+            <span>{{ scope.row.processDetail.productDescription }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="工艺版本" prop="type" align="center" >
+          <template #default="scope" >
+            <span>{{ scope.row.processDetail.technologyVersion }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="工序编码" prop="type" align="center"  >
+          <template #default="scope" >
+            <span>{{ scope.row.processDetail.processCode }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="工序简称" prop="type" align="center"  >
+          <template #default="scope" >
+            <span>{{ scope.row.processDetail.processAlias }}</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="操作时间" prop="createTime" align="center" />
+        <el-table-column label="操作类型" prop="type" align="center" />
+      </el-table>
+      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+    </div>
+    
+  </el-dialog>
+</template>
+<script setup>
+import { ref } from '@vue/reactivity'
+import { listRecords } from '@/api/business/drawingRecords'
+const { proxy } = getCurrentInstance()
+const visible = ref(false)
+/**设备弹窗变量 */
+const total = ref(0)
+const props = defineProps({
+  width: {
+    type: String,
+    default: '900px'
+  }
+})
+const list = ref([])
+
+/**查询对象 */
+const data = reactive({
+  queryParams: {
+    name: '',
+    pageSize: 10,
+    pageNum: 1
+  }
+})
+const { queryParams } = toRefs(data)
+/***********************  方法区  ****************************/
+/**
+ * 对话框打开 事件
+ */
+function open(row) {
+  visible.value = true
+  if (row) {
+    console.log(row)
+    queryParams.value.technologicalProcessDetailId = row.id
+    getList()
+
+  }
+}
+
+/**
+ * 对话框关闭 事件
+ */
+function close() {
+  // proxy.$refs.dialogForm.resetFields()
+  proxy.$refs.dialogTable.clearSelection()
+  // handleSearch('clear')
+  visible.value = false
+}
+
+/**
+ * 加载数据
+ */
+function getList() {
+  listRecords(queryParams.value).then((res) => {
+    list.value = res.rows
+    total.value = res.total
+  })
+}
+
+defineExpose({
+  open
+})
+</script>

+ 17 - 20
src/views/business/productionBatch/computedMaterialForm.vue

@@ -27,8 +27,9 @@
                 v-model="form.materialpickUpQuantity"
                 :min="0"
                 :precision="2"
-                style="width: 200px; margin-left: 30px"
                 controls-position="right"
+                style="width: 200px; margin-left: 30px"
+                @input="handleInputMaterialpickUpQuantity"
               />
             </el-form-item>
           </el-col>
@@ -37,11 +38,12 @@
           <el-col :span="18">
             <el-form-item
               label="单批量(KG)"
+              v-model="form.peqty"
               prop="peqty"
               label-width="100px"
               style="margin-top: 30px"
             >
-              <span>{{ form.peqty }}</span>
+              <span style="margin-left: 40px">{{ form.peqty }}</span>
             </el-form-item>
           </el-col>
         </el-row>
@@ -49,6 +51,7 @@
           <el-col :span="18">
             <el-form-item
               label="批数"
+              v-model="form.lotNumber"
               prop="lotNumber"
               label-width="100px"
               style="margin-top: 30px"
@@ -59,8 +62,8 @@
         </el-row>
       </el-form>
       <div class="bottom-buttons">
-        <el-button size="large" style="width: 200px;height: 50px;" type="info"  @click="handleCancel">取 消</el-button>
-      <el-button size="large" style="width: 200px;height: 50px;" type="primary"  @click="handleSave"
+        <el-button size="large" style="width: 200px;height: 50px;" type="info"  @click="cancel">取 消</el-button>
+      <el-button size="large" style="width: 200px;height: 50px;" type="primary"  @click="handleInputLotNumber"
         >填入</el-button
       >
     </div>
@@ -90,10 +93,9 @@ const detailInfo = ref({})
 function open(data) {
   reset();
   detailInfo.value = proxy.deepClone(data);
-  console.log(detailInfo.value)
   getProductionLotAmount({lotno:detailInfo.value.productionPlanNo,lotseq:detailInfo.value.lineNumber}).then(res =>{
     if(res.code == 200) {
-      form.value.peqty = res.data
+      form.value.peqty = res.data[0].peqty
        visible.value = true;
     }
   }
@@ -111,24 +113,19 @@ function cancel() {
 function reset() {
   form.value = {
     lotNumber: 0,
+    materialpickUpQuantity:0
   };
   proxy.resetForm("formRef");
 }
+//填写领料量
+function handleInputMaterialpickUpQuantity(data) {
+   form.value.lotNumber = Math.ceil(data / form.value.peqty);
+}
 
-// 外协商选择带回
-const handleSingleSelectedSupplier = (data) => {
-  console.log(data);
-  form.value.supplierId = data.id;
-  form.value.lossLimit = data.lossLimit;
-  form.value.supplierName = data.name;
-  form.value.deliveryMethod = data.deliveryMethod;
-  form.value.freightPrice = data.freightPrice;
-  form.value.settlementType = data.settlementType;
-  if (form.value.deliveryMethod == 1) {
-    form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
-  } else {
-    form.value.freightAmount = 0.0;
-  }
+// 投产批数带回
+function handleInputLotNumber(){
+  singleSelected.value(form.value.lotNumber)
+  visible.value = false
 };
 
 /** 暴露给父组件的方法 */

+ 5 - 1
src/views/business/productionBatch/form.vue

@@ -80,7 +80,7 @@
         </el-row>
       </el-form>
       <!-- 计算外协领料 -->
-      <form-computed-material ref="formComputedMaterialRef"/>
+      <form-computed-material ref="formComputedMaterialRef" :single-selected="handleInputLotNumber"/>
     </div>
     <template #footer>
       <el-button type="primary" icon="Check" @click="handleSave"
@@ -311,6 +311,10 @@ function handleUpdateLotNumber(data) {
     }
   }
 }
+function handleInputLotNumber(data) {
+  form.value.lotNumber = data
+  handleUpdateLotNumber(data)
+}
 //当尾批switch状态改变时
 function handleUpdateLastLotStatus() {
   handleUpdateLotNumber(form.value.lotNumber);

+ 2 - 0
src/views/business/returnReceipt/DialogOutsourceDetails.vue

@@ -97,12 +97,14 @@ function open(data) {
 
 //查看对应外协所有批次
 function handleShowAllDetail() {
+	queryParams.value.pageNum =1
 	queryParams.value.pageSize = 10
 	showAll.value = true
 	getAllList()
 }
 //查看对应外协已完成批次
 function handleShowFinishedDetail() {
+	queryParams.value.pageNum =1
 	queryParams.value.pageSize = 10
 	showAll.value = false
 	getList()

+ 7 - 0
src/views/business/returnReceipt/form.vue

@@ -315,6 +315,7 @@ const handleMultipleSelectedOutsourceDetails = (selection) => {
         processAlias: selection[i].processes[j].processAlias,
         processCode: selection[i].processes[j].processCode,
         processStepNumber: selection[i].processes[j].processStepNumber,
+        productionDeptId:selection[i].productionDeptId,
         status: 0,
         auditNum: 0,
       };
@@ -414,6 +415,8 @@ function submitForm() {
 }
 //反选操作
 function handleDelReturnReceiveDetail(row) {
+  console.log(row)
+  if(form.value.id) {
   if(row.productionDeptId!=0) {
     proxy.$modal.msgError("该批次已周转,不能删除");
   }else{
@@ -426,6 +429,10 @@ function handleDelReturnReceiveDetail(row) {
     });
   }
 }
+else{
+  form.value.details.splice(form.value.details.indexOf(row), 1)
+}
+}
 
 /** 暴露给父组件的方法 */
 defineExpose({

+ 1 - 1
src/views/business/returnReceipt/index.vue

@@ -57,7 +57,7 @@
       <el-button
         type="danger"
         icon="Delete"
-        :disabled="multiple"
+        :disabled="ids.length == 0"
         v-hasPermi="['business:returnReceipt:remove']"
         @click="handleDelete"
       >