| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <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
- ref="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>
- <template slot="assetId" slot-scope="scope">
- <span>{{ scope.row.zcmc }}</span>
- </template>
-
- </avue-crud>
- <upload-excel-dialog ref="uploadExcelDialog" templateKey="预算-折旧费用与长期待摊费用" templateName="预算-折旧费用与长期待摊费用-导入模板" :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 moment from "moment";
- import Decimal from "decimal.js";
- export default window.$crudCommon({
- props: {
- projectId: [String, Number]
- },
- components: {
- UploadExcelDialog,
- projectSelect,
- },
- data() {
- return {
- params: {
- xmId: ''
- },
- selProject: {},
- currZcObj: {},
- };
- },
- watch: {
- "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;
- let newOption = { ...this.option };
- // 姓名下拉框,设置监听事件
- newOption.column.forEach(item => {
- if (item.prop == "assetId") {
- item.change = ({ item }) => {
- if (!!item) {
- this.currZcObj = item;
- }
- }
- }
- });
- this.option = { ...newOption };
- },
- methods: {
- validCustom() {
- const { sysm, ysysm } = this.currZcObj;
- const { xmkssj, xmjssj } = this.selProject
- let sm = sysm - ysysm;
- if (this.form.zzsc > sm) {
- this.$message.warning(`设备剩余寿命为${sm}月,在项目的工作时长不能大于设备寿命!`);
- return false;
- }
- if (xmkssj && xmjssj) {
- let monthDiff = moment(xmjssj).diff(moment(xmkssj), 'months', true).toFixed(0);
- if (this.form.zzsc > monthDiff) {
- this.$message.warning(`项目周期为${monthDiff}月,在项目的工作时长不能大于项目周期!`);
- return false;
- }
- }
- return true;
- },
- addBefore(loading, callback) {
- if (!this.validCustom()) {
- loading();
- return;
- }
- callback && callback();
- },
- updateBefore(loading, callback) {
- if (!this.validCustom()) {
- loading();
- return false;
- }
- callback && callback();
- },
- handleBeforeOpen(done) {
- if (!this.params.xmId) {
- this.$message.warning("请选择项目!");
- return;
- }
- this.currZcObj = {};
- // this.option.column.forEach(item => {
- // let yearAndMonth = this.selProject.xmkssj || new Date();
- // if (item.prop == "zcbm") {
- // item.dicUrl = '/api/kd-scientific/asset/simple/list';
- // item.dicQuery.yearAndMonth = moment(yearAndMonth).format("yyyyMM");
- // }
- // });
- 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-zjfyycqdtfy/import', excelParams);
- },
- uploadAfter() {
- this.page.currentPage = 1;
- this.getList(this.page);
- },
- handleExport() {
- exportBloByPost(`/api/kd-scientific/ys-zjfyycqdtfy/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: 95
- });
- },
- },
- }, {
- // 模块路径
- name: 'projectManage/zjfyycqdtfyCost',
- res: ({ data }) => {
- data.records = data.records.map(item => {
- // item.zcmc = item.zcmc;
- // item.zcbm = item.zcbm;
- item.yzje = Number((item.yzje || 0)).toFixed(2);
- item.cqdtfyysje = Number((item.cqdtfyysje || 0)).toFixed(2);
- let zzscD = new Decimal(item.zzsc || 0); // 工作时长
- let yzjeD = new Decimal(item.yzje || 0);
- item.yshj = zzscD.mul(yzjeD).toFixed(2);
- return item;
- });
- return data;
- },
- });
- </script>
|