feat(完成部门管理基础功能): ✨ 修改全局组件大小 large -> default
This commit is contained in:
@@ -135,7 +135,7 @@ export const useThemeConfig = defineStore('themeConfig', {
|
|||||||
// 默认初始语言,可选值"<zh-cn|en|zh-tw>",默认 zh-cn
|
// 默认初始语言,可选值"<zh-cn|en|zh-tw>",默认 zh-cn
|
||||||
globalI18n: 'zh-cn',
|
globalI18n: 'zh-cn',
|
||||||
// 默认全局组件大小,可选值"<large|'default'|small>",默认 'large'
|
// 默认全局组件大小,可选值"<large|'default'|small>",默认 'large'
|
||||||
globalComponentSize: 'large',
|
globalComponentSize: 'default',
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
|
|||||||
41
web/src/views/system/dept/api.ts
Normal file
41
web/src/views/system/dept/api.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { request } from '/@/utils/service';
|
||||||
|
import { PageQuery, AddReq, DelReq, EditReq, InfoReq } from '@fast-crud/fast-crud';
|
||||||
|
|
||||||
|
export const apiPrefix = '/api/system/dept/';
|
||||||
|
export function GetList(query: PageQuery) {
|
||||||
|
return request({
|
||||||
|
url: apiPrefix,
|
||||||
|
method: 'get',
|
||||||
|
data: query,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
export function GetObj(id: InfoReq) {
|
||||||
|
return request({
|
||||||
|
url: apiPrefix + id,
|
||||||
|
method: 'get',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AddObj(obj: AddReq) {
|
||||||
|
return request({
|
||||||
|
url: apiPrefix,
|
||||||
|
method: 'post',
|
||||||
|
data: obj,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function UpdateObj(obj: EditReq) {
|
||||||
|
return request({
|
||||||
|
url: apiPrefix + obj.id + '/',
|
||||||
|
method: 'put',
|
||||||
|
data: obj,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function DelObj(id: DelReq) {
|
||||||
|
return request({
|
||||||
|
url: apiPrefix + id + '/',
|
||||||
|
method: 'delete',
|
||||||
|
data: { id },
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,173 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="system-add-dept-container">
|
|
||||||
<el-dialog title="新增部门" v-model="isShowDialog" width="769px">
|
|
||||||
<el-form :model="ruleForm" size="default" label-width="90px">
|
|
||||||
<el-row :gutter="35">
|
|
||||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
|
||||||
<el-form-item label="上级部门">
|
|
||||||
<el-cascader
|
|
||||||
:options="deptData"
|
|
||||||
:props="{ checkStrictly: true, value: 'deptName', label: 'deptName' }"
|
|
||||||
placeholder="请选择部门"
|
|
||||||
clearable
|
|
||||||
class="w100"
|
|
||||||
v-model="ruleForm.deptLevel"
|
|
||||||
>
|
|
||||||
<template #default="{ node, data }">
|
|
||||||
<span>{{ data.deptName }}</span>
|
|
||||||
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
|
|
||||||
</template>
|
|
||||||
</el-cascader>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="部门名称">
|
|
||||||
<el-input v-model="ruleForm.deptName" placeholder="请输入部门名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="负责人">
|
|
||||||
<el-input v-model="ruleForm.person" placeholder="请输入负责人" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="手机号">
|
|
||||||
<el-input v-model="ruleForm.phone" placeholder="请输入手机号" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="邮箱">
|
|
||||||
<el-input v-model="ruleForm.email" placeholder="请输入" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="排序">
|
|
||||||
<el-input-number v-model="ruleForm.sort" :min="0" :max="999" controls-position="right" placeholder="请输入排序" class="w100" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="部门状态">
|
|
||||||
<el-switch v-model="ruleForm.status" inline-prompt active-text="启" inactive-text="禁"></el-switch>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
|
||||||
<el-form-item label="部门描述">
|
|
||||||
<el-input v-model="ruleForm.describe" type="textarea" placeholder="请输入部门描述" maxlength="150"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="onCancel" size="default">取 消</el-button>
|
|
||||||
<el-button type="primary" @click="onSubmit" size="default">新 增</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { reactive, toRefs, onMounted, defineComponent } from 'vue';
|
|
||||||
|
|
||||||
// 定义接口来定义对象的类型
|
|
||||||
interface TableDataRow {
|
|
||||||
deptName: string;
|
|
||||||
createTime: string;
|
|
||||||
status: boolean;
|
|
||||||
sort: number;
|
|
||||||
describe: string;
|
|
||||||
id: number;
|
|
||||||
children?: TableDataRow[];
|
|
||||||
}
|
|
||||||
interface DeptSate {
|
|
||||||
isShowDialog: boolean;
|
|
||||||
ruleForm: {
|
|
||||||
deptLevel: Array<string>;
|
|
||||||
deptName: string;
|
|
||||||
person: string;
|
|
||||||
phone: string | number;
|
|
||||||
email: string;
|
|
||||||
sort: number;
|
|
||||||
status: boolean;
|
|
||||||
describe: string;
|
|
||||||
};
|
|
||||||
deptData: Array<TableDataRow>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'systemAddDept',
|
|
||||||
setup() {
|
|
||||||
const state = reactive<DeptSate>({
|
|
||||||
isShowDialog: false,
|
|
||||||
ruleForm: {
|
|
||||||
deptLevel: [], // 上级部门
|
|
||||||
deptName: '', // 部门名称
|
|
||||||
person: '', // 负责人
|
|
||||||
phone: '', // 手机号
|
|
||||||
email: '', // 邮箱
|
|
||||||
sort: 0, // 排序
|
|
||||||
status: true, // 部门状态
|
|
||||||
describe: '', // 部门描述
|
|
||||||
},
|
|
||||||
deptData: [], // 部门数据
|
|
||||||
});
|
|
||||||
// 打开弹窗
|
|
||||||
const openDialog = () => {
|
|
||||||
state.isShowDialog = true;
|
|
||||||
};
|
|
||||||
// 关闭弹窗
|
|
||||||
const closeDialog = () => {
|
|
||||||
state.isShowDialog = false;
|
|
||||||
};
|
|
||||||
// 取消
|
|
||||||
const onCancel = () => {
|
|
||||||
closeDialog();
|
|
||||||
};
|
|
||||||
// 新增
|
|
||||||
const onSubmit = () => {
|
|
||||||
closeDialog();
|
|
||||||
};
|
|
||||||
// 初始化部门数据
|
|
||||||
const initTableData = () => {
|
|
||||||
state.deptData.push({
|
|
||||||
deptName: 'vueNextAdmin',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '顶级部门',
|
|
||||||
id: Math.random(),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
deptName: 'IT外包服务',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '总部',
|
|
||||||
id: Math.random(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
deptName: '资本控股',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '分部',
|
|
||||||
id: Math.random(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// 页面加载时
|
|
||||||
onMounted(() => {
|
|
||||||
initTableData();
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
openDialog,
|
|
||||||
closeDialog,
|
|
||||||
onCancel,
|
|
||||||
onSubmit,
|
|
||||||
...toRefs(state),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="system-edit-dept-container">
|
|
||||||
<el-dialog title="修改部门" v-model="isShowDialog" width="769px">
|
|
||||||
<el-form :model="ruleForm" size="default" label-width="90px">
|
|
||||||
<el-row :gutter="35">
|
|
||||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
|
||||||
<el-form-item label="上级部门">
|
|
||||||
<el-cascader
|
|
||||||
:options="deptData"
|
|
||||||
:props="{ checkStrictly: true, value: 'deptName', label: 'deptName' }"
|
|
||||||
placeholder="请选择部门"
|
|
||||||
clearable
|
|
||||||
class="w100"
|
|
||||||
v-model="ruleForm.deptLevel"
|
|
||||||
>
|
|
||||||
<template #default="{ node, data }">
|
|
||||||
<span>{{ data.deptName }}</span>
|
|
||||||
<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
|
|
||||||
</template>
|
|
||||||
</el-cascader>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="部门名称">
|
|
||||||
<el-input v-model="ruleForm.deptName" placeholder="请输入部门名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="负责人">
|
|
||||||
<el-input v-model="ruleForm.person" placeholder="请输入负责人" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="手机号">
|
|
||||||
<el-input v-model="ruleForm.phone" placeholder="请输入手机号" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="邮箱">
|
|
||||||
<el-input v-model="ruleForm.email" placeholder="请输入" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="排序">
|
|
||||||
<el-input-number v-model="ruleForm.sort" :min="0" :max="999" controls-position="right" placeholder="请输入排序" class="w100" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
|
|
||||||
<el-form-item label="部门状态">
|
|
||||||
<el-switch v-model="ruleForm.status" inline-prompt active-text="启" inactive-text="禁"></el-switch>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24" class="mb20">
|
|
||||||
<el-form-item label="部门描述">
|
|
||||||
<el-input v-model="ruleForm.describe" type="textarea" placeholder="请输入部门描述" maxlength="150"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span class="dialog-footer">
|
|
||||||
<el-button @click="onCancel" size="default">取 消</el-button>
|
|
||||||
<el-button type="primary" @click="onSubmit" size="default">修 改</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { reactive, toRefs, onMounted, defineComponent } from 'vue';
|
|
||||||
|
|
||||||
// 定义接口来定义对象的类型
|
|
||||||
interface TableDataRow {
|
|
||||||
deptName: string;
|
|
||||||
createTime: string;
|
|
||||||
status: boolean;
|
|
||||||
sort: number;
|
|
||||||
describe: string;
|
|
||||||
id: number;
|
|
||||||
children?: TableDataRow[];
|
|
||||||
}
|
|
||||||
interface RuleFormState {
|
|
||||||
deptLevel: Array<string>;
|
|
||||||
deptName: string;
|
|
||||||
person: string;
|
|
||||||
phone: string | number;
|
|
||||||
email: string;
|
|
||||||
sort: number;
|
|
||||||
status: boolean;
|
|
||||||
describe: string;
|
|
||||||
}
|
|
||||||
interface DeptSate {
|
|
||||||
isShowDialog: boolean;
|
|
||||||
ruleForm: RuleFormState;
|
|
||||||
deptData: Array<TableDataRow>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'systemEditDept',
|
|
||||||
setup() {
|
|
||||||
const state = reactive<DeptSate>({
|
|
||||||
isShowDialog: false,
|
|
||||||
ruleForm: {
|
|
||||||
deptLevel: [], // 上级部门
|
|
||||||
deptName: '', // 部门名称
|
|
||||||
person: '', // 负责人
|
|
||||||
phone: '', // 手机号
|
|
||||||
email: '', // 邮箱
|
|
||||||
sort: 0, // 排序
|
|
||||||
status: true, // 部门状态
|
|
||||||
describe: '', // 部门描述
|
|
||||||
},
|
|
||||||
deptData: [], // 部门数据
|
|
||||||
});
|
|
||||||
// 打开弹窗
|
|
||||||
const openDialog = (row: RuleFormState) => {
|
|
||||||
row.deptLevel = ['vueNextAdmin'];
|
|
||||||
row.person = 'lyt';
|
|
||||||
row.phone = '12345678910';
|
|
||||||
row.email = 'vueNextAdmin@123.com';
|
|
||||||
state.ruleForm = row;
|
|
||||||
state.isShowDialog = true;
|
|
||||||
};
|
|
||||||
// 关闭弹窗
|
|
||||||
const closeDialog = () => {
|
|
||||||
state.isShowDialog = false;
|
|
||||||
};
|
|
||||||
// 取消
|
|
||||||
const onCancel = () => {
|
|
||||||
closeDialog();
|
|
||||||
};
|
|
||||||
// 新增
|
|
||||||
const onSubmit = () => {
|
|
||||||
closeDialog();
|
|
||||||
};
|
|
||||||
// 初始化部门数据
|
|
||||||
const initTableData = () => {
|
|
||||||
state.deptData.push({
|
|
||||||
deptName: 'vueNextAdmin',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '顶级部门',
|
|
||||||
id: Math.random(),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
deptName: 'IT外包服务',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '总部',
|
|
||||||
id: Math.random(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
deptName: '资本控股',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '分部',
|
|
||||||
id: Math.random(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
};
|
|
||||||
// 页面加载时
|
|
||||||
onMounted(() => {
|
|
||||||
initTableData();
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
openDialog,
|
|
||||||
closeDialog,
|
|
||||||
onCancel,
|
|
||||||
onSubmit,
|
|
||||||
...toRefs(state),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
223
web/src/views/system/dept/crud.tsx
Normal file
223
web/src/views/system/dept/crud.tsx
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
import * as api from "./api";
|
||||||
|
import { dict, PageQuery, AddReq, DelReq, EditReq, CrudExpose, CrudOptions, } from "@fast-crud/fast-crud";
|
||||||
|
import { request } from "/@/utils/service";
|
||||||
|
import { dictionary } from "/@/utils/dictionary";
|
||||||
|
interface CreateCrudOptionsTypes {
|
||||||
|
crudOptions: CrudOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const createCrudOptions = function ({ crudExpose }: { crudExpose: CrudExpose }): CreateCrudOptionsTypes {
|
||||||
|
const pageRequest = async (query: PageQuery) => {
|
||||||
|
return await api.GetList(query);
|
||||||
|
};
|
||||||
|
const editRequest = async ({ form, row }: EditReq) => {
|
||||||
|
form.id = row.id;
|
||||||
|
return await api.UpdateObj(form);
|
||||||
|
};
|
||||||
|
const delRequest = async ({ row }: DelReq) => {
|
||||||
|
return await api.DelObj(row.id);
|
||||||
|
};
|
||||||
|
const addRequest = async ({ form }: AddReq) => {
|
||||||
|
return await api.AddObj(form);
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
crudOptions: {
|
||||||
|
request: {
|
||||||
|
pageRequest,
|
||||||
|
addRequest,
|
||||||
|
editRequest,
|
||||||
|
delRequest
|
||||||
|
},
|
||||||
|
columns: {
|
||||||
|
_index: {
|
||||||
|
title: '序号',
|
||||||
|
form: { show: false },
|
||||||
|
column: {
|
||||||
|
//type: 'index',
|
||||||
|
align: 'center',
|
||||||
|
width: '70px',
|
||||||
|
columnSetDisabled: true, //禁止在列设置中选择
|
||||||
|
formatter: (context) => {
|
||||||
|
//计算序号,你可以自定义计算规则,此处为翻页累加
|
||||||
|
let index = context.index ?? 1;
|
||||||
|
let pagination = crudExpose.crudBinding.value.pagination;
|
||||||
|
return ((pagination.currentPage ?? 1) - 1) * pagination.pageSize + index + 1;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
search: {
|
||||||
|
title: '关键词',
|
||||||
|
column: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
search: {
|
||||||
|
show: true,
|
||||||
|
component: {
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
},
|
||||||
|
placeholder: '请输入关键词'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
form: {
|
||||||
|
show: false,
|
||||||
|
component: {
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
parent: {
|
||||||
|
column: {
|
||||||
|
show: false
|
||||||
|
},
|
||||||
|
title: '上级部门',
|
||||||
|
type: 'dict-tree',
|
||||||
|
dict: dict({
|
||||||
|
url: '/api/system/dept/all_dept/',
|
||||||
|
value: 'id',
|
||||||
|
label: 'name',
|
||||||
|
isTree: true,
|
||||||
|
getData: async ({ url }: { url: string }) => {
|
||||||
|
return request({
|
||||||
|
url: url,
|
||||||
|
}).then((ret: any) => {
|
||||||
|
return ret.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
form: {
|
||||||
|
helper: '默认留空为创建者的部门',
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
props: {
|
||||||
|
props: {
|
||||||
|
value: "id",
|
||||||
|
label: "name",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
title: '部门名称',
|
||||||
|
sortable: true,
|
||||||
|
treeNode: true, // 设置为树形列
|
||||||
|
search: {
|
||||||
|
disabled: false,
|
||||||
|
component: {
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
width: 180,
|
||||||
|
type: 'input',
|
||||||
|
form: {
|
||||||
|
rules: [
|
||||||
|
// 表单校验规则
|
||||||
|
{ required: true, message: '部门名称必填项' }
|
||||||
|
],
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
},
|
||||||
|
placeholder: '请输入部门名称'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
key: {
|
||||||
|
title: '部门标识',
|
||||||
|
sortable: true,
|
||||||
|
form: {
|
||||||
|
component: {
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
},
|
||||||
|
placeholder: '请输入标识字符'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
owner: {
|
||||||
|
title: '负责人',
|
||||||
|
sortable: true,
|
||||||
|
form: {
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
},
|
||||||
|
placeholder: '请输入负责人'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
phone: {
|
||||||
|
title: '联系电话',
|
||||||
|
sortable: true,
|
||||||
|
form: {
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
},
|
||||||
|
placeholder: '请输入联系电话'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
title: '邮箱',
|
||||||
|
sortable: true,
|
||||||
|
form: {
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
props: {
|
||||||
|
clearable: true
|
||||||
|
},
|
||||||
|
placeholder: '请输入邮箱'
|
||||||
|
},
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
type: 'email',
|
||||||
|
message: '请输入正确的邮箱地址',
|
||||||
|
trigger: ['blur', 'change']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sort: {
|
||||||
|
title: '排序',
|
||||||
|
sortable: true,
|
||||||
|
width: 80,
|
||||||
|
type: 'number',
|
||||||
|
form: {
|
||||||
|
value: 1,
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
placeholder: '请选择序号'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
status: {
|
||||||
|
title: '状态',
|
||||||
|
sortable: true,
|
||||||
|
search: {
|
||||||
|
disabled: false
|
||||||
|
},
|
||||||
|
type: 'dict-radio',
|
||||||
|
dict: dict({
|
||||||
|
data: dictionary('button_status_bool')
|
||||||
|
}),
|
||||||
|
form: {
|
||||||
|
value: true,
|
||||||
|
component: {
|
||||||
|
span: 12,
|
||||||
|
placeholder: '请选择状态'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,163 +1,26 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="system-dept-container">
|
<fs-page>
|
||||||
<el-card shadow="hover">
|
<fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
|
||||||
<div class="system-dept-search mb15">
|
</fs-page>
|
||||||
<el-input size="default" placeholder="请输入部门名称" style="max-width: 180px"> </el-input>
|
|
||||||
<el-button size="default" type="primary" class="ml10">
|
|
||||||
<el-icon>
|
|
||||||
<ele-Search />
|
|
||||||
</el-icon>
|
|
||||||
查询
|
|
||||||
</el-button>
|
|
||||||
<el-button size="default" type="success" class="ml10" @click="onOpenAddDept">
|
|
||||||
<el-icon>
|
|
||||||
<ele-FolderAdd />
|
|
||||||
</el-icon>
|
|
||||||
新增部门
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<el-table
|
|
||||||
:data="tableData.data"
|
|
||||||
style="width: 100%"
|
|
||||||
row-key="id"
|
|
||||||
default-expand-all
|
|
||||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
|
||||||
>
|
|
||||||
<el-table-column prop="deptName" label="部门名称" show-overflow-tooltip> </el-table-column>
|
|
||||||
<el-table-column label="排序" show-overflow-tooltip width="80">
|
|
||||||
<template #default="scope">
|
|
||||||
{{ scope.$index }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="status" label="部门状态" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
<el-tag type="success" v-if="scope.row.status">启用</el-tag>
|
|
||||||
<el-tag type="info" v-else>禁用</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="describe" label="部门描述" show-overflow-tooltip></el-table-column>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" show-overflow-tooltip></el-table-column>
|
|
||||||
<el-table-column label="操作" show-overflow-tooltip width="140">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button size="small" text type="primary" @click="onOpenAddDept">新增</el-button>
|
|
||||||
<el-button size="small" text type="primary" @click="onOpenEditDept(scope.row)">修改</el-button>
|
|
||||||
<el-button size="small" text type="primary" @click="onTabelRowDel(scope.row)">删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</el-card>
|
|
||||||
<AddDept ref="addDeptRef" />
|
|
||||||
<EditDept ref="editDeptRef" />
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts" setup>
|
||||||
import { ref, toRefs, reactive, onMounted, defineComponent } from 'vue';
|
import { ref, onMounted } from 'vue';
|
||||||
import { ElMessageBox, ElMessage } from 'element-plus';
|
import { useExpose, useCrud } from '@fast-crud/fast-crud';
|
||||||
import AddDept from '/@/views/system/dept/component/addDept.vue';
|
import { createCrudOptions } from './crud';
|
||||||
import EditDept from '/@/views/system/dept/component/editDept.vue';
|
// crud组件的ref
|
||||||
|
const crudRef = ref();
|
||||||
|
// crud 配置的ref
|
||||||
|
const crudBinding = ref();
|
||||||
|
// 暴露的方法
|
||||||
|
const { crudExpose } = useExpose({ crudRef, crudBinding });
|
||||||
|
// 你的crud配置
|
||||||
|
const { crudOptions } = createCrudOptions({ crudExpose });
|
||||||
|
// 初始化crud配置
|
||||||
|
const { resetCrudOptions } = useCrud({ crudExpose, crudOptions });
|
||||||
|
|
||||||
// 定义接口来定义对象的类型
|
// 页面打开后获取列表数据
|
||||||
interface TableDataRow {
|
onMounted(() => {
|
||||||
deptName: string;
|
crudExpose.doRefresh();
|
||||||
createTime: string;
|
|
||||||
status: boolean;
|
|
||||||
sort: number;
|
|
||||||
describe: string;
|
|
||||||
id: number;
|
|
||||||
children?: TableDataRow[];
|
|
||||||
}
|
|
||||||
interface TableDataState {
|
|
||||||
tableData: {
|
|
||||||
data: Array<TableDataRow>;
|
|
||||||
total: number;
|
|
||||||
loading: boolean;
|
|
||||||
param: {
|
|
||||||
pageNum: number;
|
|
||||||
pageSize: number;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default defineComponent({
|
|
||||||
name: 'systemDept',
|
|
||||||
components: { AddDept, EditDept },
|
|
||||||
setup() {
|
|
||||||
const addDeptRef = ref();
|
|
||||||
const editDeptRef = ref();
|
|
||||||
const state = reactive<TableDataState>({
|
|
||||||
tableData: {
|
|
||||||
data: [],
|
|
||||||
total: 0,
|
|
||||||
loading: false,
|
|
||||||
param: {
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
// 初始化表格数据
|
|
||||||
const initTableData = () => {
|
|
||||||
state.tableData.data.push({
|
|
||||||
deptName: 'vueNextAdmin',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '顶级部门',
|
|
||||||
id: Math.random(),
|
|
||||||
children: [
|
|
||||||
{
|
|
||||||
deptName: 'IT外包服务',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '总部',
|
|
||||||
id: Math.random(),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
deptName: '资本控股',
|
|
||||||
createTime: new Date().toLocaleString(),
|
|
||||||
status: true,
|
|
||||||
sort: Math.random(),
|
|
||||||
describe: '分部',
|
|
||||||
id: Math.random(),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
state.tableData.total = state.tableData.data.length;
|
|
||||||
};
|
|
||||||
// 打开新增菜单弹窗
|
|
||||||
const onOpenAddDept = () => {
|
|
||||||
addDeptRef.value.openDialog();
|
|
||||||
};
|
|
||||||
// 打开编辑菜单弹窗
|
|
||||||
const onOpenEditDept = (row: TableDataRow) => {
|
|
||||||
editDeptRef.value.openDialog(row);
|
|
||||||
};
|
|
||||||
// 删除当前行
|
|
||||||
const onTabelRowDel = (row: TableDataRow) => {
|
|
||||||
ElMessageBox.confirm(`此操作将永久删除部门:${row.deptName}, 是否继续?`, '提示', {
|
|
||||||
confirmButtonText: '删除',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
ElMessage.success('删除成功');
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
};
|
|
||||||
// 页面加载时
|
|
||||||
onMounted(() => {
|
|
||||||
initTableData();
|
|
||||||
});
|
|
||||||
return {
|
|
||||||
addDeptRef,
|
|
||||||
editDeptRef,
|
|
||||||
onOpenAddDept,
|
|
||||||
onOpenEditDept,
|
|
||||||
onTabelRowDel,
|
|
||||||
...toRefs(state),
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user