From ce567eb11cd0cdbd826214c355d1a8caff175dca Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 15 十一月 2023 14:25:22 +0800
Subject: [PATCH] bug列表:181(修复新增,修改,删除接口,新增时没设置默认值,导致在建分类时无法查询到,关键属性查重规则)183(历史数据导入模板下载,过滤掉模板中配置的默认属性)

---
 Source/UBCS-WEB/src/components/Master/MasterTransfer.vue |  323 +++++++++++++++++++++++++++++++++++------------------
 1 files changed, 210 insertions(+), 113 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue b/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
index 7e667be..8d3d9df 100644
--- a/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
+++ b/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
@@ -1,48 +1,56 @@
 <template>
-<el-dialog :visible.sync="dialogPush" append-to-body  :close-on-click-modal="false"  @close="recoverPage" title="瀵煎嚭">
-  <div style="margin-bottom: 10px">
-    <el-radio-group v-model="radio">
-      <el-radio :label="0">閫夋嫨</el-radio>
-      <el-radio :label="1">鍏ㄩ儴</el-radio>
-      <el-radio :label="2">椤电爜</el-radio>
-    </el-radio-group>
-  </div>
-  <div style="text-align: center">
-  <el-transfer
-    style="text-align: left; display: inline-block;height: 400px"
-    filterable
-    :filter-method="filterMethod"
-    filter-placeholder="鍏抽敭璇嶆悳绱�"
-    v-model="value"
-    :titles="['鏈�夊睘鎬�', '宸查�夊睘鎬�']"
-    :data="data">
-  </el-transfer>
-  </div>
-  <div style="display: flex;justify-content: flex-end;">
-    <el-button size="small" plain type="success" @click="handleExcel">纭畾</el-button>
-    <el-button size="small" plain >鍙栨秷</el-button>
-  </div>
-</el-dialog>
+  <el-dialog :close-on-click-modal="false" :visible.sync="dialogPush" append-to-body style="width: 1550px; margin: auto"
+             title="瀵煎嚭"
+             @close="escHandler">
+    <div style="margin-bottom: 20px;">
+      <div>
+        <span>瀵煎嚭鏂瑰紡锛�</span>
+        <el-radio-group v-model="radio">
+          <el-radio :label="0">閫夋嫨</el-radio>
+          <el-radio :label="1">鍏ㄩ儴</el-radio>
+          <el-radio :label="2">椤电爜</el-radio>
+        </el-radio-group>
+        <span v-if="radio === 2" style="margin-left: 20px;"><el-input v-model="pageExport" style="width: 150px"></el-input> 锛堣緭鍏ラ〉鐮佹垨鑰呴〉闈㈣寖鍥达紝濡傦細1-10锛�</span>
+      </div>
+    </div>
+    <div style="text-align: center">
+      <el-transfer
+        v-model="value"
+        :data="data"
+        :filter-method="filterMethod"
+        :titles="['鏈�夊睘鎬�', '宸查�夊睘鎬�']"
+        filter-placeholder="鍏抽敭璇嶆悳绱�"
+        filterable
+        style="text-align: left; display: inline-block;height: 400px">
+      </el-transfer>
+    </div>
+    <div style="display: flex;justify-content: flex-end;">
+      <el-button plain size="small" type="success" @click="handleExcel">纭畾</el-button>
+      <el-button plain size="small" @click="escHandler">鍙栨秷</el-button>
+    </div>
+  </el-dialog>
 </template>
 
 <script>
-import {exportCode} from '@/api/GetItem'
+import {exportCode, FindData} from '@/api/GetItem'
 import func from "@/util/func";
+
 export default {
-name: "MasterTransfer",
-  props:['visible','tableHeadData','codeClassifyOid','tableData','selectRow'],
-  data(){
+  name: "MasterTransfer",
+  props: ['visible', 'tableHeadData', 'codeClassifyOid', 'tableData', 'selectRow', 'templateOid', 'limit'],
+  data() {
     return {
+      pageExport: "",
       data: [],
       value: [],
       filterMethod(query, item) {
         return item.label.indexOf(query) > -1;
       },
-      dialogPush:this.visible,
-      radio:0,
-      tableHeadFindData:[],
-      tableExportData:[],
-      option:{
+      dialogPush: this.visible,
+      radio: 0,
+      tableHeadFindData: [],
+      tableExportData: [],
+      option: {
         title: '鏂囨。鏍囬',
         column: [{
           label: '涓绘暟鎹�',
@@ -50,121 +58,210 @@
           children: []
         }],
         data: []
-      }
+      },
+      exportArr: {},
+      exportArrTwo: {},
+      ids: ""
     };
   },
-  watch:{
+  watch: {
     //鐩戝惉鍒濆鍖�
-    visible (){
+    visible() {
       this.dialogPush = this.visible;
     },
     //琛ㄥご鏁版嵁 鐢ㄦ潵娓叉煋绌挎妗�
-    tableHeadData:{
-      handler(newval,oldval){
-        console.log(newval)
-       if(newval){
-         //excel琛ㄥご鏁版嵁杞崲
-         this.tableHeadFindData=newval.map(obj => obj.label);
-         this.tableHeadFindData.forEach((city, index) => {
-           this.data.push({
-             label: city,
-             key: index,
-           });
-         });
-         //excel琛ㄦ牸鏁版嵁杞崲
-         this.option.column[0].children=newval.map(obj => {
-           return {
-             label: obj.label,
-             prop: obj.prop
-           }
-         })
-       }
+    tableHeadData: {
+      handler(newval, oldval) {
+        if (newval) {
+          // 娓呯┖data鏁扮粍
+          this.data = [];
+          // excel琛ㄥご鏁版嵁杞崲
+          this.tableHeadFindData = newval.map(obj => obj.label);
+          this.tableHeadFindData.forEach((city, index) => {
+            this.data.push({
+              label: city,
+              key: index,
+            });
+          });
+          // excel琛ㄦ牸鏁版嵁杞崲
+          this.option.column[0].children = newval.map(obj => {
+            return {
+              label: obj.label,
+              prop: obj.prop
+            }
+          })
+        }
       }
-},
-    tableData(){
+    },
+    tableData() {
       // 灏嗗�奸噷闈㈢殑true鎴杅alse鏀瑰彉涓烘槸鎴栧惁
       this.option.data = this.tableData.map(obj => {
-          for (let prop in obj) {
-            if (obj[prop] === "true") {
-              obj[prop] = "鏄�";
-            } else if (obj[prop] === "false") {
-              obj[prop] = "鍚�";
-            }
+        for (let prop in obj) {
+          if (obj[prop] === "true") {
+            obj[prop] = "鏄�";
+          } else if (obj[prop] === "false") {
+            obj[prop] = "鍚�";
           }
+        }
         return obj;
       });
     },
-    codeClassifyOid:{
-      handler(newval,oldval){
+    codeClassifyOid: {
+      handler(newval, oldval) {
+      }
+    },
+    value: {
+      handler(newval, oldval) {
+        //console.log('value', newval)
       }
     }
   },
-  computed:{
-
-  },
+  computed: {},
   mounted() {
   },
-  methods:{
+  methods: {
+    escHandler() {
+      this.$emit('update:visible', false);
+      this.value = [];
+      this.radio = 0
+    },
     //鍏抽棴椤甸潰
-    recoverPage(){
+    recoverPage() {
       this.$emit('update:visible', false);
     },
-    handleExcel(){
-      // this.$Export.excel({
-      //   title: this.option.title,
-      //   columns: this.option.column,
-      //   data: this.option.data
-      // });
-      if(this.radio === 0){
-        if(this.selectRow.length<=0){
+    handleExcel() {
+      this.value.map(index => this.tableHeadData[index].prop).forEach((item, index) => {
+        this.exportArr[`attrIdIndexMap[${index}]`] = item
+      })
+      if (this.radio === 0) {
+        if (this.selectRow.length <= 0) {
           this.$message.warning('璇烽�夋嫨瑕佸鍑虹殑妯℃澘')
-        }else {
+        } else {
           //宸查�夋嫨澶氶��
-          const selectList=[]
+          const selectList = []
           //宸查�夋嫨灞炴��
-          let exportArr={}
-          const ids = this.selectRow.map(item => item.oid).join(',')
-          this.selectRow.forEach(item=>{
+          let exportArr = {}
+          this.ids = this.selectRow.map(item => item.oid).join(',')
+          this.selectRow.forEach(item => {
             selectList.push(
-             item.oid
+              item.oid
             )
           })
-          this.value.map(index => this.tableHeadData[index].prop).forEach((item, index) => {
-            exportArr[`attrIdIndexMap[${index}]`] = item
-          })
-          exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':ids,...exportArr}).then(res=>{
-            console.log('res',res)
-            if(res){
-              const fileNames = res.headers['content-disposition'].split(";");
-              let characterSet = fileNames[2].split("filename*=")[1];
-              let fileName = decodeURI(fileNames[1].split("filename=")[1],characterSet);  // 涓嬭浇鐨勬枃浠跺悕
-              let blob = new Blob([res.data], {
-                type: res.data.type + ";charset=utf-8",
+          if (this.value <= 0) {
+            this.tableHeadData.map(item => item.prop)
+              .forEach((prop, index) => {
+                this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
               });
-              func.downloadFileByBlob(blob,fileName);
-              window.URL.revokeObjectURL(src); //閲婃斁鎺塨lob瀵硅薄
-            }
+            exportCode({
+              codeClassifyOid: this.codeClassifyOid,
+              'conditionMap[oid]': this.ids, ...this.exportArrTwo,
+              limit: -1
+            }).then(res => {
+              // console.log('res',res)
+              if (res) {
+                func.downloadFileByBlobHandler(res);
+                this.escHandler()
+              }
+            })
+          } else {
 
-            // let src = window.URL.createObjectURL(blob);
-            // if (src) {
-            //   let link = document.createElement("a");
-            //   link.style.display = "none";
-            //   link.href = src;
-            //   link.setAttribute("download", "鏂囦欢鍚嶅瓧.xls");
-            //   document.body.appendChild(link);
-            //   link.click();
-            //   document.body.removeChild(link); //涓嬭浇瀹屾垚绉婚櫎鍏冪礌
-            //   window.URL.revokeObjectURL(src); //閲婃斁鎺塨lob瀵硅薄
-            // }
-          })
+            exportCode({
+              codeClassifyOid: this.codeClassifyOid,
+              'conditionMap[oid]': this.ids, ...this.exportArr
+            }).then(res => {
+              // console.log('res',res)
+              if (res) {
+                func.downloadFileByBlobHandler(res);
+                this.escHandler()
+              }
+            })
 
+          }
         }
-      };
+      } else if (this.radio === 1) {
+        if (this.value <= 0) {
+          this.tableHeadData.map(item => item.prop)
+            .forEach((prop, index) => {
+              this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
+            });
+          exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArrTwo, limit: -1}).then(res => {
+            // console.log('res',res)
+            if (res) {
+              func.downloadFileByBlobHandler(res);
+              this.escHandler()
+            }
+          })
+        } else {
+          exportCode({codeClassifyOid: this.codeClassifyOid, ...this.exportArr, limit: -1}).then(res => {
+            // console.log('res',res)
+            if (res) {
+              func.downloadFileByBlobHandler(res);
+              this.escHandler()
+            }
+          })
+        }
+      } else if (this.radio === 2) {
+        const input = this.pageExport.trim();
+        let start, end;
+        if (input.includes('-')) {
+          if (input.indexOf('-') !== input.lastIndexOf('-')) {
+            this.$message.warning('杈撳叆鏍煎紡閿欒锛氬彧鑳借緭鍏ヤ竴涓� - 鍙烽殧寮�');
+            return;
+          }
+          //鍖呭惈-瑙f瀽
+          const range = input.split('-');
+          start = Number(range[0]);
+          end = Number(range[1]);
+          if (isNaN(start) || isNaN(end)) {
+            this.$message.warning('杈撳叆鏍煎紡閿欒');
+            return;
+          }
+        } else {
+          //涓嶅寘鍚�-瑙f瀽
+          start = Number(input);
+          end = start;
+          if (isNaN(start)) {
+            this.$message.warning('杈撳叆鏍煎紡閿欒');
+            return;
+          }
+        }
+        if (this.value >= 1) {
+          exportCode({
+            codeClassifyOid: this.codeClassifyOid, ...this.exportArr,
+            limit: this.limit,
+            page: start,
+            endPage: end
+          }).then((res) => {
+            // console.log('res',res)
+            if (res) {
+              func.downloadFileByBlobHandler(res);
+              this.escHandler()
+            }
+          });
+        } else {
+          this.tableHeadData.map(item => item.prop)
+            .forEach((prop, index) => {
+              this.exportArrTwo[`attrIdIndexMap[${index}]`] = prop;
+            });
+          exportCode({
+            codeClassifyOid: this.codeClassifyOid, ...this.exportArrTwo,
+            limit: this.limit,
+            page: start,
+            endPage: end
+          }).then(res => {
+            // console.log('res',res)
+            if (res) {
+              func.downloadFileByBlobHandler(res);
+              this.escHandler()
+            }
+          })
+        }
+      }
     },
   }
 }
 </script>
 
-<style scoped lang="scss">
+<style lang="scss" scoped>
 
 </style>

--
Gitblit v1.9.3