From 54f35ae7866dac5c497372b68d03309c7eae9424 Mon Sep 17 00:00:00 2001
From: dangsn <dangsn@chicecm.com>
Date: 星期三, 02 八月 2023 18:15:07 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/UBCS-WEB/src/components/Master/MasterTransfer.vue |  162 +++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 125 insertions(+), 37 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue b/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
index 9341b92..b876bab 100644
--- a/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
+++ b/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue
@@ -1,13 +1,15 @@
 <template>
-<el-dialog :visible.sync="dialogPush" append-to-body  :close-on-click-modal="false"  @close="recoverPage" title="瀵煎嚭">
-  <div style="margin-bottom: 10px">
-    <el-button type="success"
-               @click="handleExcel">涓嬭浇 澶氱骇琛ㄥごexcel</el-button>
-    <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>
+<el-dialog :visible.sync="dialogPush" append-to-body  :close-on-click-modal="false"  @close="escHandler" title="瀵煎嚭" style="width: 1550px; margin: auto">
+  <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 style="width: 150px" v-model="pageExport"></el-input> 锛堣緭鍏ラ〉鐮佹垨鑰呴〉闈㈣寖鍥达紝濡傦細1-10)锛�</span>
+    </div>
   </div>
   <div style="text-align: center">
   <el-transfer
@@ -20,15 +22,22 @@
     :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 @click="escHandler">鍙栨秷</el-button>
+  </div>
 </el-dialog>
 </template>
 
 <script>
+import {exportCode,FindData} from '@/api/GetItem'
+import func from "@/util/func";
 export default {
 name: "MasterTransfer",
-  props:['visible','tableHeadData','codeClassifyOid','tableData'],
+  props:['visible','tableHeadData','codeClassifyOid','tableData','selectRow','templateOid','limit'],
   data(){
     return {
+      pageExport:"",
       data: [],
       value: [],
       filterMethod(query, item) {
@@ -41,12 +50,14 @@
       option:{
         title: '鏂囨。鏍囬',
         column: [{
-          label: '澶氱骇琛ㄥご',
+          label: '涓绘暟鎹�',
           prop: 'header',
           children: []
         }],
         data: []
-      }
+      },
+      exportArr:{},
+      ids:""
     };
   },
   watch:{
@@ -55,28 +66,31 @@
       this.dialogPush = this.visible;
     },
     //琛ㄥご鏁版嵁 鐢ㄦ潵娓叉煋绌挎妗�
-    tableHeadData:{
-      handler(newval,oldval){
+    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
-           }
-         })
-       }
+        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,
+            });
+          });
+          console.log(this.data)
+          // excel琛ㄦ牸鏁版嵁杞崲
+          this.option.column[0].children = newval.map(obj => {
+            return {
+              label: obj.label,
+              prop: obj.prop
+            }
+          })
+        }
       }
-},
+    },
     tableData(){
       // 灏嗗�奸噷闈㈢殑true鎴杅alse鏀瑰彉涓烘槸鎴栧惁
       this.option.data = this.tableData.map(obj => {
@@ -101,16 +115,90 @@
   mounted() {
   },
   methods:{
+    escHandler(){
+      this.$emit('update:visible', false);
+      this.value=[];
+      this.radio=0
+    },
     //鍏抽棴椤甸潰
     recoverPage(){
       this.$emit('update:visible', false);
     },
     handleExcel(){
-      this.$Export.excel({
-        title: this.option.title,
-        columns: this.option.column,
-        data: this.option.data
-      });
+      if(this.value <= 0){
+        this.$message.warning('璇烽�夋嫨灞炴��')
+      }else {
+        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 {
+            //宸查�夋嫨澶氶��
+            const selectList=[]
+            //宸查�夋嫨灞炴��
+            let exportArr={}
+            const ids = this.selectRow.map(item => item.oid).join(',')
+            this.selectRow.forEach(item=>{
+              selectList.push(
+                item.oid
+              )
+            })
+            exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':this.ids,...this.exportArr}).then(res=>{
+              // console.log('res',res)
+              if(res){
+                func.downloadFileByBlob(res);
+                this.escHandler()
+              }
+            })
+
+          }
+        }else if(this.radio === 1){
+          this.ids=this.tableData.map(item => item.oid).join(',')
+          exportCode({codeClassifyOid:this.codeClassifyOid,...this.exportArr,limit:-1}).then(res=>{
+            // console.log('res',res)
+            if(res){
+              func.downloadFileByBlob(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;
+            }
+          }
+          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()
+            }
+          });
+        }
+
+      }
+
     },
   }
 }

--
Gitblit v1.9.3