Przeglądaj źródła

产品维护excel导出

cz 10 miesięcy temu
rodzic
commit
6e90246a21
1 zmienionych plików z 95 dodań i 237 usunięć
  1. 95 237
      src/views/WDLY/basic/product/index.vue

+ 95 - 237
src/views/WDLY/basic/product/index.vue

@@ -1,30 +1,20 @@
 <template>
   <div class="user">
     <div class="tree">
-      <treeList
-        title="产品分类"
-        submitType="1"
-        :data="treeListData"
-        v-model="sourceList.pagination.productClassifyId"
-        @change="treeChange"
-        @changeTreeList="getTreeList"
-      >
+      <treeList title="产品分类" submitType="1" :data="treeListData" v-model="sourceList.pagination.productClassifyId" @change="treeChange"
+                @changeTreeList="getTreeList">
       </treeList>
     </div>
     <div class="content">
-      <byTable
-        :tableHeight="tableHeight"
-        :source="sourceList.data"
-        :pagination="sourceList.pagination"
-        :config="config"
-        :loading="loading"
-        highlight-current-row
-        :selectConfig="selectConfig"
-        :table-events="{
+      <byTable :tableHeight="tableHeight" :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: '导出Excel',
+            action: () => deriveExcel(),
+          },
           {
             text: '批量修改销售状态',
             action: () => openUpdateDialog(),
@@ -40,113 +30,60 @@
             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="800"
-      v-loading="loadingOne"
-      destroy-on-close
-    >
+    <el-dialog :title="modalType == 'add' ? '添加' : '编辑'" v-model="dialogVisible" width="800" v-loading="loadingOne" 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
-                v-model:fileList="fileList"
-                action="https://winfaster.obs.cn-south-1.myhuaweicloud.com"
-                :data="uploadData"
-                list-type="picture-card"
-                :on-remove="handleRemove"
-                :on-success="handleSuccess"
-                :before-upload="handleBeforeUpload"
-                accept=".gif, .jpeg, .jpg, .png"
-              >
-                <el-icon><Plus /></el-icon>
+              <el-upload v-model:fileList="fileList" action="https://winfaster.obs.cn-south-1.myhuaweicloud.com" :data="uploadData"
+                         list-type="picture-card" :on-remove="handleRemove" :on-success="handleSuccess" :before-upload="handleBeforeUpload"
+                         accept=".gif, .jpeg, .jpg, .png">
+                <el-icon>
+                  <Plus />
+                </el-icon>
               </el-upload>
             </div>
           </template>
 
           <template #combination>
             <div style="width: 100%">
-              <div
-                style="
+              <div style="
                   font-size: 14px;
                   font-weight: bold;
                   margin-bottom: 10px;
                   color: #333333;
-                "
-                v-show="formData.data.combination == 1"
-              >
+                " v-show="formData.data.combination == 1">
                 组合明细
               </div>
-              <el-button
-                type="primary"
-                @click="openProduct = true"
-                style="margin-bottom: 10px"
-                v-show="formData.data.combination == 1"
-              >
+              <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px" v-show="formData.data.combination == 1">
                 添加
               </el-button>
-              <el-table
-                :data="formData.data.productCombinationList"
-                v-show="formData.data.combination == 1"
-              >
+              <el-table :data="formData.data.productCombinationList" v-show="formData.data.combination == 1">
                 <el-table-column prop="code" label="产品编码" />
                 <el-table-column prop="name" label="产品名称" />
                 <el-table-column prop="spec" label="规格" />
-                <el-table-column
-                  prop="linkQuantity"
-                  label="组合数量"
-                  min-width="150"
-                >
+                <el-table-column prop="linkQuantity" label="组合数量" min-width="150">
                   <template #default="{ row, $index }">
-                    <el-form-item
-                      :prop="
+                    <el-form-item :prop="
                         'productCombinationList.' + $index + '.linkQuantity'
-                      "
-                      :rules="rules.linkQuantity"
-                      :inline-message="true"
-                    >
-                      <el-input-number
-                        v-model="row.linkQuantity"
-                        placeholder="请输入"
-                        :min="1"
-                        :controls="false"
-                        :precision="0"
-                        onmousewheel="return false;"
-                      />
+                      " :rules="rules.linkQuantity" :inline-message="true">
+                      <el-input-number v-model="row.linkQuantity" placeholder="请输入" :min="1" :controls="false" :precision="0"
+                                       onmousewheel="return false;" />
                     </el-form-item>
                   </template>
                 </el-table-column>
                 <el-table-column prop="zip" label="操作" width="100">
                   <template #default="{ $index }">
-                    <el-button
-                      type="primary"
-                      link
-                      @click="handleRemoveProduct($index)"
-                      >删除</el-button
-                    >
+                    <el-button type="primary" link @click="handleRemoveProduct($index)">删除</el-button>
                   </template>
                 </el-table-column>
               </el-table>
@@ -156,39 +93,19 @@
             <div style="width: 100%">
               <el-row>
                 <el-col :span="4">
-                  <el-input
-                    v-model="formData.data.victoriatouristJson.newProductsDay1"
-                    placeholder="请输入"
-                    disabled
-                  />
+                  <el-input v-model="formData.data.victoriatouristJson.newProductsDay1" placeholder="请输入" disabled />
                 </el-col>
                 <el-col :span="1" style="text-align: center"> ~ </el-col>
                 <el-col :span="4">
-                  <el-input-number
-                    v-model="formData.data.victoriatouristJson.newProductsDay"
-                    placeholder="请输入"
-                    :min="0"
-                    :controls="false"
-                    :precision="0"
-                    style="width: 100%"
-                    @change="changeDay(10)"
-                    onmousewheel="return false;"
-                  >
+                  <el-input-number v-model="formData.data.victoriatouristJson.newProductsDay" placeholder="请输入" :min="0" :controls="false"
+                                   :precision="0" style="width: 100%" @change="changeDay(10)" onmousewheel="return false;">
                   </el-input-number>
                 </el-col>
                 <el-col :span="1" style="text-align: center"> : </el-col>
                 <el-col :span="6">
-                  <el-input-number
-                    v-model="
+                  <el-input-number v-model="
                       formData.data.victoriatouristJson.newProductsExpectedSales
-                    "
-                    placeholder="预期销量"
-                    :min="0"
-                    :controls="false"
-                    :precision="0"
-                    style="width: 100%"
-                    onmousewheel="return false;"
-                  />
+                    " placeholder="预期销量" :min="0" :controls="false" :precision="0" style="width: 100%" onmousewheel="return false;" />
                 </el-col>
               </el-row>
             </div>
@@ -197,39 +114,19 @@
             <div style="width: 100%">
               <el-row>
                 <el-col :span="4">
-                  <el-input
-                    v-model="formData.data.victoriatouristJson.growUpDay1"
-                    placeholder="请输入"
-                    disabled
-                  />
+                  <el-input v-model="formData.data.victoriatouristJson.growUpDay1" placeholder="请输入" disabled />
                 </el-col>
                 <el-col :span="1" style="text-align: center"> ~ </el-col>
                 <el-col :span="4">
-                  <el-input-number
-                    v-model="formData.data.victoriatouristJson.growUpDay"
-                    placeholder="请输入"
-                    :min="0"
-                    :controls="false"
-                    :precision="0"
-                    style="width: 100%"
-                    @change="changeDay(20)"
-                    onmousewheel="return false;"
-                  >
+                  <el-input-number v-model="formData.data.victoriatouristJson.growUpDay" placeholder="请输入" :min="0" :controls="false" :precision="0"
+                                   style="width: 100%" @change="changeDay(20)" onmousewheel="return false;">
                   </el-input-number>
                 </el-col>
                 <el-col :span="1" style="text-align: center"> : </el-col>
                 <el-col :span="6">
-                  <el-input-number
-                    v-model="
+                  <el-input-number v-model="
                       formData.data.victoriatouristJson.growUpExpectedSales
-                    "
-                    placeholder="预期销量"
-                    :min="0"
-                    :controls="false"
-                    :precision="0"
-                    style="width: 100%"
-                    onmousewheel="return false;"
-                  />
+                    " placeholder="预期销量" :min="0" :controls="false" :precision="0" style="width: 100%" onmousewheel="return false;" />
                 </el-col>
               </el-row>
             </div>
@@ -240,17 +137,9 @@
                 大于{{ formData.data.victoriatouristJson.attDay }}天:
               </el-col>
               <el-col :span="6">
-                <el-input-number
-                  v-model="
+                <el-input-number v-model="
                     formData.data.victoriatouristJson.matureExpectedSales
-                  "
-                  placeholder="预期销量"
-                  :min="0"
-                  :controls="false"
-                  :precision="0"
-                  style="width: 100%"
-                  onmousewheel="return false;"
-                />
+                  " placeholder="预期销量" :min="0" :controls="false" :precision="0" style="width: 100%" onmousewheel="return false;" />
               </el-col>
             </el-row>
           </template>
@@ -258,53 +147,23 @@
       </div>
       <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
-      title="Excel导入"
-      v-model="openExcelDialog"
-      width="600"
-      v-loading="loading"
-    >
+    <el-dialog title="Excel导入" v-model="openExcelDialog" width="600" v-loading="loading">
       <div v-loading="excelLoading">
-        <el-button
-          @click="downloadTemplate"
-          type="primary"
-          style="margin-bottom: 10px"
-          >Excel模板下载</el-button
-        >
-        <el-upload
-          :action="actionUrl + '/productInfo/excelImport'"
-          :headers="headers"
-          :before-upload="useImportExcelStore().updateRequestHeaders"
-          :on-success="handleSuccessOne"
-          :on-progress="handleProgress"
-          :show-file-list="false"
-          :on-error="handleError"
-          accept=".xls, .xlsx"
-        >
+        <el-button @click="downloadTemplate" type="primary" style="margin-bottom: 10px">Excel模板下载</el-button>
+        <el-upload :action="actionUrl + '/productInfo/excelImport'" :headers="headers" :before-upload="useImportExcelStore().updateRequestHeaders"
+                   :on-success="handleSuccessOne" :on-progress="handleProgress" :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
           <el-button type="primary">点击导入</el-button>
         </el-upload>
       </div>
 
       <template #footer>
-        <el-button @click="openExcelDialog = false" size="large"
-          >取 消</el-button
-        >
-        <el-button
-          type="primary"
-          @click="submitExcel()"
-          size="large"
-          :loading="submitLoading"
-        >
+        <el-button @click="openExcelDialog = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitExcel()" size="large" :loading="submitLoading">
           确 定
         </el-button>
       </template>
@@ -312,48 +171,22 @@
 
     <el-dialog title="移交" v-model="moveDept" width="400" v-loading="loading">
       <div style="margin-bottom: 15px">请选择部门</div>
-      <el-tree-select
-        v-model="moveForm.deptId"
-        :data="deptList"
-        :render-after-expand="false"
-        check-strictly
-        :node-key="'deptId'"
-        :props="defaultProps"
-      />
+      <el-tree-select v-model="moveForm.deptId" :data="deptList" :render-after-expand="false" check-strictly :node-key="'deptId'"
+                      :props="defaultProps" />
       <template #footer>
         <el-button @click="moveDept = false">取 消</el-button>
-        <el-button
-          type="primary"
-          @click="submitMove()"
-          :loading="submitLoading"
-        >
+        <el-button type="primary" @click="submitMove()" :loading="submitLoading">
           确 定
         </el-button>
       </template>
     </el-dialog>
-    <el-dialog
-      title="批量修改销售状态"
-      v-model="updateSaleStatusDialog"
-      width="50%"
-      v-loading="submitLoading"
-      destroy-on-close
-    >
-      <byForm
-        :formConfig="saleStatusFormConfig"
-        :formOption="formOption"
-        v-model="formData.saleStatusData"
-        :rules="saleStatusRules"
-        ref="saleStatusForm"
-      >
+    <el-dialog title="批量修改销售状态" v-model="updateSaleStatusDialog" width="50%" v-loading="submitLoading" destroy-on-close>
+      <byForm :formConfig="saleStatusFormConfig" :formOption="formOption" v-model="formData.saleStatusData" :rules="saleStatusRules"
+              ref="saleStatusForm">
         <template #productCode>
           <div style="width: 100%">
             <el-form-item prop="productCodes">
-              <el-input
-                v-model="formData.saleStatusData.productCodes"
-                :rows="10"
-                type="textarea"
-                placeholder="请输入产品编码"
-              />
+              <el-input v-model="formData.saleStatusData.productCodes" :rows="10" type="textarea" placeholder="请输入产品编码" />
             </el-form-item>
             <div style="margin-top: 8px">
               多个产品请用回车换行,如:A00001
@@ -364,25 +197,13 @@
         </template>
       </byForm>
       <template #footer>
-        <el-button @click="updateSaleStatusDialog = false" size="large"
-          >取 消</el-button
-        >
-        <el-button
-          type="primary"
-          @click="submitUpdateSaleStatus()"
-          size="large"
-          :loading="submitLoading"
-        >
+        <el-button @click="updateSaleStatusDialog = false" size="large">取 消</el-button>
+        <el-button type="primary" @click="submitUpdateSaleStatus()" size="large" :loading="submitLoading">
           确 定
         </el-button>
       </template>
     </el-dialog>
-    <el-dialog
-      v-model="openProduct"
-      title="选择产品"
-      width="70%"
-      append-to-body
-    >
+    <el-dialog v-model="openProduct" title="选择产品" width="70%" append-to-body>
       <SelectProduct @handleSelect="handleSelect"></SelectProduct>
       <template #footer>
         <span class="dialog-footer">
@@ -1309,6 +1130,43 @@ const submitUpdateSaleStatus = () => {
       });
   });
 };
+
+const exportData = (res, name) => {
+  const content = res;
+  const blob = new Blob([content], { type: "application/ms-excel" });
+  const fileName = name;
+  if ("download" in document.createElement("a")) {
+    // 非IE下载
+    const elink = document.createElement("a");
+    elink.download = fileName;
+    elink.style.display = "none";
+    elink.href = URL.createObjectURL(blob);
+    document.body.appendChild(elink);
+    elink.click();
+    URL.revokeObjectURL(elink.href); // 释放URL 对象
+    document.body.removeChild(elink);
+  } else {
+    navigator.msSaveBlob(blob, fileName);
+  }
+};
+
+const deriveExcel = () => {
+  ElMessage({
+    message: "请稍后",
+    type: "success",
+  });
+  proxy.postTwo("/productInfo/exportExcel", sourceList.value.pagination).then(
+    (res) => {
+      exportData(res, "产品库.xlsx");
+    },
+    (err) => {
+      return ElMessage({
+        message: "请重试",
+        type: "info",
+      });
+    }
+  );
+};
 </script>
 
 <style lang="scss" scoped>