jt
2024-05-31 d0eedc364ccf9f7d0a43036d6b034f49180708a0
pages/modal/3018_2.vue
@@ -74,12 +74,12 @@
    font-weight: 400;
    font-style: normal;
    /* width: 48rpx; */
    height: 48rpx;
    line-height: 48rpx;
    /* height: 48rpx; */
    /* line-height: 44rpx; */
   color: #2d8cf0;
    cursor: pointer;
    display: inline-block;
   vertical-align: 18rpx;
   vertical-align: middle;
}
@@ -350,7 +350,7 @@
      <!-- 表头样式 -->
      <view class="v-headStyle" v-for="(item,index) in head_styledef.form.items" >
        <!-- 普通布局 -->
        <view v-if="item.name!='Layout'">
        <view v-if="item.name!='Layout' && item.show==true">
         <text class="txt_title" :style="{'width':item.labelWidth+'px'}">{{item.label}}:</text>
         <span class="form-item-span" v-if="item.disabled"
           :style="'width: calc(100% - '+item.labelWidth+'px);'">{{item.value}}</span>
@@ -434,13 +434,13 @@
         </view>
        </view>
        <!-- 栅格布局 -->
        <uni-row class="demo-uni-row" v-if="item.name=='Layout'">
        <uni-row class="demo-uni-row" v-if="item.name=='Layout' && item.show==true">
            <uni-col v-for="(cols,key) in item.setting.colList" 
               :span="item.setting.spanList?item.setting.spanList[key]:24 / item.setting.col">
               <view v-if="cols!=null" >
                  <text class="txt_title" :style="{'width':cols.labelWidth+'px'}">{{cols.label}}:</text>
                  <span class="form-item-span" v-if="cols.disabled">{{cols.value}}</span>
                  <view class="dv_input" v-if="(cols.name=='Input' || cols.name=='InputNumber') && !cols.disabled">
                  <view class="input-wrapper" v-if="(cols.name=='Input' || cols.name=='InputNumber') && !cols.disabled">
                     <text v-if="cols.setting.prefix" 
                        class="uni-icon" 
                        :class="[cols.setting.prefix]"
@@ -511,7 +511,7 @@
               
               </view>
            </uni-col>
         </uni-row>
        </uni-row>
        
        
      </view>
@@ -610,10 +610,18 @@
            $this.$data.head_styledef = ret.result.style_def? JSON.parse(styledef): {};
            // console.log($this.$data.head_styledef);
            $this.head_styledef.form.items.forEach(async (ele,index) => {
               ele.show=true;
                if(ele.useDict==true){ //判断useDict是否使用字典
                    await this.DictGetInfo(ele.bind.dict,index,'mast');
                }
            });
            if($this.head_styledef.event?.length>0){
              $this.head_styledef.event.forEach(async (a)=>{  //判断是否是初始化事件
                if(a.event_id == "initial"){
                  await this.loadInitEvent(a.scrip_id);
                }
              });
            }
            
         }else{
            uni.showModal({title:"错误1",content:ret.err_msg,showCancel:false,confirmText:"取消"});
@@ -668,9 +676,166 @@
         uni.showModal({title:"错误1.3",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   async loadInitEvent(eventid){
      var $this = this;
      if(!eventid.includes('{')) eventid = '{'+eventid+'}';
      var dataInfo={
          ed_type: 0,
          start_transaction: true,
          class_id: this.param.DataCls.id,
          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;
            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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                else uni.showModal({title:'提示',content:tip+',提示:'+data.ret,showCancel:false,confirmText:"取消"});
               return false
            }else{
               var tip = data.info ? typeof data.info == 'string' ? data.info : data.info.join('<br/>') : '';
               if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
               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;
                        for (var i = 0; i < result.length; i++) {
                           if (result[i].choice_list) {
                              for (var c = 0; c < $this.head_styledef.form.items.length; c++) {
                                 var attr = $this.head_styledef.form.items[c];
                                 if(attr.name!='Layout'){
                                   if(attr.fieldId==result[i].attr){
                                      var dictItemList=[];
                                      for(var d in result[i].choice_list){
                                         var val =result[i].choice_list[d];
                                         dictItemList.push({"CN_S_NAME":val,"CN_S_VALUE":val,"text":val,"value":val});
                                      }
                                      attr.dict = dictItemList;
                                   }
                                 } else if(attr.name=='Layout'){
                                   attr.setting.colList.forEach(col=>{
                                     if(col){
                                       if(col.fieldId==result[i].attr){
                                          var dictItemList=[];
                                          for(var d in result[i].choice_list){
                                             var val =result[i].choice_list[d];
                                             dictItemList.push({"CN_S_NAME":val,"CN_S_VALUE":val,"text":val,"value":val});
                                          }
                                          col.dict = dictItemList;
                                       }
                                     }
                                   });
                                 }
                              }
                           }
                           for (var c = 0; c < $this.$data.head_styledef.form.items.length; c++) {
                              var attr = $this.$data.head_styledef.form.items[c];
                              // console.log(attr[j].Name+'=='+result[i].attr);
                              //判断表单里是否有返回字段,没有就装载到model里,点击确定提交的时候带上这些数据
                              if($this.head_styledef.form.model[result[i].attr]==undefined){
                                   $this.head_styledef.form.model[result[i].attr]=result[i].value;
                              }
                              //判断是否是栅格表单
                              if(attr.name!='Layout'){
                                if(attr.fieldId==result[i].attr){
                                   attr.value = '';
                                   attr.oldvalue = '';
                                   attr.value = result[i].value;
                                   attr.oldvalue = result[i].value;
                                   $this.head_styledef.form.model[attr.fieldId] =result[i].value;
                                }
                              } else if(attr.name=='Layout'){
                                attr.setting.colList.forEach(col=>{
                                  if(col){
                                    if(col.fieldId==result[i].attr){
                                       col.value = '';
                                       col.oldvalue = '';
                                       col.value = result[i].value;
                                       col.oldvalue = result[i].value;
                                       $this.head_styledef.form.model[col.fieldId] =result[i].value;
                                    }
                                  }
                                });
                              }
                           }
                           var length = 0;
                           if (!$this.$data.refdatastore.filter(function (s) {
                              return result[i].attr == s.attr
                           }).length) {
                              length = 1;
                              $this.$data.refdatastore.push(result[i]);
                           }
                           if (length == 0) {
                              for (var j = 0; j < $this.$data.refdatastore.length; j++) {
                                 if ($this.$data.refdatastore[j].attr == result[i].attr) {
                                    $this.$data.refdatastore[j].value = result[i].value;
                                 }
                              }
                           }
                        }
                     } else if (data.action[i].action_type == 'set_dlg_attr_show') {
                        var result = action.value;
                        result.forEach(async (attr,key) => {
                          $this.$data.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.$data.head_styledef =[];
                        $this.$data.head_styledef = head_styledef;
                        // console.log($this.$data.head_styledef);
                     } else {
                        uni.showModal({title:"提示",content:"执行初始化事件失败:"+item.action_type + '此action尚未处理!',showCancel:false,confirmText:"取消"});
                     }
                  }
               }
            }
         }else{
            uni.showModal({title:"错误3",content:"执行初始化事件失败:"+success.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误3.1",content:"执行初始化事件失败:"+ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   
   ontap(item){ //扫码功能
      //console.log(e.target)
      // uni.scanCode({
      //   //成功回调
      //   success: function (res) {
      //    //条码类型
      //    console.log(res.scanType);
      //    //条码的值
      //    console.log(res.result);
      //   },//失败回调
      //   fail: function (res) {},
      //   //完成回调
      //   complete: function (res) {},
      // })
      getApp().onScan((result)=>{
         //console.log(result.decodedata);
         uni.hideKeyboard();
@@ -687,7 +852,7 @@
               //    $this.focusMateria=true; //第二个输入框获取焦点
                  setTimeout(function(){
                     uni.hideKeyboard();
                  },100);
                  },1000);
               // },500);
            }
            var eventid = item.bind.onChangeEvent.id;   //内容变化后事件
@@ -722,6 +887,7 @@
      console.log(item);
      if(item.oldvalue != item.value){
          item.oldvalue = item.value;
         item.value = item.value;
         var attr = item.fieldId;
         $this.head_styledef.form.model[attr] = item.value;
         //子数据类扫码区事件脚本
@@ -745,7 +911,7 @@
                attr: req,
               dataJson:[],
             }
             this.DataObjRunCustomEvent(info, data_attr);
             this.DataObjRunCustomEvent(info, "");
          }
      }
      
@@ -786,6 +952,8 @@
   onModelValue(item) { //绑定Model值
      var attr = item.fieldId;
      this.head_styledef.form.model[attr] = item.value;
   },
   classAttr_extButton(item){
      var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent;   //后图标点击事件
      var onSuffixClickEvent = item.bind.onSuffixClickEvent;   //后图标点击回调
      
@@ -959,24 +1127,61 @@
                           if (result[i].choice_list) {
                              for (var c = 0; c < $this.head_styledef.form.items.length; c++) {
                                 var attr = $this.head_styledef.form.items[c];
                                 if(attr.fieldId==result[i].attr){
                                    var dictItemList=[];
                                    for(var d in result[i].choice_list){
                                       var val =result[i].choice_list[d];
                                       dictItemList.push({"CN_S_NAME":val,"CN_S_VALUE":val,"text":val,"value":val});
                                    }
                                    attr.dict = dictItemList;
                                 if(attr.name!='Layout'){
                                   if(attr.fieldId==result[i].attr){
                                      var dictItemList=[];
                                      for(var d in result[i].choice_list){
                                         var val =result[i].choice_list[d];
                                         dictItemList.push({"CN_S_NAME":val,"CN_S_VALUE":val,"text":val,"value":val});
                                      }
                                      attr.dict = dictItemList;
                                   }
                                 } else if(attr.name=='Layout'){
                                   attr.setting.colList.forEach(col=>{
                                     if(col){
                                       if(col.fieldId==result[i].attr){
                                          var dictItemList=[];
                                          for(var d in result[i].choice_list){
                                             var val =result[i].choice_list[d];
                                             dictItemList.push({"CN_S_NAME":val,"CN_S_VALUE":val,"text":val,"value":val});
                                          }
                                          col.dict = dictItemList;
                                       }
                                     }
                                   });
                                 }
                              }
                           }
                           for (var c = 0; c < $this.$data.head_styledef.form.items.length; c++) {
                              var attr = $this.$data.head_styledef.form.items[c];
                              // console.log(attr[j].Name+'=='+result[i].attr);
                              if(attr.fieldId==result[i].attr){
                                 attr.value = result[i].value;
                                 $this.head_styledef.form.model[attr.fieldId] =result[i].value;
                              //判断表单里是否有返回字段,没有就装载到model里,点击确定提交的时候带上这些数据
                              if($this.head_styledef.form.model[result[i].attr]==undefined){
                                   $this.head_styledef.form.model[result[i].attr]=result[i].value;
                              }
                              //判断是否是栅格表单
                              if(attr.name!='Layout'){
                                if(attr.fieldId==result[i].attr){
                                   attr.value = '';
                                   attr.oldvalue = '';
                                   attr.value = result[i].value;
                                   attr.oldvalue = result[i].value;
                                   $this.head_styledef.form.model[attr.fieldId] =result[i].value;
                                }
                              } else if(attr.name=='Layout'){
                                attr.setting.colList.forEach(col=>{
                                  if(col){
                                    if(col.fieldId==result[i].attr){
                                       col.value = '';
                                       col.oldvalue = '';
                                       col.value = result[i].value;
                                       col.oldvalue = result[i].value;
                                       $this.head_styledef.form.model[col.fieldId] =result[i].value;
                                    }
                                  }
                                });
                              }
                           }
                           var length = 0;
                           if (!$this.$data.refdatastore.filter(function (s) {
@@ -993,20 +1198,72 @@
                              }
                           }
                        }
                     } else if (data.action[i].action_type == 'set_global_attr') {
                        $this.$data.global_attr = data.action[i].value || [];
                     }
                     } else if (action.action_type == 'set_dlg_attr_show') {
                        var result = action.value;
                        result.forEach(async (attr,key) => {
                          $this.$data.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.$data.head_styledef =[];
                        $this.$data.head_styledef = head_styledef;
                        // console.log($this.$data.head_styledef);
                     } else if (action.action_type == 'set_global_attr') {
                        $this.$data.global_attr = action.value || [];
                     } else {
                        uni.showModal({title:"提示",content:action.action_type + '此action尚未处理!',showCancel:false,confirmText:"取消"});
                     }
                  }
               }
               // var head_styledef = JSON.parse(JSON.stringify($this.head_styledef));
               // $this.head_styledef=[];
               // $this.head_styledef = head_styledef;
               console.log($this.head_styledef);
               
               if (data.result) {
                  var result = data.result;
                  for (var i = 0; i < result.length; i++) {
                     for (var c = 0; c < $this.$data.head_styledef.form.items.length; c++) {
                        var attr = $this.$data.head_styledef.form.items[c];
                        if(attr.fieldId==result[i].attr){
                           attr.value = result[i].value;
                           $this.head_styledef.form.model[attr.fieldId] =result[i].value;
                        //判断表单里是否有返回字段,没有就装载到model里,点击确定提交的时候带上这些数据
                        if($this.head_styledef.form.model[result[i].attr]==undefined){
                             $this.head_styledef.form.model[result[i].attr]=result[i].value;
                        }
                        //判断是否是栅格表单
                        if(attr.name!='Layout'){
                          if(attr.fieldId==result[i].attr){
                             attr.value = '';
                             attr.oldvalue = '';
                             attr.value = result[i].value;
                             attr.oldvalue = result[i].value;
                             $this.head_styledef.form.model[attr.fieldId] =result[i].value;
                          }
                        } else if(attr.name=='Layout'){
                          attr.setting.colList.forEach(col=>{
                            if(col){
                              if(col.fieldId==result[i].attr){
                                 col.value = '';
                                 col.oldvalue = '';
                                 col.value = result[i].value;
                                 col.oldvalue = result[i].value;
                                 $this.head_styledef.form.model[col.fieldId] =result[i].value;
                              }
                            }
                          });
                        }
                     }
                     
@@ -1242,13 +1499,10 @@
                              }
                           }
                        });
                     } else {
                        var d = dialog({
                           title: '<i class="ace-icon fa fa-info-circle"></i> ' + '提示',
                           content: action.action_type + '此action尚未处理!'
                        });
                        d.show();
                     }
                     }
                     else {
                        uni.showModal({title:"提示",content:action.action_type + '此action尚未处理!',showCancel:false,confirmText:"取消"});
                     }
                  }
               }
               }else{