<wxs module="m1">

  var hasAuth = function (array, auth) {
    return array.indexOf(auth) !== -1;
  }
  module.exports.hasAuth = hasAuth;

  var defineIndexOf = function (str, val) {
    if (str != null) {
      return str.indexOf(val);
    }
  }
  module.exports.defineIndexOf = defineIndexOf;

  var getInfoNum = function (array, infos, val) {
    var num;
    if (array.indexOf(val) >= 0) {
      for (var i = 0; i < infos.length; i++) { if (infos[i].code === val) { num = infos[i].num; break; } }
    } return num
  }
  module.exports.getInfoNum = getInfoNum; 
</wxs>
<wxs src='/utils/wxmlUtil.wxs' module="wxmlUtil"></wxs>
<!-- loading -->
<van-notify id="van-notify" />
<loading wx:if="{{loadingShow}}" loadingName="加载中" backgroundColor="#f2f2f2;" opacity="0.8"></loading>
<!--选择功能分区-->
<van-sticky scroll-top="0">
  <view class="menu-box">
    <view style="width:32%;background:white;">
      <van-dropdown-menu>
        <van-dropdown-item id="functionItem" title-class="title-class" title="{{ functionItem.text }}">
          <dk-dropdown-switch dataList="{{functionRegion}}" bind:commit='dropdowncommit'></dk-dropdown-switch>
        </van-dropdown-item>
      </van-dropdown-menu>
    </view>
    <view style="width:69%;background:white;display:flex; align-items: center;">
      <van-search field-class="field-class" custom-class="custom-class" model:value="{{ allCondition }}" bind:change="filterFunction" use-action-slot input-align="center" placeholder="搜索菜单" />
    </view>
  </view>
</van-sticky>

<!-- 常用应用 -->
<view wx:if="{{bingFlag == 0 }}">
  <view class="panel-class">
    <view class="app-name" style="display: flex;justify-content: space-between;line-height: 30rpx;">
      <view style="display: flex;width: 100%;align-items: center;">
        <view class="title-label-class">常用应用 </view>
        <!--图标-->
        <view style="display: flex;width: 75%;" bindtap='expand'>
          <view wx:if="{{!showMore}}" style="display: flex;margin-left: 10rpx;">
            <view style="margin-left: 2rpx;" wx:for="{{comMenuList}}" wx:for-item="item" data-code="{{item.menuUuid}}" data-url="{{item.objectPath}}" wx:key="i">
              <image src="{{item.objectIcon?(imageUrl + item.objectIcon):''}}" style="height: 30rpx;width:30rpx;"></image>
            </view>
          </view>
          <view wx:if="{{showMore}}" class="expand-class">
            <dk-text  bindtap='expand'  fontSize="12px" color="#95A8CB" fontWeight="nomal" value="{{editTip}}"></dk-text>
            <van-icon size="12px" name="arrow-up" />
          </view>
          <view wx:else class="expand-class">
            <van-icon size="12px" name="arrow-down" />
          </view>
        </view>
      </view>
      <dk-tag wx:if="{{editFlag}}" style="margin-right: 5rpx;" type="default" padding="0 20rpx" height="40rpx" textColor="#FFFFFF" radius="5rpx" roundFlag="{{true}}" value="{{'取消'}}" catchtap="cancel"></dk-tag>
      <dk-tag type="primary" padding="0 20rpx" height="40rpx" color="#1E90FF" textColor="#FFFFFF" radius="5rpx" roundFlag="{{true}}" value="{{editFlag?'保存':'编辑'}}" catchtap="toEdit"></dk-tag>
    </view>
    <view wx:if="{{showMore}}" style="background: #fff;border-radius: 15rpx;">
      <view style="flex-wrap: wrap;padding: 43rpx 0;align-items: center;height: {{wxmlUtil.ceiling(comMenuList.length/size)*160 + 'rpx'}};">
        <dk-drag id="drag" imageCol="objectIcon" titleCol="menuName" generic:item="drag-item" bind:click="comItemClick" bind:sortend="dragEnd" list-data="{{comMenuList}}" columns="{{size}}"  editFlag="{{editFlag}}">
        </dk-drag>
        <!-- <view class="app-item "  
        style="width:25%;text-align: center;" wx:for="{{comMenuList}}" wx:for-item="item" data-item="{{item}}" data-code="{{item.menuUuid}}" data-url="{{item.objectPath}}" data-com="{{true}}" bindtap="toApp" wx:key="i" >
          <view style="display: flex;justify-content: center;">
            <image src="{{item.objectIcon?('/static/img/' + item.objectIcon):''}}" style="height: 80rpx;width:80rpx;margin-bottom: 11rpx;"></image>
            <view style="margin-left: -6rpx; margin-top: -20rpx" wx:if="{{editFlag  }}">
              <van-icon size="15px" name="clear" color="#D3D3D3" />
            </view>
          </view>
          <view class="index-grid-item-text-class">{{item.menuName}}</view>
        </view> -->
      </view>
    </view>
  </view>
</view>

<!-- 应用集合 -->
<view wx:if="{{bingFlag == 0 }}">
  <view class="panel-class" wx:for="{{regions}}" data-item="{{item}}" wx:key="index" title="{{item.FunctionName}}" wx:if="{{m1.hasAuth(functionRegions,item.FunctionName)}}">
    <view class="app-name">{{item.FunctionName}}
      <image wx:if="{{item.FunctionName == '资金管理' || item.FunctionName == '经营分析'}}" src="{{imageUrl + 'diamond.png'}}" class="icon-title_diamond" />
    </view>
    <view style="background: #fff;border-radius: 15rpx;">
      <view style="display: flex;flex-wrap: wrap;padding: 43rpx 0;">
        <view class="app-item" style="width:25%;text-align: center;" icon-class="index-grid-item-icon-class" text-class="index-grid-item-text-class" content-class="index-grid-item-class" wx:for="{{functionItems}}" wx:for-item="item2" data-code="{{item2.FunctionCode}}" wx:if="{{item.FunctionCodeOrder==item2.PFunctionCode}}" data-url="{{item2.FormName}}" data-item="{{item2}}" bindtap="toApp" wx:key="i" info="{{m1.getInfoNum(infocodes,infos,item2.FunctionCode)}}">
        <view wx:if="{{item2.isVip}}" class="vip-icon-view">
          <image src="{{imageUrl + 'diamond.png'}} " class="icon-title_diamond" />
        </view>
          <view style="display: flex;justify-content: center;margin-left: {{editFlag?'20rpx':''}};">
            <image src="{{item2.ImageUri}}" style="height: 80rpx;width:80rpx;margin-bottom: 11rpx;"></image>
            <view style="margin-left: -6rpx; margin-top: -20rpx" wx:if="{{editFlag && !m1.hasAuth(comMenuListForCheck,item2.FunctionCode) }}">
              <van-icon size="15px" name="add" color="#1E90FF" />
            </view>
          </view>
          <view class="index-grid-item-text-class" >{{item2.FunctionName}}</view>
        </view>
      </view>
    </view>
  </view>
</view>