update
1.替换修改救助人员接口 2.用户管理添加专业人员和操作人员模块
This commit is contained in:
@@ -0,0 +1,397 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
import { h, ref } from 'vue';
|
||||
import { checkPassword } from '/@/hooks/checkPassword/checkPassword';
|
||||
import { getEmergencyList } from '/@/views/consult/agentManagement/agentManagement.api';
|
||||
import { allCenterApi } from '/@/views/emergency/scheduling/scheduling.api';
|
||||
import { rules } from '/@/utils/helper/validator';
|
||||
import { Image } from 'ant-design-vue';
|
||||
import { getFamaleDefaultImage, getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
import { EyeOutlined } from '@ant-design/icons-vue';
|
||||
import { ComponentType } from '/@/components/Form/src/types';
|
||||
|
||||
//列表数据
|
||||
export const columns = function (showGoodAt: boolean): BasicColumn[] {
|
||||
return [
|
||||
{
|
||||
title: '用户账号',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
fixed: 'left',
|
||||
dataIndex: 'username',
|
||||
},
|
||||
{
|
||||
title: '姓名',
|
||||
align: 'center',
|
||||
fixed: 'left',
|
||||
dataIndex: 'realname',
|
||||
},
|
||||
{
|
||||
title: '头像',
|
||||
align: 'center',
|
||||
dataIndex: 'avatar',
|
||||
width: 100,
|
||||
customRender: ({ text }) => {
|
||||
const t = text ? text.replace(',', '') : null;
|
||||
return h(Image, {
|
||||
placeholder: true,
|
||||
src: getFileAccessHttpUrl(t),
|
||||
height: 50,
|
||||
width: 50,
|
||||
fallback: getFamaleDefaultImage(''),
|
||||
previewMask: () => {
|
||||
return h(EyeOutlined, {
|
||||
style: {
|
||||
color: 'white',
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '所属应急中心',
|
||||
align: 'center',
|
||||
dataIndex: 'centerName',
|
||||
},
|
||||
{
|
||||
title: '职称',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
dataIndex: 'post_dictText',
|
||||
},
|
||||
{
|
||||
title: '毕业院校',
|
||||
align: 'center',
|
||||
dataIndex: 'school',
|
||||
},
|
||||
{
|
||||
title: '学历',
|
||||
align: 'center',
|
||||
dataIndex: 'edu_dictText',
|
||||
},
|
||||
{
|
||||
title: '擅长症状',
|
||||
align: 'center',
|
||||
dataIndex: 'goodAt',
|
||||
ifShow: showGoodAt,
|
||||
},
|
||||
];
|
||||
};
|
||||
//查询数据
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
label: '姓名',
|
||||
field: 'name',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '所属应急中心',
|
||||
field: 'centerId',
|
||||
component: 'ApiSelect',
|
||||
componentProps: {
|
||||
//@ts-ignore
|
||||
api: allCenterApi,
|
||||
labelField: 'centerName',
|
||||
valueField: 'id',
|
||||
immediate: true,
|
||||
resultField: 'records',
|
||||
showSearch: true,
|
||||
filterOption: (input: string, option: any): boolean => {
|
||||
const str: string = input?.trim()?.toLowerCase();
|
||||
return option.label.toLowerCase().indexOf(str) >= 0;
|
||||
},
|
||||
getPopupContainer: () => document.body,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
//表单数据
|
||||
// @ts-ignore
|
||||
export const formSchema = function (showGoodAt: boolean): FormSchema[] {
|
||||
return [
|
||||
// 主键Id
|
||||
{
|
||||
label: '',
|
||||
field: 'userId',
|
||||
show: false,
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '用户账号',
|
||||
field: 'username',
|
||||
component: 'Input',
|
||||
componentProps: ({ formModel }) => {
|
||||
return {
|
||||
autocomplete: 'off',
|
||||
onInput: (event: Event) => {
|
||||
const target = event.target;
|
||||
formModel.username = target?.value?.replace(/[^\w]/g, '');
|
||||
},
|
||||
};
|
||||
},
|
||||
rules: [{ required: true, message: '请输入用户账号' }],
|
||||
dynamicDisabled: ({ values }) => {
|
||||
return !!values.userId;
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '头像',
|
||||
field: 'avatar',
|
||||
component: 'JImageUpload',
|
||||
required: true,
|
||||
componentProps: () => ({
|
||||
maxCount: 1,
|
||||
}),
|
||||
},
|
||||
{
|
||||
label: '密码',
|
||||
field: 'password',
|
||||
component: 'StrengthMeter',
|
||||
componentProps: {
|
||||
//@ts-ignore
|
||||
autocomplete: 'new-password',
|
||||
readOnly: true,
|
||||
onfocus: (field) => {
|
||||
field.target.readOnly = false;
|
||||
},
|
||||
},
|
||||
dynamicRules: () => {
|
||||
return [
|
||||
{
|
||||
required: true,
|
||||
validator: (_, value) => {
|
||||
const { message } = checkPassword(value);
|
||||
if (message === 'ok') {
|
||||
return Promise.resolve();
|
||||
} else {
|
||||
return Promise.reject(message);
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
];
|
||||
},
|
||||
ifShow: ({ values }) => {
|
||||
return !values.userId;
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '确认密码',
|
||||
field: 'confirmPassword',
|
||||
component: 'InputPassword',
|
||||
dynamicRules: ({ values }) => rules.confirmPassword(values, true),
|
||||
ifShow: ({ values }) => {
|
||||
return !values.userId;
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '姓名',
|
||||
field: 'realname',
|
||||
component: 'Input',
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: '所属应急中心',
|
||||
field: 'centerId',
|
||||
component: 'ApiSelect',
|
||||
required: true,
|
||||
componentProps: {
|
||||
//@ts-ignore
|
||||
api: getEmergencyList,
|
||||
params: {
|
||||
pageNo: 1,
|
||||
pageSize: 200,
|
||||
},
|
||||
labelField: 'centerName',
|
||||
valueField: 'id',
|
||||
immediate: true,
|
||||
resultField: 'records',
|
||||
showSearch: true,
|
||||
filterOption: (input: string, option: any): boolean => {
|
||||
const str: string = input?.trim()?.toLowerCase();
|
||||
return option.label.toLowerCase().indexOf(str) >= 0;
|
||||
},
|
||||
getPopupContainer: () => document.body,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '擅长症状',
|
||||
field: 'goodAt',
|
||||
component: 'InputTextArea',
|
||||
required: true,
|
||||
ifShow: showGoodAt,
|
||||
},
|
||||
{
|
||||
label: '职称',
|
||||
field: 'post',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: () => ({
|
||||
dictCode: 'z_doct_lev',
|
||||
getPopupContainer: () => document.body,
|
||||
}),
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
label: '毕业院校',
|
||||
field: 'school',
|
||||
component: 'Input',
|
||||
},
|
||||
{
|
||||
label: '学历',
|
||||
field: 'edu',
|
||||
component: 'JDictSelectTag',
|
||||
componentProps: {
|
||||
//@ts-ignore
|
||||
dictCode: 'education',
|
||||
showSearch: true,
|
||||
filterOption: (input: string, option: any): boolean => {
|
||||
const str: string = input.trim().toLowerCase();
|
||||
return option.label.toLowerCase().indexOf(str) >= 0;
|
||||
},
|
||||
getPopupContainer: () => document.body,
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '人员类型',
|
||||
field: 'type',
|
||||
component: 'Input',
|
||||
show: false,
|
||||
},
|
||||
];
|
||||
};
|
||||
|
||||
interface DetailForm extends FormSchema {
|
||||
value: string;
|
||||
customRender?: Function;
|
||||
component: ComponentType | 'Image';
|
||||
}
|
||||
|
||||
export function useDetailForm(showGoodAt: boolean) {
|
||||
const detailFormSchema = ref<DetailForm[]>([
|
||||
{
|
||||
label: '用户账号',
|
||||
field: 'username',
|
||||
component: 'Input',
|
||||
value: '',
|
||||
},
|
||||
|
||||
{
|
||||
label: '姓名',
|
||||
field: 'realname',
|
||||
component: 'Input',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '头像',
|
||||
field: 'avatar',
|
||||
component: 'Image',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '所属应急中心',
|
||||
field: 'centerName',
|
||||
component: 'Input',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '职称',
|
||||
field: 'post_dictText',
|
||||
component: 'Input',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '毕业院校',
|
||||
field: 'school',
|
||||
component: 'Input',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '学历',
|
||||
field: 'edu_dictText',
|
||||
component: 'Input',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
label: '擅长症状',
|
||||
field: 'goodAt',
|
||||
component: 'InputTextArea',
|
||||
value: '',
|
||||
ifShow: showGoodAt,
|
||||
},
|
||||
]);
|
||||
function setData(record: Recordable, list: DetailForm[], callback?: Function) {
|
||||
if (callback) {
|
||||
callback(list);
|
||||
return;
|
||||
}
|
||||
list = list.filter((item) => {
|
||||
return item.ifShow === undefined || item.ifShow;
|
||||
});
|
||||
list.forEach((item) => {
|
||||
const { field } = item;
|
||||
const isEmpty = (obj, field) => {
|
||||
if (!obj) return true;
|
||||
return obj[field] === undefined || obj[field] === null || obj[field] === '';
|
||||
};
|
||||
if (!isEmpty(record, field)) {
|
||||
if (Object.hasOwn(item, 'customRender')) {
|
||||
// @ts-ignore
|
||||
item.value = item.customRender(record);
|
||||
} else if (Object.hasOwn(item, 'slot')) {
|
||||
//@ts-ignore
|
||||
item.value = { ...record, dataIndex: field };
|
||||
} else {
|
||||
item.value = record[field] || '';
|
||||
}
|
||||
} else {
|
||||
item.value = '';
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
function getDetailSchema() {
|
||||
return detailFormSchema.value.filter((item) => {
|
||||
return item.ifShow === undefined || item.ifShow;
|
||||
});
|
||||
}
|
||||
function setDetailFormData(record: Recordable) {
|
||||
//@ts-ignore
|
||||
setData(record, getDetailSchema());
|
||||
}
|
||||
return {
|
||||
detailFormSchema,
|
||||
getDetailSchema,
|
||||
setDetailFormData,
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 流程表单调用这个方法获取formSchema
|
||||
*/
|
||||
export function getBpmFormSchema(): FormSchema[] {
|
||||
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema
|
||||
return formSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 人员类型
|
||||
*/
|
||||
export function getPersonType(t: string) {
|
||||
enum PersonType {
|
||||
'professional' = '6', //专业人员
|
||||
'operation' = '5', //操作人员
|
||||
}
|
||||
return PersonType[t];
|
||||
}
|
||||
export const week_text = (key) => {
|
||||
const type = {
|
||||
1: '星期一',
|
||||
2: '星期二',
|
||||
3: '星期三',
|
||||
4: '星期四',
|
||||
5: '星期五',
|
||||
6: '星期六',
|
||||
7: '星期日',
|
||||
};
|
||||
return type[key];
|
||||
};
|
||||
Reference in New Issue
Block a user