From e4bb381c896015c4b87faa002ba6875c06a2fd16 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期四, 26 十二月 2024 14:33:10 +0800
Subject: [PATCH] 同步检测中心cnas修改

---
 src/components/view/b1-expenses.vue |  153 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 137 insertions(+), 16 deletions(-)

diff --git a/src/components/view/b1-expenses.vue b/src/components/view/b1-expenses.vue
index be06f02..62fd65a 100644
--- a/src/components/view/b1-expenses.vue
+++ b/src/components/view/b1-expenses.vue
@@ -49,7 +49,7 @@
     <div style="width: 100%;height: 100%;">
       <div>
         <el-row class="title">
-          <el-col :span="12" style="padding-left: 20px;">璐圭敤缁熻</el-col>
+          <el-col :span="12" style="padding-left: 20px;text-align: left;">璐圭敤缁熻</el-col>
           <el-col :span="12" style="text-align: right;">
             <el-button size="small" type="primary">OA鎺ㄩ��</el-button>
           </el-col>
@@ -65,19 +65,32 @@
             </el-date-picker>
           </div>
         </div>
-        <div class="search_thing">
-          <div class="search_label">濮旀墭浜猴細</div>
-          <div class="search_input"><el-input size="small" placeholder="璇疯緭鍏�" clearable
-              v-model="componentData.entity.name" @keyup.enter.native="refreshTable()"></el-input></div>
+        <div class="search_thing" style="width: 340px">
+          <div class="search_label">濮旀墭鍗曚綅锛�</div>
+          <div class="search_input">
+<!--            <el-input size="small" placeholder="璇疯緭鍏�" clearable-->
+<!--               @keyup.enter.native="refreshTable()"></el-input>-->
+            <el-select @focus="getCompanyOptions" @change="refreshTable()" clearable
+                       size="small" v-model="componentData.entity.company" style="width: 100%">
+              <el-option v-for="item in companyOptions" :key="item.value"
+                         :label="item.label" :value="item.label">
+              </el-option>
+            </el-select>
+          </div>
         </div>
         <div class="search_thing" style="padding-left: 30px;">
           <el-button size="small" @click="refresh()">閲� 缃�</el-button>
           <el-button size="small" type="primary" @click="refreshTable()">鏌� 璇�</el-button>
         </div>
+        <div class="search_thing" style="padding-left: 70px;">鎬讳环锛歿{total}}</div>
+        <div class="search_thing" style="padding-left: 70px;">
+          <el-button size="small" type="primary" @click="handleDown" :loading="outLoading" v-if="isExport">瀵煎嚭</el-button>
+        </div>
       </div>
       <div class="table">
-        <ValueTable ref="ValueTable" :url="$api.insOrder.costStatistics" :componentData="componentData" :key="upIndex"
-          @handleWeave="handleWeave" />
+        <ValueTable ref="ValueTable" :url="$api.insOrder.costStatistics"
+                    :componentData="componentData" :key="upIndex"
+          @handleWeave="handleWeave" :column-min-width="'140'"/>
       </div>
     </div>
     <el-dialog title="鍦ㄧ嚎缂栧埗" :visible.sync="claimVisible" width="70%" :modal-append-to-body="false">
@@ -92,20 +105,18 @@
 
 <script>
   import ValueTable from '../tool/value-table.vue'
-  import Word from '../tool/word.vue'
   export default {
     components: {
       ValueTable,
-      Word,
     },
     data() {
       return {
         componentData: {
           entity: {
-            name: null,
+            company: null,
             dates: null,
             orderBy: {
-              field: 'id,ins_sample_id',
+              field: 'id',
               order: 'asc'
             }
           },
@@ -126,6 +137,14 @@
                 name: 'entrustCode',
                 index: 2
               },
+              /* {
+                name: 'sample',
+                index: 3
+              },
+              {
+                name: 'model',
+                index: 4
+              }, */
               {
                 name: 'company',
                 index: 8
@@ -136,8 +155,8 @@
               },
             ],
             // 鐗规畩鐨勫悎骞惰锛屾牴鎹甿ain鍜宺ows鐨刵ame鏉ュ悎骞�
-            special: {
-              main: 'insSampleId',
+            /* special: {
+              main: 'entrustCode',
               rows: [{
                   name: 'sample',
                   index: 3
@@ -155,7 +174,7 @@
                   index: 6
                 },
               ]
-            }
+            } */
           },
           tagField: {
             type: {
@@ -179,13 +198,28 @@
           },
           selectField: {},
           requiredAdd: [],
-          requiredUp: []
+          requiredUp: [],
+          needSort: ['createTime', 'sample'],
         },
         entityCopy: {},
         upIndex: 0,
         claimVisible: false,
         dates: [],
-        index2: 0
+        index2: 0,
+        total: 0,
+        companyOptions: [], // 濮旀墭鍗曚綅鏋氫妇鍊�
+        entity: {
+          orderBy: {
+            field: 'id',
+            order: 'asc'
+          }
+        },
+        page: {
+          current: -1,
+          size: -1,
+        },
+        outLoading:false,
+        isExport:false
       }
     },
     mounted() {
@@ -195,6 +229,61 @@
       this.getPower()
     },
     methods: {
+      handleDown(){
+        let entity = {...this.componentData.entity}
+        // entity.dates = JSON.stringify(entity.dates)
+        delete entity.orderBy
+        this.outLoading = true
+        this.$axios.post(this.$api.insOrder.export,{
+          entity:entity
+        },{
+            headers: {
+              'Content-Type': 'application/json'
+            }
+          ,responseType: "blob"}).then(res => {
+          this.outLoading = false
+          const blob = new Blob([res],{ type: 'application/octet-stream' });
+          //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆
+          let reader = new FileReader();
+          reader.readAsText(blob, 'utf-8');
+          reader.onload = () => {
+            try {
+              let result = JSON.parse(reader.result);
+              if (result.message) {
+                this.$message.error(result.message);
+              } else {
+                const url = URL.createObjectURL(blob);
+                const link = document.createElement('a');
+                link.href = url;
+                let date = JSON.parse(entity.dates)
+                link.download = (entity.company?entity.company+' ':'')+date[0]+' - '+date[1]+'璐圭敤缁熻.xlsx';
+                link.click();
+                this.$message.success('瀵煎嚭鎴愬姛')
+              }
+            } catch (err) {
+              console.log(err);
+              const url = URL.createObjectURL(blob);
+              const link = document.createElement('a');
+              link.href = url;
+              let date = JSON.parse(entity.dates)
+              link.download = (entity.company?entity.company+' ':'')+date[0]+' - '+date[1]+'璐圭敤缁熻.xlsx';
+              link.click();
+              this.$message.success('瀵煎嚭鎴愬姛')
+            }
+          }
+        })
+      },
+      getTotal(){
+        this.$axios.post(this.$api.insOrder.costStatistics2, {
+          entity:this.componentData.entity
+        }, {
+          headers: {
+            'Content-Type': 'application/json'
+          }
+        }).then(res => {
+          this.total = res.data.total
+        })
+      },
       getDates(){
         //褰撳墠鏈堢涓�澶�
         var y = new Date().getFullYear(); //鑾峰彇骞翠唤
@@ -213,13 +302,40 @@
         this.index2++
         this.componentData.entity.dates = `["${startDate}","${endDate}"]`
       },
+      getCompanyOptions () {
+        this.$axios.post(this.$api.user.selectCustomPageList, {
+          page: this.page,
+          entity: this.entity
+        }, {
+          headers: {
+            'Content-Type': 'application/json'
+          }
+          }
+        ).then(res => {
+          if (res.code === 200) {
+            const list = res.data.body.records
+            this.companyOptions = []
+            list.map((item) => {
+              const obj = Object.assign({
+                value: item.id,
+                label: item.company,
+              })
+              this.companyOptions.push(obj)
+            })
+          }
+        }).catch(e => {
+          this.$message.error('鏌ヨ澶辫触')
+        })
+      },
       refreshTable() {
         this.$refs['ValueTable'].selectList()
+        this.getTotal()
       },
       refresh() {
         this.componentData.entity = this.HaveJson(this.entityCopy)
         this.componentData.init = true
         this.getDates()
+        this.getTotal()
         this.upIndex++
       },
       handleWeave() {
@@ -238,6 +354,10 @@
           if (power[i].menuMethod == 'addInsOrder') {
             add = true
           }
+          //
+          if (power[i].menuMethod == 'export') {
+            this.isExport = true
+          }
         }
         if (!up) {
           this.componentData.do.splice(4, 1)
@@ -255,6 +375,7 @@
         }
         this.componentData.entity.dates = JSON.stringify(val)
         this.$refs['ValueTable'].selectList()
+        this.getTotal()
       }
     }
   }

--
Gitblit v1.9.3