完善表单细节

This commit is contained in:
Cool 2025-03-03 19:41:01 +08:00
parent 2beaa3b57e
commit 34f7309717
10 changed files with 1215 additions and 1236 deletions

View File

@ -1,97 +1,101 @@
import {BasicColumn} from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import {FormSchema} from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { rules} from '/@/utils/helper/validator'; import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils'; import { render } from '/@/utils/common/renderUtils';
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '宿舍信息', title: '宿舍信息',
align:"center", align: 'center',
dataIndex: 'dormitory' dataIndex: 'dormitory',
}, },
{ {
title: '宿舍类型(男/女)', title: '宿舍类型(男/女)',
align:"center", align: 'center',
dataIndex: 'dormitoryType' dataIndex: 'dormitoryType',
}, },
{ {
title: '宿舍人数', title: '宿舍人数',
align:"center", align: 'center',
dataIndex: 'dormitoryNum' dataIndex: 'dormitoryNum',
}, },
{ {
title: '状态', title: '状态',
align:"center", align: 'center',
dataIndex: 'dormitoryStatus' dataIndex: 'dormitoryStatus',
}, },
]; ];
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [];
];
//表单数据 //表单数据
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [
{ {
label: '宿舍信息', label: '宿舍信息',
field: 'dormitory', field: 'dormitory',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入宿舍信息!' }];
{ required: true, message: '请输入宿舍信息!'}, },
];
},
}, },
{ {
label: '男/女', label: '男/女',
field: 'dormitoryType', field: 'dormitoryType',
component: 'Input', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入男/女!'}, { label: '男', value: 0 },
]; { label: '女', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请选择男/女!' }];
},
}, },
{ {
label: '宿舍人数', label: '宿舍人数',
field: 'dormitoryNum', field: 'dormitoryNum',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入宿舍人数!' }];
{ required: true, message: '请输入宿舍人数!'}, },
];
},
}, },
{ {
label: '宿舍状态0没满1已满', label: '宿舍状态',
//0没满1已满
field: 'dormitoryStatus', field: 'dormitoryStatus',
component: 'Input', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入宿舍状态0没满1已满!'}, { label: '未满', value: 0 },
]; { label: '已满', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请选择宿舍状态' }];
},
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
}, },
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
]; ];
// 高级查询数据 // 高级查询数据
export const superQuerySchema = { export const superQuerySchema = {
dormitory: {title: '宿舍信息',order: 0,view: 'text', type: 'string',}, dormitory: { title: '宿舍信息', order: 0, view: 'text', type: 'string' },
dormitoryType: {title: '男/女',order: 1,view: 'text', type: 'string',}, dormitoryType: { title: '男/女', order: 1, view: 'text', type: 'string' },
dormitoryNum: {title: '宿舍人数',order: 2,view: 'number', type: 'number',}, dormitoryNum: { title: '宿舍人数', order: 2, view: 'number', type: 'number' },
dormitoryStatus: {title: '宿舍状态0没满1已满',order: 3,view: 'text', type: 'string',}, dormitoryStatus: { title: '宿舍状态0没满1已满', order: 3, view: 'text', type: 'string' },
}; };
/** /**
* formSchema * formSchema
* @param param * @param param
*/ */
export function getBpmFormSchema(_formData): FormSchema[]{ export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema // 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema
return formSchema; return formSchema;
} }

View File

@ -1,93 +1,101 @@
<template> <template>
<div> <div>
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection"> <BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete"> <a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon> <Icon icon="ant-design:delete-outlined" />
删除 删除
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
<Icon icon="mdi:chevron-down"></Icon> >批量操作
</a-button> <Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown> </a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template> </template>
<!--字段回显插槽--> <!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }"> <template #bodyCell="{ column, record, index, text }">
<span v-if="column.dataIndex === 'dormitoryType'">
<a-tag v-if="record.dormitoryType === 0" color="green"></a-tag>
<a-tag v-else-if="record.dormitoryType !== 0" color="red"></a-tag>
</span>
<span v-if="column.dataIndex === 'dormitoryStatus'">
<a-tag v-if="record.dormitoryStatus === 0" color="green">未满</a-tag>
<a-tag v-else-if="record.dormitoryStatus !== 0" color="red">已满</a-tag>
</span>
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
<CeesDormitoryInfoModal @register="registerModal" @success="handleSuccess"></CeesDormitoryInfoModal> <CeesDormitoryInfoModal @register="registerModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" name="CEES-ceesDormitoryInfo" setup> <script lang="ts" name="CEES-ceesDormitoryInfo" setup>
import {ref, reactive, computed, unref} from 'vue'; import { ref, reactive, computed, unref } from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {useModal} from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage' import { useListPage } from '/@/hooks/system/useListPage';
import CeesDormitoryInfoModal from './components/CeesDormitoryInfoModal.vue' import CeesDormitoryInfoModal from './components/CeesDormitoryInfoModal.vue';
import {columns, searchFormSchema, superQuerySchema} from './CeesDormitoryInfo.data'; import { columns, searchFormSchema, superQuerySchema } from './CeesDormitoryInfo.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CeesDormitoryInfo.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CeesDormitoryInfo.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
//model //model
const [registerModal, {openModal}] = useModal(); const [registerModal, { openModal }] = useModal();
//table //table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps:{ tableProps: {
title: '宿舍信息表', title: '宿舍信息表',
api: list, api: list,
columns, columns,
canResize:false, canResize: false,
formConfig: { formConfig: {
//labelWidth: 120, //labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter:true, autoSubmitOnEnter: true,
showAdvancedButton:true, showAdvancedButton: true,
fieldMapToNumber: [ fieldMapToNumber: [],
], fieldMapToTime: [],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
}, },
exportConfig: { actionColumn: {
name:"宿舍信息表", width: 120,
url: getExportUrl, fixed: 'right',
params: queryParam, },
}, beforeFetch: (params) => {
importConfig: { return Object.assign(params, queryParam);
url: getImportUrl, },
success: handleSuccess },
}, exportConfig: {
}) name: '宿舍信息表',
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
@ -101,86 +109,83 @@
}); });
reload(); reload();
} }
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
/** /**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record){ function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
} },
] ];
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record){ function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
}, { },
label: '删除', {
popConfirm: { label: '删除',
title: '是否确认删除', popConfirm: {
confirm: handleDelete.bind(null, record), title: '是否确认删除',
placement: 'topLeft', confirm: handleDelete.bind(null, record),
} placement: 'topLeft',
} },
] },
} ];
}
</script> </script>
<style scoped> <style scoped></style>
</style>

View File

@ -1,70 +1,70 @@
<template> <template>
<div style="min-height: 400px"> <div style="min-height: 400px">
<BasicForm @register="registerForm"></BasicForm> <BasicForm @register="registerForm" />
<div style="width: 100%;text-align: center" v-if="!formDisabled"> <div style="width: 100%; text-align: center" v-if="!formDisabled">
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary"> </a-button> <a-button @click="submitForm" pre-icon="ant-design:check" type="primary"> </a-button>
</div>
</div> </div>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
import {BasicForm, useForm} from '/@/components/Form/index'; import { BasicForm, useForm } from '/@/components/Form/index';
import {computed, defineComponent} from 'vue'; import { computed, defineComponent } from 'vue';
import {defHttp} from '/@/utils/http/axios'; import { defHttp } from '/@/utils/http/axios';
import { propTypes } from '/@/utils/propTypes'; import { propTypes } from '/@/utils/propTypes';
import {getBpmFormSchema} from '../CeesDormitoryInfo.data'; import { getBpmFormSchema } from '../CeesDormitoryInfo.data';
import {saveOrUpdate} from '../CeesDormitoryInfo.api'; import { saveOrUpdate } from '../CeesDormitoryInfo.api';
export default defineComponent({
name: "CeesDormitoryInfoForm",
components:{
BasicForm
},
props:{
formData: propTypes.object.def({}),
formBpm: propTypes.bool.def(true),
},
setup(props){
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 150,
schemas: getBpmFormSchema(props.formData),
showActionButtonGroup: false,
baseColProps: {span: 24}
});
const formDisabled = computed(()=>{ export default defineComponent({
if(props.formData.disabled === false){ name: 'CeesDormitoryInfoForm',
return false; components: {
} BasicForm,
return true; },
}); props: {
formData: propTypes.object.def({}),
formBpm: propTypes.bool.def(true),
},
setup(props) {
const [registerForm, { setFieldsValue, setProps, getFieldsValue }] = useForm({
labelWidth: 150,
schemas: getBpmFormSchema(props.formData),
showActionButtonGroup: false,
baseColProps: { span: 24 },
});
let formData = {}; const formDisabled = computed(() => {
const queryByIdUrl = '/CEES/ceesDormitoryInfo/queryById'; if (props.formData.disabled === false) {
async function initFormData(){ return false;
let params = {id: props.formData.dataId};
const data = await defHttp.get({url: queryByIdUrl, params});
formData = {...data}
//
await setFieldsValue(formData);
//
await setProps({disabled: formDisabled.value})
}
async function submitForm() {
let data = getFieldsValue();
let params = Object.assign({}, formData, data);
console.log('表单数据', params)
await saveOrUpdate(params, true)
}
initFormData();
return {
registerForm,
formDisabled,
submitForm,
}
} }
}); return true;
</script> });
let formData = {};
const queryByIdUrl = '/CEES/ceesDormitoryInfo/queryById';
async function initFormData() {
let params = { id: props.formData.dataId };
const data = await defHttp.get({ url: queryByIdUrl, params });
formData = { ...data };
//
await setFieldsValue(formData);
//
await setProps({ disabled: formDisabled.value });
}
async function submitForm() {
let data = getFieldsValue();
let params = Object.assign({}, formData, data);
console.log('表单数据', params);
await saveOrUpdate(params, true);
}
initFormData();
return {
registerForm,
formDisabled,
submitForm,
};
},
});
</script>

View File

@ -1,66 +1,66 @@
<template> <template>
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit"> <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
<BasicForm @register="registerForm"/> <BasicForm @register="registerForm" />
</BasicModal> </BasicModal>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {ref, computed, unref} from 'vue'; import { ref, computed, unref } from 'vue';
import {BasicModal, useModalInner} from '/@/components/Modal'; import { BasicModal, useModalInner } from '/@/components/Modal';
import {BasicForm, useForm} from '/@/components/Form/index'; import { BasicForm, useForm } from '/@/components/Form/index';
import {formSchema} from '../CeesDormitoryInfo.data'; import { formSchema } from '../CeesDormitoryInfo.data';
import {saveOrUpdate} from '../CeesDormitoryInfo.api'; import { saveOrUpdate } from '../CeesDormitoryInfo.api';
// Emits // Emits
const emit = defineEmits(['register','success']); const emit = defineEmits(['register', 'success']);
const isUpdate = ref(true); const isUpdate = ref(true);
// //
const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = useForm({ const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({
//labelWidth: 150, //labelWidth: 150,
schemas: formSchema, schemas: formSchema,
showActionButtonGroup: false, showActionButtonGroup: false,
baseColProps: {span: 24} baseColProps: { span: 24 },
}); });
// //
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
// //
await resetFields(); await resetFields();
setModalProps({confirmLoading: false,showCancelBtn:!!data?.showFooter,showOkBtn:!!data?.showFooter}); setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
isUpdate.value = !!data?.isUpdate; isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) { if (unref(isUpdate)) {
// //
await setFieldsValue({ await setFieldsValue({
...data.record, ...data.record,
}); });
}
//
setProps({ disabled: !data?.showFooter })
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
setModalProps({confirmLoading: true});
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} finally {
setModalProps({confirmLoading: false});
}
} }
//
setProps({ disabled: !data?.showFooter });
});
//
const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
//
async function handleSubmit(v) {
try {
let values = await validate();
setModalProps({ confirmLoading: true });
//
await saveOrUpdate(values, isUpdate.value);
//
closeModal();
//
emit('success');
} finally {
setModalProps({ confirmLoading: false });
}
}
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
/** 时间和数字输入框样式 */ /** 时间和数字输入框样式 */
:deep(.ant-input-number){ :deep(.ant-input-number) {
width: 100% width: 100%;
} }
:deep(.ant-calendar-picker){ :deep(.ant-calendar-picker) {
width: 100% width: 100%;
} }
</style> </style>

View File

@ -1,63 +1,63 @@
import {BasicColumn} from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import {FormSchema} from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { rules} from '/@/utils/helper/validator'; import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils'; import { render } from '/@/utils/common/renderUtils';
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '用户id', title: '用户id',
align:"center", align: 'center',
dataIndex: 'userId' dataIndex: 'userId',
}, },
{ {
title: '用户名', title: '用户名',
align:"center", align: 'center',
dataIndex: 'userName' dataIndex: 'userName',
}, },
{ {
title: '专业id,0表示未选择', title: '专业id,0表示未选择',
align:"center", align: 'center',
dataIndex: 'majorId' dataIndex: 'majorId',
}, },
{ {
title: '用户专业id', title: '用户专业id',
align:"center", align: 'center',
dataIndex: 'userMajorId' dataIndex: 'userMajorId',
}, },
{ {
title: '用户专业id', title: '用户专业id',
align:"center", align: 'center',
dataIndex: 'teacherId' dataIndex: 'teacherId',
}, },
{ {
title: '手机号', title: '手机号',
align:"center", align: 'center',
dataIndex: 'phone' dataIndex: 'phone',
}, },
{ {
title: '组id', title: '组id',
align:"center", align: 'center',
dataIndex: 'groupId' dataIndex: 'groupId',
}, },
{ {
title: '使用次数', title: '使用次数',
align:"center", align: 'center',
dataIndex: 'numberuse' dataIndex: 'numberuse',
}, },
{ {
title: '状态0正常 1禁用', title: '状态',
align:"center", align: 'center',
dataIndex: 'status' dataIndex: 'status',
}, },
]; ];
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: "用户名", label: '用户名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
//colProps: {span: 6}, //colProps: {span: 6},
}, },
]; ];
//表单数据 //表单数据
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [
@ -65,119 +65,107 @@ export const formSchema: FormSchema[] = [
label: '用户id', label: '用户id',
field: 'userId', field: 'userId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户id!' }];
{ required: true, message: '请输入用户id!'}, },
];
},
}, },
{ {
label: '用户名', label: '用户名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户名!' }];
{ required: true, message: '请输入用户名!'}, },
];
},
}, },
{ {
label: '专业id,0表示未选择', label: '专业id,0表示未选择',
field: 'majorId', field: 'majorId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入专业id,0表示未选择!' }];
{ required: true, message: '请输入专业id,0表示未选择!'}, },
];
},
}, },
{ {
label: '用户专业id', label: '用户专业id',
field: 'userMajorId', field: 'userMajorId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户专业id!' }];
{ required: true, message: '请输入用户专业id!'}, },
];
},
}, },
{ {
label: '用户专业id', label: '用户专业id',
field: 'teacherId', field: 'teacherId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户专业id!' }];
{ required: true, message: '请输入用户专业id!'}, },
];
},
}, },
{ {
label: '手机号', label: '手机号',
field: 'phone', field: 'phone',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入手机号!' }];
{ required: true, message: '请输入手机号!'}, },
];
},
}, },
{ {
label: '组id', label: '组id',
field: 'groupId', field: 'groupId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入组id!' }];
{ required: true, message: '请输入组id!'}, },
];
},
}, },
{ {
label: '使用次数', label: '使用次数',
field: 'numberuse', field: 'numberuse',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入使用次数!' }];
{ required: true, message: '请输入使用次数!'}, },
];
},
}, },
{ {
label: '状态0正常 1禁用', label: '状态',
field: 'status', field: 'status',
component: 'InputNumber', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入状态0正常 1禁用!'}, { label: '正常', value: 0 },
]; { label: '禁用', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请选择状态!' }];
},
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
}, },
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
]; ];
// 高级查询数据 // 高级查询数据
export const superQuerySchema = { export const superQuerySchema = {
userId: {title: '用户id',order: 0,view: 'text', type: 'string',}, userId: { title: '用户id', order: 0, view: 'text', type: 'string' },
userName: {title: '用户名',order: 1,view: 'text', type: 'string',}, userName: { title: '用户名', order: 1, view: 'text', type: 'string' },
majorId: {title: '专业id,0表示未选择',order: 2,view: 'number', type: 'number',}, majorId: { title: '专业id,0表示未选择', order: 2, view: 'number', type: 'number' },
userMajorId: {title: '用户专业id',order: 3,view: 'text', type: 'string',}, userMajorId: { title: '用户专业id', order: 3, view: 'text', type: 'string' },
teacherId: {title: '用户专业id',order: 4,view: 'text', type: 'string',}, teacherId: { title: '用户专业id', order: 4, view: 'text', type: 'string' },
phone: {title: '手机号',order: 5,view: 'text', type: 'string',}, phone: { title: '手机号', order: 5, view: 'text', type: 'string' },
groupId: {title: '组id',order: 6,view: 'number', type: 'number',}, groupId: { title: '组id', order: 6, view: 'number', type: 'number' },
numberuse: {title: '使用次数',order: 7,view: 'number', type: 'number',}, numberuse: { title: '使用次数', order: 7, view: 'number', type: 'number' },
status: {title: '状态0正常 1禁用',order: 8,view: 'number', type: 'number',}, status: { title: '状态0正常 1禁用', order: 8, view: 'number', type: 'number' },
}; };
/** /**
* formSchema * formSchema
* @param param * @param param
*/ */
export function getBpmFormSchema(_formData): FormSchema[]{ export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema // 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema
return formSchema; return formSchema;
} }

View File

@ -1,93 +1,96 @@
<template> <template>
<div> <div>
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection"> <BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete"> <a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon> <Icon icon="ant-design:delete-outlined" />
删除 删除
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
<Icon icon="mdi:chevron-down"></Icon> >批量操作
</a-button> <Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown> </a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template> </template>
<!--字段回显插槽--> <!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }"> <template #bodyCell="{ column, record, index, text }">
<span v-if="column.dataIndex === 'status'">
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
<a-tag v-else-if="record.status !== 0" color="red">禁用</a-tag>
</span>
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
<CeesLocalTeacherModal @register="registerModal" @success="handleSuccess"></CeesLocalTeacherModal> <CeesLocalTeacherModal @register="registerModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" name="CEES-ceesLocalTeacher" setup> <script lang="ts" name="CEES-ceesLocalTeacher" setup>
import {ref, reactive, computed, unref} from 'vue'; import { ref, reactive, computed, unref } from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {useModal} from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage' import { useListPage } from '/@/hooks/system/useListPage';
import CeesLocalTeacherModal from './components/CeesLocalTeacherModal.vue' import CeesLocalTeacherModal from './components/CeesLocalTeacherModal.vue';
import {columns, searchFormSchema, superQuerySchema} from './CeesLocalTeacher.data'; import { columns, searchFormSchema, superQuerySchema } from './CeesLocalTeacher.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CeesLocalTeacher.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CeesLocalTeacher.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
//model //model
const [registerModal, {openModal}] = useModal(); const [registerModal, { openModal }] = useModal();
//table //table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps:{ tableProps: {
title: '本校教师表', title: '本校教师表',
api: list, api: list,
columns, columns,
canResize:false, canResize: false,
formConfig: { formConfig: {
//labelWidth: 120, //labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter:true, autoSubmitOnEnter: true,
showAdvancedButton:true, showAdvancedButton: true,
fieldMapToNumber: [ fieldMapToNumber: [],
], fieldMapToTime: [],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
}, },
exportConfig: { actionColumn: {
name:"本校教师表", width: 120,
url: getExportUrl, fixed: 'right',
params: queryParam, },
}, beforeFetch: (params) => {
importConfig: { return Object.assign(params, queryParam);
url: getImportUrl, },
success: handleSuccess },
}, exportConfig: {
}) name: '本校教师表',
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
@ -101,86 +104,83 @@
}); });
reload(); reload();
} }
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
/** /**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record){ function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
} },
] ];
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record){ function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
}, { },
label: '删除', {
popConfirm: { label: '删除',
title: '是否确认删除', popConfirm: {
confirm: handleDelete.bind(null, record), title: '是否确认删除',
placement: 'topLeft', confirm: handleDelete.bind(null, record),
} placement: 'topLeft',
} },
] },
} ];
}
</script> </script>
<style scoped> <style scoped></style>
</style>

View File

@ -1,16 +1,16 @@
import {BasicColumn} from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import {FormSchema} from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { rules} from '/@/utils/helper/validator'; import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils'; import { render } from '/@/utils/common/renderUtils';
// 学科映射 // 学科映射
const majorMap = { const majorMap = {
1: '语文', 1: '语文',
4: '地理', 4: '地理',
7: '历史', 7: '历史',
8: '政治', 8: '政治',
}; };
// 根据 majorId 获取学科名称 // 根据 majorId 获取学科名称
const isMajor = (majorId) => { const isMajor = (majorId) => {
return majorMap[majorId] || '未知学科'; return majorMap[majorId] || '未知学科';
@ -18,81 +18,78 @@ const isMajor = (majorId) => {
// 学科过滤方法 // 学科过滤方法
const filterMajor = (value, row) => { const filterMajor = (value, row) => {
console.log(value, row); // 打印过滤值和行数据 console.log(value, row); // 打印过滤值和行数据
return row === value; return row === value;
}; };
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '学生名', title: '学生名',
align:"center", align: 'center',
dataIndex: 'userName' dataIndex: 'userName',
}, },
{ {
title: '用户ID', title: '用户ID',
align:"center", align: 'center',
dataIndex: 'userId' dataIndex: 'userId',
}, },
{ {
title: '学号', title: '学号',
align:"center", align: 'center',
dataIndex: 'studentId' dataIndex: 'studentId',
}, },
{ {
title: '手机号', title: '手机号',
align:"center", align: 'center',
dataIndex: 'phone' dataIndex: 'phone',
}, },
{ {
title: '学科', title: '学科',
align:"center", align: 'center',
dataIndex: 'majorId', dataIndex: 'majorId',
customRender: ({ text }) => { customRender: ({ text }) => {
return isMajor(text); // 根据 majorId 显示学科名称 return isMajor(text); // 根据 majorId 显示学科名称
}, },
filters: [ filters: [
{ text: '语文', value: 1 }, { text: '语文', value: 1 },
{ text: '地理', value: 4 }, { text: '地理', value: 4 },
{ text: '历史', value: 7 }, { text: '历史', value: 7 },
{ text: '政治', value: 8 }, { text: '政治', value: 8 },
], ],
filterMultiple: false, // 是否支持多选过滤 filterMultiple: false, // 是否支持多选过滤
//value: 用户选择的过滤值(如 1 //value: 用户选择的过滤值(如 1
onFilter: (value, record) => filterMajor(value, record.majorId), // 过滤方法 onFilter: (value, record) => filterMajor(value, record.majorId), // 过滤方法
}, },
{ {
title: '所属分组', title: '所属分组',
align:"center", align: 'center',
dataIndex: 'groupId' dataIndex: 'groupId',
}, },
{ {
title: '是否第一次阅卷', title: '是否第一次阅卷',
align:"center", align: 'center',
dataIndex: 'checked', dataIndex: 'checked',
customRender: ({text}) => { },
return text == 1 ? '是' : '否';
} {
},
{
title: '使用次数', title: '使用次数',
align:"center", align: 'center',
dataIndex: 'numberuse' dataIndex: 'numberuse',
}, },
{ {
title: '状态0正常 1禁用', title: '状态',
align:"center", align: 'center',
dataIndex: 'status' dataIndex: 'status',
}, },
]; ];
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: "用户名", label: '用户名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
//colProps: {span: 6}, //colProps: {span: 6},
}, },
]; ];
//表单数据 //表单数据
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [
@ -100,21 +97,17 @@ export const formSchema: FormSchema[] = [
label: '用户id', label: '用户id',
field: 'userId', field: 'userId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户id!' }];
{ required: true, message: '请输入用户id!'}, },
];
},
}, },
{ {
label: '用户名', label: '用户名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户名!' }];
{ required: true, message: '请输入用户名!'}, },
];
},
}, },
{ {
label: '学科', label: '学科',
@ -128,116 +121,106 @@ export const formSchema: FormSchema[] = [
{ label: '政治', value: 8 }, { label: '政治', value: 8 },
], ],
}, },
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请选择学科!' }];
{ required: true, message: '请选择学科!'}, },
];
},
}, },
{ {
label: '用户专业id', label: '用户专业id',
field: 'userMajorId', field: 'userMajorId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户专业id!' }];
{ required: true, message: '请输入用户专业id!'}, },
];
},
}, },
{ {
label: '学生id', label: '学生id',
field: 'studentId', field: 'studentId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入学生id!' }];
{ required: true, message: '请输入学生id!'}, },
];
},
}, },
{ {
label: '手机号', label: '手机号',
field: 'phone', field: 'phone',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入手机号!' }];
{ required: true, message: '请输入手机号!'}, },
];
},
}, },
{ {
label: '是否第一次阅卷', label: '是否第一次阅卷',
field: 'checked', field: 'checked',
component: 'RadioGroup', component: 'RadioGroup',
componentProps: { componentProps: {
options: [ options: [
{ label: '是', value: 1 }, { label: '是', value: 0 },
{ label: '否', value: 0 }, { label: '否', value: 1 },
], ],
}, },
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请选择是否第一次阅卷!' }];
{ required: true, message: '请选择是否第一次阅卷!'}, },
];
},
}, },
{ {
label: '组id', label: '组id',
field: 'groupId', field: 'groupId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入组id!' }];
{ required: true, message: '请输入组id!'}, },
];
},
}, },
{ {
label: '使用次数', label: '使用次数',
field: 'numberuse', field: 'numberuse',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入使用次数!' }];
{ required: true, message: '请输入使用次数!'}, },
];
},
}, },
{ {
label: '状态0正常 1禁用', label: '状态',
field: 'status', field: 'status',
component: 'InputNumber', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入状态0正常 1禁用!'}, { label: '正常', value: 0 },
]; { label: '禁用', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请选择状态!' }];
},
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
}, },
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
]; ];
// 高级查询数据 // 高级查询数据
export const superQuerySchema = { export const superQuerySchema = {
userId: {title: '用户id',order: 0,view: 'text', type: 'string',}, userId: { title: '用户id', order: 0, view: 'text', type: 'string' },
userName: {title: '用户名',order: 1,view: 'text', type: 'string',}, userName: { title: '用户名', order: 1, view: 'text', type: 'string' },
majorId: {title: '专业id,0表示未选择',order: 2,view: 'number', type: 'number',}, majorId: { title: '专业id,0表示未选择', order: 2, view: 'number', type: 'number' },
userMajorId: {title: '用户专业id',order: 3,view: 'text', type: 'string',}, userMajorId: { title: '用户专业id', order: 3, view: 'text', type: 'string' },
studentId: {title: '学生id',order: 4,view: 'text', type: 'string',}, studentId: { title: '学生id', order: 4, view: 'text', type: 'string' },
phone: {title: '手机号',order: 5,view: 'text', type: 'string',}, phone: { title: '手机号', order: 5, view: 'text', type: 'string' },
checked: {title: '是否第一次阅卷',order: 6,view: 'text', type: 'string',}, checked: { title: '是否第一次阅卷', order: 6, view: 'text', type: 'string' },
groupId: {title: '组id',order: 7,view: 'number', type: 'number',}, groupId: { title: '组id', order: 7, view: 'number', type: 'number' },
numberuse: {title: '使用次数',order: 8,view: 'number', type: 'number',}, numberuse: { title: '使用次数', order: 8, view: 'number', type: 'number' },
status: {title: '状态0正常 1禁用',order: 9,view: 'number', type: 'number',}, status: { title: '状态0正常 1禁用', order: 9, view: 'number', type: 'number' },
}; };
/** /**
* formSchema * formSchema
* @param param * @param param
*/ */
export function getBpmFormSchema(_formData): FormSchema[]{ export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema // 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema
return formSchema; return formSchema;
} }

View File

@ -11,13 +11,14 @@
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete"> <a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon> <Icon icon="ant-design:delete-outlined" />
删除 删除
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
<Icon icon="mdi:chevron-down"></Icon> >批量操作
<Icon icon="mdi:chevron-down" />
</a-button> </a-button>
</a-dropdown> </a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
@ -28,157 +29,162 @@
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template> </template>
<!--字段回显插槽--> <!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }"> <template #bodyCell="{ column, record, index, text }">
<span v-if="column.dataIndex === 'checked'">
<a-tag v-if="record.checked === 0" color="green"></a-tag>
<a-tag v-else-if="record.checked !== 0" color="red"></a-tag>
</span>
<span v-if="column.dataIndex === 'status'">
<a-tag v-if="record.status === 0" color="green">正常</a-tag>
<a-tag v-else-if="record.status !== 0" color="red">禁用</a-tag>
</span>
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
<StudentModal @register="registerModal" @success="handleSuccess"></StudentModal> <StudentModal @register="registerModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" name="cees-student" setup> <script lang="ts" name="cees-student" setup>
import { ref, reactive, computed, unref } from 'vue'; import { ref, reactive, computed, unref } from 'vue';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage' import { useListPage } from '/@/hooks/system/useListPage';
import StudentModal from './components/StudentModal.vue' import StudentModal from './components/StudentModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './Student.data'; import { columns, searchFormSchema, superQuerySchema } from './Student.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Student.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Student.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
//model //model
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
//table //table
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps: { tableProps: {
title: '研究生表', title: '研究生表',
api: list, api: list,
columns, columns,
canResize: false, canResize: false,
formConfig: { formConfig: {
//labelWidth: 120, //labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter: true, autoSubmitOnEnter: true,
showAdvancedButton: true, showAdvancedButton: true,
fieldMapToNumber: [ fieldMapToNumber: [],
], fieldMapToTime: [],
fieldMapToTime: [ },
], actionColumn: {
width: 120,
fixed: 'right',
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
}, },
actionColumn: { exportConfig: {
width: 120, name: '研究生表',
fixed: 'right' url: getExportUrl,
params: queryParam,
}, },
beforeFetch: (params) => { importConfig: {
return Object.assign(params, queryParam); url: getImportUrl,
success: handleSuccess,
}, },
}, });
exportConfig: {
name: "研究生表",
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess
},
})
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
/** /**
* 高级查询事件 * 高级查询事件
*/ */
function handleSuperQuery(params) { function handleSuperQuery(params) {
Object.keys(params).map((k) => { Object.keys(params).map((k) => {
queryParam[k] = params[k]; queryParam[k] = params[k];
}); });
reload(); reload();
} }
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
/** /**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({ id: record.id }, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record) { function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
} },
] ];
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record) { function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
}, { },
label: '删除', {
popConfirm: { label: '删除',
title: '是否确认删除', popConfirm: {
confirm: handleDelete.bind(null, record), title: '是否确认删除',
placement: 'topLeft', confirm: handleDelete.bind(null, record),
} placement: 'topLeft',
} },
] },
} ];
}
</script> </script>
<style scoped></style> <style scoped></style>

View File

@ -1,139 +1,139 @@
import {BasicColumn} from '/@/components/Table'; import { BasicColumn } from '/@/components/Table';
import {FormSchema} from '/@/components/Table'; import { FormSchema } from '/@/components/Table';
import { rules} from '/@/utils/helper/validator'; import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils'; import { render } from '/@/utils/common/renderUtils';
//列表数据 //列表数据
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '用户id', title: '用户id',
align:"center", align: 'center',
dataIndex: 'userId' dataIndex: 'userId',
}, },
{ {
title: '专业id', title: '专业id',
align:"center", align: 'center',
dataIndex: 'majorId' dataIndex: 'majorId',
}, },
{ {
title: '用户专业id', title: '用户专业id',
align:"center", align: 'center',
dataIndex: 'userMajorId' dataIndex: 'userMajorId',
}, },
{ {
title: '用户名', title: '用户名',
align:"center", align: 'center',
dataIndex: 'userName' dataIndex: 'userName',
}, },
{ {
title: '手机号', title: '手机号',
align:"center", align: 'center',
dataIndex: 'phone' dataIndex: 'phone',
}, },
{ {
title: '职称', title: '职称',
align:"center", align: 'center',
dataIndex: 'jobTitle' dataIndex: 'jobTitle',
}, },
{ {
title: '银行卡号', title: '银行卡号',
align:"center", align: 'center',
dataIndex: 'pyCard' dataIndex: 'pyCard',
}, },
{ {
title: '饭卡', title: '饭卡',
align:"center", align: 'center',
dataIndex: 'mealCard' dataIndex: 'mealCard',
}, },
{ {
title: '办公位', title: '办公位',
align:"center", align: 'center',
dataIndex: 'office' dataIndex: 'office',
}, },
{ {
title: '工作名称', title: '工作名称',
align:"center", align: 'center',
dataIndex: 'workName' dataIndex: 'workName',
}, },
{ {
title: '固定电话', title: '固定电话',
align:"center", align: 'center',
dataIndex: 'workPhone' dataIndex: 'workPhone',
}, },
{ {
title: '身份证', title: '身份证',
align:"center", align: 'center',
dataIndex: 'identityId' dataIndex: 'identityId',
}, },
{ {
title: '车牌号', title: '车牌号',
align:"center", align: 'center',
dataIndex: 'carNumber' dataIndex: 'carNumber',
}, },
{ {
title: '性别', title: '性别',
align:"center", align: 'center',
dataIndex: 'sex' dataIndex: 'sex',
}, },
{ {
title: '年龄', title: '年龄',
align:"center", align: 'center',
dataIndex: 'age' dataIndex: 'age',
}, },
{ {
title: '车辆是否入校', title: '车辆是否入校',
align:"center", align: 'center',
dataIndex: 'carStatus' dataIndex: 'carStatus',
}, },
{ {
title: '宿舍信息', title: '宿舍信息',
align:"center", align: 'center',
dataIndex: 'dormitory' dataIndex: 'dormitory',
}, },
{ {
title: '是否住宿', title: '是否住宿',
align:"center", align: 'center',
dataIndex: 'dormitoryStatus' dataIndex: 'dormitoryStatus',
}, },
{ {
title: '开户所在地', title: '开户所在地',
align:"center", align: 'center',
dataIndex: 'bankAddress' dataIndex: 'bankAddress',
}, },
{ {
title: '开户行', title: '开户行',
align:"center", align: 'center',
dataIndex: 'bankName' dataIndex: 'bankName',
}, },
{ {
title: '组id', title: '组id',
align:"center", align: 'center',
dataIndex: 'groupId' dataIndex: 'groupId',
}, },
{ {
title: '使用次数', title: '使用次数',
align:"center", align: 'center',
dataIndex: 'numberuse' dataIndex: 'numberuse',
}, },
{ {
title: '状态0已报道 1未报到', title: '状态',
align:"center", align: 'center',
dataIndex: 'status' dataIndex: 'status',
}, },
]; ];
//查询数据 //查询数据
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
label: "专业id", label: '专业id',
field: "majorId", field: 'majorId',
component: 'JRangeNumber', component: 'JRangeNumber',
//colProps: {span: 6}, //colProps: {span: 6},
}, },
{ {
label: "用户名", label: '用户名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
//colProps: {span: 6}, //colProps: {span: 6},
}, },
]; ];
//表单数据 //表单数据
export const formSchema: FormSchema[] = [ export const formSchema: FormSchema[] = [
@ -141,136 +141,116 @@ export const formSchema: FormSchema[] = [
label: '用户id', label: '用户id',
field: 'userId', field: 'userId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户id!' }];
{ required: true, message: '请输入用户id!'}, },
];
},
}, },
{ {
label: '专业id', label: '专业id',
field: 'majorId', field: 'majorId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入专业id!' }];
{ required: true, message: '请输入专业id!'}, },
];
},
}, },
{ {
label: '用户专业id', label: '用户专业id',
field: 'userMajorId', field: 'userMajorId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户专业id!' }];
{ required: true, message: '请输入用户专业id!'}, },
];
},
}, },
{ {
label: '用户名', label: '用户名',
field: 'userName', field: 'userName',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入用户名!' }];
{ required: true, message: '请输入用户名!'}, },
];
},
}, },
{ {
label: '手机号', label: '手机号',
field: 'phone', field: 'phone',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入手机号!' }];
{ required: true, message: '请输入手机号!'}, },
];
},
}, },
{ {
label: '职称', label: '职称',
field: 'jobTitle', field: 'jobTitle',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入职称!' }];
{ required: true, message: '请输入职称!'}, },
];
},
}, },
{ {
label: '银行卡号', label: '银行卡号',
field: 'pyCard', field: 'pyCard',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入银行卡号!' }];
{ required: true, message: '请输入银行卡号!'}, },
];
},
}, },
{ {
label: '饭卡', label: '饭卡',
field: 'mealCard', field: 'mealCard',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入饭卡!' }];
{ required: true, message: '请输入饭卡!'}, },
];
},
}, },
{ {
label: '办公位', label: '办公位',
field: 'office', field: 'office',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入办公位!' }];
{ required: true, message: '请输入办公位!'}, },
];
},
}, },
{ {
label: '工作名称', label: '工作名称',
field: 'workName', field: 'workName',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入工作名称!' }];
{ required: true, message: '请输入工作名称!'}, },
];
},
}, },
{ {
label: '固定电话', label: '固定电话',
field: 'workPhone', field: 'workPhone',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入固定电话!' }];
{ required: true, message: '请输入固定电话!'}, },
];
},
}, },
{ {
label: '身份证', label: '身份证',
field: 'identityId', field: 'identityId',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入身份证!' }];
{ required: true, message: '请输入身份证!'}, },
];
},
}, },
{ {
label: '车牌号', label: '车牌号',
field: 'carNumber', field: 'carNumber',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入车牌号!' }];
{ required: true, message: '请输入车牌号!'}, },
];
},
}, },
{ {
label: '性别', label: '性别',
field: 'sex', field: 'sex',
component: 'Input', component: 'RadioGroup',
componentProps: {
options: [
{ label: '男', value: 0 },
{ label: '女', value: 1 },
],
},
}, },
{ {
label: '年龄', label: '年龄',
@ -280,124 +260,126 @@ export const formSchema: FormSchema[] = [
{ {
label: '车辆是否入校', label: '车辆是否入校',
field: 'carStatus', field: 'carStatus',
component: 'InputNumber', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入车辆是否入校!'}, { label: '是', value: 0 },
]; { label: '否', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入车辆是否入校!' }];
},
}, },
{ {
label: '宿舍信息', label: '宿舍信息',
field: 'dormitory', field: 'dormitory',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入宿舍信息!' }];
{ required: true, message: '请输入宿舍信息!'}, },
];
},
}, },
{ {
label: '是否住宿', label: '是否住宿',
field: 'dormitoryStatus', field: 'dormitoryStatus',
component: 'Input', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入是否住宿!'}, { label: '是', value: 0 },
]; { label: '否', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请输入是否住宿!' }];
},
}, },
{ {
label: '开户所在地', label: '开户所在地',
field: 'bankAddress', field: 'bankAddress',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入开户所在地!' }];
{ required: true, message: '请输入开户所在地!'}, },
];
},
}, },
{ {
label: '开户行', label: '开户行',
field: 'bankName', field: 'bankName',
component: 'Input', component: 'Input',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入开户行!' }];
{ required: true, message: '请输入开户行!'}, },
];
},
}, },
{ {
label: '组id', label: '组id',
field: 'groupId', field: 'groupId',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入组id!' }];
{ required: true, message: '请输入组id!'}, },
];
},
}, },
{ {
label: '使用次数', label: '使用次数',
field: 'numberuse', field: 'numberuse',
component: 'InputNumber', component: 'InputNumber',
dynamicRules: ({model,schema}) => { dynamicRules: ({ model, schema }) => {
return [ return [{ required: true, message: '请输入使用次数!' }];
{ required: true, message: '请输入使用次数!'}, },
];
},
}, },
{ {
label: '状态:0已报道 1未报到', label: '状态:',
field: 'status', field: 'status',
component: 'InputNumber', component: 'RadioGroup',
dynamicRules: ({model,schema}) => { componentProps: {
return [ options: [
{ required: true, message: '请输入状态0已报道 1未报到!'}, { label: '已报到', value: 0 },
]; { label: '未报到', value: 1 },
}, ],
},
dynamicRules: ({ model, schema }) => {
return [{ required: true, message: '请选择状态' }];
},
},
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false,
}, },
// TODO 主键隐藏字段目前写死为ID
{
label: '',
field: 'id',
component: 'Input',
show: false
},
]; ];
// 高级查询数据 // 高级查询数据
export const superQuerySchema = { export const superQuerySchema = {
userId: {title: '用户id',order: 0,view: 'text', type: 'string',}, userId: { title: '用户id', order: 0, view: 'text', type: 'string' },
majorId: {title: '专业id',order: 1,view: 'number', type: 'number',}, majorId: { title: '专业id', order: 1, view: 'number', type: 'number' },
userMajorId: {title: '用户专业id',order: 2,view: 'text', type: 'string',}, userMajorId: { title: '用户专业id', order: 2, view: 'text', type: 'string' },
userName: {title: '用户名',order: 3,view: 'text', type: 'string',}, userName: { title: '用户名', order: 3, view: 'text', type: 'string' },
phone: {title: '手机号',order: 4,view: 'text', type: 'string',}, phone: { title: '手机号', order: 4, view: 'text', type: 'string' },
jobTitle: {title: '职称',order: 5,view: 'text', type: 'string',}, jobTitle: { title: '职称', order: 5, view: 'text', type: 'string' },
pyCard: {title: '银行卡号',order: 6,view: 'text', type: 'string',}, pyCard: { title: '银行卡号', order: 6, view: 'text', type: 'string' },
mealCard: {title: '饭卡',order: 7,view: 'text', type: 'string',}, mealCard: { title: '饭卡', order: 7, view: 'text', type: 'string' },
office: {title: '办公位',order: 8,view: 'text', type: 'string',}, office: { title: '办公位', order: 8, view: 'text', type: 'string' },
workName: {title: '工作名称',order: 9,view: 'text', type: 'string',}, workName: { title: '工作名称', order: 9, view: 'text', type: 'string' },
workPhone: {title: '固定电话',order: 10,view: 'text', type: 'string',}, workPhone: { title: '固定电话', order: 10, view: 'text', type: 'string' },
identityId: {title: '身份证',order: 11,view: 'text', type: 'string',}, identityId: { title: '身份证', order: 11, view: 'text', type: 'string' },
carNumber: {title: '车牌号',order: 12,view: 'text', type: 'string',}, carNumber: { title: '车牌号', order: 12, view: 'text', type: 'string' },
sex: {title: '性别',order: 13,view: 'text', type: 'string',}, sex: { title: '性别', order: 13, view: 'text', type: 'string' },
age: {title: '年龄',order: 14,view: 'number', type: 'number',}, age: { title: '年龄', order: 14, view: 'number', type: 'number' },
carStatus: {title: '车辆是否入校',order: 15,view: 'number', type: 'number',}, carStatus: { title: '车辆是否入校', order: 15, view: 'number', type: 'number' },
dormitory: {title: '宿舍信息',order: 16,view: 'text', type: 'string',}, dormitory: { title: '宿舍信息', order: 16, view: 'text', type: 'string' },
dormitoryStatus: {title: '是否住宿',order: 17,view: 'text', type: 'string',}, dormitoryStatus: { title: '是否住宿', order: 17, view: 'text', type: 'string' },
bankAddress: {title: '开户所在地',order: 18,view: 'text', type: 'string',}, bankAddress: { title: '开户所在地', order: 18, view: 'text', type: 'string' },
bankName: {title: '开户行',order: 19,view: 'text', type: 'string',}, bankName: { title: '开户行', order: 19, view: 'text', type: 'string' },
groupId: {title: '组id',order: 20,view: 'number', type: 'number',}, groupId: { title: '组id', order: 20, view: 'number', type: 'number' },
numberuse: {title: '使用次数',order: 21,view: 'number', type: 'number',}, numberuse: { title: '使用次数', order: 21, view: 'number', type: 'number' },
status: {title: '状态0已报道 1未报到',order: 22,view: 'number', type: 'number',}, status: { title: '状态0已报道 1未报到', order: 22, view: 'number', type: 'number' },
}; };
/** /**
* formSchema * formSchema
* @param param * @param param
*/ */
export function getBpmFormSchema(_formData): FormSchema[]{ export function getBpmFormSchema(_formData): FormSchema[] {
// 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema // 默认和原始表单保持一致 如果流程中配置了权限数据这里需要单独处理formSchema
return formSchema; return formSchema;
} }

View File

@ -1,94 +1,108 @@
<template> <template>
<div> <div>
<!--引用表格--> <!--引用表格-->
<BasicTable @register="registerTable" :rowSelection="rowSelection"> <BasicTable @register="registerTable" :rowSelection="rowSelection">
<!--插槽:table标题--> <!--插槽:table标题-->
<template #tableTitle> <template #tableTitle>
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> <a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button> <j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0"> <a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay> <template #overlay>
<a-menu> <a-menu>
<a-menu-item key="1" @click="batchHandleDelete"> <a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined"></Icon> <Icon icon="ant-design:delete-outlined" />
删除 删除
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
</template> </template>
<a-button>批量操作 <a-button
<Icon icon="mdi:chevron-down"></Icon> >批量操作
</a-button> <Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown> </a-dropdown>
<!-- 高级查询 --> <!-- 高级查询 -->
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> <super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template> </template>
<!--操作栏--> <!--操作栏-->
<template #action="{ record }"> <template #action="{ record }">
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
</template> </template>
<!--字段回显插槽--> <!--字段回显插槽-->
<template v-slot:bodyCell="{ column, record, index, text }"> <template #bodyCell="{ column, record, index, text }">
<span v-if="column.dataIndex === 'sex'">
<a-tag v-if="record.dormitoryType === 0" color="green"></a-tag>
<a-tag v-else-if="record.dormitoryType !== 0" color="red"></a-tag>
</span>
<span v-if="column.dataIndex === 'status'">
<a-tag v-if="record.dormitoryStatus === 0" color="green">已报到</a-tag>
<a-tag v-else-if="record.dormitoryStatus !== 0" color="red">未报到</a-tag>
</span>
<span v-if="column.dataIndex === 'carStatus'">
<a-tag v-if="record.carStatus === 0" color="green"></a-tag>
<a-tag v-else-if="record.carStatus !== 0" color="red"></a-tag>
</span>
<span v-if="column.dataIndex === 'dormitoryStatus'">
<a-tag v-if="record.dormitoryStatus === 0" color="green"></a-tag>
<a-tag v-else-if="record.dormitoryStatus !== 0" color="red"></a-tag>
</span>
</template> </template>
</BasicTable> </BasicTable>
<!-- 表单区域 --> <!-- 表单区域 -->
<CeesWaiTeacherModal @register="registerModal" @success="handleSuccess"></CeesWaiTeacherModal> <CeesWaiTeacherModal @register="registerModal" @success="handleSuccess" />
</div> </div>
</template> </template>
<script lang="ts" name="cees-ceesWaiTeacher" setup> <script lang="ts" name="cees-ceesWaiTeacher" setup>
import {ref, reactive, computed, unref} from 'vue'; import { ref, reactive, computed, unref } from 'vue';
import {BasicTable, useTable, TableAction} from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import {useModal} from '/@/components/Modal'; import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage' import { useListPage } from '/@/hooks/system/useListPage';
import CeesWaiTeacherModal from './components/CeesWaiTeacherModal.vue' import CeesWaiTeacherModal from './components/CeesWaiTeacherModal.vue';
import {columns, searchFormSchema, superQuerySchema} from './CeesWaiTeacher.data'; import { columns, searchFormSchema, superQuerySchema } from './CeesWaiTeacher.data';
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './CeesWaiTeacher.api'; import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './CeesWaiTeacher.api';
import { downloadFile } from '/@/utils/common/renderUtils'; import { downloadFile } from '/@/utils/common/renderUtils';
import { useUserStore } from '/@/store/modules/user'; import { useUserStore } from '/@/store/modules/user';
const queryParam = reactive<any>({}); const queryParam = reactive<any>({});
const checkedKeys = ref<Array<string | number>>([]); const checkedKeys = ref<Array<string | number>>([]);
const userStore = useUserStore(); const userStore = useUserStore();
//model //model
const [registerModal, {openModal}] = useModal(); const [registerModal, { openModal }] = useModal();
//table //table
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({ const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
tableProps:{ tableProps: {
title: '外校老师管理', title: '外校老师管理',
api: list, api: list,
columns, columns,
canResize:false, canResize: false,
formConfig: { formConfig: {
//labelWidth: 120, //labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter:true, autoSubmitOnEnter: true,
showAdvancedButton:true, showAdvancedButton: true,
fieldMapToNumber: [ fieldMapToNumber: [['majorId', ['majorId_begin', 'majorId_end']]],
['majorId', ['majorId_begin', 'majorId_end']], fieldMapToTime: [],
],
fieldMapToTime: [
],
},
actionColumn: {
width: 120,
fixed:'right'
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
}, },
exportConfig: { actionColumn: {
name:"外校老师管理", width: 120,
url: getExportUrl, fixed: 'right',
params: queryParam, },
}, beforeFetch: (params) => {
importConfig: { return Object.assign(params, queryParam);
url: getImportUrl, },
success: handleSuccess },
}, exportConfig: {
}) name: '外校老师管理',
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
// //
const superQueryConfig = reactive(superQuerySchema); const superQueryConfig = reactive(superQuerySchema);
@ -102,86 +116,83 @@
}); });
reload(); reload();
} }
/** /**
* 新增事件 * 新增事件
*/ */
function handleAdd() { function handleAdd() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 编辑事件 * 编辑事件
*/ */
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: true, showFooter: true,
}); });
} }
/** /**
* 详情 * 详情
*/ */
function handleDetail(record: Recordable) { function handleDetail(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
showFooter: false, showFooter: false,
}); });
} }
/** /**
* 删除事件 * 删除事件
*/ */
async function handleDelete(record) { async function handleDelete(record) {
await deleteOne({id: record.id}, handleSuccess); await deleteOne({ id: record.id }, handleSuccess);
} }
/** /**
* 批量删除事件 * 批量删除事件
*/ */
async function batchHandleDelete() { async function batchHandleDelete() {
await batchDelete({ids: selectedRowKeys.value}, handleSuccess); await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
} }
/** /**
* 成功回调 * 成功回调
*/ */
function handleSuccess() { function handleSuccess() {
(selectedRowKeys.value = []) && reload(); (selectedRowKeys.value = []) && reload();
} }
/** /**
* 操作栏 * 操作栏
*/ */
function getTableAction(record){ function getTableAction(record) {
return [ return [
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
} },
] ];
} }
/** /**
* 下拉操作栏 * 下拉操作栏
*/ */
function getDropDownAction(record){ function getDropDownAction(record) {
return [ return [
{ {
label: '详情', label: '详情',
onClick: handleDetail.bind(null, record), onClick: handleDetail.bind(null, record),
}, { },
label: '删除', {
popConfirm: { label: '删除',
title: '是否确认删除', popConfirm: {
confirm: handleDelete.bind(null, record), title: '是否确认删除',
placement: 'topLeft', confirm: handleDelete.bind(null, record),
} placement: 'topLeft',
} },
] },
} ];
}
</script> </script>
<style scoped> <style scoped></style>
</style>