Commit 5fa3135d8c66f287389ef8d2f8b585b5210004f3

Authored by 陈威
1 parent 3fea4fbc
Exists in dev

支持省市区经纬度选择版本

Showing 1 changed file with 1512 additions and 1223 deletions   Show diff stats
frontend/manage/src/components/form/PropertyPanel.vue
@@ -364,6 +364,201 @@ @@ -364,6 +364,201 @@
364 </template> 364 </template>
365 </ht-select> 365 </ht-select>
366 </ht-form-item> 366 </ht-form-item>
  367 +
  368 +
  369 +
  370 + <ht-form-item label-width="100px">
  371 + <template slot="label">
  372 + 经度
  373 + <el-tooltip content="请选择经度要绑定的字段">
  374 + <i class="property-tip icon-my-todo-comment" />
  375 + </el-tooltip>
  376 + </template>
  377 + <ht-select
  378 + v-model="field.options.longitudeName"
  379 + :options="tableFields"
  380 + :props="{key: 'name', value: 'desc'}"
  381 + @change="longitudeChangeMap"
  382 + >
  383 + <template slot-scope="{options, propKey, propValue}">
  384 + <el-option-group
  385 + v-for="group in options"
  386 + :key="group.name"
  387 + :label="group.desc"
  388 + >
  389 + <el-option
  390 + v-for="item in group.children.filter((obj) => {
  391 + return filterFields(obj)
  392 + })"
  393 + :key="item[propKey]"
  394 + :label="item[propValue]"
  395 + :value="item[propKey]"
  396 + ></el-option>
  397 + </el-option-group>
  398 + </template>
  399 + </ht-select>
  400 + </ht-form-item>
  401 +
  402 + <ht-form-item label-width="100px">
  403 + <template slot="label">
  404 + 纬度
  405 + <el-tooltip content="请选择纬度要绑定的字段">
  406 + <i class="property-tip icon-my-todo-comment" />
  407 + </el-tooltip>
  408 + </template>
  409 + <ht-select
  410 + v-model="field.options.latitudeName"
  411 + :options="tableFields"
  412 + :props="{key: 'name', value: 'desc'}"
  413 + @change="latitudeChangeMap"
  414 + >
  415 + <template slot-scope="{options, propKey, propValue}">
  416 + <el-option-group
  417 + v-for="group in options"
  418 + :key="group.name"
  419 + :label="group.desc"
  420 + >
  421 + <el-option
  422 + v-for="item in group.children.filter((obj) => {
  423 + return filterFields(obj)
  424 + })"
  425 + :key="item[propKey]"
  426 + :label="item[propValue]"
  427 + :value="item[propKey]"
  428 + ></el-option>
  429 + </el-option-group>
  430 + </template>
  431 + </ht-select>
  432 + </ht-form-item>
  433 + <ht-form-item label-width="100px">
  434 + <template slot="label">
  435 + 省
  436 + <el-tooltip content="请选择省要绑定的字段">
  437 + <i class="property-tip icon-my-todo-comment" />
  438 + </el-tooltip>
  439 + </template>
  440 + <ht-select
  441 + v-model="field.options.provinceName"
  442 + :options="tableFields"
  443 + :props="{key: 'name', value: 'desc'}"
  444 + @change="provinceChangeMap"
  445 + >
  446 + <template slot-scope="{options, propKey, propValue}">
  447 + <el-option-group
  448 + v-for="group in options"
  449 + :key="group.name"
  450 + :label="group.desc"
  451 + >
  452 + <el-option
  453 + v-for="item in group.children.filter((obj) => {
  454 + return filterFields(obj)
  455 + })"
  456 + :key="item[propKey]"
  457 + :label="item[propValue]"
  458 + :value="item[propKey]"
  459 + ></el-option>
  460 + </el-option-group>
  461 + </template>
  462 + </ht-select>
  463 + </ht-form-item>
  464 +
  465 + <ht-form-item label-width="100px">
  466 + <template slot="label">
  467 + 市
  468 + <el-tooltip content="请选择市要绑定的字段">
  469 + <i class="property-tip icon-my-todo-comment" />
  470 + </el-tooltip>
  471 + </template>
  472 + <ht-select
  473 + v-model="field.options.cityName"
  474 + :options="tableFields"
  475 + :props="{key: 'name', value: 'desc'}"
  476 + @change="cityChangeMap"
  477 + >
  478 + <template slot-scope="{options, propKey, propValue}">
  479 + <el-option-group
  480 + v-for="group in options"
  481 + :key="group.name"
  482 + :label="group.desc"
  483 + >
  484 + <el-option
  485 + v-for="item in group.children.filter((obj) => {
  486 + return filterFields(obj)
  487 + })"
  488 + :key="item[propKey]"
  489 + :label="item[propValue]"
  490 + :value="item[propKey]"
  491 + ></el-option>
  492 + </el-option-group>
  493 + </template>
  494 + </ht-select>
  495 + </ht-form-item>
  496 +
  497 + <ht-form-item label-width="100px">
  498 + <template slot="label">
  499 + 区
  500 + <el-tooltip content="请选择区要绑定的字段">
  501 + <i class="property-tip icon-my-todo-comment" />
  502 + </el-tooltip>
  503 + </template>
  504 + <ht-select
  505 + v-model="field.options.districtName"
  506 + :options="tableFields"
  507 + :props="{key: 'name', value: 'desc'}"
  508 + @change="districtChangeMap"
  509 + >
  510 + <template slot-scope="{options, propKey, propValue}">
  511 + <el-option-group
  512 + v-for="group in options"
  513 + :key="group.name"
  514 + :label="group.desc"
  515 + >
  516 + <el-option
  517 + v-for="item in group.children.filter((obj) => {
  518 + return filterFields(obj)
  519 + })"
  520 + :key="item[propKey]"
  521 + :label="item[propValue]"
  522 + :value="item[propKey]"
  523 + ></el-option>
  524 + </el-option-group>
  525 + </template>
  526 + </ht-select>
  527 + </ht-form-item>
  528 +
  529 + <ht-form-item label-width="100px">
  530 + <template slot="label">
  531 + 街道
  532 + <el-tooltip content="请选择街道要绑定的字段">
  533 + <i class="property-tip icon-my-todo-comment" />
  534 + </el-tooltip>
  535 + </template>
  536 + <ht-select
  537 + v-model="field.options.streetName"
  538 + :options="tableFields"
  539 + :props="{key: 'name', value: 'desc'}"
  540 + @change="streetChangeMap"
  541 + >
  542 + <template slot-scope="{options, propKey, propValue}">
  543 + <el-option-group
  544 + v-for="group in options"
  545 + :key="group.name"
  546 + :label="group.desc"
  547 + >
  548 + <el-option
  549 + v-for="item in group.children.filter((obj) => {
  550 + return filterFields(obj)
  551 + })"
  552 + :key="item[propKey]"
  553 + :label="item[propValue]"
  554 + :value="item[propKey]"
  555 + ></el-option>
  556 + </el-option-group>
  557 + </template>
  558 + </ht-select>
  559 + </ht-form-item>
  560 +
  561 +
367 </template> 562 </template>
368 <!-- 对应某些控件是基础属性 但又不是所有控件的基础属性放入BasicsProperty组件中 --> 563 <!-- 对应某些控件是基础属性 但又不是所有控件的基础属性放入BasicsProperty组件中 -->
369 <BasicsProperty 564 <BasicsProperty
@@ -773,19 +968,9 @@ const EipSysTypeSelector = () =&gt; @@ -773,19 +968,9 @@ const EipSysTypeSelector = () =&gt;
773 import('@/components/selector/EipSysTypeSelector.vue') 968 import('@/components/selector/EipSysTypeSelector.vue')
774 const DynamicControlDialog = () => 969 const DynamicControlDialog = () =>
775 import('@/components/form/customView/DynamicControlDialog.vue') 970 import('@/components/form/customView/DynamicControlDialog.vue')
776 -  
777 export default { 971 export default {
778 name: 'property-panel', 972 name: 'property-panel',
779 - props: [  
780 - // 'data',  
781 - 'boDefData',  
782 - 'formData',  
783 - 'mainBoFields',  
784 - 'subTables',  
785 - 'sunTablesMap',  
786 - 'widgetForm',  
787 - 'handleType'  
788 - ], 973 +
789 components: { 974 components: {
790 LayoutProperty, 975 LayoutProperty,
791 AdvancedProperty, 976 AdvancedProperty,
@@ -796,6 +981,18 @@ export default { @@ -796,6 +981,18 @@ export default {
796 SubmitVerificationDialog, 981 SubmitVerificationDialog,
797 DynamicControlDialog 982 DynamicControlDialog
798 }, 983 },
  984 +
  985 + props: [
  986 + // 'data',
  987 + 'boDefData',
  988 + 'formData',
  989 + 'mainBoFields',
  990 + 'subTables',
  991 + 'sunTablesMap',
  992 + 'widgetForm',
  993 + 'handleType'
  994 + ],
  995 +
799 data() { 996 data() {
800 return { 997 return {
801 formCollapseActiveNames: 'formBasic', 998 formCollapseActiveNames: 'formBasic',
@@ -900,1349 +1097,1441 @@ export default { @@ -900,1349 +1097,1441 @@ export default {
900 allModelingData: [] 1097 allModelingData: []
901 } 1098 }
902 }, 1099 },
  1100 +
903 computed: { 1101 computed: {
904 ...mapState({ 1102 ...mapState({
905 data: state => state.form.selectWidget 1103 data: state => state.form.selectWidget
906 }) 1104 })
907 }, 1105 },
908 - created() {  
909 - this.field = this.data  
910 - const me_ = this  
911 - //表单初始化时收集无属性控件字段  
912 - WidgetFormBus.$off('initNoAttrField')  
913 - WidgetFormBus.$on('initNoAttrField', obj => {  
914 - if (  
915 - (this.isNoAttrField(obj) || this.isAllowNoAttributes(obj)) &&  
916 - obj.tableName  
917 - ) {  
918 - me_.noAttrFieldListChange(obj, false)  
919 - }  
920 - })  
921 - if (!this.formData.formSetting.display) {  
922 - this.formData.formSetting = JSON.stringify(this.formSetting)  
923 - }  
924 - },  
925 - methods: {  
926 - confirmDynamic(data) {  
927 - this.$set(this.widgetFormData, 'globalDynamicControl', data)  
928 - },  
929 - // 显示动态控件配置页面  
930 - showDynamicDialog() {  
931 - this.$refs.dynamicControlRef.showDialog(this.widgetFormData)  
932 - },  
933 - ...mapMutations({  
934 - setSelectWidget: 'form/setSelectWidget' // 设置当前选中控件  
935 - }),  
936 - getTableLayoutOfControlKeys() {  
937 - let keys = []  
938 - if (this.widgetForm.list && this.widgetForm.list.length) {  
939 - this.widgetForm.list.map(item => {  
940 - if (item.isLayout && item.ctrlType == 'table') {  
941 - item.rows.map(it => {  
942 - if (it.cols && it.cols.length) {  
943 - it.cols.map(col => {  
944 - if (col.list && col.list.length) {  
945 - col.list.map(list => {  
946 - keys.push(list.key)  
947 - })  
948 - }  
949 - })  
950 - }  
951 - })  
952 - }  
953 - })  
954 - }  
955 - return keys  
956 - },  
957 - getSubtableType(type) {  
958 - this.subTableLayoutType = type 1106 +
  1107 + watch: {
  1108 + data(val) {
  1109 + this.field = val
959 }, 1110 },
960 - setTableFieldsChildren(data, ctrlType) {  
961 - if (['checkbox', 'radio', 'select'].includes(ctrlType)) {  
962 - const copyDate = JSON.parse(JSON.stringify(data))  
963 - copyDate.map(item => {  
964 - const options = item.children.filter(  
965 - it => it.dataType !== 'number' && it.dataType !== 'date'  
966 - )  
967 - this.$set(item, 'children', options)  
968 - })  
969 - this.tableFields = copyDate  
970 - }  
971 - },  
972 - //重置表单配置信息  
973 - formSettingReset() {  
974 - this.formSetting.align = 'right'  
975 - this.formSetting.customColon = false  
976 - this.formSetting.fontColor = 'rgb(150, 151, 153)'  
977 - this.formSetting.display = 'block'  
978 - this.formSetting.roInputDisplayMode = 'text'  
979 - this.formSetting.labelPosition = false  
980 - },  
981 - //打开表单配置弹框  
982 - formSettingClick() {  
983 - if (this.formData.formSetting) {  
984 - this.formSetting = {  
985 - ...this.formSetting,  
986 - ...JSON.parse(this.formData.formSetting) 1111 + field: {
  1112 + handler(val) {
  1113 + // 下拉框 多选isMultiple 属性废弃 使用options.multiple属性 为了兼容以前的代码 将isMultiple true 值赋值给 options.multiple属性
  1114 + if (val && val.ctrlType == 'select' && val.isMultiple) {
  1115 + val.options.multiple = true
  1116 + val.isMultiple = false
987 } 1117 }
988 - }  
989 - this.formSettingVisible = true  
990 - },  
991 - //保存表单配置信息  
992 - formSettingOk() {  
993 - this.formData.formSetting = JSON.stringify(this.formSetting)  
994 - this.formSettingVisible = false  
995 - },  
996 - //打开添加表单提交校验配置弹框  
997 - formSubmitVerificationClick(index) {  
998 - let item = null  
999 - if (typeof index !== 'undefined' && index >= 0) {  
1000 - item = this.submitVerification[index]  
1001 - this.currentSubmitVerificationIndex = index  
1002 - } else {  
1003 - this.currentSubmitVerificationIndex = -1  
1004 - }  
1005 - this.$refs.submitVerificationDialog.handleOpen(item)  
1006 - },  
1007 - //保存表单提交校验配置信息  
1008 - formSubmitVerificationOk(verification) {  
1009 - if (!this.submitVerification) {  
1010 - this.submitVerification = []  
1011 - }  
1012 - if (this.currentSubmitVerificationIndex > -1) {  
1013 - this.submitVerification[  
1014 - this.currentSubmitVerificationIndex  
1015 - ] = verification  
1016 - } else {  
1017 - this.submitVerification.push(verification)  
1018 - }  
1019 - },  
1020 - saveValidate() {  
1021 - const this_ = this  
1022 - //这里先校验字段属性,再校验表单属性  
1023 - if(this.data.ctrlType =='tag'&& !this.data.options.tag){  
1024 - return this.$message.warning('请选择标签')  
1025 - }  
1026 - this_.$root.$validator.validateAll('field').then(result => {  
1027 - console.log(result)  
1028 - if (result) {  
1029 - utils  
1030 - .validateForm(this, 'editBpmForm')  
1031 - .then(() => {  
1032 - //手机表单保存时 表单类型指定为手机表单类型  
1033 - if (  
1034 - this_.formData.formType &&  
1035 - this_.formData.formType != 'mobile'  
1036 - ) {  
1037 - this_.formData.formType = 'pc' 1118 +
  1119 + if (val && ['sub', 'sun'].includes(val.parentNodeType)) {
  1120 + if (val.boSubEntity || val.tableName) {
  1121 + this.currentBoSubEntity = val.boSubEntity
  1122 + this.tableFields = this.subTables.filter(
  1123 + item => item.name === val.boSubEntity || item.name === val.tableName
  1124 + )
  1125 + if (this.tableFields.length > 0) {
  1126 + for (let e = 0; e < this.tableFields.length; e++) {
  1127 + if (this.tableFields[e].children.length > 0) {
  1128 + for (
  1129 + let w = 0;
  1130 + w < this.tableFields[e].children.length;
  1131 + w++
  1132 + ) {
  1133 + this.tableFields[e].children[w].keyName = this.tableFields[
  1134 + e
  1135 + ].children[w].name
  1136 + }
  1137 + }
1038 } 1138 }
1039 - // this.formData.name = this.formData.formName;  
1040 - const hasValidateForm =  
1041 - this.$refs.advancedProperty &&  
1042 - this.$refs.advancedProperty.$refs.validateProperty  
1043 - if (  
1044 - this.$refs.BasicsProperty &&  
1045 - this.$refs.BasicsProperty.validateKey()  
1046 - ) {  
1047 - return this.$message.warning(  
1048 - '下拉树或下拉框固定选项有重复的选项值,请重新输入'  
1049 - ) 1139 + }
  1140 + }
  1141 +
  1142 + //如果是孙表,则选取子表里的孙表供选择绑定
  1143 + if (
  1144 + ((val && val.ctrlType == 'suntable') || val.ctrlType == 'sunDiv') &&
  1145 + this.currentBoSubEntity
  1146 + ) {
  1147 + this.sunTables = this.sunTablesMap[this.currentBoSubEntity] || []
  1148 + }
  1149 + //如果是孙表里的控件,则找到这个一个孙表供其选择属性
  1150 + if (val && val.parentNodeType == 'sun') {
  1151 + for (const subName in this.sunTablesMap) {
  1152 + let sunTabs = this.sunTablesMap[subName]
  1153 + if (sunTabs) {
  1154 + sunTabs.forEach(sunTab => {
  1155 + if (sunTab.name == this.currentBoSubEntity) {
  1156 + this.tableFields = [sunTab]
  1157 + }
  1158 + })
  1159 + if (this.tableFields.length > 0) {
  1160 + for (let o = 0; o < this.tableFields.length; o++) {
  1161 + if (this.tableFields[o].children.length > 0) {
  1162 + for (
  1163 + let h = 0;
  1164 + h < this.tableFields[o].children.length;
  1165 + h++
  1166 + ) {
  1167 + this.tableFields[o].children[
  1168 + h
  1169 + ].keyName = this.tableFields[o].children[h].name
  1170 + }
  1171 + }
  1172 + }
  1173 + }
1050 } 1174 }
1051 - if (  
1052 - this.$refs.BasicsProperty &&  
1053 - this.$refs.BasicsProperty.validateFilterRange()  
1054 - ) {  
1055 - return this.$message.warning('请选择过滤范围') 1175 + }
  1176 + }
  1177 + } else {
  1178 + if (this.mainBoFields.length > 0) {
  1179 + for (let y = 0; y < this.mainBoFields.length; y++) {
  1180 + if (this.mainBoFields[y].children.length > 0) {
  1181 + for (let t = 0; t < this.mainBoFields[y].children.length; t++) {
  1182 + this.mainBoFields[y].children[t].keyName =
  1183 + this.mainBoFields[y].children[t].path +
  1184 + '.' +
  1185 + this.mainBoFields[y].children[t].name
  1186 + }
1056 } 1187 }
1057 - if (hasValidateForm) {  
1058 - this.$refs.advancedProperty.$refs.validateProperty  
1059 - .getValidateFormResult()  
1060 - .then(result => {  
1061 - this_.$emit('saveEnd')  
1062 - })  
1063 - .catch(err => {  
1064 - if (err.length > 0) {  
1065 - return this.$message.warning(  
1066 - `有${err.length}个字段未通过校验,请正确填写校验规则。`  
1067 - )  
1068 - }  
1069 - })  
1070 - } else {  
1071 - this_.$emit('saveEnd') 1188 + }
  1189 + }
  1190 + if (
  1191 + val &&
  1192 + ['time', 'time-picker', 'date-picker'].includes(val.ctrlType)
  1193 + ) {
  1194 + this.tableFields = JSON.parse(JSON.stringify(this.mainBoFields))
  1195 + this.tableFields.forEach(table => {
  1196 + if (table.children) {
  1197 + let newFileds = []
  1198 + table.children = table.children.filter(
  1199 + f => f.dataType != 'date' && f.dataType != 'number'
  1200 + )
1072 } 1201 }
1073 }) 1202 })
1074 - .catch(reason => {  
1075 - let rules = reason.map(obj => {  
1076 - return obj.rule  
1077 - })  
1078 - if (  
1079 - this_.formData &&  
1080 - this_.formData.typeName &&  
1081 - this_.formData.name &&  
1082 - this_.formData.formKey  
1083 - ) {  
1084 - if (rules.includes('isExist')) {  
1085 - this.$message.error('表单别名重复')  
1086 - } else if (rules.includes('regex')) {  
1087 - this.$message.error(  
1088 - '只能输入字母、数字、下划线,且以字母开头'  
1089 - )  
1090 - } else {  
1091 - this.$message.error('表单校验不通过')  
1092 - }  
1093 - } else {  
1094 - //获取到报错后的规则数组  
1095 - if (rules.includes('required')) {  
1096 - this.$message.error('请完整填写表单内容')  
1097 - } else if (rules.includes('isExist')) {  
1098 - this.$message.error('表单别名重复') 1203 + } else {
  1204 + this.mainBoFields.forEach(item => {
  1205 + for (let q = 0; q < item.children.length; q++) {
  1206 + for (let i = 0; i < item.children.length - 1 - q; i++) {
  1207 + if (item.children[i].index > item.children[i + 1].index) {
  1208 + let temp = item.children[i]
  1209 + item.children[i] = item.children[i + 1]
  1210 + item.children[i + 1] = temp
  1211 + }
1099 } 1212 }
1100 } 1213 }
1101 - this.activeTabName = 'form'  
1102 }) 1214 })
1103 - } else {  
1104 - let arr = this_.$root.$validator.errors.items.filter(  
1105 - item => item.scope == 'field'  
1106 - )  
1107 - let errorLength = arr.length  
1108 - this.activeTabName = 'field'  
1109 - this_.$message({  
1110 - showClose: true,  
1111 - message: `有${errorLength}个字段未通过校验,请正确填写表单内容。`,  
1112 - type: 'warning'  
1113 - }) 1215 + this.tableFields = this.mainBoFields
  1216 + }
1114 } 1217 }
1115 - })  
1116 - },  
1117 - filterFields(obj) {  
1118 - if (  
1119 - (obj.columnType == 'clob' || obj.dataType == 'clob') &&  
1120 - this.clobFieldList.indexOf(this.field.ctrlType) == -1  
1121 - ) {  
1122 - return false  
1123 - }  
1124 - if (this.field.ctrlType == 'handSignature') { 1218 + this.setTableFieldsChildren(this.tableFields, val && val.ctrlType)
  1219 + //合并数组对象
  1220 + let allModelingData = []
  1221 + let allBoData = []
  1222 + let formVarData = []
  1223 + let returnData = [] //对话框返回值选择的字段信息 主表对应主表,子表对应子表,孙表对应孙表。
  1224 + let returnTypes = ['select', 'dropdown', 'dialog']
1125 if ( 1225 if (
1126 - (obj.columnType == 'clob' || obj.dataType == 'clob') &&  
1127 - obj.fieldName != 'id_' &&  
1128 - obj.fieldName != 'ref_id_' 1226 + (val &&
  1227 + ['suntable', 'sunDiv'].includes(val.ctrlType) &&
  1228 + this.currentBoSubEntity) ||
  1229 + (val && val.parentNodeType == 'sun')
1129 ) { 1230 ) {
1130 - return true 1231 + this.mainBoFields.forEach(mainBoField => {
  1232 + formVarData.push({...mainBoField})
  1233 + allBoData.push({...mainBoField})
  1234 + allModelingData.push({...mainBoField})
  1235 + })
  1236 + this.subTables.forEach(subTable => {
  1237 + allModelingData.push({...subTable})
  1238 + let sunTabs = this.sunTablesMap[subTable.name]
  1239 + if (sunTabs) {
  1240 + sunTabs.forEach(sunTab => {
  1241 + allModelingData.push({...sunTab})
  1242 + })
  1243 + }
  1244 + })
  1245 + if (this.sunTables && this.sunTables.length > 0) {
  1246 + this.sunTables.forEach(sunTable => {
  1247 + if (val && val.parentNodeType == 'sun') {
  1248 + if (sunTable.name == val.boSubEntity) {
  1249 + allBoData.push({...sunTable})
  1250 + formVarData.push({...sunTable})
  1251 + returnData.push({...sunTable})
  1252 + }
  1253 + } else {
  1254 + allBoData.push({...sunTable})
  1255 + formVarData.push({...sunTable})
  1256 + returnData.push({...sunTable})
  1257 + }
  1258 + })
  1259 + }
  1260 + } else {
  1261 + if (
  1262 + val &&
  1263 + val.parentNodeType != 'sub' &&
  1264 + returnTypes.includes(val.ctrlType)
  1265 + ) {
  1266 + //添加主表字段
  1267 + this.mainBoFields.forEach(mainBoField => {
  1268 + returnData.push({...mainBoField})
  1269 + })
  1270 + } else if (
  1271 + val &&
  1272 + val.parentNodeType == 'sub' &&
  1273 + returnTypes.includes(val.ctrlType)
  1274 + ) {
  1275 + //添加子表字段
  1276 + this.subTables.forEach(subTable => {
  1277 + returnData.push({...subTable})
  1278 + })
  1279 + }
  1280 + //添加主表字段
  1281 + this.mainBoFields.forEach(mainBoField => {
  1282 + allBoData.push({...mainBoField})
  1283 + })
  1284 + this.subTables.forEach(subTable => {
  1285 + allBoData.push({...subTable})
  1286 + let sunTabs = this.sunTablesMap[subTable.name]
  1287 + if (sunTabs) {
  1288 + sunTabs.forEach(sunTab => {
  1289 + allBoData.push({...sunTab})
  1290 + })
  1291 + }
  1292 + })
  1293 + formVarData = allBoData
1131 } 1294 }
1132 - return false  
1133 - }  
1134 - if (this.field.ctrlType == 'richText') { 1295 + //判断无属性控件 按钮
1135 if ( 1296 if (
1136 - obj.columnType != 'number' &&  
1137 - obj.columnType != 'date' &&  
1138 - obj.fieldName != 'id_' &&  
1139 - obj.fieldName != 'ref_id_' 1297 + (this.isNoAttrField(val) || this.isAllowNoAttributes(val)) &&
  1298 + this.tableFields &&
  1299 + this.tableFields.length > 0
1140 ) { 1300 ) {
1141 - return true  
1142 - }  
1143 - return false  
1144 - }  
1145 - if (this.field.ctrlType == 'signature') {  
1146 - //审批签章不能绑定数字和日期属性的字段  
1147 - if (obj.columnType != 'number' && obj.columnType != 'date') {  
1148 - return true 1301 + if (val && !val.name) {
  1302 + this.$set(val, 'name', 'c_' + val.key)
  1303 + }
  1304 + if (val && !val.boDefAlias) {
  1305 + if (val.parentNodeType == 'sub' || val.parentNodeType == 'sun') {
  1306 + const paths = this.tableFields[0].path.split('.')
  1307 + this.$set(val, 'boDefAlias', paths[0])
  1308 + } else {
  1309 + this.$set(val, 'boDefAlias', this.tableFields[0].boDefAlias)
  1310 + }
  1311 + }
  1312 + if (val && !val.tableName) {
  1313 + this.$set(val, 'tableName', this.tableFields[0].name)
  1314 + this.changeNoAttrFile(this.tableFields[0].name)
  1315 + }
  1316 + this.noAttrFieldListChange(val, true)
  1317 + } else if (
  1318 + val &&
  1319 + val.ctrlType == 'button' &&
  1320 + val.options.bindEventjson &&
  1321 + val.options.bindEventjson.isShowInput
  1322 + ) {
  1323 + this.noAttrFieldListChange(val, false)
1149 } 1324 }
1150 - return false  
1151 - }  
1152 -  
1153 - if (this.filterListType.indexOf(this.field.ctrlType) > -1) { 1325 + this.allModelingData = allModelingData
  1326 + this.allBoData = allBoData
  1327 + this.formVarData = formVarData
  1328 + this.returnData = returnData
  1329 + // this.$emit('update:data', val)
  1330 + //通过模板生成的表单字段需更改为 建模别名.字段名 (解决2个不同的建模,但主表建模字段一样)
1154 if ( 1331 if (
1155 - this.field.ctrlType == 'date' &&  
1156 - this.field.options.dataType != 'date' 1332 + val &&
  1333 + val.target &&
  1334 + val.parentNodeType != 'sub' &&
  1335 + val.parentNodeType != 'sun'
1157 ) { 1336 ) {
1158 - this.field.options.dataType = 'date'  
1159 - } else if (this.field.ctrlType == 'switch') {  
1160 - this.field.options.dataType = 'varchar'  
1161 - } else if (this.field.ctrlType == 'number') {  
1162 - this.field.options.dataType = 'number' 1337 + if (!utils.isEmpty(val.boDefAlias) && !utils.isEmpty(val.name)) {
  1338 + val.target = val.boDefAlias + '.' + val.name
  1339 + }
1163 } 1340 }
1164 -  
1165 - return obj.dataType == this.field.options.dataType  
1166 - } else if (obj.nodeType == 'sub') {  
1167 - return false  
1168 - } else {  
1169 - return true  
1170 - } 1341 + },
  1342 + deep: true
1171 }, 1343 },
1172 - flowComponentsFilter(item) {  
1173 - if (this.field.boSubEntity) {  
1174 - return ![  
1175 - 'processForecast',  
1176 - 'related-process',  
1177 - 'handSignature',  
1178 - 'signature',  
1179 - 'opinion'  
1180 - ].includes(item.ctrlType) 1344 + 'field.ctrlType': {
  1345 + handler(newVal, oldVal) {
  1346 + if (oldVal == undefined || newVal == undefined || newVal == oldVal) {
  1347 + return
  1348 + }
  1349 + if (!this.isWatch) {
  1350 + return
  1351 + }
  1352 + if (newVal === 'rate') {
  1353 + this.changeCtrlType(false,'rate')
  1354 + } else if (['number', 'currency'].includes(oldVal)) {
  1355 + if (newVal == 'date' || newVal == 'time') {
  1356 + this.changeCtrlType(true)
  1357 + } else {
  1358 + this.changeCtrlType(false)
  1359 + }
  1360 + } else if (oldVal == 'date' || oldVal == 'time') {
  1361 + if (newVal == 'number' || newVal == 'currency') {
  1362 + this.changeCtrlType(true)
  1363 + } else {
  1364 + this.changeCtrlType(false)
  1365 + }
  1366 + } else if (newVal == 'select') {
  1367 + this.changeCtrlType(false)
  1368 + } else {
  1369 + if (['number', 'currency'].includes(newVal)) {
  1370 + if (this.field.columnType == 'number') {
  1371 + this.changeCtrlType(false)
  1372 + } else {
  1373 + this.changeCtrlType(true)
  1374 + }
  1375 + } else if (newVal == 'date' || newVal == 'time') {
  1376 + this.changeCtrlType(false)
  1377 + } else if (newVal == 'switch') {
  1378 + this.changeCtrlType(false)
  1379 + } else {
  1380 + this.changeCtrlType(false)
  1381 + }
  1382 + }
  1383 + this.isWatch = false
  1384 + const validateList = this.field.options.validateList
  1385 + ? [
  1386 + ...this.field.options.validateList,
  1387 + {
  1388 + key: 'required',
  1389 + name: '*必填'
  1390 + }
  1391 + ]
  1392 + : [
  1393 + {
  1394 + key: 'required',
  1395 + name: '*必填'
  1396 + }
  1397 + ]
  1398 + const hasValidateRules =
  1399 + this.field.options.validateType &&
  1400 + this.field.options.validateType.includes('required')
  1401 + this.tableFields.forEach(boData => {
  1402 + boData.children.forEach((v, i) => {
  1403 + if (
  1404 + hasValidateRules &&
  1405 + this.field.fieldPath === v.keyName &&
  1406 + v.isRequired
  1407 + ) {
  1408 + this.$set(
  1409 + this.field.options,
  1410 + 'validateList',
  1411 + uniqueArrayObject(validateList, 'key')
  1412 + )
  1413 + if (this.field.options && !this.field.options.validate) {
  1414 + this.$set(this.field.options, 'validate', "'required'")
  1415 + }
  1416 + }
  1417 + })
  1418 + })
1181 } 1419 }
1182 - return true  
1183 }, 1420 },
1184 - //高级控件  
1185 - filterAdvanceFields(obj) {  
1186 - //子/孙表不能选择的控件类型 返回false 不能选择  
1187 - let types = ['dataView', 'formTable', 'QRcode', 'milepost', 'customChart']  
1188 - if (this.field.boSubEntity && types.includes(obj.ctrlType)) {  
1189 - return false  
1190 - }  
1191 - if (  
1192 - (this.field.hasOwnProperty('boSubEntity') || this.isColumnLayout()) &&  
1193 - ['formTable', 'dataView'].includes(obj.ctrlType)  
1194 - ) {  
1195 - return false 1421 + widgetForm(val) {
  1422 + this.widgetFormData = val
  1423 + if (val.submitVerification && val.submitVerification.length > 0) {
  1424 + this.submitVerification = JSON.parse(
  1425 + Base64.decode(val.submitVerification)
  1426 + )
  1427 + } else {
  1428 + this.submitVerification = []
1196 } 1429 }
1197 - return true  
1198 }, 1430 },
1199 - isColumnLayout() {  
1200 - let isGrid = false  
1201 - const result = this.widgetForm.list.map(item => {  
1202 - if (item.ctrlType === 'grid') {  
1203 - return item.columns.map(it => {  
1204 - return it.list.some(field => field.key === this.field.key)  
1205 - })  
1206 - }  
1207 - })  
1208 - if (result && result.length) {  
1209 - isGrid = result.flat().filter(Boolean).length > 0  
1210 - }  
1211 - return isGrid  
1212 - },  
1213 - //basicsProperty调用showSelectQueryDialog  
1214 - basicsPropertyShowSelectQueryDialog() {  
1215 - this.showSelectQueryDialog() 1431 + submitVerification: {
  1432 + handler(val) {
  1433 + this.$set(
  1434 + this.widgetFormData,
  1435 + 'submitVerification',
  1436 + Base64.encode(JSON.stringify(this.submitVerification), 'utf-8')
  1437 + )
  1438 + },
  1439 + deep: true
1216 }, 1440 },
1217 - //常用控件  
1218 - filterFieldsByCurrentField(obj, value) {  
1219 - //获取table布局中控件的key  
1220 - const controlKeys = this.getTableLayoutOfControlKeys()  
1221 - if (obj.ctrlType === 'amap' && controlKeys.includes(this.field.key)) {  
1222 - return false  
1223 - }  
1224 - //子/孙表不能选择的控件类型 返回false 不能选择  
1225 - let types = [  
1226 - 'related-process',  
1227 - 'amap',  
1228 - 'signature',  
1229 - 'handSignature',  
1230 - 'milepost',  
1231 - 'customChart',  
1232 - 'dataView',  
1233 - 'formTable',  
1234 - 'divider',  
1235 - 'QRcode'  
1236 - ]  
1237 - let attributeType = null 1441 + // 根据绑定属性过滤空间类型
  1442 + 'field.target': {
  1443 + handler(val) {
  1444 + this.filterBasicComponents = basicComponents.filter(obj => {
  1445 + return this.filterFieldsByCurrentField(obj, val)
  1446 + })
  1447 + },
  1448 + deep: true
  1449 + }
  1450 + },
  1451 +
  1452 + created() {
  1453 + this.field = this.data
  1454 + const me_ = this
  1455 + //表单初始化时收集无属性控件字段
  1456 + WidgetFormBus.$off('initNoAttrField')
  1457 + WidgetFormBus.$on('initNoAttrField', obj => {
1238 if ( 1458 if (
1239 - this.field &&  
1240 - this.field.boSubEntity &&  
1241 - types.includes(obj.ctrlType) 1459 + (this.isNoAttrField(obj) || this.isAllowNoAttributes(obj)) &&
  1460 + obj.tableName
1242 ) { 1461 ) {
1243 - return false  
1244 - }  
1245 - if (!obj.options.dataType) {  
1246 - return true  
1247 - }  
1248 - if (this.field && !this.field.options) {  
1249 - return true  
1250 - }  
1251 - if (this.field && !this.field.options.dataType) {  
1252 - return true  
1253 - }  
1254 - if (this.field && this.field.options.dataType == obj.options.dataType) {  
1255 - return true  
1256 - }  
1257 - let dataTypes = obj.options.dataType.split('|')  
1258 - if (dataTypes.indexOf('string') != -1) {  
1259 - dataTypes.push('varchar')  
1260 - dataTypes.push('nvarchar') 1462 + me_.noAttrFieldListChange(obj, false)
1261 } 1463 }
1262 - this.tableFields.forEach(boData => {  
1263 - boData.children.forEach((v, i) => {  
1264 - if (v.keyName == value) {  
1265 - attributeType = v.dataType 1464 + })
  1465 + if (!this.formData.formSetting.display) {
  1466 + this.formData.formSetting = JSON.stringify(this.formSetting)
  1467 + }
  1468 + },
  1469 +
  1470 + mounted() {
  1471 + // 声明
  1472 + this.$validator = this.$root.$validator
  1473 + // 复制高级字段列表
  1474 + this.copyAdvanceComponents = this.advanceComponents.slice()
  1475 + },
  1476 +
  1477 + destroyed() {},
  1478 +
  1479 + methods: {
  1480 + confirmDynamic(data) {
  1481 + this.$set(this.widgetFormData, 'globalDynamicControl', data)
  1482 + },
  1483 + // 显示动态控件配置页面
  1484 + showDynamicDialog() {
  1485 + this.$refs.dynamicControlRef.showDialog(this.widgetFormData)
  1486 + },
  1487 + ...mapMutations({
  1488 + setSelectWidget: 'form/setSelectWidget' // 设置当前选中控件
  1489 + }),
  1490 + getTableLayoutOfControlKeys() {
  1491 + let keys = []
  1492 + if (this.widgetForm.list && this.widgetForm.list.length) {
  1493 + this.widgetForm.list.map(item => {
  1494 + if (item.isLayout && item.ctrlType == 'table') {
  1495 + item.rows.map(it => {
  1496 + if (it.cols && it.cols.length) {
  1497 + it.cols.map(col => {
  1498 + if (col.list && col.list.length) {
  1499 + col.list.map(list => {
  1500 + keys.push(list.key)
  1501 + })
  1502 + }
  1503 + })
  1504 + }
  1505 + })
1266 } 1506 }
1267 }) 1507 })
1268 - })  
1269 - if (attributeType != 'number') {  
1270 - return (  
1271 - attributeType != 'number' &&  
1272 - obj.ctrlType != 'rate' &&  
1273 - obj.ctrlType != 'slider'  
1274 - )  
1275 } 1508 }
1276 - // 数字控件不能绑定日期控件  
1277 - if (this.field.options.dataType == 'number') {  
1278 - return obj.options.dataType != 'date'  
1279 - }  
1280 - // 日期控件不能绑定数字控件  
1281 - if (this.field.options.dataType == 'date') {  
1282 - return obj.options.dataType != 'number' 1509 + return keys
  1510 + },
  1511 + getSubtableType(type) {
  1512 + this.subTableLayoutType = type
  1513 + },
  1514 + setTableFieldsChildren(data, ctrlType) {
  1515 + if (['checkbox', 'radio', 'select'].includes(ctrlType)) {
  1516 + const copyDate = JSON.parse(JSON.stringify(data))
  1517 + copyDate.map(item => {
  1518 + const options = item.children.filter(
  1519 + it => it.dataType !== 'number' && it.dataType !== 'date'
  1520 + )
  1521 + this.$set(item, 'children', options)
  1522 + })
  1523 + this.tableFields = copyDate
1283 } 1524 }
1284 - // 大文本类型默认多行文本和附件  
1285 - if (this.field.options.dataType == 'clob') {  
1286 - if (obj.ctrlType == 'textarea' || obj.ctrlType == 'attachment') {  
1287 - return true 1525 + },
  1526 + //重置表单配置信息
  1527 + formSettingReset() {
  1528 + this.formSetting.align = 'right'
  1529 + this.formSetting.customColon = false
  1530 + this.formSetting.fontColor = 'rgb(150, 151, 153)'
  1531 + this.formSetting.display = 'block'
  1532 + this.formSetting.roInputDisplayMode = 'text'
  1533 + this.formSetting.labelPosition = false
  1534 + },
  1535 + //打开表单配置弹框
  1536 + formSettingClick() {
  1537 + if (this.formData.formSetting) {
  1538 + this.formSetting = {
  1539 + ...this.formSetting,
  1540 + ...JSON.parse(this.formData.formSetting)
1288 } 1541 }
1289 } 1542 }
1290 - // 字符串类型可以选择所有字段  
1291 - let charArr = ['string', 'varchar', 'nvarchar']  
1292 -  
1293 - // 需要兼容以前的代码 this.field.options.dataType == ""  
1294 - let result = this.field.options.dataType.split('|').filter(item => {  
1295 - return dataTypes.indexOf(item) != -1 || charArr.indexOf(item) != -1  
1296 - })  
1297 -  
1298 - if (result && result.length >= 1) {  
1299 - return true  
1300 - }  
1301 - return false 1543 + this.formSettingVisible = true
1302 }, 1544 },
1303 - /**  
1304 - * 新旧属性的替换,并保留原有的双向绑定,  
1305 - * 具体逻辑为:  
1306 - * 1.新属性有值的,旧属性没有的,新增  
1307 - * 2.新属性没有的,旧属性有的,删除  
1308 - * 3.新属性有的,旧属性也有,,则保留旧属性(desc等一些特殊key 需要特殊逻辑处理)  
1309 - */  
1310 - attributeToReplace(oldV, newV) {  
1311 - for (let key in oldV) {  
1312 - //2.新属性没有的,旧属性有的,删除  
1313 - if (  
1314 - key != 'key' &&  
1315 - newV[key] === undefined &&  
1316 - (oldV[key] || oldV[key] === '')  
1317 - ) {  
1318 - delete oldV[key]  
1319 - } 1545 + //保存表单配置信息
  1546 + formSettingOk() {
  1547 + this.formData.formSetting = JSON.stringify(this.formSetting)
  1548 + this.formSettingVisible = false
  1549 + },
  1550 + //打开添加表单提交校验配置弹框
  1551 + formSubmitVerificationClick(index) {
  1552 + let item = null
  1553 + if (typeof index !== 'undefined' && index >= 0) {
  1554 + item = this.submitVerification[index]
  1555 + this.currentSubmitVerificationIndex = index
  1556 + } else {
  1557 + this.currentSubmitVerificationIndex = -1
1320 } 1558 }
1321 - for (let key in newV) {  
1322 - let value = newV[key]  
1323 - //1.新属性有值的,旧属性没有的,新增  
1324 - if (oldV[key] === undefined || oldV[key] === '') {  
1325 - this.$set(oldV, key, value)  
1326 - //3.新属性有的,旧属性也有,,则保留旧属性(options等一些特殊key 需要特殊逻辑处理)  
1327 - } else {  
1328 - if (key === 'options') {  
1329 - // 保留绑定的dataType  
1330 - let boDataType = oldV[key].dataType  
1331 - oldV[key] = value  
1332 - if (boDataType) {  
1333 - oldV[key].dataType = boDataType  
1334 - }  
1335 - }  
1336 - } 1559 + this.$refs.submitVerificationDialog.handleOpen(item)
  1560 + },
  1561 + //保存表单提交校验配置信息
  1562 + formSubmitVerificationOk(verification) {
  1563 + if (!this.submitVerification) {
  1564 + this.submitVerification = []
1337 } 1565 }
1338 - //旧属性有值 和新属性的值不一样 要重置  
1339 - for (let keys in oldV) {  
1340 - if (!(oldV[keys] instanceof Object)) {  
1341 - if (oldV[keys] != newV[keys] && newV[keys] != undefined) {  
1342 - oldV[keys] = newV[keys]  
1343 - }  
1344 - } 1566 + if (this.currentSubmitVerificationIndex > -1) {
  1567 + this.submitVerification[
  1568 + this.currentSubmitVerificationIndex
  1569 + ] = verification
  1570 + } else {
  1571 + this.submitVerification.push(verification)
1345 } 1572 }
1346 }, 1573 },
1347 - //切换控件类型对应改变属性  
1348 - changeCtrlType(isClean,type) {  
1349 - const me_ = this  
1350 - const selectObj = deepmerge({}, me_.field, {clone: true})  
1351 - basicComponents.forEach(item => {  
1352 - if (me_.field.ctrlType == item.ctrlType) {  
1353 - // me_.field = deepmerge({}, item, { clone: true });  
1354 - let i = deepmerge({}, item, {clone: true})  
1355 - i.parentNodeType = me_.data.parentNodeType  
1356 - i.boSubEntity = me_.data.boSubEntity  
1357 - me_.attributeToReplace(me_.field, i)  
1358 -  
1359 - me_.field.key = me_.data.key  
1360 - me_.field.tableName = selectObj.tableName  
1361 - me_.field.target = selectObj.target  
1362 -  
1363 -  
1364 - if (!isClean) {  
1365 - me_.field.boDefId = selectObj.boDefId  
1366 - me_.field.target = selectObj.target  
1367 - me_.field.boAttrId = selectObj.boAttrId  
1368 - me_.field.fieldPath = selectObj.fieldPath  
1369 - me_.field.name = selectObj.name  
1370 - me_.field.desc = selectObj.desc  
1371 - me_.field.title = selectObj.desc  
1372 - me_.field.entId = selectObj.entId  
1373 - me_.field.boDefAlias = selectObj.boDefAlias  
1374 - me_.field.tableName = selectObj.tableName  
1375 - me_.field.columnType = selectObj.columnType  
1376 - if(!type){  
1377 - me_.field.options.format = selectObj.options.format  
1378 - me_.field.options.inputFormat = selectObj.options.format  
1379 - me_.field.options.decimalDigits = selectObj.options.decimalDigits  
1380 - me_.field.options.maxDecimalDigits =  
1381 - selectObj.options.maxDecimalDigits  
1382 - me_.field.options.max = selectObj.options.max  
1383 - me_.field.options.numberMax = selectObj.options.numberMax  
1384 - me_.field.options.numberMin = selectObj.options.numberMin  
1385 - me_.field.options.min = selectObj.options.min  
1386 - }  
1387 - }  
1388 - if (item.ctrlType == 'amap') {  
1389 - me_.field.options.dataType = 'varchar'  
1390 - }  
1391 - if (item.ctrlType == 'switch') {  
1392 - me_.field.options.dataType = 'varchar'  
1393 - }  
1394 - //me_.$emit("data:update", me_.field);  
1395 - //WidgetFormBus.$emit("changeCtrlType", me_.field);  
1396 - }  
1397 - })  
1398 - flowComponents.forEach(item => {  
1399 - if (me_.field.ctrlType == item.ctrlType) {  
1400 - // me_.field = deepmerge({}, item, { clone: true });  
1401 - let i = deepmerge({}, item, {clone: true})  
1402 - i.parentNodeType = me_.data.parentNodeType  
1403 - i.boSubEntity = me_.data.boSubEntity  
1404 - me_.attributeToReplace(me_.field, i)  
1405 -  
1406 - me_.field.key = me_.data.key  
1407 - if (!isClean) {  
1408 - me_.field.boDefId = selectObj.boDefId  
1409 - me_.field.target = selectObj.target  
1410 - me_.field.boAttrId = selectObj.boAttrId  
1411 - me_.field.fieldPath = selectObj.fieldPath  
1412 - me_.field.name = selectObj.name  
1413 - me_.field.desc = selectObj.desc  
1414 - me_.field.title = selectObj.desc  
1415 - me_.field.entId = selectObj.entId  
1416 - me_.field.boDefAlias = selectObj.boDefAlias  
1417 - me_.field.tableName = selectObj.tableName  
1418 - me_.field.columnType = selectObj.columnType  
1419 - me_.field.options.format = selectObj.options.format  
1420 - me_.field.options.inputFormat = selectObj.options.format  
1421 - me_.field.options.decimalDigits = selectObj.options.decimalDigits  
1422 - me_.field.options.maxDecimalDigits =  
1423 - selectObj.options.maxDecimalDigits  
1424 - me_.field.options.max = selectObj.options.max  
1425 - me_.field.options.numberMax = selectObj.options.numberMax  
1426 - me_.field.options.numberMin = selectObj.options.numberMin  
1427 - me_.field.options.min = selectObj.options.min  
1428 - }  
1429 - }  
1430 - })  
1431 - advanceComponents.forEach(item => {  
1432 - if (me_.field.ctrlType == item.ctrlType) {  
1433 - // me_.field = deepmerge({}, item, { clone: true });  
1434 - let e = deepmerge({}, item, {clone: true})  
1435 - e.parentNodeType = me_.data.parentNodeType  
1436 - e.boSubEntity = me_.data.boSubEntity  
1437 - me_.attributeToReplace(me_.field, e)  
1438 - me_.field.key = me_.data.key  
1439 - // 如果是非绑定属性的 不用赋值  
1440 - if (item.options && item.options.noBindModel) {  
1441 - isClean = true  
1442 - }  
1443 - if (!isClean) {  
1444 - me_.field.boDefId = selectObj.boDefId  
1445 - me_.field.target = selectObj.target  
1446 - me_.field.boAttrId = selectObj.boAttrId  
1447 - me_.field.fieldPath = selectObj.fieldPath  
1448 - me_.field.name = selectObj.name  
1449 - me_.field.desc = selectObj.desc  
1450 - me_.field.title = selectObj.desc  
1451 - me_.field.entId = selectObj.entId  
1452 - me_.field.boDefAlias = selectObj.boDefAlias  
1453 - me_.field.tableName = selectObj.tableName  
1454 - me_.field.columnType = selectObj.columnType  
1455 - me_.field.options.format = selectObj.format  
1456 - me_.field.options.inputFormat = selectObj.format  
1457 - me_.field.options.decimalDigits = selectObj.options.decimalDigits  
1458 - me_.field.options.maxDecimalDigits =  
1459 - selectObj.options.maxDecimalDigits  
1460 - me_.field.options.max = selectObj.options.max  
1461 - me_.field.options.numberMax = selectObj.options.numberMax  
1462 - me_.field.options.numberMin = selectObj.options.numberMin  
1463 - me_.field.options.min = selectObj.options.min  
1464 - }  
1465 - if (item.ctrlType == 'amap') {  
1466 - me_.field.options.dataType = 'varchar'  
1467 - }  
1468 - // WidgetFormBus.$emit("changeCtrlType", me_.field);  
1469 - }  
1470 - })  
1471 - me_.$nextTick(() => {  
1472 - this.setSelectWidget(me_.field)  
1473 - })  
1474 - this.checkAndClearTarget()  
1475 - },  
1476 - //引入脚本和样式对象保存  
1477 - includeFilesOk() {  
1478 - if (!this.formHtml) {  
1479 - this.$message.warning('模板HTML不能为空!')  
1480 - return 1574 + saveValidate() {
  1575 + const this_ = this
  1576 + //这里先校验字段属性,再校验表单属性
  1577 + if(this.data.ctrlType =='tag'&& !this.data.options.tag){
  1578 + return this.$message.warning('请选择标签')
1481 } 1579 }
1482 - this.dialogincluddingFileVisible = false  
1483 - form  
1484 - .saveFormJs({  
1485 - formId: this.formData.id,  
1486 - diyJs: this.includeFiles.diyJs,  
1487 - formHtml: Base64.encode(this.formHtml, 'utf-8'),  
1488 - formExpand: Base64.encode(this.formExpand, 'utf-8')  
1489 - })  
1490 - .then(resp => {  
1491 - if (resp.state) {  
1492 - this.$message.success(resp.message)  
1493 - }  
1494 - })  
1495 - },  
1496 - variablesClick(data) {  
1497 - this.includeFiles.diyJs += data.value  
1498 - },  
1499 - afterformHtml(data) {  
1500 - this.formExpand = data.bpmForm.formExpand  
1501 - this.formHtml = data.bpmForm.formHtml  
1502 - this.includeFiles.diyJs = data.bpmForm.diyJs  
1503 - },  
1504 - includdingFile() {  
1505 - this.dialogincluddingFileVisible = true  
1506 - this.formHtmlUrl =  
1507 - '/form/form/v1/previewDesignVue?formId=' + this.formData.id  
1508 - this.includeFiles = this.formData.includeFiles  
1509 - ? Base64.decode(this.formData.includeFiles, 'utf-8')  
1510 - : {diyFile: ' ', diyCss: ' ', diyJs: ' '}  
1511 - },  
1512 - // 改变地图地址绑定的字段 设置fieldPath  
1513 - changeMap(value) {  
1514 - let selectObj = null  
1515 - this.tableFields.forEach(boData => {  
1516 - if (!selectObj) {  
1517 - selectObj = boData.children.find(opt => opt.name === value)  
1518 - if (selectObj) {  
1519 - selectObj.boDefAlias =  
1520 - boData.boDefAlias || boData.fieldPath.split('.')[0]  
1521 - selectObj.tableName = boData.name  
1522 - } 1580 + this_.$root.$validator.validateAll('field').then(result => {
  1581 + console.log(result)
  1582 + if (result) {
  1583 + utils
  1584 + .validateForm(this, 'editBpmForm')
  1585 + .then(() => {
  1586 + //手机表单保存时 表单类型指定为手机表单类型
  1587 + if (
  1588 + this_.formData.formType &&
  1589 + this_.formData.formType != 'mobile'
  1590 + ) {
  1591 + this_.formData.formType = 'pc'
  1592 + }
  1593 + // this.formData.name = this.formData.formName;
  1594 + const hasValidateForm =
  1595 + this.$refs.advancedProperty &&
  1596 + this.$refs.advancedProperty.$refs.validateProperty
  1597 + if (
  1598 + this.$refs.BasicsProperty &&
  1599 + this.$refs.BasicsProperty.validateKey()
  1600 + ) {
  1601 + return this.$message.warning(
  1602 + '下拉树或下拉框固定选项有重复的选项值,请重新输入'
  1603 + )
  1604 + }
  1605 + if (
  1606 + this.$refs.BasicsProperty &&
  1607 + this.$refs.BasicsProperty.validateFilterRange()
  1608 + ) {
  1609 + return this.$message.warning('请选择过滤范围')
  1610 + }
  1611 + if (hasValidateForm) {
  1612 + this.$refs.advancedProperty.$refs.validateProperty
  1613 + .getValidateFormResult()
  1614 + .then(result => {
  1615 + this_.$emit('saveEnd')
  1616 + })
  1617 + .catch(err => {
  1618 + if (err.length > 0) {
  1619 + return this.$message.warning(
  1620 + `有${err.length}个字段未通过校验,请正确填写校验规则。`
  1621 + )
  1622 + }
  1623 + })
  1624 + } else {
  1625 + this_.$emit('saveEnd')
  1626 + }
  1627 + })
  1628 + .catch(reason => {
  1629 + let rules = reason.map(obj => {
  1630 + return obj.rule
  1631 + })
  1632 + if (
  1633 + this_.formData &&
  1634 + this_.formData.typeName &&
  1635 + this_.formData.name &&
  1636 + this_.formData.formKey
  1637 + ) {
  1638 + if (rules.includes('isExist')) {
  1639 + this.$message.error('表单别名重复')
  1640 + } else if (rules.includes('regex')) {
  1641 + this.$message.error(
  1642 + '只能输入字母、数字、下划线,且以字母开头'
  1643 + )
  1644 + } else {
  1645 + this.$message.error('表单校验不通过')
  1646 + }
  1647 + } else {
  1648 + //获取到报错后的规则数组
  1649 + if (rules.includes('required')) {
  1650 + this.$message.error('请完整填写表单内容')
  1651 + } else if (rules.includes('isExist')) {
  1652 + this.$message.error('表单别名重复')
  1653 + }
  1654 + }
  1655 + this.activeTabName = 'form'
  1656 + })
  1657 + } else {
  1658 + let arr = this_.$root.$validator.errors.items.filter(
  1659 + item => item.scope == 'field'
  1660 + )
  1661 + let errorLength = arr.length
  1662 + this.activeTabName = 'field'
  1663 + this_.$message({
  1664 + showClose: true,
  1665 + message: `有${errorLength}个字段未通过校验,请正确填写表单内容。`,
  1666 + type: 'warning'
  1667 + })
1523 } 1668 }
1524 }) 1669 })
1525 - this.field.options.locationPath = selectObj.path + '.' + selectObj.name  
1526 }, 1670 },
1527 - // 改变绑定的字段 设置fieldPath  
1528 - change(value) {  
1529 - let selectObj = null  
1530 - this.fieldIndexData = {}  
1531 - this.tableFields.forEach(boData => {  
1532 - boData.children.forEach((v, i) => {  
1533 - let keyName = v.name  
1534 - if (value.indexOf('.') != -1) {  
1535 - keyName = v.path + '.' + v.name  
1536 - }  
1537 - if (v.isRequired && keyName == value) {  
1538 - if (!this.fieldIndexData.fieldName) {  
1539 - this.fieldIndexData.fieldName = v.fieldName  
1540 - this.fieldIndexData.index = i  
1541 - }  
1542 - }  
1543 - })  
1544 - if (!selectObj) {  
1545 - selectObj = boData.children.find(opt => opt.name === value)  
1546 - if (value.indexOf('.') != -1) {  
1547 - selectObj = boData.children.find(  
1548 - opt => opt.path + '.' + opt.name === value  
1549 - )  
1550 - }  
1551 -  
1552 - if (selectObj) {  
1553 - selectObj.boDefAlias =  
1554 - boData.boDefAlias || boData.path.split('.')[0]  
1555 - selectObj.tableName = boData.name  
1556 - } 1671 + filterFields(obj) {
  1672 + if (
  1673 + (obj.columnType == 'clob' || obj.dataType == 'clob') &&
  1674 + this.clobFieldList.indexOf(this.field.ctrlType) == -1
  1675 + ) {
  1676 + return false
  1677 + }
  1678 + if (this.field.ctrlType == 'handSignature') {
  1679 + if (
  1680 + (obj.columnType == 'clob' || obj.dataType == 'clob') &&
  1681 + obj.fieldName != 'id_' &&
  1682 + obj.fieldName != 'ref_id_'
  1683 + ) {
  1684 + return true
1557 } 1685 }
1558 - })  
1559 -  
1560 - if (!selectObj) {  
1561 - if (this.field.parentNodeType == 'sub') {  
1562 - this.field.fieldPath = 'item.' + value  
1563 - this.field.name = 'item.' + value  
1564 - } else {  
1565 - this.$message.warning('只允许子表绑定虚拟字段') 1686 + return false
  1687 + }
  1688 + if (this.field.ctrlType == 'richText') {
  1689 + if (
  1690 + obj.columnType != 'number' &&
  1691 + obj.columnType != 'date' &&
  1692 + obj.fieldName != 'id_' &&
  1693 + obj.fieldName != 'ref_id_'
  1694 + ) {
  1695 + return true
1566 } 1696 }
1567 - return 1697 + return false
1568 } 1698 }
1569 -  
1570 - this.field.boDefId = selectObj.boDefId  
1571 - this.field.boAttrId = selectObj.id  
1572 - if (this.field.parentNodeType == 'sub') {  
1573 - this.field.fieldPath = 'item.' + selectObj.name  
1574 - } else {  
1575 - this.field.fieldPath = selectObj.path + '.' + selectObj.name 1699 + if (this.field.ctrlType == 'signature') {
  1700 + //审批签章不能绑定数字和日期属性的字段
  1701 + if (obj.columnType != 'number' && obj.columnType != 'date') {
  1702 + return true
  1703 + }
  1704 + return false
1576 } 1705 }
1577 1706
1578 - this.field.options.dataType = selectObj.dataType  
1579 -  
1580 - this.field.name = selectObj.name  
1581 - this.field.desc = selectObj.desc  
1582 - this.field.title = selectObj.desc  
1583 - this.field.entId = selectObj.entId  
1584 - this.field.boDefAlias = selectObj.boDefAlias  
1585 - this.field.tableName = selectObj.tableName  
1586 - this.field.columnType = selectObj.columnType  
1587 - if (selectObj.dataType == 'date') {  
1588 - this.field.options.format = selectObj.format  
1589 - this.field.options.inputFormat = selectObj.format  
1590 - } else if (selectObj.dataType == 'number') {  
1591 - //如果为评分组件则默认最大值为5  
1592 - if (this.field.ctrlType === 'rate') {  
1593 - this.field.options.max = Number(this.field.options.max)  
1594 - } else {  
1595 - this.field.options.maxDecimalDigits = selectObj.decimalLen  
1596 - this.field.options.decimalDigits = selectObj.decimalLen  
1597 - this.field.options.max = Number(''.padStart(selectObj.charLen, '9'))  
1598 - this.field.options.numberMax = Number(  
1599 - ''.padStart(selectObj.charLen, '9')  
1600 - )  
1601 - this.field.options.numberMin = -Number(  
1602 - ''.padStart(selectObj.charLen, '9')  
1603 - )  
1604 - this.field.options.min = -Number(''.padStart(selectObj.charLen, '9')) 1707 + if (this.filterListType.indexOf(this.field.ctrlType) > -1) {
  1708 + if (
  1709 + this.field.ctrlType == 'date' &&
  1710 + this.field.options.dataType != 'date'
  1711 + ) {
  1712 + this.field.options.dataType = 'date'
  1713 + } else if (this.field.ctrlType == 'switch') {
  1714 + this.field.options.dataType = 'varchar'
  1715 + } else if (this.field.ctrlType == 'number') {
  1716 + this.field.options.dataType = 'number'
1605 } 1717 }
  1718 +
  1719 + return obj.dataType == this.field.options.dataType
  1720 + } else if (obj.nodeType == 'sub') {
  1721 + return false
  1722 + } else {
  1723 + return true
  1724 + }
  1725 + },
  1726 + flowComponentsFilter(item) {
  1727 + if (this.field.boSubEntity) {
  1728 + return ![
  1729 + 'processForecast',
  1730 + 'related-process',
  1731 + 'handSignature',
  1732 + 'signature',
  1733 + 'opinion'
  1734 + ].includes(item.ctrlType)
  1735 + }
  1736 + return true
  1737 + },
  1738 + //高级控件
  1739 + filterAdvanceFields(obj) {
  1740 + //子/孙表不能选择的控件类型 返回false 不能选择
  1741 + let types = ['dataView', 'formTable', 'QRcode', 'milepost', 'customChart']
  1742 + if (this.field.boSubEntity && types.includes(obj.ctrlType)) {
  1743 + return false
1606 } 1744 }
1607 - // bo属性中设置了必填 且 当前控件的校验规则为空  
1608 if ( 1745 if (
1609 - selectObj.isRequired == '1' &&  
1610 - (!this.field.options.validateList ||  
1611 - this.field.options.validateList.length == 0) 1746 + (this.field.hasOwnProperty('boSubEntity') || this.isColumnLayout()) &&
  1747 + ['formTable', 'dataView'].includes(obj.ctrlType)
1612 ) { 1748 ) {
1613 - this.$set(this.field.options, 'validateList', [  
1614 - {  
1615 - key: 'required',  
1616 - name: '*必填'  
1617 - }  
1618 - ]) 1749 + return false
1619 } 1750 }
1620 - this.$forceUpdate() 1751 + return true
1621 }, 1752 },
1622 - //给无属性控件设置关联ent属性  
1623 - changeNoAttrFile(value) {  
1624 - let _this = this  
1625 - this.tableFields.forEach(ent => {  
1626 - if (ent.name == value) {  
1627 - _this.$set(_this.field, 'entId', ent.id)  
1628 - _this.$set(_this.field, 'boDefId', ent.boDefId)  
1629 - if (!_this.field.boDefAlias) {  
1630 - _this.$set(_this.field, 'boDefAlias', ent.boDefAlias)  
1631 - }  
1632 - this.$forceUpdate()  
1633 - _this.noAttrFieldListChange(_this.field, true) 1753 + isColumnLayout() {
  1754 + let isGrid = false
  1755 + const result = this.widgetForm.list.map(item => {
  1756 + if (item.ctrlType === 'grid') {
  1757 + return item.columns.map(it => {
  1758 + return it.list.some(field => field.key === this.field.key)
  1759 + })
1634 } 1760 }
1635 }) 1761 })
  1762 + if (result && result.length) {
  1763 + isGrid = result.flat().filter(Boolean).length > 0
  1764 + }
  1765 + return isGrid
1636 }, 1766 },
1637 - //取消无属性设置  
1638 - changeNoBindModel() {  
1639 - if (this.field.options.noBindModel) {  
1640 - this.$set(this.field, 'name', 'c_' + this.field.key)  
1641 - this.noAttrFieldListChange(this.field, true)  
1642 - } else if (  
1643 - !this.field.options.noBindModel &&  
1644 - this.noAttrFieldList &&  
1645 - this.noAttrFieldList.length > 0 1767 + //basicsProperty调用showSelectQueryDialog
  1768 + basicsPropertyShowSelectQueryDialog() {
  1769 + this.showSelectQueryDialog()
  1770 + },
  1771 + //常用控件
  1772 + filterFieldsByCurrentField(obj, value) {
  1773 + //获取table布局中控件的key
  1774 + const controlKeys = this.getTableLayoutOfControlKeys()
  1775 + if (obj.ctrlType === 'amap' && controlKeys.includes(this.field.key)) {
  1776 + return false
  1777 + }
  1778 + //子/孙表不能选择的控件类型 返回false 不能选择
  1779 + let types = [
  1780 + 'related-process',
  1781 + 'amap',
  1782 + 'signature',
  1783 + 'handSignature',
  1784 + 'milepost',
  1785 + 'customChart',
  1786 + 'dataView',
  1787 + 'formTable',
  1788 + 'divider',
  1789 + 'QRcode'
  1790 + ]
  1791 + let attributeType = null
  1792 + if (
  1793 + this.field &&
  1794 + this.field.boSubEntity &&
  1795 + types.includes(obj.ctrlType)
1646 ) { 1796 ) {
1647 - this.$set(this.field, 'name', '')  
1648 - this.noAttrFieldListChange(this.field, false) 1797 + return false
1649 } 1798 }
1650 - if (this.field.ctrlType === 'number') {  
1651 - this.setDefaultValueForDigitalControl() 1799 + if (!obj.options.dataType) {
  1800 + return true
1652 } 1801 }
1653 - },  
1654 - setDefaultValueForDigitalControl() {  
1655 - this.field.options.max = 999999999  
1656 - this.field.options.numberMax = 999999999  
1657 - this.field.options.numberMin = -999999999  
1658 - this.field.options.min = 0  
1659 - },  
1660 - isChangeWatch() {  
1661 - this.isWatch = true  
1662 - //  
1663 - //  
1664 - // 切换时 处理合计  
1665 - if (this.widgetForm.list && this.widgetForm.list.length > 0) {  
1666 - this.widgetForm.list.forEach((item, index) => {  
1667 - if (item.name === this.field.tableName) {  
1668 - item.CombinedColumnList &&  
1669 - item.CombinedColumnList.forEach((ComItem, ComIndex) => {  
1670 - if (ComItem.columnField === this.field.name) {  
1671 - if (  
1672 - this.field.ctrlType != 'number' ||  
1673 - selitem.columnType != 'number'  
1674 - ) {  
1675 - item.CombinedColumnList.splice(ComIndex, 1)  
1676 - }  
1677 - }  
1678 - })  
1679 - this.$set(  
1680 - this.widgetForm.list[index],  
1681 - 'CombinedColumnListJson',  
1682 - Base64.encode(JSON.stringify(item.CombinedColumnList), 'utf-8')  
1683 - )  
1684 - }  
1685 - }) 1802 + if (this.field && !this.field.options) {
  1803 + return true
1686 } 1804 }
1687 - },  
1688 - //判断并清空绑定属性  
1689 - checkAndClearTarget() {  
1690 - if (!utils.isEmpty(this.field.target) && this.tableFields.length > 0) {  
1691 - this.tableFields.forEach((item, i) => {  
1692 - var items =  
1693 - this.tableFields[i].children &&  
1694 - this.tableFields[i].children.filter(obj => {  
1695 - return this.field.target == obj['keyName']  
1696 - })  
1697 -  
1698 - if (!items || items.length <= 0) {  
1699 - this.field.target = ''  
1700 - }  
1701 - if (!this.filterFields(items[0])) {  
1702 - this.field.target = '' 1805 + if (this.field && !this.field.options.dataType) {
  1806 + return true
  1807 + }
  1808 + if (this.field && this.field.options.dataType == obj.options.dataType) {
  1809 + return true
  1810 + }
  1811 + let dataTypes = obj.options.dataType.split('|')
  1812 + if (dataTypes.indexOf('string') != -1) {
  1813 + dataTypes.push('varchar')
  1814 + dataTypes.push('nvarchar')
  1815 + }
  1816 + this.tableFields.forEach(boData => {
  1817 + boData.children.forEach((v, i) => {
  1818 + if (v.keyName == value) {
  1819 + attributeType = v.dataType
1703 } 1820 }
1704 }) 1821 })
  1822 + })
  1823 + if (attributeType != 'number') {
  1824 + return (
  1825 + attributeType != 'number' &&
  1826 + obj.ctrlType != 'rate' &&
  1827 + obj.ctrlType != 'slider'
  1828 + )
1705 } 1829 }
1706 - },  
1707 - editI18nMessage(after) {  
1708 - this.i18nMessageKey = this.field.fieldPath || this.field.path  
1709 -  
1710 - if (this.createKeyMap[this.field.ctrlType]) {  
1711 - this.i18nMessageKey =  
1712 - this.formData.formKey +  
1713 - '.' +  
1714 - this.field.ctrlType +  
1715 - Math.random() * 5000  
1716 - }  
1717 - if (this.i18nMessageKey && after) {  
1718 - this.i18nMessageKey += after 1830 + // 数字控件不能绑定日期控件
  1831 + if (this.field.options.dataType == 'number') {
  1832 + return obj.options.dataType != 'date'
1719 } 1833 }
1720 - this.$refs.i18nMessageEdit.handleOpen()  
1721 - },  
1722 - afterSaveI18n(data) {  
1723 - data.key = data.key.replace('$', '#')  
1724 - if (data.prop.endsWith('placeholder')) {  
1725 - this.field.options.placeholder = data.key  
1726 - this.field.options.placeholder_zh = data.desc  
1727 - } else if (data.prop.endsWith('tip')) {  
1728 - this.tooltip = data.key  
1729 - } else {  
1730 - this.field.desc = data.key  
1731 - this.field.desc_zh = data.desc 1834 + // 日期控件不能绑定数字控件
  1835 + if (this.field.options.dataType == 'date') {
  1836 + return obj.options.dataType != 'number'
1732 } 1837 }
1733 - },  
1734 - isNoAttrField(field) {  
1735 - //无属性控件  
1736 - if (!field) {  
1737 - field = this.field 1838 + // 大文本类型默认多行文本和附件
  1839 + if (this.field.options.dataType == 'clob') {
  1840 + if (obj.ctrlType == 'textarea' || obj.ctrlType == 'attachment') {
  1841 + return true
  1842 + }
1738 } 1843 }
1739 - const unboundPropertyList = [  
1740 - 'text',  
1741 - 'immediate-single',  
1742 - 'immediate-textarea',  
1743 - 'flowChart',  
1744 - 'approvalHistory',  
1745 - 'opinion',  
1746 - 'big-title',  
1747 - 'small-title',  
1748 - 'simple-text',  
1749 - 'explain',  
1750 - 'dataView',  
1751 - 'formTable',  
1752 - 'QRcode',  
1753 - 'iframe',  
1754 - 'image',  
1755 - 'customChart',  
1756 - 'button',  
1757 - 'historicalApproval',  
1758 - 'processForecast'  
1759 - ] 1844 + // 字符串类型可以选择所有字段
  1845 + let charArr = ['string', 'varchar', 'nvarchar']
1760 1846
1761 - if (  
1762 - (field && unboundPropertyList.includes(field.ctrlType)) ||  
1763 - (field &&  
1764 - field.ctrlType == 'button' &&  
1765 - field.options.bindEventjson &&  
1766 - !field.options.bindEventjson.isShowInput)  
1767 - ) { 1847 + // 需要兼容以前的代码 this.field.options.dataType == ""
  1848 + let result = this.field.options.dataType.split('|').filter(item => {
  1849 + return dataTypes.indexOf(item) != -1 || charArr.indexOf(item) != -1
  1850 + })
  1851 +
  1852 + if (result && result.length >= 1) {
1768 return true 1853 return true
1769 } 1854 }
1770 return false 1855 return false
1771 }, 1856 },
1772 - isAllowNoAttributes(field) {  
1773 - //允许无属性控件  
1774 - if (!field) {  
1775 - field = this.field 1857 + /**
  1858 + * 新旧属性的替换,并保留原有的双向绑定,
  1859 + * 具体逻辑为:
  1860 + * 1.新属性有值的,旧属性没有的,新增
  1861 + * 2.新属性没有的,旧属性有的,删除
  1862 + * 3.新属性有的,旧属性也有,,则保留旧属性(desc等一些特殊key 需要特殊逻辑处理)
  1863 + */
  1864 + attributeToReplace(oldV, newV) {
  1865 + for (let key in oldV) {
  1866 + //2.新属性没有的,旧属性有的,删除
  1867 + if (
  1868 + key != 'key' &&
  1869 + newV[key] === undefined &&
  1870 + (oldV[key] || oldV[key] === '')
  1871 + ) {
  1872 + delete oldV[key]
  1873 + }
1776 } 1874 }
1777 - if (  
1778 - field &&  
1779 - this.allowNoAttributes.includes(field.ctrlType) &&  
1780 - field.options.noBindModel  
1781 - ) {  
1782 - return true 1875 + for (let key in newV) {
  1876 + let value = newV[key]
  1877 + //1.新属性有值的,旧属性没有的,新增
  1878 + if (oldV[key] === undefined || oldV[key] === '') {
  1879 + this.$set(oldV, key, value)
  1880 + //3.新属性有的,旧属性也有,,则保留旧属性(options等一些特殊key 需要特殊逻辑处理)
  1881 + } else {
  1882 + if (key === 'options') {
  1883 + // 保留绑定的dataType
  1884 + let boDataType = oldV[key].dataType
  1885 + oldV[key] = value
  1886 + if (boDataType) {
  1887 + oldV[key].dataType = boDataType
  1888 + }
  1889 + }
  1890 + }
  1891 + }
  1892 + //旧属性有值 和新属性的值不一样 要重置
  1893 + for (let keys in oldV) {
  1894 + if (!(oldV[keys] instanceof Object)) {
  1895 + if (oldV[keys] != newV[keys] && newV[keys] != undefined) {
  1896 + oldV[keys] = newV[keys]
  1897 + }
  1898 + }
1783 } 1899 }
1784 - return false  
1785 }, 1900 },
1786 - noAttrFieldListChange(field, isAdd) {  
1787 - //无属性控件的变化实时其更新联动列表  
1788 - let inList = false 1901 + //切换控件类型对应改变属性
  1902 + changeCtrlType(isClean,type) {
  1903 + const me_ = this
  1904 + const selectObj = deepmerge({}, me_.field, {clone: true})
  1905 + basicComponents.forEach(item => {
  1906 + if (me_.field.ctrlType == item.ctrlType) {
  1907 + // me_.field = deepmerge({}, item, { clone: true });
  1908 + let i = deepmerge({}, item, {clone: true})
  1909 + i.parentNodeType = me_.data.parentNodeType
  1910 + i.boSubEntity = me_.data.boSubEntity
  1911 + me_.attributeToReplace(me_.field, i)
1789 1912
1790 - this.noAttrFieldList.forEach(item => {  
1791 - if (item.key === field.key) {  
1792 - if (field.ctrlType == 'button') {  
1793 - field.desc = field.options.bindEventjson.name 1913 + me_.field.key = me_.data.key
  1914 + me_.field.tableName = selectObj.tableName
  1915 + me_.field.target = selectObj.target
  1916 +
  1917 +
  1918 + if (!isClean) {
  1919 + me_.field.boDefId = selectObj.boDefId
  1920 + me_.field.target = selectObj.target
  1921 + me_.field.boAttrId = selectObj.boAttrId
  1922 + me_.field.fieldPath = selectObj.fieldPath
  1923 + me_.field.name = selectObj.name
  1924 + me_.field.desc = selectObj.desc
  1925 + me_.field.title = selectObj.desc
  1926 + me_.field.entId = selectObj.entId
  1927 + me_.field.boDefAlias = selectObj.boDefAlias
  1928 + me_.field.tableName = selectObj.tableName
  1929 + me_.field.columnType = selectObj.columnType
  1930 + if(!type){
  1931 + me_.field.options.format = selectObj.options.format
  1932 + me_.field.options.inputFormat = selectObj.options.format
  1933 + me_.field.options.decimalDigits = selectObj.options.decimalDigits
  1934 + me_.field.options.maxDecimalDigits =
  1935 + selectObj.options.maxDecimalDigits
  1936 + me_.field.options.max = selectObj.options.max
  1937 + me_.field.options.numberMax = selectObj.options.numberMax
  1938 + me_.field.options.numberMin = selectObj.options.numberMin
  1939 + me_.field.options.min = selectObj.options.min
  1940 + }
1794 } 1941 }
1795 - if (  
1796 - ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType)  
1797 - ) {  
1798 - field.desc = field.options.textValue 1942 + if (item.ctrlType == 'amap') {
  1943 + me_.field.options.dataType = 'varchar'
1799 } 1944 }
1800 - if (isAdd) {  
1801 - inList = true  
1802 - } else {  
1803 - this.noAttrFieldList.remove(item)  
1804 - return 1945 + if (item.ctrlType == 'switch') {
  1946 + me_.field.options.dataType = 'varchar'
1805 } 1947 }
  1948 + //me_.$emit("data:update", me_.field);
  1949 + //WidgetFormBus.$emit("changeCtrlType", me_.field);
1806 } 1950 }
1807 }) 1951 })
1808 - if (isAdd && !inList) {  
1809 - if (field.ctrlType == 'button') {  
1810 - field.desc = field.options.bindEventjson.name  
1811 - }  
1812 - if (  
1813 - ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType)  
1814 - ) {  
1815 - field.desc = field.options.textValue 1952 + flowComponents.forEach(item => {
  1953 + if (me_.field.ctrlType == item.ctrlType) {
  1954 + // me_.field = deepmerge({}, item, { clone: true });
  1955 + let i = deepmerge({}, item, {clone: true})
  1956 + i.parentNodeType = me_.data.parentNodeType
  1957 + i.boSubEntity = me_.data.boSubEntity
  1958 + me_.attributeToReplace(me_.field, i)
  1959 +
  1960 + me_.field.key = me_.data.key
  1961 + if (!isClean) {
  1962 + me_.field.boDefId = selectObj.boDefId
  1963 + me_.field.target = selectObj.target
  1964 + me_.field.boAttrId = selectObj.boAttrId
  1965 + me_.field.fieldPath = selectObj.fieldPath
  1966 + me_.field.name = selectObj.name
  1967 + me_.field.desc = selectObj.desc
  1968 + me_.field.title = selectObj.desc
  1969 + me_.field.entId = selectObj.entId
  1970 + me_.field.boDefAlias = selectObj.boDefAlias
  1971 + me_.field.tableName = selectObj.tableName
  1972 + me_.field.columnType = selectObj.columnType
  1973 + me_.field.options.format = selectObj.options.format
  1974 + me_.field.options.inputFormat = selectObj.options.format
  1975 + me_.field.options.decimalDigits = selectObj.options.decimalDigits
  1976 + me_.field.options.maxDecimalDigits =
  1977 + selectObj.options.maxDecimalDigits
  1978 + me_.field.options.max = selectObj.options.max
  1979 + me_.field.options.numberMax = selectObj.options.numberMax
  1980 + me_.field.options.numberMin = selectObj.options.numberMin
  1981 + me_.field.options.min = selectObj.options.min
  1982 + }
1816 } 1983 }
1817 - this.$set(field, 'name', '')  
1818 - this.$set(field, 'target', field.name)  
1819 - if (  
1820 - (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') &&  
1821 - !field.options.noBindModel  
1822 - ) {  
1823 - this.$set(field, 'fieldPath', 'item.' + field.name)  
1824 - } else if (  
1825 - (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') &&  
1826 - field.options.noBindModel &&  
1827 - field.key  
1828 - ) {  
1829 - this.$set(field, 'fieldPath', 'item.' + `c_${field.key}`)  
1830 - } else if (field.options.noBindModel && field.boDefAlias && field.key) {  
1831 - this.$set(field, 'fieldPath', `${field.boDefAlias}.c_${field.key}`)  
1832 - } else if (field.boDefAlias) {  
1833 - this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name) 1984 + })
  1985 + advanceComponents.forEach(item => {
  1986 + if (me_.field.ctrlType == item.ctrlType) {
  1987 + // me_.field = deepmerge({}, item, { clone: true });
  1988 + let e = deepmerge({}, item, {clone: true})
  1989 + e.parentNodeType = me_.data.parentNodeType
  1990 + e.boSubEntity = me_.data.boSubEntity
  1991 + me_.attributeToReplace(me_.field, e)
  1992 + me_.field.key = me_.data.key
  1993 + // 如果是非绑定属性的 不用赋值
  1994 + if (item.options && item.options.noBindModel) {
  1995 + isClean = true
  1996 + }
  1997 + if (!isClean) {
  1998 + me_.field.boDefId = selectObj.boDefId
  1999 + me_.field.target = selectObj.target
  2000 + me_.field.boAttrId = selectObj.boAttrId
  2001 + me_.field.fieldPath = selectObj.fieldPath
  2002 + me_.field.name = selectObj.name
  2003 + me_.field.desc = selectObj.desc
  2004 + me_.field.title = selectObj.desc
  2005 + me_.field.entId = selectObj.entId
  2006 + me_.field.boDefAlias = selectObj.boDefAlias
  2007 + me_.field.tableName = selectObj.tableName
  2008 + me_.field.columnType = selectObj.columnType
  2009 + me_.field.options.format = selectObj.format
  2010 + me_.field.options.inputFormat = selectObj.format
  2011 + me_.field.options.decimalDigits = selectObj.options.decimalDigits
  2012 + me_.field.options.maxDecimalDigits =
  2013 + selectObj.options.maxDecimalDigits
  2014 + me_.field.options.max = selectObj.options.max
  2015 + me_.field.options.numberMax = selectObj.options.numberMax
  2016 + me_.field.options.numberMin = selectObj.options.numberMin
  2017 + me_.field.options.min = selectObj.options.min
  2018 + }
  2019 + if (item.ctrlType == 'amap') {
  2020 + me_.field.options.dataType = 'varchar'
  2021 + }
  2022 + // WidgetFormBus.$emit("changeCtrlType", me_.field);
1834 } 2023 }
1835 - } else if (field.boDefAlias && !field.fieldPath) {  
1836 - this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name) 2024 + })
  2025 + me_.$nextTick(() => {
  2026 + this.setSelectWidget(me_.field)
  2027 + })
  2028 + this.checkAndClearTarget()
  2029 + },
  2030 + //引入脚本和样式对象保存
  2031 + includeFilesOk() {
  2032 + if (!this.formHtml) {
  2033 + this.$message.warning('模板HTML不能为空!')
  2034 + return
1837 } 2035 }
1838 - this.noAttrFieldList.some((item, i) => {  
1839 - if (item.key === field.key) {  
1840 - this.noAttrFieldList.splice(i, 1)  
1841 - return true 2036 + this.dialogincluddingFileVisible = false
  2037 + form
  2038 + .saveFormJs({
  2039 + formId: this.formData.id,
  2040 + diyJs: this.includeFiles.diyJs,
  2041 + formHtml: Base64.encode(this.formHtml, 'utf-8'),
  2042 + formExpand: Base64.encode(this.formExpand, 'utf-8')
  2043 + })
  2044 + .then(resp => {
  2045 + if (resp.state) {
  2046 + this.$message.success(resp.message)
  2047 + }
  2048 + })
  2049 + },
  2050 + variablesClick(data) {
  2051 + this.includeFiles.diyJs += data.value
  2052 + },
  2053 + afterformHtml(data) {
  2054 + this.formExpand = data.bpmForm.formExpand
  2055 + this.formHtml = data.bpmForm.formHtml
  2056 + this.includeFiles.diyJs = data.bpmForm.diyJs
  2057 + },
  2058 + includdingFile() {
  2059 + this.dialogincluddingFileVisible = true
  2060 + this.formHtmlUrl =
  2061 + '/form/form/v1/previewDesignVue?formId=' + this.formData.id
  2062 + this.includeFiles = this.formData.includeFiles
  2063 + ? Base64.decode(this.formData.includeFiles, 'utf-8')
  2064 + : {diyFile: ' ', diyCss: ' ', diyJs: ' '}
  2065 + },
  2066 + streetChangeMap(value) {
  2067 + let selectObj = null
  2068 + this.tableFields.forEach((boData) => {
  2069 + if (!selectObj) {
  2070 + selectObj = boData.children.find((opt) => opt.name === value)
  2071 + if (selectObj) {
  2072 + selectObj.boDefAlias =
  2073 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2074 + selectObj.tableName = boData.name
  2075 + }
1842 } 2076 }
1843 }) 2077 })
1844 - this.noAttrFieldList.push(field) 2078 + this.field.options.streetPath = selectObj.path + '.' + selectObj.name
1845 }, 2079 },
1846 - showSelectQueryDialog() {  
1847 - //初始化关联查询用到的实体map  
1848 - this.initQueryEntMap()  
1849 - if (this.widgetFormData.config == undefined) {  
1850 - this.widgetFormData.config = {}  
1851 - }  
1852 - this.$refs.selectQueryDialog.showDialog(  
1853 - this.widgetFormData.config.globalQueryJson  
1854 - ) 2080 + districtChangeMap(value) {
  2081 + let selectObj = null
  2082 + this.tableFields.forEach((boData) => {
  2083 + if (!selectObj) {
  2084 + selectObj = boData.children.find((opt) => opt.name === value)
  2085 + if (selectObj) {
  2086 + selectObj.boDefAlias =
  2087 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2088 + selectObj.tableName = boData.name
  2089 + }
  2090 + }
  2091 + })
  2092 + this.field.options.districtPath = selectObj.path + '.' + selectObj.name
1855 }, 2093 },
1856 - //保存关联查询数据  
1857 - saveCustQueryJson(json) {  
1858 - this.$set(this.widgetFormData.config, 'globalQueryJson', json)  
1859 - this.$set(this.widgetForm.config, 'globalQueryJson', json) 2094 + cityChangeMap(value) {
  2095 + let selectObj = null
  2096 + this.tableFields.forEach((boData) => {
  2097 + if (!selectObj) {
  2098 + selectObj = boData.children.find((opt) => opt.name === value)
  2099 + if (selectObj) {
  2100 + selectObj.boDefAlias =
  2101 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2102 + selectObj.tableName = boData.name
  2103 + }
  2104 + }
  2105 + })
  2106 + this.field.options.cityPath = selectObj.path + '.' + selectObj.name
1860 }, 2107 },
1861 - initQueryEntMap() {  
1862 - if (this.mainBoFields && this.mainBoFields.length > 0) {  
1863 - this.queryEntMap['main'] = this.mainBoFields  
1864 - }  
1865 - if (this.subTables && this.subTables.length > 0) {  
1866 - this.queryEntMap['sub'] = this.subTables  
1867 - }  
1868 - if (this.sunTablesMap && Object.keys(this.sunTablesMap).length !== 0) {  
1869 - let sunTables = []  
1870 - for (var key in this.sunTablesMap) {  
1871 - if (this.sunTablesMap.hasOwnProperty(key)) {  
1872 - sunTables.push(...this.sunTablesMap[key]) 2108 + provinceChangeMap(value) {
  2109 + let selectObj = null
  2110 + this.tableFields.forEach((boData) => {
  2111 + if (!selectObj) {
  2112 + selectObj = boData.children.find((opt) => opt.name === value)
  2113 + if (selectObj) {
  2114 + selectObj.boDefAlias =
  2115 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2116 + selectObj.tableName = boData.name
1873 } 2117 }
1874 } 2118 }
1875 - this.queryEntMap['sun'] = sunTables  
1876 - } 2119 + })
  2120 + this.field.options.provincePath = selectObj.path + '.' + selectObj.name
1877 }, 2121 },
1878 - selectTypeChange(type) {  
1879 - if (type) {  
1880 - this.formData.typeId = type.id  
1881 - this.formData.typeName = type.name  
1882 - } else {  
1883 - this.formData.typeId = ''  
1884 - this.formData.typeName = ''  
1885 - }  
1886 - this.$forceUpdate() 2122 + latitudeChangeMap(value) {
  2123 + let selectObj = null
  2124 + this.tableFields.forEach((boData) => {
  2125 + if (!selectObj) {
  2126 + selectObj = boData.children.find((opt) => opt.name === value)
  2127 + if (selectObj) {
  2128 + selectObj.boDefAlias =
  2129 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2130 + selectObj.tableName = boData.name
  2131 + }
  2132 + }
  2133 + })
  2134 + this.field.options.latitudePath = selectObj.path + '.' + selectObj.name
1887 }, 2135 },
1888 - // 隐藏标题时 标题宽度赋值为0  
1889 - hideTitleChange(flag) {  
1890 - this.field.options.labelstyleWidth = flag ? '0' : ''  
1891 - }  
1892 - },  
1893 - watch: {  
1894 - data(val) {  
1895 - this.field = val 2136 +
  2137 + longitudeChangeMap(value) {
  2138 + let selectObj = null
  2139 + this.tableFields.forEach((boData) => {
  2140 + if (!selectObj) {
  2141 + selectObj = boData.children.find((opt) => opt.name === value)
  2142 + if (selectObj) {
  2143 + selectObj.boDefAlias =
  2144 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2145 + selectObj.tableName = boData.name
  2146 + }
  2147 + }
  2148 + })
  2149 + this.field.options.longitudePath = selectObj.path + '.' + selectObj.name
1896 }, 2150 },
1897 - field: {  
1898 - handler(val) {  
1899 - // 下拉框 多选isMultiple 属性废弃 使用options.multiple属性 为了兼容以前的代码 将isMultiple true 值赋值给 options.multiple属性  
1900 - if (val && val.ctrlType == 'select' && val.isMultiple) {  
1901 - val.options.multiple = true  
1902 - val.isMultiple = false 2151 + // 改变地图地址绑定的字段 设置fieldPath
  2152 + changeMap(value) {
  2153 + let selectObj = null
  2154 + this.tableFields.forEach(boData => {
  2155 + if (!selectObj) {
  2156 + selectObj = boData.children.find(opt => opt.name === value)
  2157 + if (selectObj) {
  2158 + selectObj.boDefAlias =
  2159 + boData.boDefAlias || boData.fieldPath.split('.')[0]
  2160 + selectObj.tableName = boData.name
  2161 + }
1903 } 2162 }
1904 -  
1905 - if (val && ['sub', 'sun'].includes(val.parentNodeType)) {  
1906 - if (val.boSubEntity || val.tableName) {  
1907 - this.currentBoSubEntity = val.boSubEntity  
1908 - this.tableFields = this.subTables.filter(  
1909 - item => item.name === val.boSubEntity || item.name === val.tableName  
1910 - )  
1911 - if (this.tableFields.length > 0) {  
1912 - for (let e = 0; e < this.tableFields.length; e++) {  
1913 - if (this.tableFields[e].children.length > 0) {  
1914 - for (  
1915 - let w = 0;  
1916 - w < this.tableFields[e].children.length;  
1917 - w++  
1918 - ) {  
1919 - this.tableFields[e].children[w].keyName = this.tableFields[  
1920 - e  
1921 - ].children[w].name  
1922 - }  
1923 - }  
1924 - } 2163 + })
  2164 + this.field.options.locationPath = selectObj.path + '.' + selectObj.name
  2165 + },
  2166 + // 改变绑定的字段 设置fieldPath
  2167 + change(value) {
  2168 + let selectObj = null
  2169 + this.fieldIndexData = {}
  2170 + this.tableFields.forEach(boData => {
  2171 + boData.children.forEach((v, i) => {
  2172 + let keyName = v.name
  2173 + if (value.indexOf('.') != -1) {
  2174 + keyName = v.path + '.' + v.name
  2175 + }
  2176 + if (v.isRequired && keyName == value) {
  2177 + if (!this.fieldIndexData.fieldName) {
  2178 + this.fieldIndexData.fieldName = v.fieldName
  2179 + this.fieldIndexData.index = i
1925 } 2180 }
1926 } 2181 }
  2182 + })
  2183 + if (!selectObj) {
  2184 + selectObj = boData.children.find(opt => opt.name === value)
  2185 + if (value.indexOf('.') != -1) {
  2186 + selectObj = boData.children.find(
  2187 + opt => opt.path + '.' + opt.name === value
  2188 + )
  2189 + }
1927 2190
1928 - //如果是孙表,则选取子表里的孙表供选择绑定  
1929 - if (  
1930 - ((val && val.ctrlType == 'suntable') || val.ctrlType == 'sunDiv') &&  
1931 - this.currentBoSubEntity  
1932 - ) {  
1933 - this.sunTables = this.sunTablesMap[this.currentBoSubEntity] || [] 2191 + if (selectObj) {
  2192 + selectObj.boDefAlias =
  2193 + boData.boDefAlias || boData.path.split('.')[0]
  2194 + selectObj.tableName = boData.name
1934 } 2195 }
1935 - //如果是孙表里的控件,则找到这个一个孙表供其选择属性  
1936 - if (val && val.parentNodeType == 'sun') {  
1937 - for (const subName in this.sunTablesMap) {  
1938 - let sunTabs = this.sunTablesMap[subName]  
1939 - if (sunTabs) {  
1940 - sunTabs.forEach(sunTab => {  
1941 - if (sunTab.name == this.currentBoSubEntity) {  
1942 - this.tableFields = [sunTab]  
1943 - }  
1944 - })  
1945 - if (this.tableFields.length > 0) {  
1946 - for (let o = 0; o < this.tableFields.length; o++) {  
1947 - if (this.tableFields[o].children.length > 0) {  
1948 - for (  
1949 - let h = 0;  
1950 - h < this.tableFields[o].children.length;  
1951 - h++  
1952 - ) {  
1953 - this.tableFields[o].children[  
1954 - h  
1955 - ].keyName = this.tableFields[o].children[h].name  
1956 - }  
1957 - }  
1958 - }  
1959 - }  
1960 - }  
1961 - } 2196 + }
  2197 + })
  2198 +
  2199 + if (!selectObj) {
  2200 + if (this.field.parentNodeType == 'sub') {
  2201 + this.field.fieldPath = 'item.' + value
  2202 + this.field.name = 'item.' + value
  2203 + } else {
  2204 + this.$message.warning('只允许子表绑定虚拟字段')
  2205 + }
  2206 + return
  2207 + }
  2208 +
  2209 + this.field.boDefId = selectObj.boDefId
  2210 + this.field.boAttrId = selectObj.id
  2211 + if (this.field.parentNodeType == 'sub') {
  2212 + this.field.fieldPath = 'item.' + selectObj.name
  2213 + } else {
  2214 + this.field.fieldPath = selectObj.path + '.' + selectObj.name
  2215 + }
  2216 +
  2217 + this.field.options.dataType = selectObj.dataType
  2218 +
  2219 + this.field.name = selectObj.name
  2220 + this.field.desc = selectObj.desc
  2221 + this.field.title = selectObj.desc
  2222 + this.field.entId = selectObj.entId
  2223 + this.field.boDefAlias = selectObj.boDefAlias
  2224 + this.field.tableName = selectObj.tableName
  2225 + this.field.columnType = selectObj.columnType
  2226 + if (selectObj.dataType == 'date') {
  2227 + this.field.options.format = selectObj.format
  2228 + this.field.options.inputFormat = selectObj.format
  2229 + } else if (selectObj.dataType == 'number') {
  2230 + //如果为评分组件则默认最大值为5
  2231 + if (this.field.ctrlType === 'rate') {
  2232 + this.field.options.max = Number(this.field.options.max)
  2233 + } else {
  2234 + this.field.options.maxDecimalDigits = selectObj.decimalLen
  2235 + this.field.options.decimalDigits = selectObj.decimalLen
  2236 + this.field.options.max = Number(''.padStart(selectObj.charLen, '9'))
  2237 + this.field.options.numberMax = Number(
  2238 + ''.padStart(selectObj.charLen, '9')
  2239 + )
  2240 + this.field.options.numberMin = -Number(
  2241 + ''.padStart(selectObj.charLen, '9')
  2242 + )
  2243 + this.field.options.min = -Number(''.padStart(selectObj.charLen, '9'))
  2244 + }
  2245 + }
  2246 + // bo属性中设置了必填 且 当前控件的校验规则为空
  2247 + if (
  2248 + selectObj.isRequired == '1' &&
  2249 + (!this.field.options.validateList ||
  2250 + this.field.options.validateList.length == 0)
  2251 + ) {
  2252 + this.$set(this.field.options, 'validateList', [
  2253 + {
  2254 + key: 'required',
  2255 + name: '*必填'
1962 } 2256 }
1963 - } else {  
1964 - if (this.mainBoFields.length > 0) {  
1965 - for (let y = 0; y < this.mainBoFields.length; y++) {  
1966 - if (this.mainBoFields[y].children.length > 0) {  
1967 - for (let t = 0; t < this.mainBoFields[y].children.length; t++) {  
1968 - this.mainBoFields[y].children[t].keyName =  
1969 - this.mainBoFields[y].children[t].path +  
1970 - '.' +  
1971 - this.mainBoFields[y].children[t].name  
1972 - }  
1973 - }  
1974 - } 2257 + ])
  2258 + }
  2259 + this.$forceUpdate()
  2260 + },
  2261 + //给无属性控件设置关联ent属性
  2262 + changeNoAttrFile(value) {
  2263 + let _this = this
  2264 + this.tableFields.forEach(ent => {
  2265 + if (ent.name == value) {
  2266 + _this.$set(_this.field, 'entId', ent.id)
  2267 + _this.$set(_this.field, 'boDefId', ent.boDefId)
  2268 + if (!_this.field.boDefAlias) {
  2269 + _this.$set(_this.field, 'boDefAlias', ent.boDefAlias)
1975 } 2270 }
1976 - if (  
1977 - val &&  
1978 - ['time', 'time-picker', 'date-picker'].includes(val.ctrlType)  
1979 - ) {  
1980 - this.tableFields = JSON.parse(JSON.stringify(this.mainBoFields))  
1981 - this.tableFields.forEach(table => {  
1982 - if (table.children) {  
1983 - let newFileds = []  
1984 - table.children = table.children.filter(  
1985 - f => f.dataType != 'date' && f.dataType != 'number'  
1986 - )  
1987 - }  
1988 - })  
1989 - } else {  
1990 - this.mainBoFields.forEach(item => {  
1991 - for (let q = 0; q < item.children.length; q++) {  
1992 - for (let i = 0; i < item.children.length - 1 - q; i++) {  
1993 - if (item.children[i].index > item.children[i + 1].index) {  
1994 - let temp = item.children[i]  
1995 - item.children[i] = item.children[i + 1]  
1996 - item.children[i + 1] = temp 2271 + this.$forceUpdate()
  2272 + _this.noAttrFieldListChange(_this.field, true)
  2273 + }
  2274 + })
  2275 + },
  2276 + //取消无属性设置
  2277 + changeNoBindModel() {
  2278 + if (this.field.options.noBindModel) {
  2279 + this.$set(this.field, 'name', 'c_' + this.field.key)
  2280 + this.noAttrFieldListChange(this.field, true)
  2281 + } else if (
  2282 + !this.field.options.noBindModel &&
  2283 + this.noAttrFieldList &&
  2284 + this.noAttrFieldList.length > 0
  2285 + ) {
  2286 + this.$set(this.field, 'name', '')
  2287 + this.noAttrFieldListChange(this.field, false)
  2288 + }
  2289 + if (this.field.ctrlType === 'number') {
  2290 + this.setDefaultValueForDigitalControl()
  2291 + }
  2292 + },
  2293 + setDefaultValueForDigitalControl() {
  2294 + this.field.options.max = 999999999
  2295 + this.field.options.numberMax = 999999999
  2296 + this.field.options.numberMin = -999999999
  2297 + this.field.options.min = 0
  2298 + },
  2299 + isChangeWatch() {
  2300 + this.isWatch = true
  2301 + //
  2302 + //
  2303 + // 切换时 处理合计
  2304 + if (this.widgetForm.list && this.widgetForm.list.length > 0) {
  2305 + this.widgetForm.list.forEach((item, index) => {
  2306 + if (item.name === this.field.tableName) {
  2307 + item.CombinedColumnList &&
  2308 + item.CombinedColumnList.forEach((ComItem, ComIndex) => {
  2309 + if (ComItem.columnField === this.field.name) {
  2310 + if (
  2311 + this.field.ctrlType != 'number' ||
  2312 + selitem.columnType != 'number'
  2313 + ) {
  2314 + item.CombinedColumnList.splice(ComIndex, 1)
1997 } 2315 }
1998 } 2316 }
1999 - }  
2000 - })  
2001 - this.tableFields = this.mainBoFields  
2002 - }  
2003 - }  
2004 - this.setTableFieldsChildren(this.tableFields, val && val.ctrlType)  
2005 - //合并数组对象  
2006 - let allModelingData = []  
2007 - let allBoData = []  
2008 - let formVarData = []  
2009 - let returnData = [] //对话框返回值选择的字段信息 主表对应主表,子表对应子表,孙表对应孙表。  
2010 - let returnTypes = ['select', 'dropdown', 'dialog']  
2011 - if (  
2012 - (val &&  
2013 - ['suntable', 'sunDiv'].includes(val.ctrlType) &&  
2014 - this.currentBoSubEntity) ||  
2015 - (val && val.parentNodeType == 'sun')  
2016 - ) {  
2017 - this.mainBoFields.forEach(mainBoField => {  
2018 - formVarData.push({...mainBoField})  
2019 - allBoData.push({...mainBoField})  
2020 - allModelingData.push({...mainBoField})  
2021 - })  
2022 - this.subTables.forEach(subTable => {  
2023 - allModelingData.push({...subTable})  
2024 - let sunTabs = this.sunTablesMap[subTable.name]  
2025 - if (sunTabs) {  
2026 - sunTabs.forEach(sunTab => {  
2027 - allModelingData.push({...sunTab})  
2028 }) 2317 })
2029 - }  
2030 - })  
2031 - if (this.sunTables && this.sunTables.length > 0) {  
2032 - this.sunTables.forEach(sunTable => {  
2033 - if (val && val.parentNodeType == 'sun') {  
2034 - if (sunTable.name == val.boSubEntity) {  
2035 - allBoData.push({...sunTable})  
2036 - formVarData.push({...sunTable})  
2037 - returnData.push({...sunTable})  
2038 - }  
2039 - } else {  
2040 - allBoData.push({...sunTable})  
2041 - formVarData.push({...sunTable})  
2042 - returnData.push({...sunTable})  
2043 - }  
2044 - }) 2318 + this.$set(
  2319 + this.widgetForm.list[index],
  2320 + 'CombinedColumnListJson',
  2321 + Base64.encode(JSON.stringify(item.CombinedColumnList), 'utf-8')
  2322 + )
2045 } 2323 }
2046 - } else {  
2047 - if (  
2048 - val &&  
2049 - val.parentNodeType != 'sub' &&  
2050 - returnTypes.includes(val.ctrlType)  
2051 - ) {  
2052 - //添加主表字段  
2053 - this.mainBoFields.forEach(mainBoField => {  
2054 - returnData.push({...mainBoField}) 2324 + })
  2325 + }
  2326 + },
  2327 + //判断并清空绑定属性
  2328 + checkAndClearTarget() {
  2329 + if (!utils.isEmpty(this.field.target) && this.tableFields.length > 0) {
  2330 + this.tableFields.forEach((item, i) => {
  2331 + var items =
  2332 + this.tableFields[i].children &&
  2333 + this.tableFields[i].children.filter(obj => {
  2334 + return this.field.target == obj['keyName']
2055 }) 2335 })
2056 - } else if (  
2057 - val &&  
2058 - val.parentNodeType == 'sub' &&  
2059 - returnTypes.includes(val.ctrlType) 2336 +
  2337 + if (!items || items.length <= 0) {
  2338 + this.field.target = ''
  2339 + }
  2340 + if (!this.filterFields(items[0])) {
  2341 + this.field.target = ''
  2342 + }
  2343 + })
  2344 + }
  2345 + },
  2346 + editI18nMessage(after) {
  2347 + this.i18nMessageKey = this.field.fieldPath || this.field.path
  2348 +
  2349 + if (this.createKeyMap[this.field.ctrlType]) {
  2350 + this.i18nMessageKey =
  2351 + this.formData.formKey +
  2352 + '.' +
  2353 + this.field.ctrlType +
  2354 + Math.random() * 5000
  2355 + }
  2356 + if (this.i18nMessageKey && after) {
  2357 + this.i18nMessageKey += after
  2358 + }
  2359 + this.$refs.i18nMessageEdit.handleOpen()
  2360 + },
  2361 + afterSaveI18n(data) {
  2362 + data.key = data.key.replace('$', '#')
  2363 + if (data.prop.endsWith('placeholder')) {
  2364 + this.field.options.placeholder = data.key
  2365 + this.field.options.placeholder_zh = data.desc
  2366 + } else if (data.prop.endsWith('tip')) {
  2367 + this.tooltip = data.key
  2368 + } else {
  2369 + this.field.desc = data.key
  2370 + this.field.desc_zh = data.desc
  2371 + }
  2372 + },
  2373 + isNoAttrField(field) {
  2374 + //无属性控件
  2375 + if (!field) {
  2376 + field = this.field
  2377 + }
  2378 + const unboundPropertyList = [
  2379 + 'text',
  2380 + 'immediate-single',
  2381 + 'immediate-textarea',
  2382 + 'flowChart',
  2383 + 'approvalHistory',
  2384 + 'opinion',
  2385 + 'big-title',
  2386 + 'small-title',
  2387 + 'simple-text',
  2388 + 'explain',
  2389 + 'dataView',
  2390 + 'formTable',
  2391 + 'QRcode',
  2392 + 'iframe',
  2393 + 'image',
  2394 + 'customChart',
  2395 + 'button',
  2396 + 'historicalApproval',
  2397 + 'processForecast'
  2398 + ]
  2399 +
  2400 + if (
  2401 + (field && unboundPropertyList.includes(field.ctrlType)) ||
  2402 + (field &&
  2403 + field.ctrlType == 'button' &&
  2404 + field.options.bindEventjson &&
  2405 + !field.options.bindEventjson.isShowInput)
  2406 + ) {
  2407 + return true
  2408 + }
  2409 + return false
  2410 + },
  2411 + isAllowNoAttributes(field) {
  2412 + //允许无属性控件
  2413 + if (!field) {
  2414 + field = this.field
  2415 + }
  2416 + if (
  2417 + field &&
  2418 + this.allowNoAttributes.includes(field.ctrlType) &&
  2419 + field.options.noBindModel
  2420 + ) {
  2421 + return true
  2422 + }
  2423 + return false
  2424 + },
  2425 + noAttrFieldListChange(field, isAdd) {
  2426 + //无属性控件的变化实时其更新联动列表
  2427 + let inList = false
  2428 +
  2429 + this.noAttrFieldList.forEach(item => {
  2430 + if (item.key === field.key) {
  2431 + if (field.ctrlType == 'button') {
  2432 + field.desc = field.options.bindEventjson.name
  2433 + }
  2434 + if (
  2435 + ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType)
2060 ) { 2436 ) {
2061 - //添加子表字段  
2062 - this.subTables.forEach(subTable => {  
2063 - returnData.push({...subTable})  
2064 - }) 2437 + field.desc = field.options.textValue
  2438 + }
  2439 + if (isAdd) {
  2440 + inList = true
  2441 + } else {
  2442 + this.noAttrFieldList.remove(item)
  2443 + return
2065 } 2444 }
2066 - //添加主表字段  
2067 - this.mainBoFields.forEach(mainBoField => {  
2068 - allBoData.push({...mainBoField})  
2069 - })  
2070 - this.subTables.forEach(subTable => {  
2071 - allBoData.push({...subTable})  
2072 - let sunTabs = this.sunTablesMap[subTable.name]  
2073 - if (sunTabs) {  
2074 - sunTabs.forEach(sunTab => {  
2075 - allBoData.push({...sunTab})  
2076 - })  
2077 - }  
2078 - })  
2079 - formVarData = allBoData  
2080 } 2445 }
2081 - //判断无属性控件 按钮 2446 + })
  2447 + if (isAdd && !inList) {
  2448 + if (field.ctrlType == 'button') {
  2449 + field.desc = field.options.bindEventjson.name
  2450 + }
2082 if ( 2451 if (
2083 - (this.isNoAttrField(val) || this.isAllowNoAttributes(val)) &&  
2084 - this.tableFields &&  
2085 - this.tableFields.length > 0  
2086 - ) {  
2087 - if (val && !val.name) {  
2088 - this.$set(val, 'name', 'c_' + val.key)  
2089 - }  
2090 - if (val && !val.boDefAlias) {  
2091 - if (val.parentNodeType == 'sub' || val.parentNodeType == 'sun') {  
2092 - const paths = this.tableFields[0].path.split('.')  
2093 - this.$set(val, 'boDefAlias', paths[0])  
2094 - } else {  
2095 - this.$set(val, 'boDefAlias', this.tableFields[0].boDefAlias)  
2096 - }  
2097 - }  
2098 - if (val && !val.tableName) {  
2099 - this.$set(val, 'tableName', this.tableFields[0].name)  
2100 - this.changeNoAttrFile(this.tableFields[0].name)  
2101 - }  
2102 - this.noAttrFieldListChange(val, true)  
2103 - } else if (  
2104 - val &&  
2105 - val.ctrlType == 'button' &&  
2106 - val.options.bindEventjson &&  
2107 - val.options.bindEventjson.isShowInput 2452 + ['small-title', 'big-title', 'simple-text'].includes(field.ctrlType)
2108 ) { 2453 ) {
2109 - this.noAttrFieldListChange(val, false) 2454 + field.desc = field.options.textValue
2110 } 2455 }
2111 - this.allModelingData = allModelingData  
2112 - this.allBoData = allBoData  
2113 - this.formVarData = formVarData  
2114 - this.returnData = returnData  
2115 - // this.$emit('update:data', val)  
2116 - //通过模板生成的表单字段需更改为 建模别名.字段名 (解决2个不同的建模,但主表建模字段一样) 2456 + this.$set(field, 'name', '')
  2457 + this.$set(field, 'target', field.name)
2117 if ( 2458 if (
2118 - val &&  
2119 - val.target &&  
2120 - val.parentNodeType != 'sub' &&  
2121 - val.parentNodeType != 'sun' 2459 + (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') &&
  2460 + !field.options.noBindModel
2122 ) { 2461 ) {
2123 - if (!utils.isEmpty(val.boDefAlias) && !utils.isEmpty(val.name)) {  
2124 - val.target = val.boDefAlias + '.' + val.name  
2125 - }  
2126 - }  
2127 - },  
2128 - deep: true  
2129 - },  
2130 - 'field.ctrlType': {  
2131 - handler(newVal, oldVal) {  
2132 - if (oldVal == undefined || newVal == undefined || newVal == oldVal) {  
2133 - return 2462 + this.$set(field, 'fieldPath', 'item.' + field.name)
  2463 + } else if (
  2464 + (field.parentNodeType == 'sub' || field.parentNodeType == 'sun') &&
  2465 + field.options.noBindModel &&
  2466 + field.key
  2467 + ) {
  2468 + this.$set(field, 'fieldPath', 'item.' + `c_${field.key}`)
  2469 + } else if (field.options.noBindModel && field.boDefAlias && field.key) {
  2470 + this.$set(field, 'fieldPath', `${field.boDefAlias}.c_${field.key}`)
  2471 + } else if (field.boDefAlias) {
  2472 + this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name)
2134 } 2473 }
2135 - if (!this.isWatch) {  
2136 - return 2474 + } else if (field.boDefAlias && !field.fieldPath) {
  2475 + this.$set(field, 'fieldPath', field.boDefAlias + '.' + field.name)
  2476 + }
  2477 + this.noAttrFieldList.some((item, i) => {
  2478 + if (item.key === field.key) {
  2479 + this.noAttrFieldList.splice(i, 1)
  2480 + return true
2137 } 2481 }
2138 - if (newVal === 'rate') {  
2139 - this.changeCtrlType(false,'rate')  
2140 - } else if (['number', 'currency'].includes(oldVal)) {  
2141 - if (newVal == 'date' || newVal == 'time') {  
2142 - this.changeCtrlType(true)  
2143 - } else {  
2144 - this.changeCtrlType(false)  
2145 - }  
2146 - } else if (oldVal == 'date' || oldVal == 'time') {  
2147 - if (newVal == 'number' || newVal == 'currency') {  
2148 - this.changeCtrlType(true)  
2149 - } else {  
2150 - this.changeCtrlType(false)  
2151 - }  
2152 - } else if (newVal == 'select') {  
2153 - this.changeCtrlType(false)  
2154 - } else {  
2155 - if (['number', 'currency'].includes(newVal)) {  
2156 - if (this.field.columnType == 'number') {  
2157 - this.changeCtrlType(false)  
2158 - } else {  
2159 - this.changeCtrlType(true)  
2160 - }  
2161 - } else if (newVal == 'date' || newVal == 'time') {  
2162 - this.changeCtrlType(false)  
2163 - } else if (newVal == 'switch') {  
2164 - this.changeCtrlType(false)  
2165 - } else {  
2166 - this.changeCtrlType(false) 2482 + })
  2483 + this.noAttrFieldList.push(field)
  2484 + },
  2485 + showSelectQueryDialog() {
  2486 + //初始化关联查询用到的实体map
  2487 + this.initQueryEntMap()
  2488 + if (this.widgetFormData.config == undefined) {
  2489 + this.widgetFormData.config = {}
  2490 + }
  2491 + this.$refs.selectQueryDialog.showDialog(
  2492 + this.widgetFormData.config.globalQueryJson
  2493 + )
  2494 + },
  2495 + //保存关联查询数据
  2496 + saveCustQueryJson(json) {
  2497 + this.$set(this.widgetFormData.config, 'globalQueryJson', json)
  2498 + this.$set(this.widgetForm.config, 'globalQueryJson', json)
  2499 + },
  2500 + initQueryEntMap() {
  2501 + if (this.mainBoFields && this.mainBoFields.length > 0) {
  2502 + this.queryEntMap['main'] = this.mainBoFields
  2503 + }
  2504 + if (this.subTables && this.subTables.length > 0) {
  2505 + this.queryEntMap['sub'] = this.subTables
  2506 + }
  2507 + if (this.sunTablesMap && Object.keys(this.sunTablesMap).length !== 0) {
  2508 + let sunTables = []
  2509 + for (var key in this.sunTablesMap) {
  2510 + if (this.sunTablesMap.hasOwnProperty(key)) {
  2511 + sunTables.push(...this.sunTablesMap[key])
2167 } 2512 }
2168 } 2513 }
2169 - this.isWatch = false  
2170 - const validateList = this.field.options.validateList  
2171 - ? [  
2172 - ...this.field.options.validateList,  
2173 - {  
2174 - key: 'required',  
2175 - name: '*必填'  
2176 - }  
2177 - ]  
2178 - : [  
2179 - {  
2180 - key: 'required',  
2181 - name: '*必填'  
2182 - }  
2183 - ]  
2184 - const hasValidateRules =  
2185 - this.field.options.validateType &&  
2186 - this.field.options.validateType.includes('required')  
2187 - this.tableFields.forEach(boData => {  
2188 - boData.children.forEach((v, i) => {  
2189 - if (  
2190 - hasValidateRules &&  
2191 - this.field.fieldPath === v.keyName &&  
2192 - v.isRequired  
2193 - ) {  
2194 - this.$set(  
2195 - this.field.options,  
2196 - 'validateList',  
2197 - uniqueArrayObject(validateList, 'key')  
2198 - )  
2199 - if (this.field.options && !this.field.options.validate) {  
2200 - this.$set(this.field.options, 'validate', "'required'")  
2201 - }  
2202 - }  
2203 - })  
2204 - }) 2514 + this.queryEntMap['sun'] = sunTables
2205 } 2515 }
2206 }, 2516 },
2207 - widgetForm(val) {  
2208 - this.widgetFormData = val  
2209 - if (val.submitVerification && val.submitVerification.length > 0) {  
2210 - this.submitVerification = JSON.parse(  
2211 - Base64.decode(val.submitVerification)  
2212 - ) 2517 + selectTypeChange(type) {
  2518 + if (type) {
  2519 + this.formData.typeId = type.id
  2520 + this.formData.typeName = type.name
2213 } else { 2521 } else {
2214 - this.submitVerification = [] 2522 + this.formData.typeId = ''
  2523 + this.formData.typeName = ''
2215 } 2524 }
  2525 + this.$forceUpdate()
2216 }, 2526 },
2217 - submitVerification: {  
2218 - handler(val) {  
2219 - this.$set(  
2220 - this.widgetFormData,  
2221 - 'submitVerification',  
2222 - Base64.encode(JSON.stringify(this.submitVerification), 'utf-8')  
2223 - )  
2224 - },  
2225 - deep: true  
2226 - },  
2227 - // 根据绑定属性过滤空间类型  
2228 - 'field.target': {  
2229 - handler(val) {  
2230 - this.filterBasicComponents = basicComponents.filter(obj => {  
2231 - return this.filterFieldsByCurrentField(obj, val)  
2232 - })  
2233 - },  
2234 - deep: true 2527 + // 隐藏标题时 标题宽度赋值为0
  2528 + hideTitleChange(flag) {
  2529 + this.field.options.labelstyleWidth = flag ? '0' : ''
2235 } 2530 }
2236 - },  
2237 - mounted() {  
2238 - // 声明  
2239 - this.$validator = this.$root.$validator  
2240 - // 复制高级字段列表  
2241 - this.copyAdvanceComponents = this.advanceComponents.slice()  
2242 - },  
2243 - destroyed() {}  
2244 -} 2531 + }
  2532 +};
2245 </script> 2533 </script>
  2534 +
2246 <style lang="scss" scoped> 2535 <style lang="scss" scoped>
2247 @import '@/assets/css/element-variables.scss'; 2536 @import '@/assets/css/element-variables.scss';
2248 @import '@/assets/css/form-editor.scss'; 2537 @import '@/assets/css/form-editor.scss';