| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- <template>
- <basic-container>
- <avue-crud
- v-bind="bindVal"
- v-on="onEvent"
- v-model="form"
- :page.sync="page"
- :span-method="spanMethod"
- >
- <template slot="menuLeft">
- <el-button
- type="warning"
- size="small"
- plain
- icon="el-icon-download"
- @click="handleExport"
- >
- 导出
- </el-button>
- <div>
- <year-month-select v-model="params.yearAndMonth"></year-month-select>
- </div>
- </template>
-
- </avue-crud>
- </basic-container>
- </template>
- <script>
- import {exportBloByPost} from "@/api/common";
- import YearMonthSelect from "@/components/year-month-select";
- import moment from "moment";
- import NProgress from 'nprogress';
- import 'nprogress/nprogress.css';
- import {getToken} from "@/util/auth";
- import {downloadXls} from "@/util/util";
- export default window.$crudCommon({
- components: {
- YearMonthSelect,
- },
- data() {
- return {
- params: {
- yearAndMonth: moment(new Date()).format('YYYYMM'),
- spanArr: [
- { prop: 'projectName', span: [] },
- ]
- },
- };
- },
- watch: {
- 'params.yearAndMonth'(newVal) {
- this.page.currentPage = 1;
- this.getList(this.page);
- }
- },
- methods: {
- getList() {
- this.data = [{
- projectName: '项目1'
- }, {
- projectName: '项目1'
- }, {
- projectName: '项目1'
- }, {
- projectName: '项目2'
- }, {
- projectName: '项目3'
- }];
- },
- spanMethod({ row, column, rowIndex, columnIndex }) {
- let fields = ["projectName"];
- let cellValue = row[column.property];
- if (cellValue && fields.includes(column.property)) {
- let prevRow = this.data[rowIndex - 1];
- let nextRow = this.data[rowIndex + 1];
- if (prevRow && prevRow[column.property] === cellValue) {
- return { rowspan: 0, colspan: 0 };
- } else {
- let countRowspan = 1;
- while (nextRow && nextRow[column.property] === cellValue) {
- nextRow = this.data[++countRowspan + rowIndex];
- }
- if (countRowspan > 1) {
- row.hbFlag = true;
- return { rowspan: countRowspan, colspan: 1 };
- }
- }
- }
- },
- handleExport() {
- this.$confirm("是否导出吗?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- NProgress.start();
- exportBloByPost(`/api/kd-scientific/technician/export?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
- downloadXls(res.data, `项目参研人员汇总表${this.params.yearAndMonth}.xlsx`);
- NProgress.done();
- })
- });
- },
- },
- }, {
- // 模块路径
- name: 'cyPersonSumList'
- });
- </script>
|