| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <template>
- <div>
- <div style="margin-top: 6px;">
- <el-form :inline="true">
- <el-form-item label="研发项目名称">
- <project-select v-model="params.xmId" @change="handleProjectChange"></project-select>
- </el-form-item>
- <el-form-item label="研发项目编号">
- {{ selProject.xmbh }}
- </el-form-item>
- </el-form>
- </div>
- <avue-crud
- v-bind="bindVal"
- v-on="onEvent"
- v-model="form"
- :page.sync="page"
- :before-open="handleBeforeOpen"
- >
- <template slot="menuLeft">
- <el-button
- v-if="!isSelAnnual"
- type="danger"
- size="small"
- icon="el-icon-delete"
- plain
- @click="handleDelete"
- >
- 删 除
- </el-button>
- <el-button
- v-if="!isSelAnnual"
- type="success"
- size="small"
- plain
- icon="el-icon-upload2"
- @click="handleImport"
- >
- 导入
- </el-button>
- <el-button
- type="warning"
- size="small"
- plain
- icon="el-icon-download"
- @click="handleExport"
- >
- 导出
- </el-button>
- <print-table-btn @click="printTable" />
- </template>
-
- </avue-crud>
- <upload-excel-dialog ref="uploadExcelDialog" :uploadAfter="uploadAfter"/>
- <WideTablePrinter
- ref="printWideTable"
- :columns="wideTableColumns"
- :data="data"
- :print-title="printTitle"
- :rows-per-page="30"
- :default-landscape="true"
- />
- </div>
- </template>
- <script>
- import {exportBloByPost} from "@/api/common";
- import UploadExcelDialog from "@/components/upload-excel-dialog";
- import projectSelect from "@/components/project-select";
- import {getToken} from "@/util/auth";
- import {downloadXls} from "@/util/util";
- import Decimal from "decimal.js";
- export default window.$crudCommon({
- props: {
- projectId: [String, Number]
- },
- components: {
- UploadExcelDialog,
- projectSelect,
- },
- data() {
- return {
- params: {
- xmId: ''
- },
- selProject: {},
- wideTableColumns: [],
- printTitle: "",
- };
- },
- watch: {
- "params.xmId"() {
- this.page.currentPage = 1;
- this.getList(this.page);
- },
- },
- created() {
- this.params.xmId = this.projectId;
- this.option.height = window.innerHeight - 340;
- },
- methods: {
- handleBeforeOpen(done, type) {
- if (!this.params.xmId) {
- this.$message.warning("请选择项目!");
- return;
- }
- done();
- },
- getList() {
- if (!this.params.xmId) {
- return;
- }
- this.loadData();
- },
- getFormData() {
- return { ...this.form, xmId: this.params.xmId }
- },
- handleProjectChange(data) {
- this.selProject = data;
- },
- handleImport() {
- if (!this.params.xmId) {
- this.$message.warning("请选择项目!");
- return;
- }
- let excelParams = { xmId: this.params.xmId };
- this.$refs.uploadExcelDialog.open('/api/kd-scientific/ys-zjtrfy/import', excelParams);
- },
- uploadAfter() {
- this.page.currentPage = 1;
- this.getList(this.page);
- },
- handleExport() {
- exportBloByPost(`/api/kd-scientific/ys-zjtrfy/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
- downloadXls(res.data, `${this.selProject.xmmc}直接投入费用.xlsx`);
- });
- },
- /**
- * 打印表格
- * @param isLandscape 是否横向打印
- */
- printTable(isLandscape) {
- this.wideTableColumns = this.$refs.crud.columnOption;
- this.printTitle = `${this.selProject.xmmc}直接投入费用`;
- this.$nextTick(() => {
- this.$refs.printWideTable.printTable(isLandscape);
- })
- },
- },
- }, {
- // 模块路径
- name: 'projectManage/zztlCost',
- res: ({ data }) => {
- data.records = data.records.map(item => {
- item.yongLiang = item.yongLiang === -1 ? '' : (item.yongLiang).toFixed(2);
- item.danJia = item.danJia === -1 ? '' : (item.danJia).toFixed(2);
- item.ysje = item.ysje === -1 ? '' : (item.ysje).toFixed(2);
- item.zlfyys = item.zlfyys === -1 ? '' : (item.zlfyys).toFixed(2);
- if (item.yongLiang && item.danJia) {
- item.wzysje = new Decimal(item.yongLiang).mul(item.danJia);
- }
- return item;
- });
- return data;
- },
- });
- </script>
|