|
|
@@ -2,164 +2,88 @@
|
|
|
* Created by RaoMeng on 2020/12/11
|
|
|
* Desc: 通用表单接口数据处理
|
|
|
*/
|
|
|
-import { Toast } from 'antd-mobile'
|
|
|
import { isObjEmpty } from './common.util'
|
|
|
import BillGroupModel from '../../model/common/BillGroupModel'
|
|
|
import BillModel from '../../model/common/BillModel'
|
|
|
|
|
|
-const testForm = [
|
|
|
- {
|
|
|
- 'groupTitle': '基础信息',
|
|
|
- 'isForm': true,
|
|
|
- 'keyField': 'base',
|
|
|
- 'groupCaller': 'test',
|
|
|
- 'fieldList': [
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '姓名',
|
|
|
- 'value': '饶猛',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '性别',
|
|
|
- 'value': '男',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '年龄',
|
|
|
- 'value': '25',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '籍贯',
|
|
|
- 'value': '江西',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '公司',
|
|
|
- 'value': '深圳市优软科技有限公司',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '学校',
|
|
|
- 'value': '南昌大学',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- {
|
|
|
- 'appwidth': 100,
|
|
|
- 'length': 100,
|
|
|
- 'isdefault': true,
|
|
|
- 'caption': '高中',
|
|
|
- 'value': '金溪一中',
|
|
|
- 'display': '饶猛',
|
|
|
- 'type': 'S',
|
|
|
- 'readOnly': true,
|
|
|
- 'field': 'name',
|
|
|
- 'defValue': '',
|
|
|
- 'allowBlank': true,
|
|
|
- 'localDatas': [],
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
-]
|
|
|
-
|
|
|
-export function analysisFormData () {
|
|
|
+export function analysisFormData (formData, isDetail) {
|
|
|
let billGroupList = []
|
|
|
- if (!isObjEmpty(testForm)) {
|
|
|
- testForm.forEach((groupItem, groupIndex) => {
|
|
|
- let billGroup = new BillGroupModel()
|
|
|
- billGroup.group = groupItem.groupTitle
|
|
|
- billGroup.isForm = groupItem.isForm
|
|
|
- billGroup.keyField = groupItem.keyField
|
|
|
- billGroup.billCaller = groupItem.groupCaller
|
|
|
- billGroup.groupIndex = groupIndex
|
|
|
+ if (!isObjEmpty(formData)) {
|
|
|
+ const formList = formData.formList
|
|
|
+ const gridList = formData.gridList
|
|
|
|
|
|
- let showBillFields = [], hideBillFields = []
|
|
|
- if (!isObjEmpty(groupItem.fieldList)) {
|
|
|
- groupItem.fieldList.forEach((fieldItem, filedIndex) => {
|
|
|
- let billModel = new BillModel()
|
|
|
+ /**
|
|
|
+ * 主表数据
|
|
|
+ */
|
|
|
+ if (!isObjEmpty(formList)) {
|
|
|
+ formList.forEach((formGroup, formIndex) => {
|
|
|
+ const billGroup = getBillGroup(formGroup, billGroupList.length,
|
|
|
+ isDetail)
|
|
|
+ billGroupList.push(billGroup)
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- billModel.groupIndex = groupIndex
|
|
|
- billModel.appwidth = fieldItem.appwidth
|
|
|
- billModel.length = fieldItem.length
|
|
|
- billModel.isdefault = fieldItem.isdefault
|
|
|
- billModel.caption = fieldItem.caption
|
|
|
- billModel.type = fieldItem.type
|
|
|
- billModel.readOnly = fieldItem.readOnly ? 'T' : 'F'
|
|
|
- billModel.field = fieldItem.field
|
|
|
- billModel.value = fieldItem.value
|
|
|
- billModel.display = fieldItem.display
|
|
|
- billModel.defValue = fieldItem.defValue
|
|
|
- billModel.logicType = fieldItem.logicType
|
|
|
- billModel.allowBlank = fieldItem.allowBlank ? 'T' : 'F'
|
|
|
+ /**
|
|
|
+ * 从表数据
|
|
|
+ */
|
|
|
+ if (!isObjEmpty(gridList)) {
|
|
|
+ gridList.forEach((gridGroup, gridIndex) => {
|
|
|
+ //单个从表的明细列表
|
|
|
+ const gridDetailList = gridGroup.fieldList
|
|
|
+ if (!isObjEmpty(gridDetailList)) {
|
|
|
+ gridDetailList.forEach((gridDetail, gridDetailIndex) => {
|
|
|
+ const billGroup = getBillGroup({
|
|
|
+ ...gridGroup,
|
|
|
+ fieldList: gridDetail,
|
|
|
+ }, billGroupList.length, isDetail)
|
|
|
+ billGroupList.push(billGroup)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (billModel.isdefault) {
|
|
|
- showBillFields.push(billModel)
|
|
|
- } else {
|
|
|
- hideBillFields.push(billModel)
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ return billGroupList
|
|
|
+}
|
|
|
|
|
|
- billGroup.showBillFields = showBillFields
|
|
|
- billGroup.hideBillFields = hideBillFields
|
|
|
+export function getBillGroup (groupItem, groupIndex, isDetail) {
|
|
|
+ let billGroup = new BillGroupModel()
|
|
|
+ billGroup.group = groupItem.groupTitle
|
|
|
+ billGroup.isForm = groupItem.isForm
|
|
|
+ billGroup.keyField = groupItem.keyField
|
|
|
+ billGroup.billCaller = groupItem.groupCaller
|
|
|
+ billGroup.groupIndex = groupIndex
|
|
|
|
|
|
- billGroupList.push(billGroup)
|
|
|
+ let showBillFields = [], hideBillFields = []
|
|
|
+ if (!isObjEmpty(groupItem.fieldList)) {
|
|
|
+ groupItem.fieldList.forEach((fieldItem, filedIndex) => {
|
|
|
+ let billModel = new BillModel()
|
|
|
+
|
|
|
+ billModel.groupIndex = groupIndex
|
|
|
+ billModel.appwidth = fieldItem.appwidth
|
|
|
+ billModel.length = fieldItem.length
|
|
|
+ billModel.isdefault = fieldItem.isdefault
|
|
|
+ billModel.caption = fieldItem.caption
|
|
|
+ billModel.type = fieldItem.type
|
|
|
+ billModel.readOnly = (fieldItem.readOnly || isDetail) ? 'T' : 'F'
|
|
|
+ billModel.field = fieldItem.field
|
|
|
+ billModel.value = fieldItem.value
|
|
|
+ billModel.display = fieldItem.display
|
|
|
+ billModel.defValue = fieldItem.defValue
|
|
|
+ billModel.logicType = fieldItem.logicType
|
|
|
+ billModel.allowBlank = (fieldItem.allowBlank || isDetail) ? 'T' : 'F'
|
|
|
+ billModel.localDatas = fieldItem.localDatas
|
|
|
+
|
|
|
+ if (billModel.isdefault) {
|
|
|
+ showBillFields.push(billModel)
|
|
|
+ } else {
|
|
|
+ hideBillFields.push(billModel)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- return billGroupList
|
|
|
+ billGroup.showBillFields = showBillFields
|
|
|
+ billGroup.hideBillFields = hideBillFields
|
|
|
+
|
|
|
+ return billGroup
|
|
|
}
|