|
@@ -1,20 +1,59 @@
|
|
|
<template>
|
|
|
<fs-page>
|
|
|
- <fs-crud ref="crudRef" v-bind="crudBinding"> </fs-crud>
|
|
|
+ <fs-crud ref="crudRef" v-bind="crudBinding">
|
|
|
+ <template #form_organization_ref="scope">
|
|
|
+
|
|
|
+ <el-cascader :disabled="scope.mode=='view'" v-model="scope.form.organization_ref" :options="options" :props="props1" :show-all-levels="false" />
|
|
|
+ </template>
|
|
|
+ </fs-crud>
|
|
|
</fs-page>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup name="studentInfo">
|
|
|
import { useFs } from '@fast-crud/fast-crud';
|
|
|
-import { onMounted } from 'vue';
|
|
|
-import { GetPermission } from './api';
|
|
|
+import { onMounted,ref } from 'vue';
|
|
|
+import { GetPermission,GetTree } from './api';
|
|
|
import { createCrudOptions } from './crud';
|
|
|
import { handleColumnPermission } from '/@/utils/columnPermission';
|
|
|
|
|
|
const { crudBinding, crudRef, crudExpose, crudOptions, resetCrudOptions } = useFs({ createCrudOptions });
|
|
|
|
|
|
+const options=ref<any[]>([])
|
|
|
+const props1 = {
|
|
|
+ checkStrictly: true,
|
|
|
+ label: 'name',
|
|
|
+ value: 'id',
|
|
|
+ children: 'children',
|
|
|
+ emitPath: false // 只返回选中节点的值,不返回完整路径
|
|
|
+}
|
|
|
+
|
|
|
+const init=()=>{
|
|
|
+ GetTree().then((res:any) => {
|
|
|
+ console.log('组织架构API响应:', res);
|
|
|
+ // 兼容多种响应格式
|
|
|
+ if(res && (res.code === 200 || res.code === 2000 || !res.code)){
|
|
|
+ // 尝试多种数据结构
|
|
|
+ const data = res.data || res.results || res;
|
|
|
+ if (Array.isArray(data)) {
|
|
|
+ options.value = data;
|
|
|
+ console.log('成功赋值组织架构数据:', options.value);
|
|
|
+ } else {
|
|
|
+ console.warn('返回的数据不是数组格式:', data);
|
|
|
+ options.value = [];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.error('获取组织架构数据失败:', res);
|
|
|
+ options.value = [];
|
|
|
+ }
|
|
|
+ }).catch((error: any) => {
|
|
|
+ console.error('请求组织架构数据失败:', error);
|
|
|
+ options.value = [];
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
// 页面打开后获取列表数据
|
|
|
onMounted(async () => {
|
|
|
+ init()
|
|
|
// 设置列权限
|
|
|
const newOptions = await handleColumnPermission(GetPermission, crudOptions);
|
|
|
//重置crudBinding
|