cuiqian2004
2025-08-29 7662665a4f88da0f8afa804bd4a34dfbefc1fb56
pages/modal/form/index.vue
@@ -57,7 +57,10 @@
   } from "@/api/data.js"
   import dayjs from "dayjs";
   import OIForm from '@/components/oi-form/index.vue'
   import {
      showInfo,
      showError
   } from "@/js/Page.js"
   export default {
      name: "PageModalForm",
      components: {
@@ -158,12 +161,8 @@
         if (this.clsId) {
            this.loadData(objAttr)
         } else {
            uni.showModal({
               title: this.translateSys("error"),
               content: this.translate("tip_no_master_class"),
               showCancel: false,
               confirmText: this.translateSys('close')
            });
            showInfo(this.translate("tip_no_master_class"))
         }
      },
      //页面初始化获取焦点
@@ -323,16 +322,8 @@
            } catch (ex) {
               // console.log(ex);
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: $this.translateSys('tip') + "1",
                  content: exStr,
                  showCancel: false,
                  confirmText: $this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "1")
            }
@@ -365,12 +356,7 @@
               formItem.dict = list;
            } catch (ex) {
               // console.log(ex);
               uni.showModal({
                  title: this.translateSys("error") + "3",
                  content: ex.errMsg,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('error') + "3")
            }
         },
@@ -438,60 +424,33 @@
                     data_json,
                     ext_info
                  })
                  if (result.ret != 0&& result.ret != 1) {
                     var tip = result.err_info ? typeof result
                        .err_info == 'string' ? result
                        .err_info : result.err_info.join('<br/>') :
                        '';
                     if (result.ret == 801) {
                        if (this.param.Only_Script_Error) {
                           let pos = tip.indexOf(":");
                           if (pos > -1) tip = tip.substring(pos +
                              1);
                        }
                        uni.showModal({
                           title: this.translateSys(
                              "tip"),
                           content: tip,
                           showCancel: false,
                           confirmText: this.translateSys(
                              'close')
                        });
                     } else uni.showModal({
                        title: this.translateSys('tip'),
                        content: tip + ',' + this
                           .translateSys('tip') + ':' +
                           result
                           .ret,
                        showCancel: false,
                        confirmText: this.translateSys(
                           'close')
                     });
                     return false;
                  if (result.ret != 0 && result.ret != 1) {
                     let cls_name = result.event_info?.cls_name
                     let event_name = result.event_info?.event_name
                     tip = result.err_info ? typeof result.err_info == 'string' ? result.err_info : result
                        .err_info
                        .join('\n') : ''
                     if (cls_name && event_name) tip = `执行“${cls_name}”数据类的“${event_name}”脚本时返回错误:${tip}`
                     if (result.ret == 801) showInfo(tip)
                     else showError(`${tip},提示:${result.ret}`, this.translateSys('tip'))
                     this.saving = false
                     return false
                  } else {
                     var tip = result.info ? typeof result.info ==
                        'string' ? result.info :
                        result.info.join('<br/>') : '';
                     var tip = result.info ? typeof result.info == 'string' ? result.info :
                        result.info.join('\n') : '';
                     tip = tip || result.err_info
                     if (tip) uni.showModal({
                        title: this.translateSys('tip'),
                        content: tip,
                        showCancel: false,
                        confirmText: this.translateSys(
                           'close')
                     });
                     let time = result.info_time || 0
                     if (time)
                        showError(tip, this.translateSys('tip'))
                     else
                        showInfo(tip)
                     if ([0, 2, 3, 4, -1].includes(result.result_type)) {
                        if (result.result_type == 2) {
                        } else if (typeof result.result == 'string') {
                           if (result.result) {
                              uni.showModal({
                                 title: this.translateSys('tip'),
                                 content: result.result,
                                 showCancel: false,
                                 confirmText: this.translateSys('close')
                              });
                           }
                           showError(result.result)
                        }
                        try {
                           var actionList = result.action || []
@@ -535,13 +494,7 @@
                           let actionList = (result.action || []).map(a => a.action_type).join(';')
                           let tip = typeof ex == 'string' ? ex : ex.message
                           tip = `执行脚本返回的${actionList}时出现异常,请检查脚本返回的数据格式是否正确。${tip}`
                           uni.showModal({
                              title: this.translateSys('tip'),
                              content: tip,
                              showCancel: false,
                              confirmText: this.translateSys('close')
                           });
                           console.log(ex)
                           showError(tip, this.translateSys('tip'))
                           return
                        }
                     }
@@ -549,16 +502,7 @@
               }
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: $this.translateSys('tip') + "2",
                  content: exStr,
                  showCancel: false,
                  confirmText: $this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "2")
            }
         },
         onClick(item) {
@@ -685,21 +629,13 @@
            var onSuffixClickEvent = item.bind.onSuffixClickEvent; //后图标点击回调
            if (!onSuffixClickCallbackEvent.id) {
               uni.showModal({
                  title: this.translateSys("tip"),
                  content: this.translate('icon_click_callback_empty'),
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showInfo(this.translate('icon_click_callback_empty'))
               return;
            }
            if (!onSuffixClickEvent.id) {
               uni.showModal({
                  title: this.translateSys("tip"),
                  content: this.translate('icon_click_event_empty'),
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showInfo(this.translate('icon_click_event_empty'))
               return;
            }
            this.popupType = 'right'
@@ -761,61 +697,34 @@
                  };
                  runCustomEvent(dataInfo).then(result => {
                     console.log(result);
                     if (result.ret != 0 && result.ret != 1) {
                        let cls_name = result.event_info?.cls_name
                        let event_name = result.event_info?.event_name
                        tip = result.err_info ? typeof result.err_info == 'string' ? result.err_info :
                           result.err_info
                           .join('\n') : ''
                     if (result.ret != 0&& result.ret != 1) {
                        var tip = result.err_info ? typeof result
                           .err_info == 'string' ? result
                           .err_info : result.err_info.join('<br/>') :
                           '';
                        if (result.ret == 801) {
                           if (this.param.Only_Script_Error) {
                              let pos = tip.indexOf(":");
                              if (pos > -1) tip = tip.substring(pos +
                                 1);
                           }
                           uni.showModal({
                              title: this.translateSys(
                                 "tip"),
                              content: tip,
                              showCancel: false,
                              confirmText: this.translateSys(
                                 'close')
                           });
                        } else uni.showModal({
                           title: this.translateSys('tip'),
                           content: tip + ',' + this
                              .translateSys('tip') + ':' +
                              result
                              .ret,
                           showCancel: false,
                           confirmText: this.translateSys(
                              'close')
                        });
                        return false;
                        if (cls_name && event_name) tip =
                           `执行“${cls_name}”数据类的“${event_name}”脚本时返回错误:${tip}`
                        if (result.ret == 801) showInfo(tip)
                        else showError(`${tip},提示:${result.ret}`, this.translateSys('tip'))
                        this.saving = false
                        return false
                     } else {
                        var tip = result.info ? typeof result.info ==
                           'string' ? result.info :
                           result.info.join('<br/>') : '';
                        var tip = result.info ? typeof result.info == 'string' ? result.info :
                           result.info.join('\n') : '';
                        tip = tip || result.err_info
                        if (tip) uni.showModal({
                           title: this.translateSys('tip'),
                           content: tip,
                           showCancel: false,
                           confirmText: this.translateSys(
                              'close')
                        });
                        let time = result.info_time || 0
                        if (time)
                           showError(tip, this.translateSys('tip'))
                        else
                           showInfo(tip)
                        if ([0, 2, 3, 4, -1].includes(result.result_type)) {
                           if (result.result_type == 2) {
                           } else if (typeof result.result == 'string') {
                              if (result.result) {
                                 uni.showModal({
                                    title: this.translateSys('tip'),
                                    content: result.result,
                                    showCancel: false,
                                    confirmText: this.translateSys('close')
                                 });
                              }
                              showInfo(result.result)
                           }
                           try {
                              var actionList = result.action || []
@@ -861,13 +770,7 @@
                                 .join(';')
                              let tip = typeof ex == 'string' ? ex : ex.message
                              tip = `执行脚本返回的${actionList}时出现异常,请检查脚本返回的数据格式是否正确。${tip}`
                              uni.showModal({
                                 title: this.translateSys('tip'),
                                 content: tip,
                                 showCancel: false,
                                 confirmText: this.translateSys('close')
                              });
                              console.log(ex)
                              showError(tip, this.translateSys('tip'))
                              return
                           }
                        }
@@ -876,28 +779,11 @@
                  }).catch(ex => {
                     // console.log(ex);
                     let tip = typeof ex.errMsg == "string" ? ex.errMsg : ex
                     uni.showModal({
                        title: this.translateSys("error") + "4.1",
                        content: tip,
                        showCancel: false,
                        confirmText: this.translateSys('close')
                     });
                     showError(ex, this.translateSys('error') + "4.1")
                  });
               }
            } catch (ex) {
               var tip = typeof ex == "string" ? ex : ex.message;
               uni.showModal({
                  title: this.translateSys("error") + "4.2",
                  content: this.translate(
                        'execute_after_change_event_failed') + this
                     .translateSys(
                        "comma") +
                     this.translate('reason') + this.translateSys("colon") +
                     tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "4.2")
            }
         },
@@ -1027,21 +913,13 @@
               }
            }
            if (!$this.popupParam) {
               uni.showModal({
                  title: this.translateSys("tip"),
                  content: "popupParam为空!",
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showInfo("popupParam为空!")
               return;
            }
            if (data.length == 0) {
               uni.showModal({
                  title: this.translateSys("tip"),
                  content: this.translate("tip_no_select_data"),
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showInfo(this.translate("tip_no_select_data"))
               return;
            }
            let global_attr = Base64.encode(JSON.stringify(this.global_attr))
@@ -1125,54 +1003,32 @@
            console.log(dataInfo);
            // return;
            runCustomEvent(dataInfo).then(data => {
               if (data.ret != 0&& data.ret != 1) {
                  var tip = data.err_info ? typeof data.err_info == 'string' ? data
                     .err_info :
                     data
                     .err_info.join('<br/>') : '';
                  if (data.ret == 801) {
                     if (this.param.Only_Script_Error) {
                        let pos = tip.indexOf(":");
                        if (pos > -1) tip = tip.substring(pos + 1);
                     }
                     uni.showModal({
                        title: this.translateSys("tip"),
                        content: tip,
                        showCancel: false,
                        confirmText: this.translateSys('close')
                     });
                  } else uni.showModal({
                     title: this.translateSys("tip"),
                     content: tip + ',' + this.translateSys('tip') + ':' + data
                        .ret,
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
               if (data.ret != 0 && data.ret != 1) {
                  let cls_name = data.event_info?.cls_name
                  let event_name = data.event_info?.event_name
                  tip = data.err_info ? typeof data.err_info == 'string' ? data.err_info : data.err_info
                     .join('\n') : ''
                  if (cls_name && event_name) tip = `执行“${cls_name}”数据类的“${event_name}”脚本时返回错误:${tip}`
                  if (data.ret == 801) showInfo(tip)
                  else showError(`${tip},提示:${data.ret}`, this.translateSys('tip'))
                  this.saving = false
                  return false
               } else {
                  var tip = data.info ? typeof data.info == 'string' ? data.info : data
                     .info
                     .join(
                        '<br/>') : '';
                  var tip = data.info ? typeof data.info == 'string' ? data.info :
                     data.info.join('\n') : '';
                  tip = tip || data.err_info
                  if (tip) uni.showModal({
                     title: this.translateSys("tip"),
                     content: tip,
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  let time = data.info_time || 0
                  if (time)
                     showError(tip, this.translateSys('tip'))
                  else
                     showInfo(tip)
                  if ([0, 2, 3, 4, -1].includes(data.result_type)) {
                     if (data.result_type == 2) {
                        $this.setFormValues(data.result || [])
                     } else if (typeof data.result == 'string') {
                        if (data.result) {
                           uni.showModal({
                              title: this.translateSys('tip'),
                              content: data.result,
                              showCancel: false,
                              confirmText: this.translateSys('close')
                           });
                        }
                        showInfo(data.result)
                     }
                     try {
                        var actionlist = data.action || []
@@ -1196,9 +1052,7 @@
                                    .action_type + this.translateSys(
                                       "quotation_mark_right") + this
                                    .translate(
                                       "tip_action_unprocessed"),
                                 showCancel: false,
                                 confirmText: this.translateSys('close')
                                       "tip_action_unprocessed")
                              });
                           }
                        }
@@ -1207,13 +1061,7 @@
                        let actionList = (data.action || []).map(a => a.action_type).join(';')
                        let tip = typeof ex == 'string' ? ex : ex.message
                        tip = `执行脚本返回的${actionList}时出现异常,请检查脚本返回的数据格式是否正确。${tip}`
                        uni.showModal({
                           title: this.translateSys('tip'),
                           content: tip,
                           showCancel: false,
                           confirmText: this.translateSys('close')
                        });
                        console.log(ex)
                        showError(tip, this.translateSys('tip'))
                        return
                     }
                  }
@@ -1223,16 +1071,7 @@
            }).catch(ex => {
               // console.log(ex);
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys("error") + "3.1",
                  content: exStr,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('error') + "3.1")
            });
         },
         dataObjRunCustomEvent_Return(eventid, data_attr, button_callback, item) {
@@ -1293,54 +1132,33 @@
            console.log(dataInfo);
            // return;
            runCustomEvent(dataInfo).then(data => {
               if (data.ret != 0&& data.ret != 1) {
                  var tip = data.err_info ? typeof data.err_info == 'string' ? data
                     .err_info :
                     data
                     .err_info.join('<br/>') : '';
                  if (data.ret == 801) {
                     if ($this.param.Only_Script_Error) {
                        let pos = tip.indexOf(":");
                        if (pos > -1) tip = tip.substring(pos + 1);
                     }
                     uni.showModal({
                        title: $this.translateSys("tip"),
                        content: tip,
                        showCancel: false,
                        confirmText: $this.translateSys('close')
                     });
                  } else uni.showModal({
                     title: $this.translateSys("tip"),
                     content: tip + ',' + $this.translateSys('tip') + ':' + data
                        .ret,
                     showCancel: false,
                     confirmText: $this.translateSys('close')
                  });
               if (data.ret != 0 && data.ret != 1) {
                  let cls_name = data.event_info?.cls_name
                  let event_name = data.event_info?.event_name
                  tip = data.err_info ? typeof data.err_info == 'string' ? data.err_info : data.err_info
                     .join('\n') : ''
                  if (cls_name && event_name) tip = `执行“${cls_name}”数据类的“${event_name}”脚本时返回错误:${tip}`
                  if (data.ret == 801) showInfo(tip)
                  else showError(`${tip},提示:${data.ret}`, this.translateSys('tip'))
                  this.saving = false
                  return false
               } else {
                  var tip = data.info ? typeof data.info == 'string' ? data.info : data
                     .info
                     .join(
                        '<br/>') : '';
                  var tip = data.info ? typeof data.info == 'string' ? data.info :
                     data.info.join('\n') : '';
                  tip = tip || data.err_info
                  if (tip) uni.showModal({
                     title: $this.translateSys("tip"),
                     content: tip,
                     showCancel: false,
                     confirmText: $this.translateSys('close')
                  });
                  let time = data.info_time || 0
                  if (time)
                     showError(tip, this.translateSys('tip'))
                  else
                     showInfo(tip)
                  showInfo(tip)
                  if ([0, 2, 3, 4, -1].includes(data.result_type)) {
                     if (data.result_type == 2) {
                     } else if (typeof data.result == 'string') {
                        if (data.result) {
                           uni.showModal({
                              title: this.translateSys('tip'),
                              content: data.result,
                              showCancel: false,
                              confirmText: this.translateSys('close')
                           });
                        }
                        showInfo(data.result)
                     }
                     try {
                        var actions = data.action || []
@@ -1505,18 +1323,14 @@
                                 }
                              });
                           } else {
                              uni.showModal({
                                 title: $this.translateSys("tip"),
                                 content: $this.translateSys(
                                       "quotation_mark_left") +
                                    action.action_type + $this
                                    .translateSys(
                                       "quotation_mark_right") + $this
                                    .translate(
                                       "tip_action_unprocessed"),
                                 showCancel: false,
                                 confirmText: $this.translateSys('close')
                              });
                              showInfo($this.translateSys(
                                    "quotation_mark_left") +
                                 action.action_type + $this
                                 .translateSys(
                                    "quotation_mark_right") + $this
                                 .translate(
                                    "tip_action_unprocessed"))
                           }
                        }
@@ -1524,30 +1338,15 @@
                        let actionList = (data.action || []).map(a => a.action_type).join(';')
                        let tip = typeof ex == 'string' ? ex : ex.message
                        tip = `执行脚本返回的${actionList}时出现异常,请检查脚本返回的数据格式是否正确。${tip}`
                        uni.showModal({
                           title: this.translateSys('tip'),
                           content: tip,
                           showCancel: false,
                           confirmText: this.translateSys('close')
                        });
                        console.log(ex)
                        showError(tip, this.translateSys('tip'))
                        return
                     }
                  }
               }
            }).catch(ex => {
               // console.log(ex);
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: $this.translateSys('tip') + "5.1",
                  content: exStr,
                  showCancel: false,
                  confirmText: $this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "5.1")
            });
         },
         //确定
@@ -1575,6 +1374,7 @@
               uni.navigateBack()
            } catch (ex) {
               this.okLoading = true
               showError(ex, this.translateSys('tip') + "1")
               return false;
            }
         },
@@ -1611,7 +1411,7 @@
               return true;
            } catch (ex) {
               console.log("sava", ex)
               this.showError(ex)
               showError(ex, this.translateSys('tip'))
               return false;
            }
@@ -1657,16 +1457,7 @@
               await runCustomEvent(dataInfo)
               return true
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys('tip') + "7.1",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "7.1")
               return false
            }
@@ -1684,16 +1475,7 @@
               await dataObjCreate(dataInfo)
               return true
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys("tip") + "6.1",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "6.1")
               return false
            }
@@ -1711,16 +1493,7 @@
               return true
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys("tip") + "6.2",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "6.2")
               return false
            }
@@ -1765,16 +1538,7 @@
               await runCustomEvent(dataInfo)
               return true
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys('tip') + "7.2",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "7.2")
               return false
            }
@@ -1798,7 +1562,9 @@
                  delta: 1 //返回层数,2则上上页
               });
               await this.afterCancel();
            } catch (ex) {}
            } catch (ex) {
               showError(ex, this.translateSys('tip'))
            }
         },
         async beforeCancel() {
            try {
@@ -1835,18 +1601,7 @@
               })
               return true
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex
                  .errMsg : exStr
               uni.showModal({
                  title: this.translateSys("tip") +
                     "8.1",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('tip') + "8.1")
               return false
            }
         },
@@ -1888,33 +1643,11 @@
               })
               return true
            } catch (ex) {
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
                  exStr = ex
               let tip = typeof ex.errMsg == "string" ? ex
                  .errMsg :
                  exStr
               uni.showModal({
                  title: this.translateSys("tip") +
                     "8.2",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys(
                     'close')
               });
               showError(ex, this.translateSys('tip') + "8.2")
               return false
            }
         },
         showError(ex) {
            uni.showModal({
               title: this.translateSys('error'),
               content: typeof ex == "string" ? ex : typeof ex.errMsg == "string" ? ex
                  .errMsg : "",
               showCancel: false,
               confirmText: this.translateSys(
                  'cancel')
            })
         },
         translate(t) {
            if (typeof this.$t == "function") return this.$t(
               `page.${t}`)