| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <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" templateKey="研发项目管理-预算编制-直接投入费用" :uploadAfter="uploadAfter"/>
- </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],
- projectData: Object,
- },
- components: {
- UploadExcelDialog,
- projectSelect,
- },
- data() {
- return {
- params: {
- xmId: ''
- },
- selProject: {},
- };
- },
- watch: {
- projectId(newVal, oldVal) {
- this.params.xmId = newVal;
- if (oldVal) {
- this.selProject = this.projectData;
- }
- },
- "params.xmId"() {
- this.page.currentPage = 1;
- this.getList(this.page);
- },
- },
- computed: {
- pageTitle() {
- return `${this.selProject.xmmc}直接投入费用`;
- }
- },
- 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;
- this.$emit("change", 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.pageTitle}.xlsx`);
- });
- },
- /**
- * 打印表格
- * @param isLandscape 是否横向打印
- */
- printTable(isLandscape) {
- this.$emit("printClick", {
- column: this.printOption.column,
- data: this.data,
- pageTitle: this.pageTitle,
- zoom: 90
- });
- },
- },
- }, {
- // 模块路径
- 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 ? '' : (new Decimal(item.danJia).div(new Decimal(10000))).toFixed(4);
- item.ysje = item.ysje === -1 ? '' : (new Decimal(item.ysje).div(new Decimal(10000))).toFixed(4);
- item.zlfyys = item.zlfyys === -1 ? '' : (new Decimal(item.zlfyys).div(new Decimal(10000))).toFixed(4);
- if (item.yongLiang && item.danJia) {
- item.wzysje = new Decimal(item.yongLiang).mul(item.danJia).toFixed(4);
- }
- return item;
- });
- return data;
- },
- });
- </script>
|