From 5fa3135d8c66f287389ef8d2f8b585b5210004f3 Mon Sep 17 00:00:00 2001 From: chenwei Date: Tue, 27 Aug 2024 14:37:01 +0800 Subject: [PATCH] 支持省市区经纬度选择版本 --- frontend/manage/src/components/form/PropertyPanel.vue | 2735 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 1512 insertions(+), 1223 deletions(-) diff --git a/frontend/manage/src/components/form/PropertyPanel.vue b/frontend/manage/src/components/form/PropertyPanel.vue index a7a80d1..41b7cba 100644 --- a/frontend/manage/src/components/form/PropertyPanel.vue +++ b/frontend/manage/src/components/form/PropertyPanel.vue @@ -364,6 +364,201 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + import('@/components/selector/EipSysTypeSelector.vue') const DynamicControlDialog = () => import('@/components/form/customView/DynamicControlDialog.vue') - export default { name: 'property-panel', - props: [ - // 'data', - 'boDefData', - 'formData', - 'mainBoFields', - 'subTables', - 'sunTablesMap', - 'widgetForm', - 'handleType' - ], + components: { LayoutProperty, AdvancedProperty, @@ -796,6 +981,18 @@ export default { SubmitVerificationDialog, DynamicControlDialog }, + + props: [ + // 'data', + 'boDefData', + 'formData', + 'mainBoFields', + 'subTables', + 'sunTablesMap', + 'widgetForm', + 'handleType' + ], + data() { return { formCollapseActiveNames: 'formBasic', @@ -900,1349 +1097,1441 @@ export default { allModelingData: [] } }, + computed: { ...mapState({ data: state => state.form.selectWidget }) }, - created() { - this.field = this.data - const me_ = this - //表单初始化时收集无属性控件字段 - WidgetFormBus.$off('initNoAttrField') - WidgetFormBus.$on('initNoAttrField', obj => { - if ( - (this.isNoAttrField(obj) || this.isAllowNoAttributes(obj)) && - obj.tableName - ) { - me_.noAttrFieldListChange(obj, false) - } - }) - if (!this.formData.formSetting.display) { - this.formData.formSetting = JSON.stringify(this.formSetting) - } - }, - methods: { - confirmDynamic(data) { - this.$set(this.widgetFormData, 'globalDynamicControl', data) - }, - // 显示动态控件配置页面 - showDynamicDialog() { - this.$refs.dynamicControlRef.showDialog(this.widgetFormData) - }, - ...mapMutations({ - setSelectWidget: 'form/setSelectWidget' // 设置当前选中控件 - }), - getTableLayoutOfControlKeys() { - let keys = [] - if (this.widgetForm.list && this.widgetForm.list.length) { - this.widgetForm.list.map(item => { - if (item.isLayout && item.ctrlType == 'table') { - item.rows.map(it => { - if (it.cols && it.cols.length) { - it.cols.map(col => { - if (col.list && col.list.length) { - col.list.map(list => { - keys.push(list.key) - }) - } - }) - } - }) - } - }) - } - return keys - }, - getSubtableType(type) { - this.subTableLayoutType = type + + watch: { + data(val) { + this.field = val }, - setTableFieldsChildren(data, ctrlType) { - if (['checkbox', 'radio', 'select'].includes(ctrlType)) { - const copyDate = JSON.parse(JSON.stringify(data)) - copyDate.map(item => { - const options = item.children.filter( - it => it.dataType !== 'number' && it.dataType !== 'date' - ) - this.$set(item, 'children', options) - }) - this.tableFields = copyDate - } - }, - //重置表单配置信息 - formSettingReset() { - this.formSetting.align = 'right' - this.formSetting.customColon = false - this.formSetting.fontColor = 'rgb(150, 151, 153)' - this.formSetting.display = 'block' - this.formSetting.roInputDisplayMode = 'text' - this.formSetting.labelPosition = false - }, - //打开表单配置弹框 - formSettingClick() { - if (this.formData.formSetting) { - this.formSetting = { - ...this.formSetting, - ...JSON.parse(this.formData.formSetting) + field: { + handler(val) { + // 下拉框 多选isMultiple 属性废弃 使用options.multiple属性 为了兼容以前的代码 将isMultiple true 值赋值给 options.multiple属性 + if (val && val.ctrlType == 'select' && val.isMultiple) { + val.options.multiple = true + val.isMultiple = false } - } - this.formSettingVisible = true - }, - //保存表单配置信息 - formSettingOk() { - this.formData.formSetting = JSON.stringify(this.formSetting) - this.formSettingVisible = false - }, - //打开添加表单提交校验配置弹框 - formSubmitVerificationClick(index) { - let item = null - if (typeof index !== 'undefined' && index >= 0) { - item = this.submitVerification[index] - this.currentSubmitVerificationIndex = index - } else { - this.currentSubmitVerificationIndex = -1 - } - this.$refs.submitVerificationDialog.handleOpen(item) - }, - //保存表单提交校验配置信息 - formSubmitVerificationOk(verification) { - if (!this.submitVerification) { - this.submitVerification = [] - } - if (this.currentSubmitVerificationIndex > -1) { - this.submitVerification[ - this.currentSubmitVerificationIndex - ] = verification - } else { - this.submitVerification.push(verification) - } - }, - saveValidate() { - const this_ = this - //这里先校验字段属性,再校验表单属性 - if(this.data.ctrlType =='tag'&& !this.data.options.tag){ - return this.$message.warning('请选择标签') - } - this_.$root.$validator.validateAll('field').then(result => { - console.log(result) - if (result) { - utils - .validateForm(this, 'editBpmForm') - .then(() => { - //手机表单保存时 表单类型指定为手机表单类型 - if ( - this_.formData.formType && - this_.formData.formType != 'mobile' - ) { - this_.formData.formType = 'pc' + + if (val && ['sub', 'sun'].includes(val.parentNodeType)) { + if (val.boSubEntity || val.tableName) { + this.currentBoSubEntity = val.boSubEntity + this.tableFields = this.subTables.filter( + item => item.name === val.boSubEntity || item.name === val.tableName + ) + if (this.tableFields.length > 0) { + for (let e = 0; e < this.tableFields.length; e++) { + if (this.tableFields[e].children.length > 0) { + for ( + let w = 0; + w < this.tableFields[e].children.length; + w++ + ) { + this.tableFields[e].children[w].keyName = this.tableFields[ + e + ].children[w].name + } + } } - // this.formData.name = this.formData.formName; - const hasValidateForm = - this.$refs.advancedProperty && - this.$refs.advancedProperty.$refs.validateProperty - if ( - this.$refs.BasicsProperty && - this.$refs.BasicsProperty.validateKey() - ) { - return this.$message.warning( - '下拉树或下拉框固定选项有重复的选项值,请重新输入' - ) + } + } + + //如果是孙表,则选取子表里的孙表供选择绑定 + if ( + ((val && val.ctrlType == 'suntable') || val.ctrlType == 'sunDiv') && + this.currentBoSubEntity + ) { + this.sunTables = this.sunTablesMap[this.currentBoSubEntity] || [] + } + //如果是孙表里的控件,则找到这个一个孙表供其选择属性 + if (val && val.parentNodeType == 'sun') { + for (const subName in this.sunTablesMap) { + let sunTabs = this.sunTablesMap[subName] + if (sunTabs) { + sunTabs.forEach(sunTab => { + if (sunTab.name == this.currentBoSubEntity) { + this.tableFields = [sunTab] + } + }) + if (this.tableFields.length > 0) { + for (let o = 0; o < this.tableFields.length; o++) { + if (this.tableFields[o].children.length > 0) { + for ( + let h = 0; + h < this.tableFields[o].children.length; + h++ + ) { + this.tableFields[o].children[ + h + ].keyName = this.tableFields[o].children[h].name + } + } + } + } } - if ( - this.$refs.BasicsProperty && - this.$refs.BasicsProperty.validateFilterRange() - ) { - return this.$message.warning('请选择过滤范围') + } + } + } else { + if (this.mainBoFields.length > 0) { + for (let y = 0; y < this.mainBoFields.length; y++) { + if (this.mainBoFields[y].children.length > 0) { + for (let t = 0; t < this.mainBoFields[y].children.length; t++) { + this.mainBoFields[y].children[t].keyName = + this.mainBoFields[y].children[t].path + + '.' + + this.mainBoFields[y].children[t].name + } } - if (hasValidateForm) { - this.$refs.advancedProperty.$refs.validateProperty - .getValidateFormResult() - .then(result => { - this_.$emit('saveEnd') - }) - .catch(err => { - if (err.length > 0) { - return this.$message.warning( - `有${err.length}个字段未通过校验,请正确填写校验规则。` - ) - } - }) - } else { - this_.$emit('saveEnd') + } + } + if ( + val && + ['time', 'time-picker', 'date-picker'].includes(val.ctrlType) + ) { + this.tableFields = JSON.parse(JSON.stringify(this.mainBoFields)) + this.tableFields.forEach(table => { + if (table.children) { + let newFileds = [] + table.children = table.children.filter( + f => f.dataType != 'date' && f.dataType != 'number' + ) } }) - .catch(reason => { - let rules = reason.map(obj => { - return obj.rule - }) - if ( - this_.formData && - this_.formData.typeName && - this_.formData.name && - this_.formData.formKey - ) { - if (rules.includes('isExist')) { - this.$message.error('表单别名重复') - } else if (rules.includes('regex')) { - this.$message.error( - '只能输入字母、数字、下划线,且以字母开头' - ) - } else { - this.$message.error('表单校验不通过') - } - } else { - //获取到报错后的规则数组 - if (rules.includes('required')) { - this.$message.error('请完整填写表单内容') - } else if (rules.includes('isExist')) { - this.$message.error('表单别名重复') + } else { + this.mainBoFields.forEach(item => { + for (let q = 0; q < item.children.length; q++) { + for (let i = 0; i < item.children.length - 1 - q; i++) { + if (item.children[i].index > item.children[i + 1].index) { + let temp = item.children[i] + item.children[i] = item.children[i + 1] + item.children[i + 1] = temp + } } } - this.activeTabName = 'form' }) - } else { - let arr = this_.$root.$validator.errors.items.filter( - item => item.scope == 'field' - ) - let errorLength = arr.length - this.activeTabName = 'field' - this_.$message({ - showClose: true, - message: `有${errorLength}个字段未通过校验,请正确填写表单内容。`, - type: 'warning' - }) + this.tableFields = this.mainBoFields + } } - }) - }, - filterFields(obj) { - if ( - (obj.columnType == 'clob' || obj.dataType == 'clob') && - this.clobFieldList.indexOf(this.field.ctrlType) == -1 - ) { - return false - } - if (this.field.ctrlType == 'handSignature') { + this.setTableFieldsChildren(this.tableFields, val && val.ctrlType) + //合并数组对象 + let allModelingData = [] + let allBoData = [] + let formVarData = [] + let returnData = [] //对话框返回值选择的字段信息 主表对应主表,子表对应子表,孙表对应孙表。 + let returnTypes = ['select', 'dropdown', 'dialog'] if ( - (obj.columnType == 'clob' || obj.dataType == 'clob') && - obj.fieldName != 'id_' && - obj.fieldName != 'ref_id_' + (val && + ['suntable', 'sunDiv'].includes(val.ctrlType) && + this.currentBoSubEntity) || + (val && val.parentNodeType == 'sun') ) { - return true + this.mainBoFields.forEach(mainBoField => { + formVarData.push({...mainBoField}) + allBoData.push({...mainBoField}) + allModelingData.push({...mainBoField}) + }) + this.subTables.forEach(subTable => { + allModelingData.push({...subTable}) + let sunTabs = this.sunTablesMap[subTable.name] + if (sunTabs) { + sunTabs.forEach(sunTab => { + allModelingData.push({...sunTab}) + }) + } + }) + if (this.sunTables && this.sunTables.length > 0) { + this.sunTables.forEach(sunTable => { + if (val && val.parentNodeType == 'sun') { + if (sunTable.name == val.boSubEntity) { + allBoData.push({...sunTable}) + formVarData.push({...sunTable}) + returnData.push({...sunTable}) + } + } else { + allBoData.push({...sunTable}) + formVarData.push({...sunTable}) + returnData.push({...sunTable}) + } + }) + } + } else { + if ( + val && + val.parentNodeType != 'sub' && + returnTypes.includes(val.ctrlType) + ) { + //添加主表字段 + this.mainBoFields.forEach(mainBoField => { + returnData.push({...mainBoField}) + }) + } else if ( + val && + val.parentNodeType == 'sub' && + returnTypes.includes(val.ctrlType) + ) { + //添加子表字段 + this.subTables.forEach(subTable => { + returnData.push({...subTable}) + }) + } + //添加主表字段 + this.mainBoFields.forEach(mainBoField => { + allBoData.push({...mainBoField}) + }) + this.subTables.forEach(subTable => { + allBoData.push({...subTable}) + let sunTabs = this.sunTablesMap[subTable.name] + if (sunTabs) { + sunTabs.forEach(sunTab => { + allBoData.push({...sunTab}) + }) + } + }) + formVarData = allBoData } - return false - } - if (this.field.ctrlType == 'richText') { + //判断无属性控件 按钮 if ( - obj.columnType != 'number' && - obj.columnType != 'date' && - obj.fieldName != 'id_' && - obj.fieldName != 'ref_id_' + (this.isNoAttrField(val) || this.isAllowNoAttributes(val)) && + this.tableFields && + this.tableFields.length > 0 ) { - return true - } - return false - } - if (this.field.ctrlType == 'signature') { - //审批签章不能绑定数字和日期属性的字段 - if (obj.columnType != 'number' && obj.columnType != 'date') { - return true + if (val && !val.name) { + this.$set(val, 'name', 'c_' + val.key) + } + if (val && !val.boDefAlias) { + if (val.parentNodeType == 'sub' || val.parentNodeType == 'sun') { + const paths = this.tableFields[0].path.split('.') + this.$set(val, 'boDefAlias', paths[0]) + } else { + this.$set(val, 'boDefAlias', this.tableFields[0].boDefAlias) + } + } + if (val && !val.tableName) { + this.$set(val, 'tableName', this.tableFields[0].name) + this.changeNoAttrFile(this.tableFields[0].name) + } + this.noAttrFieldListChange(val, true) + } else if ( + val && + val.ctrlType == 'button' && + val.options.bindEventjson && + val.options.bindEventjson.isShowInput + ) { + this.noAttrFieldListChange(val, false) } - return false - } - - if (this.filterListType.indexOf(this.field.ctrlType) > -1) { + this.allModelingData = allModelingData + this.allBoData = allBoData + this.formVarData = formVarData + this.returnData = returnData + // this.$emit('update:data', val) + //通过模板生成的表单字段需更改为 建模别名.字段名 (解决2个不同的建模,但主表建模字段一样) if ( - this.field.ctrlType == 'date' && - this.field.options.dataType != 'date' + val && + val.target && + val.parentNodeType != 'sub' && + val.parentNodeType != 'sun' ) { - this.field.options.dataType = 'date' - } else if (this.field.ctrlType == 'switch') { - this.field.options.dataType = 'varchar' - } else if (this.field.ctrlType == 'number') { - this.field.options.dataType = 'number' + if (!utils.isEmpty(val.boDefAlias) && !utils.isEmpty(val.name)) { + val.target = val.boDefAlias + '.' + val.name + } } - - return obj.dataType == this.field.options.dataType - } else if (obj.nodeType == 'sub') { - return false - } else { - return true - } + }, + deep: true }, - flowComponentsFilter(item) { - if (this.field.boSubEntity) { - return ![ - 'processForecast', - 'related-process', - 'handSignature', - 'signature', - 'opinion' - ].includes(item.ctrlType) + 'field.ctrlType': { + handler(newVal, oldVal) { + if (oldVal == undefined || newVal == undefined || newVal == oldVal) { + return + } + if (!this.isWatch) { + return + } + if (newVal === 'rate') { + this.changeCtrlType(false,'rate') + } else if (['number', 'currency'].includes(oldVal)) { + if (newVal == 'date' || newVal == 'time') { + this.changeCtrlType(true) + } else { + this.changeCtrlType(false) + } + } else if (oldVal == 'date' || oldVal == 'time') { + if (newVal == 'number' || newVal == 'currency') { + this.changeCtrlType(true) + } else { + this.changeCtrlType(false) + } + } else if (newVal == 'select') { + this.changeCtrlType(false) + } else { + if (['number', 'currency'].includes(newVal)) { + if (this.field.columnType == 'number') { + this.changeCtrlType(false) + } else { + this.changeCtrlType(true) + } + } else if (newVal == 'date' || newVal == 'time') { + this.changeCtrlType(false) + } else if (newVal == 'switch') { + this.changeCtrlType(false) + } else { + this.changeCtrlType(false) + } + } + this.isWatch = false + const validateList = this.field.options.validateList + ? [ + ...this.field.options.validateList, + { + key: 'required', + name: '*必填' + } + ] + : [ + { + key: 'required', + name: '*必填' + } + ] + const hasValidateRules = + this.field.options.validateType && + this.field.options.validateType.includes('required') + this.tableFields.forEach(boData => { + boData.children.forEach((v, i) => { + if ( + hasValidateRules && + this.field.fieldPath === v.keyName && + v.isRequired + ) { + this.$set( + this.field.options, + 'validateList', + uniqueArrayObject(validateList, 'key') + ) + if (this.field.options && !this.field.options.validate) { + this.$set(this.field.options, 'validate', "'required'") + } + } + }) + }) } - return true }, - //高级控件 - filterAdvanceFields(obj) { - //子/孙表不能选择的控件类型 返回false 不能选择 - let types = ['dataView', 'formTable', 'QRcode', 'milepost', 'customChart'] - if (this.field.boSubEntity && types.includes(obj.ctrlType)) { - return false - } - if ( - (this.field.hasOwnProperty('boSubEntity') || this.isColumnLayout()) && - ['formTable', 'dataView'].includes(obj.ctrlType) - ) { - return false + widgetForm(val) { + this.widgetFormData = val + if (val.submitVerification && val.submitVerification.length > 0) { + this.submitVerification = JSON.parse( + Base64.decode(val.submitVerification) + ) + } else { + this.submitVerification = [] } - return true }, - isColumnLayout() { - let isGrid = false - const result = this.widgetForm.list.map(item => { - if (item.ctrlType === 'grid') { - return item.columns.map(it => { - return it.list.some(field => field.key === this.field.key) - }) - } - }) - if (result && result.length) { - isGrid = result.flat().filter(Boolean).length > 0 - } - return isGrid - }, - //basicsProperty调用showSelectQueryDialog - basicsPropertyShowSelectQueryDialog() { - this.showSelectQueryDialog() + submitVerification: { + handler(val) { + this.$set( + this.widgetFormData, + 'submitVerification', + Base64.encode(JSON.stringify(this.submitVerification), 'utf-8') + ) + }, + deep: true }, - //常用控件 - filterFieldsByCurrentField(obj, value) { - //获取table布局中控件的key - const controlKeys = this.getTableLayoutOfControlKeys() - if (obj.ctrlType === 'amap' && controlKeys.includes(this.field.key)) { - return false - } - //子/孙表不能选择的控件类型 返回false 不能选择 - let types = [ - 'related-process', - 'amap', - 'signature', - 'handSignature', - 'milepost', - 'customChart', - 'dataView', - 'formTable', - 'divider', - 'QRcode' - ] - let attributeType = null + // 根据绑定属性过滤空间类型 + 'field.target': { + handler(val) { + this.filterBasicComponents = basicComponents.filter(obj => { + return this.filterFieldsByCurrentField(obj, val) + }) + }, + deep: true + } + }, + + created() { + this.field = this.data + const me_ = this + //表单初始化时收集无属性控件字段 + WidgetFormBus.$off('initNoAttrField') + WidgetFormBus.$on('initNoAttrField', obj => { if ( - this.field && - this.field.boSubEntity && - types.includes(obj.ctrlType) + (this.isNoAttrField(obj) || this.isAllowNoAttributes(obj)) && + obj.tableName ) { - return false - } - if (!obj.options.dataType) { - return true - } - if (this.field && !this.field.options) { - return true - } - if (this.field && !this.field.options.dataType) { - return true - } - if (this.field && this.field.options.dataType == obj.options.dataType) { - return true - } - let dataTypes = obj.options.dataType.split('|') - if (dataTypes.indexOf('string') != -1) { - dataTypes.push('varchar') - dataTypes.push('nvarchar') + me_.noAttrFieldListChange(obj, false) } - this.tableFields.forEach(boData => { - boData.children.forEach((v, i) => { - if (v.keyName == value) { - attributeType = v.dataType + }) + if (!this.formData.formSetting.display) { + this.formData.formSetting = JSON.stringify(this.formSetting) + } + }, + + mounted() { + // 声明 + this.$validator = this.$root.$validator + // 复制高级字段列表 + this.copyAdvanceComponents = this.advanceComponents.slice() + }, + + destroyed() {}, + + methods: { + confirmDynamic(data) { + this.$set(this.widgetFormData, 'globalDynamicControl', data) + }, + // 显示动态控件配置页面 + showDynamicDialog() { + this.$refs.dynamicControlRef.showDialog(this.widgetFormData) + }, + ...mapMutations({ + setSelectWidget: 'form/setSelectWidget' // 设置当前选中控件 + }), + getTableLayoutOfControlKeys() { + let keys = [] + if (this.widgetForm.list && this.widgetForm.list.length) { + this.widgetForm.list.map(item => { + if (item.isLayout && item.ctrlType == 'table') { + item.rows.map(it => { + if (it.cols && it.cols.length) { + it.cols.map(col => { + if (col.list && col.list.length) { + col.list.map(list => { + keys.push(list.key) + }) + } + }) + } + }) } }) - }) - if (attributeType != 'number') { - return ( - attributeType != 'number' && - obj.ctrlType != 'rate' && - obj.ctrlType != 'slider' - ) } - // 数字控件不能绑定日期控件 - if (this.field.options.dataType == 'number') { - return obj.options.dataType != 'date' - } - // 日期控件不能绑定数字控件 - if (this.field.options.dataType == 'date') { - return obj.options.dataType != 'number' + return keys + }, + getSubtableType(type) { + this.subTableLayoutType = type + }, + setTableFieldsChildren(data, ctrlType) { + if (['checkbox', 'radio', 'select'].includes(ctrlType)) { + const copyDate = JSON.parse(JSON.stringify(data)) + copyDate.map(item => { + const options = item.children.filter( + it => it.dataType !== 'number' && it.dataType !== 'date' + ) + this.$set(item, 'children', options) + }) + this.tableFields = copyDate } - // 大文本类型默认多行文本和附件 - if (this.field.options.dataType == 'clob') { - if (obj.ctrlType == 'textarea' || obj.ctrlType == 'attachment') { - return true + }, + //重置表单配置信息 + formSettingReset() { + this.formSetting.align = 'right' + this.formSetting.customColon = false + this.formSetting.fontColor = 'rgb(150, 151, 153)' + this.formSetting.display = 'block' + this.formSetting.roInputDisplayMode = 'text' + this.formSetting.labelPosition = false + }, + //打开表单配置弹框 + formSettingClick() { + if (this.formData.formSetting) { + this.formSetting = { + ...this.formSetting, + ...JSON.parse(this.formData.formSetting) } } - // 字符串类型可以选择所有字段 - let charArr = ['string', 'varchar', 'nvarchar'] - - // 需要兼容以前的代码 this.field.options.dataType == "" - let result = this.field.options.dataType.split('|').filter(item => { - return dataTypes.indexOf(item) != -1 || charArr.indexOf(item) != -1 - }) - - if (result && result.length >= 1) { - return true - } - return false + this.formSettingVisible = true }, - /** - * 新旧属性的替换,并保留原有的双向绑定, - * 具体逻辑为: - * 1.新属性有值的,旧属性没有的,新增 - * 2.新属性没有的,旧属性有的,删除 - * 3.新属性有的,旧属性也有,,则保留旧属性(desc等一些特殊key 需要特殊逻辑处理) - */ - attributeToReplace(oldV, newV) { - for (let key in oldV) { - //2.新属性没有的,旧属性有的,删除 - if ( - key != 'key' && - newV[key] === undefined && - (oldV[key] || oldV[key] === '') - ) { - delete oldV[key] - } + //保存表单配置信息 + formSettingOk() { + this.formData.formSetting = JSON.stringify(this.formSetting) + this.formSettingVisible = false + }, + //打开添加表单提交校验配置弹框 + formSubmitVerificationClick(index) { + let item = null + if (typeof index !== 'undefined' && index >= 0) { + item = this.submitVerification[index] + this.currentSubmitVerificationIndex = index + } else { + this.currentSubmitVerificationIndex = -1 } - for (let key in newV) { - let value = newV[key] - //1.新属性有值的,旧属性没有的,新增 - if (oldV[key] === undefined || oldV[key] === '') { - this.$set(oldV, key, value) - //3.新属性有的,旧属性也有,,则保留旧属性(options等一些特殊key 需要特殊逻辑处理) - } else { - if (key === 'options') { - // 保留绑定的dataType - let boDataType = oldV[key].dataType - oldV[key] = value - if (boDataType) { - oldV[key].dataType = boDataType - } - } - } + this.$refs.submitVerificationDialog.handleOpen(item) + }, + //保存表单提交校验配置信息 + formSubmitVerificationOk(verification) { + if (!this.submitVerification) { + this.submitVerification = [] } - //旧属性有值 和新属性的值不一样 要重置 - for (let keys in oldV) { - if (!(oldV[keys] instanceof Object)) { - if (oldV[keys] != newV[keys] && newV[keys] != undefined) { - oldV[keys] = newV[keys] - } - } + if (this.currentSubmitVerificationIndex > -1) { + this.submitVerification[ + this.currentSubmitVerificationIndex + ] = verification + } else { + this.submitVerification.push(verification) } }, - //切换控件类型对应改变属性 - changeCtrlType(isClean,type) { - const me_ = this - const selectObj = deepmerge({}, me_.field, {clone: true}) - basicComponents.forEach(item => { - if (me_.field.ctrlType == item.ctrlType) { - // me_.field = deepmerge({}, item, { clone: true }); - let i = deepmerge({}, item, {clone: true}) - i.parentNodeType = me_.data.parentNodeType - i.boSubEntity = me_.data.boSubEntity - me_.attributeToReplace(me_.field, i) - - me_.field.key = me_.data.key - me_.field.tableName = selectObj.tableName - me_.field.target = selectObj.target - - - if (!isClean) { - me_.field.boDefId = selectObj.boDefId - me_.field.target = selectObj.target - me_.field.boAttrId = selectObj.boAttrId - me_.field.fieldPath = selectObj.fieldPath - me_.field.name = selectObj.name - me_.field.desc = selectObj.desc - me_.field.title = selectObj.desc - me_.field.entId = selectObj.entId - me_.field.boDefAlias = selectObj.boDefAlias - me_.field.tableName = selectObj.tableName - me_.field.columnType = selectObj.columnType - if(!type){ - me_.field.options.format = selectObj.options.format - me_.field.options.inputFormat = selectObj.options.format - me_.field.options.decimalDigits = selectObj.options.decimalDigits - me_.field.options.maxDecimalDigits = - selectObj.options.maxDecimalDigits - me_.field.options.max = selectObj.options.max - me_.field.options.numberMax = selectObj.options.numberMax - me_.field.options.numberMin = selectObj.options.numberMin - me_.field.options.min = selectObj.options.min - } - } - if (item.ctrlType == 'amap') { - me_.field.options.dataType = 'varchar' - } - if (item.ctrlType == 'switch') { - me_.field.options.dataType = 'varchar' - } - //me_.$emit("data:update", me_.field); - //WidgetFormBus.$emit("changeCtrlType", me_.field); - } - }) - flowComponents.forEach(item => { - if (me_.field.ctrlType == item.ctrlType) { - // me_.field = deepmerge({}, item, { clone: true }); - let i = deepmerge({}, item, {clone: true}) - i.parentNodeType = me_.data.parentNodeType - i.boSubEntity = me_.data.boSubEntity - me_.attributeToReplace(me_.field, i) - - me_.field.key = me_.data.key - if (!isClean) { - me_.field.boDefId = selectObj.boDefId - me_.field.target = selectObj.target - me_.field.boAttrId = selectObj.boAttrId - me_.field.fieldPath = selectObj.fieldPath - me_.field.name = selectObj.name - me_.field.desc = selectObj.desc - me_.field.title = selectObj.desc - me_.field.entId = selectObj.entId - me_.field.boDefAlias = selectObj.boDefAlias - me_.field.tableName = selectObj.tableName - me_.field.columnType = selectObj.columnType - me_.field.options.format = selectObj.options.format - me_.field.options.inputFormat = selectObj.options.format - me_.field.options.decimalDigits = selectObj.options.decimalDigits - me_.field.options.maxDecimalDigits = - selectObj.options.maxDecimalDigits - me_.field.options.max = selectObj.options.max - me_.field.options.numberMax = selectObj.options.numberMax - me_.field.options.numberMin = selectObj.options.numberMin - me_.field.options.min = selectObj.options.min - } - } - }) - advanceComponents.forEach(item => { - if (me_.field.ctrlType == item.ctrlType) { - // me_.field = deepmerge({}, item, { clone: true }); - let e = deepmerge({}, item, {clone: true}) - e.parentNodeType = me_.data.parentNodeType - e.boSubEntity = me_.data.boSubEntity - me_.attributeToReplace(me_.field, e) - me_.field.key = me_.data.key - // 如果是非绑定属性的 不用赋值 - if (item.options && item.options.noBindModel) { - isClean = true - } - if (!isClean) { - me_.field.boDefId = selectObj.boDefId - me_.field.target = selectObj.target - me_.field.boAttrId = selectObj.boAttrId - me_.field.fieldPath = selectObj.fieldPath - me_.field.name = selectObj.name - me_.field.desc = selectObj.desc - me_.field.title = selectObj.desc - me_.field.entId = selectObj.entId - me_.field.boDefAlias = selectObj.boDefAlias - me_.field.tableName = selectObj.tableName - me_.field.columnType = selectObj.columnType - me_.field.options.format = selectObj.format - me_.field.options.inputFormat = selectObj.format - me_.field.options.decimalDigits = selectObj.options.decimalDigits - me_.field.options.maxDecimalDigits = - selectObj.options.maxDecimalDigits - me_.field.options.max = selectObj.options.max - me_.field.options.numberMax = selectObj.options.numberMax - me_.field.options.numberMin = selectObj.options.numberMin - me_.field.options.min = selectObj.options.min - } - if (item.ctrlType == 'amap') { - me_.field.options.dataType = 'varchar' - } - // WidgetFormBus.$emit("changeCtrlType", me_.field); - } - }) - me_.$nextTick(() => { - this.setSelectWidget(me_.field) - }) - this.checkAndClearTarget() - }, - //引入脚本和样式对象保存 - includeFilesOk() { - if (!this.formHtml) { - this.$message.warning('模板HTML不能为空!') - return + saveValidate() { + const this_ = this + //这里先校验字段属性,再校验表单属性 + if(this.data.ctrlType =='tag'&& !this.data.options.tag){ + return this.$message.warning('请选择标签') } - this.dialogincluddingFileVisible = false - form - .saveFormJs({ - formId: this.formData.id, - diyJs: this.includeFiles.diyJs, - formHtml: Base64.encode(this.formHtml, 'utf-8'), - formExpand: Base64.encode(this.formExpand, 'utf-8') - }) - .then(resp => { - if (resp.state) { - this.$message.success(resp.message) - } - }) - }, - variablesClick(data) { - this.includeFiles.diyJs += data.value - }, - afterformHtml(data) { - this.formExpand = data.bpmForm.formExpand - this.formHtml = data.bpmForm.formHtml - this.includeFiles.diyJs = data.bpmForm.diyJs - }, - includdingFile() { - this.dialogincluddingFileVisible = true - this.formHtmlUrl = - '/form/form/v1/previewDesignVue?formId=' + this.formData.id - this.includeFiles = this.formData.includeFiles - ? Base64.decode(this.formData.includeFiles, 'utf-8') - : {diyFile: ' ', diyCss: ' ', diyJs: ' '} - }, - // 改变地图地址绑定的字段 设置fieldPath - changeMap(value) { - let selectObj = null - this.tableFields.forEach(boData => { - if (!selectObj) { - selectObj = boData.children.find(opt => opt.name === value) - if (selectObj) { - selectObj.boDefAlias = - boData.boDefAlias || boData.fieldPath.split('.')[0] - selectObj.tableName = boData.name - } + this_.$root.$validator.validateAll('field').then(result => { + console.log(result) + if (result) { + utils + .validateForm(this, 'editBpmForm') + .then(() => { + //手机表单保存时 表单类型指定为手机表单类型 + if ( + this_.formData.formType && + this_.formData.formType != 'mobile' + ) { + this_.formData.formType = 'pc' + } + // this.formData.name = this.formData.formName; + const hasValidateForm = + this.$refs.advancedProperty && + this.$refs.advancedProperty.$refs.validateProperty + if ( + this.$refs.BasicsProperty && + this.$refs.BasicsProperty.validateKey() + ) { + return this.$message.warning( + '下拉树或下拉框固定选项有重复的选项值,请重新输入' + ) + } + if ( + this.$refs.BasicsProperty && + this.$refs.BasicsProperty.validateFilterRange() + ) { + return this.$message.warning('请选择过滤范围') + } + if (hasValidateForm) { + this.$refs.advancedProperty.$refs.validateProperty + .getValidateFormResult() + .then(result => { + this_.$emit('saveEnd') + }) + .catch(err => { + if (err.length > 0) { + return this.$message.warning( + `有${err.length}个字段未通过校验,请正确填写校验规则。` + ) + } + }) + } else { + this_.$emit('saveEnd') + } + }) + .catch(reason => { + let rules = reason.map(obj => { + return obj.rule + }) + if ( + this_.formData && + this_.formData.typeName && + this_.formData.name && + this_.formData.formKey + ) { + if (rules.includes('isExist')) { + this.$message.error('表单别名重复') + } else if (rules.includes('regex')) { + this.$message.error( + '只能输入字母、数字、下划线,且以字母开头' + ) + } else { + this.$message.error('表单校验不通过') + } + } else { + //获取到报错后的规则数组 + if (rules.includes('required')) { + this.$message.error('请完整填写表单内容') + } else if (rules.includes('isExist')) { + this.$message.error('表单别名重复') + } + } + this.activeTabName = 'form' + }) + } else { + let arr = this_.$root.$validator.errors.items.filter( + item => item.scope == 'field' + ) + let errorLength = arr.length + this.activeTabName = 'field' + this_.$message({ + showClose: true, + message: `有${errorLength}个字段未通过校验,请正确填写表单内容。`, + type: 'warning' + }) } }) - this.field.options.locationPath = selectObj.path + '.' + selectObj.name }, - // 改变绑定的字段 设置fieldPath - change(value) { - let selectObj = null - this.fieldIndexData = {} - this.tableFields.forEach(boData => { - boData.children.forEach((v, i) => { - let keyName = v.name - if (value.indexOf('.') != -1) { - keyName = v.path + '.' + v.name - } - if (v.isRequired && keyName == value) { - if (!this.fieldIndexData.fieldName) { - this.fieldIndexData.fieldName = v.fieldName - this.fieldIndexData.index = i - } - } - }) - if (!selectObj) { - selectObj = boData.children.find(opt => opt.name === value) - if (value.indexOf('.') != -1) { - selectObj = boData.children.find( - opt => opt.path + '.' + opt.name === value - ) - } - - if (selectObj) { - selectObj.boDefAlias = - boData.boDefAlias || boData.path.split('.')[0] - selectObj.tableName = boData.name - } + filterFields(obj) { + if ( + (obj.columnType == 'clob' || obj.dataType == 'clob') && + this.clobFieldList.indexOf(this.field.ctrlType) == -1 + ) { + return false + } + if (this.field.ctrlType == 'handSignature') { + if ( + (obj.columnType == 'clob' || obj.dataType == 'clob') && + obj.fieldName != 'id_' && + obj.fieldName != 'ref_id_' + ) { + return true } - }) - - if (!selectObj) { - if (this.field.parentNodeType == 'sub') { - this.field.fieldPath = 'item.' + value - this.field.name = 'item.' + value - } else { - this.$message.warning('只允许子表绑定虚拟字段') + return false + } + if (this.field.ctrlType == 'richText') { + if ( + obj.columnType != 'number' && + obj.columnType != 'date' && + obj.fieldName != 'id_' && + obj.fieldName != 'ref_id_' + ) { + return true } - return + return false } - - this.field.boDefId = selectObj.boDefId - this.field.boAttrId = selectObj.id - if (this.field.parentNodeType == 'sub') { - this.field.fieldPath = 'item.' + selectObj.name - } else { - this.field.fieldPath = selectObj.path + '.' + selectObj.name + if (this.field.ctrlType == 'signature') { + //审批签章不能绑定数字和日期属性的字段 + if (obj.columnType != 'number' && obj.columnType != 'date') { + return true + } + return false } - this.field.options.dataType = selectObj.dataType - - this.field.name = selectObj.name - this.field.desc = selectObj.desc - this.field.title = selectObj.desc - this.field.entId = selectObj.entId - this.field.boDefAlias = selectObj.boDefAlias - this.field.tableName = selectObj.tableName - this.field.columnType = selectObj.columnType - if (selectObj.dataType == 'date') { - this.field.options.format = selectObj.format - this.field.options.inputFormat = selectObj.format - } else if (selectObj.dataType == 'number') { - //如果为评分组件则默认最大值为5 - if (this.field.ctrlType === 'rate') { - this.field.options.max = Number(this.field.options.max) - } else { - this.field.options.maxDecimalDigits = selectObj.decimalLen - this.field.options.decimalDigits = selectObj.decimalLen - this.field.options.max = Number(''.padStart(selectObj.charLen, '9')) - this.field.options.numberMax = Number( - ''.padStart(selectObj.charLen, '9') - ) - this.field.options.numberMin = -Number( - ''.padStart(selectObj.charLen, '9') - ) - this.field.options.min = -Number(''.padStart(selectObj.charLen, '9')) + if (this.filterListType.indexOf(this.field.ctrlType) > -1) { + if ( + this.field.ctrlType == 'date' && + this.field.options.dataType != 'date' + ) { + this.field.options.dataType = 'date' + } else if (this.field.ctrlType == 'switch') { + this.field.options.dataType = 'varchar' + } else if (this.field.ctrlType == 'number') { + this.field.options.dataType = 'number' } + + return obj.dataType == this.field.options.dataType + } else if (obj.nodeType == 'sub') { + return false + } else { + return true + } + }, + flowComponentsFilter(item) { + if (this.field.boSubEntity) { + return ![ + 'processForecast', + 'related-process', + 'handSignature', + 'signature', + 'opinion' + ].includes(item.ctrlType) + } + return true + }, + //高级控件 + filterAdvanceFields(obj) { + //子/孙表不能选择的控件类型 返回false 不能选择 + let types = ['dataView', 'formTable', 'QRcode', 'milepost', 'customChart'] + if (this.field.boSubEntity && types.includes(obj.ctrlType)) { + return false } - // bo属性中设置了必填 且 当前控件的校验规则为空 if ( - selectObj.isRequired == '1' && - (!this.field.options.validateList || - this.field.options.validateList.length == 0) + (this.field.hasOwnProperty('boSubEntity') || this.isColumnLayout()) && + ['formTable', 'dataView'].includes(obj.ctrlType) ) { - this.$set(this.field.options, 'validateList', [ - { - key: 'required', - name: '*必填' - } - ]) + return false } - this.$forceUpdate() + return true }, - //给无属性控件设置关联ent属性 - changeNoAttrFile(value) { - let _this = this - this.tableFields.forEach(ent => { - if (ent.name == value) { - _this.$set(_this.field, 'entId', ent.id) - _this.$set(_this.field, 'boDefId', ent.boDefId) - if (!_this.field.boDefAlias) { - _this.$set(_this.field, 'boDefAlias', ent.boDefAlias) - } - this.$forceUpdate() - _this.noAttrFieldListChange(_this.field, true) + isColumnLayout() { + let isGrid = false + const result = this.widgetForm.list.map(item => { + if (item.ctrlType === 'grid') { + return item.columns.map(it => { + return it.list.some(field => field.key === this.field.key) + }) } }) + if (result && result.length) { + isGrid = result.flat().filter(Boolean).length > 0 + } + return isGrid }, - //取消无属性设置 - changeNoBindModel() { - if (this.field.options.noBindModel) { - this.$set(this.field, 'name', 'c_' + this.field.key) - this.noAttrFieldListChange(this.field, true) - } else if ( - !this.field.options.noBindModel && - this.noAttrFieldList && - this.noAttrFieldList.length > 0 + //basicsProperty调用showSelectQueryDialog + basicsPropertyShowSelectQueryDialog() { + this.showSelectQueryDialog() + }, + //常用控件 + filterFieldsByCurrentField(obj, value) { + //获取table布局中控件的key + const controlKeys = this.getTableLayoutOfControlKeys() + if (obj.ctrlType === 'amap' && controlKeys.includes(this.field.key)) { + return false + } + //子/孙表不能选择的控件类型 返回false 不能选择 + let types = [ + 'related-process', + 'amap', + 'signature', + 'handSignature', + 'milepost', + 'customChart', + 'dataView', + 'formTable', + 'divider', + 'QRcode' + ] + let attributeType = null + if ( + this.field && + this.field.boSubEntity && + types.includes(obj.ctrlType) ) { - this.$set(this.field, 'name', '') - this.noAttrFieldListChange(this.field, false) + return false } - if (this.field.ctrlType === 'number') { - this.setDefaultValueForDigitalControl() + if (!obj.options.dataType) { + return true } - }, - setDefaultValueForDigitalControl() { - this.field.options.max = 999999999 - this.field.options.numberMax = 999999999 - this.field.options.numberMin = -999999999 - this.field.options.min = 0 - }, - isChangeWatch() { - this.isWatch = true - // - // - // 切换时 处理合计 - if (this.widgetForm.list && this.widgetForm.list.length > 0) { - this.widgetForm.list.forEach((item, index) => { - if (item.name === this.field.tableName) { - item.CombinedColumnList && - item.CombinedColumnList.forEach((ComItem, ComIndex) => { - if (ComItem.columnField === this.field.name) { - if ( - this.field.ctrlType != 'number' || - selitem.columnType != 'number' - ) { - item.CombinedColumnList.splice(ComIndex, 1) - } - } - }) - this.$set( - this.widgetForm.list[index], - 'CombinedColumnListJson', - Base64.encode(JSON.stringify(item.CombinedColumnList), 'utf-8') - ) - } - }) + if (this.field && !this.field.options) { + return true } - }, - //判断并清空绑定属性 - checkAndClearTarget() { - if (!utils.isEmpty(this.field.target) && this.tableFields.length > 0) { - this.tableFields.forEach((item, i) => { - var items = - this.tableFields[i].children && - this.tableFields[i].children.filter(obj => { - return this.field.target == obj['keyName'] - }) - - if (!items || items.length <= 0) { - this.field.target = '' - } - if (!this.filterFields(items[0])) { - this.field.target = '' + if (this.field && !this.field.options.dataType) { + return true + } + if (this.field && this.field.options.dataType == obj.options.dataType) { + return true + } + let dataTypes = obj.options.dataType.split('|') + if (dataTypes.indexOf('string') != -1) { + dataTypes.push('varchar') + dataTypes.push('nvarchar') + } + this.tableFields.forEach(boData => { + boData.children.forEach((v, i) => { + if (v.keyName == value) { + attributeType = v.dataType } }) + }) + if (attributeType != 'number') { + return ( + attributeType != 'number' && + obj.ctrlType != 'rate' && + obj.ctrlType != 'slider' + ) } - }, - editI18nMessage(after) { - this.i18nMessageKey = this.field.fieldPath || this.field.path - - if (this.createKeyMap[this.field.ctrlType]) { - this.i18nMessageKey = - this.formData.formKey + - '.' + - this.field.ctrlType + - Math.random() * 5000 - } - if (this.i18nMessageKey && after) { - this.i18nMessageKey += after + // 数字控件不能绑定日期控件 + if (this.field.options.dataType == 'number') { + return obj.options.dataType != 'date' } - this.$refs.i18nMessageEdit.handleOpen() - }, - afterSaveI18n(data) { - data.key = data.key.replace('$', '#') - if (data.prop.endsWith('placeholder')) { - this.field.options.placeholder = data.key - this.field.options.placeholder_zh = data.desc - } else if (data.prop.endsWith('tip')) { - this.tooltip = data.key - } else { - this.field.desc = data.key - this.field.desc_zh = data.desc + // 日期控件不能绑定数字控件 + if (this.field.options.dataType == 'date') { + return obj.options.dataType != 'number' } - }, - isNoAttrField(field) { - //无属性控件 - if (!field) { - field = this.field + // 大文本类型默认多行文本和附件 + if (this.field.options.dataType == 'clob') { + if (obj.ctrlType == 'textarea' || obj.ctrlType == 'attachment') { + return true + } } - const unboundPropertyList = [ - 'text', - 'immediate-single', - 'immediate-textarea', - 'flowChart', - 'approvalHistory', - 'opinion', - 'big-title', - 'small-title', - 'simple-text', - 'explain', - 'dataView', - 'formTable', - 'QRcode', - 'iframe', - 'image', - 'customChart', - 'button', - 'historicalApproval', - 'processForecast' - ] + // 字符串类型可以选择所有字段 + let charArr = ['string', 'varchar', 'nvarchar'] - if ( - (field && unboundPropertyList.includes(field.ctrlType)) || - (field && - field.ctrlType == 'button' && - field.options.bindEventjson && - !field.options.bindEventjson.isShowInput) - ) { + // 需要兼容以前的代码 this.field.options.dataType == "" + let result = this.field.options.dataType.split('|').filter(item => { + return dataTypes.indexOf(item) != -1 || charArr.indexOf(item) != -1 + }) + + if (result && result.length >= 1) { return true } return false }, - isAllowNoAttributes(field) { - //允许无属性控件 - if (!field) { - field = this.field + /** + * 新旧属性的替换,并保留原有的双向绑定, + * 具体逻辑为: + * 1.新属性有值的,旧属性没有的,新增 + * 2.新属性没有的,旧属性有的,删除 + * 3.新属性有的,旧属性也有,,则保留旧属性(desc等一些特殊key 需要特殊逻辑处理) + */ + attributeToReplace(oldV, newV) { + for (let key in oldV) { + //2.新属性没有的,旧属性有的,删除 + if ( + key != 'key' && + newV[key] === undefined && + (oldV[key] || oldV[key] === '') + ) { + delete oldV[key] + } } - if ( - field && - this.allowNoAttributes.includes(field.ctrlType) && - field.options.noBindModel - ) { - return true + for (let key in newV) { + let value = newV[key] + //1.新属性有值的,旧属性没有的,新增 + if (oldV[key] === undefined || oldV[key] === '') { + this.$set(oldV, key, value) + //3.新属性有的,旧属性也有,,则保留旧属性(options等一些特殊key 需要特殊逻辑处理) + } else { + if (key === 'options') { + // 保留绑定的dataType + let boDataType = oldV[key].dataType + oldV[key] = value + if (boDataType) { + oldV[key].dataType = boDataType + } + } + } + } + //旧属性有值 和新属性的值不一样 要重置 + for (let keys in oldV) { + if (!(oldV[keys] instanceof Object)) { + if (oldV[keys] != newV[keys] && newV[keys] != undefined) { + oldV[keys] = newV[keys] + } + } } - return false }, - noAttrFieldListChange(field, isAdd) { - //无属性控件的变化实时其更新联动列表 - let inList = false + //切换控件类型对应改变属性 + changeCtrlType(isClean,type) { + const me_ = this + const selectObj = deepmerge({}, me_.field, {clone: true}) + basicComponents.forEach(item => { + if (me_.field.ctrlType == item.ctrlType) { + // me_.field = deepmerge({}, item, { clone: true }); + let i = deepmerge({}, item, {clone: true}) + i.parentNodeType = me_.data.parentNodeType + i.boSubEntity = me_.data.boSubEntity + me_.attributeToReplace(me_.field, i) - this.noAttrFieldList.forEach(item => { - if (item.key === field.key) { - if (field.ctrlType == 'button') { - field.desc = field.options.bindEventjson.name + me_.field.key = me_.data.key + me_.field.tableName = selectObj.tableName + me_.field.target = selectObj.target + + + if (!isClean) { + me_.field.boDefId = selectObj.boDefId + me_.field.target = selectObj.target + me_.field.boAttrId = selectObj.boAttrId + me_.field.fieldPath = selectObj.fieldPath + me_.field.name = selectObj.name + me_.field.desc = selectObj.desc + me_.field.title = selectObj.desc + me_.field.entId = selectObj.entId + me_.field.boDefAlias = selectObj.boDefAlias + me_.field.tableName = selectObj.tableName + me_.field.columnType = selectObj.columnType + if(!type){ + me_.field.options.format = selectObj.options.format + me_.field.options.inputFormat = selectObj.options.format + me_.field.options.decimalDigits = selectObj.options.decimalDigits + me_.field.options.maxDecimalDigits = + selectObj.options.maxDecimalDigits + me_.field.options.max = selectObj.options.max + me_.field.options.numberMax = selectObj.options.numberMax + me_.field.options.numberMin = selectObj.options.numberMin + me_.field.options.min = selectObj.options.min + } } - if ( - ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType) - ) { - field.desc = field.options.textValue + if (item.ctrlType == 'amap') { + me_.field.options.dataType = 'varchar' } - if (isAdd) { - inList = true - } else { - this.noAttrFieldList.remove(item) - return + if (item.ctrlType == 'switch') { + me_.field.options.dataType = 'varchar' } + //me_.$emit("data:update", me_.field); + //WidgetFormBus.$emit("changeCtrlType", me_.field); } }) - if (isAdd && !inList) { - if (field.ctrlType == 'button') { - field.desc = field.options.bindEventjson.name - } - if ( - ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType) - ) { - field.desc = field.options.textValue + flowComponents.forEach(item => { + if (me_.field.ctrlType == item.ctrlType) { + // me_.field = deepmerge({}, item, { clone: true }); + let i = deepmerge({}, item, {clone: true}) + i.parentNodeType = me_.data.parentNodeType + i.boSubEntity = me_.data.boSubEntity + me_.attributeToReplace(me_.field, i) + + me_.field.key = me_.data.key + if (!isClean) { + me_.field.boDefId = selectObj.boDefId + me_.field.target = selectObj.target + me_.field.boAttrId = selectObj.boAttrId + me_.field.fieldPath = selectObj.fieldPath + me_.field.name = selectObj.name + me_.field.desc = selectObj.desc + me_.field.title = selectObj.desc + me_.field.entId = selectObj.entId + me_.field.boDefAlias = selectObj.boDefAlias + me_.field.tableName = selectObj.tableName + me_.field.columnType = selectObj.columnType + me_.field.options.format = selectObj.options.format + me_.field.options.inputFormat = selectObj.options.format + me_.field.options.decimalDigits = selectObj.options.decimalDigits + me_.field.options.maxDecimalDigits = + selectObj.options.maxDecimalDigits + me_.field.options.max = selectObj.options.max + me_.field.options.numberMax = selectObj.options.numberMax + me_.field.options.numberMin = selectObj.options.numberMin + me_.field.options.min = selectObj.options.min + } } - this.$set(field, 'name', '') - this.$set(field, 'target', field.name) - if ( - (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') && - !field.options.noBindModel - ) { - this.$set(field, 'fieldPath', 'item.' + field.name) - } else if ( - (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') && - field.options.noBindModel && - field.key - ) { - this.$set(field, 'fieldPath', 'item.' + `c_${field.key}`) - } else if (field.options.noBindModel && field.boDefAlias && field.key) { - this.$set(field, 'fieldPath', `${field.boDefAlias}.c_${field.key}`) - } else if (field.boDefAlias) { - this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name) + }) + advanceComponents.forEach(item => { + if (me_.field.ctrlType == item.ctrlType) { + // me_.field = deepmerge({}, item, { clone: true }); + let e = deepmerge({}, item, {clone: true}) + e.parentNodeType = me_.data.parentNodeType + e.boSubEntity = me_.data.boSubEntity + me_.attributeToReplace(me_.field, e) + me_.field.key = me_.data.key + // 如果是非绑定属性的 不用赋值 + if (item.options && item.options.noBindModel) { + isClean = true + } + if (!isClean) { + me_.field.boDefId = selectObj.boDefId + me_.field.target = selectObj.target + me_.field.boAttrId = selectObj.boAttrId + me_.field.fieldPath = selectObj.fieldPath + me_.field.name = selectObj.name + me_.field.desc = selectObj.desc + me_.field.title = selectObj.desc + me_.field.entId = selectObj.entId + me_.field.boDefAlias = selectObj.boDefAlias + me_.field.tableName = selectObj.tableName + me_.field.columnType = selectObj.columnType + me_.field.options.format = selectObj.format + me_.field.options.inputFormat = selectObj.format + me_.field.options.decimalDigits = selectObj.options.decimalDigits + me_.field.options.maxDecimalDigits = + selectObj.options.maxDecimalDigits + me_.field.options.max = selectObj.options.max + me_.field.options.numberMax = selectObj.options.numberMax + me_.field.options.numberMin = selectObj.options.numberMin + me_.field.options.min = selectObj.options.min + } + if (item.ctrlType == 'amap') { + me_.field.options.dataType = 'varchar' + } + // WidgetFormBus.$emit("changeCtrlType", me_.field); } - } else if (field.boDefAlias && !field.fieldPath) { - this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name) + }) + me_.$nextTick(() => { + this.setSelectWidget(me_.field) + }) + this.checkAndClearTarget() + }, + //引入脚本和样式对象保存 + includeFilesOk() { + if (!this.formHtml) { + this.$message.warning('模板HTML不能为空!') + return } - this.noAttrFieldList.some((item, i) => { - if (item.key === field.key) { - this.noAttrFieldList.splice(i, 1) - return true + this.dialogincluddingFileVisible = false + form + .saveFormJs({ + formId: this.formData.id, + diyJs: this.includeFiles.diyJs, + formHtml: Base64.encode(this.formHtml, 'utf-8'), + formExpand: Base64.encode(this.formExpand, 'utf-8') + }) + .then(resp => { + if (resp.state) { + this.$message.success(resp.message) + } + }) + }, + variablesClick(data) { + this.includeFiles.diyJs += data.value + }, + afterformHtml(data) { + this.formExpand = data.bpmForm.formExpand + this.formHtml = data.bpmForm.formHtml + this.includeFiles.diyJs = data.bpmForm.diyJs + }, + includdingFile() { + this.dialogincluddingFileVisible = true + this.formHtmlUrl = + '/form/form/v1/previewDesignVue?formId=' + this.formData.id + this.includeFiles = this.formData.includeFiles + ? Base64.decode(this.formData.includeFiles, 'utf-8') + : {diyFile: ' ', diyCss: ' ', diyJs: ' '} + }, + streetChangeMap(value) { + let selectObj = null + this.tableFields.forEach((boData) => { + if (!selectObj) { + selectObj = boData.children.find((opt) => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name + } } }) - this.noAttrFieldList.push(field) + this.field.options.streetPath = selectObj.path + '.' + selectObj.name }, - showSelectQueryDialog() { - //初始化关联查询用到的实体map - this.initQueryEntMap() - if (this.widgetFormData.config == undefined) { - this.widgetFormData.config = {} - } - this.$refs.selectQueryDialog.showDialog( - this.widgetFormData.config.globalQueryJson - ) + districtChangeMap(value) { + let selectObj = null + this.tableFields.forEach((boData) => { + if (!selectObj) { + selectObj = boData.children.find((opt) => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name + } + } + }) + this.field.options.districtPath = selectObj.path + '.' + selectObj.name }, - //保存关联查询数据 - saveCustQueryJson(json) { - this.$set(this.widgetFormData.config, 'globalQueryJson', json) - this.$set(this.widgetForm.config, 'globalQueryJson', json) + cityChangeMap(value) { + let selectObj = null + this.tableFields.forEach((boData) => { + if (!selectObj) { + selectObj = boData.children.find((opt) => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name + } + } + }) + this.field.options.cityPath = selectObj.path + '.' + selectObj.name }, - initQueryEntMap() { - if (this.mainBoFields && this.mainBoFields.length > 0) { - this.queryEntMap['main'] = this.mainBoFields - } - if (this.subTables && this.subTables.length > 0) { - this.queryEntMap['sub'] = this.subTables - } - if (this.sunTablesMap && Object.keys(this.sunTablesMap).length !== 0) { - let sunTables = [] - for (var key in this.sunTablesMap) { - if (this.sunTablesMap.hasOwnProperty(key)) { - sunTables.push(...this.sunTablesMap[key]) + provinceChangeMap(value) { + let selectObj = null + this.tableFields.forEach((boData) => { + if (!selectObj) { + selectObj = boData.children.find((opt) => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name } } - this.queryEntMap['sun'] = sunTables - } + }) + this.field.options.provincePath = selectObj.path + '.' + selectObj.name }, - selectTypeChange(type) { - if (type) { - this.formData.typeId = type.id - this.formData.typeName = type.name - } else { - this.formData.typeId = '' - this.formData.typeName = '' - } - this.$forceUpdate() + latitudeChangeMap(value) { + let selectObj = null + this.tableFields.forEach((boData) => { + if (!selectObj) { + selectObj = boData.children.find((opt) => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name + } + } + }) + this.field.options.latitudePath = selectObj.path + '.' + selectObj.name }, - // 隐藏标题时 标题宽度赋值为0 - hideTitleChange(flag) { - this.field.options.labelstyleWidth = flag ? '0' : '' - } - }, - watch: { - data(val) { - this.field = val + + longitudeChangeMap(value) { + let selectObj = null + this.tableFields.forEach((boData) => { + if (!selectObj) { + selectObj = boData.children.find((opt) => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name + } + } + }) + this.field.options.longitudePath = selectObj.path + '.' + selectObj.name }, - field: { - handler(val) { - // 下拉框 多选isMultiple 属性废弃 使用options.multiple属性 为了兼容以前的代码 将isMultiple true 值赋值给 options.multiple属性 - if (val && val.ctrlType == 'select' && val.isMultiple) { - val.options.multiple = true - val.isMultiple = false + // 改变地图地址绑定的字段 设置fieldPath + changeMap(value) { + let selectObj = null + this.tableFields.forEach(boData => { + if (!selectObj) { + selectObj = boData.children.find(opt => opt.name === value) + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.fieldPath.split('.')[0] + selectObj.tableName = boData.name + } } - - if (val && ['sub', 'sun'].includes(val.parentNodeType)) { - if (val.boSubEntity || val.tableName) { - this.currentBoSubEntity = val.boSubEntity - this.tableFields = this.subTables.filter( - item => item.name === val.boSubEntity || item.name === val.tableName - ) - if (this.tableFields.length > 0) { - for (let e = 0; e < this.tableFields.length; e++) { - if (this.tableFields[e].children.length > 0) { - for ( - let w = 0; - w < this.tableFields[e].children.length; - w++ - ) { - this.tableFields[e].children[w].keyName = this.tableFields[ - e - ].children[w].name - } - } - } + }) + this.field.options.locationPath = selectObj.path + '.' + selectObj.name + }, + // 改变绑定的字段 设置fieldPath + change(value) { + let selectObj = null + this.fieldIndexData = {} + this.tableFields.forEach(boData => { + boData.children.forEach((v, i) => { + let keyName = v.name + if (value.indexOf('.') != -1) { + keyName = v.path + '.' + v.name + } + if (v.isRequired && keyName == value) { + if (!this.fieldIndexData.fieldName) { + this.fieldIndexData.fieldName = v.fieldName + this.fieldIndexData.index = i } } + }) + if (!selectObj) { + selectObj = boData.children.find(opt => opt.name === value) + if (value.indexOf('.') != -1) { + selectObj = boData.children.find( + opt => opt.path + '.' + opt.name === value + ) + } - //如果是孙表,则选取子表里的孙表供选择绑定 - if ( - ((val && val.ctrlType == 'suntable') || val.ctrlType == 'sunDiv') && - this.currentBoSubEntity - ) { - this.sunTables = this.sunTablesMap[this.currentBoSubEntity] || [] + if (selectObj) { + selectObj.boDefAlias = + boData.boDefAlias || boData.path.split('.')[0] + selectObj.tableName = boData.name } - //如果是孙表里的控件,则找到这个一个孙表供其选择属性 - if (val && val.parentNodeType == 'sun') { - for (const subName in this.sunTablesMap) { - let sunTabs = this.sunTablesMap[subName] - if (sunTabs) { - sunTabs.forEach(sunTab => { - if (sunTab.name == this.currentBoSubEntity) { - this.tableFields = [sunTab] - } - }) - if (this.tableFields.length > 0) { - for (let o = 0; o < this.tableFields.length; o++) { - if (this.tableFields[o].children.length > 0) { - for ( - let h = 0; - h < this.tableFields[o].children.length; - h++ - ) { - this.tableFields[o].children[ - h - ].keyName = this.tableFields[o].children[h].name - } - } - } - } - } - } + } + }) + + if (!selectObj) { + if (this.field.parentNodeType == 'sub') { + this.field.fieldPath = 'item.' + value + this.field.name = 'item.' + value + } else { + this.$message.warning('只允许子表绑定虚拟字段') + } + return + } + + this.field.boDefId = selectObj.boDefId + this.field.boAttrId = selectObj.id + if (this.field.parentNodeType == 'sub') { + this.field.fieldPath = 'item.' + selectObj.name + } else { + this.field.fieldPath = selectObj.path + '.' + selectObj.name + } + + this.field.options.dataType = selectObj.dataType + + this.field.name = selectObj.name + this.field.desc = selectObj.desc + this.field.title = selectObj.desc + this.field.entId = selectObj.entId + this.field.boDefAlias = selectObj.boDefAlias + this.field.tableName = selectObj.tableName + this.field.columnType = selectObj.columnType + if (selectObj.dataType == 'date') { + this.field.options.format = selectObj.format + this.field.options.inputFormat = selectObj.format + } else if (selectObj.dataType == 'number') { + //如果为评分组件则默认最大值为5 + if (this.field.ctrlType === 'rate') { + this.field.options.max = Number(this.field.options.max) + } else { + this.field.options.maxDecimalDigits = selectObj.decimalLen + this.field.options.decimalDigits = selectObj.decimalLen + this.field.options.max = Number(''.padStart(selectObj.charLen, '9')) + this.field.options.numberMax = Number( + ''.padStart(selectObj.charLen, '9') + ) + this.field.options.numberMin = -Number( + ''.padStart(selectObj.charLen, '9') + ) + this.field.options.min = -Number(''.padStart(selectObj.charLen, '9')) + } + } + // bo属性中设置了必填 且 当前控件的校验规则为空 + if ( + selectObj.isRequired == '1' && + (!this.field.options.validateList || + this.field.options.validateList.length == 0) + ) { + this.$set(this.field.options, 'validateList', [ + { + key: 'required', + name: '*必填' } - } else { - if (this.mainBoFields.length > 0) { - for (let y = 0; y < this.mainBoFields.length; y++) { - if (this.mainBoFields[y].children.length > 0) { - for (let t = 0; t < this.mainBoFields[y].children.length; t++) { - this.mainBoFields[y].children[t].keyName = - this.mainBoFields[y].children[t].path + - '.' + - this.mainBoFields[y].children[t].name - } - } - } + ]) + } + this.$forceUpdate() + }, + //给无属性控件设置关联ent属性 + changeNoAttrFile(value) { + let _this = this + this.tableFields.forEach(ent => { + if (ent.name == value) { + _this.$set(_this.field, 'entId', ent.id) + _this.$set(_this.field, 'boDefId', ent.boDefId) + if (!_this.field.boDefAlias) { + _this.$set(_this.field, 'boDefAlias', ent.boDefAlias) } - if ( - val && - ['time', 'time-picker', 'date-picker'].includes(val.ctrlType) - ) { - this.tableFields = JSON.parse(JSON.stringify(this.mainBoFields)) - this.tableFields.forEach(table => { - if (table.children) { - let newFileds = [] - table.children = table.children.filter( - f => f.dataType != 'date' && f.dataType != 'number' - ) - } - }) - } else { - this.mainBoFields.forEach(item => { - for (let q = 0; q < item.children.length; q++) { - for (let i = 0; i < item.children.length - 1 - q; i++) { - if (item.children[i].index > item.children[i + 1].index) { - let temp = item.children[i] - item.children[i] = item.children[i + 1] - item.children[i + 1] = temp + this.$forceUpdate() + _this.noAttrFieldListChange(_this.field, true) + } + }) + }, + //取消无属性设置 + changeNoBindModel() { + if (this.field.options.noBindModel) { + this.$set(this.field, 'name', 'c_' + this.field.key) + this.noAttrFieldListChange(this.field, true) + } else if ( + !this.field.options.noBindModel && + this.noAttrFieldList && + this.noAttrFieldList.length > 0 + ) { + this.$set(this.field, 'name', '') + this.noAttrFieldListChange(this.field, false) + } + if (this.field.ctrlType === 'number') { + this.setDefaultValueForDigitalControl() + } + }, + setDefaultValueForDigitalControl() { + this.field.options.max = 999999999 + this.field.options.numberMax = 999999999 + this.field.options.numberMin = -999999999 + this.field.options.min = 0 + }, + isChangeWatch() { + this.isWatch = true + // + // + // 切换时 处理合计 + if (this.widgetForm.list && this.widgetForm.list.length > 0) { + this.widgetForm.list.forEach((item, index) => { + if (item.name === this.field.tableName) { + item.CombinedColumnList && + item.CombinedColumnList.forEach((ComItem, ComIndex) => { + if (ComItem.columnField === this.field.name) { + if ( + this.field.ctrlType != 'number' || + selitem.columnType != 'number' + ) { + item.CombinedColumnList.splice(ComIndex, 1) } } - } - }) - this.tableFields = this.mainBoFields - } - } - this.setTableFieldsChildren(this.tableFields, val && val.ctrlType) - //合并数组对象 - let allModelingData = [] - let allBoData = [] - let formVarData = [] - let returnData = [] //对话框返回值选择的字段信息 主表对应主表,子表对应子表,孙表对应孙表。 - let returnTypes = ['select', 'dropdown', 'dialog'] - if ( - (val && - ['suntable', 'sunDiv'].includes(val.ctrlType) && - this.currentBoSubEntity) || - (val && val.parentNodeType == 'sun') - ) { - this.mainBoFields.forEach(mainBoField => { - formVarData.push({...mainBoField}) - allBoData.push({...mainBoField}) - allModelingData.push({...mainBoField}) - }) - this.subTables.forEach(subTable => { - allModelingData.push({...subTable}) - let sunTabs = this.sunTablesMap[subTable.name] - if (sunTabs) { - sunTabs.forEach(sunTab => { - allModelingData.push({...sunTab}) }) - } - }) - if (this.sunTables && this.sunTables.length > 0) { - this.sunTables.forEach(sunTable => { - if (val && val.parentNodeType == 'sun') { - if (sunTable.name == val.boSubEntity) { - allBoData.push({...sunTable}) - formVarData.push({...sunTable}) - returnData.push({...sunTable}) - } - } else { - allBoData.push({...sunTable}) - formVarData.push({...sunTable}) - returnData.push({...sunTable}) - } - }) + this.$set( + this.widgetForm.list[index], + 'CombinedColumnListJson', + Base64.encode(JSON.stringify(item.CombinedColumnList), 'utf-8') + ) } - } else { - if ( - val && - val.parentNodeType != 'sub' && - returnTypes.includes(val.ctrlType) - ) { - //添加主表字段 - this.mainBoFields.forEach(mainBoField => { - returnData.push({...mainBoField}) + }) + } + }, + //判断并清空绑定属性 + checkAndClearTarget() { + if (!utils.isEmpty(this.field.target) && this.tableFields.length > 0) { + this.tableFields.forEach((item, i) => { + var items = + this.tableFields[i].children && + this.tableFields[i].children.filter(obj => { + return this.field.target == obj['keyName'] }) - } else if ( - val && - val.parentNodeType == 'sub' && - returnTypes.includes(val.ctrlType) + + if (!items || items.length <= 0) { + this.field.target = '' + } + if (!this.filterFields(items[0])) { + this.field.target = '' + } + }) + } + }, + editI18nMessage(after) { + this.i18nMessageKey = this.field.fieldPath || this.field.path + + if (this.createKeyMap[this.field.ctrlType]) { + this.i18nMessageKey = + this.formData.formKey + + '.' + + this.field.ctrlType + + Math.random() * 5000 + } + if (this.i18nMessageKey && after) { + this.i18nMessageKey += after + } + this.$refs.i18nMessageEdit.handleOpen() + }, + afterSaveI18n(data) { + data.key = data.key.replace('$', '#') + if (data.prop.endsWith('placeholder')) { + this.field.options.placeholder = data.key + this.field.options.placeholder_zh = data.desc + } else if (data.prop.endsWith('tip')) { + this.tooltip = data.key + } else { + this.field.desc = data.key + this.field.desc_zh = data.desc + } + }, + isNoAttrField(field) { + //无属性控件 + if (!field) { + field = this.field + } + const unboundPropertyList = [ + 'text', + 'immediate-single', + 'immediate-textarea', + 'flowChart', + 'approvalHistory', + 'opinion', + 'big-title', + 'small-title', + 'simple-text', + 'explain', + 'dataView', + 'formTable', + 'QRcode', + 'iframe', + 'image', + 'customChart', + 'button', + 'historicalApproval', + 'processForecast' + ] + + if ( + (field && unboundPropertyList.includes(field.ctrlType)) || + (field && + field.ctrlType == 'button' && + field.options.bindEventjson && + !field.options.bindEventjson.isShowInput) + ) { + return true + } + return false + }, + isAllowNoAttributes(field) { + //允许无属性控件 + if (!field) { + field = this.field + } + if ( + field && + this.allowNoAttributes.includes(field.ctrlType) && + field.options.noBindModel + ) { + return true + } + return false + }, + noAttrFieldListChange(field, isAdd) { + //无属性控件的变化实时其更新联动列表 + let inList = false + + this.noAttrFieldList.forEach(item => { + if (item.key === field.key) { + if (field.ctrlType == 'button') { + field.desc = field.options.bindEventjson.name + } + if ( + ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType) ) { - //添加子表字段 - this.subTables.forEach(subTable => { - returnData.push({...subTable}) - }) + field.desc = field.options.textValue + } + if (isAdd) { + inList = true + } else { + this.noAttrFieldList.remove(item) + return } - //添加主表字段 - this.mainBoFields.forEach(mainBoField => { - allBoData.push({...mainBoField}) - }) - this.subTables.forEach(subTable => { - allBoData.push({...subTable}) - let sunTabs = this.sunTablesMap[subTable.name] - if (sunTabs) { - sunTabs.forEach(sunTab => { - allBoData.push({...sunTab}) - }) - } - }) - formVarData = allBoData } - //判断无属性控件 按钮 + }) + if (isAdd && !inList) { + if (field.ctrlType == 'button') { + field.desc = field.options.bindEventjson.name + } if ( - (this.isNoAttrField(val) || this.isAllowNoAttributes(val)) && - this.tableFields && - this.tableFields.length > 0 - ) { - if (val && !val.name) { - this.$set(val, 'name', 'c_' + val.key) - } - if (val && !val.boDefAlias) { - if (val.parentNodeType == 'sub' || val.parentNodeType == 'sun') { - const paths = this.tableFields[0].path.split('.') - this.$set(val, 'boDefAlias', paths[0]) - } else { - this.$set(val, 'boDefAlias', this.tableFields[0].boDefAlias) - } - } - if (val && !val.tableName) { - this.$set(val, 'tableName', this.tableFields[0].name) - this.changeNoAttrFile(this.tableFields[0].name) - } - this.noAttrFieldListChange(val, true) - } else if ( - val && - val.ctrlType == 'button' && - val.options.bindEventjson && - val.options.bindEventjson.isShowInput + ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType) ) { - this.noAttrFieldListChange(val, false) + field.desc = field.options.textValue } - this.allModelingData = allModelingData - this.allBoData = allBoData - this.formVarData = formVarData - this.returnData = returnData - // this.$emit('update:data', val) - //通过模板生成的表单字段需更改为 建模别名.字段名 (解决2个不同的建模,但主表建模字段一样) + this.$set(field, 'name', '') + this.$set(field, 'target', field.name) if ( - val && - val.target && - val.parentNodeType != 'sub' && - val.parentNodeType != 'sun' + (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') && + !field.options.noBindModel ) { - if (!utils.isEmpty(val.boDefAlias) && !utils.isEmpty(val.name)) { - val.target = val.boDefAlias + '.' + val.name - } - } - }, - deep: true - }, - 'field.ctrlType': { - handler(newVal, oldVal) { - if (oldVal == undefined || newVal == undefined || newVal == oldVal) { - return + this.$set(field, 'fieldPath', 'item.' + field.name) + } else if ( + (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') && + field.options.noBindModel && + field.key + ) { + this.$set(field, 'fieldPath', 'item.' + `c_${field.key}`) + } else if (field.options.noBindModel && field.boDefAlias && field.key) { + this.$set(field, 'fieldPath', `${field.boDefAlias}.c_${field.key}`) + } else if (field.boDefAlias) { + this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name) } - if (!this.isWatch) { - return + } else if (field.boDefAlias && !field.fieldPath) { + this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name) + } + this.noAttrFieldList.some((item, i) => { + if (item.key === field.key) { + this.noAttrFieldList.splice(i, 1) + return true } - if (newVal === 'rate') { - this.changeCtrlType(false,'rate') - } else if (['number', 'currency'].includes(oldVal)) { - if (newVal == 'date' || newVal == 'time') { - this.changeCtrlType(true) - } else { - this.changeCtrlType(false) - } - } else if (oldVal == 'date' || oldVal == 'time') { - if (newVal == 'number' || newVal == 'currency') { - this.changeCtrlType(true) - } else { - this.changeCtrlType(false) - } - } else if (newVal == 'select') { - this.changeCtrlType(false) - } else { - if (['number', 'currency'].includes(newVal)) { - if (this.field.columnType == 'number') { - this.changeCtrlType(false) - } else { - this.changeCtrlType(true) - } - } else if (newVal == 'date' || newVal == 'time') { - this.changeCtrlType(false) - } else if (newVal == 'switch') { - this.changeCtrlType(false) - } else { - this.changeCtrlType(false) + }) + this.noAttrFieldList.push(field) + }, + showSelectQueryDialog() { + //初始化关联查询用到的实体map + this.initQueryEntMap() + if (this.widgetFormData.config == undefined) { + this.widgetFormData.config = {} + } + this.$refs.selectQueryDialog.showDialog( + this.widgetFormData.config.globalQueryJson + ) + }, + //保存关联查询数据 + saveCustQueryJson(json) { + this.$set(this.widgetFormData.config, 'globalQueryJson', json) + this.$set(this.widgetForm.config, 'globalQueryJson', json) + }, + initQueryEntMap() { + if (this.mainBoFields && this.mainBoFields.length > 0) { + this.queryEntMap['main'] = this.mainBoFields + } + if (this.subTables && this.subTables.length > 0) { + this.queryEntMap['sub'] = this.subTables + } + if (this.sunTablesMap && Object.keys(this.sunTablesMap).length !== 0) { + let sunTables = [] + for (var key in this.sunTablesMap) { + if (this.sunTablesMap.hasOwnProperty(key)) { + sunTables.push(...this.sunTablesMap[key]) } } - this.isWatch = false - const validateList = this.field.options.validateList - ? [ - ...this.field.options.validateList, - { - key: 'required', - name: '*必填' - } - ] - : [ - { - key: 'required', - name: '*必填' - } - ] - const hasValidateRules = - this.field.options.validateType && - this.field.options.validateType.includes('required') - this.tableFields.forEach(boData => { - boData.children.forEach((v, i) => { - if ( - hasValidateRules && - this.field.fieldPath === v.keyName && - v.isRequired - ) { - this.$set( - this.field.options, - 'validateList', - uniqueArrayObject(validateList, 'key') - ) - if (this.field.options && !this.field.options.validate) { - this.$set(this.field.options, 'validate', "'required'") - } - } - }) - }) + this.queryEntMap['sun'] = sunTables } }, - widgetForm(val) { - this.widgetFormData = val - if (val.submitVerification && val.submitVerification.length > 0) { - this.submitVerification = JSON.parse( - Base64.decode(val.submitVerification) - ) + selectTypeChange(type) { + if (type) { + this.formData.typeId = type.id + this.formData.typeName = type.name } else { - this.submitVerification = [] + this.formData.typeId = '' + this.formData.typeName = '' } + this.$forceUpdate() }, - submitVerification: { - handler(val) { - this.$set( - this.widgetFormData, - 'submitVerification', - Base64.encode(JSON.stringify(this.submitVerification), 'utf-8') - ) - }, - deep: true - }, - // 根据绑定属性过滤空间类型 - 'field.target': { - handler(val) { - this.filterBasicComponents = basicComponents.filter(obj => { - return this.filterFieldsByCurrentField(obj, val) - }) - }, - deep: true + // 隐藏标题时 标题宽度赋值为0 + hideTitleChange(flag) { + this.field.options.labelstyleWidth = flag ? '0' : '' } - }, - mounted() { - // 声明 - this.$validator = this.$root.$validator - // 复制高级字段列表 - this.copyAdvanceComponents = this.advanceComponents.slice() - }, - destroyed() {} -} + } +}; +