新增
{}">刷新
编辑
删除
自定义新增
自定义修改
取消
// column: [{prop:'name',formslot:true}]
新增
修改
查看
{{user.name?user.name:'暂时没有内容'}}
// column: [{prop:'name',labelslot:true}]
自定义提示{{error}}
// column: [{prop:'name',errorslot:true}]
姓名
option: {
//列的对其方式
align:'left',
//表格宽度
width: '100%',
//表格高度差(主要用于减去其他部分让表格高度自适应)
calcHeight: 'auto',
//表格高度
height: 'auto',
//表格最大高度
maxHeight: 'auto',
// 弹框文字提示
tip: false,
// 边框
border: true,
// 显示序号
index: true,
// 序号标题
indexLabel: "序号",
//打印按钮
printBtn: true
// 刷新按钮
refreshBtn: true
// 查看按钮
viewBtn: true,
// 行内编辑按钮
editBtn: false,
// 行内删除
delBtn: false,
//首次加载是否显示搜索
searchShow: true,
editBtnText:'编辑文案',
viewBtnText:'查看文案',
printBtnText:'打印文案',
excelBtnText:'导出文案',
updateBtnText:'修改文案',
saveBtnText:'保存文案',
cancelBtnText:'取消文案',
//弹框宽度控制
dialogWidth: 600,
column: [
{
label: "请假人",
//匹配后端字段
prop: "userId",
//输入框状态控制 默认为input
type: "tree",
//type:input/input/select/radio/checkbox/textarea/cascader/date/time/datetime
/daterange/timerange/datetimerange/week/month/year/dates/password/switch/tree/number
maxRows:4,//最大行(当type为textarea,当number时最大值)
minRows:2,//最小行(当type为textarea,当number时最小值)
// 搜索栏目自定义内容 同时控制页面显示隐藏
search: true,
//表单编辑时是否禁止输入
editDisabled: true,
//表单新增时是否禁止输入
addDisabled: true,
//隐藏显示当前项
display: false,
// 表单新增是可见
addDisplay: false,
// 表单查看是否可见
viewDisplay: true,
// 编辑按钮是否可见
editDisplay: false,
// 隐藏列
hide: true,
//选着多个 当type为tree生效
multiple: true,
// 传入静态字典
dicData: [],
// 字典参数 props 匹配后台字段
props: {
value: "sysId",
label: "name",
},
//字典地址
dicUrl: "/api/blade-system/dict/dictionary?code=exam_state",
//时间格式
format: "yyyy-MM-dd hh:mm:ss",
valueFormat: "yyyy-MM-dd hh:mm:ss",
//验证
rules: [
{
required: true,
message: "请选择请假人",
trigger: "blur",
},
],
},
data: []
methods: {
rowSave(row, done, loading) {
add(row).then(() => {
done();
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
}, error => {
window.console.log(error);
loading();
});
},
rowUpdate(row, index, done, loading) {
update(row).then(() => {
done();
this.onLoad(this.page);
this.$message({
type: "success",
message: "操作成功!"
});
}, error => {
window.console.log(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: "操作成功!"
});
});
},
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();
});
},
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) {
if (params.dispatchDate) {
console.log(params.dispatchDate, '################');
let date = new Date(params.dispatchDate)
date.setDate(date.getDate())
console.log(date.toISOString().split('T')[0]); // 输出结果为 "2023-10-20"
let startTimes = date.toISOString().split('T')[0]
params.weekdate = startTimes
params.yearOfOperation = startTimes.substring(0, 4)
delete params.dispatchDate;
}
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;
},
onLoad(page, params = {}) {
this.loading = true;
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
const data = res.data.data;
this.page.total = data.total;
this.data = data.records;
for (let i = 0; i < this.data.length; i++) {
const lv = this.data[i]
lv.riskAnalysisCompletionRate = lv.riskAnalysisCompletionRate + '%'
lv.hazardRectificationRate = lv.hazardRectificationRate + '%'
lv.completionRateOfTroubleshootingTasks = lv.completionRateOfTroubleshootingTasks + '%'
}
this.loading = false;
this.selectionClear();
});
}
}