<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">
|
<template #menu-left>
|
<el-button type="primary" icon="el-icon-plus" @click="handleAdd">
|
新增
|
</el-button>
|
<el-button type="danger" icon="el-icon-delete" plain v-if="permission.evaluateTask_delete" @click="handleDelete">
|
删除
|
</el-button>
|
<el-button type="warning" plain icon="el-icon-download" @click="handleExport">
|
导出
|
</el-button>
|
</template>
|
<template #menu="{ size, row, index }">
|
<el-button type="primary" text plain icon="el-icon-edit" @click="editDialog(row)">
|
编辑
|
</el-button>
|
<el-button type="primary" text plain icon="el-icon-position" @click="publicTimeBtn(row)">
|
发布
|
</el-button>
|
<el-button type="primary" text plain icon="el-icon-download" @click="">
|
导出
|
</el-button>
|
</template>
|
</avue-crud>
|
<!-- 发布弹窗 -->
|
<el-dialog v-model="dialogVisible" title="发布" width="500px">
|
<el-form :model="publicForm">
|
<el-form-item label="评优评先截止时间:">
|
<el-date-picker v-model="publicForm.publicData" type="datetime" placeholder="请选择截止时间"
|
value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%;" />
|
</el-form-item>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="dialogVisible = false">取消</el-button>
|
<el-button type="primary" @click="timeSubmit">确认</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
<!-- 新增编辑弹窗 -->
|
<addDialog :params="addParams" @refreshTable="this.onLoad" />
|
</basic-container>
|
</template>
|
|
<script>
|
import { getList, getDetail, add, update, remove } from "@/api/evaluate/evaluateTask";
|
import option from "@/option/evaluate/evaluateTask";
|
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 addDialog from "./components/addDialog.vue";
|
import { getDeptTree } from '@/api/system/dept';
|
|
export default {
|
components: {
|
addDialog
|
},
|
data() {
|
return {
|
rowData: {},
|
form: {},
|
query: {},
|
search: {},
|
loading: true,
|
page: {
|
pageSize: 10,
|
currentPage: 1,
|
total: 0
|
},
|
selectionList: [],
|
option: option,
|
data: [],
|
// 发布弹窗
|
dialogVisible: false,
|
publicForm: {
|
publicData: ""
|
},
|
isAddDialogVisible: false,
|
addParams: {},
|
viewParams: {},
|
depts: []
|
};
|
},
|
computed: {
|
...mapGetters(["permission"]),
|
permissionList() {
|
return {
|
addBtn: this.validData(this.permission.evaluateTask_add, false),
|
viewBtn: this.validData(this.permission.evaluateTask_view, false),
|
delBtn: this.validData(this.permission.evaluateTask_delete, false),
|
editBtn: this.validData(this.permission.evaluateTask_edit, false)
|
};
|
},
|
ids() {
|
let ids = [];
|
this.selectionList.forEach(ele => {
|
ids.push(ele.id);
|
});
|
return ids.join(",");
|
}
|
},
|
methods: {
|
handleAdd() {
|
this.addParams = {
|
visible: true,
|
title: '添加',
|
isEdit: false,
|
addForm: {}
|
}
|
},
|
rowSave(row, done, loading) {
|
console.log(row);
|
add(row).then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
done();
|
}, error => {
|
loading();
|
window.console.log(error);
|
});
|
},
|
editDialog(row) {
|
this.addParams = {
|
visible: true,
|
title: '编辑',
|
isEdit: true,
|
addForm: {
|
...row
|
}
|
}
|
},
|
rowUpdate(row, index, done, loading) {
|
update(row).then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
done();
|
}, 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"
|
})
|
.then(() => {
|
return remove(this.ids);
|
})
|
.then(() => {
|
this.onLoad(this.page);
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
this.$refs.crud.toggleSelection();
|
});
|
},
|
handleExport() {
|
let downloadUrl = `/evaluateTask/evaluateTask/export-evaluateTask?${this.website.tokenHeader}=${getToken()}`;
|
const {
|
taskName,
|
} = this.query;
|
let values = {
|
taskName_like: taskName,
|
};
|
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 => {
|
if (type === 'view') {
|
this.deptData().then(deptRes => {
|
const candidates = []
|
res.data.data.candidateNum.forEach(item => {
|
const value = deptRes.find(dept => dept.id === item.deptId)
|
candidates.push(`${value.title}: ${item.val}人`)
|
})
|
this.form.candidateNum = candidates.join('、')
|
})
|
}
|
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 {
|
taskName,
|
} = this.query;
|
|
let values = {
|
taskName_like: taskName,
|
};
|
|
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();
|
});
|
},
|
deptData() {
|
return getDeptTree(this.website.tenantId).then(deptResult => {
|
const result = deptResult.data.data
|
let deptList = []
|
result.forEach(dept => {
|
if (dept.children) {
|
deptList = result.concat(dept.children)
|
delete dept.children
|
} else {
|
deptList.push(dept)
|
}
|
})
|
return deptList
|
});
|
},
|
publicTimeBtn(row) {
|
this.rowData = row
|
this.dialogVisible = true
|
},
|
timeSubmit() {
|
const { id } = this.rowData
|
const params = {
|
id,
|
evaluateCutoffTime: this.publicForm.publicData
|
}
|
add(params).then(res => {
|
this.$message({
|
type: "success",
|
message: "操作成功!"
|
});
|
this.refreshChange()
|
}, error => {
|
this.$message({
|
type: "success",
|
message: error
|
});
|
})
|
this.dialogVisible = false
|
}
|
}
|
};
|
</script>
|
|
<style></style>
|