cuiqian2004
2024-09-05 b217ec6d467ef11448dbcfa56f236ebe94f4be65
pages/modal/3018_2.vue
@@ -166,6 +166,16 @@
<script>
   import Base64 from '../../components/js-base64/base64.js'
   import utils from "@/js/utils.js"
   import {
      appGetInfo,
      dictGetInfo
   } from "@/api/mobox.js"
   import {
      getUIStyleInfo,
      runCustomEvent,
      dataObjCreate
   } from "@/api/data.js"
   export default {
      modules: {
         Base64,
@@ -181,9 +191,6 @@
            global_attr: [],
            refdatastore: [], //引用数据存储区// {attr:'G_PRJ_' + bindattr + '_ID', value:info.id}
            scanCodeVal: "",
            subClassAttrList: [],
            subPanelList: [],
            subClassGridStyle: [],
            popupType: "center",
            check_list: {},
@@ -251,12 +258,8 @@
               global_attr: [],
               refdatastore: [], //引用数据存储区// {attr:'G_PRJ_' + bindattr + '_ID', value:info.id}
               scanCodeVal: "",
               subClassAttrList: [],
               subPanelList: [],
               subClassGridStyle: [],
               popupType: "center",
               check_list: {},
               focusFieldId: "",
               focusOldFieldId: "",
               head_styledef: {
@@ -292,6 +295,7 @@
      },
      methods: {
         setData: function(obj) {
            let that = this;
            let keys = [];
@@ -351,31 +355,22 @@
               ui_style_id: style_id,
            };
            try {
               var textProgress = `Head_UIStyleGetInfo start ${class_id}_${style_id}\n`
               const ret = await this.getUIStyleInfo(dataInfo)
               textProgress += `err_code:${ret.err_code}\n`
               const ret = await getUIStyleInfo(dataInfo)
               var styledef = "";
               if (ret.result.style_def) {
               if (ret.style_def) {
                  //mobox2的style_def是json字符串
                  styledef = ret.result.style_def.replace(/\\/g, "");
                  styledef = ret.style_def.replace(/\\/g, "");
                  //mobox3的style_def是base64字符串
                  if (!ret.result.style_def.includes('"')) styledef = Base64.decode(ret
                     .result
                     .style_def);
                  if (!ret.style_def.includes('"')) styledef = Base64.decode(ret.style_def);
               }
               textProgress += `styledef2:${styledef}\n`
               const styledefHead = styledef ? JSON.parse(styledef) : {};
               if (styledefHead?.form?.items) {
                  for (let i in styledefHead.form.items) {
                     const ele = styledefHead.form.items[i]
                     textProgress += `form.items${i}:${ele.name}\n`
                     if (ele.name != "Layout") {
                        ele.show = true
                        if (ele?.useDict) {
                           //判断useDict是否使用字典
                           textProgress += `Dict:${ele.bind.dict.name}\n`
                           await $this.DictGetInfo(ele.bind.dict,
                              styledefHead.form.model,
                              ele);
@@ -383,7 +378,6 @@
                        if ($this.focusFieldId == "") {
                           if (ele.name == 'Input' || ele.name ==
                              'InputNumber') {
                              textProgress += `focusFieldId=${ele.fieldId}\n`
                              $this.setData({
                                 focusFieldId: ele.fieldId
                              })
@@ -392,12 +386,10 @@
                     } else {
                        for (let j in ele.setting.colList) {
                           const col = ele.setting.colList[j]
                           textProgress += `col${j}:${col?.name || ''}\n`
                           if (col) {
                              col.show = true
                              if (col?.useDict) {
                                 //判断useDict是否使用字典
                                 textProgress += `Dict:${col.bind.dict.name}\n`
                                 await $this.DictGetInfo(col.bind
                                    .dict,
                                    styledefHead.form
@@ -407,7 +399,6 @@
                                 if (col.name == 'Input' || col
                                    .name ==
                                    'InputNumber') {
                                    textProgress += `focusFieldId=${col.fieldId}\n`
                                    $this.setData({
                                       focusFieldId: col
                                          .fieldId
@@ -420,11 +411,9 @@
                  }
               }
               textProgress += `head_styledef value\n`
               $this.setData({
                  head_styledef: styledefHead
               })
               textProgress += `event:${this.head_styledef.event?.length || 0}\n`
               if ($this.head_styledef.event) {
                  $this.head_styledef.event.forEach(async (a) => { //判断是否是初始化事件
                     if (a.event_id == "initial") {
@@ -437,10 +426,8 @@
                     }
                  });
               }
               textProgress += `end`
            } catch (ex) {
               // console.log(ex);
               console.log(textProgress);
               console.log(JSON.stringify(ex), ex);
               let exStr = JSON.stringify(ex)
               if (exStr == "{}")
@@ -448,137 +435,24 @@
               let tip = typeof ex.errMsg == "string" ? ex.errMsg : exStr
               uni.showModal({
                  title: this.translateSys("error") + "1.1",
                  content: tip + '\n' + textProgress,
                  content: tip,
                  showCancel: false,
                  confirmText: this.translateSys("cancel")
               });
            }
            // this.$store.dispatch('UIStyleGetInfo', dataInfo).then(async (ret) => {
            //    // console.log("ret",ret);
            //    textProgress += `err_code:${ret.err_code}\n`
            //    if (ret.err_code == 0) {
            //       var styledef = "";
            //       if (ret.result.style_def) {
            //          //mobox2的style_def是json字符串
            //          styledef = ret.result.style_def.replace(/\\/g, "");
            //          //mobox3的style_def是base64字符串
            //          if (!ret.result.style_def.includes('"')) styledef = Base64.decode(ret
            //             .result
            //             .style_def);
            //       }
            //       textProgress += `styledef2:${styledef}\n`
            //       const styledefHead = styledef ? JSON.parse(styledef) : {};
            //       for (let i in styledefHead.form.items) {
            //          const ele = styledefHead.form.items[i]
            //          textProgress += `form.items${i}:${ele.name}\n`
            //          if (ele.name != "Layout") {
            //             ele.show = true
            //             if (ele?.useDict) {
            //                //判断useDict是否使用字典
            //                textProgress += `Dict:${ele.bind.dict.name}\n`
            //                await $this.DictGetInfo(ele.bind.dict,
            //                   styledefHead.form.model,
            //                   ele);
            //             }
            //             if ($this.focusFieldId == "") {
            //                if (ele.name == 'Input' || ele.name ==
            //                   'InputNumber') {
            //                   textProgress += `focusFieldId=${ele.fieldId}\n`
            //                   $this.setData({
            //                      focusFieldId: ele.fieldId
            //                   })
            //                }
            //             }
            //          } else {
            //             for (let j in ele.setting.colList) {
            //                const col = ele.setting.colList[j]
            //                textProgress += `col${j}:${col?.name || ''}\n`
            //                if (col) {
            //                   col.show = true
            //                   if (col?.useDict) {
            //                      //判断useDict是否使用字典
            //                      textProgress += `Dict:${col.bind.dict.name}\n`
            //                      await $this.DictGetInfo(col.bind
            //                         .dict,
            //                         styledefHead.form
            //                         .model, col);
            //                   }
            //                   if ($this.focusFieldId == "") {
            //                      if (col.name == 'Input' || col
            //                         .name ==
            //                         'InputNumber') {
            //                         textProgress += `focusFieldId=${col.fieldId}\n`
            //                         $this.setData({
            //                            focusFieldId: col
            //                               .fieldId
            //                         })
            //                      }
            //                   }
            //                }
            //             }
            //          }
            //       }
            //       textProgress += `head_styledef value\n`
            //       $this.setData({
            //          head_styledef: styledefHead
            //       })
            //       textProgress += `event:${this.head_styledef.event?.length || 0}\n`
            //       if ($this.head_styledef.event) {
            //          $this.head_styledef.event.forEach(async (a) => { //判断是否是初始化事件
            //             if (a.event_id == "initial") {
            //                await $this.loadInitEvent(a.scrip_id);
            //             } else if (a.event_id == 'after_ok') {
            //                $this.after_ok = {
            //                   id: a.scrip_id,
            //                   name: a.scrip_name
            //                };
            //             }
            //          });
            //       }
            //       textProgress += `end`
            //    } else {
            //       textProgress += `err_msg:${ret.err_msg}\n`
            //       uni.showModal({
            //          title: this.translateSys("error") + "1",
            //          content: tip + '\n' + textProgress,
            //          showCancel: false,
            //          confirmText: this.translateSys("cancel")
            //       });
            //    }
            // }).catch(ex => {
            //    console.log(textProgress);
            //    console.log(JSON.stringify(ex), ex);
            //    let tip = typeof ex.errMsg == "string" ? ex.errMsg : ex
            //    uni.showModal({
            //       title: this.translateSys("error") + "1.1",
            //       content: tip + '\n' + textProgress,
            //       showCancel: false,
            //       confirmText: this.translateSys("cancel")
            //    });
            //    // console.log(ex);
            //    // uni.showModal({
            //    //    title: this.translateSys("error") + "1.1",
            //    //    content: ex.errMsg,
            //    //    showCancel: false,
            //    //    confirmText: this.translateSys("cancel")
            //    // });
            // });
         },
         async DictGetInfo(dict, formModel, formItem) { //Mobox3得到得到字典信息字典项列表
            try {
            var $this = this;
            var dataInfo = {
               dict_id: dict.id,
               dict_name: dict.name
            };
            try {
               const res = await this.getDictInfo(dataInfo)
               const res = await dictGetInfo(dataInfo)
               var list = [];
               var itemName = '';
               res.result.dict_item_list.forEach((item) => {
               (res.dict_item_list || []).forEach((item) => {
                  if (item.is_default == '1')
                     itemName = item.name;
                  list.push({
@@ -592,9 +466,6 @@
                  formModel[formItem.fieldId] = itemName;
               }
               formItem.dict = list;
               // $this.head_styledef.form.items[index].dictitem=success.result;
               // this.$store.commit("classAttrList", $this.$data.classAttrList);
            } catch (ex) {
               // console.log(ex);
               uni.showModal({
@@ -605,101 +476,9 @@
               });
            }
         },
         getDictInfo(info) { //Mobox3得到得到字典信息字典项列表
            const loginInfo = this.$store.getters.loginid
            const mobxoSApi = this.$store.getters.getMobxoSApi
            return new Promise((resolve, reject) => {
               uni.request({
                  url: mobxoSApi + 'api/dict/GetInfo2?sessionid=' + loginInfo.result.session_id,
                  data: info,
                  method: 'POST',
                  dataType: "json",
                  success: (_res) => {
                     // console.log(_res);
                     var ret = _res.data
                     if (typeof ret == 'string') {
                        try {
                           try {
                              try {
                                 ret = JSON.parse(ret.replace(/\\"/g, '"'));
                              } catch (ex) {
                                 ret = JSON.parse(ret.replace(/\\/g, '\\\\'))
                              }
                           } catch (ex) {
                              ret = JSON.parse(ret.replace(/\\"/g, "'").replace(/[\r\n]/g,
                                 '<br>').replace(/[\t]/g, '    '));
                           }
                        } catch (ex) {
                           console.log(ret)
                           return reject('将getDictInfo【json string】转换为【json object】失败')
                        }
                     }
                     if (ret.err_code == 0) {
                        resolve(ret);
                     } else {
                        reject({
                           "errMsg": ret.err_msg
                        });
                     }
                  },
                  fail: (err) => {
                     // console.log(err);
                     reject(err);
                  }
               })
            })
         },
         getUIStyleInfo(info) { //Mobox3数据类界面样式
            const loginInfo = this.$store.getters.loginid
            const dataSApi = this.$store.getters.getDataSApi
            return new Promise((resolve, reject) => {
               uni.request({
                  url: dataSApi + 'api/class/uistyle/GetInfo?sessionid=' + loginInfo.result
                     .session_id,
                  data: info,
                  method: 'POST',
                  dataType: "json",
                  success: (_res) => {
                     // console.log(_res);
                     var ret = _res.data
                     if (typeof ret == 'string') {
                        try {
                           try {
                              try {
                                 ret = JSON.parse(ret.replace(/\\"/g, '"'));
                              } catch (ex) {
                                 ret = JSON.parse(ret.replace(/\\/g, '\\\\'))
                              }
                           } catch (ex) {
                              ret = JSON.parse(ret.replace(/\\"/g, "'").replace(/[\r\n]/g,
                                 '<br>').replace(/[\t]/g, '    '));
                           }
                        } catch (ex) {
                           console.log(ret)
                           return reject('将getUIStyleInfo【json string】转换为【json object】失败')
                        }
                     }
                     if (ret.err_code == 0) {
                        resolve(ret);
                     } else {
                        reject({
                           "errMsg": ret.err_msg || ret.errMsg
                        });
                     }
                  },
                  fail: (err) => {
                     // console.log(err);
                     reject(err);
                  }
               })
            })
         },
         async loadInitEvent(eventid) {
            try {
            var $this = this;
            if (!eventid.includes('{')) eventid = '{' + eventid + '}';
            var dataInfo = {
@@ -709,11 +488,7 @@
               event_id: eventid,
            };
            console.log(dataInfo);
            // return;
            this.$store.dispatch('runCustomEvent', dataInfo).then(success => {
               console.log(success);
               if (success.err_code == 0) {
                  var data = success.result;
               var data = await runCustomEvent(dataInfo)
                  if (data.ret != 0) {
                     var tip = data.err_info ? typeof data.err_info == 'string' ? data
                        .err_info : data
@@ -931,30 +706,21 @@
                        }
                     }
                  }
               } else {
            } 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",
                     content: this.translate('execute_init_event_failed') +
                        this.translateSys("full_stop") +
                        this.translate('reason') + this.translateSys("colon") +
                        success
                        .err_msg,
                     this.translate('reason') + this.translateSys("colon") + tip,
                     showCancel: false,
                     confirmText: this.translateSys("cancel")
                  });
               }
            }).catch(ex => {
               // console.log(ex);
               uni.showModal({
                  title: this.translateSys("error") + "3.1",
                  content: this.translate('execute_init_event_failed') +
                     this.translateSys("full_stop") +
                     this.translate('reason') + this.translateSys("colon") + ex
                     .errMsg,
                  showCancel: false,
                  confirmText: this.translateSys("cancel")
               });
            });
         },
@@ -1013,71 +779,6 @@
               item.value = value;
               var attr = item.fieldId;
               $this.head_styledef.form.model[attr] = value;
               /*if (item.value) { //第一个输入框不为空
                  //初始化,下个输入框focus属性
                  var findd = false
                  const items = $this.head_styledef.form.items || []
                  for (let i in items) {
                     const ele = items[i]
                     if (ele.name != "Layout") {
                        if (ele.name == 'Input' || ele.name == 'InputNumber' || ele.name ==
                           'Textarea') {
                           if (attr == ele.fieldId) {
                              findd = true
                           } else {
                              if (findd) {
                                 $this.setData({
                                    focusFieldId: ele.fieldId
                                 })
                                 break
                              }
                           }
                        }
                     } else {
                        if (findd) {
                           let curIndex = ele.setting.colList.findIndex((col, index2, arr) => {
                              return (col.name == 'Input' || col.name == 'InputNumber' ||
                                 col.name ==
                                 'Textarea');
                           })
                           if (curIndex > -1) {
                              $this.setData({
                                 focusFieldId: ele.setting.colList[curIndex]
                                    .fieldId
                              })
                              break
                           }
                        } else {
                           let curIndex = ele.setting.colList.findIndex((col, index2, arr) => {
                              return attr == col.fieldId;
                           })
                           if (curIndex > -1) {
                              findd = true
                              let curIndex2 = ele.setting.colList.findIndex((col, index2,
                                 arr) => {
                                 return (col.name == 'Input' || col.name ==
                                       'InputNumber' || col.name == 'Textarea') &&
                                    index2 >
                                    curIndex;
                              })
                              if (curIndex2 > -1) {
                                 $this.setData({
                                    focusFieldId: ele.setting.colList[curIndex]
                                       .fieldId
                                 })
                                 break
                              }
                           }
                        }
                     }
                  }
               }
               */
               var eventid = item.bind.onChangeEvent.id; //内容变化后事件
               if (eventid) {
                  var obj_attr = this.head_styledef.form.model;
@@ -1277,7 +978,7 @@
            this.$refs.popup.close();
         },
         DataObjRunCustomEvent(info, data_attr) {
         async DataObjRunCustomEvent(info, data_attr) {
            var $this = this;
            var enviroment = {
               'function': '3000', // 功能点编号
@@ -1344,10 +1045,7 @@
            };
            console.log(dataInfo);
            // return;
            this.$store.dispatch('runCustomEvent', dataInfo).then(success => {
               console.log(success);
               if (success.err_code == 0) {
                  var data = success.result;
            runCustomEvent(dataInfo).then(data => {
                  if (data.ret != 0) {
                     var tip = data.err_info ? typeof data.err_info == 'string' ? data
                        .err_info :
@@ -1626,19 +1324,16 @@
                        }
                     }
                  }
               } else {
                  uni.showModal({
                     title: this.translateSys("error") + "3",
                     content: success.err_msg,
                     showCancel: false,
                     confirmText: this.translateSys("cancel")
                  });
               }
            }).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: ex.errMsg,
                  content: exStr,
                  showCancel: false,
                  confirmText: this.translateSys("cancel")
               });
@@ -1679,11 +1374,6 @@
               type: 'small', //小窗口
               class_id: this.$data.param.DataCls.id, //当前数据类id
            }
            // var dataInfo = {
            //    edtype:  "0", eventid: eventid, projectid: '',rclsid: '', robjid: '', userlogin: '',
            //    clsid: this.$data.param.DataCls.id, objid: '',attr: JSON.stringify(req),
            //    extinfo: JSON.stringify(extinfo), global_attr: JSON.stringify(this.$data.global_attr)
            // }
            extinfo = Base64.encode(JSON.stringify(extinfo)); //将字符串转换为base64编码
            var global_attr = Base64.encode(JSON.stringify(this.$data.global_attr)); //将字符串转换为base64编码
            var obj_attr = {};
@@ -1712,10 +1402,7 @@
            };
            console.log(dataInfo);
            // return;
            this.$store.dispatch('runCustomEvent', dataInfo).then(success => {
               console.log(success);
               if (success.err_code == 0) {
                  var data = success.result;
            runCustomEvent(dataInfo).then(data => {
                  if (data.ret != 0) {
                     var tip = data.err_info ? typeof data.err_info == 'string' ? data
                        .err_info :
@@ -1941,19 +1628,16 @@
                        });
                     }
                  }
               } else {
                  uni.showModal({
                     title: this.translateSys("error") + "5",
                     content: success.err_msg,
                     showCancel: false,
                     confirmText: this.translateSys("cancel")
                  });
               }
            }).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: ex.errMsg,
                  content: exStr,
                  showCancel: false,
                  confirmText: this.translateSys("cancel")
               });
@@ -2015,14 +1699,10 @@
            };
            console.log(dataInfo);
            // return
            this.$store.dispatch('createDataObj', dataInfo).then(success => {
               console.log(success);
            dataObjCreate(dataInfo).then(result => {
               uni.hideLoading();
               if (success.err_code == 0) {
                  var result = success.result;
                  // if(result.result_type == 0){}
                  if (success.result.action) {
                     var action = JSON.parse(success.result.action);
               if (result.action) {
                  var action = JSON.parse(result.action);
                     console.log(action);
                     if (action.ret == '0') {
                        if (action.ret != 0) {
@@ -2078,14 +1758,7 @@
                  }
                  // this.class_attr_init();
               } else {
                  uni.showModal({
                     title: this.translateSys("error"),
                     content: success.err_msg,
                     showCancel: false,
                     confirmText: this.translateSys("cancel")
                  });
               }
               this.saving = false
            }).catch(ex => {
               console.log(ex);
@@ -2130,10 +1803,8 @@
            };
            console.log(dataInfo);
            // return;
            this.$store.dispatch('runCustomEvent', dataInfo).then(success => {
               console.log(success);
               if (success.err_code == 0) {
                  var data = success.result;
            runCustomEvent(dataInfo).then(data => {
                  if (data.ret != 0) {
                     var tip = data.err_info ? typeof data.err_info == 'string' ? data
                        .err_info :
@@ -2174,14 +1845,7 @@
                     var result = data.result;
                  }
               } else {
                  uni.showModal({
                     title: this.translateSys("error") + "7",
                     content: success.err_msg,
                     showCancel: false,
                     confirmText: this.translateSys("cancel")
                  });
               }
               this.saving = false
            }).catch(ex => {
               // console.log(ex);
@@ -2267,10 +1931,7 @@
            };
            console.log(dataInfo);
            // return;
            this.$store.dispatch('runCustomEvent', dataInfo).then(success => {
               console.log(success);
               if (success.err_code == 0) {
                  var data = success.result;
            runCustomEvent(dataInfo).then(data => {
                  if (data.ret != 0) {
                     var tip = data.err_info ? typeof data.err_info == 'string' ? data
                        .err_info :
@@ -2310,14 +1971,7 @@
                     var result = data.result;
                  }
               } else {
                  uni.showModal({
                     title: this.translateSys("error") + "7",
                     content: success.err_msg,
                     showCancel: false,
                     confirmText: this.translateSys("cancel")
                  });
               }
            }).catch(ex => {
               // console.log(ex);
               uni.showModal({