소스 검색

样品交接单_ehsd、合同交接单_ehsd 增加“发起采购”功能

lxf 2 년 전
부모
커밋
840f95cdf8
3개의 변경된 파일382개의 추가작업 그리고 288개의 파일을 삭제
  1. 262 134
      src/components/process/EHSD/Purchase.vue
  2. 9 9
      src/views/process/processApproval/index.vue
  3. 111 145
      src/views/product/material/index.vue

+ 262 - 134
src/components/process/EHSD/Purchase.vue

@@ -166,7 +166,7 @@
             :style="index !== formData.data.purchaseProductList.length - 1 ? 'margin-bottom: 20px' : ''"
             v-for="(item, index) in formData.data.purchaseProductList"
             :key="item.dataResourceId">
-            <div style="border: 1px solid #ccc; padding: 20px 10px; width: 100%">
+            <div style="border: 1px solid #ccc; padding: 20px 10px 0 10px; width: 100%">
               <el-row style="width: 100%" :gutter="5" type="flex" align="middle">
                 <el-col :span="2" style="text-align: center">
                   <img v-if="item.fileUrl" :src="item.fileUrl" class="pic" @click="onPicture(item.fileUrl)" />
@@ -187,93 +187,86 @@
                   <el-button type="primary" text @click="handleHandover(item, index)">编辑备注</el-button>
                 </el-col>
                 <el-col :span="2">
-                  <el-button type="primary" text @click="handleHandover(item, index)">添加配件</el-button>
+                  <el-button type="primary" text @click="handleMaterial(index)">添加配件</el-button>
                 </el-col>
                 <el-col :span="3">
                   <span>金额小计: {{ item.amount }}</span>
                 </el-col>
               </el-row>
-              <!-- <div style="width: 80px">
-                <div v-if="item.fileUrl">
-                </div>
+              <el-collapse v-model="item.activeName" class="hideCollapse" accordion>
+                <el-collapse-item title="" :name="true">
+                  <div style="padding: 0 40px">
+                    <el-table :data="item.purchaseProductMountingsList" style="width: 100%">
+                      <el-table-column label="图片" align="center" width="80">
+                        <template #default="{ row }">
+                          <img v-if="row.fileUrl" :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
+                        </template>
+                      </el-table-column>
+                      <el-table-column label="类型" align="center" width="80">
+                        <template #default="{ row }">
+                          <div>{{ dictValueLabel(row.productType, productType) }}</div>
+                        </template>
+                      </el-table-column>
+                      <el-table-column label="产品名称" prop="productName" min-width="180" />
+                      <el-table-column label="尺寸" prop="productModel" min-width="140" />
+                      <el-table-column label="单价" width="140">
+                        <template #default="{ row, $index }">
+                          <div style="width: 100%" class="removePadding">
+                            <el-form-item
+                              :prop="'purchaseProductList.' + index + '.purchaseProductMountingsList.' + $index + '.price'"
+                              :rules="rules.price"
+                              :inline-message="true"
+                              @change="
+                                () => {
+                                  return changeProductMaterial(index, $index);
+                                }
+                              ">
+                              <el-input-number v-model="row.price" placeholder="请输入单价" :precision="2" :controls="false" :min="0" />
+                            </el-form-item>
+                          </div>
+                        </template>
+                      </el-table-column>
+                      <el-table-column label="数量" width="140">
+                        <template #default="{ row, $index }">
+                          <div style="width: 100%" class="removePadding">
+                            <el-form-item
+                              :prop="'purchaseProductList.' + index + '.purchaseProductMountingsList.' + $index + '.quantity'"
+                              :rules="rules.quantity"
+                              :inline-message="true"
+                              @change="
+                                () => {
+                                  return changeProductMaterial(index, $index);
+                                }
+                              ">
+                              <el-input-number v-model="row.quantity" placeholder="请输入数量" :precision="0" :controls="false" :min="0" />
+                            </el-form-item>
+                          </div>
+                        </template>
+                      </el-table-column>
+                      <el-table-column label="金额" prop="amount" width="100" />
+                      <el-table-column label="操作" align="center" width="80" fixed="right">
+                        <template #default="{ $index }">
+                          <el-button type="primary" v-if="$index !== 0" link @click="handleRemove(index, $index)">删除</el-button>
+                        </template>
+                      </el-table-column>
+                    </el-table>
+                  </div>
+                </el-collapse-item>
+              </el-collapse>
+              <div style="text-align: center; margin-top: -18px">
+                <el-button type="primary" @click="item.activeName = !item.activeName" style="margin-bottom: -28px" text>
+                  <span v-if="item.activeName">
+                    <span style="vertical-align: middle">收起明细</span>
+                    <el-icon style="margin-left: 8px; transform: rotate(-90deg); vertical-align: middle"><DArrowRight /></el-icon>
+                  </span>
+                  <span v-else>
+                    <span style="vertical-align: middle">查看明细</span>
+                    <el-icon style="margin-left: 8px; transform: rotate(90deg); vertical-align: middle"><DArrowRight /></el-icon>
+                  </span>
+                </el-button>
               </div>
-              <div ></div> -->
             </div>
           </div>
-          <!--<el-table :data="formData.data.purchaseProductList" style="width: 100%; margin-top: 16px">
-            <el-table-column label="商品图片" width="80">
-              <template #default="{ row }">
-                <div v-if="row.productId">
-                  <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
-                </div>
-                <div v-else></div>
-              </template>
-            </el-table-column>
-            <el-table-column label="商品名称" min-width="180">
-              <template #default="{ row, $index }">
-                <div style="width: 100%">
-                  <!~~ <el-form-item
-                    :prop="'purchaseProductList.' + $index + '.productName'"
-                    :rules="rules.productName"
-                    :inline-message="true"
-                    class="shrinkPadding">
-                    <el-input v-model="row.productName" placeholder="请输入商品名称" />
-                  </el-form-item> ~~>
-                </div>
-              </template>
-            </el-table-column>
-            <el-table-column label="尺寸 cm*cm*cm" width="140">
-              <template #default="{ row, $index }">
-                <div style="width: 100%">
-                  <!~~ <el-form-item
-                    :prop="'purchaseProductList.' + $index + '.productModel'"
-                    :rules="rules.productModel"
-                    :inline-message="true"
-                    class="shrinkPadding">
-                    <el-input v-model="row.productModel" placeholder="请输入" />
-                  </el-form-item> ~~>
-                </div>
-              </template>
-            </el-table-column>
-            <el-table-column label="数量" width="130">
-              <template #default="{ row, $index }">
-                <div style="width: 100%">
-                  <el-form-item :prop="'purchaseProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true" class="shrinkPadding">
-                    <el-input-number
-                      v-model="row.quantity"
-                      placeholder="请输入"
-                      style="width: 100%"
-                      :precision="0"
-                      :controls="false"
-                      :min="0"
-                      @change="calculationAmount()" />
-                  </el-form-item>
-                </div>
-              </template>
-            </el-table-column>
-            <el-table-column label="单价" width="140">
-              <template #default="{ row, $index }">
-                <div style="width: 100%">
-                  <el-form-item :prop="'purchaseProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true" class="shrinkPadding">
-                    <el-input-number
-                      v-model="row.price"
-                      placeholder="请输入"
-                      style="width: 100%"
-                      :precision="2"
-                      :controls="false"
-                      :min="0"
-                      @change="calculationAmount()" />
-                  </el-form-item>
-                </div>
-              </template>
-            </el-table-column>
-            <el-table-column prop="amount" label="金额" width="130" />
-            <el-table-column label="操作" width="60" align="center" fixed="right">
-              <template #default="{ row, $index }">
-                <el-button type="primary" link @click="handleRemove($index, row)">删除</el-button>
-              </template>
-            </el-table-column>
-          </el-table>-->
         </div>
       </template>
       <template #otherCharge>
@@ -301,15 +294,13 @@
             <el-table-column label="金额" width="130">
               <template #default="{ row, $index }">
                 <div style="width: 100%">
-                  <el-form-item :prop="'purchaseProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true" class="shrinkPadding">
-                    <el-input-number
-                      v-model="row.amount"
-                      placeholder="请输入金额"
-                      style="width: 100%"
-                      :precision="2"
-                      :controls="false"
-                      :min="0"
-                      @change="totalAmount()" />
+                  <el-form-item
+                    :prop="'purchaseProjectList.' + $index + '.amount'"
+                    :rules="rules.amount"
+                    :inline-message="true"
+                    class="shrinkPadding"
+                    @change="changeProject">
+                    <el-input-number v-model="row.amount" placeholder="请输入金额" style="width: 100%" :precision="2" :controls="false" :min="0" />
                   </el-form-item>
                 </div>
               </template>
@@ -355,27 +346,20 @@
           <el-table :data="formData.data.purchaseArrivalList" style="width: 100%; margin-top: 16px">
             <el-table-column prop="code" label="商品编码" width="120" />
             <el-table-column prop="productName" label="商品名称" />
-            <el-table-column label="货日期" width="220">
+            <el-table-column label="货日期" width="220">
               <template #default="{ row, $index }">
                 <div style="width: 100%">
                   <el-form-item :prop="'purchaseArrivalList.' + $index + '.arrivalTime'" :rules="rules.arrivalTime" :inline-message="true">
-                    <el-date-picker v-model="row.arrivalTime" type="date" placeholder="请选择货日期" value-format="YYYY-MM-DD" />
+                    <el-date-picker v-model="row.arrivalTime" type="date" placeholder="请选择货日期" value-format="YYYY-MM-DD" />
                   </el-form-item>
                 </div>
               </template>
             </el-table-column>
-            <el-table-column label="数量" width="160">
+            <el-table-column label="到货数量" width="160">
               <template #default="{ row, $index }">
                 <div style="width: 100%">
                   <el-form-item :prop="'purchaseArrivalList.' + $index + '.quantity'" :inline-message="true">
-                    <el-input-number
-                      v-model="row.quantity"
-                      placeholder="请输入数量"
-                      style="width: 100%"
-                      :precision="0"
-                      :controls="false"
-                      :min="0"
-                      @change="calculationAmount()" />
+                    <el-input-number v-model="row.quantity" placeholder="请输入到货数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
                   </el-form-item>
                 </div>
               </template>
@@ -391,8 +375,8 @@
       </template>
     </byForm>
 
-    <el-dialog v-if="openProductCompany" v-model="openProductCompany" title="公司产品库" width="90%" append-to-body>
-      <CompanyProduct :selectStatus="true"></CompanyProduct>
+    <el-dialog v-if="openMaterialCompany" v-model="openMaterialCompany" title="公司产品库" width="90%" append-to-body>
+      <ProductMaterial :selectStatus="true" @selectMaterial="selectMaterial"></ProductMaterial>
     </el-dialog>
 
     <el-dialog title="备注" v-if="openHandover" v-model="openHandover" width="800">
@@ -427,7 +411,7 @@
 
 <script setup>
 import byForm from "@/components/byForm/index";
-import CompanyProduct from "@/views/EHSD/productLibrary/companyProduct/index";
+import ProductMaterial from "@/views/product/material/index";
 import { ElMessage } from "element-plus";
 import selectCity from "@/components/selectCity/index.vue";
 import Editor from "@/components/Editor/index.vue";
@@ -441,7 +425,7 @@ const supplierList = ref([]);
 const countryData = ref([]);
 const provinceData = ref([]);
 const cityData = ref([]);
-const openProductCompany = ref(false);
+const openMaterialCompany = ref(false);
 const formData = reactive({
   data: {
     deliveryType: 1,
@@ -467,6 +451,16 @@ const deliveryType = ref([
     value: 3,
   },
 ]);
+const productType = ref([
+  {
+    label: "产品",
+    value: 1,
+  },
+  {
+    label: "物料",
+    value: 2,
+  },
+]);
 const formOption = reactive({
   inline: true,
   labelWidth: 100,
@@ -622,8 +616,23 @@ const changeBuyCorporation = (val) => {
 };
 const changeAddress = () => {
   if (formData.data.deliveryType === 1) {
-    formData.data.address =
-      formData.data.buyCountryName + ", " + formData.data.buyProvinceName + ", " + formData.data.buyCityName + "," + formData.data.buyAddress;
+    let buyCountryName = "";
+    if (formData.data.buyCountryName) {
+      buyCountryName = formData.data.buyCountryName;
+    }
+    let buyProvinceName = "";
+    if (formData.data.buyProvinceName) {
+      buyProvinceName = formData.data.buyProvinceName;
+    }
+    let buyCityName = "";
+    if (formData.data.buyCityName) {
+      buyCityName = formData.data.buyCityName;
+    }
+    let buyAddress = "";
+    if (formData.data.buyAddress) {
+      buyAddress = formData.data.buyAddress;
+    }
+    formData.data.address = buyCountryName + ", " + buyProvinceName + ", " + buyCityName + "," + buyAddress;
   } else if (formData.data.deliveryType === 2) {
     let countryName = "";
     if (formData.data.countryId) {
@@ -718,44 +727,91 @@ const changeSupplier = (val) => {
 const onPicture = (path) => {
   window.open(path, "_blank");
 };
-const handleRemove = async (index, row) => {
-  formData.data.purchaseArrivalList = formData.data.purchaseArrivalList.filter((item) => item.productId !== row.productId);
-  await formData.data.purchaseProductList.splice(index, 1);
-  totalAmount();
-};
-const calculationAmount = () => {
+const changeProject = () => {
+  console.log("222");
   nextTick(() => {
-    if (formData.data.purchaseProductList && formData.data.purchaseProductList.length > 0) {
-      for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
-        let money = 0;
-        if (formData.data.purchaseProductList[i].quantity && formData.data.purchaseProductList[i].price) {
-          money = parseFloat(Number(formData.data.purchaseProductList[i].quantity) * Number(formData.data.purchaseProductList[i].price)).toFixed(2);
-        }
-        formData.data.purchaseProductList[i].amount = money;
-      }
-    }
-    nextTick(() => {
-      totalAmount();
-    });
+    calculationAllAmount();
   });
 };
-const totalAmount = () => {
-  let money = 0;
+const calculationAllAmount = () => {
+  console.log("111");
+  let amount = 0;
   if (formData.data.purchaseProductList && formData.data.purchaseProductList.length > 0) {
     for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
       if (formData.data.purchaseProductList[i].amount) {
-        money = parseFloat(Number(money) + Number(formData.data.purchaseProductList[i].amount)).toFixed(2);
+        amount = Number(parseFloat(Number(amount) + Number(formData.data.purchaseProductList[i].amount)).toFixed(2));
       }
     }
   }
   if (formData.data.purchaseProjectList && formData.data.purchaseProjectList.length > 0) {
     for (let i = 0; i < formData.data.purchaseProjectList.length; i++) {
       if (formData.data.purchaseProjectList[i].amount) {
-        money = parseFloat(Number(money) + Number(formData.data.purchaseProjectList[i].amount)).toFixed(2);
+        amount = Number(parseFloat(Number(amount) + Number(formData.data.purchaseProjectList[i].amount)).toFixed(2));
+      }
+    }
+  }
+  console.log(amount);
+  formData.data.amount = amount;
+};
+const calculationProductAmount = (index) => {
+  if (
+    formData.data.purchaseProductList &&
+    formData.data.purchaseProductList.length > 0 &&
+    formData.data.purchaseProductList[index].purchaseProductMountingsList &&
+    formData.data.purchaseProductList[index].purchaseProductMountingsList.length > 0
+  ) {
+    let amount = 0;
+    for (let i = 0; i < formData.data.purchaseProductList[index].purchaseProductMountingsList.length; i++) {
+      if (formData.data.purchaseProductList[index].purchaseProductMountingsList[i].amount) {
+        amount = Number(parseFloat(Number(amount) + Number(formData.data.purchaseProductList[index].purchaseProductMountingsList[i].amount)).toFixed(2));
       }
     }
+    formData.data.purchaseProductList[index].amount = amount;
+    let price = 0;
+    if (formData.data.purchaseProductList[index].quantity && amount) {
+      price = Number(parseFloat(Number(amount) / Number(formData.data.purchaseProductList[index].quantity)).toFixed(4));
+    }
+    formData.data.purchaseProductList[index].price = price;
   }
-  formData.data.amount = money;
+  nextTick(() => {
+    calculationAllAmount();
+  });
+};
+const changeProductMaterial = (index, indexTwo) => {
+  nextTick(() => {
+    if (
+      formData.data.purchaseProductList &&
+      formData.data.purchaseProductList.length > 0 &&
+      formData.data.purchaseProductList[index].purchaseProductMountingsList &&
+      formData.data.purchaseProductList[index].purchaseProductMountingsList.length > 0
+    ) {
+      if (indexTwo === 0 && formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].quantity) {
+        formData.data.purchaseProductList[index].quantity = formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].quantity;
+      }
+      if (
+        formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].quantity &&
+        formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].price
+      ) {
+        formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].amount = Number(
+          parseFloat(
+            Number(formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].quantity) *
+              Number(formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].price)
+          ).toFixed(2)
+        );
+      } else {
+        formData.data.purchaseProductList[index].purchaseProductMountingsList[indexTwo].amount = 0;
+      }
+    }
+    nextTick(() => {
+      calculationProductAmount(index);
+    });
+  });
+};
+const handleRemove = async (index, indexTwo) => {
+  await formData.data.purchaseProductList[index].purchaseProductMountingsList.splice(indexTwo, 1);
+  nextTick(() => {
+    calculationProductAmount(index);
+  });
 };
 const clickAdd = () => {
   if (formData.data.purchaseProjectList && formData.data.purchaseProjectList.length > 0) {
@@ -770,7 +826,9 @@ const clickAdd = () => {
 };
 const handleDelete = async (index) => {
   await formData.data.purchaseProjectList.splice(index, 1);
-  totalAmount();
+  nextTick(() => {
+    calculationAllAmount();
+  });
 };
 const querySearch = (queryString, callback) => {
   proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
@@ -793,13 +851,15 @@ const handleSubmit = async () => {
     if (formData.data.purchaseArrivalList && formData.data.purchaseArrivalList.length > 0) {
       for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
         let data = formData.data.purchaseArrivalList.filter((item) => item.productId === formData.data.purchaseProductList[i].productId);
+        console.log(data, "bbb");
         if (data && data.length > 0) {
           let quantity = 0;
           for (let j = 0; j < data.length; j++) {
             quantity = parseFloat(Number(quantity) + Number(data[j].quantity));
           }
+          console.log(quantity, formData.data.purchaseProductList[i].quantity, "aaa");
           if (quantity > formData.data.purchaseProductList[i].quantity) {
-            ElMessage("出货数量不能大于商品数量");
+            ElMessage("到货数量不能大于采购数量");
             return false;
           }
         }
@@ -832,22 +892,47 @@ onMounted(() => {
             productId: item.productId,
             productName: item.productName,
             productModel: item.productModel,
-            quantity: "",
+            quantity: item.expendQuantity,
             price: "",
             amount: "",
             remark: "",
             json: "",
+            fileUrl: "",
             dataResource: props.queryData.type,
             dataResourceId: item.id,
-            purchaseProductMountingsList: [],
+            purchaseProductMountingsList: [
+              {
+                productId: item.productId,
+                productType: 1,
+                productName: item.productName,
+                productModel: item.productModel,
+                quantity: item.expendQuantity,
+                price: undefined,
+                amount: "",
+                remark: "",
+                json: "",
+                fileUrl: "",
+                activeName: false,
+              },
+            ],
             fileList: [],
           };
         });
+        formData.data.purchaseArrivalList = res.rows.map((item) => {
+          return {
+            code: item.productCode,
+            productId: item.productId,
+            productName: item.productName,
+            arrivalTime: "",
+            quantity: undefined,
+          };
+        });
         let fileIds = formData.data.purchaseProductList.map((item) => item.productId);
         proxy.post("/fileInfo/getList", { businessIdList: fileIds }).then((resFile) => {
           for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
             if (resFile[formData.data.purchaseProductList[i].productId] && resFile[formData.data.purchaseProductList[i].productId].length > 0) {
               formData.data.purchaseProductList[i].fileUrl = resFile[formData.data.purchaseProductList[i].productId][0].fileUrl;
+              formData.data.purchaseProductList[i].purchaseProductMountingsList[0].fileUrl = resFile[formData.data.purchaseProductList[i].productId][0].fileUrl;
             }
           }
         });
@@ -942,6 +1027,10 @@ const handleHandover = (row, index) => {
   productIndex.value = index;
   openHandover.value = true;
 };
+const handleMaterial = (index) => {
+  productIndex.value = index;
+  openMaterialCompany.value = true;
+};
 const uploadFile = async (file) => {
   const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
   uploadData.value = res.uploadBody;
@@ -982,6 +1071,37 @@ const submitHandoverForm = () => {
   formData.data.purchaseProductList[productIndex.value].remark = productRow.data.remark;
   openHandover.value = false;
 };
+const selectMaterial = (goods) => {
+  if (goods && goods.id) {
+    let data = formData.data.purchaseProductList[productIndex.value].purchaseProductMountingsList.filter((item) => item.productId === goods.id);
+    if (data && data.length > 0) {
+      return ElMessage("该物料已添加");
+    }
+    let fileUrl = "";
+    if (goods.fileList && goods.fileList.length > 0) {
+      fileUrl = goods.fileList[0].fileUrl;
+    }
+    formData.data.purchaseProductList[productIndex.value].purchaseProductMountingsList.push({
+      productId: goods.id,
+      productType: 2,
+      productName: goods.name,
+      productModel: goods.spec,
+      quantity: undefined,
+      price: undefined,
+      amount: "",
+      remark: "",
+      json: "",
+      fileUrl: fileUrl,
+      activeName: false,
+    });
+    ElMessage({
+      message: "添加成功!",
+      type: "success",
+    });
+  } else {
+    return ElMessage("选择错误");
+  }
+};
 </script>
 
 <style lang="scss" scoped>
@@ -999,7 +1119,7 @@ const submitHandoverForm = () => {
   padding-right: 0 !important;
 }
 .hideCollapse {
-  margin-top: -62px;
+  margin-top: -28px;
   border: 0 !important;
 }
 ::v-deep(.el-collapse-item__arrow) {
@@ -1011,6 +1131,9 @@ const submitHandoverForm = () => {
 ::v-deep(.el-collapse-item__header) {
   border: 0 !important;
 }
+::v-deep(.el-collapse-item__content) {
+  padding-bottom: 8px !important;
+}
 .pic {
   object-fit: contain;
   width: 50px;
@@ -1018,4 +1141,9 @@ const submitHandoverForm = () => {
   cursor: pointer;
   vertical-align: middle;
 }
+::v-deep(.removePadding) {
+  .el-form-item {
+    padding-right: 0 !important;
+  }
+}
 </style>

+ 9 - 9
src/views/process/processApproval/index.vue

@@ -408,15 +408,15 @@ const skipPage = () => {
       path: "/EHSD/saleContract/sampleEHSD",
     });
   } else if (flowForm.flowKey == "ehsd_purchase_flow") {
-    if (flowForm.type === 1) {
-      router.replace({
-        path: "/EHSD/procurement/handoverSlipSampleEHSD",
-      });
-    } else {
-      router.replace({
-        path: "/EHSD/procurement/handoverSlipEHSD",
-      });
-    }
+    // if (flowForm.type === 1) {
+    //   router.replace({
+    //     path: "/EHSD/procurement/handoverSlipSampleEHSD",
+    //   });
+    // } else {
+    //   router.replace({
+    //     path: "/EHSD/procurement/handoverSlipEHSD",
+    //   });
+    // }
   } else if (flowForm.flowKey == "service_contract_flow") {
     router.replace({
       path: "/ERP/saleContract/serviceContract",

+ 111 - 145
src/views/product/material/index.vue

@@ -7,8 +7,7 @@
         :data="treeListData"
         v-model="sourceList.pagination.productClassifyId"
         @change="treeChange"
-        @changeTreeList="getTreeList"
-      >
+        @changeTreeList="getTreeList">
       </treeList>
     </div>
     <div class="content">
@@ -24,46 +23,33 @@
           select: select,
         }"
         :action-list="[
-          {
-            text: 'Excel导入',
-            action: () => openExcel(),
-            disabled: false,
-          },
-          {
-            text: '添加物料',
-            action: () => openModal('add'),
-            disabled: false,
-          },
+          props.selectStatus
+            ? {}
+            : {
+                text: 'Excel导入',
+                action: () => openExcel(),
+                disabled: false,
+              },
+          props.selectStatus
+            ? {}
+            : {
+                text: '添加物料',
+                action: () => openModal('add'),
+                disabled: false,
+              },
         ]"
-        @get-list="getList"
-      >
+        @get-list="getList">
         <template #pic="{ item }">
           <div v-if="item.fileList.length > 0">
-            <img
-              :src="item.fileList[0].fileUrl"
-              class="pic"
-              @click="handleClickFile(item.fileList[0])"
-            />
+            <img :src="item.fileList[0].fileUrl" class="pic" @click="handleClickFile(item.fileList[0])" />
           </div>
           <div v-else></div>
         </template>
       </byTable>
     </div>
-    <el-dialog
-      :title="modalType == 'add' ? '添加' : '编辑'"
-      v-model="dialogVisible"
-      width="500"
-      v-loading="loading"
-      destroy-on-close
-    >
+    <el-dialog :title="modalType == 'add' ? '添加' : '编辑'" v-model="dialogVisible" width="500" v-loading="loading" destroy-on-close>
       <div class="public_height_dialog">
-        <byForm
-          :formConfig="formConfig"
-          :formOption="formOption"
-          v-model="formData.data"
-          :rules="rules"
-          ref="byform"
-        >
+        <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
           <template #productPic>
             <div>
               <el-upload
@@ -73,8 +59,7 @@
                 list-type="picture-card"
                 :on-remove="handleRemove"
                 :on-success="handleSuccess"
-                :before-upload="handleBeforeUpload"
-              >
+                :before-upload="handleBeforeUpload">
                 <el-icon><Plus /></el-icon>
               </el-upload>
             </div>
@@ -84,39 +69,18 @@
 
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button
-          type="primary"
-          @click="submitForm('byform')"
-          size="large"
-          :loading="submitLoading"
-        >
-          确 定
-        </el-button>
+        <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading"> 确 定 </el-button>
       </template>
     </el-dialog>
-    <el-dialog
-      title="Excel导入"
-      v-model="openExcelDialog"
-      width="400"
-      v-loading="loading"
-    >
+    <el-dialog title="Excel导入" v-model="openExcelDialog" width="400" v-loading="loading">
       <template #footer>
-        <el-button @click="openExcelDialog = false" size="large"
-          >取 消</el-button
-        >
-        <el-button
-          type="primary"
-          @click="submitExcel()"
-          size="large"
-          :loading="submitLoading"
-        >
-          确 定
-        </el-button>
+        <el-button @click="openExcelDialog = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitExcel()" size="large" :loading="submitLoading"> 确 定 </el-button>
       </template>
     </el-dialog>
   </div>
 </template>
-  
+
 <script setup>
 /* eslint-disable vue/no-unused-components */
 import { ElMessage, ElMessageBox } from "element-plus";
@@ -146,14 +110,15 @@ const materialUnit = ref([]);
 const materialType = ref([]);
 const treeData = ref([]);
 let rules = ref({
-  productClassifyId: [
-    { required: true, message: "请选择物料分类", trigger: "change" },
-  ],
+  productClassifyId: [{ required: true, message: "请选择物料分类", trigger: "change" }],
   type: [{ required: true, message: "请选择物料类型", trigger: "change" }],
   name: [{ required: true, message: "请输入物料名称", trigger: "blur" }],
   unit: [{ required: true, message: "请选择单位", trigger: "change" }],
 });
 const { proxy } = getCurrentInstance();
+const props = defineProps({
+  selectStatus: Boolean,
+});
 const selectConfig = reactive([
   {
     label: "物料类型",
@@ -212,60 +177,66 @@ const config = computed(() => {
         prop: "remark",
       },
     },
-
     {
       attrs: {
         label: "操作",
         width: "200",
         align: "right",
       },
-      // 渲染 el-button,一般用在最后一列。
       renderHTML(row) {
         return [
-          {
-            attrs: {
-              label: "修改",
-              type: "primary",
-              text: true,
-            },
-            el: "button",
-            click() {
-              getDtl(row);
-            },
-          },
-          {
-            attrs: {
-              label: "删除",
-              type: "danger",
-              text: true,
-            },
-            el: "button",
-            click() {
-              // 弹窗提示是否删除
-              ElMessageBox.confirm(
-                "此操作将永久删除该数据, 是否继续?",
-                "提示",
-                {
-                  confirmButtonText: "确定",
-                  cancelButtonText: "取消",
-                  type: "warning",
-                }
-              ).then(() => {
-                // 删除
-                proxy
-                  .post("/productInfo/delete", {
-                    id: row.id,
-                  })
-                  .then((res) => {
-                    ElMessage({
-                      message: "删除成功",
-                      type: "success",
-                    });
-                    getList();
+          props.selectStatus
+            ? {
+                attrs: {
+                  label: "选择",
+                  type: "primary",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  clickSelect(row);
+                },
+              }
+            : {
+                attrs: {
+                  label: "修改",
+                  type: "primary",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  getDtl(row);
+                },
+              },
+          props.selectStatus
+            ? {}
+            : {
+                attrs: {
+                  label: "删除",
+                  type: "danger",
+                  text: true,
+                },
+                el: "button",
+                click() {
+                  ElMessageBox.confirm("此操作将永久删除该数据, 是否继续?", "提示", {
+                    confirmButtonText: "确定",
+                    cancelButtonText: "取消",
+                    type: "warning",
+                  }).then(() => {
+                    proxy
+                      .post("/productInfo/delete", {
+                        id: row.id,
+                      })
+                      .then(() => {
+                        ElMessage({
+                          message: "删除成功",
+                          type: "success",
+                        });
+                        getList();
+                      });
                   });
-              });
-            },
-          },
+                },
+              },
         ];
       },
     },
@@ -351,33 +322,29 @@ const generatePassword = () => {
 const getList = async (req) => {
   sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
   loading.value = true;
-  proxy
-    .post("/productInfo/page", sourceList.value.pagination)
-    .then((message) => {
-      console.log(message);
-      sourceList.value.data = message.rows.map((x) => ({ ...x, fileList: [] }));
-      sourceList.value.pagination.total = message.total;
-      setTimeout(() => {
-        loading.value = false;
-      }, 200);
+  proxy.post("/productInfo/page", sourceList.value.pagination).then((message) => {
+    console.log(message);
+    sourceList.value.data = message.rows.map((x) => ({ ...x, fileList: [] }));
+    sourceList.value.pagination.total = message.total;
+    setTimeout(() => {
+      loading.value = false;
+    }, 200);
 
-      const productIdList = message.rows.map((x) => x.id);
-      // 请求文件数据并回显
-      if (productIdList.length > 0) {
-        proxy
-          .post("/fileInfo/getList", { businessIdList: productIdList })
-          .then((fileObj) => {
-            for (let i = 0; i < sourceList.value.data.length; i++) {
-              const e = sourceList.value.data[i];
-              for (const key in fileObj) {
-                if (e.id === key) {
-                  e.fileList = fileObj[key];
-                }
-              }
+    const productIdList = message.rows.map((x) => x.id);
+    // 请求文件数据并回显
+    if (productIdList.length > 0) {
+      proxy.post("/fileInfo/getList", { businessIdList: productIdList }).then((fileObj) => {
+        for (let i = 0; i < sourceList.value.data.length; i++) {
+          const e = sourceList.value.data[i];
+          for (const key in fileObj) {
+            if (e.id === key) {
+              e.fileList = fileObj[key];
             }
-          });
-      }
-    });
+          }
+        }
+      });
+    }
+  });
 };
 const uploadData = ref({});
 const fileList = ref([]);
@@ -443,12 +410,10 @@ const submitForm = () => {
 };
 
 const getTreeList = () => {
-  proxy
-    .post("/productClassify/tree", { parentId: "", name: "", definition: "2" })
-    .then((message) => {
-      treeListData.value = message;
-      treeData.value = message;
-    });
+  proxy.post("/productClassify/tree", { parentId: "", name: "", definition: "2" }).then((message) => {
+    treeListData.value = message;
+    treeData.value = message;
+  });
 };
 
 const getDtl = (row) => {
@@ -484,9 +449,7 @@ const handleSuccess = (res, file, files) => {
 };
 
 const handleRemove = (file) => {
-  const index = fileListCopy.value.findIndex(
-    (x) => x.uid === file.uid || x.id === file.id
-  );
+  const index = fileListCopy.value.findIndex((x) => x.uid === file.uid || x.id === file.id);
   fileListCopy.value.splice(index, 1);
 };
 
@@ -508,8 +471,11 @@ const getDict = () => {
   });
 };
 getDict();
+const clickSelect = (item) => {
+  proxy.$emit("selectMaterial", item);
+};
 </script>
-  
+
 <style lang="scss" scoped>
 .user {
   padding: 20px;
@@ -529,4 +495,4 @@ getDict();
   cursor: pointer;
   vertical-align: middle;
 }
-</style>
+</style>