cuiqian2004
2024-06-27 81162e054b22d912acef0452841be8185c810ba2
pages/modal/3200.vue
@@ -1,3 +1,1384 @@
<template>
   <view class="content">
     <view class="v-content">
      <!-- 表头样式 -->
      <view class="v-headStyle" v-for="(item,index) in head_styledef.form.items" v-if="isFilter==true">
         <text class="txt_title" :style="{'width':item.labelWidth+'px'}">{{item.label}}:</text>
         <!-- 下拉框-单选 item.useDict?item.dict:item.selections-->
         <uni-data-select id="dv_select" v-if="item.name=='Select'"
            :class="item.disabled?'input-disabled':''"
            v-model="item.value"
            :localdata="item.dict"
            @change="onChange(item)"
            :disabled="item.disabled"
            :clear="false"
         ></uni-data-select>
         <view class="input-wrapper" v-if="item.name=='Input' || item.name=='InputNumber'">
            <text v-if="item.setting.prefix"
               class="uni-icon"
               :class="[item.setting.prefix]"
               @click="onEnterChange(item)">&#xe568;</text>
            <input class="uni-input"
               :class="item.disabled?'input-disabled':''"
               :type="item.name=='Input'?'text':'number'"
               v-model="item.value"
               :disabled="item.disabled"
               :placeholder="item.placeholder"
               :style="{'width':item.setting.prefix && item.setting.suffix?'78%':item.setting.prefix || item.setting.suffix?'87%':'96%'}"
               :focus="focusMateria"
               @focus="ontap(item)"
               @keyup.enter="onEnterChange(item)"
               @blur="onEnterChange(item)"
            />
            <text v-if="item.setting.suffix"
               class="uni-icon"
               :class="[item.setting.suffix]"
               @click="onEnterChange(item)">&#xe568;</text>
          </view>
      </view>
      <scroll-view :scroll-top="scrollTop" :scroll-y="true" class="scroll-Y"
        @scrolltolower="scrolltolower" @scroll="scroll">
         <view class="view-content" id="tabpanel">
           <view class="dv-panel dv-panel-bkcolor" v-for="(style,ii) in detail1StyleDefList"
            @click="onPanelClick(ii)"
            :id="'panel'+style.form.htmlobjId"
            :class="activelist[ii].active==true?'bk-active':''">
            <div class="dv-panel-button" v-if="param.ListPage.CheckBox==true">
              <checkbox-group>
               <label>
                  <checkbox :value="style.SelBut_Checked" :checked="style.SelBut_Checked" />
               </label>
              </checkbox-group>
            </div>
            <!-- HTML页面类型显示 -->
            <div class="dv-listHtml-Panel" v-if="ListHtml_Panel" v-html="ListHtml_Panel[ii]"
              :style="param.ListPage.CheckBox==true && param.ListPage.Click_View==true?'width:85%;':
              param.ListPage.CheckBox==false && param.ListPage.Click_View==true?'width:91%;':
              param.ListPage.CheckBox==true && param.ListPage.Click_View==false?'width:88%;':'width:100%;'">
               <!-- <div class="dv_panel_content">
                  <div class="dv_panel_attr">
                    <label>No:</label>
                    <span>TA240129-00001</span>
                  </div>
                  <div class="dv_panel_attr">
                    <div class="dv_box_node">
                     <p><span>毛料线边</span></p>
                     <label>L002-1</label>
                    </div>
                    <i class="mobox-normal-right"></i>
                    <div class="dv_box_node">
                     <p><span>毛料线边</span></p>
                     <label>L003-3</label>
                    </div>
                  </div>
               </div> -->
            </div>
            <!-- 自定义表单类型显示 -->
            <div class="dv-panel-input" v-if="!ListHtml_Panel"
              :style="param.ListPage.CheckBox==true && param.ListPage.Click_View==true?'width:85%;':
              param.ListPage.CheckBox==false && param.ListPage.Click_View==true?'width:91%;':
              param.ListPage.CheckBox==true && param.ListPage.Click_View==false?'width:88%;':'width:100%;'">
              <div v-for="(item,index) in style.form.items">
               <!-- 普通布局 -->
               <view v-if="item.name!='Layout'">
                  <text class="txt_title" :style="{'width':item.labelWidth+'px'}">{{item.label}}:</text>
                  <span class="form-item-span" v-if="item.disabled">{{item.value}}</span>
                  <!-- 文本框/数字框 -->
                  <view class="dv_input" v-if="(item.name=='Input' || item.name=='InputNumber') && !item.disabled">
                     <text v-if="item.setting.prefix"
                        class="uni-icon"
                        :class="[item.setting.prefix]"
                        @change="onChange(item)">&#xe568;</text>
                     <input class="uni-input" :class="item.disabled?'input-disabled':''"
                        :type="item.name=='Input'?'text':item.name=='InputNumber'?'number':'text'"
                        v-model="item.value"
                        :disabled="item.disabled"
                        :placeholder="item.placeholder"
                        :style="{'width':item.setting.prefix && item.setting.suffix?'78%':item.setting.prefix || item.setting.suffix?'87%':'96%'}"
                        :focus="focusMateria"
                        @focus="ontap(item)"
                        @blur="onevent(item)"
                     />
                     <text v-if="item.setting.suffix"
                        class="uni-icon"
                        :class="[item.setting.suffix]"
                        @click="onChange(item)">&#xe568;</text>
                  </view>
                  <!-- 下拉框-单选 item.useDict?item.dict:item.selections-->
                  <uni-data-select id="dv_select" v-if="item.name=='Select' && !item.disabled"
                     :class="item.disabled?'input-disabled':''"
                     v-model="item.value"
                     :localdata="item.dict"
                     @change="onChange(item)"
                     :disabled="item.disabled"
                     :clear="false"
                  ></uni-data-select>
                  <!-- 多行文本 -->
                  <view class="input-wrapper" v-if="item.name=='Textarea' && !item.disabled">
                     <textarea class="uni-input" :value="item.value"
                       :class="item.disabled?'input-disabled':''"
                       :placeholder="item.placeholder"
                       @blur="onModelValue(item)"
                       style="height:60px;"
                       :style="{'width':'96%'}"
                       :disabled="item.disabled"
                     ></textarea>
                  </view>
                  <!-- 复选框 -->
                  <checkbox-group class="check_rememberPwd" v-if="item.name=='Checkbox'"
                     :class="item.disabled?'input-disabled':''"
                     @change="onModelValue(item)"
                     :data-ischeck="item.value"
                     :disabled="item.disabled"
                     :style="{'margin-left':'10rpx'}">
                     <label>
                        <checkbox :value="item.value" :checked="item.value"/>
                        <text>{{item.label}}</text>
                     </label>
                  </checkbox-group>
                  <!-- Switch开关 -->
                  <switch v-if="item.name=='Switch'" :class="item.disabled?'input-disabled':''"
                     :disabled="item.disabled"
                     v-model="item.value"
                     @change="onModelValue(item)"
                     :style="{'margin-left':'10rpx'}"/>
                  <!-- 日期时间 -->
                  <view class="input-wrapper" v-if="(item.name=='TimePicker' || item.name=='DatePicker') && !item.disabled">
                     <picker mode="date" class="date_iput" :class="item.disabled?'input-disabled':''"
                       :disabled="item.disabled"
                       :value="item.value"
                       @change="onModelValue(item)"
                     >
                        <view class="picker">{{item.value}}</view>
                     </picker>
                  </view>
               </view>
               <!-- 栅格布局 -->
               <uni-row class="demo-uni-row" v-if="item.name=='Layout'">
                  <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">
                           <text v-if="cols.setting.prefix"
                              class="uni-icon"
                              :class="[cols.setting.prefix]"
                              @change="onChange(cols)">&#xe568;</text>
                           <input class="uni-input" :class="cols.disabled?'input-disabled':''"
                              :type="cols.name=='Input'?'text':cols.name=='InputNumber'?'number':'text'"
                              v-model="cols.value"
                              :disabled="cols.disabled"
                              :placeholder="cols.placeholder"
                              :style="{'width':cols.setting.prefix && cols.setting.suffix?'78%':cols.setting.prefix || cols.setting.suffix?'87%':'96%'}"
                              :focus="focusMateria"
                              @focus="ontap(cols)"
                              @blur="onevent(cols)"
                           />
                           <text v-if="cols.setting.suffix"
                              class="uni-icon"
                              :class="[cols.setting.suffix]"
                              @click="onChange(cols)">&#xe568;</text>
                        </view>
                        <!-- 下拉框-单选 cols.useDict?cols.dict:cols.selections-->
                        <uni-data-select id="dv_select" v-if="cols.name=='Select' && !cols.disabled"
                           :class="cols.disabled?'input-disabled':''"
                           v-model="cols.value"
                           :localdata="cols.dict"
                           @change="onChange(cols)"
                           :disabled="cols.disabled"
                           :clear="false"
                        ></uni-data-select>
                        <!-- 多行文本 -->
                        <view class="input-wrapper" v-if="cols.name=='Textarea' && !cols.disabled">
                           <textarea class="uni-input" :value="cols.value"
                             :class="cols.disabled?'input-disabled':''"
                             :placeholder="cols.placeholder"
                             @blur="onModelValue(cols)"
                             style="height:60px;"
                             :style="{'width':'96%'}"
                             :disabled="cols.disabled"
                           ></textarea>
                        </view>
                        <!-- 复选框 -->
                        <checkbox-group class="check_rememberPwd" v-if="cols.name=='Checkbox'"
                           :class="cols.disabled?'input-disabled':''"
                           :disabled="item.disabled"
                           @change="onModelValue(cols)"
                           :data-ischeck="cols.value"
                           :style="{'margin-left':'10rpx'}">
                           <label>
                              <checkbox :value="cols.value" :checked="cols.value"/>
                              <text>{{cols.label}}</text>
                           </label>
                        </checkbox-group>
                        <!-- Switch开关 -->
                        <switch v-if="cols.name=='Switch'" :class="cols.disabled?'input-disabled':''"
                           :disabled="item.disabled"
                           v-model="cols.value"
                           @change="onModelValue(cols)"
                           :style="{'margin-left':'10rpx'}"/>
                        <!-- 日期时间 -->
                        <view class="input-wrapper" v-if="(cols.name=='TimePicker' || cols.name=='DatePicker') && !cols.disabled">
                           <picker mode="date" class="date_iput" :class="cols.disabled?'input-disabled':''"
                             :disabled="item.disabled"
                             :value="cols.value"
                             @change="onModelValue(cols)"
                           >
                              <view class="picker">{{cols.value}}</view>
                           </picker>
                        </view>
                     </view>
                  </uni-col>
               </uni-row>
               </div>
            </div>
            <div class="dv-panel-button" v-if="param.ListPage.Click_View==true" >
              <a @click="onViewPageClick(style)"><i class="mobox-normal-right-arrow" /></a>
            </div>
            <div class="dv-panel-buticon" v-if="param.ListPage.ListItem_Button" >
              <view class="btn-padding" v-for="(btn,key) in param.ListPage.ListItem_Button">
               <a @click="onBtnClick(btn,style)" :title="btn.ShowName" v-if="btn.Style=='img'">
                  <i :class="btn.Img" />
               </a>
               <button type="default" @click="onBtnClick(btn,style)" class="btn-padding" v-else-if="btn.Style=='text'">{{btn.ShowName}}</button>
              </view>
            </div>
           </view>
         </view>
      </scroll-view>
     </view>
     <view class="view-floor">
        <button type="default" @click="cancel" class="btn_cancel"
        :style="{'width':param.ListPage.Page_Button.length>0?'39.5%':'48.5%'}">关闭</button>
        <button type="default" @click="Refresh" class="btn_refresh"
        :style="{'width':param.ListPage.Page_Button.length>0?'39.5%':'48.5%'}">刷新</button>
      <view class="uni-padding-wrap" v-if="param.ListPage.Page_Button.length>0">
         <view class="uni-btn-v">
            <a @tap="actionSheetTap"><Icon class="mobox-normal-more"/></a>
         </view>
      </view>
     </view>
    </view>
</template>
<script>
import Base64 from '../../components/js-base64/base64.js'
import classUtils from "@/js/utils.js"
export default {
  modules:{
   Base64,
  },
  onNavigationBarButtonTap(e) {
 //     console.log(e);
   // e.text="\ue924";
     // console.log(e.fontSize);
   if(this.isFilter)
       this.isFilter=false;
   else
       this.isFilter=true;
  },
  onBackPress(e){
   // console.log("监听返回按钮事件",e);
   var eventChannel = this.$scope.eventChannel;
   // const eventChannel = this.getOpenerEventChannel();
   eventChannel.emit('view_3201',"");
   // uni.navigateBack({
   //    delta:1 ,//返回层数,2则上上页
   // });
   // return true;
  },
  data() {
    return {
     title:'新增',
      isFilter:true,
      param: {},
     focusMateria:false,
     styledef:{},
     head_styledef:{
      form:{
         items:[]
      }
     },
      detail1_styledef:{},
      detail1StyleDefList:[],
      detail2_styledef:{},
      detail2StyleDefList:[],
     items: [],
      active_id:'',
     activelist:[],
      where:'',
      wheres:'',
      orderby:'',
      query_id:'',
      pageindex:1,
      page_size:10,
      page_count:0,
     scrollTop: 0,
     old: {
        scrollTop: 0
     },
     isScroll:true,
     //获取数据类的HTML页面
     ListHtml_Panel:"",
     ListPageHtml_Show: {
        name: "",
        event: {
           id: "",
           name: ""
        }
     },
    };
  },
  async onLoad(options) {
   // console.log(options);
   uni.setNavigationBarTitle({ title: options.titlename}); //设置顶部标题
   this.$data.title = options.titlename;
   this.$data.param = JSON.parse(options.param);
   this.initial();
   // this.isFilter=true;
   // if(this.param.ShowFilter)
   //   this.isFilter=false;
   // //获取数据类的自定义表单参数
   // if(this.param.Query_Panel){
   //    this.Head_UIStyleGetInfo(this.param.DataCls.id,this.param.Query_Panel.id);
   // }
   // if(this.param.ListPage.ListItem_UIDef?.ui_type=="HTML页面"){
   //    // HTML页面
   //    //获取数据类的HTML页面
   //    await this.Html_UIstyleGetInfo(this.param.DataCls.id,this.param.ListPage.ListItem_UIDef.id);
   // }else{
   //    await this.Detail1_UIstyleGetInfo(this.param.DataCls.id,this.param.ListPage.ListItem_UIDef.id);
   // }
   // this.orderby = this.param.Order?this.param.Order:'T_CREATE Desc';
   // if(this.param.Query_Event){
   //     await this.onSearChange(this.param.DataCls.id,this.param.Query_Event.id);
   // } else{
   //   this.wheres = this.param.Condition;
   //   this.pageindex = 1;
   //   this.page_size = 3;
   //   this.query_id = "";
   //   await this.loadDataGetList();
   // }
   // console.log(this.$data.param);
   //页面初始化获取焦点
   // this.focusMateria=true;
  },
  methods: {
   //初始化
   async initial(){
      this.styledef={};
      this.head_styledef={
            form:{
               items:[]
            }
      };
      this.detail1_styledef={};
      this.detail1StyleDefList=[];
      this.detail2_styledef={};
      this.detail2StyleDefList=[];
      this.items=[];
      this.active_id='';
      this.activelist=[];
      this.ListHtml_Panel="";
      this.ListPageHtml_Show= {
         name: "",
         event: {
            id: "",
            name: ""
         }
      };
      this.isFilter=true;
      if(this.param.ShowFilter)
        this.isFilter=false;
      //获取数据类的自定义表单参数
      if(this.param.Query_Panel){
         this.Head_UIStyleGetInfo(this.param.DataCls.id,this.param.Query_Panel.id);
      }
      if(this.param.ListPage.ListItem_UIDef?.ui_type=="HTML页面"){
         // HTML页面
         //获取数据类的HTML页面
         await this.Html_UIstyleGetInfo(this.param.DataCls.id,this.param.ListPage.ListItem_UIDef.id);
      }else{
         await this.Detail1_UIstyleGetInfo(this.param.DataCls.id,this.param.ListPage.ListItem_UIDef.id);
      }
      this.orderby = this.param.Order?this.param.Order:'T_CREATE Desc';
      if(this.param.Query_Event){
          await this.onSearChange(this.param.DataCls.id,this.param.Query_Event.id);
      } else{
        this.wheres = this.param.Condition;
        this.pageindex = 1;
        this.page_size = 3;
        this.query_id = "";
        await this.loadDataGetList();
      }
   },
   //滚动到底部后懒加载数据
   async scrolltolower(e) {
      // console.log(e)
      if(this.isScroll){ //判断刷新一次后不会持续刷新
         if(this.page_count==this.pageindex){
            return;
         }
         this.pageindex += 1;
         if(this.where || this.page_count==1) {
           this.query_id = "";
           this.detail1StyleDefList=[];
         }
         await this.loadDataGetList();
      }
   },
   scroll: function(e) {
      // console.log(e.detail.scrollTop)
      this.old.scrollTop = e.detail.scrollTop
   },
   async Head_UIStyleGetInfo(class_id,style_id){   //获取自定义表单样式
      var $this = this;
      var dataInfo={
         class_id:class_id,
         ui_style_id:style_id,
      };
      // console.log(dataInfo);
      this.$store.dispatch('UIStyleGetInfo',dataInfo).then(ret=>{
         // console.log(ret);
         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);
            }
            $this.$data.head_styledef = ret.result.style_def? JSON.parse(styledef): {};
            // this.form = this.head_styledef.form.model;
            // console.log($this.$data.head_styledef);
            $this.head_styledef.form.items.forEach(async (ele,index) => {
               console.log(ele.useDict);
                if(ele.useDict==true){ //判断useDict是否使用字典
                    await this.DictGetInfo(ele.bind.dict,index,'mast');
                }
            });
         }else{
            uni.showModal({title:"错误1",content:ret.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误1.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   async Detail1_UIstyleGetInfo(class_id,style_id){   //获取自定义表单样式
      var $this = this;
      var dataInfo={
         class_id:class_id,
         ui_style_id:style_id,
      };
      this.$store.dispatch('UIStyleGetInfo',dataInfo).then(ret=>{
         console.log(ret);
         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);
            }
            $this.$data.detail1_styledef = ret.result.style_def? JSON.parse(styledef): {};
            $this.$data.detail1_styledef.SelBut_Checked = false;
            // console.log($this.$data.detail1_styledef);
            // $this.$data.detail1StyleDefList.push($this.$data.detail1_styledef);
            // var aa = JSON.stringify(this.detail1_styledef);
            // $this.$data.detail1StyleDefList.push(JSON.parse(aa));
            // console.log($this.$data.detail1StyleDefList);
         }else{
            uni.showModal({title:"错误2",content:ret.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误2.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   async Html_UIstyleGetInfo(class_id, style_id) { //获取自定义表单样式
      var $this = this;
      var dataInfo = {
         class_id: class_id,
         ui_style_id: style_id,
      };
      this.$store.dispatch('UIStyleGetInfo', dataInfo).then(ret => {
         // console.log(ret);
         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);
            }
            $this.ListPageHtml_Show = ret.result.style_def ? JSON.parse(styledef) : {};
            // console.log($this.ListPageHtml_Show);
         } else {
            uni.showModal({
               title: "错误10",
               content: ret.err_msg,
               showCancel: false,
               confirmText: "取消"
            });
         }
      }).catch(ex => {
         // console.log(ex);
         uni.showModal({
            title: "错误10.1",
            content: ex.errMsg,
            showCancel: false,
            confirmText: "取消"
         });
      });
   },
   async DictGetInfo(dict,index,type){ //Mobox3得到得到字典信息字典项列表
      this.data=[];
      var $this = this;
      var dataInfo ={
         dict_id: dict.id,
         dict_name: dict.name
      };
      // console.log(dataInfo);
      this.$store.dispatch('DictGetInfo',dataInfo).then(async (success)=>{
         console.log(success);
         if (success.err_code == 0) {
            if(type=='mast'){
               var list=[];
               var itemName='';
               success.result.dict_item_list.forEach((item) => {
                   if(item.is_default=='1')
                       itemName = item.name;
                   list.push({
                       text:item.value,
                       value:item.name,
                   });
               });
               //有默认值,显示默认值
               if(itemName){
                  $this.head_styledef.form.items[index].value=itemName;
                  var attr = $this.head_styledef.form.items[index].fieldId;
                  $this.head_styledef.form.model[attr] = itemName;
               }
               $this.head_styledef.form.items[index].dict=list;
               var head_styledef = JSON.parse(JSON.stringify($this.head_styledef));
               $this.head_styledef=[];
               $this.head_styledef = head_styledef;
            }else{
               // $this.$data.subClassAttrList[index].attr_list[key].dictitem=success.result;
               // this.$store.commit("subClassAttrList", $this.$data.subClassAttrList);
            }
         }else{
            uni.showModal({title:"错误3.1",content:success.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误3",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   // 执行查询事件
   async onSearChange(clsid,eventid) {
    try {
       if (eventid) {
         var $this = this;
         var dataInfo={
           ed_type: 0,
            start_transaction: true,
          class_id: clsid,
         event_id: eventid,
         };
         this.$store.dispatch('runCustomEvent',dataInfo).then(ret=>{
            // console.log(ret);
            if (ret.err_code == 0) {
             var result = ret.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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                 else uni.showModal({title:'提示',content:tip+',提示:'+result.ret,showCancel:false,confirmText:"取消"});
                return false;
             }else{
                var tip = result.info ? typeof result.info == 'string' ? result.info : result.info.join('<br/>') : '';
                if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                if(result.result_type == 0 && result.action){
                   result.action.forEach(item=>{
                      if(item.action_type == "set_query_condition"){
                          var value = item.value;
                          $this.wheres = value.condition;
                          $this.orderby = value.order?value.order:$this.orderby;
                        $this.pageindex = 1;
                        $this.query_id = "";
                        $this.detail1StyleDefList=[];
                          $this.loadDataGetList();
                      }
                  });
                }else{
                   // this.detail2StyleDefList=[];
                   if(result.info){
                      uni.showModal({title:"提示",content:result.info,showCancel:false,confirmText:"取消"});
                   }
                }
             }
            }else{
               uni.showModal({title:"错误4",content:ret.err_msg,showCancel:false,confirmText:"取消"});
            }
         }).catch(ex=>{
            // console.log(ex);
            uni.showModal({title:"错误4.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
         });
        }
    } catch (ex) {
        var tip = typeof ex == "string" ? ex : ex.message;
       uni.showModal({title:"错误4.2",content:"执行“查询事件”事件失败:" + tip,showCancel:false,confirmText:"取消"});
    }
   },
   //查询数据类数据信息
   async loadDataGetList(){
     try{
      uni.showLoading({
         title:"加载中...",
         mask:true
      });
       //条件查询
       var condition = this.wheres;
       if(this.where){
         if(condition) condition +=' and ';
         condition+=this.where;
       }
       // console.log(condition);
       // console.log(this.orderby);
       var $this = this;
      var dataInfo={
         class_id: this.param.DataCls.id,
         attrs: [],
         condition: this.toWhereBase64String(""+ condition +""),
         prj_rel_type: "",
         order_by: this.orderby,
         page_size: this.page_size,
         page: this.pageindex,
         query_id: this.query_id,
      };
      this.$store.dispatch('dataObjQuery',dataInfo).then(ret=>{
         console.log(ret);
         uni.hideLoading();
         if (ret.err_code == 0) {
            // var list=[];
            $this.query_id = '';
            if(ret.result){
               $this.page_count = ret.result.page_count;
               if(ret.result.page_count>1) $this.query_id = ret.result.query_id;
               if($this.ListPageHtml_Show.event.id){
                  ret.result.obj_list.forEach((obj) => {
                     var info ={
                         id:obj.id,
                     };
                     obj.attr_list.forEach((attr) => {
                       info[attr.name]=attr.value;
                     });
                     var detailStyle ={
                         SelBut_Checked:false,
                         form:{},
                         info:info
                     };
                     detailStyle.form.htmlobjId = obj.id?obj.id.replace(/-/g,'').replace('{','').replace('}',''):'null';
                     detailStyle.form.objId = obj.id;
                     detailStyle.form.attrs = obj.attr_list;
                     $this.detail1StyleDefList.push(detailStyle);
                    $this.activelist.push({active:false});
                   });
                   // console.log(this.detail1StyleDefList);
                   var jsonlist=[];
                   $this.detail1StyleDefList.forEach(attr=>{
                     jsonlist.push({
                       id:attr.info.id,
                       attrs: Object.keys(attr.info).map((a) => ({
                         attr: a,
                         value: attr.info[a] || "",
                       }))
                     });
                   });
                   // console.log(jsonlist);
                  var data_json = Base64.encode(JSON.stringify(jsonlist));
                   var eventid = $this.ListPageHtml_Show.event.id;
                   if (!$this.ListPageHtml_Show.event.id.includes('{'))
                      eventid = '{' + $this.ListPageHtml_Show.event.id + '}';
                   //HTML页面事件
                   $this.runCustomEvent({
                      ed_type: 0,
                      start_transaction: true,
                      class_id: $this.param.DataCls.id,
                      event_id: eventid,
                      data_json,
                   });
               }else{
                 // $this.detail1StyleDefList=[];
                 ret.result.obj_list.forEach((obj) => {
                  var styleStr = JSON.stringify($this.detail1_styledef);
                  var detailStyle = JSON.parse(styleStr);
                  // var info ={
                  //     S_ID:obj.id,
                  // };
                  obj.attr_list.forEach((attr) => {
                    // info[attr.name]=attr.value;
                    detailStyle.form.items.forEach(ele=>{
                     if(ele.name!='Layout'){
                       if(ele.fieldId == attr.name) ele.value = attr.value;
                     } else if(ele.name=='Layout'){
                       ele.setting.colList.forEach(col=>{
                        if(col){
                          if(col.fieldId == attr.name) col.value = attr.value;
                        }
                       });
                     }
                    });
                  });
                  detailStyle.form.htmlobjId = obj.id?obj.id.replace(/-/g,'').replace('{','').replace('}',''):'null';
                  detailStyle.form.objId = obj.id;
                  detailStyle.form.attrs = obj.attr_list;
                  $this.detail1StyleDefList.push(detailStyle);
                  $this.activelist.push({active:false});
                  //list.push(info);
                 });
               }
               // 解决view层不同步的问题
               // $this.scrollTop = $this.old.scrollTop;
               $this.isScroll=false;
               setTimeout(function(){
                  $this.isScroll=true;
               },1000);
               // console.log($this.detail1StyleDefList);
            }
         }else{
            uni.showModal({title:"错误5",content:ret.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误5.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
     } catch (ex) {
       var tip = typeof ex == "string" ? ex : ex.message;
      uni.showModal({title:"错误5.2",content:tip,showCancel:false,confirmText:"取消"});
     }
   },
   //刷新
   Refresh(value){
     //刷新当前页面
     this.initial();
     // uni.redirectTo({
     //    url:'../modal/3200?param='+JSON.stringify(this.$data.param)+"&titlename="+this.$data.title,
     // });
   },
   //点击显示浏览对象显示页面
   async onViewPageClick(style){
     if(this.param.ViewPage){
        if(this.param.ViewPage.View_UIDef){
         this.styledef = style;
         var $this = this;
         uni.navigateTo({
            url:'../modal/3200_view?param='+JSON.stringify(this.param)+"&titlename="+this.title+"&style="+JSON.stringify(style),
            events: {
                // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                ExitViewEvent: function(data) {
                  console.log(data);
                 //退出页面后事件
                 var eventid = $this.param.ViewPage.Exit_View_Event?.id;
                 if(eventid){
                   try {
                    var obj_attr = {'S_ID':$this.styledef.form.objId};
                     $this.styledef.form.attrs.forEach((attr) => {
                      obj_attr[attr.name]=attr.value;
                     });
                     // console.log(obj_attr);
                     var input_param = Base64.encode(JSON.stringify(obj_attr));
                     $this.runCustomEvent({
                         ed_type: 0,
                       start_transaction: true,
                         class_id: $this.param.DataCls.id,
                         event_id: eventid,
                       data_obj_id:$this.styledef.form.objId,
                         obj_attr,
                         input_param,
                     });
                   } catch (ex) {
                     var tip = typeof ex == "string" ? ex : ex.message;
                     uni.showModal({title:"错误",content:tip,showCancel:false,confirmText:"取消"});
                   }
                 }
                }
            },
         });
      }
     }
   },
   //点击按钮
   onBtnClick(btn,style){
     var that = this
     if (btn.Prompt) {
      uni.showModal({
        title: '提示',
        content: btn.PromptContent || "是否确定?",
        success: function (res) {
          if (res.confirm) {
             that.onButtonClicked(btn,style);
          // } else if (res.cancel) {
          //    console.log('用户点击取消');
          }
        }
      });
     } else that.onButtonClicked(btn,style);
   },
   //点击按钮列表
   actionSheetTap() {
        var that = this
      var itemlist=[];
      this.param.ListPage.Page_Button.forEach((btn) => {
         itemlist.push(btn.ShowName);
      });
        uni.showActionSheet({
           // title: '按钮列表',
           itemList: itemlist,
           success: (e) => {
              console.log(e.tapIndex);
              var btn = that.param.ListPage.Page_Button[e.tapIndex];
              if (btn.Prompt) {
               uni.showModal({
                  title: '提示',
                  content: btn.PromptContent || "是否确定?",
                  success: function (res) {
                     if (res.confirm) {
                        that.onButtonClicked(btn);
                     // } else if (res.cancel) {
                     //    console.log('用户点击取消');
                     }
                  }
               });
              } else that.onButtonClicked(btn);
           }
        })
   },
   //处理相关按钮
   async onButtonClicked(btn,style) {
      style = style || '';
     try {
       var enviroment = {
         button: "top",
         button_name: btn.ShowName,
         cls_id: btn.Cls_ID,
         function: "3200",
         master: {},
       };
       if (btn.FunCode == "Add" || btn.FunCode == "Modify") {
         if (btn.Edit_dlg.Model == "small"){
           this.showAddSmallDialog(btn, style, enviroment);
        }
       } else if (btn.FunCode == "Delete") {
         this.DeleteObj(btn, style, enviroment);
       // } else if (btn.FunCode == "TriggerEvent") {
       //   this.triggerEvent(btn, style, enviroment);
       } else {
        uni.showModal({title:"提示",content:"未实现",showCancel:false,confirmText:"取消"});
       }
     } catch (ex) {
       var tip = typeof ex == "string" ? ex : ex.message;
      uni.showModal({title:"错误",content:tip,showCancel:false,confirmText:"取消"});
     }
   },
   //新增修改小窗口数据
   showAddSmallDialog(btn, style, enviroment){
      var data={
         Add_BtnName: btn.ShowName,
         EditDlgMode: btn.Edit_dlg.Model,
         clsid: this.param.DataCls.id,
         cls_name:  this.param.DataCls.name,
         Edit_dlg: btn.Edit_dlg
      };
      var $this = this;
      uni.navigateTo({
         url:'../modal/3018?param='+JSON.stringify(data)+"&titlename="+btn.Edit_dlg.Name+"&type=addDataObj",
         events: {
             // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
             addDataObj: function(data) {
               console.log(data);
              $this.Refresh();
            },
         }
      });
   },
   //删除数据对象
   DeleteObj(btn, style, enviroment){
     // console.log(style);
     var $this = this;
     uni.showModal({
        title: '提示',
        content: '确定删除该数据!',
        success: function (res) {
           if (res.confirm) {
            var objID=style.form.objId;
            if(!style.form.objId.includes('{')) objID = '{'+style.form.objId+'}';
            var dataInfo={
               class_id: btn.Cls_ID,
               class_name: '',
               obj_id: objID
            };
            // console.log(dataInfo);
            $this.$store.dispatch('dataObjDel',dataInfo).then(ret=>{
               // console.log(ret);
               if (ret.err_code == 0) {
                  //执行后处理事件
                  $this.AfterProcess_Event(btn.clsId, btm.AfterProcess_Event, enviroment);
                  //清除当前列表数据
                  $this.detail1StyleDefList.forEach((ele,index)=>{
                    if(ele.form.objId == objID){
                      $this.detail1StyleDefList.splice(index,1);
                    }
                  });
                  uni.showModal({title:"提示",content:"删除成功!",showCancel:false,confirmText:"取消"});
               }else{
                  uni.showModal({title:"错误6.1",content:ret.err_msg,showCancel:false,confirmText:"取消"});
               }
            }).catch(ex=>{
               // console.log(ex);
               uni.showModal({title:"错误6",content:ex.errMsg,showCancel:false,confirmText:"取消"});
            });
           } else if (res.cancel) {
           }
        }
     });
   },
   //执行后处理事件
   async AfterProcess_Event(clsId, afterProcess_Event, enviroment){
     try {
       if (afterProcess_Event.ID) {
         //执行后处理事件
         await this.runCustomEvent({
               ed_type: 0,
            start_transaction: true,
               class_id: clsId,
               event_id: afterProcess_Event.ID,
           });
       }
     } catch (ex) {
       var tip = typeof ex == "string" ? ex : ex.message;
      uni.showModal({title:"错误7",content:tip,showCancel:false,confirmText:"取消"});
     }
   },
   ontap(item){ //扫码功能
      // var $ele = e;
      //console.log(e.target)
      getApp().onScan((result)=>{
         console.log(result.decodedata);
         item.value = result.decodedata;
         uni.hideKeyboard();
         var $this = this;
         console.log(item);
         if(item.oldvalue != item.value){
             item.oldvalue = item.value;
            var attr = item.fieldId;
            this.head_styledef.form.model[attr] = item.value;
            var onChangeEvent = item.bind.onChangeEvent;   //内容变化后事件
            var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent;   //后图标点击事件
            var onSuffixClickEvent = item.bind.onSuffixClickEvent;   //后图标点击回调
            var isflag = false;
             if(onChangeEvent.id){   //内容变化后事件
               $this.onChange(onChangeEvent);
             } else{
              $this.where ='';
              if(item.value)
               $this.where =item.fieldId+" like '%"+item.value+"%'";
              $this.query_id='';
              $this.pageindex = 1;
              $this.detail1StyleDefList=[];
              $this.loadDataGetList();
            }
            if(item.value){ //第一个输入框不为空
               $this.focusMateria = true; //初始化,第二个输入框focus属性
               // setTimeout(function(){
               //    $this.focusMateria=true; //第二个输入框获取焦点
                  setTimeout(function(){
                     uni.hideKeyboard();
                  },1000);
               // },500);
            }
             // if(onSuffixClickCallbackEvent.id){   //后图标点击事件
             //   this.onSuffixClick(onSuffixClickCallbackEvent);
             // }
             // if(onSuffixClickEvent.id){   //后图标点击回调
             //   this.onSuffixClickCallback(onSuffixClickEvent);
             // }
         }
      })
   },
   onEnterChange(item){ //回车,点击按钮,取消节点事件
      // console.log(item);
      if(item.oldvalue != item.value){
          item.oldvalue = item.value;
         var attr = item.fieldId;
         this.head_styledef.form.model[attr] = item.value;
         var onChangeEvent = item.bind.onChangeEvent;   //内容变化后事件
         var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent;   //后图标点击事件
         var onSuffixClickEvent = item.bind.onSuffixClickEvent;   //后图标点击回调
         var isflag = false;
          if(onChangeEvent.id){   //内容变化后事件
            this.onChange(onChangeEvent);
          } else{
           this.where ='';
           if(item.value)
            this.where =item.fieldId+" like '%"+item.value+"%'";
           this.query_id='';
           this.pageindex = 1;
           this.detail1StyleDefList=[];
           this.loadDataGetList();
         }
          // if(onSuffixClickCallbackEvent.id){   //后图标点击事件
          //   this.onSuffixClick(onSuffixClickCallbackEvent);
          // }
          // if(onSuffixClickEvent.id){   //后图标点击回调
          //   this.onSuffixClickCallback(onSuffixClickEvent);
          // }
      }
   },
   // 内容变化后事件
   async onChange(event) {
       try {
           if (event.id) {
             var obj_attr = this.head_styledef.form.model;
             // console.log(obj_attr);
             var input_param = Base64.encode(
               JSON.stringify(
                 Object.keys(obj_attr).map((a) => ({
                   attr: a,
                   value: obj_attr[a] || "",
                 }))
               )
             );
           var $this = this;
           var dataInfo={
               ed_type: 0,
            start_transaction: true,
               class_id: this.$data.head_styledef.form.clsId,
            class_name: '',
               event_id: event.id,
            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,
             };
           this.$store.dispatch('runCustomEvent',dataInfo).then(ret=>{
              // console.log(ret);
              if (ret.err_code == 0) {
               var result = ret.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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                   else uni.showModal({title:'提示',content:tip+',提示:'+result.ret,showCancel:false,confirmText:"取消"});
                  return false;
               }else{
                  var tip = result.info ? typeof result.info == 'string' ? result.info : result.info.join('<br/>') : '';
                  if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                  if(result.result_type == 0 && result.action){
                     result.action.forEach(item=>{
                        if(item.action_type == "set_dlg_attr"){
                          // value = {"attr":"xxx", "value":"xxx"}
                          var data = item.value;
                          $this.$data.head_styledef.form.items.forEach(async (ele,index) => {
                            data.forEach(async (ele2,index) => {
                              if(ele.fieldId == ele2.attr){
                                ele.value = ele2.value;
                              }
                            });
                          });
                        }
                     });
                  }else{
                     // this.detail2StyleDefList=[];
                     if(result.info){
                        uni.showModal({title:"提示",content:result.info,showCancel:false,confirmText:"取消"});
                     }
                  }
               }
              }else{
                 uni.showModal({title:"错误8",content:ret.err_msg,showCancel:false,confirmText:"取消"});
              }
           }).catch(ex=>{
              // console.log(ex);
              uni.showModal({title:"错误8.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
           });
           }
       } catch (ex) {
           var tip = typeof ex == "string" ? ex : ex.message;
         uni.showModal({title:"错误8.2",content:"执行“内容变化后”事件失败:" + tip,showCancel:false,confirmText:"取消"});
       }
   },
   //点中表单
   onPanelClick(value){ //点击面板高亮显示
      // console.log(value);
       this.activelist.forEach(ele=>{
           ele.active = false;
       });
       this.activelist[value].active = true;
   },
   //事件处理
   async runCustomEvent(dataInfo) {
       try {
         var $this = this;
         this.$store.dispatch('runCustomEvent',dataInfo).then(ret=>{
              console.log(ret);
              if (ret.err_code == 0) {
               var result = ret.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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                   else uni.showModal({title:'提示',content:tip+',提示:'+result.ret,showCancel:false,confirmText:"取消"});
                  return false;
               }else{
                  var tip = result.info ? typeof result.info == 'string' ? result.info : result.info.join('<br/>') : '';
                  if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                  if(result.result_type == 0 && result.action){
                     result.action.forEach(item=>{
                        if(item.action_type == "goback_to_pre_page"){ //返回上一页
                           var value = item.value;
                           uni.navigateBack({
                              delta:1 ,//返回层数,2则上上页
                           });
                        } else if(item.action_type == "hidden_button"){ //隐藏按钮
                           var value = item.value;
                           value.forEach(btn => {
                               var index = $this.param.ListPage.Page_Button.findIndex(button => button.ShowName == btn)
                               if (index > -1)
                                 $this.param.ListPage.Page_Button.splice(index, 1)
                           })
                        // } else if(item.action_type == "refresh_cur_row"){ //
                        //    var value = item.value;
                        } else if (item.action_type == "set_panel_html") { //显示Html页面
                           // var value = item.value;
                           $this.ListHtml_Panel = item.value;
                           // $this.detail1StyleDefList.forEach((ele,index)=>{
                           //    ele.ListHtml_Panel = item.value[index];
                           // });
                        } else{
                           uni.showModal({title:"提示",content:"当前action_type:"+item.action_type+"未处理",showCancel:false,confirmText:"取消"});
                        }
                     });
                  }else{
                     // this.detail2StyleDefList=[];
                     if(result.info){
                        uni.showModal({title:"提示",content:result.info,showCancel:false,confirmText:"取消"});
                     }
                  }
               }
              }else{
                 uni.showModal({title:"错误9",content:ret.err_msg,showCancel:false,confirmText:"取消"});
              }
         }).catch(ex=>{
              // console.log(ex);
              uni.showModal({title:"错误9.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
         });
       } catch (ex) {
           var tip = typeof ex == "string" ? ex : ex.message;
         uni.showModal({title:"错误9.2",content:"执行事件失败:" + tip,showCancel:false,confirmText:"取消"});
       }
   },
   cancel(e){ //取消
      // var eventChannel = this.$scope.eventChannel;
      // // const eventChannel = this.getOpenerEventChannel();
      // eventChannel.emit('view_3201',"");
      uni.navigateBack({
         delta:1 ,//返回层数,2则上上页
      });
   },
   /**
    * 只支持["column1='A' or column2='B'", "column3='C' and column4='D'", "column5='E'"]这种格式
    * {
    *     "model": 0 / 1,
    *     "condition":
    *     [
    *         [
    *             { },
    *             { },
    *             { }
    *         ],
    *         [
    *             { }
    *         ],
    *         [
    *             { }
    *         ]
    *     ]
    * }
    */
   toWhereBase64String(list) {
      if (typeof list == 'string') list = [list]
      var sql = []
      var seps = [' not in', ' in', '<>', '!=', '<=', '>=', '<', '=', '>', ' like']
      list.forEach(ls => {
         var where = ls.trim()
         if (where.startsWith('(') && where.endsWith(')')) where = where.replace(/^\(/, '').replace(/\)$/, '')
         if (where.toLowerCase().includes(' and ')) {
            // 二级and放在第一级数组中
            where.split(/ and /i).forEach(li => {
               var l = li.trim()
               if (l.startsWith('(') && l.endsWith(')')) l = l.replace(/^\(/, '').replace(/\)$/, '')
               var sep = ''
               for (var i = 0; i < seps.length; i++) {
                  if (l.toLowerCase().includes(seps[i])) {
                     sep = seps[i]
                     break
                  }
               }
               if (sep) {
                  var values = l.split(new RegExp(sep, 'i'))
                  var field = values[0]?.trim().replace(/^\[/, '').replace(/\]$/, '')
                  var value = ''
                  var op = sep.trim()
                  if ([' in', ' not in'].includes(sep) && values[1]?.toLowerCase().includes('select ') && values[1]?.toLowerCase().includes(' from ')) {
                     value = l.replace(field, '').replace(/^\s*(in|not in)\s*/i, '').trim()
                     if (value.startsWith('(') && value.endsWith(')')) value = value.replace(/^\(/, '').replace(/\)$/, '').trim()
                  }
                  else {
                     value = values[1]?.trim().replace(/^\'/, '').replace(/\'$/, '')
                     if (['in', 'not in'].includes(op)) {
                        value = value.replace(/^\(/, '').replace(/\)$/, '')
                        value = value.split(',').map(v => v.trim().replace(/^\'/, '').replace(/\'$/, ''))
                     }
                  }
                  sql.push([{ field, value, op }])
               }
            })
         }
         else if (where.toLowerCase().includes(' or ')) {
            // 二级or放在第二级同一组数组中
            var s = []
            where.split(/ or /i).forEach(li => {
               var l = li.trim()
               if (l.startsWith('(') && l.endsWith(')')) l = l.replace(/^\(/, '').replace(/\)$/, '')
               var sep = ''
               for (var i = 0; i < seps.length; i++) {
                  if (l.toLowerCase().includes(seps[i])) {
                     sep = seps[i]
                     break
                  }
               }
               if (sep) {
                  var values = l.split(new RegExp(sep, 'i'))
                  var field = values[0]?.trim().replace(/^\[/, '').replace(/\]$/, '')
                  var value = ''
                  var op = sep.trim()
                  if ([' in', ' not in'].includes(sep) && values[1]?.toLowerCase().includes('select ') && values[1]?.toLowerCase().includes(' from ')) {
                     value = l.replace(field, '').replace(/^\s*(in|not in)\s*/i, '').trim()
                     if (value.startsWith('(') && value.endsWith(')')) value = value.replace(/^\(/, '').replace(/\)$/, '').trim()
                  }
                  else {
                     value = values[1]?.trim().replace(/^\'/, '').replace(/\'$/, '')
                     if (['in', 'not in'].includes(op)) {
                        value = value.replace(/^\(/, '').replace(/\)$/, '')
                        value = value.split(',').map(v => v.trim().replace(/^\'/, '').replace(/\'$/, ''))
                     }
                  }
                  sql.push([{ field, value, op }])
               }
            })
            sql.push(s)
         }
         else {
            var li = where
            // 单一查询条件直接放在第一级数组中
            var l = li.trim()
            if (l.startsWith('(') && l.endsWith(')')) l = l.replace(/^\(/, '').replace(/\)$/, '')
            var sep = ''
            for (var i = 0; i < seps.length; i++) {
               if (l.toLowerCase().includes(seps[i])) {
                  sep = seps[i]
                  break
               }
            }
            if (sep) {
               var values = l.split(new RegExp(sep,'i'))
               var field = values[0]?.trim().replace(/^\[/, '').replace(/\]$/, '')
               var value = ''
               var op = sep.trim()
               if ([' in', ' not in'].includes(sep) && values[1]?.toLowerCase().includes('select ') && values[1]?.toLowerCase().includes(' from ')) {
                  value = l.replace(field, '').replace(/^\s*(in|not in)\s*/i, '').trim()
                  if (value.startsWith('(') && value.endsWith(')')) value = value.replace(/^\(/, '').replace(/\)$/, '').trim()
               }
               else {
                  value = values[1]?.trim().replace(/^\'/, '').replace(/\'$/, '')
                  if (['in', 'not in'].includes(op)) {
                     value = value.replace(/^\(/, '').replace(/\)$/, '')
                     value = value.split(',').map(v => v.trim().replace(/^\'/, '').replace(/\'$/, ''))
                  }
               }
               sql.push([{ field, value, op }])
            }
         }
      })
      if (sql.length > 0)
         return Base64.encode(JSON.stringify({
            model: 1,
            condition: sql
         }))
      else
      return ''
   },
  },
};
</script>
<style>
.v-headStyle:first-child{
   margin-top: 15rpx;
@@ -271,15 +1652,41 @@
    margin-bottom: 5px;
}
.dv_panel_content .dv_panel_attr i{
    vertical-align: 22px;
    vertical-align: super;
    margin: 0 10px;
}
.dv_panel_content .dv_panel_attr .circel_node{}
/* 是菱形的 */
.dv_panel_content .dv_panel_attr .dv_diamond_node {}
.dv_panel_content .dv_panel_attr .dv_box_node{
  display: inline-block;
  text-align: center;
.dv_panel_content .dv_panel_attr .dv_diamond_node p{
   width: 50px;
   height: 50px;
   background-color: #4D6AF4;
   transform: rotate(45deg);
   -ms-transform: rotate(45deg);
   -moz-transform: rotate(45deg);
   -webkit-transform: rotate(45deg);
   -o-transform: rotate(45deg);
   margin: 15px auto;
   padding: 9px;
   // line-height: 28px;
   text-align: center;
}
.dv_panel_content .dv_panel_attr .dv_diamond_node p span{
    color: #fff;
   transform: rotate(-45deg);
   display: inline-block;
   text-align: center;
   overflow: hidden;
   text-overflow: ellipsis;
   // white-space: nowrap;
}
/* 默认形 */
.dv_panel_content .dv_panel_attr .dv_box_node,
.dv_panel_content .dv_panel_attr .dv_diamond_node{
   vertical-align: middle;
   display: inline-block;
   text-align: center;
   width: 100px;
}
.dv_panel_content .dv_panel_attr .dv_box_node p{
    background: #4D6AF4;
@@ -308,1347 +1715,3 @@
      width: calc(100% - 120px);
   }
</style>
<template>
   <view class="content">
      <!-- <view class="dv_panel_condent">
         <view class="dv_panel_attr">
            <label>No:</label>
            <span>TA240129-00001</span>
         </view>
         <view class="dv_panel_attr">
            <view class="dv_inline">
               <p>毛料线边</p>
               <label>L002-1</label>
            </view>
            <i class="mobox-normal-right"></i>
            <view class="dv_inline">
               <p>毛料线边</p>
               <label>L003-3</label>
            </view>
         </view>
      </view> -->
     <view class="v-content">
      <!-- 表头样式 -->
      <view class="v-headStyle" v-for="(item,index) in head_styledef.form.items" v-if="isFilter==true">
         <text class="txt_title" :style="{'width':item.labelWidth+'px'}">{{item.label}}:</text>
         <!-- 下拉框-单选 item.useDict?item.dict:item.selections-->
         <uni-data-select id="dv_select" v-if="item.name=='Select'"
            :class="item.disabled?'input-disabled':''"
            v-model="item.value"
            :localdata="item.dict"
            @change="onChange(item)"
            :disabled="item.disabled"
            :clear="false"
         ></uni-data-select>
         <view class="input-wrapper" v-if="item.name=='Input' || item.name=='InputNumber'">
            <text v-if="item.setting.prefix"
               class="uni-icon"
               :class="[item.setting.prefix]"
               @click="onEnterChange(item)">&#xe568;</text>
            <input class="uni-input"
               :class="item.disabled?'input-disabled':''"
               :type="item.name=='Input'?'text':'number'"
               v-model="item.value"
               :disabled="item.disabled"
               :placeholder="item.placeholder"
               :style="{'width':item.setting.prefix && item.setting.suffix?'78%':item.setting.prefix || item.setting.suffix?'87%':'96%'}"
               :focus="focusMateria"
               @focus="ontap(item)"
               @keyup.enter="onEnterChange(item)"
               @blur="onEnterChange(item)"
            />
            <text v-if="item.setting.suffix"
               class="uni-icon"
               :class="[item.setting.suffix]"
               @click="onEnterChange(item)">&#xe568;</text>
          </view>
      </view>
      <scroll-view :scroll-top="scrollTop" :scroll-y="true" class="scroll-Y"
        @scrolltolower="scrolltolower" @scroll="scroll">
         <view class="view-content" id="tabpanel">
           <view class="dv-panel dv-panel-bkcolor" v-for="(style,ii) in detail1StyleDefList"
            @click="onPanelClick(ii)"
            :id="'panel'+style.form.htmlobjId"
            :class="activelist[ii].active==true?'bk-active':''">
            <div class="dv-panel-button" v-if="param.ListPage.CheckBox==true">
              <checkbox-group>
               <label>
                  <checkbox :value="style.SelBut_Checked" :checked="style.SelBut_Checked" />
               </label>
              </checkbox-group>
            </div>
            <!-- HTML页面类型显示 -->
            <div class="dv-listHtml-Panel" v-if="ListHtml_Panel" v-html="ListHtml_Panel[ii]"
              :style="param.ListPage.CheckBox==true && param.ListPage.Click_View==true?'width:85%;':
              param.ListPage.CheckBox==false && param.ListPage.Click_View==true?'width:91%;':
              param.ListPage.CheckBox==true && param.ListPage.Click_View==false?'width:88%;':'width:100%;'">
               <!-- <div class="dv_panel_content">
                  <div class="dv_panel_attr">
                    <label>No:</label>
                    <span>TA240129-00001</span>
                  </div>
                  <div class="dv_panel_attr">
                    <div class="dv_box_node">
                     <p>毛料线边</p>
                     <label>L002-1</label>
                    </div>
                    <i class="mobox-normal-right"></i>
                    <div class="dv_box_node">
                     <p>毛料线边</p>
                     <label>L003-3</label>
                    </div>
                  </div>
               </div> -->
            </div>
            <!-- 自定义表单类型显示 -->
            <div class="dv-panel-input" v-if="!ListHtml_Panel"
              :style="param.ListPage.CheckBox==true && param.ListPage.Click_View==true?'width:85%;':
              param.ListPage.CheckBox==false && param.ListPage.Click_View==true?'width:91%;':
              param.ListPage.CheckBox==true && param.ListPage.Click_View==false?'width:88%;':'width:100%;'">
              <div v-for="(item,index) in style.form.items">
               <!-- 普通布局 -->
               <view v-if="item.name!='Layout'">
                  <text class="txt_title" :style="{'width':item.labelWidth+'px'}">{{item.label}}:</text>
                  <span class="form-item-span" v-if="item.disabled">{{item.value}}</span>
                  <!-- 文本框/数字框 -->
                  <view class="dv_input" v-if="(item.name=='Input' || item.name=='InputNumber') && !item.disabled">
                     <text v-if="item.setting.prefix"
                        class="uni-icon"
                        :class="[item.setting.prefix]"
                        @change="onChange(item)">&#xe568;</text>
                     <input class="uni-input" :class="item.disabled?'input-disabled':''"
                        :type="item.name=='Input'?'text':item.name=='InputNumber'?'number':'text'"
                        v-model="item.value"
                        :disabled="item.disabled"
                        :placeholder="item.placeholder"
                        :style="{'width':item.setting.prefix && item.setting.suffix?'78%':item.setting.prefix || item.setting.suffix?'87%':'96%'}"
                        :focus="focusMateria"
                        @focus="ontap(item)"
                        @blur="onevent(item)"
                     />
                     <text v-if="item.setting.suffix"
                        class="uni-icon"
                        :class="[item.setting.suffix]"
                        @click="onChange(item)">&#xe568;</text>
                  </view>
                  <!-- 下拉框-单选 item.useDict?item.dict:item.selections-->
                  <uni-data-select id="dv_select" v-if="item.name=='Select' && !item.disabled"
                     :class="item.disabled?'input-disabled':''"
                     v-model="item.value"
                     :localdata="item.dict"
                     @change="onChange(item)"
                     :disabled="item.disabled"
                     :clear="false"
                  ></uni-data-select>
                  <!-- 多行文本 -->
                  <view class="input-wrapper" v-if="item.name=='Textarea' && !item.disabled">
                     <textarea class="uni-input" :value="item.value"
                       :class="item.disabled?'input-disabled':''"
                       :placeholder="item.placeholder"
                       @blur="onModelValue(item)"
                       style="height:60px;"
                       :style="{'width':'96%'}"
                       :disabled="item.disabled"
                     ></textarea>
                  </view>
                  <!-- 复选框 -->
                  <checkbox-group class="check_rememberPwd" v-if="item.name=='Checkbox'"
                     :class="item.disabled?'input-disabled':''"
                     @change="onModelValue(item)"
                     :data-ischeck="item.value"
                     :disabled="item.disabled"
                     :style="{'margin-left':'10rpx'}">
                     <label>
                        <checkbox :value="item.value" :checked="item.value"/>
                        <text>{{item.label}}</text>
                     </label>
                  </checkbox-group>
                  <!-- Switch开关 -->
                  <switch v-if="item.name=='Switch'" :class="item.disabled?'input-disabled':''"
                     :disabled="item.disabled"
                     v-model="item.value"
                     @change="onModelValue(item)"
                     :style="{'margin-left':'10rpx'}"/>
                  <!-- 日期时间 -->
                  <view class="input-wrapper" v-if="(item.name=='TimePicker' || item.name=='DatePicker') && !item.disabled">
                     <picker mode="date" class="date_iput" :class="item.disabled?'input-disabled':''"
                       :disabled="item.disabled"
                       :value="item.value"
                       @change="onModelValue(item)"
                     >
                        <view class="picker">{{item.value}}</view>
                     </picker>
                  </view>
               </view>
               <!-- 栅格布局 -->
               <uni-row class="demo-uni-row" v-if="item.name=='Layout'">
                  <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">
                           <text v-if="cols.setting.prefix"
                              class="uni-icon"
                              :class="[cols.setting.prefix]"
                              @change="onChange(cols)">&#xe568;</text>
                           <input class="uni-input" :class="cols.disabled?'input-disabled':''"
                              :type="cols.name=='Input'?'text':cols.name=='InputNumber'?'number':'text'"
                              v-model="cols.value"
                              :disabled="cols.disabled"
                              :placeholder="cols.placeholder"
                              :style="{'width':cols.setting.prefix && cols.setting.suffix?'78%':cols.setting.prefix || cols.setting.suffix?'87%':'96%'}"
                              :focus="focusMateria"
                              @focus="ontap(cols)"
                              @blur="onevent(cols)"
                           />
                           <text v-if="cols.setting.suffix"
                              class="uni-icon"
                              :class="[cols.setting.suffix]"
                              @click="onChange(cols)">&#xe568;</text>
                        </view>
                        <!-- 下拉框-单选 cols.useDict?cols.dict:cols.selections-->
                        <uni-data-select id="dv_select" v-if="cols.name=='Select' && !cols.disabled"
                           :class="cols.disabled?'input-disabled':''"
                           v-model="cols.value"
                           :localdata="cols.dict"
                           @change="onChange(cols)"
                           :disabled="cols.disabled"
                           :clear="false"
                        ></uni-data-select>
                        <!-- 多行文本 -->
                        <view class="input-wrapper" v-if="cols.name=='Textarea' && !cols.disabled">
                           <textarea class="uni-input" :value="cols.value"
                             :class="cols.disabled?'input-disabled':''"
                             :placeholder="cols.placeholder"
                             @blur="onModelValue(cols)"
                             style="height:60px;"
                             :style="{'width':'96%'}"
                             :disabled="cols.disabled"
                           ></textarea>
                        </view>
                        <!-- 复选框 -->
                        <checkbox-group class="check_rememberPwd" v-if="cols.name=='Checkbox'"
                           :class="cols.disabled?'input-disabled':''"
                           :disabled="item.disabled"
                           @change="onModelValue(cols)"
                           :data-ischeck="cols.value"
                           :style="{'margin-left':'10rpx'}">
                           <label>
                              <checkbox :value="cols.value" :checked="cols.value"/>
                              <text>{{cols.label}}</text>
                           </label>
                        </checkbox-group>
                        <!-- Switch开关 -->
                        <switch v-if="cols.name=='Switch'" :class="cols.disabled?'input-disabled':''"
                           :disabled="item.disabled"
                           v-model="cols.value"
                           @change="onModelValue(cols)"
                           :style="{'margin-left':'10rpx'}"/>
                        <!-- 日期时间 -->
                        <view class="input-wrapper" v-if="(cols.name=='TimePicker' || cols.name=='DatePicker') && !cols.disabled">
                           <picker mode="date" class="date_iput" :class="cols.disabled?'input-disabled':''"
                             :disabled="item.disabled"
                             :value="cols.value"
                             @change="onModelValue(cols)"
                           >
                              <view class="picker">{{cols.value}}</view>
                           </picker>
                        </view>
                     </view>
                  </uni-col>
               </uni-row>
               </div>
            </div>
            <div class="dv-panel-button" v-if="param.ListPage.Click_View==true" >
              <a @click="onViewPageClick(style)"><i class="mobox-normal-right-arrow" /></a>
            </div>
            <div class="dv-panel-buticon" v-if="param.ListPage.ListItem_Button" >
              <view class="btn-padding" v-for="(btn,key) in param.ListPage.ListItem_Button">
               <a @click="onBtnClick(btn,style)" :title="btn.ShowName" v-if="btn.Style=='img'">
                  <i :class="btn.Img" />
               </a>
               <button type="default" @click="onBtnClick(btn,style)" class="btn-padding" v-else-if="btn.Style=='text'">{{btn.ShowName}}</button>
              </view>
            </div>
           </view>
         </view>
      </scroll-view>
     </view>
     <view class="view-floor">
        <button type="default" @click="cancel" class="btn_cancel"
        :style="{'width':param.ListPage.Page_Button.length>0?'39.5%':'48.5%'}">关闭</button>
        <button type="default" @click="Refresh" class="btn_refresh"
        :style="{'width':param.ListPage.Page_Button.length>0?'39.5%':'48.5%'}">刷新</button>
      <view class="uni-padding-wrap" v-if="param.ListPage.Page_Button.length>0">
         <view class="uni-btn-v">
            <a @tap="actionSheetTap"><Icon class="mobox-normal-more"/></a>
         </view>
      </view>
     </view>
    </view>
</template>
<script>
import Base64 from '../../components/js-base64/base64.js'
export default {
  modules:{
   Base64,
  },
  onNavigationBarButtonTap(e) {
 //     console.log(e);
   // e.text="\ue924";
     // console.log(e.fontSize);
   if(this.isFilter)
       this.isFilter=false;
   else
       this.isFilter=true;
  },
  onBackPress(e){
   // console.log("监听返回按钮事件",e);
   var eventChannel = this.$scope.eventChannel;
   // const eventChannel = this.getOpenerEventChannel();
   eventChannel.emit('view_3201',"");
   // uni.navigateBack({
   //    delta:1 ,//返回层数,2则上上页
   // });
   // return true;
  },
  data() {
    return {
     title:'新增',
      isFilter:true,
      param: {},
     focusMateria:false,
     styledef:{},
     head_styledef:{
      form:{
         items:[]
      }
     },
      detail1_styledef:{},
      detail1StyleDefList:[],
      detail2_styledef:{},
      detail2StyleDefList:[],
     items: [],
      active_id:'',
     activelist:[],
      where:'',
      wheres:'',
      orderby:'',
      query_id:'',
      pageindex:1,
      page_size:10,
      page_count:0,
     scrollTop: 0,
     old: {
        scrollTop: 0
     },
     isScroll:true,
     //获取数据类的HTML页面
     ListHtml_Panel:"",
     ListPageHtml_Show: {
        name: "",
        event: {
           id: "",
           name: ""
        }
     },
    };
  },
  async onLoad(options) {
   // console.log(options);
   uni.setNavigationBarTitle({ title: options.titlename}); //设置顶部标题
   this.$data.title = options.titlename;
   this.$data.param = JSON.parse(options.param);
   this.isFilter=true;
   if(this.param.ShowFilter)
     this.isFilter=false;
   //获取数据类的自定义表单参数
   this.Head_UIStyleGetInfo(this.param.DataCls.id,this.param.Query_Panel.id);
   if(this.param.ListPage.ListItem_UIDef?.ui_type=="HTML页面"){
      // HTML页面
      //获取数据类的HTML页面
      await this.Html_UIstyleGetInfo(this.param.DataCls.id,this.param.ListPage.ListItem_UIDef.id);
   }else{
      await this.Detail1_UIstyleGetInfo(this.param.DataCls.id,this.param.ListPage.ListItem_UIDef.id);
   }
   this.orderby = this.param.Order?this.param.Order:'T_CREATE Desc';
   if(this.param.Query_Event){
       await this.onSearChange(this.param.DataCls.id,this.param.Query_Event.id);
   } else{
     this.wheres = this.param.Condition;
     this.pageindex = 1;
     this.page_size = 3;
     this.query_id = "";
     await this.loadDataGetList();
   }
   console.log(this.$data.param);
   //页面初始化获取焦点
   // this.focusMateria=true;
  },
  methods: {
   //滚动到底部后懒加载数据
   async scrolltolower(e) {
      // console.log(e)
      if(this.isScroll){ //判断刷新一次后不会持续刷新
         if(this.page_count==this.pageindex){
            return;
         }
         this.pageindex += 1;
         if(this.where || this.page_count==1) {
           this.query_id = "";
           this.detail1StyleDefList=[];
         }
         await this.loadDataGetList();
      }
   },
   scroll: function(e) {
      // console.log(e.detail.scrollTop)
      this.old.scrollTop = e.detail.scrollTop
   },
   async Head_UIStyleGetInfo(class_id,style_id){   //获取自定义表单样式
      var $this = this;
      var dataInfo={
         class_id:class_id,
         ui_style_id:style_id,
      };
      // console.log(dataInfo);
      this.$store.dispatch('UIStyleGetInfo',dataInfo).then(ret=>{
         // console.log(ret);
         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);
            }
            $this.$data.head_styledef = ret.result.style_def? JSON.parse(styledef): {};
            // this.form = this.head_styledef.form.model;
            // console.log($this.$data.head_styledef);
            $this.head_styledef.form.items.forEach(async (ele,index) => {
               console.log(ele.useDict);
                if(ele.useDict==true){ //判断useDict是否使用字典
                    await this.DictGetInfo(ele.bind.dict,index,'mast');
                }
            });
         }else{
            uni.showModal({title:"错误1",content:ret.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误1.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   async Detail1_UIstyleGetInfo(class_id,style_id){   //获取自定义表单样式
      var $this = this;
      var dataInfo={
         class_id:class_id,
         ui_style_id:style_id,
      };
      this.$store.dispatch('UIStyleGetInfo',dataInfo).then(ret=>{
         console.log(ret);
         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);
            }
            $this.$data.detail1_styledef = ret.result.style_def? JSON.parse(styledef): {};
            $this.$data.detail1_styledef.SelBut_Checked = false;
            // console.log($this.$data.detail1_styledef);
            // $this.$data.detail1StyleDefList.push($this.$data.detail1_styledef);
            // var aa = JSON.stringify(this.detail1_styledef);
            // $this.$data.detail1StyleDefList.push(JSON.parse(aa));
            // console.log($this.$data.detail1StyleDefList);
         }else{
            uni.showModal({title:"错误2",content:ret.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误2.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   async Html_UIstyleGetInfo(class_id, style_id) { //获取自定义表单样式
      var $this = this;
      var dataInfo = {
         class_id: class_id,
         ui_style_id: style_id,
      };
      this.$store.dispatch('UIStyleGetInfo', dataInfo).then(ret => {
         // console.log(ret);
         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);
            }
            $this.ListPageHtml_Show = ret.result.style_def ? JSON.parse(styledef) : {};
            // console.log($this.ListPageHtml_Show);
         } else {
            uni.showModal({
               title: "错误10",
               content: ret.err_msg,
               showCancel: false,
               confirmText: "取消"
            });
         }
      }).catch(ex => {
         // console.log(ex);
         uni.showModal({
            title: "错误10.1",
            content: ex.errMsg,
            showCancel: false,
            confirmText: "取消"
         });
      });
   },
   async DictGetInfo(dict,index,type){ //Mobox3得到得到字典信息字典项列表
      this.data=[];
      var $this = this;
      var dataInfo ={
         dict_id: dict.id,
         dict_name: dict.name
      };
      // console.log(dataInfo);
      this.$store.dispatch('DictGetInfo',dataInfo).then(async (success)=>{
         console.log(success);
         if (success.err_code == 0) {
            if(type=='mast'){
               var list=[];
               var itemName='';
               success.result.dict_item_list.forEach((item) => {
                   if(item.is_default=='1')
                       itemName = item.name;
                   list.push({
                       text:item.value,
                       value:item.name,
                   });
               });
               //有默认值,显示默认值
               if(itemName){
                  $this.head_styledef.form.items[index].value=itemName;
                  var attr = $this.head_styledef.form.items[index].fieldId;
                  $this.head_styledef.form.model[attr] = itemName;
               }
               $this.head_styledef.form.items[index].dict=list;
               var head_styledef = JSON.parse(JSON.stringify($this.head_styledef));
               $this.head_styledef=[];
               $this.head_styledef = head_styledef;
            }else{
               // $this.$data.subClassAttrList[index].attr_list[key].dictitem=success.result;
               // this.$store.commit("subClassAttrList", $this.$data.subClassAttrList);
            }
         }else{
            uni.showModal({title:"错误3.1",content:success.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误3",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
   },
   // 执行查询事件
   async onSearChange(clsid,eventid) {
    try {
       if (event.id) {
         var $this = this;
         var dataInfo={
           ed_type: 0,
            start_transaction: true,
          class_id: clsid,
         event_id: eventid,
         };
         this.$store.dispatch('runCustomEvent',dataInfo).then(ret=>{
            // console.log(ret);
            if (ret.err_code == 0) {
             var result = ret.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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                 else uni.showModal({title:'提示',content:tip+',提示:'+result.ret,showCancel:false,confirmText:"取消"});
                return false;
             }else{
                var tip = result.info ? typeof result.info == 'string' ? result.info : result.info.join('<br/>') : '';
                if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                if(result.result_type == 0 && result.action){
                   result.action.forEach(item=>{
                      if(item.action_type == "set_query_condition"){
                          var value = item.value;
                          $this.wheres = value.condition;
                          $this.orderby = value.order?value.order:$this.orderby;
                        $this.pageindex = 1;
                        $this.query_id = "";
                        $this.detail1StyleDefList=[];
                          $this.loadDataGetList();
                      }
                  });
                }else{
                   // this.detail2StyleDefList=[];
                   if(result.info){
                      uni.showModal({title:"提示",content:result.info,showCancel:false,confirmText:"取消"});
                   }
                }
             }
            }else{
               uni.showModal({title:"错误4",content:ret.err_msg,showCancel:false,confirmText:"取消"});
            }
         }).catch(ex=>{
            // console.log(ex);
            uni.showModal({title:"错误4.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
         });
        }
    } catch (ex) {
        var tip = typeof ex == "string" ? ex : ex.message;
       uni.showModal({title:"错误4.2",content:"执行“查询事件”事件失败:" + tip,showCancel:false,confirmText:"取消"});
    }
   },
   //查询数据类数据信息
   async loadDataGetList(){
     try{
      uni.showLoading({
         title:"加载中...",
         mask:true
      });
       //条件查询
       var condition = this.wheres;
       if(this.where){
         if(condition) condition +=' and ';
         condition+=this.where;
       }
       // console.log(condition);
       // console.log(this.orderby);
       var $this = this;
      var dataInfo={
         class_id: this.param.DataCls.id,
         attrs: [],
         condition: this.toWhereBase64String(""+ condition +""),
         prj_rel_type: "",
         order_by: this.orderby,
         page_size: this.page_size,
         page: this.pageindex,
         query_id: this.query_id,
      };
      this.$store.dispatch('dataObjQuery',dataInfo).then(ret=>{
         console.log(ret);
         uni.hideLoading();
         if (ret.err_code == 0) {
            // var list=[];
            $this.query_id = '';
            if(ret.result){
               $this.page_count = ret.result.page_count;
               if(ret.result.page_count>1) $this.query_id = ret.result.query_id;
               if($this.ListPageHtml_Show.event.id){
                  ret.result.obj_list.forEach((obj) => {
                     var info ={
                         id:obj.id,
                     };
                     obj.attr_list.forEach((attr) => {
                       info[attr.name]=attr.value;
                     });
                     var detailStyle ={
                         SelBut_Checked:false,
                         form:{},
                         info:info
                     };
                     detailStyle.form.htmlobjId = obj.id?obj.id.replace(/-/g,'').replace('{','').replace('}',''):'null';
                     detailStyle.form.objId = obj.id;
                     detailStyle.form.attrs = obj.attr_list;
                     $this.detail1StyleDefList.push(detailStyle);
                    $this.activelist.push({active:false});
                   });
                   // console.log(this.detail1StyleDefList);
                   var jsonlist=[];
                   $this.detail1StyleDefList.forEach(attr=>{
                     jsonlist.push({
                       id:attr.info.id,
                       attrs: Object.keys(attr.info).map((a) => ({
                         attr: a,
                         value: attr.info[a] || "",
                       }))
                     });
                   });
                   // console.log(jsonlist);
                  var data_json = Base64.encode(JSON.stringify(jsonlist));
                   var eventid = $this.ListPageHtml_Show.event.id;
                   if (!$this.ListPageHtml_Show.event.id.includes('{'))
                      eventid = '{' + $this.ListPageHtml_Show.event.id + '}';
                   //HTML页面事件
                   $this.runCustomEvent({
                      ed_type: 0,
                      start_transaction: true,
                      class_id: $this.param.DataCls.id,
                      event_id: eventid,
                      data_json,
                   });
               }else{
                 // $this.detail1StyleDefList=[];
                 ret.result.obj_list.forEach((obj) => {
                  var styleStr = JSON.stringify($this.detail1_styledef);
                  var detailStyle = JSON.parse(styleStr);
                  // var info ={
                  //     S_ID:obj.id,
                  // };
                  obj.attr_list.forEach((attr) => {
                    // info[attr.name]=attr.value;
                    detailStyle.form.items.forEach(ele=>{
                     if(ele.name!='Layout'){
                       if(ele.fieldId == attr.name) ele.value = attr.value;
                     } else if(ele.name=='Layout'){
                       ele.setting.colList.forEach(col=>{
                        if(col){
                          if(col.fieldId == attr.name) col.value = attr.value;
                        }
                       });
                     }
                    });
                  });
                  detailStyle.form.htmlobjId = obj.id?obj.id.replace(/-/g,'').replace('{','').replace('}',''):'null';
                  detailStyle.form.objId = obj.id;
                  detailStyle.form.attrs = obj.attr_list;
                  $this.detail1StyleDefList.push(detailStyle);
                  $this.activelist.push({active:false});
                  //list.push(info);
                 });
               }
               // 解决view层不同步的问题
               // $this.scrollTop = $this.old.scrollTop;
               $this.isScroll=false;
               setTimeout(function(){
                  $this.isScroll=true;
               },1000);
               // console.log($this.detail1StyleDefList);
            }
         }else{
            uni.showModal({title:"错误5",content:ret.err_msg,showCancel:false,confirmText:"取消"});
         }
      }).catch(ex=>{
         // console.log(ex);
         uni.showModal({title:"错误5.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
      });
     } catch (ex) {
       var tip = typeof ex == "string" ? ex : ex.message;
      uni.showModal({title:"错误5.2",content:tip,showCancel:false,confirmText:"取消"});
     }
   },
   //刷新
   Refresh(value){
     //刷新当前页面
     // location.reload();
     uni.redirectTo({
        url:'../modal/3200?param='+JSON.stringify(this.$data.param)+"&titlename="+this.$data.title
     });
   },
   //点击显示浏览对象显示页面
   async onViewPageClick(style){
     if(this.param.ViewPage){
        if(this.param.ViewPage.View_UIDef){
         this.styledef = style;
         var $this = this;
         uni.navigateTo({
            url:'../modal/3200_view?param='+JSON.stringify(this.param)+"&titlename="+this.title+"&style="+JSON.stringify(style),
            events: {
                // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
                ExitViewEvent: function(data) {
                  console.log(data);
                 //退出页面后事件
                 var eventid = $this.param.ViewPage.Exit_View_Event?.id;
                 if(eventid){
                   try {
                    var obj_attr = {'S_ID':$this.styledef.form.objId};
                     $this.styledef.form.attrs.forEach((attr) => {
                      obj_attr[attr.name]=attr.value;
                     });
                     // console.log(obj_attr);
                     var input_param = Base64.encode(JSON.stringify(obj_attr));
                     $this.runCustomEvent({
                         ed_type: 0,
                       start_transaction: true,
                         class_id: $this.param.DataCls.id,
                         event_id: eventid,
                         obj_attr,
                         input_param,
                     });
                   } catch (ex) {
                     var tip = typeof ex == "string" ? ex : ex.message;
                     uni.showModal({title:"错误",content:tip,showCancel:false,confirmText:"取消"});
                   }
                 }
                }
            },
         });
      }
     }
   },
   //点击按钮
   onBtnClick(btn,style){
     var that = this
     if (btn.Prompt) {
      uni.showModal({
        title: '提示',
        content: btn.PromptContent || "是否确定?",
        success: function (res) {
          if (res.confirm) {
             that.onButtonClicked(btn,style);
          // } else if (res.cancel) {
          //    console.log('用户点击取消');
          }
        }
      });
     } else that.onButtonClicked(btn,style);
   },
   //点击按钮列表
   actionSheetTap() {
        var that = this
      var itemlist=[];
      this.param.ListPage.Page_Button.forEach((btn) => {
         itemlist.push(btn.ShowName);
      });
        uni.showActionSheet({
           // title: '按钮列表',
           itemList: itemlist,
           success: (e) => {
              console.log(e.tapIndex);
              var btn = that.param.ListPage.Page_Button[e.tapIndex];
              if (btn.Prompt) {
               uni.showModal({
                  title: '提示',
                  content: btn.PromptContent || "是否确定?",
                  success: function (res) {
                     if (res.confirm) {
                        that.onButtonClicked(btn);
                     // } else if (res.cancel) {
                     //    console.log('用户点击取消');
                     }
                  }
               });
              } else that.onButtonClicked(btn);
           }
        })
   },
   //处理相关按钮
   async onButtonClicked(btn,style) {
      style = style || '';
     try {
       var enviroment = {
         button: "top",
         button_name: btn.ShowName,
         cls_id: btn.Cls_ID,
         function: "3200",
         master: {},
       };
       if (btn.FunCode == "Add" || btn.FunCode == "Modify") {
         if (btn.Edit_dlg.Model == "small"){
           this.showAddSmallDialog(btn, style, enviroment);
        }
       } else if (btn.FunCode == "Delete") {
         this.DeleteObj(btn, style, enviroment);
       // } else if (btn.FunCode == "TriggerEvent") {
       //   this.triggerEvent(btn, style, enviroment);
       } else {
        uni.showModal({title:"提示",content:"未实现",showCancel:false,confirmText:"取消"});
       }
     } catch (ex) {
       var tip = typeof ex == "string" ? ex : ex.message;
      uni.showModal({title:"错误",content:tip,showCancel:false,confirmText:"取消"});
     }
   },
   //新增修改小窗口数据
   showAddSmallDialog(btn, style, enviroment){
      var data={
         Add_BtnName: btn.ShowName,
         EditDlgMode: btn.Edit_dlg.Model,
         clsid: this.param.DataCls.id,
         cls_name:  this.param.DataCls.name,
         Edit_dlg: btn.Edit_dlg
      };
      var $this = this;
      uni.navigateTo({
         url:'../modal/3018?param='+JSON.stringify(data)+"&titlename="+btn.Edit_dlg.Name+"&type=addDataObj",
         events: {
             // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
             addDataObj: function(data) {
               console.log(data);
              $this.Refresh();
            },
         }
      });
   },
   //删除数据对象
   DeleteObj(btn, style, enviroment){
     // console.log(style);
     var $this = this;
     uni.showModal({
        title: '提示',
        content: '确定删除该数据!',
        success: function (res) {
           if (res.confirm) {
            var objID=style.form.objId;
            if(!style.form.objId.includes('{')) objID = '{'+style.form.objId+'}';
            var dataInfo={
               class_id: btn.Cls_ID,
               class_name: '',
               obj_id: objID
            };
            // console.log(dataInfo);
            $this.$store.dispatch('dataObjDel',dataInfo).then(ret=>{
               // console.log(ret);
               if (ret.err_code == 0) {
                  //执行后处理事件
                  $this.AfterProcess_Event(btn.clsId, btm.AfterProcess_Event, enviroment);
                  //清除当前列表数据
                  $this.detail1StyleDefList.forEach((ele,index)=>{
                    if(ele.form.objId == objID){
                      $this.detail1StyleDefList.splice(index,1);
                    }
                  });
                  uni.showModal({title:"提示",content:"删除成功!",showCancel:false,confirmText:"取消"});
               }else{
                  uni.showModal({title:"错误6.1",content:ret.err_msg,showCancel:false,confirmText:"取消"});
               }
            }).catch(ex=>{
               // console.log(ex);
               uni.showModal({title:"错误6",content:ex.errMsg,showCancel:false,confirmText:"取消"});
            });
           } else if (res.cancel) {
           }
        }
     });
   },
   //执行后处理事件
   async AfterProcess_Event(clsId, afterProcess_Event, enviroment){
     try {
       if (afterProcess_Event.ID) {
         //执行后处理事件
         await this.runCustomEvent({
               ed_type: 0,
            start_transaction: true,
               class_id: clsId,
               event_id: afterProcess_Event.ID,
           });
       }
     } catch (ex) {
       var tip = typeof ex == "string" ? ex : ex.message;
      uni.showModal({title:"错误7",content:tip,showCancel:false,confirmText:"取消"});
     }
   },
   ontap(item){ //扫码功能
      // var $ele = e;
      //console.log(e.target)
      getApp().onScan((result)=>{
         console.log(result.decodedata);
         item.value = result.decodedata;
         uni.hideKeyboard();
         var $this = this;
         console.log(item);
         if(item.oldvalue != item.value){
             item.oldvalue = item.value;
            var attr = item.fieldId;
            this.head_styledef.form.model[attr] = item.value;
            var onChangeEvent = item.bind.onChangeEvent;   //内容变化后事件
            var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent;   //后图标点击事件
            var onSuffixClickEvent = item.bind.onSuffixClickEvent;   //后图标点击回调
            var isflag = false;
             if(onChangeEvent.id){   //内容变化后事件
               $this.onChange(onChangeEvent);
             } else{
              $this.where ='';
              if(item.value)
               $this.where =item.fieldId+" like '%"+item.value+"%'";
              $this.query_id='';
              $this.pageindex = 1;
              $this.detail1StyleDefList=[];
              $this.loadDataGetList();
            }
            if(item.value){ //第一个输入框不为空
               $this.focusMateria = true; //初始化,第二个输入框focus属性
               // setTimeout(function(){
               //    $this.focusMateria=true; //第二个输入框获取焦点
                  setTimeout(function(){
                     uni.hideKeyboard();
                  },100);
               // },500);
            }
             // if(onSuffixClickCallbackEvent.id){   //后图标点击事件
             //   this.onSuffixClick(onSuffixClickCallbackEvent);
             // }
             // if(onSuffixClickEvent.id){   //后图标点击回调
             //   this.onSuffixClickCallback(onSuffixClickEvent);
             // }
         }
      })
   },
   onEnterChange(item){ //回车,点击按钮,取消节点事件
      // console.log(item);
      if(item.oldvalue != item.value){
          item.oldvalue = item.value;
         var attr = item.fieldId;
         this.head_styledef.form.model[attr] = item.value;
         var onChangeEvent = item.bind.onChangeEvent;   //内容变化后事件
         var onSuffixClickCallbackEvent = item.bind.onSuffixClickCallbackEvent;   //后图标点击事件
         var onSuffixClickEvent = item.bind.onSuffixClickEvent;   //后图标点击回调
         var isflag = false;
          if(onChangeEvent.id){   //内容变化后事件
            this.onChange(onChangeEvent);
          } else{
           this.where ='';
           if(item.value)
            this.where =item.fieldId+" like '%"+item.value+"%'";
           this.query_id='';
           this.pageindex = 1;
           this.detail1StyleDefList=[];
           this.loadDataGetList();
         }
          // if(onSuffixClickCallbackEvent.id){   //后图标点击事件
          //   this.onSuffixClick(onSuffixClickCallbackEvent);
          // }
          // if(onSuffixClickEvent.id){   //后图标点击回调
          //   this.onSuffixClickCallback(onSuffixClickEvent);
          // }
      }
   },
   // 内容变化后事件
   async onChange(event) {
       try {
           if (event.id) {
             var obj_attr = this.head_styledef.form.model;
             // console.log(obj_attr);
             var input_param = Base64.encode(
               JSON.stringify(
                 Object.keys(obj_attr).map((a) => ({
                   attr: a,
                   value: obj_attr[a] || "",
                 }))
               )
             );
           var $this = this;
           var dataInfo={
               ed_type: 0,
            start_transaction: true,
               class_id: this.$data.head_styledef.form.clsId,
            class_name: '',
               event_id: event.id,
            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,
             };
           this.$store.dispatch('runCustomEvent',dataInfo).then(ret=>{
              // console.log(ret);
              if (ret.err_code == 0) {
               var result = ret.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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                   else uni.showModal({title:'提示',content:tip+',提示:'+result.ret,showCancel:false,confirmText:"取消"});
                  return false;
               }else{
                  var tip = result.info ? typeof result.info == 'string' ? result.info : result.info.join('<br/>') : '';
                  if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                  if(result.result_type == 0 && result.action){
                     result.action.forEach(item=>{
                        if(item.action_type == "set_dlg_attr"){
                          // value = {"attr":"xxx", "value":"xxx"}
                          var data = item.value;
                          $this.$data.head_styledef.form.items.forEach(async (ele,index) => {
                            data.forEach(async (ele2,index) => {
                              if(ele.fieldId == ele2.attr){
                                ele.value = ele2.value;
                              }
                            });
                          });
                        }
                     });
                  }else{
                     // this.detail2StyleDefList=[];
                     if(result.info){
                        uni.showModal({title:"提示",content:result.info,showCancel:false,confirmText:"取消"});
                     }
                  }
               }
              }else{
                 uni.showModal({title:"错误8",content:ret.err_msg,showCancel:false,confirmText:"取消"});
              }
           }).catch(ex=>{
              // console.log(ex);
              uni.showModal({title:"错误8.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
           });
           }
       } catch (ex) {
           var tip = typeof ex == "string" ? ex : ex.message;
         uni.showModal({title:"错误8.2",content:"执行“内容变化后”事件失败:" + tip,showCancel:false,confirmText:"取消"});
       }
   },
   //点中表单
   onPanelClick(value){ //点击面板高亮显示
      // console.log(value);
       this.activelist.forEach(ele=>{
           ele.active = false;
       });
       this.activelist[value].active = true;
   },
   //事件处理
   async runCustomEvent(dataInfo) {
       try {
         var $this = this;
         this.$store.dispatch('runCustomEvent',dataInfo).then(ret=>{
              console.log(ret);
              if (ret.err_code == 0) {
               var result = ret.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) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                   else uni.showModal({title:'提示',content:tip+',提示:'+result.ret,showCancel:false,confirmText:"取消"});
                  return false;
               }else{
                  var tip = result.info ? typeof result.info == 'string' ? result.info : result.info.join('<br/>') : '';
                  if (tip) uni.showModal({title:'提示',content:tip,showCancel:false,confirmText:"取消"});
                  if(result.result_type == 0 && result.action){
                     result.action.forEach(item=>{
                        if(item.action_type == "goback_to_pre_page"){ //返回上一页
                           var value = item.value;
                           uni.navigateBack({
                              delta:1 ,//返回层数,2则上上页
                           });
                        } else if(item.action_type == "hidden_button"){ //隐藏按钮
                           var value = item.value;
                           value.forEach(btn => {
                               var index = $this.param.ListPage.Page_Button.findIndex(button => button.ShowName == btn)
                               if (index > -1)
                                 $this.param.ListPage.Page_Button.splice(index, 1)
                           })
                        // } else if(item.action_type == "refresh_cur_row"){ //
                        //    var value = item.value;
                        } else if (item.action_type == "set_panel_html") { //显示Html页面
                           // var value = item.value;
                           $this.ListHtml_Panel = item.value;
                           // $this.detail1StyleDefList.forEach((ele,index)=>{
                           //    ele.ListHtml_Panel = item.value[index];
                           // });
                        } else{
                           uni.showModal({title:"提示",content:"当前action_type:"+item.action_type+"未处理",showCancel:false,confirmText:"取消"});
                        }
                     });
                  }else{
                     // this.detail2StyleDefList=[];
                     if(result.info){
                        uni.showModal({title:"提示",content:result.info,showCancel:false,confirmText:"取消"});
                     }
                  }
               }
              }else{
                 uni.showModal({title:"错误9",content:ret.err_msg,showCancel:false,confirmText:"取消"});
              }
         }).catch(ex=>{
              // console.log(ex);
              uni.showModal({title:"错误9.1",content:ex.errMsg,showCancel:false,confirmText:"取消"});
         });
       } catch (ex) {
           var tip = typeof ex == "string" ? ex : ex.message;
         uni.showModal({title:"错误9.2",content:"执行事件失败:" + tip,showCancel:false,confirmText:"取消"});
       }
   },
   cancel(e){ //取消
      var eventChannel = this.$scope.eventChannel;
      // const eventChannel = this.getOpenerEventChannel();
      eventChannel.emit('view_3201',"");
      uni.navigateBack({
         delta:1 ,//返回层数,2则上上页
      });
   },
   /**
    * 只支持["column1='A' or column2='B'", "column3='C' and column4='D'", "column5='E'"]这种格式
    * {
    *     "model": 0 / 1,
    *     "condition":
    *     [
    *         [
    *             { },
    *             { },
    *             { }
    *         ],
    *         [
    *             { }
    *         ],
    *         [
    *             { }
    *         ]
    *     ]
    * }
    */
   toWhereBase64String(list) {
       if (typeof list == 'string') list = [list]
       var sql = []
       var seps = [' not in', ' in', '<>', '!=', '<=', '>=', '<', '=', '>', ' like']
       list.forEach(ls => {
           var where = ls.trim().toLowerCase()
           if (where.startsWith('(') && where.endsWith(')')) where = where.replace(/^\(/, '').replace(/\)$/, '')
           if (where.includes(' and ')) {
               // 二级and放在第一级数组中
               where.split(' and ').forEach(li => {
                   var l = li.trim()
                   if (l.startsWith('(') && l.endsWith(')')) l = l.replace(/^\(/, '').replace(/\)$/, '')
                   var sep = ''
                   for (var i = 0; i < seps.length; i++) {
                       if (l.includes(seps[i])) {
                           sep = seps[i]
                           break
                       }
                   }
                   if (sep) {
                       var values = l.split(sep)
                       var field = values[0]?.trim().replace(/^\[/, '').replace(/\]$/, '')
                       var value = ''
                       var op = sep.trim()
                       if ([' in', ' not in'].includes(sep) && values[1].includes('select ') && values[1].includes(' from ')) {
                           value = l.replace(field, '').replace(/^\s*(in|not in)\s*/, '').trim()
                           if (value.startsWith('(') && value.endsWith(')')) value = value.replace(/^\(/, '').replace(/\)$/, '').trim()
                       }
                       else {
                           value = values[1]?.trim().replace(/^\'/, '').replace(/\'$/, '')
                           if (['in', 'not in'].includes(op)) {
                               value = value.replace(/^\(/, '').replace(/\)$/, '')
                               value = value.split(',').map(v => v.trim().replace(/^\'/, '').replace(/\'$/, ''))
                           }
                       }
                       sql.push([{ field, value, op }])
                   }
               })
           }
           else if (where.includes(' or ')) {
               // 二级or放在第二级同一组数组中
               var s = []
               where.split(' or ').forEach(li => {
                   var l = li.trim()
                   if (l.startsWith('(') && l.endsWith(')')) l = l.replace(/^\(/, '').replace(/\)$/, '')
                   var sep = ''
                   for (var i = 0; i < seps.length; i++) {
                       if (l.includes(seps[i])) {
                           sep = seps[i]
                           break
                       }
                   }
                   if (sep) {
                       var values = l.split(sep)
                       var field = values[0]?.trim().replace(/^\[/, '').replace(/\]$/, '')
                       var value = ''
                       var op = sep.trim()
                       if ([' in', ' not in'].includes(sep) && values[1].includes('select ') && values[1].includes(' from ')) {
                           value = l.replace(field, '').replace(/^\s*(in|not in)\s*/, '').trim()
                           if (value.startsWith('(') && value.endsWith(')')) value = value.replace(/^\(/, '').replace(/\)$/, '').trim()
                       }
                       else {
                           value = values[1]?.trim().replace(/^\'/, '').replace(/\'$/, '')
                           if (['in', 'not in'].includes(op)) {
                               value = value.replace(/^\(/, '').replace(/\)$/, '')
                               value = value.split(',').map(v => v.trim().replace(/^\'/, '').replace(/\'$/, ''))
                           }
                       }
                       sql.push([{ field, value, op }])
                   }
               })
               sql.push(s)
           }
           else {
               var li = where
               // 单一查询条件直接放在第一级数组中
               var l = li.trim()
               if (l.startsWith('(') && l.endsWith(')')) l = l.replace(/^\(/, '').replace(/\)$/, '')
               var sep = ''
               for (var i = 0; i < seps.length; i++) {
                   if (l.includes(seps[i])) {
                       sep = seps[i]
                       break
                   }
               }
               if (sep) {
                   var values = l.split(sep)
                   var field = values[0]?.trim().replace(/^\[/, '').replace(/\]$/, '')
                   var value = ''
                   var op = sep.trim()
                   if ([' in', ' not in'].includes(sep) && values[1].includes('select ') && values[1].includes(' from ')) {
                       value = l.replace(field, '').replace(/^\s*(in|not in)\s*/, '').trim()
                       if (value.startsWith('(') && value.endsWith(')')) value = value.replace(/^\(/, '').replace(/\)$/, '').trim()
                   }
                   else {
                       value = values[1]?.trim().replace(/^\'/, '').replace(/\'$/, '')
                       if (['in', 'not in'].includes(op)) {
                           value = value.replace(/^\(/, '').replace(/\)$/, '')
                           value = value.split(',').map(v => v.trim().replace(/^\'/, '').replace(/\'$/, ''))
                       }
                   }
                   sql.push([{ field, value, op }])
               }
           }
       })
       if (sql.length > 0)
           return Base64.encode(JSON.stringify({
               model: 1,
               condition: sql
           }))
       else
           return ''
   }
  },
};
</script>