<page-plugin isAuth="{{authInfo['SF_ERP_STAFF_VIEW']}}" loading="{{loading}}" is-login="{{isLogin}}"
  bind:handleLogin="handleLogin">
  <search-popup placeholder="输入员工账号" bind:change="searchChange" bind:ok="searchOk"
    bind:reset="searchReset" value="{{params.login_name}}" data-key="login_name">
    <view slot="content">
      <search-input label="手机" value="{{params.user_phone}}" data-key="user_phone"
        bind:change="searchChange" />

      <option-cell-plugin title="组织架构" value="{{params.department_id || ''}}"
        bind:change="searchChange" mode="radio" options="{{depOption}}" data-key="department_id" />
      <option-cell-plugin title="组织架构" value="{{params.group_id || ''}}" bind:change="searchChange"
        mode="radio" options="{{groupsOption}}" data-key="group_id" />

      <!-- <date-picker-plugin title="创建开始日期" value="{{params.create_dateL}}" data-key="create_dateL"
        bind:confirm="searchChange" />
      <date-picker-plugin title="创建结束日期" value="{{params.create_dateU}}" data-key="create_dateU"
        bind:confirm="searchChange" /> -->
    </view>
  </search-popup>

  <count-plugin count="{{count}}">
    <view slot="left">
      <t-button size="small" theme="{{params.state == '-1' ? '': 'primary'}}" class="btn-left"
        bind:tap="onSearchState" data-key="">在职员工</t-button>
      <t-button size="small" theme="{{params.state == '-1' ? 'primary': ''}}" class="btn-right"
        bind:tap="onSearchState" data-key="-1">离职员工</t-button>
    </view>
    <sort-plugin options="{{sort}}" bind:ok="onSort" value="{{params.order}}" slot="right" />
  </count-plugin>
  <empty-plugin wx:if="{{list.length == 0}}" />
  <card-plugin wx:for="{{ list }}" wx:key="staff_id" showAll="{{true}}">
    <view slot="header"
      style="display: flex;justify-content: space-between;align-items: center;width: 100%;">
      <view style="word-break: break-all;">
        {{ item.login_name }}
        <text wx:if="{{item.nick_name}}">({{item.nick_name}})</text>
      </view>
      <view style="font-weight: normal;color: #999;flex-shrink: 0;display: flex;">
        {{ item.state== 1 ? '正常' : '禁用'}}
      </view>
    </view>
    <view slot="content">
      <card-item-plugin label="手机" value="{{item.user_phone}}" />
      <card-item-plugin label="部门" value="{{item.dep_name}}" />
      <card-item-plugin label="岗位" value="{{item.group_name}}" />
      <card-item-plugin label="创建日期" value="{{item.create_date}}" />
    </view>
    <view slot="footer" class="card-plugin-footer">
      <block wx:if="{{item.state == -1}}">
        <t-button wx:if="{{authInfo['SF_ERP_STAFF_EDIT']}}" size="small" theme="primary"
          bind:tap="onReinstatedStaff" data-index="{{index}}">复职</t-button>
      </block>
      <block wx:else>
        <t-button wx:if="{{user_id != item.user_id && authInfo['SF_ERP_STAFF_FIRE']}}" size="small"
          theme="danger" bind:tap="onFireStaff" data-index="{{index}}">解雇</t-button>
        <t-button wx:if="{{authInfo['SF_ERP_STAFF_EDIT']}}" size="small"
          theme="{{ item.state== 1 ? 'danger' : 'primary'}}" bind:tap="onStaffState"
          data-index="{{index}}">{{ item.state== 1 ? '禁用' : '启用'}}</t-button>
      </block>
    </view>
  </card-plugin>
  <pagination-plugin curr_page="{{params.curr_page}}" page_count="{{params.page_count}}"
    total="{{count}}" bind:change="paginationChange" />
</page-plugin>