cuiqian2004
5 天以前 07925905f1a596e20e980de6d42db217abb753b0
pages/modal/form/index.vue
@@ -2,7 +2,8 @@
   <view class="uni-page-modal-form" :class="largeMode?'large-mode':''">
      <view class="view-content">
         <!-- 表头样式 -->
         <OIForm ref="refBaseForm" class="v-head-style" :form="head_styledef.form" :focusId="focusFieldId"
         <OIForm ref="refBaseForm" class="v-head-style" :form="head_styledef.form"
            :hiddenIds="head_styledef.hiddenIds ?head_styledef.hiddenIds :[] " :focusId="focusFieldId"
            @on-click="onClick" @on-focus="ontap" @on-change="onEnterChange" @on-click-prefix="classAttr_extButton"
            @on-click-suffix="classAttr_extButton"></OIForm>
      </view>
@@ -56,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: {
@@ -64,7 +68,7 @@
      },
      data() {
         return {
               largeMode: getApp().globalData.largeMode || false,
            largeMode: getApp().globalData.largeMode || false,
            okLoading: false,
            title: this.translateSys('add2'),
            type: '',
@@ -129,6 +133,11 @@
            };
         },
      },
      onReady() {
         uni.setNavigationBarTitle({
            title: this.title
         }); //设置顶部标题
      },
      onLoad(options) {
         this.param = JSON.parse(options.param);
@@ -149,20 +158,11 @@
         if (options.dataJson)
            this.data_json = JSON.parse(options.dataJson);
         this.title = options.titlename ? options.titlename : this.param.ShowName; //设置按钮文字
         // console.log(options)
         uni.setNavigationBarTitle({
            title: this.title
         }); //设置顶部标题
         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"))
         }
      },
      //页面初始化获取焦点
@@ -322,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")
            }
@@ -364,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")
            }
         },
@@ -437,120 +424,106 @@
                     data_json,
                     ext_info
                  })
                  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;
                  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/>') : '';
                     if (tip) uni.showModal({
                        title: this.translateSys('tip'),
                        content: tip,
                        showCancel: false,
                        confirmText: this.translateSys(
                           'close')
                     });
                     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') {
                           showError(result.result)
                           if (item.action_type ==
                              "set_dlg_current_edit_attr"
                           ) {
                        }
                        try {
                           var actionList = result.action || []
                           actionList.forEach(item => {
                              if ($this
                                 .focusOldFieldId ==
                                 item.value) {
                                 $this.setData({
                                    focusFieldId: ""
                                 })
                              } else {
                                 $this.setData({
                                    focusFieldId: $this
                                       .focusOldFieldId
                                 })
                              if (item.action_type ==
                                 "set_dlg_current_edit_attr"
                              ) {
                                 if ($this
                                    .focusOldFieldId ==
                                    item.value) {
                                    $this.setData({
                                       focusFieldId: ""
                                    })
                                 } else {
                                    $this.setData({
                                       focusFieldId: $this
                                          .focusOldFieldId
                                    })
                                 }
                                 $this.$nextTick(() => {
                                    $this.setData({
                                       focusFieldId: item
                                          .value
                                    })
                                 });
                              } else if (item.action_type ==
                                 "set_dlg_attr") {
                                 // value = {"attr":"xxx", "value":"xxx"}
                                 var data = item.value;
                                 $this.setFormValues(data)
                              } else if (action.action_type == 'set_dlg_attr_show') {
                                 var data = action.value;
                                 $this.setFormItemVisible(data)
                              }
                              $this.$nextTick(() => {
                                 $this.setData({
                                    focusFieldId: item
                                       .value
                                 })
                              });
                           } else if (item.action_type ==
                              "set_dlg_attr") {
                              // value = {"attr":"xxx", "value":"xxx"}
                              var data = item.value;
                              $this.setFormValues(data)
                           }
                        });
                     } else {
                        if (result.info) {
                           uni.showModal({
                              title: this.translateSys(
                                 "error") + "4.3",
                              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) {
               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) {
            this.focusFieldId = item.fieldId
            if (item.name == "Input" || item.name == "InputNumber" || item.name == "Textarea") {
               this.focusFieldId = item.fieldId
            } else if (item.name == "ImageButton") {
               var onClickEvent = item.bind.onClickEvent; //后图标点击回调
               if (!onClickEvent.id) {
                  showInfo(this.translate('icon_click_event_empty'))
                  return;
               }
               this.onChange(onClickEvent);
            }
         },
         ontap(item) { //扫码功能
            // var $ele = e;
            //console.log(e.target)
            this.focusOldFieldId = item.fieldId
            getApp().onScan((result) => {
               console.log(result.decodedata);
               item.value = result.decodedata;
               console.log(result);
               item.value = result;
               var $this = this;
               let newVal = item.value.trim()
               if (newVal) {
@@ -665,28 +638,20 @@
            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'
            // open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
            this.$refs.popup.open(this.popupType);
            this.dataObjRunCustomEvent_Return(onSuffixClickEvent.id, '', onSuffixClickCallbackEvent.id,
            this.dataObjRunCustomEvent_Return(onSuffixClickEvent.id, onSuffixClickCallbackEvent.id,
               item);
         },
@@ -741,550 +706,100 @@
                  };
                  runCustomEvent(dataInfo).then(result => {
                     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.result_type == 0 && result.action) {
                           result.action.forEach(item => {
                              if (item.action_type ==
                                 "set_dlg_current_edit_attr"
                              ) {
                                 if ($this
                                    .focusOldFieldId ==
                                    item.value) {
                                    $this.setData({
                                       focusFieldId: ""
                                    })
                                 } else {
                                    $this.setData({
                                       focusFieldId: $this
                                          .focusOldFieldId
                                    })
                                 }
                                 $this.$nextTick(() => {
                                    $this.setData({
                                       focusFieldId: item
                                          .value
                                    })
                                 });
                              } else if (item.action_type ==
                                 "set_dlg_attr") {
                                 // value = {"attr":"xxx", "value":"xxx"}
                                 var data = item.value;
                                 $this.setFormValues(data)
                              }
                           });
                        } else {
                           if (result.info) {
                              uni.showModal({
                                 title: this.translateSys(
                                    "error") + "4.3",
                                 content: result.info,
                                 showCancel: false,
                                 confirmText: this
                                    .translateSys('close')
                              });
                           }
                        }
                     }
                     $this.onFormEventResult(result, "")
                  }).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")
            }
         },
         setFormValues(attrs) {
            console.log(attrs)
            const head_styledef = this.head_styledef
            if (JSON.stringify(attrs) == '{}') {
               return;
            }
            attrs.forEach(async (attr, key) => {
               if (attr.choice_list) {
                  var dictItemList = [];
                  attr.choice_list.forEach(async (val, index) => {
                     dictItemList.push({
                        text: val,
                        value: val
                     });
                  });
                  head_styledef.form.items.forEach(async (attr_item, index) => {
                     if (attr_item.name != "Layout") {
                        if (attr_item.fieldId == attr.attr) {
                           if (attr_item.useDict) {
                              attr_item.dict = dictItemList;
                           } else {
                              attr_item.selections = dictItemList;
                           }
                        }
                     } else if (attr_item.name == "Layout") {
                        attr_item.setting.colList.forEach((col) => {
                           if (col) {
                              if (col.fieldId == attr.attr) {
                                 if (col.useDict) {
                                    col.dict = dictItemList;
                                 } else {
                                    col.selections = dictItemList;
                                 }
                              }
                           }
                        });
                     }
                  });
               }
               head_styledef.form.model[attr.attr] = attr.value;
               head_styledef.form.items.forEach(async (ele, index) => {
                  if (ele.name != "Layout") {
                     if (ele.fieldId == attr.attr) {
                        ele.value = attr.value;
                        ele.oldvalue = attr.value;
                     }
                  } else if (ele.name == "Layout") {
                     ele.setting.colList.forEach((col) => {
                        if (col) {
                           if (col.fieldId == attr.attr) {
                              col.value = attr.value;
                              col.oldvalue = attr.value;
                           }
                        }
                     });
         async onFormEventResult(data, button_callback, item,req) {
            try {
               const $this = this
               var enviroment = {
                  'function': '3000', // 功能点编号
                  cls_id: $this.clsId, // 功能点主数据类标识
                  'button': 'top', // top/bottom
                  button_name: $this.translateSys('add2'),
                  master: {
                     cls_id: $this.clsId, // button=bottom时 master的cls_id
                     //obj_id: ''  // button=bottom时 master的obj_id
                  }
               };
               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') : ''
               })
               //判断表单里是否有返回字段,没有就装载到model里,点击确定提交的时候带上这些数据
            })
            this.setData({
               head_styledef: head_styledef
            })
         },
         popupChange(e) {
            console.log('当前模式:' + e.type + ',状态:' + e.show);
         },
         checkChange(e) { //弹框check选择
            // console.log(e.target.dataset);
            var index = e.target.dataset.index;
            var ischeck = e.target.dataset.ischeck;
            var data = this.check_list.items;
            // this.check_list.items=[];
            if (this.check_list.multiple_choice == "0") { //判断时单选还是多选
               for (var i in data) {
                  data[i].check = false;
               }
            }
            data[index].check = ischeck ? false : true;
            this.check_list.items = data;
         },
         popup_cancel(e) { //弹框取消
            this.$refs.popup.close();
         },
         popup_sava(e) { //弹框确定
            var $this = this;
            var items = $this.check_list.items;
            var data = [];
            var name = "";
            for (var i = 0; i < items.length; i++) {
               if (items[i].check == true) {
                  if (name)
                     name += ';';
                  name += items[i].name;
                  data.push({
                     id: items[i].id,
                     name: items[i].name
                  });
               }
            }
            if (!$this.popupParam) {
               uni.showModal({
                  title: this.translateSys("tip"),
                  content: "popupParam为空!",
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               return;
            }
            if (data.length == 0) {
               uni.showModal({
                  title: this.translateSys("tip"),
                  content: this.translate("tip_no_select_data"),
                  showCancel: false,
                  confirmText: this.translateSys('close')
               });
               return;
            }
            let global_attr = Base64.encode(JSON.stringify(this.global_attr))
            let data_json = Base64.encode(JSON.stringify(this.data_json))
            let ext_info = Base64.encode(JSON.stringify(this.ext_info))
            var callback_eventid = $this.popupParam.button_callback.trim();
            var info = {
               eventid: callback_eventid,
               edtype: "0",
               projectid: '',
               rclsid: '',
               robjid: '',
               userlogin: '',
               clsid: $this.clsId,
               objid: "",
               attr: $this.popupParam.req,
               dataJson: data
            }
            $this.DataObjRunCustomEvent(info, $this.popupParam.data_attr);
            this.$refs.popup.close();
         },
         async DataObjRunCustomEvent(info, data_attr) {
            var $this = this;
            var enviroment = {
               'function': '3000', // 功能点编号
               cls_id: this.clsId, // 功能点主数据类标识
               'button': 'top', // top/bottom
               button_name: this.translateSys('add2'),
               master: {
                  cls_id: this.clsId, // button=bottom时 master的cls_id
                  //obj_id: ''  // button=bottom时 master的obj_id
               }
            };
            if (data_attr) {
               enviroment.edit_dlg = {
                  type: 'small', //小窗口
                  class_id: this.clsId, //当前数据类id
               }
               if (data_attr) {
                  enviroment.edit_dlg.form_control = { //所属的表单控件
                     name: data_attr.Name, //字段属性
                     text: data_attr.DispName, //显示文本
                     group_name: data_attr.GroupName, //属性组
                     type: data_attr.Type, //字段类型
                     readonly: data_attr.ReadOnly, //是否只读
                     button_img: data_attr.button_img, //引用按钮的图标
                     button_tooltip: data_attr.button_tooltip //引用按钮的tooltip
                  }
               }
            }
            enviroment = Base64.encode(JSON.stringify(enviroment)); //将字符串转换为base64编码
            var input_param = Base64.encode(JSON.stringify(info.attr)); //将字符串转换为base64编码
            var global_attr = Base64.encode(JSON.stringify(this.global_attr)); //将字符串转换为base64编码
            if (info.dataJson)
               info.dataJson = Base64.encode(JSON.stringify(info.dataJson)); //将字符串转换为base64编码
            var obj_attr = {};
            info.attr.forEach(item => {
               obj_attr[item.attr] = item.value;
            });
            if (!info.eventid.includes('{')) info.eventid = '{' + info.eventid + '}';
            var dataInfo = {
               ed_type: info.edtype,
               start_transaction: true,
               class_id: info.clsid,
               class_name: '',
               event_id: info.eventid,
               event_name: '',
               data_obj_id: info.objid,
               obj_attr: obj_attr,
               prj_id: info.projectid,
               ref_cls_id: info.rclsid,
               rel_obj_id: info.robjid,
               user_login: info.userlogin,
               data_json: info.dataJson,
               compose_info: '',
               ext_info: enviroment,
               global_attr: global_attr,
               input_param: input_param,
            };
            console.log(dataInfo);
            // return;
            runCustomEvent(dataInfo).then(data => {
               if (data.ret != 0) {
                  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 (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/>') : '';
                  if (tip) uni.showModal({
                     title: this.translateSys("tip"),
                     content: tip,
                     showCancel: false,
                     confirmText: this.translateSys('close')
                  });
                  var tip = data.info ? typeof data.info == 'string' ? data.info :
                     data.info.join('\n') : '';
                  tip = tip || data.err_info
                  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) {
                  var actionlist = data.action;
                  if (actionlist) {
                     console.log(actionlist);
                     for (var i = 0; i < actionlist.length; i++) {
                        var action = actionlist[i];
                        if (action.action_type == 'set_dlg_attr') {
                           var result = action.value;
                           $this.setFormValues(result)
                        } else if (action.action_type == 'set_dlg_attr_show') {
                           var result = action.value;
                           result.forEach(async (attr, key) => {
                              $this.head_styledef.form.items
                                 .forEach(
                                    async (ele,
                                       index) => {
                                       //判断是否是栅格表单
                                       if (ele.name != 'Layout') {
                                          if (ele.fieldId == attr
                                             .attr) {
                                             ele.show = attr
                                                .show;
                                          }
                                       } else if (ele.name ==
                                          'Layout') {
                                          ele.setting.colList
                                             .forEach(
                                                col => {
                                                   if (col) {
                                                      if (col
                                                         .fieldId ==
                                                         attr
                                                         .attr
                                                      ) {
                                                         col.show =
                                                            attr
                                                            .show;
                                                      }
                                                   }
                                                });
                                       }
                                    });
                           });
                           var head_styledef = JSON.parse(JSON.stringify($this.$data
                              .head_styledef));
                           $this.head_styledef = [];
                           $this.head_styledef = head_styledef;
                           // console.log($this.head_styledef);
                        } else if (action.action_type == 'set_global_attr') {
                           $this.global_attr = action.value || [];
                        } 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')
                           });
                        }
                     } else if (typeof data.result == 'string') {
                        showInfo(data.result)
                     }
                  }
                  console.log($this.head_styledef);
                  if (data.result) {
                     $this.setFormValues(data.result)
                  }
               }
            }).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')
               });
            });
         },
         dataObjRunCustomEvent_Return(eventid, data_attr, button_callback, item) {
            console.log("dataObjRunCustomEvent_Return", eventid, data_attr, button_callback)
            const $this = this
            var enviroment = {
               'function': '3000', // 功能点编号
               cls_id: $this.clsId, // 功能点主数据类标识
               'button': 'top', // top/bottom
               button_name: $this.translateSys('add2'),
               master: {
                  cls_id: $this.clsId, // button=bottom时 master的cls_id
                  //obj_id: ''  // button=bottom时 master的obj_id
               }
            };
            var obj_attr = $this.head_styledef.form.model;
            console.log(obj_attr);
            var req = Object.keys(obj_attr).map((a) => ({
               attr: a,
               value: obj_attr[a] || "",
            }));
            let global_attr = Base64.encode(JSON.stringify(this.global_attr))
            let data_json = Base64.encode(JSON.stringify(this.data_json))
            let ext_info = Base64.encode(JSON.stringify(this.ext_info))
            var obj_attr = {};
            req.forEach(item2 => {
               obj_attr[item2.attr] = item2.value;
            });
            let input_param = Base64.encode(
               JSON.stringify(
                  Object.keys(obj_attr).map((a) => ({
                     attr: a,
                     value: obj_attr[a] || "",
                  }))
               )
            );
            if (!eventid.includes('{')) eventid = '{' + eventid + '}';
            var dataInfo = {
               ed_type: "0",
               start_transaction: true,
               class_id: $this.clsId,
               class_name: '',
               event_id: eventid,
               event_name: '',
               data_obj_id: '',
               obj_attr: obj_attr,
               prj_id: '',
               ref_cls_id: '',
               rel_obj_id: '',
               user_login: '',
               data_json,
               compose_info: '',
               ext_info,
               global_attr,
               input_param: input_param,
            };
            console.log(dataInfo);
            // return;
            runCustomEvent(dataInfo).then(data => {
               if (data.ret != 0) {
                  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')
                  });
                  return false
               } else {
                  var tip = data.info ? typeof data.info == 'string' ? data.info : data
                     .info
                     .join(
                        '<br/>') : '';
                  if (tip) uni.showModal({
                     title: $this.translateSys("tip"),
                     content: tip,
                     showCancel: false,
                     confirmText: $this.translateSys('close')
                  });
                  if (data != "") {
                     var actions = data.action;
                     if (actions) {
                     try {
                        var enviroment = JSON.stringify(enviroment);
                        var actions = data.action || []
                        for (var i = 0; i < actions.length; i++) {
                           var action = actions[i];
                           console.log(action)
                           var val = action.value;
                           var enviroment = JSON.stringify(enviroment);
                           if (action.action_type ==
                              "set_dlg_current_edit_attr"
                           ) {
                           if (action.action_type == 'open_panel') {
                              if ($this
                                 .focusOldFieldId ==
                                 action.value) {
                                 $this.setData({
                                    focusFieldId: ""
                                 })
                              } else {
                                 $this.setData({
                                    focusFieldId: $this
                                       .focusOldFieldId
                                 })
                              }
                              $this.$nextTick(() => {
                                 $this.setData({
                                    focusFieldId: action
                                       .value
                                 })
                              });
                           } else if (action.action_type ==
                              "set_dlg_attr") {
                              // value = {"attr":"xxx", "value":"xxx"}
                              var data = action.value;
                              $this.setFormValues(data)
                           } else if (action.action_type ==
                              'set_dlg_attr_show') {
                              var data = action.value;
                              $this.setFormItemVisible(data)
                           } else if (action.action_type == 'set_global_attr') {
                              $this.global_attr = action.value || [];
                           } else if (action.action_type == 'open_panel') {
                              var d = dialog({
                                 title: '<i class="ace-icon fa fa-info-circle"></i> ' +
                                    $this.translateSys("tip"),
@@ -1304,7 +819,7 @@
                                 item: item,
                                 button_callback: button_callback,
                                 req: req,
                                 data_attr: data_attr
                                 data_attr: ""
                              }
                              uni.navigateTo({
                                 url: '../selpsn/index?mulit=false&param=' +
@@ -1356,7 +871,8 @@
                                 $this.setData({
                                    check_list: val.config
                                 })
                                 if (val.config.appear_style == 'sideslip') //判断是否是侧滑
                                 if (val.config.appear_style ==
                                    'sideslip') //判断是否是侧滑
                                    $this.setData({
                                       popupType: "right"
                                    })
@@ -1370,13 +886,14 @@
                                    item: item,
                                    button_callback: button_callback,
                                    req: req,
                                    data_attr: data_attr
                                    data_attr: ""
                                 }
                                 $this.setData({
                                    popupParam: popupParam
                                 })
                              }
                           } else if (action.action_type == 'open_project_query_dlg') {
                           } else if (action.action_type ==
                              'open_project_query_dlg') {
                              //console.log(action.value.select_range);
                              //console.log(action.value.mulit_select);
                              var priRel = '-1';
@@ -1437,45 +954,319 @@
                                 }
                              });
                           } 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"))
                           }
                        }
                     } catch (ex) {
                        let actionList = (data.action || []).map(a => a.action_type).join(';')
                        let tip = typeof ex == 'string' ? ex : ex.message
                        tip = `执行脚本返回的${actionList}时出现异常,请检查脚本返回的数据格式是否正确。${tip}`
                        showError(tip, this.translateSys('tip'))
                        return
                     }
                  } else {
                     uni.showModal({
                        title: $this.translateSys('tip') + "5.2",
                        content: $this.translateSys("quotation_mark_left") +
                           "before_click_button" + $this.translateSys(
                              "quotation_mark_right") + $this.translateSys(
                              "comma") + 'event_id' + eventid,
                        showCancel: false,
                        confirmText: $this.translateSys('close')
                     });
                  }
               }
            } catch (ex) {
               showError(ex, this.translateSys("error") + "10.1")
            }
         },
         setFormValues(attrs) {
            console.log(attrs)
            const head_styledef = this.head_styledef
            if (!Array.isArray(attrs)) {
               return
            }
            attrs.forEach(async (attr, key) => {
               if (attr.choice_list) {
                  var dictItemList = [];
                  attr.choice_list.forEach(async (val, index) => {
                     dictItemList.push({
                        text: val,
                        value: val
                     });
                  });
                  head_styledef.form.items.forEach(async (attr_item, index) => {
                     if (attr_item.name != "Layout") {
                        if (attr_item.fieldId == attr.attr) {
                           if (attr_item.useDict) {
                              attr_item.dict = dictItemList;
                           } else {
                              attr_item.selections = dictItemList;
                           }
                        }
                     } else if (attr_item.name == "Layout") {
                        attr_item.setting.colList.forEach((col) => {
                           if (col) {
                              if (col.fieldId == attr.attr) {
                                 if (col.useDict) {
                                    col.dict = dictItemList;
                                 } else {
                                    col.selections =
                                       dictItemList;
                                 }
                              }
                           }
                        });
                     }
                  });
               }
               head_styledef.form.model[attr.attr] = attr.value;
               head_styledef.form.items.forEach(async (ele, index) => {
                  if (ele.name != "Layout") {
                     if (ele.fieldId == attr.attr) {
                        ele.value = attr.value;
                        ele.oldvalue = attr.value;
                     }
                  } else if (ele.name == "Layout") {
                     ele.setting.colList.forEach((col) => {
                        if (col) {
                           if (col.fieldId == attr.attr) {
                              col.value = attr.value;
                              col.oldvalue = attr.value;
                           }
                        }
                     });
                  }
               })
               //判断表单里是否有返回字段,没有就装载到model里,点击确定提交的时候带上这些数据
            })
            this.setData({
               head_styledef: head_styledef
            })
         },
         setFormItemVisible(attrs) {
            if (!Array.isArray(attrs)) {
               return
            }
            const head_styledef = this.head_styledef
            if (!head_styledef.hiddenIds) {
               head_styledef.hiddenIds = []
            }
            attrs.forEach((attr) => {
               let index = head_styledef.hiddenIds.findIndex((id) => id == attr.attr);
               if (attr.show) {
                  if (index > -1) head_styledef.hiddenIds.splice(index, 1);
               } else {
                  if (index == -1) head_styledef.hiddenIds.push(attr.attr);
               }
            });
            this.setData({
               head_styledef: head_styledef
            })
         },
         popupChange(e) {
            console.log('当前模式:' + e.type + ',状态:' + e.show);
         },
         checkChange(e) { //弹框check选择
            // console.log(e.target.dataset);
            var index = e.target.dataset.index;
            var ischeck = e.target.dataset.ischeck;
            var data = this.check_list.items;
            // this.check_list.items=[];
            if (this.check_list.multiple_choice == "0") { //判断时单选还是多选
               for (var i in data) {
                  data[i].check = false;
               }
            }
            data[index].check = ischeck ? false : true;
            this.check_list.items = data;
         },
         popup_cancel(e) { //弹框取消
            this.$refs.popup.close();
         },
         popup_sava(e) { //弹框确定
            var $this = this;
            var items = $this.check_list.items;
            var data = [];
            var name = "";
            for (var i = 0; i < items.length; i++) {
               if (items[i].check == true) {
                  if (name)
                     name += ';';
                  name += items[i].name;
                  data.push({
                     id: items[i].id,
                     name: items[i].name
                  });
               }
            }
            if (!$this.popupParam) {
               showInfo("popupParam为空!")
               return;
            }
            if (data.length == 0) {
               showInfo(this.translate("tip_no_select_data"))
               return;
            }
            let global_attr = Base64.encode(JSON.stringify(this.global_attr))
            let data_json = Base64.encode(JSON.stringify(this.data_json))
            let ext_info = Base64.encode(JSON.stringify(this.ext_info))
            var callback_eventid = $this.popupParam.button_callback.trim();
            var info = {
               eventid: callback_eventid,
               edtype: "0",
               projectid: '',
               rclsid: '',
               robjid: '',
               userlogin: '',
               clsid: $this.clsId,
               objid: "",
               attr: $this.popupParam.req,
               dataJson: data
            }
            $this.DataObjRunCustomEvent(info, $this.popupParam.data_attr);
            this.$refs.popup.close();
         },
         async DataObjRunCustomEvent(info, data_attr) {
            var $this = this;
            if (!info.eventid)
               return
            var enviroment = {
               'function': '3000', // 功能点编号
               cls_id: this.clsId, // 功能点主数据类标识
               'button': 'top', // top/bottom
               button_name: this.translateSys('add2'),
               master: {
                  cls_id: this.clsId, // button=bottom时 master的cls_id
                  //obj_id: ''  // button=bottom时 master的obj_id
               }
            };
            if (data_attr) {
               enviroment.edit_dlg = {
                  type: 'small', //小窗口
                  class_id: this.clsId, //当前数据类id
               }
               if (data_attr) {
                  enviroment.edit_dlg.form_control = { //所属的表单控件
                     name: data_attr.Name, //字段属性
                     text: data_attr.DispName, //显示文本
                     group_name: data_attr.GroupName, //属性组
                     type: data_attr.Type, //字段类型
                     readonly: data_attr.ReadOnly, //是否只读
                     button_img: data_attr.button_img, //引用按钮的图标
                     button_tooltip: data_attr.button_tooltip //引用按钮的tooltip
                  }
               }
            }
            enviroment = Base64.encode(JSON.stringify(enviroment)); //将字符串转换为base64编码
            var input_param = Base64.encode(JSON.stringify(info.attr)); //将字符串转换为base64编码
            var global_attr = Base64.encode(JSON.stringify(this.global_attr)); //将字符串转换为base64编码
            if (info.dataJson)
               info.dataJson = Base64.encode(JSON.stringify(info.dataJson)); //将字符串转换为base64编码
            var obj_attr = {};
            info.attr.forEach(item => {
               obj_attr[item.attr] = item.value;
            });
            if (!info.eventid.includes('{')) info.eventid = '{' + info.eventid + '}';
            var dataInfo = {
               ed_type: info.edtype,
               start_transaction: true,
               class_id: info.clsid,
               class_name: '',
               event_id: info.eventid,
               event_name: '',
               data_obj_id: info.objid,
               obj_attr: obj_attr,
               prj_id: info.projectid,
               ref_cls_id: info.rclsid,
               rel_obj_id: info.robjid,
               user_login: info.userlogin,
               data_json: info.dataJson,
               compose_info: '',
               ext_info: enviroment,
               global_attr: global_attr,
               input_param: input_param,
            };
            console.log(dataInfo);
            // return;
            runCustomEvent(dataInfo).then(data => {
               $this.onFormEventResult(data, "")
            }).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('error') + "3.1")
            });
         },
         dataObjRunCustomEvent_Return(eventid, button_callback, item) {
            console.log("dataObjRunCustomEvent_Return", eventid, button_callback)
            const $this = this
            var enviroment = {
               'function': '3000', // 功能点编号
               cls_id: $this.clsId, // 功能点主数据类标识
               'button': 'top', // top/bottom
               button_name: $this.translateSys('add2'),
               master: {
                  cls_id: $this.clsId, // button=bottom时 master的cls_id
                  //obj_id: ''  // button=bottom时 master的obj_id
               }
            };
            var obj_attr = $this.head_styledef.form.model;
            console.log(obj_attr);
            var req = Object.keys(obj_attr).map((a) => ({
               attr: a,
               value: obj_attr[a] || "",
            }));
            let global_attr = Base64.encode(JSON.stringify(this.global_attr))
            let data_json = Base64.encode(JSON.stringify(this.data_json))
            let ext_info = Base64.encode(JSON.stringify(this.ext_info))
            var obj_attr = {};
            req.forEach(item2 => {
               obj_attr[item2.attr] = item2.value;
            });
            let input_param = Base64.encode(
               JSON.stringify(
                  Object.keys(obj_attr).map((a) => ({
                     attr: a,
                     value: obj_attr[a] || "",
                  }))
               )
            );
            if (!eventid.includes('{')) eventid = '{' + eventid + '}';
            var dataInfo = {
               ed_type: "0",
               start_transaction: true,
               class_id: $this.clsId,
               class_name: '',
               event_id: eventid,
               event_name: '',
               data_obj_id: '',
               obj_attr: obj_attr,
               prj_id: '',
               ref_cls_id: '',
               rel_obj_id: '',
               user_login: '',
               data_json,
               compose_info: '',
               ext_info,
               global_attr,
               input_param: input_param,
            };
            console.log(dataInfo);
            // return;
            runCustomEvent(dataInfo).then(data => {
               $this.onFormEventResult(data, button_callback, item,req)
            }).catch(ex => {
               showError(ex, this.translateSys('tip') + "5.1")
            });
         },
         //确定
@@ -1503,6 +1294,7 @@
               uni.navigateBack()
            } catch (ex) {
               this.okLoading = true
               showError(ex, this.translateSys('tip') + "1")
               return false;
            }
         },
@@ -1539,7 +1331,7 @@
               return true;
            } catch (ex) {
               console.log("sava", ex)
               this.showError(ex)
               showError(ex, this.translateSys('tip'))
               return false;
            }
@@ -1585,16 +1377,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
            }
@@ -1612,16 +1395,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
            }
@@ -1639,16 +1413,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
            }
@@ -1665,8 +1430,10 @@
                     value: obj_attr[a],
                  })),
               };
               let global_attr = Base64.encode(JSON.stringify(this.global_attr))
               let data_json = Base64.encode(JSON.stringify(this.data_json))
               let global_attr = Base64.encode(JSON.stringify(this
                  .global_attr))
               let data_json = Base64.encode(JSON.stringify(this
                  .data_json))
               let ext_info = Base64.encode(JSON.stringify(this.ext_info))
               var dataInfo = {
                  ed_type: "0",
@@ -1685,21 +1452,13 @@
                  data_json,
                  ext_info,
                  compose_info: '',
                  input_param: Base64.encode(JSON.stringify(input_param)),
                  input_param: Base64.encode(JSON.stringify(
                     input_param)),
               };
               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
            }
@@ -1723,59 +1482,15 @@
                  delta: 1 //返回层数,2则上上页
               });
               await this.afterCancel();
            } catch (ex) {}
            } catch (ex) {
               showError(ex, this.translateSys('tip'))
            }
         },
         async beforeCancel() {
            try {
               if (!this.beforeCancelEvent.id) return true;
               var obj_attr = this.head_styledef.form.model;
               let inputParam = {
                  id: "",
                  attrs: Object.keys(obj_attr).map((a) => ({
                     attr: a,
                     value: obj_attr[a],
                  })),
               };
               let input_param = Base64.encode(JSON.stringify(
                  inputParam));
               let global_attr = Base64.encode(JSON.stringify(this
                  .global_attr))
               let data_json = Base64.encode(JSON.stringify(this
                  .data_json))
               let ext_info = Base64.encode(JSON.stringify(this.ext_info))
               await runCustomEvent({
                  ed_type: 0,
                  start_transaction: true,
                  class_id: this.clsId,
                  event_id: this.beforeCancelEvent.id,
                  data_obj_id: this.objId,
                  obj_attr,
                  input_param,
                  global_attr,
                  data_json,
                  ext_info,
               })
               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')
               });
               return false
            }
         },
         async afterCancel() {
            try {
               if (!this.afterCancelEvent.id) return true;
               var obj_attr = this.head_styledef.form.model;
               let inputParam = {
                  id: "",
                  attrs: Object.keys(obj_attr).map((a) => ({
@@ -1796,6 +1511,48 @@
                  ed_type: 0,
                  start_transaction: true,
                  class_id: this.clsId,
                  event_id: this.beforeCancelEvent.id,
                  data_obj_id: this.objId,
                  obj_attr,
                  input_param,
                  global_attr,
                  data_json,
                  ext_info,
               })
               return true
            } catch (ex) {
               showError(ex, this.translateSys('tip') + "8.1")
               return false
            }
         },
         async afterCancel() {
            try {
               if (!this.afterCancelEvent.id) return true;
               var obj_attr = this.head_styledef.form.model;
               let inputParam = {
                  id: "",
                  attrs: Object.keys(obj_attr).map((a) =>
                     ({
                        attr: a,
                        value: obj_attr[a],
                     })),
               };
               let input_param = Base64.encode(JSON.stringify(
                  inputParam));
               let global_attr = Base64.encode(JSON.stringify(
                  this
                  .global_attr))
               let data_json = Base64.encode(JSON.stringify(
                  this
                  .data_json))
               let ext_info = Base64.encode(JSON.stringify(
                  this
                  .ext_info))
               await runCustomEvent({
                  ed_type: 0,
                  start_transaction: true,
                  class_id: this.clsId,
                  event_id: this.afterCancelEvent.id,
                  data_obj_id: this.objId,
                  obj_attr,
@@ -1806,28 +1563,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}`)