Browse Source

feat: 待审批 只读+编辑100%,还差隐藏

luoyali 1 year ago
parent
commit
350daca5d7
1 changed files with 35 additions and 1 deletions
  1. 35 1
      src/views/approve/components/approvedContent.vue

+ 35 - 1
src/views/approve/components/approvedContent.vue

@@ -40,7 +40,7 @@
 					<!-- 审批信息 -->
 					<div v-show="tabName === 'ApprovalInfo'" class="scroll-wrap">
 						<!-- 表单 -->
-						<div v-loading="validateForm.loading" class="form-wrap">
+						<div v-loading="validateForm.loading" class="form-wrap self-Everright-formEditor">
 							<er-form-preview
 								v-show="validateForm.rule.length"
 								ref="EReditorRef"
@@ -473,12 +473,39 @@ const getTaskDetail = () => {
 				})*/
 				cur_processForm_str = data.formContent
 				const { formStructure, formData } = JSON.parse(cur_processForm_str)
+				const formConfig = data.formConfig || []
 				let newFormStructure = formStructure // 存储一份
 				let newFields = newFormStructure.fields
 				// pendingApproval, 除了[待审批]这个状态, 其余只能读取
 				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)
+						if (matchingFormItem) {
+							item.opera = matchingFormItem.opera
+							// '0': 只读 '1': 编辑 '2': 隐藏
+							item.options.disabled = ['0', '1'].indexOf(matchingFormItem.opera) > -1 ? !Number(matchingFormItem.opera) : false
+						}
+					})
+
+					// newFields.forEach(item => {
+					// 	// 在formConfig中查找是否有相同id的对象
+					// 	let configMatch = formConfig.find(config => config.id == item.id)
+					//
+					// 	// 如果找到匹配的对象,且opera为'2',则删除newFields中的对象
+					// 	if (configMatch && configMatch.opera === '2') {
+					// 		newFields = newFields.filter(t => t.id !== item.id)
+					// 	} else if (configMatch) {
+					// 		// 否则,将opera属性添加到newFields中的对象
+					// 		item.opera = configMatch.opera
+					// 		// '0': 只读 '1': 编辑 '2': 隐藏
+					// 		item.options.disabled = ['0', '1'].indexOf(configMatch.opera) > -1 ? !Number(configMatch.opera) : false
+					// 	}
+					// })
 				}
+				// console.log(newFields, '=====')
 				newFormStructure = {
 					...newFormStructure,
 					fields: newFields
@@ -701,4 +728,11 @@ watch(
 :deep(.el-timeline-item__timestamp) {
 	margin-left: 6px;
 }
+
+// 修改everright 表单的样式
+.self-Everright-formEditor {
+	:deep(.Everright-formEditor-selectElement) {
+		padding: 0px 16px;
+	}
+}
 </style>