guoyujia 1 年之前
父节点
当前提交
cdf778759e
共有 1 个文件被更改,包括 21 次插入3 次删除
  1. 21 3
      src/views/business/outsource/form.vue

+ 21 - 3
src/views/business/outsource/form.vue

@@ -246,7 +246,7 @@
               label="箱数"
               align="center"
               prop="carrierNum"
-              width="320"
+              width="70"
             />
             <el-table-column
               :label="form.packagingMethod === '0' ? '箱号' : '原箱号'"
@@ -261,7 +261,7 @@
               width="320"
             >
               <template #default="scope">
-                <el-button link type="primary" icon="Refresh" v-if="!form.id && !scope.row.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"
@@ -283,7 +283,7 @@
                     :value="item.value"
                   />
                 </el-select>
-                <span v-else>{{ scope.row.newCarrier }}</span>
+                <span v-if="!editStatus">{{ scope.row.newCarrier }}</span>
                 <!-- <el-input
                   v-if="editStatus"
                   v-model="scope.row.newCarrier"
@@ -456,7 +456,9 @@ 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(item.newCarrier !=null) {
         item.carrierNum = item.newCarrier.split(",").length
       }else {
@@ -464,6 +466,7 @@ function getForm() {
       }
       totalCarriersNum.value += item.carrierNum
     })
+
     editStatus.value = form.value.isSubmit == 0;
     loading.value = false;
   });
@@ -471,6 +474,7 @@ function getForm() {
 //改变带箱方式
 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) {
@@ -483,6 +487,9 @@ function handleChangePackagingMethod() {
       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) {
@@ -733,6 +740,8 @@ 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 })))
@@ -740,6 +749,15 @@ function handleChangeCarrier(row) {
   }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) {