Răsfoiți Sursa

手动出入库、销售订单excel导入

cz 1 an în urmă
părinte
comite
3cd8116479

BIN
public/static/ManualOutInBoundImportTemplate.xlsx


BIN
public/static/SaleOrderImportTemplate.xlsx


+ 2 - 14
src/components/WDLY/process/SendSubscribeWDLY.vue

@@ -45,26 +45,13 @@
     <el-dialog v-model="openExcel" title="excel导入" width="30%" append-to-body>
       <div v-loading="excelLoading">
         <div style="margin: 15px 0">
-          <!-- <a
-            href="/static/申购明细导入模板.xlsx"
-            download="申购明细导入模板.xlsx"
-            class="download"
-            >Excel模板下载</a
-          > -->
           <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
-          <!-- <a
-            href="https://winfaster.obs.cn-south-1.myhuaweicloud.com/byteSailing/templates/wdly/%E7%94%B3%E8%B4%AD%E6%98%8E%E7%BB%86%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx"
-            download="申购明细导入模板.xlsx"
-            class="download"
-            >Excel模板下载</a
-          > -->
         </div>
         <el-upload :action="actionUrl + '/subscribeDetail/excelImport'" :headers="headers" :before-upload="useImportExcelStore().updateRequestHeaders"
                    :on-success="handleSuccess" :on-progress="handleProgress" :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
-          <el-button type="primary">点击导入</el-button>
+          <el-button type="primary" plain>点击导入</el-button>
         </el-upload>
       </div>
-
       <template #footer>
         <el-button @click="openExcel = false" size="large">取 消</el-button>
       </template>
@@ -298,6 +285,7 @@ const handleProgress = () => {
 };
 const handleSuccess = (res) => {
   if (res.code != 200) {
+    excelLoading.value = false;
     return ElMessage({
       message: `${res.msg},请重试!`,
       type: "info",

+ 1 - 0
src/components/jdStatus/index.vue

@@ -28,6 +28,7 @@ const loading = ref(false);
 
 // 监听来自子页面的消息
 window.addEventListener("message", function (event) {
+  console.log(event, "sss");
   if (event.data === "closeIframe") {
     closeIframe();
   } else if (event.data.indexOf("alertAndCloseIframe") >= 0) {

+ 131 - 169
src/views/WDLY/salesMange/order/index.vue

@@ -2,38 +2,23 @@
   <div class="tenant">
     <!-- <Banner /> -->
     <div class="content">
-      <byTable
-        :source="sourceList.data"
-        :pagination="sourceList.pagination"
-        :config="config"
-        :loading="loading"
-        highlight-current-row
-        :selectConfig="selectConfig"
-        :table-events="{
+      <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
+               :selectConfig="selectConfig" :table-events="{
           //element talbe事件都能传
           select: select,
-        }"
-        :action-list="[
+        }" :action-list="[
           {
             text: '添加订单',
             action: () => openModal('add'),
           },
-        ]"
-        @get-list="getList"
-      >
+        ]" @get-list="getList">
         <template #code="{ item }">
-          <div
-            style="cursor: pointer; color: #409eff"
-            @click="handleClickCode(item)"
-          >
+          <div style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
             {{ item.code }}
           </div>
         </template>
         <template #status="{ item }">
-          <div
-            style="cursor: pointer; color: #409eff"
-            @click="handleClickStatus(item)"
-          >
+          <div style="cursor: pointer; color: #409eff" @click="handleClickStatus(item)">
             {{ dictValueLabel(item.status, statusData) }}
           </div>
         </template>
@@ -45,140 +30,70 @@
         </template>
       </byTable>
     </div>
-    <el-dialog
-      :title="modalType == 'add' ? '添加订单' : '调仓接收'"
-      v-model="dialogVisible"
-      width="60%"
-      v-loading="loading"
-    >
-      <byForm
-        :formConfig="formConfig"
-        :formOption="formOption"
-        v-model="formData.data"
-        :rules="rules"
-        ref="byform"
-      >
+    <el-dialog :title="modalType == 'add' ? '添加订单' : '调仓接收'" v-model="dialogVisible" width="80%" v-loading="loading">
+      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
         <template #countryId>
-          <div>
-            <el-select
-              v-model="formData.data.countryId"
-              placeholder="国家"
-              @change="(val) => getCityData(val, '20', true)"
-            >
-              <el-option
-                v-for="item in countryData"
-                :label="item.chineseName"
-                :value="item.id"
-              >
+          <div style="width:100%">
+            <el-select v-model="formData.data.countryId" placeholder="国家" style="width:100%" @change="(val) => getCityData(val, '20', true)">
+              <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id">
               </el-option>
             </el-select>
           </div>
         </template>
 
         <template #provinceId>
-          <div>
-            <selectCity
-              placeholder="省/洲"
-              @change="(val) => getCityData(val, '30', true)"
-              addressId="provinceId"
-              addressName="provinceName"
-              v-model="formData.data"
-              :data="provinceData"
-            >
+          <div style="width:100%">
+            <selectCity placeholder="省/洲" @change="(val) => getCityData(val, '30', true)" addressId="provinceId" addressName="provinceName"
+                        v-model="formData.data" :data="provinceData">
             </selectCity>
           </div>
         </template>
 
         <template #cityId>
-          <div>
-            <selectCity
-              placeholder="城市"
-              addressId="cityId"
-              addressName="cityName"
-              v-model="formData.data"
-              :data="cityData"
-            >
+          <div style="width:100%">
+            <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData">
             </selectCity>
           </div>
         </template>
 
         <template #products>
           <div style="width: 100%">
-            <el-button
-              type="primary"
-              @click="openProduct = true"
-              style="margin-bottom: 10px"
-            >
+            <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px">
               添加产品
             </el-button>
-            <el-table
-              :data="formData.data.orderDetailsList"
-              show-summary
-              :summary-method="getSummaries"
-            >
-              <el-table-column prop="productCode" label="产品编码" />
-              <el-table-column prop="productName" label="产品名称" />
-              <el-table-column prop="price" label="单价" min-width="150">
+            <el-button type="primary" @click="openExcel = true" style="margin-bottom: 10px">
+              excel导入
+            </el-button>
+            <el-table :data="formData.data.orderDetailsList" show-summary :summary-method="getSummaries">
+              <el-table-column prop="productCode" label="产品编码" width="150" />
+              <el-table-column prop="productName" label="产品名称" min-width="150" />
+              <el-table-column prop="price" label="单价" width="150">
                 <template #default="{ row, $index }">
-                  <el-form-item
-                    :prop="'orderDetailsList.' + $index + '.price'"
-                    :rules="rules.price"
-                    :inline-message="true"
-                  >
-                    <el-input-number
-                      v-model="row.price"
-                      :precision="4"
-                      :controls="false"
-                      :min="0"
-                      @change="totalAmount"
-                      placeholder="请输入"
-                      onmousewheel="return false;"
-                    />
+                  <el-form-item :prop="'orderDetailsList.' + $index + '.price'" :rules="rules.price" :inline-message="true">
+                    <el-input-number v-model="row.price" :precision="4" :controls="false" :min="0" @change="totalAmount" placeholder="请输入"
+                                     onmousewheel="return false;" />
                   </el-form-item>
                 </template>
               </el-table-column>
-              <el-table-column prop="quantity" label="数量" min-width="150">
+              <el-table-column prop="quantity" label="数量" width="150">
                 <template #default="{ row, $index }">
-                  <el-form-item
-                    :prop="'orderDetailsList.' + $index + '.quantity'"
-                    :rules="rules.quantity"
-                    :inline-message="true"
-                  >
-                    <el-input-number
-                      v-model="row.quantity"
-                      :precision="4"
-                      :controls="false"
-                      :min="0"
-                      @change="totalAmount"
-                      placeholder="请输入"
-                      onmousewheel="return false;"
-                    />
+                  <el-form-item :prop="'orderDetailsList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
+                    <el-input-number v-model="row.quantity" :precision="4" :controls="false" :min="0" @change="totalAmount" placeholder="请输入"
+                                     onmousewheel="return false;" />
                   </el-form-item>
                 </template>
               </el-table-column>
-              <el-table-column prop="total" label="小计" />
+              <el-table-column prop="total" label="小计" width="120" />
               <el-table-column prop="remark" label="备注" min-width="200">
                 <template #default="{ row, $index }">
-                  <el-form-item
-                    :prop="'orderDetailsList.' + $index + '.remark'"
-                    :rules="rules.remark"
-                    :inline-message="true"
-                  >
+                  <el-form-item :prop="'orderDetailsList.' + $index + '.remark'" :rules="rules.remark" :inline-message="true">
                     <el-input v-model="row.remark" placeholder="请输入" />
                   </el-form-item>
                 </template>
               </el-table-column>
-              <el-table-column
-                prop="zip"
-                label="操作"
-                width="60"
-                fixed="right"
-                align="center"
-              >
+              <el-table-column prop="zip" label="操作" width="60" fixed="right" align="center">
                 <template #default="{ $index }">
-                  <el-button type="primary" link @click="handleRemove($index)"
-                    >删除</el-button
-                  >
+                  <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -187,22 +102,29 @@
       </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button
-          type="primary"
-          @click="submitForm('byform')"
-          size="large"
-          :loading="submitLoading"
-        >
+        <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">
           确 定
         </el-button>
       </template>
     </el-dialog>
-    <el-dialog
-      v-model="openProduct"
-      title="选择产品"
-      width="70%"
-      append-to-body
-    >
+
+    <el-dialog v-model="openExcel" title="excel导入" width="30%" append-to-body>
+      <div v-loading="excelLoading">
+        <div style="margin: 15px 0">
+          <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
+        </div>
+        <el-upload :action="actionUrl + '/orderInfo/excelImport'" :headers="headers" :before-upload="useImportExcelStore().updateRequestHeaders"
+                   :on-success="handleSuccess" :on-progress="handleProgress" :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
+          <el-button type="primary" plain>点击导入</el-button>
+        </el-upload>
+      </div>
+
+      <template #footer>
+        <el-button @click="openExcel = false" size="large">取 消</el-button>
+      </template>
+    </el-dialog>
+
+    <el-dialog v-model="openProduct" title="选择产品" width="70%" append-to-body>
       <SelectProduct @handleSelect="handleSelect"></SelectProduct>
       <template #footer>
         <span class="dialog-footer">
@@ -211,16 +133,8 @@
       </template>
     </el-dialog>
 
-    <el-dialog
-      v-model="openDetails"
-      title="订单详情"
-      width="40%"
-      append-to-body
-    >
-      <OrderDetails
-        :orderData="formData.orderData"
-        :key="formData.orderData.id"
-      ></OrderDetails>
+    <el-dialog v-model="openDetails" title="订单详情" width="40%" append-to-body>
+      <OrderDetails :orderData="formData.orderData" :key="formData.orderData.id"></OrderDetails>
       <template #footer>
         <span class="dialog-footer">
           <el-button @click="openDetails = false">取消</el-button>
@@ -228,37 +142,18 @@
       </template>
     </el-dialog>
 
-    <el-dialog
-      :title="'查看'"
-      v-model="recordDialog"
-      width="900"
-      destroy-on-close
-    >
-      <byForm
-        :formConfig="recordFormConfig"
-        :formOption="recordFormOption"
-        v-model="recordFormData.data"
-      >
+    <el-dialog :title="'查看'" v-model="recordDialog" width="900" destroy-on-close>
+      <byForm :formConfig="recordFormConfig" :formOption="recordFormOption" v-model="recordFormData.data">
         <template #products>
           <div style="width: 100%">
             <el-table :data="recordFormData.data.list">
-              <el-table-column
-                prop="logisticsCompanyName"
-                label="物流/快递公司"
-              />
+              <el-table-column prop="logisticsCompanyName" label="物流/快递公司" />
               <el-table-column prop="code" label="物流/快递单号" />
-              <el-table-column
-                prop="logisticsStatus"
-                label="物流状态"
-                width="100"
-                :formatter="(row) => handleShowKdStatus(row.logisticsStatus)"
-              />
+              <el-table-column prop="logisticsStatus" label="物流状态" width="100" :formatter="(row) => handleShowKdStatus(row.logisticsStatus)" />
               <el-table-column prop="createTime" label="创建时间" width="155" />
               <el-table-column label="操作" width="90" align="center">
                 <template #default="{ row, $index }">
-                  <el-button type="primary" text @click="pushKdRoute(row)"
-                    >查看</el-button
-                  >
+                  <el-button type="primary" text @click="pushKdRoute(row)">查看</el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -282,6 +177,9 @@ import useUserStore from "@/store/modules/user";
 import SelectProduct from "@/components/WDLY/product/SelectProduct";
 import OrderDetails from "@/components/WDLY/order/details";
 import selectCity from "@/components/selectCity/index.vue";
+import useImportExcelStore from "@/store/modules/importExcel";
+const headers = computed(() => useImportExcelStore().requestHeaders);
+const actionUrl = import.meta.env.VITE_APP_BASE_API;
 
 const loading = ref(false);
 const submitLoading = ref(false);
@@ -536,6 +434,9 @@ const formConfig = reactive([
       method: "post",
       resUrl: "rows",
     },
+    style: {
+      width: "31.5%",
+    },
   },
   {
     type: "select",
@@ -543,22 +444,25 @@ const formConfig = reactive([
     label: "订单类型",
     itemWidth: 100,
     data: [],
+    style: {
+      width: "31.5%",
+    },
   },
   {
     type: "input",
     prop: "contacts",
     label: "收件人",
-    itemWidth: 20,
+    itemWidth: 33.33,
     placeholder: "姓名",
   },
   {
     type: "input",
     prop: "phone",
     label: " ",
-    itemWidth: 80,
+    itemWidth: 66,
     placeholder: "联系电话",
     style: {
-      width: "30%",
+      width: "48%",
     },
   },
   {
@@ -888,6 +792,64 @@ const getSummaries = (param) => {
   });
   return sums;
 };
+
+const openExcel = ref(false);
+const excelLoading = ref(false);
+const downloadTemplate = () => {
+  fetch("/static/SaleOrderImportTemplate.xlsx")
+    .then((res) => res.blob())
+    .then((res) => {
+      const url = window.URL.createObjectURL(res);
+      let filename = "销售订单导入模板.xlsx";
+      const link = document.createElement("a");
+      link.style.display = "none";
+      link.href = url;
+      link.setAttribute("download", filename);
+      document.body.appendChild(link);
+      link.click();
+    });
+};
+
+const handleProgress = () => {
+  excelLoading.value = true;
+};
+const handleSuccess = (res) => {
+  if (res.code != 200) {
+    excelLoading.value = false;
+    return ElMessage({
+      message: `${res.msg},请重试!`,
+      type: "info",
+    });
+  } else {
+    ElMessage({
+      message: "导入成功!",
+      type: "success",
+    });
+    if (res && res.data && res.data.length > 0) {
+      formData.data.orderDetailsList = res.data.map((x) => ({
+        productName: x.productName,
+        productCode: x.productCustomCode,
+        productId: x.bussinessId,
+        total: "",
+        quantity: x.count,
+        price: x.price,
+        remark: x.remark,
+      }));
+      totalAmount();
+    }
+    openExcel.value = false;
+    excelLoading.value = false;
+  }
+};
+
+const handleError = (err) => {
+  ElMessage({
+    message: `${err},请重试!`,
+    type: "info",
+  });
+  openExcel.value = false;
+  excelLoading.value = false;
+};
 </script>
   
 <style lang="scss" scoped>

+ 108 - 93
src/views/purchaseSales/outAndInWarehouse/manualDelivery/index.vue

@@ -1,96 +1,42 @@
 <template>
   <div class="tenant">
     <div class="content">
-      <byTable
-        :source="sourceList.data"
-        :pagination="sourceList.pagination"
-        :config="config"
-        :loading="loading"
-        :selectConfig="selectConfig"
-        highlight-current-row
-        :action-list="[
+      <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
+               highlight-current-row :action-list="[
           {
             text: '手动出库',
             action: () => openModal(),
           },
-        ]"
-        @get-list="getList"
-      >
+        ]" @get-list="getList">
       </byTable>
     </div>
 
-    <el-dialog
-      title="手动出库"
-      v-if="dialogVisible"
-      v-model="dialogVisible"
-      width="1000"
-      v-loading="loadingDialog"
-    >
-      <byForm
-        :formConfig="formConfig"
-        :formOption="formOption"
-        v-model="formData.data"
-        :rules="rules"
-        ref="submit"
-      >
+    <el-dialog title="手动出库" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
+      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
         <template #details>
           <div style="width: 100%">
             <el-button type="primary" @click="clickAdd()">添加明细</el-button>
-            <el-table
-              :data="formData.data.list"
-              style="width: 100%; margin-top: 16px"
-            >
-              <el-table-column
-                prop="productCode"
-                label="产品编码"
-                width="140"
-              />
-              <el-table-column
-                prop="productName"
-                label="产品名称"
-                min-width="160"
-              />
-              <el-table-column
-                prop="productSpec"
-                label="规格"
-                width="160"
-              />
+            <el-button type="primary" @click="openExcel = true" :disabled="!formData.data.warehouseId">
+              excel导入(导入前请先选择仓库)
+            </el-button>
+            <el-table :data="formData.data.list" style="width: 100%; margin-top: 16px">
+              <el-table-column prop="productCode" label="产品编码" width="140" />
+              <el-table-column prop="productName" label="产品名称" min-width="160" />
+              <el-table-column prop="productSpec" label="规格" width="160" />
               <el-table-column prop="productUnit" label="单位" width="100" />
-              <el-table-column
-                prop="productQuantity"
-                label="库存数量"
-                width="120"
-              />
+              <el-table-column prop="productQuantity" label="库存数量" width="120" />
               <el-table-column label="出库数量" width="160">
                 <template #default="{ row, $index }">
                   <div style="width: 100%">
-                    <el-form-item
-                      :prop="'list.' + $index + '.quantity'"
-                      :rules="rules.quantity"
-                      :inline-message="true"
-                    >
-                      <el-input-number
-                        v-model="row.quantity"
-                        placeholder="请输入出库数量"
-                        style="width: 100%"
-                        :precision="0"
-                        :controls="false"
-                        :min="0"
-                      />
+                    <el-form-item :prop="'list.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
+                      <el-input-number v-model="row.quantity" placeholder="请输入出库数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
                     </el-form-item>
                   </div>
                 </template>
               </el-table-column>
-              <el-table-column
-                align="center"
-                label="操作"
-                width="80"
-                fixed="right"
-              >
+              <el-table-column align="center" label="操作" width="80" fixed="right">
                 <template #default="{ row, $index }">
-                  <el-button type="primary" link @click="handleDelete($index)"
-                    >删除</el-button
-                  >
+                  <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -99,27 +45,32 @@
       </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm()" size="large"
-          >确 定</el-button
-        >
+        <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
       </template>
     </el-dialog>
 
-    <el-dialog
-      v-model="openProduct"
-      title="选择商品"
-      width="80%"
-      append-to-body
-    >
-      <InventoryInquiry
-        :selectStatus="true"
-        :warehouseId="formData.data.warehouseId"
-        @cancel="openProduct = false"
-        @select="pushGoods"
-        :key="formData.data.warehouseId"
-      >
+    <el-dialog v-model="openProduct" title="选择商品" width="80%" append-to-body>
+      <InventoryInquiry :selectStatus="true" :warehouseId="formData.data.warehouseId" @cancel="openProduct = false" @select="pushGoods"
+                        :key="formData.data.warehouseId">
       </InventoryInquiry>
     </el-dialog>
+
+    <el-dialog v-model="openExcel" title="excel导入" width="30%" append-to-body>
+      <div v-loading="excelLoading">
+        <div style="margin: 15px 0">
+          <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
+        </div>
+        <el-upload :action="actionUrl + '/stock/excelImport'" :headers="headers" :data="uploadData"
+                   :before-upload="useImportExcelStore().updateRequestHeaders" :on-success="handleSuccess" :on-progress="handleProgress"
+                   :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
+          <el-button type="primary" plain>点击导入</el-button>
+        </el-upload>
+      </div>
+
+      <template #footer>
+        <el-button @click="openExcel = false" size="large">取 消</el-button>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -129,6 +80,10 @@ import byTable from "@/components/byTable/index";
 import byForm from "@/components/byForm/index";
 import { ElMessage } from "element-plus";
 import InventoryInquiry from "@/views/purchaseSales/outAndInWarehouse/inventoryInquiry/index";
+import useImportExcelStore from "@/store/modules/importExcel";
+const headers = computed(() => useImportExcelStore().requestHeaders);
+const actionUrl = import.meta.env.VITE_APP_BASE_API;
+const uploadData = ref({});
 
 const { proxy } = getCurrentInstance();
 const warehouseList = ref([]);
@@ -159,42 +114,42 @@ const config = computed(() => {
       attrs: {
         label: "仓库名称",
         prop: "warehouseName",
-        width: 220,
+        width: 150,
       },
     },
     {
       attrs: {
         label: "物品编码",
         prop: "productCode",
-        width: 160,
+        width: 150,
       },
     },
     {
       attrs: {
         label: "物品名称",
         prop: "productName",
-        "min-width": 220,
+        "min-width": 160,
       },
     },
     {
       attrs: {
         label: "规格",
         prop: "productSpec",
-        width: 160,
+        "min-width": 220,
       },
     },
     {
       attrs: {
         label: "单位",
         prop: "productUnit",
-        width: 120,
+        width: 100,
       },
     },
     {
       attrs: {
         label: "出库数量",
         prop: "quantity",
-        width: 140,
+        width: 110,
       },
     },
     {
@@ -266,6 +221,9 @@ const formConfig = computed(() => {
       data: warehouseList.value,
       fn: () => {
         changeWarehouse();
+        uploadData.value = {
+          warehouseId: formData.data.warehouseId,
+        };
       },
     },
     {
@@ -378,6 +336,63 @@ const submitForm = () => {
 const handleDelete = (index) => {
   formData.data.list.splice(index, 1);
 };
+
+const openExcel = ref(false);
+const excelLoading = ref(false);
+const downloadTemplate = () => {
+  fetch("/static/ManualOutInBoundImportTemplate.xlsx")
+    .then((res) => res.blob())
+    .then((res) => {
+      const url = window.URL.createObjectURL(res);
+      let filename = "手动出库导入模板.xlsx";
+      const link = document.createElement("a");
+      link.style.display = "none";
+      link.href = url;
+      link.setAttribute("download", filename);
+      document.body.appendChild(link);
+      link.click();
+    });
+};
+
+const handleProgress = () => {
+  excelLoading.value = true;
+};
+const handleSuccess = (res) => {
+  if (res.code != 200) {
+    excelLoading.value = false;
+    return ElMessage({
+      message: `${res.msg},请重试!`,
+      type: "info",
+    });
+  } else {
+    ElMessage({
+      message: "导入成功!",
+      type: "success",
+    });
+    if (res && res.data && res.data.length > 0) {
+      formData.data.list = res.data.map((x) => ({
+        productCode: x.productCustomCode,
+        productId: x.bussinessId,
+        productName: x.productName,
+        productSpec: x.productSpec,
+        productUnit: x.productUnit,
+        productQuantity: x.stockCount,
+        quantity: x.count,
+      }));
+    }
+    openExcel.value = false;
+    excelLoading.value = false;
+  }
+};
+
+const handleError = (err) => {
+  ElMessage({
+    message: `${err},请重试!`,
+    type: "info",
+  });
+  openExcel.value = false;
+  excelLoading.value = false;
+};
 </script>
 
 <style lang="scss" scoped>

+ 101 - 88
src/views/purchaseSales/outAndInWarehouse/manualWarehousing/index.vue

@@ -1,93 +1,41 @@
 <template>
   <div class="tenant">
     <div class="content">
-      <byTable
-        :source="sourceList.data"
-        :pagination="sourceList.pagination"
-        :config="config"
-        :loading="loading"
-        :selectConfig="selectConfig"
-        highlight-current-row
-        :action-list="[
+      <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
+               highlight-current-row :action-list="[
           {
             text: '手动入库',
             action: () => openModal(),
           },
-        ]"
-        @get-list="getList"
-      >
+        ]" @get-list="getList">
       </byTable>
     </div>
 
-    <el-dialog
-      title="手动入库"
-      v-if="dialogVisible"
-      v-model="dialogVisible"
-      width="1000"
-      v-loading="loadingDialog"
-    >
-      <byForm
-        :formConfig="formConfig"
-        :formOption="formOption"
-        v-model="formData.data"
-        :rules="rules"
-        ref="submit"
-      >
+    <el-dialog title="手动入库" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
+      <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
         <template #details>
           <div style="width: 100%">
-            <el-button type="primary" @click="openProduct = true"
-              >添加明细</el-button
-            >
-            <el-table
-              :data="formData.data.list"
-              style="width: 100%; margin-top: 16px"
-            >
-              <el-table-column
-                prop="productCode"
-                label="产品编码"
-                width="140"
-              />
-              <el-table-column
-                prop="productName"
-                label="产品名称"
-                min-width="220"
-              />
-              <el-table-column
-                prop="productSpec"
-                label="规格"
-                min-width="220"
-              />
+            <el-button type="primary" @click="openProduct = true">添加明细</el-button>
+            <el-button type="primary" @click="openExcel = true">
+              excel导入
+            </el-button>
+            <el-table :data="formData.data.list" style="width: 100%; margin-top: 16px">
+              <el-table-column prop="productCode" label="产品编码" width="140" />
+              <el-table-column prop="productName" label="产品名称" min-width="220" />
+              <el-table-column prop="productSpec" label="规格" min-width="220" />
               <el-table-column prop="productUnit" label="单位" width="100" />
               <el-table-column label="入库数量" width="160">
                 <template #default="{ row, $index }">
                   <div style="width: 100%">
-                    <el-form-item
-                      :prop="'list.' + $index + '.quantity'"
-                      :rules="rules.quantity"
-                      :inline-message="true"
-                    >
-                      <el-input-number
-                        v-model="row.quantity"
-                        placeholder="请输入数量"
-                        style="width: 100%"
-                        :precision="0"
-                        :controls="false"
-                        :min="0"
-                      />
+                    <el-form-item :prop="'list.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
+                      <el-input-number v-model="row.quantity" placeholder="请输入数量" style="width: 100%" :precision="0" :controls="false" :min="0" />
                     </el-form-item>
                   </div>
                 </template>
               </el-table-column>
-              <el-table-column
-                align="center"
-                label="操作"
-                width="80"
-                fixed="right"
-              >
+              <el-table-column align="center" label="操作" width="80" fixed="right">
                 <template #default="{ row, $index }">
-                  <el-button type="primary" link @click="handleDelete($index)"
-                    >删除</el-button
-                  >
+                  <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
                 </template>
               </el-table-column>
             </el-table>
@@ -96,22 +44,28 @@
       </byForm>
       <template #footer>
         <el-button @click="dialogVisible = false" size="large">取 消</el-button>
-        <el-button type="primary" @click="submitForm()" size="large"
-          >确 定</el-button
-        >
+        <el-button type="primary" @click="submitForm()" size="large">确 定</el-button>
       </template>
     </el-dialog>
 
-    <el-dialog
-      v-model="openProduct"
-      title="选择商品"
-      width="70%"
-      append-to-body
-    >
-      <SelectGoods
-        @cancel="openProduct = false"
-        @pushGoods="pushGoods"
-      ></SelectGoods>
+    <el-dialog v-model="openProduct" title="选择商品" width="70%" append-to-body>
+      <SelectGoods @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
+    </el-dialog>
+
+    <el-dialog v-model="openExcel" title="excel导入" width="30%" append-to-body>
+      <div v-loading="excelLoading">
+        <div style="margin: 15px 0">
+          <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
+        </div>
+        <el-upload :action="actionUrl + '/stock/excelImport'" :headers="headers" :before-upload="useImportExcelStore().updateRequestHeaders"
+                   :on-success="handleSuccess" :on-progress="handleProgress" :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
+          <el-button type="primary" plain>点击导入</el-button>
+        </el-upload>
+      </div>
+
+      <template #footer>
+        <el-button @click="openExcel = false" size="large">取 消</el-button>
+      </template>
     </el-dialog>
   </div>
 </template>
@@ -122,6 +76,9 @@ import byTable from "@/components/byTable/index";
 import byForm from "@/components/byForm/index";
 import { ElMessage } from "element-plus";
 import SelectGoods from "@/components/product/SelectGoods";
+import useImportExcelStore from "@/store/modules/importExcel";
+const headers = computed(() => useImportExcelStore().requestHeaders);
+const actionUrl = import.meta.env.VITE_APP_BASE_API;
 
 const { proxy } = getCurrentInstance();
 const warehouseList = ref([]);
@@ -152,42 +109,42 @@ const config = computed(() => {
       attrs: {
         label: "仓库名称",
         prop: "warehouseName",
-        width: 220,
+        width: 150,
       },
     },
     {
       attrs: {
         label: "物品编码",
         prop: "productCode",
-        width: 160,
+        width: 150,
       },
     },
     {
       attrs: {
         label: "物品名称",
         prop: "productName",
-        "min-width": 220,
+        "min-width": 160,
       },
     },
     {
       attrs: {
         label: "规格",
         prop: "productSpec",
-        width: 160,
+        "min-width": 220,
       },
     },
     {
       attrs: {
         label: "单位",
         prop: "productUnit",
-        width: 120,
+        width: 100,
       },
     },
     {
       attrs: {
         label: "入库数量",
         prop: "quantity",
-        width: 140,
+        width: 110,
       },
     },
     {
@@ -329,6 +286,62 @@ const submitForm = () => {
 const handleDelete = (index) => {
   formData.data.list.splice(index, 1);
 };
+
+const openExcel = ref(false);
+const excelLoading = ref(false);
+const downloadTemplate = () => {
+  fetch("/static/ManualOutInBoundImportTemplate.xlsx")
+    .then((res) => res.blob())
+    .then((res) => {
+      const url = window.URL.createObjectURL(res);
+      let filename = "手动入库导入模板.xlsx";
+      const link = document.createElement("a");
+      link.style.display = "none";
+      link.href = url;
+      link.setAttribute("download", filename);
+      document.body.appendChild(link);
+      link.click();
+    });
+};
+
+const handleProgress = () => {
+  excelLoading.value = true;
+};
+const handleSuccess = (res) => {
+  if (res.code != 200) {
+    excelLoading.value = false;
+    return ElMessage({
+      message: `${res.msg},请重试!`,
+      type: "info",
+    });
+  } else {
+    ElMessage({
+      message: "导入成功!",
+      type: "success",
+    });
+    if (res && res.data && res.data.length > 0) {
+      formData.data.list = res.data.map((x) => ({
+        productCode: x.productCustomCode,
+        productId: x.bussinessId,
+        productName: x.productName,
+        productSpec: x.productSpec,
+        productUnit: x.productUnit,
+        quantity: x.count,
+      }));
+    }
+    openExcel.value = false;
+    excelLoading.value = false;
+  }
+};
+
+const handleError = (err) => {
+  ElMessage({
+    message: `${err},请重试!`,
+    type: "info",
+  });
+  openExcel.value = false;
+  excelLoading.value = false;
+};
 </script>
 
 <style lang="scss" scoped>