120 lines
2.7 KiB
Vue
120 lines
2.7 KiB
Vue
<!--
|
|
* @Author: zwq
|
|
* @Date: 2023-01-04 10:29:40
|
|
* @LastEditors: zwq
|
|
* @LastEditTime: 2023-01-05 14:32:59
|
|
* @Description:
|
|
-->
|
|
<template>
|
|
<el-card shadow="never" class="aui-card--fill">
|
|
<div class="mod-sys__dept">
|
|
<search-bar :formConfigs="formConfig" ref="searchBarForm" @headBtnClick="buttonClick" />
|
|
<base-table
|
|
:table-props="tableProps"
|
|
:page="listQuery.page"
|
|
:limit="listQuery.limit"
|
|
:table-data="tableData"
|
|
row-key="id"
|
|
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
|
>
|
|
<method-btn
|
|
v-if="tableBtn.length"
|
|
slot="handleBtn"
|
|
:width="100"
|
|
label="操作"
|
|
:method-list="tableBtn"
|
|
@clickBtn="handleClick"
|
|
/>
|
|
</base-table>
|
|
<!-- 弹窗, 新增 / 修改 -->
|
|
<base-dialog
|
|
:dialogTitle="addOrEditTitle"
|
|
:dialogVisible="addOrUpdateVisible"
|
|
@cancel="handleCancel"
|
|
@confirm="handleConfirm"
|
|
:before-close="handleCancel"
|
|
>
|
|
<add-or-update ref="addOrUpdate" @successSubmit="successSubmit"></add-or-update>
|
|
</base-dialog>
|
|
</div>
|
|
</el-card>
|
|
</template>
|
|
|
|
<script>
|
|
import basicPage from "@/mixins/basic-page";
|
|
import AddOrUpdate from "./dept-add-or-update";
|
|
import i18n from "@/i18n";
|
|
const tableProps = [
|
|
{
|
|
prop: "name",
|
|
label: i18n.t("dept.name"),
|
|
},
|
|
{
|
|
prop: "parentName",
|
|
label: i18n.t("dept.parentName"),
|
|
},
|
|
{
|
|
prop: "sort",
|
|
label: i18n.t("dept.sort"),
|
|
},
|
|
];
|
|
const tableBtn = [
|
|
{
|
|
type: "edit",
|
|
btnName: "编辑",
|
|
},
|
|
{
|
|
type: "delete",
|
|
btnName: "删除",
|
|
},
|
|
];
|
|
export default {
|
|
mixins: [basicPage],
|
|
data() {
|
|
return {
|
|
urlOptions: {
|
|
getDataListURL: "/sys/dept/list",
|
|
deleteURL: "/sys/dept",
|
|
},
|
|
tableProps,
|
|
tableBtn,
|
|
formConfig: [
|
|
{
|
|
type: "button",
|
|
btnName: "新增",
|
|
name: "add",
|
|
color: "primary",
|
|
plain: true,
|
|
},
|
|
],
|
|
};
|
|
},
|
|
components: {
|
|
AddOrUpdate,
|
|
},
|
|
methods: {
|
|
// 获取数据列表
|
|
getDataList() {
|
|
this.dataListLoading = true;
|
|
this.$http
|
|
.get(this.urlOptions.getDataListURL, {
|
|
params: this.listQuery,
|
|
})
|
|
.then(({ data: res }) => {
|
|
this.dataListLoading = false;
|
|
if (res.code !== 0) {
|
|
this.tableData = [];
|
|
this.listQuery.total = 0;
|
|
return this.$message.error(res.msg);
|
|
}
|
|
this.tableData = res.data;
|
|
this.listQuery.total = res.data.total;
|
|
})
|
|
.catch(() => {
|
|
this.dataListLoading = false;
|
|
});
|
|
},
|
|
}
|
|
};
|
|
</script>
|