|
|
@@ -98,13 +98,10 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { ref, reactive } from 'vue'
|
|
|
import api from '@/api';
|
|
|
-import { h } from 'vue'
|
|
|
import { RouterLink, useRouter } from "vue-router";
|
|
|
-import ImagePreview from '@/components/ImagePreview/index.vue';
|
|
|
-import { regionData, codeToText } from "element-china-area-data";
|
|
|
-import { ElMessage, ElMessageBox, ElTag } from 'element-plus'
|
|
|
+import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
import useAuth from '@/utils/composables/useAuth'
|
|
|
-const { auth, authAll } = useAuth()
|
|
|
+const { auth } = useAuth()
|
|
|
interface PageInfo {
|
|
|
pageNum: number;
|
|
|
pageSize: number;
|
|
|
@@ -113,10 +110,13 @@ interface PageInfo {
|
|
|
}
|
|
|
const props = {
|
|
|
expandTrigger: 'hover' as const,
|
|
|
+ value: 'areaCode',
|
|
|
+ label: 'areaCname',
|
|
|
+ children: 'child'
|
|
|
}
|
|
|
const sysUpAndDownList = ref<string[]>([])//选中id
|
|
|
const provinceoptions = ref<string[]>([])//省市区回显数据
|
|
|
-const areaOptions = ref(regionData)//省市区数据
|
|
|
+const areaOptions = ref()//省市区数据
|
|
|
const provinceChange = (value: any) => {
|
|
|
if (value && value[0] != null && value[1] != null && value[2] != null) {
|
|
|
formInline.provinceId = value[0];
|
|
|
@@ -168,9 +168,24 @@ const formInline = reactive({
|
|
|
const tableData = ref([]);
|
|
|
onBeforeMount(() => {
|
|
|
if (auth('organizationlist.view')) {
|
|
|
- findpage();
|
|
|
+ findpage();//列表数据
|
|
|
+ queryTreeQuery();//区划数据
|
|
|
}
|
|
|
});
|
|
|
+//获取区划数据
|
|
|
+const queryTreeQuery = () => {
|
|
|
+ api.dept.queryTree().then((res: any) => {
|
|
|
+ if (res.code == '200') {
|
|
|
+ areaOptions.value = res.data;
|
|
|
+ } else {
|
|
|
+ ElMessage({
|
|
|
+ type: 'success',
|
|
|
+ message: res.msg,
|
|
|
+ plain: true,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
function findpage() {
|
|
|
api.tenantApi.sysList({ pageNum: pageInfo.value.pageNum, pageSize: pageInfo.value.pageSize, ...formInline }).then((res: any) => {
|
|
|
if (res.code == 200) {
|
|
|
@@ -182,69 +197,40 @@ function findpage() {
|
|
|
|
|
|
})
|
|
|
}
|
|
|
-const deptCountformatter = (row: any, column: any, cellValue: any) => {
|
|
|
- return () => h('div', {}, [
|
|
|
- row.id
|
|
|
- ? h(RouterLink, {
|
|
|
- to: { name: auth('organizationlist.view') ? 'OrganizationDetail' : '', query: { id: row.id, code: row.sysCode, typeName: 'organization' } },
|
|
|
- style: { color: '#3498db', textDecoration: 'none' },
|
|
|
- }, { default: () => row.deptCount || 'N/A' })
|
|
|
- : h('span', { style: { color: 'gray' } }, 'Loading...') // 加载状态或占位符
|
|
|
- ]);
|
|
|
-
|
|
|
-};
|
|
|
-const sysNameformatter = (row: any, column: any, cellValue: any) => {
|
|
|
- return () => h('div', {}, [
|
|
|
- row.id
|
|
|
- ? h(RouterLink, {
|
|
|
- to: { name: auth('organizationlist.view') ? 'OrganizationDetail' : '', query: { id: row.id, code: row.sysCode, typeName: 'tenantInfo' } },
|
|
|
- style: { color: '#3498db', textDecoration: 'none' },
|
|
|
- }, { default: () => row.sysName || 'N/A' })
|
|
|
- : h('span', { style: { color: 'gray' } }, 'Loading...') // 加载状态或占位符
|
|
|
- ]);
|
|
|
-};
|
|
|
-const imgformatter = (row: any, column: any, cellValue: any) => {
|
|
|
- // 返回虚拟 DOM,使用 `<ImagePreview>` 组件
|
|
|
- return h('div', {}, [
|
|
|
- h(ImagePreview, {
|
|
|
- src: row.sysIconUrl, // 显示图片的路径(替换为你的实际数据属性)
|
|
|
- width: '50px',
|
|
|
- height: '50px',
|
|
|
- style: {
|
|
|
- cursor: 'pointer',
|
|
|
- },
|
|
|
- }),
|
|
|
- ]);
|
|
|
-};
|
|
|
-const typeformatter = (row: any, column: any, cellValue: any) => {
|
|
|
- let sysType = '';
|
|
|
- sysTypelist.value.map(ele => {
|
|
|
- if (ele.id == row.sysType) {
|
|
|
- sysType = ele.name;
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- return () => h('div', {}, sysType);
|
|
|
-};
|
|
|
-const cityformatter = (row: any, column: any, cellValue: any) => {
|
|
|
- return () => h('div', {}, `${codeToText[row.provinceId]}-${codeToText[row.cityId]}-${codeToText[row.districtId]}`);
|
|
|
-};
|
|
|
-const statusformatter = (row: any, column: any, cellValue: any) => {
|
|
|
- let available = row.available;
|
|
|
- if (available) {
|
|
|
- return () => h(ElTag, { type: 'primary' }, '启用');
|
|
|
- } else {
|
|
|
- return () => h(ElTag, { type: 'danger' }, '禁用');
|
|
|
- }
|
|
|
-};
|
|
|
const columns = [
|
|
|
{ prop: "sysCode", label: "编码", width: '120', },
|
|
|
- { prop: "sysName", label: "租户名称", width: '120', formatter: sysNameformatter },
|
|
|
- { prop: "sysIcon", label: "租户图标", width: '120', formatter: imgformatter },
|
|
|
- { prop: "sysType", label: "租户类型", width: '120', formatter: typeformatter },
|
|
|
- { prop: "provinceId", label: "所在地区", formatter: cityformatter },
|
|
|
- { prop: "deptCount", label: "下级机构", formatter: deptCountformatter },
|
|
|
- { prop: "available", label: "状态", width: '120', formatter: statusformatter },
|
|
|
+ {
|
|
|
+ prop: "sysName", label: "租户名称", width: '120', component: "RouterLink",
|
|
|
+ formatter: (row: any) => ({ name: 'OrganizationDetail', query: { id: row.id, code: row.sysCode, typeName: 'tenantInfo' } })
|
|
|
+ },
|
|
|
+ { prop: "sysIconUrl", label: "租户图标", width: '120', component: 'Image' },
|
|
|
+ {
|
|
|
+ prop: "sysType", label: "租户类型", width: '120', formatter: (row: any) => {
|
|
|
+ let sysType = '';
|
|
|
+ sysTypelist.value.map(ele => {
|
|
|
+ if (ele.id == row.sysType) {
|
|
|
+ sysType = ele.name;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return sysType
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { prop: "division", label: "所在地区", },
|
|
|
+ {
|
|
|
+ prop: "deptCount", label: "下级机构",
|
|
|
+ component: "RouterLink",
|
|
|
+ formatter: (row: any) => ({ name: 'OrganizationDetail', query: { id: row.id, code: row.sysCode, typeName: 'organization' } })
|
|
|
+ },
|
|
|
+ {
|
|
|
+ prop: "available", label: "状态", width: '120', component: "Tag",
|
|
|
+ formatter: (row: any) => {
|
|
|
+ if (row.available) {
|
|
|
+ return { type: 'primary', text: '启用' };
|
|
|
+ } else {
|
|
|
+ return { type: 'danger', text: '禁用' };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
{ prop: "createTime", label: "创建时间", width: '180', },
|
|
|
{ prop: "createBy", label: "创建人", width: '120', },
|
|
|
];
|
|
|
@@ -276,7 +262,7 @@ const del = (value: string) => {
|
|
|
confirmButtonText: '确定删除',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'error',
|
|
|
- center:true,
|
|
|
+ center: true,
|
|
|
}
|
|
|
)
|
|
|
.then(() => {
|
|
|
@@ -329,7 +315,7 @@ const batchDel = () => {
|
|
|
confirmButtonText: '确定删除',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'error',
|
|
|
- center:true,
|
|
|
+ center: true,
|
|
|
}
|
|
|
)
|
|
|
.then(() => {
|
|
|
@@ -359,7 +345,7 @@ const batchdisable = () => {
|
|
|
confirmButtonText: '确定禁用',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'error',
|
|
|
- center:true,
|
|
|
+ center: true,
|
|
|
}
|
|
|
)
|
|
|
.then(async () => {
|