| | |
| | | <template> |
| | | <basic-container> |
| | | <avue-crud :option="option" |
| | | v-model:search="search" |
| | | v-model:page="page" |
| | | v-model="form" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | ref="crud" |
| | | @row-update="rowUpdate" |
| | | @row-save="rowSave" |
| | | @row-del="rowDel" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad"> |
| | | <avue-crud |
| | | :option="option" |
| | | v-model:search="search" |
| | | v-model:page="page" |
| | | v-model="form" |
| | | :table-loading="loading" |
| | | :data="data" |
| | | :permission="permissionList" |
| | | :before-open="beforeOpen" |
| | | ref="crud" |
| | | @row-update="rowUpdate" |
| | | @row-save="rowSave" |
| | | @row-del="rowDel" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @selection-change="selectionChange" |
| | | @current-change="currentChange" |
| | | @size-change="sizeChange" |
| | | @refresh-change="refreshChange" |
| | | @on-load="onLoad" |
| | | > |
| | | <template #menu-left> |
| | | <el-button type="danger" |
| | | icon="el-icon-delete" |
| | | plain |
| | | v-if="permission.assessmentConfig_delete" |
| | | @click="handleDelete">删 除 |
| | | <el-button |
| | | type="danger" |
| | | icon="el-icon-delete" |
| | | plain |
| | | v-if="permission.assessmentConfig_delete" |
| | | @click="handleDelete" |
| | | >删 除 |
| | | </el-button> |
| | | <el-button type="warning" |
| | | plain |
| | | icon="el-icon-download" |
| | | @click="handleExport">导 出 |
| | | <el-button type="success" plain icon="el-icon-download" @click="handleImport"> |
| | | 权重导入 |
| | | </el-button> |
| | | </template> |
| | | </avue-crud> |
| | | <el-dialog title="权重数据导入" append-to-body v-model="excelBox" width="555px"> |
| | | <avue-form :option="excelOption" v-model="excelForm" :upload-after="uploadAfter"> |
| | | <template #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, getDetail, add, update, remove} from "@/api/assessment/assessmentConfig"; |
| | | import option from "@/option/assessment/assessmentConfig"; |
| | | import {mapGetters} from "vuex"; |
| | | import {exportBlob} from "@/api/common"; |
| | | import {getToken} from '@/utils/auth'; |
| | | import {downloadXls} from "@/utils/util"; |
| | | import {dateNow} from "@/utils/date"; |
| | | import NProgress from 'nprogress'; |
| | | import 'nprogress/nprogress.css'; |
| | | import axios from 'axios'; |
| | | import _ from 'lodash' |
| | | import { getList, getDetail, add, update, remove } from '@/api/assessment/assessmentConfig'; |
| | | import option from '@/option/assessment/assessmentConfig'; |
| | | import { mapGetters } from 'vuex'; |
| | | import { exportBlob } from '@/api/common'; |
| | | import { getToken } from '@/utils/auth'; |
| | | import { downloadXls } from '@/utils/util'; |
| | | import { dateNow } from '@/utils/date'; |
| | | import NProgress from 'nprogress'; |
| | | import 'nprogress/nprogress.css'; |
| | | import website from '@/config/website'; |
| | | import { getDeptTree, getDeptLazyTree } from '@/api/system/dept'; |
| | | import { getList as getUserList } from '@/api/system/user.js'; |
| | | import { copy } from '@/api/tool/code'; |
| | | |
| | | export default { |
| | | data() { |
| | | export default { |
| | | data() { |
| | | return { |
| | | form: {}, |
| | | query: {}, |
| | | search: {}, |
| | | loading: true, |
| | | excelBox: false, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0, |
| | | }, |
| | | selectionList: [], |
| | | option: option, |
| | | data: [], |
| | | excelForm: {}, |
| | | excelOption: { |
| | | submitBtn: false, |
| | | emptyBtn: false, |
| | | column: [ |
| | | { |
| | | label: '模板上传', |
| | | prop: 'excelFile', |
| | | type: 'upload', |
| | | drag: true, |
| | | loadText: '模板上传中,请稍等', |
| | | span: 24, |
| | | propsHttp: { |
| | | res: 'data', |
| | | }, |
| | | tip: '请上传 .xls,.xlsx 标准格式文件', |
| | | action: '/assessment/assessmentConfig/import-assessmentConfig', |
| | | }, |
| | | { |
| | | label: '数据覆盖', |
| | | prop: 'isCovered', |
| | | type: 'switch', |
| | | align: 'center', |
| | | width: 80, |
| | | dicData: [ |
| | | { |
| | | label: '否', |
| | | value: 0, |
| | | }, |
| | | { |
| | | label: '是', |
| | | value: 1, |
| | | }, |
| | | ], |
| | | value: 0, |
| | | slot: true, |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择是否覆盖', |
| | | trigger: 'blur', |
| | | }, |
| | | ], |
| | | }, |
| | | { |
| | | label: '模板下载', |
| | | prop: 'excelTemplate', |
| | | formslot: true, |
| | | span: 24, |
| | | }, |
| | | ], |
| | | }, |
| | | userList: [], |
| | | }; |
| | | }, |
| | | watch: { |
| | | 'excelForm.isCovered'() { |
| | | if (this.excelForm.isCovered !== '') { |
| | | const column = this.findObject(this.excelOption.column, 'excelFile'); |
| | | column.action = `/assessment/assessmentConfig/import-assessmentConfig?isCovered=${this.excelForm.isCovered}`; |
| | | } |
| | | }, |
| | | 'form.userName': { |
| | | handler(newVal) { |
| | | if (!newVal || newVal === void 0 || newVal === '' || newVal.length === 0) return; |
| | | const data = this.userList.find(ele => ele.id === newVal); |
| | | this.form.deptName = data.deptName; |
| | | this.form.postName = data.postName; |
| | | }, |
| | | deep: true, |
| | | }, |
| | | 'form.assessorUserName': { |
| | | handler(newVal) { |
| | | if (!newVal || newVal === void 0 || newVal === '' || newVal.length === 0) return; |
| | | const data = this.userList.find(ele => ele.id === newVal); |
| | | this.form.assessorDeptName = data.deptName; |
| | | this.form.assessorPostName = data.postName; |
| | | }, |
| | | deep: true, |
| | | }, |
| | | }, |
| | | computed: { |
| | | ...mapGetters(['permission']), |
| | | permissionList() { |
| | | return { |
| | | form: {}, |
| | | query: {}, |
| | | search: {}, |
| | | loading: true, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0 |
| | | }, |
| | | selectionList: [], |
| | | option: option, |
| | | data: [] |
| | | addBtn: this.validData(this.permission.assessmentConfig_add, false), |
| | | viewBtn: this.validData(this.permission.assessmentConfig_view, false), |
| | | delBtn: this.validData(this.permission.assessmentConfig_delete, false), |
| | | editBtn: this.validData(this.permission.assessmentConfig_edit, false), |
| | | }; |
| | | }, |
| | | computed: { |
| | | ...mapGetters(["permission"]), |
| | | permissionList() { |
| | | return { |
| | | addBtn: this.validData(this.permission.assessmentConfig_add, false), |
| | | viewBtn: this.validData(this.permission.assessmentConfig_view, false), |
| | | delBtn: this.validData(this.permission.assessmentConfig_delete, false), |
| | | editBtn: this.validData(this.permission.assessmentConfig_edit, false) |
| | | }; |
| | | }, |
| | | ids() { |
| | | let ids = []; |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(","); |
| | | } |
| | | ids() { |
| | | let ids = []; |
| | | this.selectionList.forEach(ele => { |
| | | ids.push(ele.id); |
| | | }); |
| | | return ids.join(','); |
| | | }, |
| | | methods: { |
| | | rowSave(row, done, loading) { |
| | | add(row).then(() => { |
| | | }, |
| | | methods: { |
| | | rowSave(row, done, loading) { |
| | | const { userName, assessorUserName} = row |
| | | const usernameData = this.userList.find(ele => ele.id === userName); |
| | | const assessorUserNameData = this.userList.find(ele => ele.id === assessorUserName); |
| | | const copyRow = _.cloneDeep(row) |
| | | copyRow.userId = usernameData.id; |
| | | copyRow.userName = usernameData.name; |
| | | copyRow.deptId = usernameData.deptId; |
| | | copyRow.assessorUserId = assessorUserNameData.id; |
| | | copyRow.assessorDeptId = usernameData.deptId; |
| | | copyRow.assessorUserName = assessorUserNameData.name; |
| | | add(copyRow).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | }, |
| | | error => { |
| | | loading(); |
| | | window.console.log(error); |
| | | }); |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | update(row).then(() => { |
| | | } |
| | | ); |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | const { userName, assessorUserName} = row |
| | | const usernameData = this.userList.find(ele => ele.id === userName); |
| | | const assessorUserNameData = this.userList.find(ele => ele.id === assessorUserName); |
| | | const copyRow = _.cloneDeep(row) |
| | | copyRow.userId = usernameData.id; |
| | | copyRow.userName = usernameData.name; |
| | | copyRow.deptId = usernameData.deptId; |
| | | copyRow.assessorUserId = assessorUserNameData.id; |
| | | copyRow.assessorDeptId = usernameData.deptId; |
| | | copyRow.assessorUserName = assessorUserNameData.name; |
| | | update(copyRow).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | done(); |
| | | }, error => { |
| | | }, |
| | | error => { |
| | | loading(); |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | }); |
| | | }, |
| | | handleDelete() { |
| | | if (this.selectionList.length === 0) { |
| | | this.$message.warning("请选择至少一条数据"); |
| | | return; |
| | | } |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | ); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm('确定将选择数据删除?', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | }) |
| | | .then(() => { |
| | | return remove(this.ids); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!" |
| | | }); |
| | | this.$refs.crud.toggleSelection(); |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: 'success', |
| | | message: '操作成功!', |
| | | }); |
| | | }, |
| | | handleExport() { |
| | | let downloadUrl = `/blade-assessmentConfig/assessmentConfig/export-assessmentConfig?${this.website.tokenHeader}=${getToken()}`; |
| | | const { |
| | | } = this.query; |
| | | let values = { |
| | | }; |
| | | this.$confirm("是否导出数据?", "提示", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning" |
| | | }).then(() => { |
| | | NProgress.start(); |
| | | exportBlob(downloadUrl, values).then(res => { |
| | | downloadXls(res.data, `考核权重配置表${dateNow()}.xlsx`); |
| | | NProgress.done(); |
| | | }) |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (["edit", "view"].includes(type)) { |
| | | getDetail(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }, |
| | | 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: '操作成功!', |
| | | }); |
| | | } |
| | | done(); |
| | | }, |
| | | 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(); |
| | | }, |
| | | 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; |
| | | |
| | | const { |
| | | } = this.query; |
| | | |
| | | let values = { |
| | | }; |
| | | |
| | | getList(page.currentPage, page.pageSize, values).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | handleExport() { |
| | | let downloadUrl = `/blade-assessmentConfig/assessmentConfig/export-assessmentConfig?${ |
| | | this.website.tokenHeader |
| | | }=${getToken()}`; |
| | | const {} = this.query; |
| | | let values = {}; |
| | | this.$confirm('是否导出数据?', '提示', { |
| | | confirmButtonText: '确定', |
| | | cancelButtonText: '取消', |
| | | type: 'warning', |
| | | }).then(() => { |
| | | NProgress.start(); |
| | | exportBlob(downloadUrl, values).then(res => { |
| | | downloadXls(res.data, `考核权重配置表${dateNow()}.xlsx`); |
| | | NProgress.done(); |
| | | }); |
| | | }); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getDetail(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | }); |
| | | } |
| | | } |
| | | }; |
| | | done(); |
| | | }, |
| | | 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(); |
| | | }, |
| | | 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; |
| | | |
| | | const {} = this.query; |
| | | |
| | | let values = {}; |
| | | |
| | | getList(page.currentPage, page.pageSize, values).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | this.loading = false; |
| | | this.selectionClear(); |
| | | }); |
| | | }, |
| | | handleImport() { |
| | | this.excelBox = true; |
| | | }, |
| | | uploadAfter(res, done, loading, column) { |
| | | window.console.log(column); |
| | | this.excelBox = false; |
| | | this.refreshChange(); |
| | | done(); |
| | | }, |
| | | handleTemplate() { |
| | | const url = window.location.origin + '/excel/中图员工考核导入模板表.xlsx'; |
| | | axios({ |
| | | url: url, |
| | | method: 'get', |
| | | responseType: 'blob', |
| | | }).then(res => { |
| | | downloadXls(res.data, `中图员工考核导入模板表.xlsx`); |
| | | }); |
| | | }, |
| | | initData() { |
| | | // 获取所属部门数据 |
| | | |
| | | getDeptTree(website.tenantId).then(res => { |
| | | const column = this.option.column; |
| | | const userNameColumn = column.find(item => item.prop === 'userName'); |
| | | const assessorUserName = column.find(item => item.prop === 'assessorUserName'); |
| | | userNameColumn.dicData = res.data.data; |
| | | userNameColumn.lazyLoad = lazyLoad; |
| | | assessorUserName.dicData = res.data.data; |
| | | assessorUserName.lazyLoad = lazyLoad; |
| | | }); |
| | | |
| | | const lazyLoad = (node, resolve) => { |
| | | const column = this.option.column; |
| | | const userNameColumn = column.find(item => item.prop === 'userName'); |
| | | const assessorUserName = column.find(item => item.prop === 'assessorUserName'); |
| | | let stop_level = 2; |
| | | let level = node.level; |
| | | let data = node.data || {}; |
| | | let code = data.code; |
| | | let list = []; |
| | | let callback = () => { |
| | | resolve( |
| | | (list || []).map(ele => { |
| | | return Object.assign(ele, { |
| | | leaf: level >= stop_level, |
| | | }); |
| | | }) |
| | | ); |
| | | }; |
| | | if (level === 2) { |
| | | const deptId = node.value; |
| | | getUserList( |
| | | 1, |
| | | 1000, |
| | | { |
| | | userType: 2, |
| | | }, |
| | | deptId |
| | | ).then(userRes => { |
| | | const userData = userRes.data.data; |
| | | if (userData.records.length === 0) { |
| | | this.$message.warning('当前部门人数为空,请选择其他部门!!'); |
| | | resolve([]); |
| | | callback(); |
| | | } else { |
| | | const records = userData.records.map(item => { |
| | | item.title = item.name; |
| | | return item; |
| | | }); |
| | | list = records; |
| | | records.forEach(item => { |
| | | const is = this.userList.findIndex(v => item.id === v.id); |
| | | if (is == -1) { |
| | | this.userList.push(item); |
| | | } |
| | | }); |
| | | callback(); |
| | | } |
| | | }); |
| | | } |
| | | }; |
| | | }, |
| | | }, |
| | | mounted() { |
| | | this.initData(); |
| | | }, |
| | | }; |
| | | </script> |
| | | |
| | | <style> |
| | | </style> |
| | | <style></style> |