CET-vue-3.0/src/views/system/address/index.vue

89 lines
2.4 KiB
Vue
Raw Normal View History

2022-03-10 09:47:29 +08:00
<template>
2022-06-10 10:44:44 +08:00
<a-row :class="['p-4', `${prefixCls}--box`]" type="flex" :gutter="10" style="max-height: 800px">
<a-col :xl="6" :lg="24" :md="24" style="margin-bottom: 10px">
<DepartLeftTree ref="leftTree" @select="onTreeSelect" />
</a-col>
<a-col :xl="18" :lg="24" :md="24" style="margin-bottom: 10px">
<div style="height: 100%; background-color: white">
<!--引用表格-->
<BasicTable @register="registerTable">
<template #post="{ text }">
{{
(text || '')
.split(',')
.map((t) => (positionInfo[t] ? positionInfo[t] : t))
.join(',')
}}
</template>
</BasicTable>
</div>
</a-col>
</a-row>
2022-03-10 09:47:29 +08:00
</template>
<script lang="ts" setup>
2022-06-10 10:44:44 +08:00
import { provide, ref, unref } from 'vue';
import { useDesign } from '/@/hooks/web/useDesign';
import DepartLeftTree from './components/DepartLeftTree.vue';
import { BasicTable } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns, searchFormSchema } from './address.data';
import { list, positionList } from './address.api';
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
const { prefixCls } = useDesign('address-list');
provide('prefixCls', prefixCls);
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
// 给子组件定义一个ref变量
const leftTree = ref();
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
// 当前选中的部门code
const orgCode = ref('');
const positionInfo = ref({});
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
// 列表页面公共参数、方法
const { tableContext } = useListPage({
tableProps: {
api: list,
columns,
rowKey: 'id',
showIndexColumn: true,
formConfig: {
labelWidth: 200,
schemas: searchFormSchema,
},
canResize: false,
actionColumn: null,
showTableSetting: false,
// 请求之前对参数做处理
beforeFetch(params) {
params.orgCode = orgCode.value;
},
},
});
//注册table数据
const [registerTable, { reload }] = tableContext;
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
// 左侧树选择后触发
function onTreeSelect(data) {
orgCode.value = data.orgCode;
reload();
}
2022-03-10 09:47:29 +08:00
2022-06-10 10:44:44 +08:00
// 查询职务信息
async function queryPositionInfo() {
const result = await positionList({ pageSize: 99999 });
if (result) {
let obj = {};
result.records.forEach((position) => {
obj[position['code']] = position['name'];
});
positionInfo.value = obj;
2022-03-10 09:47:29 +08:00
}
2022-06-10 10:44:44 +08:00
}
queryPositionInfo();
2022-03-10 09:47:29 +08:00
</script>
<style lang="less" scoped>
2022-06-10 10:44:44 +08:00
@import './index.less';
2022-03-10 09:47:29 +08:00
</style>