Browse Source

科研项目清单页面接口联调

ljb 9 months ago
parent
commit
a3c6bdbbd7

+ 16 - 0
src/api/externalReports/kyProjectList.js

@@ -8,6 +8,22 @@ export const getList = params => {
   })
   })
 }
 }
 
 
+export const getYearProjectList = params => {
+  return request({
+    url: '/api/kd-scientific/xm/list-year',
+    method: 'get',
+    params
+  })
+}
+
+export const add = data => {
+  return request({
+    url: '/api/kd-scientific/xm/finance/save',
+    method: 'post',
+    data
+  })
+}
+
 export const remove = (ids) => {
 export const remove = (ids) => {
   return request({
   return request({
     url: '/api/kd-scientific/xm/finance/remove',
     url: '/api/kd-scientific/xm/finance/remove',

+ 11 - 0
src/option/externalReports/kyProjectList.js

@@ -22,6 +22,7 @@ export default {
       span: 24,
       span: 24,
       minWidth: 160,
       minWidth: 160,
       align: 'center',
       align: 'center',
+      display: false,
       showOverflowTooltip: true,
       showOverflowTooltip: true,
     },
     },
     {
     {
@@ -31,6 +32,16 @@ export default {
       minWidth: 160,
       minWidth: 160,
       align: 'center',
       align: 'center',
       search: true,
       search: true,
+      display: false,
+      showOverflowTooltip: true,
+    },
+    {
+      label: '研发项目名称',
+      prop: 'xmIdList',
+      type: 'select',
+      span: 24,
+      align: 'center',
+      hide: true,
       showOverflowTooltip: true,
       showOverflowTooltip: true,
     },
     },
   ],
   ],

+ 87 - 56
src/views/external-reports/components/ky-project-list.vue

@@ -1,47 +1,65 @@
 <template>
 <template>
-  <avue-crud
-    v-bind="bindVal"
-    v-on="onEvent"
-    v-model="form"
-  >
-    <template slot="menuLeft">
-      <el-button type="primary" size="small" @click="handleReadMonthProject">引入</el-button>
-      <el-button
-        type="danger"
-        size="small"
-        icon="el-icon-delete"
-        plain
-        @click="handleDelete"
-      >
-        删 除
-      </el-button>
-      <el-button
-        type="warning"
-        size="small"
-        plain
-        icon="el-icon-download"
-        @click="handleExport"
-      >
-        导出
-      </el-button>
-      <print-table-btn @click="printTable" />
+  <div>
+
+    <avue-crud
+      ref="crud"
+      v-bind="bindVal"
+      v-on="onEvent"
+      v-model="form"
+      :before-open="beforeOpen"
+    >
+      <template slot="menuLeft">
+        <el-button type="primary" size="small" @click="handleReadMonthProject">引入</el-button>
+        <el-button
+          type="danger"
+          size="small"
+          icon="el-icon-delete"
+          plain
+          @click="handleDelete"
+        >
+          删 除
+        </el-button>
+        <el-button
+          type="warning"
+          size="small"
+          plain
+          icon="el-icon-download"
+          @click="handleExport"
+        >
+          导出
+        </el-button>
+        <print-table-btn @click="printTable" />
+        
+        <div style="display: flex; align-items: center;">
+          <year-month-select v-model="params.yearAndMonth" :showMonth="false"></year-month-select>
+        </div>
+      </template>
+
+      <template slot="xmIdListForm">
+        <avue-select multiple v-model="form.xmIdList" placeholder="请选择项目" :dic="allProjectList"></avue-select>
+      </template>
       
       
-      <div style="display: flex; align-items: center;">
-        <year-month-select v-model="params.yearAndMonth" :showMonth="false"></year-month-select>
-      </div>
-    </template>
-    
-  </avue-crud>
+    </avue-crud>
+
+    <WideTablePrinter
+      ref="printWideTable"
+      :columns="wideTableColumns"
+      :data="data"
+      :print-title="printTitle"
+      :rows-per-page="30"
+      :default-landscape="true"
+    />
+  </div>
+  
 </template>
 </template>
 
 
 <script>
 <script>
 import YearMonthSelect from "@/components/year-month-select";
 import YearMonthSelect from "@/components/year-month-select";
-import { readMonthProject } from "@/api/externalReports/kyProjectList";
+import { readMonthProject, getYearProjectList } from "@/api/externalReports/kyProjectList";
 import {exportBlob} from "@/api/common";
 import {exportBlob} from "@/api/common";
 import {getToken} from "@/util/auth";
 import {getToken} from "@/util/auth";
 import {downloadXls} from "@/util/util";
 import {downloadXls} from "@/util/util";
 import moment from "moment";
 import moment from "moment";
-import Decimal from "decimal.js";
 
 
 
 
 export default window.$crudCommon({
 export default window.$crudCommon({
@@ -60,29 +78,56 @@ export default window.$crudCommon({
 
 
       wideTableColumns: [],
       wideTableColumns: [],
       printTitle: "",
       printTitle: "",
+
+      typeEnum: {
+        1: '会计',
+        2: '加计扣除',
+        3: '高新'
+      },
+
+      allProjectList: []
     };
     };
   },
   },
+  computed: {
+    downloadTitle() {
+      return `${this.typeEnum[this.type]}研发项目清单`;
+    }
+  },
   watch: {
   watch: {
     'params.yearAndMonth'(newVal) {
     'params.yearAndMonth'(newVal) {
-      this.page.currentPage = 1;
-      this.getList(this.page);
+      this.getList();
     }
     }
   },
   },
   methods: {
   methods: {
+    beforeOpen(done, type) {
+      getYearProjectList({ year: this.params.yearAndMonth }).then(({ data }) => {
+        if (data.code == 200) {
+          this.allProjectList = data.data.map(item => {
+            return { label: item.xmmc, value: item.id, disabled: this.data.some(dataItem => dataItem.xmbh === item.xmbh) };
+          });
+        }
+      });
+      done();
+    },
+    getFormData() {
+      return { yearAndMonth: this.params.yearAndMonth, type: this.type, xmIdList: this.form.xmIdList }
+    },
     getSearchParams() {
     getSearchParams() {
       return { ...this.params, type: this.type };
       return { ...this.params, type: this.type };
     },
     },
     loadData() {
     loadData() {
       this.loading = true;
       this.loading = true;
-      this.api['getList'](this.getSearchParams()).then(res => {
-        console.log(res)
+      this.api['getList'](this.getSearchParams()).then(({ data }) => {
+        if (data.code == 200) {
+          this.data = data.data;
+        }
         this.loading = false;
         this.loading = false;
-        this.data = res.data;
+        
       })
       })
     },
     },
     handleExport() {
     handleExport() {
-      exportBlob(`/api/kd-scientific/asset/kyyqsbzjfyfpb?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
-        downloadXls(res.data, `${this.params.yearAndMonth}科研仪器设备折旧费用分配表.xlsx`);
+      exportBlob(`/api/kd-scientific/xm/finance/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
+        downloadXls(res.data, `${this.downloadTitle}.xlsx`);
       });
       });
     },
     },
     /**
     /**
@@ -91,7 +136,7 @@ export default window.$crudCommon({
      */
      */
     printTable(isLandscape) {
     printTable(isLandscape) {
       this.wideTableColumns = this.$refs.crud.columnOption;
       this.wideTableColumns = this.$refs.crud.columnOption;
-      this.printTitle = `${this.params.yearAndMonth}科研仪器设备折旧费用分配表`;
+      this.printTitle = `${this.downloadTitle}`;
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.$refs.printWideTable.printTable(isLandscape);
         this.$refs.printWideTable.printTable(isLandscape);
       })
       })
@@ -103,19 +148,5 @@ export default window.$crudCommon({
 }, {
 }, {
   // 模块路径
   // 模块路径
   name: 'externalReports/kyProjectList',
   name: 'externalReports/kyProjectList',
-  res: ({ data }) => {
-    data.records = data.records.map(item => {
-      item.zcbm = item.asset ? item.asset.zcbm : '';
-      item.zcmc = item.asset ? item.asset.zcmc : '';
-      item.zclb = item.asset ? item.asset.zclb : '';
-      item.yt = item.asset ? item.asset.yt : '';
-      item.zcyz = item.asset ? item.asset.zcyz : '';
-      item.jcz = item.asset ? item.asset.jcz : '';
-      item.yzje = item.asset ? item.asset.yzje : '';
-      item.yanfaTanXiao = Number(new Decimal(item.yzje || 0).mul(item.yanfaFenTanLv || 0)).toFixed(2);
-      return item;
-    });
-    return data;
-  },
 });
 });
 </script>
 </script>