Explorar o código

采购待入库整改

lxf hai 1 ano
pai
achega
8c18f5d36e
Modificáronse 1 ficheiros con 36 adicións e 113 borrados
  1. 36 113
      src/views/production/warehouse/purchase-stock-pending/add.vue

+ 36 - 113
src/views/production/warehouse/purchase-stock-pending/add.vue

@@ -8,12 +8,12 @@
       highlight-current-row
       :action-list="[
         {
-          text: '导入到货单',
+          text: '导入采购到货单',
           action: () => clickUpload(),
         },
         {
-          text: '新增采购入库',
-          action: () => clickAdd(),
+          text: '导入采购赠品',
+          action: () => clickGiveaway(),
         },
       ]">
       <template #dimension="{ item }">
@@ -25,7 +25,7 @@
       <el-button type="primary" @click="submitForm()" size="large" v-preReClick>确认并入库</el-button>
     </div>
 
-    <el-dialog title="导入到货单" v-if="openUpload" v-model="openUpload" width="600">
+    <el-dialog title="导入采购到货单" v-if="openUpload" v-model="openUpload" width="600">
       <div v-loading="loadingUpload">
         <el-upload :show-file-list="false" action="##" :http-request="uploadServerLog" :before-upload="handleBeforeUpload">
           <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
@@ -36,48 +36,14 @@
       </div>
     </el-dialog>
 
-    <el-dialog title="新增采购入库" v-if="openAdd" v-model="openAdd" width="80%">
-      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formDataTwo.data" :rules="rules" ref="submit">
-        <template #purchaseId>
-          <div style="width: 100%">
-            <el-select v-model="formDataTwo.data.purchaseId" placeholder="采购合同" @change="changePurchase()">
-              <el-option v-for="item in purchaseList" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
-            </el-select>
-          </div>
-        </template>
-        <template #list>
-          <div style="width: 100%">
-            <el-table :data="formDataTwo.data.list" :row-style="{ height: '35px' }" header-row-class-name="tableHeader">
-              <el-table-column label="品号" prop="bomSpecCode" width="140" />
-              <el-table-column label="品名" prop="bomSpecName" min-width="220" />
-              <el-table-column label="采购数量" prop="purchaseQuantity" width="100" />
-              <el-table-column label="可入库数量" prop="canInStorageQuantity" width="100" />
-              <el-table-column label="到货数量" width="120">
-                <template #default="{ row, $index }">
-                  <el-form-item :prop="'list.' + $index + '.arrivalQuantity'" :rules="rules.arrivalQuantity" :inline-message="true" style="width: 100%">
-                    <el-input-number
-                      onmousewheel="return false;"
-                      v-model="row.arrivalQuantity"
-                      placeholder="数量"
-                      style="width: 100%"
-                      :controls="false"
-                      :min="0"
-                      :max="row.canInStorageQuantity" />
-                  </el-form-item>
-                </template>
-              </el-table-column>
-              <el-table-column label="操作" align="center" fixed="right" width="60">
-                <template #default="{ $index }">
-                  <el-button type="danger" @click="clickDelete($index)" text>删除</el-button>
-                </template>
-              </el-table-column>
-            </el-table>
-          </div>
-        </template>
-      </byForm>
-      <div style="text-align: center; margin: 10px">
-        <el-button @click="openAdd = false" size="large">关 闭</el-button>
-        <el-button type="primary" @click="submitAddForm()" size="large" v-preReClick>确 认</el-button>
+    <el-dialog title="导入采购赠品" v-if="openGiveaway" v-model="openGiveaway" width="600">
+      <div v-loading="loadingGiveaway">
+        <el-upload :show-file-list="false" action="##" :http-request="giveawayServerLog" :before-upload="handleBeforeGiveaway">
+          <el-button style="background: #20b2aa; color: #fff; border: 1px solid #20b2aa">上传</el-button>
+        </el-upload>
+        <div style="text-align: center; margin: 10px">
+          <el-button @click="openGiveaway = false" size="large">关 闭</el-button>
+        </div>
       </div>
     </el-dialog>
   </div>
@@ -85,7 +51,6 @@
 
 <script setup>
 import byTable from "/src/components/byTable/index";
-import byForm from "/src/components/byForm/index";
 import { ElMessage } from "element-plus";
 
 const { proxy } = getCurrentInstance();
@@ -93,8 +58,6 @@ const loading = ref(false);
 const purchaseList = ref([]);
 const formData = reactive({
   data: {
-    purchaseId: "",
-    arrivalCode: "",
     purchasePendingStorageBomList: [],
   },
 });
@@ -214,7 +177,8 @@ const uploadServerLog = (params) => {
   proxy.postUploadFile("/purchasePendingStorage/purchaseArrivalImport", formFile).then(
     (res) => {
       ElMessage({ message: "导入成功", type: "success" });
-      formData.data = res.data;
+      console.log(res);
+      formData.data.purchasePendingStorageBomList = res.data;
       loadingUpload.value = false;
       openUpload.value = false;
     },
@@ -224,72 +188,31 @@ const uploadServerLog = (params) => {
     }
   );
 };
-const formOption = reactive({
-  inline: true,
-  labelWidth: "120px",
-  itemWidth: 100,
-  rules: [],
-  labelPosition: "right",
-  disabled: false,
-});
-const formConfig = computed(() => {
-  return [
-    {
-      type: "slot",
-      prop: "purchaseId",
-      slotName: "purchaseId",
-      label: "采购合同",
-      itemWidth: 50,
-    },
-    {
-      type: "slot",
-      slotName: "list",
-      label: "",
-    },
-  ];
-});
-const rules = ref({
-  purchaseId: [{ required: true, message: "请选择采购合同", trigger: "change" }],
-  arrivalQuantity: [{ required: true, message: "请输入数量", trigger: "change" }],
-});
-const openAdd = ref(false);
-const formDataTwo = reactive({
-  data: {
-    purchaseId: "",
-    arrivalCode: "",
-    list: [],
-  },
-});
-const submit = ref("");
-const clickAdd = () => {
-  formDataTwo.data = {
-    purchaseId: "",
-    arrivalCode: "",
-    list: [],
-  };
-  openAdd.value = true;
-};
-const changePurchase = () => {
-  formDataTwo.data.list = [];
-  proxy.post("/purchaseReturn/getPurchaseBomPage", { id: formDataTwo.data.purchaseId }).then((res) => {
-    formDataTwo.data.list = res;
-  });
+const openGiveaway = ref(false);
+const loadingGiveaway = ref(false);
+const clickGiveaway = () => {
+  loadingGiveaway.value = false;
+  openGiveaway.value = true;
 };
-const clickDelete = (index) => {
-  formDataTwo.data.list.splice(index, 1);
+const handleBeforeGiveaway = () => {
+  loadingGiveaway.value = true;
 };
-const submitAddForm = () => {
-  submit.value.handleSubmit(() => {
-    let list = formDataTwo.data.list.filter((item) => item.arrivalQuantity > 0);
-    if (list && list.length > 0) {
-      formData.data.purchaseId = formDataTwo.data.purchaseId;
-      formData.data.purchasePendingStorageBomList = formDataTwo.data.list;
-      ElMessage({ message: "添加成功", type: "success" });
-      openAdd.value = "";
-    } else {
-      return ElMessage("请添加入库清单");
+const giveawayServerLog = (params) => {
+  let file = params.file;
+  let formFile = new FormData();
+  formFile.append("file", file);
+  proxy.postUploadFile("/purchasePendingStorage/purchaseGiftImport", formFile).then(
+    (res) => {
+      ElMessage({ message: "导入成功", type: "success" });
+      formData.data.purchasePendingStorageBomList = res.data;
+      loadingGiveaway.value = false;
+      openGiveaway.value = false;
+    },
+    (err) => {
+      console.log(err);
+      loadingGiveaway.value = false;
     }
-  });
+  );
 };
 </script>