cuiqian2004
5 天以前 07925905f1a596e20e980de6d42db217abb753b0
pages/modal/3202_view.vue
@@ -33,6 +33,12 @@
   import {
      Base64
   } from '@/js/Base64.js';
   import {
      showInfo,
      showError,
      showLoading,
      hideLoading
   } from "@/js/Page.js"
   import classUtils from "@/js/utils.js"
   import {
      appGetInfo,
@@ -109,58 +115,67 @@
         },
      },
      onBackPress(e) {
         this.navigateBackEvent()
         this.beforeNavigateBack()
      },
      onReady() {
         uni.setNavigationBarTitle({
            title: this.title
         }); //设置顶部标题
      },
      async onLoad(options) {
         console.log(options);
         uni.setNavigationBarTitle({
            title: options.titlename
         }); //设置顶部标题
         this.title = options.titlename;
         this.param = JSON.parse(options.param);
         this.head_styledef = {
            form: {
               items: []
            }
         };
         this.detail1_styledef = {};
         this.detail1StyleDefList = [];
         this.active_id = '';
         this.activeItem = {};
         await this.Head_UIStyleGetInfo(this.param.ClsID, this.param.MasterView_Panel.id);
         await this.Detail1_UIstyleGetInfo(this.param.ClsID, this.param.ViewItem_Panel.id);
         const dataObj = options.dataObj ? JSON.parse(options.dataObj) : {};
         if (dataObj) {
            let attrs = [];
            let master_view = dataObj?.master_view;
            Object.keys(master_view).forEach((a) => {
               attrs.push({
                  attr: a,
                  value: master_view[a]
               });
            });
            attrs.forEach((attr) => {
               this.head_styledef.form.items.forEach((ele2) => {
                  if (ele2.name != "Layout") {
                     if (ele2.fieldId == attr.attr) {
                        ele2.value = attr.value;
                     }
                  } else if (ele2.name == "Layout") {
                     ele2.setting.colList.forEach((col) => {
                        if (col) {
                           if (col.fieldId == attr.attr) {
                              col.value = attr.value;
                           }
                        }
                     });
                  }
               });
            });
            this.viewAceionContent(dataObj.page.list);
         }
         if (this.enter_view_event.id)
            this.enterAfterEvent(this.enter_view_event);
         try {
            showLoading("loading...")
            console.log(options);
            this.title = options.titlename;
            this.param = JSON.parse(options.param);
            this.head_styledef = {
               form: {
                  items: []
               }
            };
            this.detail1_styledef = {};
            this.detail1StyleDefList = [];
            this.active_id = '';
            this.activeItem = {};
            await this.Head_UIStyleGetInfo(this.param.ClsID, this.param.MasterView_Panel.id);
            await this.Detail1_UIstyleGetInfo(this.param.ClsID, this.param.ViewItem_Panel.id);
            const dataObj = options.dataObj ? JSON.parse(options.dataObj) : {};
            if (dataObj) {
               let attrs = [];
               let master_view = dataObj?.master_view;
               Object.keys(master_view).forEach((a) => {
                  attrs.push({
                     attr: a,
                     value: master_view[a]
                  });
               });
               attrs.forEach((attr) => {
                  this.head_styledef.form.items.forEach((ele2) => {
                     if (ele2.name != "Layout") {
                        if (ele2.fieldId == attr.attr) {
                           ele2.value = attr.value;
                        }
                     } else if (ele2.name == "Layout") {
                        ele2.setting.colList.forEach((col) => {
                           if (col) {
                              if (col.fieldId == attr.attr) {
                                 col.value = attr.value;
                              }
                           }
                        });
                     }
                  });
               });
               this.viewAceionContent(dataObj.page.list);
            }
            if (this.enter_view_event.id)
               this.enterAfterEvent(this.enter_view_event);
            hideLoading()
         } catch (ex) {
            hideLoading()
            showError(ex, this.translateSys("error"));
         }
      },
      methods: {
         //
@@ -234,13 +249,7 @@
               }
            } catch (ex) {
               // console.log(ex);
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : ex
               uni.showModal({
                  title: this.translateSys("error") + "1.1",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('error') + "1.1")
            }
         },
@@ -265,13 +274,7 @@
               $this.detail1_styledef.SelBut_Checked = false;
            } catch (ex) {
               // console.log(ex);
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : ex
               uni.showModal({
                  title: this.translateSys("error") + "1.1",
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('error') + "1.1")
            }
@@ -309,12 +312,7 @@
               }
            } 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")
            }
         },
         viewAceionContent(list) {
@@ -360,6 +358,7 @@
         //页面进入后事件
         async enterAfterEvent(event) {
            try {
               showLoading("loading...")
               let data_json = [];
               let jsonlist = [];
               let detailStyleList = this.detail1StyleDefList;
@@ -385,7 +384,7 @@
                  } else input_param[item.fieldId] = item.value;
               });
               input_param = Base64.encode(JSON.stringify(input_param));
               this.runCustomEvent({
               await this.runCustomEvent({
                  ed_type: 0,
                  start_transaction: true,
                  class_id: this.param.ClsID,
@@ -393,9 +392,11 @@
                  input_param,
                  data_json,
               })
               hideLoading()
            } catch (ex) {
               this.showError(ex);
               hideLoading()
               showError(ex, this.translateSys('tip'));
            }
         },
@@ -405,129 +406,84 @@
            try {
               var $this = this;
               runCustomEvent(dataInfo).then(result => {
                  console.log(result);
               const result = await runCustomEvent(dataInfo)
               console.log(result);
                  if (result.ret != 0) {
                     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;
                  } else {
                     var tip = result.info ? typeof result
                        .info == 'string' ? result
                        .info : result
                        .info.join('<br/>') : '';
                     if (tip) uni.showModal({
                        title: this.translateSys(
                           "tip"),
                        content: tip,
                        showCancel: false,
                        confirmText: this.translateSys(
                           'close')
                     });
               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 == 801) {
                     if (this.param.Only_Script_Error) {
                        let pos = tip.indexOf(":");
                        if (pos > -1) tip = tip.substring(pos + 1);
                     }
                  }
                  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('\n') : '';
                  tip = tip || result.err_info
                  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) {
                     if (result.result_type == 0 && result.action) {
                        result.action.forEach(item => {
                     } else if (typeof result.result == 'string') {
                        showInfo(result.result)
                     }
                     try {
                        var actionList = result.action || []
                        actionList.forEach(item => {
                           if (item.action_type == "goback_to_pre_page") { //返回上一页
                              var value = item.value;
                              uni.navigateBack({
                                 delta: 1, //返回层数,2则上上页
                              });
                           } else {
                              uni.showModal({
                                 title: this
                                    .translateSys(
                                       "tip"
                                    ),
                                 content: this
                                    .translateSys(
                                       "quotation_mark_left"
                                    ) +
                                    item
                                    .action_type +
                                    this
                                    .translateSys(
                                       "quotation_mark_right"
                                    ) +
                                    this
                                    .translate(
                                       "tip_action_unprocessed"
                                    ),
                                 showCancel: false,
                                 confirmText: this
                                    .translateSys(
                                       'close'
                                    )
                              });
                              showInfo(this
                                 .translateSys(
                                    "quotation_mark_left"
                                 ) +
                                 item
                                 .action_type +
                                 this
                                 .translateSys(
                                    "quotation_mark_right"
                                 ) +
                                 this
                                 .translate(
                                    "tip_action_unprocessed"
                                 ))
                           }
                        });
                     } else {
                        if (result.info) {
                           uni.showModal({
                              title: this
                                 .translateSys(
                                    "tip"),
                              content: result.info,
                              showCancel: false,
                              confirmText: this
                                 .translateSys(
                                    'close')
                           });
                        }
                     } catch (ex) {
                        let actionList = (result.action || []).map(a => a.action_type).join(';')
                        let tip = typeof ex == 'string' ? ex : ex.message
                        tip = `执行脚本返回的${actionList}时出现异常,请检查脚本返回的数据格式是否正确。${tip}`
                        showError(tip, this.translateSys('tip'))
                        return
                     }
                  }
               }).catch(ex => {
                  console.log(ex);
                  uni.showModal({
                     title: this.translateSys("error") +
                        "9.1",
                     content: ex.errMsg,
                     showCancel: false,
                     confirmText: this.translateSys(
                        'close')
                  });
               });
               }
            } catch (ex) {
               var tip = typeof ex == "string" ? ex : ex.message;
               uni.showModal({
                  title: this.translateSys("error") + "9.2",
                  content: this.translate('execute_event_failed') +
                     this.translateSys(
                        "comma") +
                     this.translate('reason') + this.translateSys(
                        "colon") + tip,
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               showError(ex, this.translateSys('error') + "9.2")
            }
         },
@@ -549,7 +505,6 @@
            })
         },
         onButtonClicked(btn) {
            let enviroment = {
               button: "top",
               button_name: btn.ShowName,
@@ -557,93 +512,159 @@
               function: "3202",
               master: {},
            };
            if (btn.FunCode == "TriggerEvent") {
               this.onTriggerEvent(btn, enviroment);
            } else {
               this.$Message.warning(this.$t("sys.unrealized"));
            }
            this.handleButtonClick((done) => {
               if (btn.FunCode == "TriggerEvent") {
                  this.onTriggerEvent(btn, enviroment);
               } else {
                  this.$Message.warning(this.$t("sys.unrealized"));
               }
               setTimeout(() => {
                  done(); // 重置状态
               }, 1000);
            });
         },
         async onTriggerEvent(btn, enviroment) {
            let data_json = [];
            let jsonlist = [];
            try {
               showLoading("loading...")
            let detailStyleList = this.detail1StyleDefList;
            detailStyleList.forEach((style) => {
               let detail_attr = {};
               style.form.items.forEach((item) => {
               let data_json = [];
               let jsonlist = [];
               let detailStyleList = this.detail1StyleDefList;
               detailStyleList.forEach((style) => {
                  let detail_attr = {};
                  style.form.items.forEach((item) => {
                     if (item.name == "Layout") {
                        item.setting.colList.forEach((cols) => {
                           if (cols != null) detail_attr[cols.fieldId] = cols.value;
                        });
                     } else detail_attr[item.fieldId] = item.value;
                  });
                  jsonlist.push(detail_attr);
               });
               data_json = Base64.encode(JSON.stringify(jsonlist));
               let input_param = {};
               this.head_styledef.form.items.forEach((item) => {
                  if (item.name == "Layout") {
                     item.setting.colList.forEach((cols) => {
                        if (cols != null) detail_attr[cols.fieldId] = cols.value;
                        if (cols != null) input_param[cols.fieldId] = cols.value;
                     });
                  } else detail_attr[item.fieldId] = item.value;
                  } else input_param[item.fieldId] = item.value;
               });
               jsonlist.push(detail_attr);
            });
            data_json = Base64.encode(JSON.stringify(jsonlist));
            let input_param = {};
            this.head_styledef.form.items.forEach((item) => {
               if (item.name == "Layout") {
                  item.setting.colList.forEach((cols) => {
                     if (cols != null) input_param[cols.fieldId] = cols.value;
                  });
               } else input_param[item.fieldId] = item.value;
            });
            input_param = Base64.encode(JSON.stringify(input_param));
            await this.runCustomEvent({
               ed_type: 0,
               start_transaction: true,
               class_id: btn.Cls_ID,
               event_id: btn.Event.ID,
               input_param,
               data_json,
            });
               input_param = Base64.encode(JSON.stringify(input_param));
               await this.runCustomEvent({
                  ed_type: 0,
                  start_transaction: true,
                  class_id: btn.Cls_ID,
                  event_id: btn.Event.ID,
                  input_param,
                  data_json,
               });
               hideLoading()
            } catch (ex) {
               hideLoading()
               showError(ex, this.translateSys("error"));
            }
         },
         navigateBackEvent() {
            if (!this.exit_view_event.id)
               return
            let data_json = [];
            let jsonlist = [];
            let detailStyleList = this.detail1StyleDefList;
            detailStyleList.forEach((style) => {
               let detail_attr = {};
               style.form.items.forEach((item) => {
         async navigateBackEvent() {
            try {
               var $this = this;
               if (!this.exit_view_event.id)
                  return
               showLoading("loading...")
               let data_json = [];
               let jsonlist = [];
               let detailStyleList = this.detail1StyleDefList;
               detailStyleList.forEach((style) => {
                  let detail_attr = {};
                  style.form.items.forEach((item) => {
                     if (item.name == "Layout") {
                        item.setting.colList.forEach((cols) => {
                           if (cols != null) detail_attr[cols.fieldId] = cols.value;
                        });
                     } else detail_attr[item.fieldId] = item.value;
                  });
                  jsonlist.push(detail_attr);
               });
               data_json = Base64.encode(JSON.stringify(jsonlist));
               let input_param = {};
               this.head_styledef.form.items.forEach((item) => {
                  if (item.name == "Layout") {
                     item.setting.colList.forEach((cols) => {
                        if (cols != null) detail_attr[cols.fieldId] = cols.value;
                        if (cols != null) input_param[cols.fieldId] = cols.value;
                     });
                  } else detail_attr[item.fieldId] = item.value;
                  } else input_param[item.fieldId] = item.value;
               });
               jsonlist.push(detail_attr);
            });
            data_json = Base64.encode(JSON.stringify(jsonlist));
               input_param = Base64.encode(JSON.stringify(input_param));
               const result = await runCustomEvent({
                  ed_type: 0,
                  start_transaction: true,
                  class_id: this.param.ClsID,
                  event_id: this.exit_view_event.id,
                  input_param,
                  data_json,
               })
               hideLoading()
               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 == 801) {
                     if (this.param.Only_Script_Error) {
                        let pos = tip.indexOf(":");
                        if (pos > -1) tip = tip.substring(pos + 1);
                     }
                  }
                  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('\n') : '';
                  tip = tip || result.err_info
                  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) {
            let input_param = {};
            this.head_styledef.form.items.forEach((item) => {
               if (item.name == "Layout") {
                  item.setting.colList.forEach((cols) => {
                     if (cols != null) input_param[cols.fieldId] = cols.value;
                  });
               } else input_param[item.fieldId] = item.value;
            });
            input_param = Base64.encode(JSON.stringify(input_param));
            const eventChannel = this.getOpenerEventChannel();
                     } else if (typeof result.result == 'string') {
                        showInfo(result.result)
                     }
            eventChannel.emit('ExitViewEvent', {
               ed_type: 0,
               start_transaction: true,
               class_id: this.param.ClsID,
               event_id: this.exit_view_event.id,
               input_param,
               data_json,
            });
                  }
               }
            } catch (ex) {
               hideLoading()
               showError(ex, this.translateSys('error') + "9.2")
            }
         },
         cancel(e) { //取消
            this.navigateBackEvent()
            this.beforeNavigateBack()
            uni.navigateBack({
               delta: 1, //返回层数,2则上上页
            });
         },
         async beforeNavigateBack() {
            await this.navigateBackEvent()
            const eventChannel = this.getOpenerEventChannel();
            eventChannel.emit('ExitViewPage');
         },
         /**
          * 只支持["column1='A' or column2='B'", "column3='C' and column4='D'", "column5='E'"]这种格式
@@ -983,8 +1004,8 @@
      .v-scroll-view {
         flex: 1;
         overflow: hidden;
         width: 98%;
         overflow: auto;
      }
      .view-bottom {