数据管理开发
This commit is contained in:
parent
16ef241f4d
commit
17e6359662
|
@ -0,0 +1,64 @@
|
||||||
|
import {defHttp} from '/@/utils/http/axios';
|
||||||
|
import { useMessage } from "/@/hooks/web/useMessage";
|
||||||
|
|
||||||
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
|
enum Api {
|
||||||
|
list = '/org.jeecg.modules/ceesUser/list',
|
||||||
|
save='/org.jeecg.modules/ceesUser/add',
|
||||||
|
edit='/org.jeecg.modules/ceesUser/edit',
|
||||||
|
deleteOne = '/org.jeecg.modules/ceesUser/delete',
|
||||||
|
deleteBatch = '/org.jeecg.modules/ceesUser/deleteBatch',
|
||||||
|
importExcel = '/org.jeecg.modules/ceesUser/importExcel',
|
||||||
|
exportXls = '/org.jeecg.modules/ceesUser/exportXls',
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 导出api
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const getExportUrl = Api.exportXls;
|
||||||
|
/**
|
||||||
|
* 导入api
|
||||||
|
*/
|
||||||
|
export const getImportUrl = Api.importExcel;
|
||||||
|
/**
|
||||||
|
* 列表接口
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const list = (params) =>
|
||||||
|
defHttp.get({url: Api.list, params});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除单个
|
||||||
|
*/
|
||||||
|
export const deleteOne = (params,handleSuccess) => {
|
||||||
|
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量删除
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const batchDelete = (params, handleSuccess) => {
|
||||||
|
createConfirm({
|
||||||
|
iconType: 'warning',
|
||||||
|
title: '确认删除',
|
||||||
|
content: '是否删除选中数据',
|
||||||
|
okText: '确认',
|
||||||
|
cancelText: '取消',
|
||||||
|
onOk: () => {
|
||||||
|
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 保存或者更新
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
export const saveOrUpdate = (params, isUpdate) => {
|
||||||
|
let url = isUpdate ? Api.edit : Api.save;
|
||||||
|
return defHttp.post({url: url, params});
|
||||||
|
}
|
|
@ -0,0 +1,189 @@
|
||||||
|
import { BasicColumn } from '/@/components/Table';
|
||||||
|
import { FormSchema } from '/@/components/Table';
|
||||||
|
import { rules } from '/@/utils/helper/validator';
|
||||||
|
import { render } from '/@/utils/common/renderUtils';
|
||||||
|
//列表数据
|
||||||
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '姓名',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'userName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户身份码',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'userId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '用户专业ID',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'userHeadingCode',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '身份',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'identity',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '学科',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'majorId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '所属分组',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'groupId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '工作量(点击单元格可编辑)',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'workload',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
//查询数据
|
||||||
|
export const searchFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '用户姓名',
|
||||||
|
field: 'userName',
|
||||||
|
component: 'Input',
|
||||||
|
//colProps: {span: 6},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
//表单数据
|
||||||
|
export const formSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '用户身份码',
|
||||||
|
field: 'userId',
|
||||||
|
component: 'Input',
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请输入登录账号!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '用户姓名',
|
||||||
|
field: 'userName',
|
||||||
|
component: 'Input',
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请输入用户姓名!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '身份',
|
||||||
|
field: 'identity',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '管理员', value: 1 },
|
||||||
|
{ label: '学生', value: 2 },
|
||||||
|
{ label: '老师', value: 3 },
|
||||||
|
{ label: '外校老师', value: 4 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请选择身份!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '学科',
|
||||||
|
field: 'majorId',
|
||||||
|
component: 'Select',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '语文', value: 1 },
|
||||||
|
{ label: '地理', value: 4 },
|
||||||
|
{ label: '历史', value: 7 },
|
||||||
|
{ label: '政治', value: 8 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请选择学科!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '所属组',
|
||||||
|
field: 'groupId',
|
||||||
|
component: 'Select',
|
||||||
|
// TODO 此处需要动态获取组数据
|
||||||
|
//dynamicRules: ({ model, schema }) => {
|
||||||
|
// return [{ required: true, message: '请选择分组!' }];
|
||||||
|
//},
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
label: '状态',
|
||||||
|
field: 'status',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '正常', value: 0 },
|
||||||
|
{ label: '禁用', value: 1 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请选择状态!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// TODO 主键隐藏字段,目前写死为ID
|
||||||
|
{
|
||||||
|
label: '',
|
||||||
|
field: 'id',
|
||||||
|
component: 'Input',
|
||||||
|
show: false,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
//表单数据
|
||||||
|
export const updateFormSchema: FormSchema[] = [
|
||||||
|
{
|
||||||
|
label: '用户姓名',
|
||||||
|
field: 'userName',
|
||||||
|
component: 'Input',
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请输入用户姓名!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '所属组',
|
||||||
|
field: 'groupId',
|
||||||
|
component: 'Select',
|
||||||
|
// TODO 此处需要动态获取组数据
|
||||||
|
//dynamicRules: ({ model, schema }) => {
|
||||||
|
// return [{ required: true, message: '请选择分组!' }];
|
||||||
|
//},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '状态',
|
||||||
|
field: 'status',
|
||||||
|
component: 'RadioGroup',
|
||||||
|
componentProps: {
|
||||||
|
options: [
|
||||||
|
{ label: '正常', value: 0 },
|
||||||
|
{ label: '禁用', value: 1 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
dynamicRules: ({ model, schema }) => {
|
||||||
|
return [{ required: true, message: '请选择状态!' }];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
// 高级查询数据
|
||||||
|
export const superQuerySchema = {
|
||||||
|
userName: { title: '用户姓名', order: 0, view: 'text', type: 'string' },
|
||||||
|
userId: { title: '用户身份码', order: 1, view: 'text', type: 'string' },
|
||||||
|
userHeadingCode: { title: '用户识别码', order: 2, view: 'text', type: 'string' },
|
||||||
|
workload: { title: '工作量', order: 3, view: 'number', type: 'number' },
|
||||||
|
groupId: { title: '组id', order: 4, view: 'number', type: 'number' },
|
||||||
|
identity: { title: '身份:管理员1 学生2,老师 3 ,外校老师4', order: 5, view: 'number', type: 'number' },
|
||||||
|
majorId: { title: '学科', order: 6, view: 'number', type: 'number' },
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 流程表单调用这个方法获取formSchema
|
||||||
|
* @param param
|
||||||
|
*/
|
||||||
|
export function getBpmFormSchema(_formData): FormSchema[] {
|
||||||
|
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
|
||||||
|
console.log(_formData, '111');
|
||||||
|
return formSchema;
|
||||||
|
}
|
|
@ -0,0 +1,203 @@
|
||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!--引用表格-->
|
||||||
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
|
<!--插槽:table标题-->
|
||||||
|
<template #tableTitle>
|
||||||
|
<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>
|
||||||
|
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||||
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
|
<template #overlay>
|
||||||
|
<a-menu>
|
||||||
|
<a-menu-item key="1" @click="batchHandleDelete">
|
||||||
|
<Icon icon="ant-design:delete-outlined" />
|
||||||
|
删除
|
||||||
|
</a-menu-item>
|
||||||
|
</a-menu>
|
||||||
|
</template>
|
||||||
|
<a-button
|
||||||
|
>批量操作
|
||||||
|
<Icon icon="mdi:chevron-down" />
|
||||||
|
</a-button>
|
||||||
|
</a-dropdown>
|
||||||
|
<!-- 高级查询 -->
|
||||||
|
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||||
|
</template>
|
||||||
|
<!--操作栏-->
|
||||||
|
<template #action="{ record }">
|
||||||
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
|
</template>
|
||||||
|
<!--字段回显插槽-->
|
||||||
|
<template #bodyCell="{ column, record, index, text }">
|
||||||
|
<span v-if="column.dataIndex === 'identity'">
|
||||||
|
{{ record.identityDescription }}
|
||||||
|
</span>
|
||||||
|
<span v-if="column.dataIndex === 'majorId'">
|
||||||
|
{{ record.majorIdDescription }}
|
||||||
|
</span>
|
||||||
|
<span v-if="column.dataIndex === 'workload'" @click="handleWordloadClick(record)">
|
||||||
|
<a-input-number v-if="record.seen" v-model:value="record.workload" @blur="handleWordLoadBlur(record)" />
|
||||||
|
<span v-else>{{ record.workload }}</span>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</BasicTable>
|
||||||
|
<!-- 表单区域 -->
|
||||||
|
<CeesUserModal @register="registerModal" @success="handleSuccess" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" name="org.jeecg.modules-ceesUser" setup>
|
||||||
|
import { ref, reactive, computed, unref } from 'vue';
|
||||||
|
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
|
import CeesUserModal from './components/CeesUserModal.vue';
|
||||||
|
import { columns, searchFormSchema, superQuerySchema } from './CeesUser.data';
|
||||||
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate } from './CeesUser.api';
|
||||||
|
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||||
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
|
const queryParam = reactive<any>({});
|
||||||
|
const checkedKeys = ref<Array<string | number>>([]);
|
||||||
|
const userStore = useUserStore();
|
||||||
|
//注册model
|
||||||
|
const [registerModal, { openModal }] = useModal();
|
||||||
|
//注册table数据
|
||||||
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
|
tableProps: {
|
||||||
|
title: 'CEES用户表',
|
||||||
|
api: list,
|
||||||
|
columns,
|
||||||
|
canResize: false,
|
||||||
|
formConfig: {
|
||||||
|
//labelWidth: 120,
|
||||||
|
schemas: searchFormSchema,
|
||||||
|
autoSubmitOnEnter: true,
|
||||||
|
showAdvancedButton: true,
|
||||||
|
fieldMapToNumber: [],
|
||||||
|
fieldMapToTime: [],
|
||||||
|
},
|
||||||
|
actionColumn: {
|
||||||
|
width: 120,
|
||||||
|
fixed: 'right',
|
||||||
|
},
|
||||||
|
beforeFetch: (params) => {
|
||||||
|
return Object.assign(params, queryParam);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
exportConfig: {
|
||||||
|
name: 'CEES用户表',
|
||||||
|
url: getExportUrl,
|
||||||
|
params: queryParam,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const workloadSeen = ref(true);
|
||||||
|
const handleWordLoadBlur = (record) => {
|
||||||
|
console.log(record);
|
||||||
|
saveOrUpdate(record, true);
|
||||||
|
record.seen = false;
|
||||||
|
//workloadSeen.value = true;
|
||||||
|
};
|
||||||
|
const handleWordloadClick = (record) => {
|
||||||
|
//workloadSeen.value = false;
|
||||||
|
record.seen = true;
|
||||||
|
console.log(111);
|
||||||
|
};
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
// 高级查询配置
|
||||||
|
const superQueryConfig = reactive(superQuerySchema);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高级查询事件
|
||||||
|
*/
|
||||||
|
function handleSuperQuery(params) {
|
||||||
|
Object.keys(params).map((k) => {
|
||||||
|
queryParam[k] = params[k];
|
||||||
|
});
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增事件
|
||||||
|
*/
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, {
|
||||||
|
isUpdate: false,
|
||||||
|
showFooter: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑事件
|
||||||
|
*/
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除事件
|
||||||
|
*/
|
||||||
|
async function handleDelete(record) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量删除事件
|
||||||
|
*/
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 成功回调
|
||||||
|
*/
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 操作栏
|
||||||
|
*/
|
||||||
|
function getTableAction(record) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 下拉操作栏
|
||||||
|
*/
|
||||||
|
function getDropDownAction(record) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
placement: 'topLeft',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
|
@ -0,0 +1,70 @@
|
||||||
|
<template>
|
||||||
|
<div style="min-height: 400px">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
<div style="width: 100%; text-align: center" v-if="!formDisabled">
|
||||||
|
<a-button @click="submitForm" pre-icon="ant-design:check" type="primary">提 交</a-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { computed, defineComponent } from 'vue';
|
||||||
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
|
import { getBpmFormSchema } from '../CeesUser.data';
|
||||||
|
import { saveOrUpdate } from '../CeesUser.api';
|
||||||
|
|
||||||
|
export default defineComponent({
|
||||||
|
name: 'CeesUserForm',
|
||||||
|
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(() => {
|
||||||
|
if (props.formData.disabled === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
let formData = {};
|
||||||
|
const queryByIdUrl = '/org.jeecg.modules/ceesUser/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>
|
|
@ -0,0 +1,72 @@
|
||||||
|
<template>
|
||||||
|
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
|
||||||
|
<BasicForm @register="registerForm" />
|
||||||
|
</BasicModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { ref, computed, unref } from 'vue';
|
||||||
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { formSchema, updateFormSchema } from '../CeesUser.data';
|
||||||
|
import { saveOrUpdate } from '../CeesUser.api';
|
||||||
|
// Emits声明
|
||||||
|
const emit = defineEmits(['register', 'success']);
|
||||||
|
const isUpdate = ref(true);
|
||||||
|
//表单配置
|
||||||
|
const [registerForm, { setProps, removeSchemaByFiled, resetFields, setFieldsValue, validate }] = useForm({
|
||||||
|
//labelWidth: 150,
|
||||||
|
schemas: formSchema,
|
||||||
|
showActionButtonGroup: false,
|
||||||
|
baseColProps: { span: 24 },
|
||||||
|
});
|
||||||
|
//表单赋值
|
||||||
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
}
|
||||||
|
//重置表单
|
||||||
|
await resetFields();
|
||||||
|
setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
|
||||||
|
isUpdate.value = !!data?.isUpdate;
|
||||||
|
// 根据模式更新表单配置
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
removeSchemaByFiled(['majorId', 'identity', 'userId']);
|
||||||
|
}
|
||||||
|
if (unref(isUpdate)) {
|
||||||
|
//表单赋值
|
||||||
|
await setFieldsValue({
|
||||||
|
...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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
/** 时间和数字输入框样式 */
|
||||||
|
:deep(.ant-input-number) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.ant-calendar-picker) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -1,8 +1,15 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!--引用表格-->
|
<!--引用表格-->
|
||||||
<BasicTable @register="registerTable" :rowSelection="rowSelection" ref="tableRef" :expandedRowKeys="expandedKeys"
|
<BasicTable
|
||||||
rowKey="id" :expandedRowRender="renderExpandedRow" @expand="handleExpand">
|
@register="registerTable"
|
||||||
|
:rowSelection="rowSelection"
|
||||||
|
ref="tableRef"
|
||||||
|
:expandedRowKeys="expandedKeys"
|
||||||
|
rowKey="id"
|
||||||
|
:expandedRowRender="renderExpandedRow"
|
||||||
|
@expand="handleExpand"
|
||||||
|
>
|
||||||
<!--插槽: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>
|
||||||
|
@ -17,7 +24,8 @@
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</template>
|
</template>
|
||||||
<a-button>批量操作
|
<a-button
|
||||||
|
>批量操作
|
||||||
<Icon icon="mdi:chevron-down" />
|
<Icon icon="mdi:chevron-down" />
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
|
@ -57,191 +65,191 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="tsx" name="cees-ceesWaiTeacher" setup>
|
<script lang="tsx" name="cees-ceesWaiTeacher" setup>
|
||||||
import { ref, reactive, computed, unref, onMounted } from 'vue';
|
import { ref, reactive, computed, unref, onMounted } 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, updateGroupOptions } from './CeesWaiTeacher.data';
|
import { columns, searchFormSchema, superQuerySchema, updateGroupOptions } from './CeesWaiTeacher.data';
|
||||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup } from './CeesWaiTeacher.api';
|
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGroup } 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: [['majorId', ['majorId_begin', 'majorId_end']]],
|
fieldMapToNumber: [['majorId', ['majorId_begin', 'majorId_end']]],
|
||||||
fieldMapToTime: [],
|
fieldMapToTime: [],
|
||||||
},
|
},
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
width: 120,
|
width: 120,
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
},
|
},
|
||||||
beforeFetch: (params) => {
|
beforeFetch: (params) => {
|
||||||
return Object.assign(params, queryParam);
|
return Object.assign(params, queryParam);
|
||||||
},
|
|
||||||
},
|
|
||||||
exportConfig: {
|
|
||||||
name: '外校老师管理',
|
|
||||||
url: getExportUrl,
|
|
||||||
params: queryParam,
|
|
||||||
},
|
|
||||||
importConfig: {
|
|
||||||
url: getImportUrl,
|
|
||||||
success: handleSuccess,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
// 指定默认展开的行(根据 rowKey 属性传入行的 key 值)
|
|
||||||
const expandedKeys = ref<string[]>(['1']); // 默认展开第一行
|
|
||||||
// 定义展开行内容的渲染函数
|
|
||||||
const renderExpandedRow = (record: Record<string, any>) => {
|
|
||||||
return (
|
|
||||||
<a-descriptions column = { 2} >
|
|
||||||
<a-descriptions - item label = "身份证号" > { record.record.identityId } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "银行卡号" > { record.record.pyCard } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "工作单位" > { record.record.workName } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "开户所在地" > { record.record.bankAddress } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "单位电话" > { record.record.workPhone } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "开户行" > { record.record.bankName } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "车牌号" > { record.record.carNumber } </a-descriptions-item>
|
|
||||||
< a - descriptions - item label = "饭卡号" > { record.record.mealCard } </a-descriptions-item>
|
|
||||||
</a-descriptions>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
// 监听展开/收起事件,更新 expandedKeys
|
|
||||||
const handleExpand = (expanded: boolean, record: Record<string, any>) => {
|
|
||||||
console.log('展开/收起', expanded, record);
|
|
||||||
if (expanded) {
|
|
||||||
if (!expandedKeys.value.includes(record.id)) {
|
|
||||||
expandedKeys.value.push(record.id);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
expandedKeys.value = expandedKeys.value.filter((key) => key !== record.id);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
|
||||||
|
|
||||||
// 在组件加载时获取分组数据
|
|
||||||
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
|
||||||
|
|
||||||
onMounted(async () => {
|
|
||||||
console.log('组件已加载');
|
|
||||||
try {
|
|
||||||
const res = await getGroup();
|
|
||||||
console.log('获取分组数据成功:', res);
|
|
||||||
groupOptions.value = res.map((group) => ({
|
|
||||||
label: group.name, // 假设分组名称字段为 name
|
|
||||||
value: group.id, // 假设分组 ID 字段为 id
|
|
||||||
}));
|
|
||||||
console.log('分组数据:', groupOptions.value);
|
|
||||||
updateGroupOptions.updateGroupOptions(groupOptions.value)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('获取分组数据失败:', error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 高级查询配置
|
|
||||||
const superQueryConfig = reactive(superQuerySchema);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级查询事件
|
|
||||||
*/
|
|
||||||
function handleSuperQuery(params) {
|
|
||||||
Object.keys(params).map((k) => {
|
|
||||||
queryParam[k] = params[k];
|
|
||||||
});
|
|
||||||
reload();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 新增事件
|
|
||||||
*/
|
|
||||||
function handleAdd() {
|
|
||||||
openModal(true, {
|
|
||||||
isUpdate: false,
|
|
||||||
showFooter: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 编辑事件
|
|
||||||
*/
|
|
||||||
function handleEdit(record: Recordable) {
|
|
||||||
openModal(true, {
|
|
||||||
record,
|
|
||||||
isUpdate: true,
|
|
||||||
showFooter: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 详情
|
|
||||||
*/
|
|
||||||
function handleDetail(record: Recordable) {
|
|
||||||
openModal(true, {
|
|
||||||
record,
|
|
||||||
isUpdate: true,
|
|
||||||
showFooter: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 删除事件
|
|
||||||
*/
|
|
||||||
async function handleDelete(record) {
|
|
||||||
await deleteOne({ id: record.id }, handleSuccess);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 批量删除事件
|
|
||||||
*/
|
|
||||||
async function batchHandleDelete() {
|
|
||||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 成功回调
|
|
||||||
*/
|
|
||||||
function handleSuccess() {
|
|
||||||
(selectedRowKeys.value = []) && reload();
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 操作栏
|
|
||||||
*/
|
|
||||||
function getTableAction(record) {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
label: '编辑',
|
|
||||||
onClick: handleEdit.bind(null, record),
|
|
||||||
},
|
|
||||||
];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 下拉操作栏
|
|
||||||
*/
|
|
||||||
function getDropDownAction(record) {
|
|
||||||
return [
|
|
||||||
{
|
|
||||||
label: '详情',
|
|
||||||
onClick: handleDetail.bind(null, record),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '删除',
|
|
||||||
popConfirm: {
|
|
||||||
title: '是否确认删除',
|
|
||||||
confirm: handleDelete.bind(null, record),
|
|
||||||
placement: 'topLeft',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
];
|
exportConfig: {
|
||||||
}
|
name: '外校老师管理',
|
||||||
|
url: getExportUrl,
|
||||||
|
params: queryParam,
|
||||||
|
},
|
||||||
|
importConfig: {
|
||||||
|
url: getImportUrl,
|
||||||
|
success: handleSuccess,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
// 指定默认展开的行(根据 rowKey 属性传入行的 key 值)
|
||||||
|
const expandedKeys = ref<string[]>(['1']); // 默认展开第一行
|
||||||
|
// 定义展开行内容的渲染函数
|
||||||
|
const renderExpandedRow = (record: Record<string, any>) => {
|
||||||
|
return (
|
||||||
|
<a-descriptions column={2}>
|
||||||
|
<a-descriptions-item label="身份证号"> {record.record.identityId} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="银行卡号"> {record.record.pyCard} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="工作单位"> {record.record.workName} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="开户所在地"> {record.record.bankAddress} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="单位电话"> {record.record.workPhone} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="开户行"> {record.record.bankName} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="车牌号"> {record.record.carNumber} </a-descriptions-item>
|
||||||
|
<a-descriptions-item label="饭卡号"> {record.record.mealCard} </a-descriptions-item>
|
||||||
|
</a-descriptions>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
// 监听展开/收起事件,更新 expandedKeys
|
||||||
|
const handleExpand = (expanded: boolean, record: Record<string, any>) => {
|
||||||
|
console.log('展开/收起', expanded, record);
|
||||||
|
if (expanded) {
|
||||||
|
if (!expandedKeys.value.includes(record.id)) {
|
||||||
|
expandedKeys.value.push(record.id);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
expandedKeys.value = expandedKeys.value.filter((key) => key !== record.id);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||||
|
|
||||||
|
// 在组件加载时获取分组数据
|
||||||
|
const groupOptions = ref<{ label: string; value: number }[]>([]);
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
console.log('组件已加载');
|
||||||
|
try {
|
||||||
|
const res = await getGroup();
|
||||||
|
console.log('获取分组数据成功:', res);
|
||||||
|
groupOptions.value = res.map((group) => ({
|
||||||
|
label: group.name, // 假设分组名称字段为 name
|
||||||
|
value: group.id, // 假设分组 ID 字段为 id
|
||||||
|
}));
|
||||||
|
console.log('分组数据:', groupOptions.value);
|
||||||
|
updateGroupOptions.updateGroupOptions(groupOptions.value);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取分组数据失败:', error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 高级查询配置
|
||||||
|
const superQueryConfig = reactive(superQuerySchema);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 高级查询事件
|
||||||
|
*/
|
||||||
|
function handleSuperQuery(params) {
|
||||||
|
Object.keys(params).map((k) => {
|
||||||
|
queryParam[k] = params[k];
|
||||||
|
});
|
||||||
|
reload();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新增事件
|
||||||
|
*/
|
||||||
|
function handleAdd() {
|
||||||
|
openModal(true, {
|
||||||
|
isUpdate: false,
|
||||||
|
showFooter: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑事件
|
||||||
|
*/
|
||||||
|
function handleEdit(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
function handleDetail(record: Recordable) {
|
||||||
|
openModal(true, {
|
||||||
|
record,
|
||||||
|
isUpdate: true,
|
||||||
|
showFooter: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除事件
|
||||||
|
*/
|
||||||
|
async function handleDelete(record) {
|
||||||
|
await deleteOne({ id: record.id }, handleSuccess);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 批量删除事件
|
||||||
|
*/
|
||||||
|
async function batchHandleDelete() {
|
||||||
|
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 成功回调
|
||||||
|
*/
|
||||||
|
function handleSuccess() {
|
||||||
|
(selectedRowKeys.value = []) && reload();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 操作栏
|
||||||
|
*/
|
||||||
|
function getTableAction(record) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '编辑',
|
||||||
|
onClick: handleEdit.bind(null, record),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 下拉操作栏
|
||||||
|
*/
|
||||||
|
function getDropDownAction(record) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: '详情',
|
||||||
|
onClick: handleDetail.bind(null, record),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: '删除',
|
||||||
|
popConfirm: {
|
||||||
|
title: '是否确认删除',
|
||||||
|
confirm: handleDelete.bind(null, record),
|
||||||
|
placement: 'topLeft',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|
Loading…
Reference in New Issue