From 0ac2d43fce4d74f6eea5a51a2e16af4e6a536c7c Mon Sep 17 00:00:00 2001
From: WXL <1785969728@qq.com>
Date: 星期三, 14 八月 2024 14:19:24 +0800
Subject: [PATCH] 11

---
 src/views/project/unitCost/index.vue |  280 +++++++++++++++++++------------------------------------
 1 files changed, 97 insertions(+), 183 deletions(-)

diff --git a/src/views/project/unitCost/index.vue b/src/views/project/unitCost/index.vue
index ed51192..11d4e41 100644
--- a/src/views/project/unitCost/index.vue
+++ b/src/views/project/unitCost/index.vue
@@ -1,206 +1,85 @@
 <template>
   <div class="app-container">
-    <el-form
-      :model="queryParams"
-      ref="queryForm"
-      :inline="true"
-      v-show="showSearch"
-      label-width="120px"
-    >
-      <el-form-item label="浠樻鍖婚櫌" prop="name">
-        <el-input
-          v-model="queryParams.name"
-          placeholder="璇疯緭鍏ュ鍚�"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
+      <el-form-item label="鍖荤枟鏈烘瀯" prop="name">
+        <el-input v-model="queryParams.name" placeholder="璇疯緭鍏ュ尰鐤楁満鏋�" clearable size="small"
+          @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item label="鏀舵骞村害" prop="donationcategory">
-        <el-input
-          v-model="queryParams.donationcategory"
-          placeholder="璇疯緭鍏ユ崘鐚被鍒�"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+        <el-input v-model="queryParams.donationcategory" placeholder="璇疯緭鍏ユ煡璇㈡椂闂�" clearable size="small"
+          @keyup.enter.native="handleQuery" />
       </el-form-item>
-      <el-form-item label="鏀舵鐘舵��" prop="chargeamount">
-        <el-input
-          v-model="queryParams.chargeamount"
-          placeholder="璇疯緭鍏ヨ垂鐢ㄩ噾棰�"
-          clearable
-          size="small"
-          @keyup.enter.native="handleQuery"
-        />
+      <el-form-item label="鏀舵閲戦" prop="chargeamount">
+        <el-input v-model="queryParams.chargeamount" placeholder="璇疯緭鍏ユ敹娆鹃噾棰�" clearable size="small"
+          @keyup.enter.native="handleQuery" />
       </el-form-item>
       <el-form-item>
-        <el-button
-          type="primary"
-          icon="el-icon-search"
-          size="mini"
-          @click="handleQuery"
-          >鎼滅储</el-button
-        >
-        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
-          >閲嶇疆</el-button
-        >
+        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">鎼滅储</el-button>
+        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">閲嶇疆</el-button>
       </el-form-item>
     </el-form>
-
     <el-row :gutter="10" class="mb8">
       <el-col :span="1.5">
-        <el-button
-          type="primary"
-          plain
-          icon="el-icon-plus"
-          size="mini"
-          @click="handleAdd"
-          v-hasPermi="['system:donorcharge:add']"
-          >鏂板</el-button
-        >
+        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
+          v-hasPermi="['system:donorcharge:add']">鏂板</el-button>
       </el-col>
       <el-col :span="1.5">
-        <el-button
-          type="success"
-          plain
-          icon="el-icon-edit"
-          size="mini"
-          :disabled="single"
-          @click="handleUpdate"
-          v-hasPermi="['system:donorcharge:edit']"
-          >淇敼</el-button
-        >
+        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
+          v-hasPermi="['system:donorcharge:edit']">淇敼</el-button>
       </el-col>
       <el-col :span="1.5">
-        <el-button
-          type="danger"
-          plain
-          icon="el-icon-delete"
-          size="mini"
-          :disabled="multiple"
-          @click="handleDelete"
-          v-hasPermi="['system:donorcharge:remove']"
-          >鍒犻櫎</el-button
-        >
+        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
+          v-hasPermi="['system:donorcharge:remove']">鍒犻櫎</el-button>
       </el-col>
 
-      <right-toolbar
-        :showSearch.sync="showSearch"
-        @queryTable="getList"
-      ></right-toolbar>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table
-      v-loading="loading"
-      :data="donorchargeList"
-      @selection-change="handleSelectionChange"
-    >
-      <el-table-column
-        label="鐢宠鏃堕棿"
-        align="center"
-        prop="createTime"
-        width="180"
-      >
+    <el-table v-loading="loading" :data="donorchargeList" @selection-change="handleSelectionChange">
+      <el-table-column label="鐢宠鏃堕棿" align="center" prop="createTime" width="180">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="鏀舵鍗曞彿" align="center" prop="paymentno" />
-      <el-table-column
-        label="浠樻鍖婚櫌"
-        width="180"
-        align="center"
-        prop="hospitalname"
-      />
+      <el-table-column label="鐢宠鍗曞彿" align="center" prop="paymentno" />
+      <el-table-column label="鍖荤枟鏈烘瀯" width="180" align="center" prop="hospitalname" />
 
-      <el-table-column label="鐘舵��" align="center" prop="paystatus">
+      <el-table-column label="浠樻鐘舵��" align="center" prop="paystatus">
         <template slot-scope="scope">
-          <dict-tag
-            :options="dict.type.sys_gathering"
-            :value="scope.row.paystatus"
-          />
+          <dict-tag :options="dict.type.Collection_status" :value="scope.row.paystatus" />
         </template>
       </el-table-column>
-      <el-table-column
-        label="搴旀敹閲戦"
-        align="center"
-        prop="receivableamount"
-      />
-      <el-table-column label="宸叉敹閲戦" align="center" prop="receivedamount" />
-      <el-table-column
-        label="鏀舵鏃ユ湡"
-        width="180"
-        align="center"
-        prop="receivedtime"
-      />
-      <el-table-column label="缁忓姙浜�" align="center" prop="updateBy" />
+      <el-table-column label="搴旀敹閲戦" align="center" prop="receivableamount" />
+      <el-table-column label="瀹炴敹閲戦" align="center" prop="receivedamount" />
+      <el-table-column label="鏀舵鏃ユ湡" width="180" align="center" prop="receivedtime"><template slot-scope="scope">
+          <span>{{ parseTime(scope.row.createTime, "{y}-{m}-{d}") }}</span>
+        </template>
+      </el-table-column>
+      <el-table-column label="缁忓姙浜�" align="center" prop="userName" />
       <el-table-column label="鎿嶄綔" width="280" align="center">
         <template slot-scope="scope">
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleUpdate(scope.row)"
-            v-hasPermi="['system:donorcharge:edit']"
-            >淇敼</el-button
-          >
-          <el-button
-            size="mini"
-            type="text"
-            icon="el-icon-edit"
-            @click="handleDetail(scope.row)"
-            v-hasPermi="['system:donorcharge:edit']"
-            >璇︽儏</el-button
-          >
-          <el-button
-            size="mini"
-            type="text"
-            @click="handleDelete(scope.row)"
-            v-hasPermi="['system:donorcharge:remove']"
-            ><span class="button-delete"
-              ><i class="el-icon-delete"></i>鍒犻櫎</span
-            ></el-button
-          >
-          <el-button
-            size="mini"
-            type="primary"
-            @click="download(scope.row)"
-            icon="el-icon-download"
-            circle
-          ></el-button>
+          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
+            v-hasPermi="['system:donorcharge:edit']">淇敼</el-button>
+          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleDetail(scope.row)"
+            v-hasPermi="['system:donorcharge:edit']">璇︽儏</el-button>
+          <el-button size="mini" type="text" @click="handleDelete(scope.row)"
+            v-hasPermi="['system:donorcharge:remove']"><span class="button-delete"><i
+                class="el-icon-delete"></i>鍒犻櫎</span></el-button>
+          <el-button size="mini" type="primary" @click="download(scope.row.id)" icon="el-icon-download"
+            circle></el-button>
         </template>
       </el-table-column>
     </el-table>
 
-    <pagination
-      v-show="total > 0"
-      :total="total"
-      :page.sync="queryParams.pageNum"
-      :limit.sync="queryParams.pageSize"
-      @pagination="getList"
-    />
+    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
+      @pagination="getList" />
 
-    <el-dialog
-      :visible.sync="showSelectionDialog"
-      :close-on-click-modal="false"
-      :title="'璇烽�夋嫨鎹愮尞妗堜緥'"
-      width="500px"
-      style="text-align: center"
-      v-loading="loading"
-    >
-      <el-form ref="selectionForm" :model="selectionForm">
+    <el-dialog :visible.sync="showSelectionDialog" :close-on-click-modal="false" :title="'璇烽�夋嫨鏀舵鍗曠殑鍖荤枟鏈烘瀯'" width="500px"
+      style="text-align: center" v-loading="loading">
+      <el-form ref="selectionForm" :model="selectionForm" label-width="100px">
         <el-row>
-          <el-form-item
-            align="left"
-            label="鍖荤枟鏈烘瀯"
-            prop="treatmenthospitalno"
-          >
-            <org-selecter
-              ref="addOrgSelect"
-              :org-type="'4'"
-              v-model="selectionForm.donorid"
-            />
+          <el-form-item align="left" label="鍖荤枟鏈烘瀯锛�" prop="treatmenthospitalno">
+            <org-selecter ref="addOrgSelect" :org-type="'4'" v-model="selectionForm.itemid" />
           </el-form-item>
         </el-row>
       </el-form>
@@ -227,10 +106,11 @@
 import { listOrganization } from "@/api/project/organization";
 
 import OrgSelecter from "@/views/project/components/orgselect";
+import { getToken } from "@/utils/auth";
 
 export default {
   name: "Donorcharge",
-  dicts: ["sys_gathering"],
+  dicts: ["Collection_status"],
   components: {
     OrgSelecter
   },
@@ -262,8 +142,8 @@
       donorinfolist: [],
       selectionForm: {
         index: null,
-        donorid: null,
-        donorname: null
+        itemid: null,
+        itemname: null
       },
       loadingdonorlist: false,
 
@@ -291,6 +171,9 @@
         pageSize: 10,
         donorchargeid: null
       },
+      headers: {
+        Authorization: "Bearer " + getToken()
+      },
       // 琛ㄥ崟鍙傛暟
       form: {},
       // 琛ㄥ崟鏍¢獙
@@ -305,15 +188,15 @@
     //涓撳/鍖荤枟鏈烘瀯/璐圭敤鎶ラ攢鏈烘瀯閫夋嫨
     confirmSelection() {
       var curdonorinfo = null;
-      console.log(this.selectionForm.donorid, "donorid");
+      console.log(this.selectionForm.itemid, "itemid");
       //浠庢渚嬪垪琛ㄨ幏鍙栦俊鎭�
       this.donorinfolist.map(item => {
-        if (this.selectionForm.donorid == item.id) {
+        if (this.selectionForm.itemid == item.id) {
           curdonorinfo = item;
         }
       });
       let searchData = {
-        organizationid: this.selectionForm.donorid //浼犲叆鐨勭被鍨�
+        organizationid: this.selectionForm.itemid //浼犲叆鐨勭被鍨�
       }; //鎼滅储鏉′欢
       listOrganization(searchData).then(res => {
         if (res.code == 200) {
@@ -382,8 +265,8 @@
     /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd() {
       this.selectionForm.index = null;
-      this.selectionForm.donorid = null;
-      this.selectionForm.donorname = null;
+      this.selectionForm.itemid = null;
+      this.selectionForm.itemname = null;
 
       if (this.donorlist[0]) {
         this.showSelectionDialog = true;
@@ -402,8 +285,8 @@
 
             this.donorinfolist.forEach(item1 => {
               this.donorlist.push({
-                donorid: item1.id,
-                donorname: item1.name
+                itemid: item1.id,
+                itemname: item1.name
               });
             });
             console.log(this.donorinfolist, " this.donorinfolist");
@@ -431,8 +314,39 @@
       });
     },
     // 鎵撳嵃
-    download(row) {
-      dyDonorpayment(row.id).then(res => {});
+    download(id) {
+      // const id =this.row.id
+      dyDonorpayment(id).then(res => {
+        var fileUrl = res;
+        //鑾峰彇褰撳墠缃戝潃
+        var urlBase = process.env.VUE_APP_BASE_API;
+        var curWWWPath = window.document.location.href;
+        var pos = curWWWPath.indexOf(window.document.location.pathname);
+        // 鍒涘缓a鏍囩
+        var aEle = document.createElement("a");
+        aEle.href =
+          curWWWPath.substring(0, pos) + urlBase + fileUrl["downloadUrl"];
+        console.log(aEle.href);
+        // 娣诲姞Authorization澶撮儴
+        fetch(aEle.href, {
+          headers: this.headers
+        })
+          .then(response => {
+            // 灏嗘枃浠朵笅杞介摼鎺ヤ綔涓篵lob瀵硅薄杩涜涓嬭浇
+            return response.blob();
+          })
+          .then(blob => {
+            const url = window.URL.createObjectURL(new Blob([blob]));
+            console.log(url);
+            const link = document.createElement("a");
+            link.href = url;
+            const name = fileUrl["downloadName"];
+            link.setAttribute("download", name); // 鏇挎崲file.pdf涓哄疄闄呯殑鏂囦欢鍚�
+            document.body.appendChild(link);
+            link.click();
+            link.parentNode.removeChild(link);
+          });
+      });
     },
 
     /** 鍒犻櫎鎸夐挳鎿嶄綔 */
@@ -440,14 +354,14 @@
       const ids = row.id || this.ids;
       this.$modal
         .confirm('鏄惁纭鍒犻櫎鎹愮尞妗堜緥鍣ㄥ畼鍒楃紪鍙蜂负"' + ids + '"鐨勬暟鎹」锛�')
-        .then(function() {
+        .then(function () {
           return delDonorpayment(ids);
         })
         .then(() => {
           this.getList();
           this.$modal.msgSuccess("鍒犻櫎鎴愬姛");
         })
-        .catch(() => {});
+        .catch(() => { });
     },
 
     /** 瀵煎嚭鎸夐挳鎿嶄綔 */
@@ -463,7 +377,7 @@
           this.$download.name(response.msg);
           this.exportLoading = false;
         })
-        .catch(() => {});
+        .catch(() => { });
     }
   }
 };

--
Gitblit v1.9.3