|
@@ -0,0 +1,378 @@
|
|
|
+import { getAccountTypeList } from '@/services/api/institution'
|
|
|
+import { getProjectTypeList } from '@/services/api/project'
|
|
|
+import { Link } from 'umi'
|
|
|
+import { action } from '@formily/reactive'
|
|
|
+import type { GeneralField } from '@formily/core'
|
|
|
+import consts from './consts'
|
|
|
+
|
|
|
+// 项目schema
|
|
|
+export const projectSchema = {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ layout: {
|
|
|
+ type: 'void',
|
|
|
+ 'x-component': 'FormLayout',
|
|
|
+ 'x-component-props': {
|
|
|
+ labelCol: 6,
|
|
|
+ wrapperCol: 8,
|
|
|
+ layout: 'horizontal'
|
|
|
+ },
|
|
|
+ properties: {
|
|
|
+ ID: {
|
|
|
+ type: 'string',
|
|
|
+ title: 'ID',
|
|
|
+ 'x-display': 'none',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 0
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ type: 'string',
|
|
|
+ title: '名称',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 1
|
|
|
+ },
|
|
|
+ shortName: {
|
|
|
+ type: 'string',
|
|
|
+ title: '项目简称',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 2
|
|
|
+ },
|
|
|
+ projectTypeID: {
|
|
|
+ type: 'string',
|
|
|
+ title: '项目类型',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Select',
|
|
|
+ 'x-index': 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 企事业单位
|
|
|
+export const institutionSchema = {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ ID: {
|
|
|
+ type: 'string',
|
|
|
+ title: 'ID',
|
|
|
+ 'x-display': 'none',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 0
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ type: 'string',
|
|
|
+ title: '企事业单位名称',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-decorator-props': {
|
|
|
+ // labelWidth: '131px'
|
|
|
+ labelCol: 4
|
|
|
+ },
|
|
|
+ 'x-index': 1
|
|
|
+ },
|
|
|
+ layout: {
|
|
|
+ type: 'void',
|
|
|
+ 'x-component': 'FormLayout',
|
|
|
+ 'x-component-props': {
|
|
|
+ labelCol: 8,
|
|
|
+ wrapperCol: 16,
|
|
|
+ layout: 'horizontal'
|
|
|
+ },
|
|
|
+ properties: {
|
|
|
+ gird: {
|
|
|
+ type: 'void',
|
|
|
+ 'x-component': 'FormGrid',
|
|
|
+ 'x-component-props': {
|
|
|
+ minColumns: 1,
|
|
|
+ maxColumns: 2,
|
|
|
+ columnGap: 0
|
|
|
+ },
|
|
|
+ properties: {
|
|
|
+ acronym: {
|
|
|
+ type: 'string',
|
|
|
+ title: '企事业单位简称',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 2
|
|
|
+ },
|
|
|
+ enterpriseCode: {
|
|
|
+ type: 'string',
|
|
|
+ title: '企业编码',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 3
|
|
|
+ },
|
|
|
+ phone: {
|
|
|
+ type: 'string',
|
|
|
+ title: '办公电话',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 4
|
|
|
+ },
|
|
|
+ address: {
|
|
|
+ type: 'string',
|
|
|
+ title: '地址',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 5
|
|
|
+ },
|
|
|
+ fax: {
|
|
|
+ type: 'string',
|
|
|
+ title: '传真号码',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 6
|
|
|
+ },
|
|
|
+ organizationCode: {
|
|
|
+ type: 'string',
|
|
|
+ title: '组织架构代码',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 7
|
|
|
+ },
|
|
|
+ bank: {
|
|
|
+ type: 'string',
|
|
|
+ title: '银行',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 8
|
|
|
+ },
|
|
|
+ idCard: {
|
|
|
+ type: 'string',
|
|
|
+ title: '身份证号码',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 9
|
|
|
+ },
|
|
|
+ bankAccount: {
|
|
|
+ type: 'string',
|
|
|
+ title: '银行账号',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 10
|
|
|
+ },
|
|
|
+ legalPerson: {
|
|
|
+ type: 'string',
|
|
|
+ title: '法人代表',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 11
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 人员信息
|
|
|
+export const staffSchema = {
|
|
|
+ type: 'object',
|
|
|
+ properties: {
|
|
|
+ layout: {
|
|
|
+ type: 'void',
|
|
|
+ 'x-component': 'FormLayout',
|
|
|
+ 'x-component-props': {
|
|
|
+ labelCol: 4,
|
|
|
+ wrapperCol: 8,
|
|
|
+ layout: 'horizontal'
|
|
|
+ },
|
|
|
+ properties: {
|
|
|
+ ID: {
|
|
|
+ type: 'string',
|
|
|
+ title: 'ID',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-display': 'none',
|
|
|
+ 'x-index': 0
|
|
|
+ },
|
|
|
+ enable: {
|
|
|
+ type: 'boolean',
|
|
|
+ title: '账号启用',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Switch',
|
|
|
+ 'x-index': 1
|
|
|
+ },
|
|
|
+ isCreated: {
|
|
|
+ type: 'boolean',
|
|
|
+ title: '项目创建人',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Switch',
|
|
|
+ 'x-index': 2
|
|
|
+ },
|
|
|
+ institutionID: {
|
|
|
+ type: 'string',
|
|
|
+ title: '事业单位',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 3
|
|
|
+ },
|
|
|
+ account: {
|
|
|
+ type: 'string',
|
|
|
+ title: '账号',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 4
|
|
|
+ },
|
|
|
+ name: {
|
|
|
+ type: 'string',
|
|
|
+ title: '姓名',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 5
|
|
|
+ },
|
|
|
+ password: {
|
|
|
+ type: 'string',
|
|
|
+ title: '密码',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 6
|
|
|
+ },
|
|
|
+ accountType: {
|
|
|
+ type: 'string',
|
|
|
+ title: '账号类型',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Select',
|
|
|
+ 'x-index': 7,
|
|
|
+ enum: [],
|
|
|
+ 'x-reactions': ['{{useAsyncDataSource(loadAccountTypeData)}}']
|
|
|
+ },
|
|
|
+ organizationalStructureID: {
|
|
|
+ type: 'string',
|
|
|
+ title: '组织架构',
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 8
|
|
|
+ },
|
|
|
+ gender: {
|
|
|
+ type: 'string',
|
|
|
+ title: '性别',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Select',
|
|
|
+ 'x-index': 9,
|
|
|
+ enum: [
|
|
|
+ { label: '男', value: 0 },
|
|
|
+ { label: '女', value: 1 }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ phone: {
|
|
|
+ type: 'string',
|
|
|
+ title: '手机',
|
|
|
+ required: true,
|
|
|
+ 'x-decorator': 'FormItem',
|
|
|
+ 'x-component': 'Input',
|
|
|
+ 'x-index': 10
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/** 组合schema */
|
|
|
+export const connectSchema = (initialSchemas, schemas) => {
|
|
|
+ if (!schemas) return initialSchemas
|
|
|
+ let startIdx = Object.keys(initialSchemas.properties).length
|
|
|
+ let i = 0
|
|
|
+ const b = { ...initialSchemas }
|
|
|
+
|
|
|
+ if ('layout' in initialSchemas.properties) {
|
|
|
+ startIdx = Object.keys(initialSchemas.properties.layout.properties).length
|
|
|
+ for (const key in schemas) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(schemas, key)) {
|
|
|
+ const schema = schemas[key]
|
|
|
+ schema['x-index'] = startIdx + i
|
|
|
+ i++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const properties = Object.assign(b.properties.layout.properties, schemas)
|
|
|
+ b.properties.layout.properties = properties
|
|
|
+ } else {
|
|
|
+ for (const key in schemas) {
|
|
|
+ if (Object.prototype.hasOwnProperty.call(schemas, key)) {
|
|
|
+ const schema = schemas[key]
|
|
|
+ schema['x-index'] = startIdx + i
|
|
|
+ i++
|
|
|
+ }
|
|
|
+ }
|
|
|
+ b.properties = { ...schemas, ...b.properties }
|
|
|
+ }
|
|
|
+ return b
|
|
|
+}
|
|
|
+
|
|
|
+export const generateFieldIsCreated = (field: GeneralField) => {
|
|
|
+ if (field.query('ID')?.get('value')) {
|
|
|
+ if (!field.value) {
|
|
|
+ field.setDecoratorProps({
|
|
|
+ addonAfter: (
|
|
|
+ <span>
|
|
|
+ 开启后,该账号添加成功后将成为 "
|
|
|
+ <Link to="/project/created" className="text-primary">
|
|
|
+ 项目创建人
|
|
|
+ </Link>
|
|
|
+ "
|
|
|
+ </span>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ field.setPattern('readPretty')
|
|
|
+ field.setDecoratorProps({
|
|
|
+ addonAfter: (
|
|
|
+ <div>
|
|
|
+ <span className="text-red-500">需要移除请进入</span>"
|
|
|
+ <Link to="/project/created" className="text-primary">
|
|
|
+ 项目创建人
|
|
|
+ </Link>
|
|
|
+ "
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export const useAsyncDataSource = service => field => {
|
|
|
+ field.loading = true
|
|
|
+ service(field).then(
|
|
|
+ action.bound(data => {
|
|
|
+ field.dataSource = data
|
|
|
+ field.loading = false
|
|
|
+ })
|
|
|
+ )
|
|
|
+}
|
|
|
+
|
|
|
+/** 加载账号类型 */
|
|
|
+export const loadAccountTypeData = async () => {
|
|
|
+ const { code = -1, data = [] } = await getAccountTypeList()
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ return data.map(item => ({ label: item.name, value: item.value }))
|
|
|
+ }
|
|
|
+ return []
|
|
|
+}
|
|
|
+
|
|
|
+/** 加载项目类型 */
|
|
|
+export const loadProjectTypeData = async () => {
|
|
|
+ const { code = -1, data = [] } = await getProjectTypeList()
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
+ return data.map(item => ({ label: item.name, value: item.ID }))
|
|
|
+ }
|
|
|
+ return []
|
|
|
+}
|