mirror of
https://github.com/chillzhuang/Saber.git
synced 2025-04-17 02:19:22 +08:00
211 lines
5.5 KiB
Vue
211 lines
5.5 KiB
Vue
<template>
|
|
<basic-container>
|
|
<avue-crud :option="option"
|
|
:data="data"
|
|
ref="crud"
|
|
v-model="form"
|
|
:page="page"
|
|
:permission="permissionList"
|
|
@row-del="rowDel"
|
|
@row-update="rowUpdate"
|
|
@row-save="rowSave"
|
|
@search-change="searchChange"
|
|
@search-reset="searchReset"
|
|
@selection-change="selectionChange"
|
|
@on-load="onLoad">
|
|
<template slot="menuLeft">
|
|
<el-button type="danger"
|
|
size="small"
|
|
icon="el-icon-delete"
|
|
v-if="permission.tenant_delete"
|
|
plain
|
|
@click="handleDelete">删 除
|
|
</el-button>
|
|
</template>
|
|
<template slot-scope="{row}"
|
|
slot="roleId">
|
|
<el-tag>{{row.roleName}}</el-tag>
|
|
</template>
|
|
<template slot-scope="{row}"
|
|
slot="deptId">
|
|
<el-tag>{{row.deptName}}</el-tag>
|
|
</template>
|
|
</avue-crud>
|
|
</basic-container>
|
|
</template>
|
|
|
|
<script>
|
|
import {getList, remove, update, add} from "@/api/system/tenant";
|
|
import {mapGetters} from "vuex";
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
form: {},
|
|
selectionList: [],
|
|
page: {
|
|
pageSize: 10,
|
|
currentPage: 1,
|
|
total: 0
|
|
},
|
|
option: {
|
|
tip: false,
|
|
border: true,
|
|
index: true,
|
|
selection: true,
|
|
viewBtn: true,
|
|
dialogWidth: 300,
|
|
dialogHeight: 400,
|
|
column: [
|
|
{
|
|
label: "租户编号",
|
|
prop: "tenantCode",
|
|
search: true,
|
|
addDisplay: false,
|
|
editDisplay: false,
|
|
span: 24,
|
|
rules: [{
|
|
required: true,
|
|
message: "请输入租户编号",
|
|
trigger: "blur"
|
|
}]
|
|
},
|
|
{
|
|
label: "租户名称",
|
|
prop: "tenantName",
|
|
search: true,
|
|
span: 24,
|
|
rules: [{
|
|
required: true,
|
|
message: "请输入参数名称",
|
|
trigger: "blur"
|
|
}]
|
|
},
|
|
{
|
|
label: "联系人",
|
|
prop: "linkman",
|
|
search: true,
|
|
span: 24,
|
|
rules: [{
|
|
required: true,
|
|
message: "请输入联系人",
|
|
trigger: "blur"
|
|
}]
|
|
},
|
|
{
|
|
label: "联系电话",
|
|
prop: "contactNumber",
|
|
span: 24,
|
|
},
|
|
{
|
|
label: "联系地址",
|
|
prop: "address",
|
|
span: 24,
|
|
minRows: 6,
|
|
type: "textarea",
|
|
}
|
|
]
|
|
},
|
|
data: []
|
|
};
|
|
},
|
|
computed: {
|
|
...mapGetters(["permission"]),
|
|
permissionList() {
|
|
return {
|
|
addBtn: this.vaildData(this.permission.tenant_add, false),
|
|
viewBtn: this.vaildData(this.permission.tenant_view, false),
|
|
delBtn: this.vaildData(this.permission.tenant_delete, false),
|
|
editBtn: this.vaildData(this.permission.tenant_edit, false)
|
|
};
|
|
},
|
|
ids() {
|
|
let ids = [];
|
|
this.selectionList.forEach(ele => {
|
|
ids.push(ele.id);
|
|
});
|
|
return ids.join(",");
|
|
}
|
|
},
|
|
methods: {
|
|
rowSave(row, loading) {
|
|
add(row).then(() => {
|
|
loading();
|
|
this.onLoad(this.page);
|
|
this.$message({
|
|
type: "success",
|
|
message: "操作成功!"
|
|
});
|
|
});
|
|
},
|
|
rowUpdate(row, index, loading) {
|
|
update(row).then(() => {
|
|
loading();
|
|
this.onLoad(this.page);
|
|
this.$message({
|
|
type: "success",
|
|
message: "操作成功!"
|
|
});
|
|
});
|
|
},
|
|
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.onLoad(this.page);
|
|
},
|
|
searchChange(params) {
|
|
this.onLoad(this.page, params);
|
|
},
|
|
selectionChange(list) {
|
|
this.selectionList = list;
|
|
},
|
|
handleDelete() {
|
|
if (this.selectionList.length === 0) {
|
|
this.$message.warning("请选择至少一条数据");
|
|
return;
|
|
}
|
|
this.$confirm("确定将选择数据删除?", {
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
type: "warning"
|
|
})
|
|
.then(() => {
|
|
return remove(this.ids);
|
|
})
|
|
.then(() => {
|
|
this.$message({
|
|
type: "success",
|
|
message: "操作成功!"
|
|
});
|
|
this.$refs.crud.toggleSelection();
|
|
});
|
|
},
|
|
onLoad(page, params = {}) {
|
|
getList(page.currentPage, page.pageSize, params).then(res => {
|
|
const data = res.data.data;
|
|
this.page.total = data.total;
|
|
this.data = data.records;
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
</style>
|