|
|
@@ -4,14 +4,17 @@ |
|
|
|
<search :search-params="searchParams" /> |
|
|
|
<div class="operating"> |
|
|
|
<el-button size="small" type="warning" @click="add">新增</el-button> |
|
|
|
<el-button size="small" type="default">批量删除</el-button> |
|
|
|
<el-button size="small" type="default">批量导入</el-button> |
|
|
|
<el-button size="small" type="default" @click="remove()" |
|
|
|
>批量删除</el-button |
|
|
|
> |
|
|
|
<!-- <el-button size="small" type="default">批量导入</el-button> --> |
|
|
|
</div> |
|
|
|
<el-table |
|
|
|
highlight-current-row |
|
|
|
:data="dataList" |
|
|
|
border |
|
|
|
:height="tableHeight" |
|
|
|
@selection-change="selectionChange" |
|
|
|
> |
|
|
|
<el-table-column |
|
|
|
type="selection" |
|
|
@@ -60,20 +63,40 @@ |
|
|
|
align="center" |
|
|
|
prop="createUser" |
|
|
|
></el-table-column> |
|
|
|
<el-table-column |
|
|
|
label="操作" |
|
|
|
min-width="150" |
|
|
|
align="center" |
|
|
|
></el-table-column> |
|
|
|
<el-table-column label="操作" min-width="120" align="center"> |
|
|
|
<template slot-scope="{ row }"> |
|
|
|
<el-link |
|
|
|
@click="edit(row)" |
|
|
|
icon="el-icon-edit" |
|
|
|
type="primary" |
|
|
|
:underline="false" |
|
|
|
>修改</el-link |
|
|
|
> |
|
|
|
<el-popconfirm |
|
|
|
title="确定要删除此表格?" |
|
|
|
@confirm="remove(row)" |
|
|
|
class="ele-action" |
|
|
|
> |
|
|
|
<el-link |
|
|
|
slot="reference" |
|
|
|
icon="el-icon-delete" |
|
|
|
type="danger" |
|
|
|
:underline="false" |
|
|
|
>删除</el-link |
|
|
|
> |
|
|
|
</el-popconfirm> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
<el-pagination |
|
|
|
:current-page="page.page" |
|
|
|
:current-page.sync="page.page" |
|
|
|
:page-size="page.limit" |
|
|
|
:total="count" |
|
|
|
:background="true" |
|
|
|
layout="total, prev, pager, next, jumper" |
|
|
|
:pager-count="5" |
|
|
|
class="ele-pagination-circle" |
|
|
|
@current-change="getDataList()" |
|
|
|
/> |
|
|
|
</el-card> |
|
|
|
<el-dialog |
|
|
@@ -81,6 +104,9 @@ |
|
|
|
:visible.sync="showAdd" |
|
|
|
width="400px" |
|
|
|
custom-class="ele-dialog-form" |
|
|
|
:lock-scroll="false" |
|
|
|
:destroy-on-close="true" |
|
|
|
@closed="form = {}" |
|
|
|
> |
|
|
|
<el-form |
|
|
|
:model="form" |
|
|
@@ -92,14 +118,29 @@ |
|
|
|
:rules="rules" |
|
|
|
> |
|
|
|
<el-form-item label="考核年度:" prop="year"> |
|
|
|
<el-date-picker type="year" placeholder="选择考核年度" style="width:100%" clearable v-model="form.year"> |
|
|
|
<el-date-picker |
|
|
|
type="year" |
|
|
|
placeholder="选择考核年度" |
|
|
|
style="width: 100%" |
|
|
|
v-model="form.year" |
|
|
|
format="yyyy" |
|
|
|
value-format="yyyy" |
|
|
|
> |
|
|
|
</el-date-picker> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="表格名称:" prop="name"> |
|
|
|
<el-input placeholder="请输入如表格名称" clearable v-model="form.name"></el-input> |
|
|
|
<el-input |
|
|
|
placeholder="请输入如表格名称" |
|
|
|
clearable |
|
|
|
v-model="form.name" |
|
|
|
></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="表编号:" prop='code'> |
|
|
|
<el-input placeholder="请输入表编号" clearable v-model="form.code"></el-input> |
|
|
|
<el-form-item label="表编号:" prop="code"> |
|
|
|
<el-input |
|
|
|
placeholder="请输入表编号" |
|
|
|
clearable |
|
|
|
v-model="form.code" |
|
|
|
></el-input> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="备注:"> |
|
|
|
<el-input type="textarea" :rows="4" v-model="form.note"></el-input> |
|
|
@@ -123,69 +164,121 @@ export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
searchParams: {}, |
|
|
|
dataList: [ |
|
|
|
{ code: "fadfadf", name: "fadfadf", note: "fdafa", year: "fdfadf" }, |
|
|
|
], |
|
|
|
dataList: [], |
|
|
|
count: 0, |
|
|
|
page: { |
|
|
|
page: 1, |
|
|
|
limit: Math.floor((document.documentElement.clientHeight - 360-45) / 45), |
|
|
|
limit: Math.floor( |
|
|
|
(document.documentElement.clientHeight - 360 - 45) / 45 |
|
|
|
), |
|
|
|
}, |
|
|
|
showAdd: false, |
|
|
|
form: {}, |
|
|
|
multipleSelection: [], |
|
|
|
tableHeight: document.documentElement.clientHeight - 360, |
|
|
|
rules: { |
|
|
|
code: [{ required: true, message: "表编号", trigger: "blur" }], |
|
|
|
name: [{ required: true, message: "请输入表格名称", trigger: "blur" }], |
|
|
|
year: [{ required: true, message: "请输入考核年度" }], |
|
|
|
year: [{ required: true, message: "请输入考核年度", trigger: "blur" }], |
|
|
|
}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
created() { |
|
|
|
this.getDataList(this.page); |
|
|
|
this.getDataList(); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
selectionChange(rows) { |
|
|
|
this.multipleSelection = rows; |
|
|
|
}, |
|
|
|
getDataList(params) { |
|
|
|
const loading = this.$loading({ lock: true }); |
|
|
|
console.log(this.page); |
|
|
|
api |
|
|
|
.getList(params) |
|
|
|
.getList(params ? Object.assign(this.page, params) : this.page) |
|
|
|
.then((res) => { |
|
|
|
loading.close(); |
|
|
|
this.dataList = res.data.data.records; |
|
|
|
this.count=res.data.data.total |
|
|
|
let data = res.data.data.records; |
|
|
|
data = data.map((item) => { |
|
|
|
item.year = item.year + ""; |
|
|
|
return item; |
|
|
|
}); |
|
|
|
this.dataList = data; |
|
|
|
this.count = res.data.data.total; |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
loading.close(); |
|
|
|
this.dataList = []; |
|
|
|
this.count=0 |
|
|
|
this.count = 0; |
|
|
|
}); |
|
|
|
}, |
|
|
|
add(row) { |
|
|
|
console.log(row) |
|
|
|
add() { |
|
|
|
this.form = { code: "", name: "", note: "", year: "" }; |
|
|
|
this.showAdd = true; |
|
|
|
}, |
|
|
|
edit(row) { |
|
|
|
console.log(row) |
|
|
|
this.form = Object.assign({}, row); |
|
|
|
this.showAdd = true; |
|
|
|
}, |
|
|
|
remove(row) { |
|
|
|
if (!row) { |
|
|
|
// 批量删除 |
|
|
|
if (this.multipleSelection.length === 0) |
|
|
|
return this.$message.error("请至少选择一条数据"); |
|
|
|
let ids = this.multipleSelection.map((d) => d.id); |
|
|
|
ids.join(","); |
|
|
|
this.$confirm("确定要删除选中表格?", "提示", { type: "warning" }) |
|
|
|
.then(() => { |
|
|
|
const loading = this.$loading({ lock: true }); |
|
|
|
api |
|
|
|
.delete(ids) |
|
|
|
.then(() => { |
|
|
|
loading.close(); |
|
|
|
this.$message({ type: "success", message: "删除成功" }); |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
loading.close(); |
|
|
|
this.$message.error("删失败"); |
|
|
|
}); |
|
|
|
}) |
|
|
|
.catch(() => 0); |
|
|
|
} else { |
|
|
|
// 单个删除 |
|
|
|
const loading = this.$loading({ lock: true }); |
|
|
|
api |
|
|
|
.delete(row.id) |
|
|
|
.then(() => { |
|
|
|
loading.close(); |
|
|
|
this.$message({ type: "success", message: "删除成功" }); |
|
|
|
}) |
|
|
|
.catch(() => { |
|
|
|
loading.close(); |
|
|
|
this.$message.error("删除失败"); |
|
|
|
}); |
|
|
|
} |
|
|
|
}, |
|
|
|
save() { |
|
|
|
this.$refs["editForm"].validate((valid) => { |
|
|
|
console.log(valid) |
|
|
|
if (valid) { |
|
|
|
const loading = this.$loading({ lock: true }); |
|
|
|
let action = this.form.id ? "edit" : "add"; |
|
|
|
api[action](this.form) |
|
|
|
.then((res) => { |
|
|
|
console.log(res); |
|
|
|
.then(() => { |
|
|
|
loading.close(); |
|
|
|
this.$message({ |
|
|
|
type: "success", |
|
|
|
message: this.form.id ? "修改成功" : "添加成功", |
|
|
|
}); |
|
|
|
this.getDataList(this.page); |
|
|
|
}) |
|
|
|
.catch((e) => { |
|
|
|
console.log(e) |
|
|
|
.catch(() => { |
|
|
|
loading.close(); |
|
|
|
this.$message.error(this.form.id ? "修改失败" : "添加失败"); |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
this.showAdd = false; |
|
|
|
}); |
|
|
|
} else { |
|
|
|
return false; |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |