Ver código fonte

fix: 审批 展示/隐藏控制

lanceJiang 9 meses atrás
pai
commit
2620c6c57a

+ 1 - 0
src/components/packages/formEditor/components/Panels/Config/components/GlobalConfigPanel.vue

@@ -137,6 +137,7 @@ const handleTypeListener = ({ property, data }) => {
 		<el-form-item :label="t('er.config.globalConfig.sync.label')" label-position="left" v-bind="utils.addTestId('configPanel:isSync')">
 			<el-switch ref="buttonRef" v-model="target.isSync" v-click-outside:[popperPaneRef]="onClickOutside" :before-change="handleBeforeChange" />
 		</el-form-item>
+		<!--表单属性配置-->
 		<PanelsConfigComponentsTypeComponent
 			v-if="isPc"
 			property="size"

+ 21 - 21
src/views/approve/components/approvedContent.vue

@@ -500,27 +500,27 @@ const getTaskDetail = () => {
 				if (props.currentTaskType !== 'pendingApproval') {
 					newFields.map(item1 => (item1.options.disabled = true))
 				} else {
-					// data.formConfig
-					newFields.forEach(item => {
-						const matchingFormItem = formConfig.find(formItem => formItem.id == item.id)
-						// 如果找到匹配的对象,且opera为'2',则删除newFields中的对象
-						if (matchingFormItem && matchingFormItem.opera === '2') {
-							newFields = newFields.filter(t => t.id !== item.id)
-						} else if (matchingFormItem) {
-							// 否则,将opera属性添加到newFields中的对象
-							item.opera = matchingFormItem.opera
-							// '0': 只读 '1': 编辑 '2': 隐藏
-							item.options.disabled = ['0', '1'].indexOf(matchingFormItem.opera) > -1 ? !Number(matchingFormItem.opera) : false
-						}
-					})
-
-					newFieldsList.forEach(item => {
-						const matchingFormItem = formConfig.find(formItem => formItem.id == item.id)
-						// 如果找到匹配的对象,且opera为'2',则删除newFields中的对象
-						if (matchingFormItem && matchingFormItem.opera === '2') {
-							newFieldsList = newFieldsList.filter(t => t.id !== item.id)
+					let idx = 0
+					while (idx < newFields.length - 1) {
+						const _field = newFields[idx]
+						const matchingFormItem = formConfig.find(formItem => formItem.id == _field.id)
+						if (matchingFormItem) {
+							// 如果找到匹配的对象,且opera为'2',则删除newFields中的对象
+							if (matchingFormItem.opera === '2') {
+								// fields 配置是准确的
+								newFields.splice(idx, 1)
+								// list 配置是跟随 fields 配置 顺序来(通过id 查找 id 只在第一次创建 才有效(修改编辑不会同步))
+								newFieldsList.splice(idx, 1)
+								idx--
+							} else {
+								// 否则,将opera属性添加到newFields中的对象
+								_field.opera = matchingFormItem.opera
+								// '0': 只读 '1': 编辑 '2': 隐藏
+								_field.options.disabled = ['0', '1'].indexOf(matchingFormItem.opera) > -1 ? !Number(matchingFormItem.opera) : false
+							}
 						}
-					})
+						idx++
+					}
 				}
 				cur_formStructure = {
 					...cur_formStructure,
@@ -529,7 +529,7 @@ const getTaskDetail = () => {
 				}
 				cur_formData = formData
 				console.log(cur_formStructure, '=/////====newFormStructure');
-				console.log(formData, '=/////====newFormStructure');
+				console.log(formData, '=/////====newFormStructure formData');
 				EReditorRef.value.setData(cur_formStructure, formData)
 				validateForm.value.rule = newFields
 				/* 这里主要是表单设计的逻辑 end */