|
@@ -1,6 +1,8 @@
|
|
|
-import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, dict, UserPageQuery,compute } from '@fast-crud/fast-crud';
|
|
|
+import { AddReq, CreateCrudOptionsProps, CreateCrudOptionsRet, dict, UserPageQuery, compute, InfoReq, EditReq, DelReq } from '@fast-crud/fast-crud';
|
|
|
import * as api from './api';
|
|
|
import { auth } from '/@/utils/authFunction';
|
|
|
+import { ElMessage } from 'element-plus';
|
|
|
+import { ref } from 'vue';
|
|
|
|
|
|
export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProps): CreateCrudOptionsRet {
|
|
|
const pageRequest = async (query: UserPageQuery) => {
|
|
@@ -22,6 +24,14 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
return await api.AddObj(form);
|
|
|
};
|
|
|
|
|
|
+ const selectedIds = ref<any[]>([]);
|
|
|
+
|
|
|
+ const onSelectionChange = (changed: any[]) => {
|
|
|
+ console.log("selection", changed);
|
|
|
+ selectedIds.value = changed.map((item: any) => item.id);
|
|
|
+ };
|
|
|
+
|
|
|
+ (crudExpose as any).selectedIds = selectedIds;
|
|
|
/**
|
|
|
* 懒加载
|
|
|
* @param row
|
|
@@ -47,6 +57,20 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
add: {
|
|
|
show: auth('area:Create'),
|
|
|
},
|
|
|
+ /* batchExport: {
|
|
|
+ text: '批量导出',
|
|
|
+ type: 'primary',
|
|
|
+ show: auth('area:Export'),
|
|
|
+ click: ({ getSelectedRows }: any) => {
|
|
|
+ const selectedRows = getSelectedRows();
|
|
|
+ if (selectedRows.length === 0) {
|
|
|
+ ElMessage.warning('请先选择要导出的用户');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 触发批量导出 - 通过全局事件总线
|
|
|
+ window.dispatchEvent(new CustomEvent('batch-export', { detail: selectedRows }));
|
|
|
+ },
|
|
|
+ }, */
|
|
|
},
|
|
|
},
|
|
|
form:{
|
|
@@ -63,8 +87,29 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
},
|
|
|
pagination: {
|
|
|
show: true,
|
|
|
+ },
|
|
|
+ table: {
|
|
|
+ rowSelection: {
|
|
|
+ show: true,
|
|
|
+ multiple: true,
|
|
|
+ },
|
|
|
+ onSelectionChange,
|
|
|
},
|
|
|
columns: {
|
|
|
+ $checked: {
|
|
|
+ title: "选择",
|
|
|
+ form: { show: false },
|
|
|
+ column: {
|
|
|
+ type: "selection",
|
|
|
+ align: "center",
|
|
|
+ width: "55px",
|
|
|
+ columnSetDisabled: true, //禁止在列设置中选择
|
|
|
+ selectable(row: any, index: any) {
|
|
|
+ // return row.id !== 1; //设置第一行不允许选择
|
|
|
+ return row.id;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
_index: {
|
|
|
title: '序号',
|
|
|
form: { show: false },
|
|
@@ -224,12 +269,54 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
rules: [{ required: false, message: '请填写租户' }],
|
|
|
},
|
|
|
},
|
|
|
+ /* 组织架构*/
|
|
|
+ /* organization_detail:{
|
|
|
+ title: '组织架构',
|
|
|
+ type: 'input',
|
|
|
+ column: {
|
|
|
+ show: true,
|
|
|
+ minWidth: 200,
|
|
|
+ formatter: ({ row, value }: { row: any; value: any }) => {
|
|
|
+ // 如果有 organization_detail 对象,显示 full_path
|
|
|
+ if (row.organization_detail && row.organization_detail.full_path) {
|
|
|
+ return row.organization_detail.full_path;
|
|
|
+ }
|
|
|
+ // 否则显示原始值
|
|
|
+ return value || '';
|
|
|
+ },
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ show:false,
|
|
|
+ component: { placeholder: '请填写组织架构' },
|
|
|
+ rules: [{ required: false, message: '请填写组织架构' }],
|
|
|
+ },
|
|
|
+ viewForm:{
|
|
|
+ component: { placeholder: '' },
|
|
|
+ }
|
|
|
+ }, */
|
|
|
organization:{
|
|
|
title: '学院',
|
|
|
type: 'input',
|
|
|
column: {
|
|
|
show: true,
|
|
|
- minWidth: 120,
|
|
|
+ minWidth: 200,
|
|
|
+ formatter: ({ row, value }: { row: any; value: any }) => {
|
|
|
+ // 如果有 organization_detail 对象,显示 parent_chain 的第二项(专业)
|
|
|
+ if (row.organization_detail && row.organization_detail.parent_chain && row.organization_detail.parent_chain.length >= 2) {
|
|
|
+ const major = row.organization_detail.parent_chain[0]; // 第二项是专业
|
|
|
+ return major.name || major.code || '';
|
|
|
+ }
|
|
|
+ // 否则显示原始值
|
|
|
+ return value || row.sub_organization;
|
|
|
+ },
|
|
|
+ /* formatter: ({ row, value }: { row: any; value: any }) => {
|
|
|
+ // 如果有 organization_detail 对象,显示 full_path
|
|
|
+ if (row.organization_detail && row.organization_detail.full_path) {
|
|
|
+ return row.organization_detail.full_path;
|
|
|
+ }
|
|
|
+ // 否则显示原始值
|
|
|
+ return value || '';
|
|
|
+ }, */
|
|
|
},
|
|
|
form: {
|
|
|
component: { placeholder: '请填写学院' },
|
|
@@ -245,6 +332,15 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
column: {
|
|
|
show: true,
|
|
|
minWidth: 120,
|
|
|
+ formatter: ({ row, value }: { row: any; value: any }) => {
|
|
|
+ // 如果有 organization_detail 对象,显示 parent_chain 的第二项(专业)
|
|
|
+ if (row.organization_detail && row.organization_detail.parent_chain && row.organization_detail.parent_chain.length >= 2) {
|
|
|
+ const major = row.organization_detail.parent_chain[1]; // 第二项是专业
|
|
|
+ return major.name || major.code || '';
|
|
|
+ }
|
|
|
+ // 否则显示原始值
|
|
|
+ return value || row.sub_organization;
|
|
|
+ },
|
|
|
},
|
|
|
form: {
|
|
|
component: { placeholder: '请填写专业' },
|
|
@@ -260,6 +356,15 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
column: {
|
|
|
show: true,
|
|
|
minWidth: 120,
|
|
|
+ formatter: ({ row, value }: { row: any; value: any }) => {
|
|
|
+ // 如果有 organization_detail 对象,显示 parent_chain 的第二项(专业)
|
|
|
+ if (row.organization_detail && row.organization_detail.parent_chain && row.organization_detail.parent_chain.length >= 2) {
|
|
|
+ const major = row.organization_detail.parent_chain[2]; // 第二项是专业
|
|
|
+ return major.name || major.code || '';
|
|
|
+ }
|
|
|
+ // 否则显示原始值
|
|
|
+ return value || row.grade_or_level;
|
|
|
+ },
|
|
|
},
|
|
|
form: {
|
|
|
component: { placeholder: '请填写年级' },
|
|
@@ -275,6 +380,14 @@ export const createCrudOptions = function ({ crudExpose }: CreateCrudOptionsProp
|
|
|
column: {
|
|
|
show: true,
|
|
|
minWidth: 120,
|
|
|
+ formatter: ({ row, value }: { row: any; value: any }) => {
|
|
|
+ // 如果有 organization_detail 对象,显示 name
|
|
|
+ if (row.organization_detail && row.organization_detail.name) {
|
|
|
+ return row.organization_detail.name;
|
|
|
+ }
|
|
|
+ // 否则显示原始值
|
|
|
+ return value || row.class_or_group;
|
|
|
+ },
|
|
|
},
|
|
|
form: {
|
|
|
component: { placeholder: '请填写班级' },
|