feat(部门管理): 部门信息布局完成

This commit is contained in:
sheng
2023-08-01 18:29:31 +08:00
parent 98b81a789d
commit 7c72cc74df
5 changed files with 150 additions and 45 deletions

View File

@@ -3,7 +3,7 @@ ENV = 'development'
# 本地环境接口地址 # 本地环境接口地址
#`VITE_API_URL = 'https://demo.dvadmin.com/api' #`VITE_API_URL = 'https://demo.dvadmin.com/api'
VITE_API_URL = 'http://192.168.1.94:10000' VITE_API_URL = 'http://192.168.1.94:1000'
# 是否启用按钮权限 # 是否启用按钮权限
VITE_PM_ENABLED = true VITE_PM_ENABLED = true

View File

@@ -113,11 +113,31 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
columnSetDisabled: true, //禁止在列设置中选择 columnSetDisabled: true, //禁止在列设置中选择
}, },
}, },
username: { search: {
title: '账号', title: '关键词',
column: {
show: false,
},
search: { search: {
show: true, show: true,
component: {
props: {
clearable: true,
},
placeholder: '请输入关键词',
},
}, },
form: {
show: false,
component: {
props: {
clearable: true,
},
},
},
},
username: {
title: '账号',
type: 'input', type: 'input',
column: { column: {
minWidth: 100, //最小列宽 minWidth: 100, //最小列宽
@@ -167,9 +187,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
}, },
name: { name: {
title: '姓名', title: '姓名',
search: {
show: true,
},
type: 'input', type: 'input',
column: { column: {
minWidth: 100, //最小列宽 minWidth: 100, //最小列宽
@@ -273,9 +290,6 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
}, },
mobile: { mobile: {
title: '手机号码', title: '手机号码',
search: {
show: true,
},
type: 'input', type: 'input',
column: { column: {
minWidth: 120, //最小列宽 minWidth: 120, //最小列宽

View File

@@ -1,16 +1,43 @@
<template> <template>
<fs-crud ref="crudRef" v-bind="crudBinding"> <div class="dept-user-com-box dept-info">
<template #actionbar-right> <div class="di-left">
<importExcel api="api/system/user/">导入 </importExcel> <div class="di-cell">
</template> <h3>技术部</h3>
</fs-crud> <!-- <el-switch
v-model="isShowChildFlag"
inline-prompt
active-text=""
inactive-text=""
style="--el-switch-on-color: var(--el-color-primary)"
/> -->
</div>
<div class="di-cell">
<p>部门人数10</p>
<p class="di-margin">部门负责人test</p>
</div>
<p>部门简介</p>
</div>
<div style="height: 100px; width: 150px" ref="deptSexPie"></div>
<div class="dept-split">
<div class="ds-line"></div>
</div>
</div>
<fs-crud ref="crudRef" v-bind="crudBinding" customClass="dept-user-com-box dept-user-com-table">
<!-- -->
<template #actionbar-right>
<importExcel api="api/system/user/">导入 </importExcel>
</template>
</fs-crud>
</template> </template>
<script lang="ts" setup name="user"> <script lang="ts" setup name="user">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { useExpose, useCrud } from '@fast-crud/fast-crud'; import { useExpose, useCrud } from '@fast-crud/fast-crud';
import { createCrudOptions } from './crud'; import { createCrudOptions } from './crud';
import importExcel from '/@/components/importExcel/index.vue' import importExcel from '/@/components/importExcel/index.vue';
import { ECharts, EChartsOption, init } from 'echarts';
let chart: ECharts;
// crud组件的ref // crud组件的ref
const crudRef = ref(); const crudRef = ref();
@@ -22,40 +49,102 @@ const { crudExpose } = useExpose({ crudRef, crudBinding });
const { crudOptions } = createCrudOptions({ crudExpose }); const { crudOptions } = createCrudOptions({ crudExpose });
// 初始化crud配置 // 初始化crud配置
const { resetCrudOptions } = useCrud({ const { resetCrudOptions } = useCrud({
crudExpose, crudOptions, crudExpose,
context: {} crudOptions,
context: {},
}); });
let deptSexPie = ref();
let isShowChildFlag = ref(false);
/** /**
* 部门切换刷新用户列表 * 部门切换刷新用户列表
*/ */
const handleDoRefreshUser = (id: string) => { const handleDoRefreshUser = (id: string) => {
crudExpose.doSearch({ form: { dept: id } }); crudExpose.doSearch({ form: { dept: id } });
} };
/**
* 初始化顶部性别统计
*/
const initDeptSexPieChart = () => {
const option: EChartsOption = {
tooltip: {
trigger: 'item',
},
legend: {
orient: 'vertical',
right: '0%',
left: '58%',
top: 'center',
itemWidth: 12,
itemHeight: 12,
},
series: [
{
type: 'pie',
radius: '65%',
center: ['35%', '50%'],
label: {
show: false,
position: 'center',
},
color: ['#51A3FC', '#E790E8', '#dcdfe6'],
data: [
{ value: 1048, name: '男' },
{ value: 735, name: '女' },
{ value: 580, name: '未知' },
],
},
],
};
chart.setOption(option);
};
onMounted(() => { onMounted(() => {
crudExpose.doRefresh(); crudExpose.doRefresh();
chart = init(deptSexPie.value as HTMLElement);
initDeptSexPieChart();
}); });
defineExpose({ defineExpose({
handleDoRefreshUser handleDoRefreshUser,
}) });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.el-row { .dept-user-com-box {
height: 100%; padding: 0 10px;
border-radius: 8px 0 0 8px;
.el-col { box-sizing: border-box;
height: 100%; background-color: #fff;
}
} }
.dept-user-com-table {
.el-card { height: calc(100% - 200px);
height: 100%;
} }
.dept-info {
width: 100%;
height: 200px;
display: flex;
align-items: center;
justify-content: space-around;
margin-bottom: 10px;
.font-normal { .di-left {
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif; h3 {
font-size: 18px;
font-weight: 900;
}
.di-cell {
display: flex;
align-items: center;
}
.di-margin {
margin-left: 20px;
}
p {
margin-top: 6px;
}
}
} }
</style> </style>

View File

@@ -128,18 +128,18 @@ onMounted(() => {
.dept-box { .dept-box {
height: 100%; height: 100%;
padding: 10px; position: relative;
background-color: #fff;
box-sizing: border-box; box-sizing: border-box;
} }
.dept-left { .dept-left {
position: relative; background-color: #fff;
border-radius: 0 8px 8px 0; border-radius: 0 8px 8px 0;
padding: 10px;
} }
.dept-table { .dept-table {
border-radius: 8px 0 0 8px;
margin-left: 10px; margin-left: 10px;
padding-bottom: 10px;
} }
</style> </style>

View File

@@ -80,13 +80,13 @@
<el-input v-model="menuFormData.component_name" placeholder="请输入组件名称" /> <el-input v-model="menuFormData.component_name" placeholder="请输入组件名称" />
</el-form-item> </el-form-item>
<el-form-item v-if="!menuFormData.is_catalog" label="缓存">
<el-switch v-model="menuFormData.cache" width="60" inline-prompt active-text="启用" inactive-text="禁用" />
</el-form-item>
<el-form-item v-if="!menuFormData.is_catalog && menuFormData.is_link" label="Url" prop="web_path"> <el-form-item v-if="!menuFormData.is_catalog && menuFormData.is_link" label="Url" prop="web_path">
<el-input v-model="menuFormData.web_path" placeholder="请输入Url" /> <el-input v-model="menuFormData.web_path" placeholder="请输入Url" />
</el-form-item> </el-form-item>
<el-form-item v-if="!menuFormData.is_catalog" label="缓存">
<el-switch v-model="menuFormData.cache" width="60" inline-prompt active-text="启用" inactive-text="禁用" />
</el-form-item>
</div> </div>
<el-divider></el-divider> <el-divider></el-divider>
@@ -128,10 +128,12 @@ const defaultTreeProps: any = {
}; };
const validateWebPath = (rule: any, value: string, callback: Function) => { const validateWebPath = (rule: any, value: string, callback: Function) => {
let pattern = /^\/.*?/; let pattern = /^\/.*?/;
if (!pattern.test(value)) { let patternUrl = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
callback(new Error('请输入正确的地址')); const reg = menuFormData.is_link ? patternUrl.test(value) : pattern.test(value);
} else { if (reg) {
callback(); callback();
} else {
callback(new Error('请输入正确的地址'));
} }
}; };
@@ -145,7 +147,7 @@ const emit = defineEmits(['drawerClose']);
const formRef = ref<InstanceType<typeof ElForm>>(); const formRef = ref<InstanceType<typeof ElForm>>();
const rules = reactive<FormRules>({ const rules = reactive<FormRules>({
web_path: [{ required: true, message: '路由地址请以/开头', validator: validateWebPath, trigger: 'blur' }], web_path: [{ required: true, message: '请输入正确的地址', validator: validateWebPath, trigger: 'blur' }],
name: [{ required: true, message: '菜单名称必填', trigger: 'blur' }], name: [{ required: true, message: '菜单名称必填', trigger: 'blur' }],
component: [{ required: true, message: '请输入组件地址', trigger: 'blur' }], component: [{ required: true, message: '请输入组件地址', trigger: 'blur' }],
component_name: [{ required: true, message: '请输入组件名称', trigger: 'blur' }], component_name: [{ required: true, message: '请输入组件名称', trigger: 'blur' }],