File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
src/views/bpm/processInstance/create Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -231,8 +231,25 @@ const getApprovalDetail = async (row: any) => {
231231 */
232232const setFieldPermission = (field : string , permission : string ) => {
233233 if (permission === FieldPermissionType .READ ) {
234+ // 1. 设置字段为只读
234235 // @ts-ignore
235236 fApi .value ?.disabled (true , field )
237+ // 2. 只读字段, 去掉验证规则
238+ // fApi.value?.updateValidate(field, []); 这个方法貌似不起作用,
239+ try {
240+ // @ts-ignore
241+ const rule = fApi .value ?.getRule (field )
242+ if (rule ) {
243+ // 必填验证设置为false
244+ rule .$required = false
245+ // 清空所有验证规则
246+ if (rule .validate ) {
247+ rule .validate = []
248+ }
249+ }
250+ } catch (error ) {
251+ console .warn (' 修改字段验证规则失败:' , error )
252+ }
236253 }
237254 if (permission === FieldPermissionType .WRITE ) {
238255 // @ts-ignore
@@ -249,8 +266,15 @@ const submitForm = async () => {
249266 if (! fApi .value || ! props .selectProcessDefinition ) {
250267 return
251268 }
252- // 流程表单校验
253- await fApi .value .validate ()
269+
270+ try {
271+ // 流程表单校验
272+ await fApi .value .validate ()
273+ } catch (error ) {
274+ // 如果验证失败,检查是否是只读字段的验证错误
275+ console .warn (' 表单验证失败:' , error )
276+ return
277+ }
254278 // 如果有指定审批人,需要校验
255279 if (startUserSelectTasks .value ?.length > 0 ) {
256280 for (const userTask of startUserSelectTasks .value ) {
You can’t perform that action at this time.
0 commit comments