|
|
@@ -0,0 +1,359 @@
|
|
|
+<template>
|
|
|
+ <basic-container>
|
|
|
+ <avue-crud
|
|
|
+ :option="technicianRosterOption"
|
|
|
+ :table-loading="loading"
|
|
|
+ :data="dataList"
|
|
|
+ :page="page"
|
|
|
+ ref="crud"
|
|
|
+ v-model="form"
|
|
|
+ :permission="permissionList"
|
|
|
+ :before-open="handleBeforeOpen"
|
|
|
+ @row-del="rowDel"
|
|
|
+ @row-update="rowUpdate"
|
|
|
+ @row-save="rowSave"
|
|
|
+ @search-change="searchChange"
|
|
|
+ @search-reset="searchReset"
|
|
|
+ @selection-change="selectionChange"
|
|
|
+ @current-change="currentChange"
|
|
|
+ @size-change="sizeChange"
|
|
|
+ @refresh-change="refreshChange"
|
|
|
+ @on-load="onLoad"
|
|
|
+ >
|
|
|
+ <template slot="menuLeft">
|
|
|
+ <el-button
|
|
|
+ type="danger"
|
|
|
+ size="small"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ plain
|
|
|
+ @click="handleDelete"
|
|
|
+ >
|
|
|
+ 删 除
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ 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>
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ size="small"
|
|
|
+ plain
|
|
|
+ @click="handleReadyLastMonData"
|
|
|
+ >
|
|
|
+ 读取上个月人员名单
|
|
|
+ </el-button>
|
|
|
+ <div>
|
|
|
+ <year-month-select v-model="yearAndMonth"></year-month-select>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ </avue-crud>
|
|
|
+
|
|
|
+ <el-dialog title="行政区划数据导入"
|
|
|
+ append-to-body
|
|
|
+ :visible.sync="excelBox"
|
|
|
+ width="555px">
|
|
|
+ <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter">
|
|
|
+ <template slot="excelTemplate">
|
|
|
+ <el-button type="primary" @click="handleTemplate">
|
|
|
+ 点击下载<i class="el-icon-download el-icon--right"></i>
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </avue-form>
|
|
|
+ </el-dialog>
|
|
|
+ </basic-container>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getList, add, update, remove } from "@/api/technicianRoster";
|
|
|
+import {exportBlob} from "@/api/common";
|
|
|
+import technicianRosterOption from "@/option/user/technicianRoster";
|
|
|
+import { mapGetters } from "vuex";
|
|
|
+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";
|
|
|
+import {dateNow} from "@/util/date";
|
|
|
+
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ YearMonthSelect,
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ form: {},
|
|
|
+ selectionList: [],
|
|
|
+ query: {},
|
|
|
+ yearAndMonth: moment(new Date()).format('YYYY-MM'),
|
|
|
+ loading: true,
|
|
|
+ page: {
|
|
|
+ pageSize: 10,
|
|
|
+ pageSizes: [10, 30, 50, 100, 200],
|
|
|
+ currentPage: 1,
|
|
|
+ total: 0,
|
|
|
+ },
|
|
|
+ dataList: [],
|
|
|
+ technicianRosterOption,
|
|
|
+
|
|
|
+ excelBox: false,
|
|
|
+ excelForm: {},
|
|
|
+
|
|
|
+ isSelAnnual: false,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ yearAndMonth(newVal) {
|
|
|
+ if (newVal && newVal.split('-')[1] == '00') {
|
|
|
+ // 是否勾选未全年
|
|
|
+ this.isSelAnnual = true;
|
|
|
+ } else {
|
|
|
+ this.isSelAnnual = false;
|
|
|
+ }
|
|
|
+ this.page.currentPage = 1;
|
|
|
+ this.onLoad(this.page);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ // permissionList() {
|
|
|
+ // return {
|
|
|
+ // addBtn: this.vaildData(this.permission.dictbiz_add, false),
|
|
|
+ // delBtn: this.vaildData(this.permission.dictbiz_delete, false),
|
|
|
+ // editBtn: this.vaildData(this.permission.dictbiz_edit, false),
|
|
|
+ // viewBtn: false,
|
|
|
+ // };
|
|
|
+ // },
|
|
|
+ ids() {
|
|
|
+ let ids = [];
|
|
|
+ this.selectionList.forEach((ele) => {
|
|
|
+ ids.push(ele.id);
|
|
|
+ });
|
|
|
+ return ids.join(",");
|
|
|
+ },
|
|
|
+ excelOption() {
|
|
|
+ return {
|
|
|
+ submitBtn: false,
|
|
|
+ emptyBtn: false,
|
|
|
+ column: [
|
|
|
+ {
|
|
|
+ label: '上传月份',
|
|
|
+ props: 'yearAndMonth',
|
|
|
+ type: 'input',
|
|
|
+ span: 24,
|
|
|
+ value: this.yearAndMonth,
|
|
|
+ disabled: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '模板上传',
|
|
|
+ prop: 'excelFile',
|
|
|
+ type: 'upload',
|
|
|
+ drag: true,
|
|
|
+ loadText: '模板上传中,请稍等',
|
|
|
+ span: 24,
|
|
|
+ propsHttp: {
|
|
|
+ res: 'data'
|
|
|
+ },
|
|
|
+ data: {
|
|
|
+ yearAndMonth: this.yearAndMonth,
|
|
|
+ },
|
|
|
+ tip: '请上传 .xls,.xlsx 标准格式文件',
|
|
|
+ action: '/api/kd-scientific/technician/import?yearAndMonth='+this.yearAndMonth
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '模板下载',
|
|
|
+ prop: 'excelTemplate',
|
|
|
+ formslot: true,
|
|
|
+ span: 24,
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleBeforeOpen(done, type) {
|
|
|
+ if (type == 'add' && this.isSelAnnual) {
|
|
|
+ this.$message.warning('请选择月份');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ rowSave(row, done, loading) {
|
|
|
+ const form = {
|
|
|
+ ...row,
|
|
|
+ };
|
|
|
+ add(form).then(
|
|
|
+ () => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!",
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ loading();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ rowUpdate(row, index, done, loading) {
|
|
|
+ update(row).then(
|
|
|
+ () => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!",
|
|
|
+ });
|
|
|
+ this.onLoad(this.page);
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ (error) => {
|
|
|
+ loading();
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ rowDel(row) {
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return remove(row.id);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!",
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ searchReset() {
|
|
|
+ this.query = {};
|
|
|
+ this.onLoad(this.page);
|
|
|
+ },
|
|
|
+ searchChange(params, done) {
|
|
|
+ this.query = params;
|
|
|
+ this.page.currentPage = 1;
|
|
|
+ this.onLoad(this.page, params);
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ selectionChange(list) {
|
|
|
+ this.selectionList = list;
|
|
|
+ },
|
|
|
+ selectionClear() {
|
|
|
+ this.selectionList = [];
|
|
|
+ this.$refs.crud.toggleSelection();
|
|
|
+ },
|
|
|
+ handleDelete() {
|
|
|
+ if (this.selectionList.length === 0) {
|
|
|
+ this.$message.warning("请选择至少一条数据");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return remove(this.ids);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!",
|
|
|
+ });
|
|
|
+ this.$refs.crud.toggleSelection();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ currentChange(currentPage) {
|
|
|
+ this.page.currentPage = currentPage;
|
|
|
+ },
|
|
|
+ sizeChange(pageSize) {
|
|
|
+ this.page.pageSize = pageSize;
|
|
|
+ },
|
|
|
+ refreshChange() {
|
|
|
+ this.onLoad(this.page, this.query);
|
|
|
+ },
|
|
|
+ onLoad(page, params = {}) {
|
|
|
+ this.loading = true;
|
|
|
+ let queryParams = Object.assign(params, this.query, { yearAndMonth: this.yearAndMonth });
|
|
|
+ if (queryParams.yearAndMonth && queryParams.yearAndMonth.split('-')[1] == '00') {
|
|
|
+ queryParams.yearAndMonth = queryParams.yearAndMonth.split('-')[0];
|
|
|
+ }
|
|
|
+ getList(
|
|
|
+ page.currentPage,
|
|
|
+ page.pageSize,
|
|
|
+ queryParams
|
|
|
+ ).then((res) => {
|
|
|
+ if (!res.data) {
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const data = res.data.data;
|
|
|
+ this.page.total = data.total;
|
|
|
+ this.dataList = data.records.map(item => {
|
|
|
+ if (item.gender) {
|
|
|
+ item.gender = String(item.gender);
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ this.loading = false;
|
|
|
+ this.selectionClear();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleImport() {
|
|
|
+ if (this.isSelAnnual) {
|
|
|
+ this.$message.warning("请选择月份");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.excelBox = true;
|
|
|
+ },
|
|
|
+ uploadAfter(res, done, loading, column) {
|
|
|
+ this.excelBox = false;
|
|
|
+ this.page.currentPage = 1;
|
|
|
+ this.onLoad(this.page);
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ handleExport() {
|
|
|
+ this.$confirm("是否导出当前月份技术人员花名册?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ NProgress.start();
|
|
|
+ exportBlob(`/api/kd-scientific/technician/export?${this.website.tokenHeader}=${getToken()}`).then(res => {
|
|
|
+ downloadXls(res.data, `技术人员花名册${dateNow()}.xlsx`);
|
|
|
+ NProgress.done();
|
|
|
+ })
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleTemplate() {
|
|
|
+ this.$message.warning("暂未配置模板");
|
|
|
+ // exportBlob(`/api/kd-system/region/export-template?${this.website.tokenHeader}=${getToken()}`).then(res => {
|
|
|
+ // downloadXls(res.data, "技术人员花名册.xlsx");
|
|
|
+ // });
|
|
|
+ },
|
|
|
+ handleReadyLastMonData() {
|
|
|
+ this.$message.warning("功能建设中...");
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|