<page-plugin
  is-login="{{isLogin}}"
  is-auth="{{authInfo['SF_ENTER_PROCESS']}}"
  loading="{{loading}}"
  bind:handleLogin="handleLogin"
  customStyle="padding: 0;"
>
  <view class="container">
    <view style="display: flex;padding: 12px 12px 4px 12px;">
      <view style="display: flex;flex-shrink: 0;flex-direction: column;margin-right: 12px;align-items: flex-end;">
        <view style="margin-bottom: 4px;font-weight: bold;">工序：</view>
        <view>
          <t-checkbox style="padding: 0;" value="{{ backFlag }}" bind:change="backChange">撤回</t-checkbox>
        </view>
      </view>
      <view style="display: flex;flex-wrap: wrap;min-height: 44px;max-height: 88px;overflow: auto;flex: 1;">
        <view wx:if="{{processItems.length == 0}}" style="display: flex;justify-content: center;height: 100%;width: 100%;align-items: center;color: #999;">暂无工序
        </view>
        <block wx:for="{{processItems}}" wx:key="process_id">
          <view class="process-item {{item.code == selectedProcessCode || (item.code + '-') == selectedProcessCode ? 'active': ''}}" bind:tap="processItemTap" data-code="{{item.code}}">{{item.name}}</view>
        </block>
      </view>
    </view>
    <t-input
      label="订单编号"
      value="{{rel_order_no}}"
      readonly
      placeholder="扫码流程编码, 订单编号"
    />
    <t-input label="流程编码" readonly value="{{process_code}}" />

    <view wx:if="{{processCodeMsg}}" style="padding: 8px 12px 0 12px;color: {{action == 'end'? '#52c41a': '#ff4d4f'}};">
      {{processCodeMsg}}
    </view>
    <view style="padding: 12px;padding-top: 0;">
      <view style="display: flex;justify-content: center;margin-top: 12px;align-items: center;column-gap: 16px;">
        <t-button theme="primary" bind:tap="scanCode" icon="qr">扫码</t-button>
        <t-button theme="primary" disabled="{{!(rel_order_no && process_code)}}" bind:tap="processEnter">流程录入</t-button>
        <!-- <view style="width: 16px;"></view> -->
        <!-- <van-checkbox value="{{voice}}" bind:change="voiceChange">语音播报</van-checkbox> -->
      </view>
    </view>

    <view class="log-header">
      <!-- <text>扫码记录</text> -->
      <text bind:tap="addMsg2">扫码结果</text>
      <view>
        <t-button
          size="extra-small"
          theme="{{logType == '0' ? 'primary' :'default'}}"
          bind:tap="onLogTypeChange"
          data-key="0"
        >图标
        </t-button>
        <t-button
          size="extra-small"
          theme="{{logType == '1' ? 'primary' :'default'}}"
          bind:tap="onLogTypeChange"
          data-key="1"
        >记录
        </t-button>
      </view>
      <!-- <t-button size="extra-small" theme="primary" bind:tap="clearMsg">清空</t-button> -->
    </view>
    <view wx:if="{{logType == 0}}" class="log-box" style="display: flex;justify-content: center;align-items: center;font-size: 65vw;">
      <!-- <view wx:for="{{logsList}}" wx:for-item="item" wx:key="date" style="font-size: 14px;word-break: break-all;margin-bottom: 8px;width: 100%;align-items: flex-start;">
        {{item.date}}
        {{item.msg}}
      </view> -->
      <t-icon wx:if="{{result == 'success'}}" name="check" style="color: #07c160;" />
      <t-icon wx:elif="{{result == 'error'}}" name="close" style="color: #ee0a24;" />

    </view>
    <view wx:else class="log-box">
      <view
        wx:for="{{logsList}}"
        wx:for-item="item"
        wx:key="date"
        style="word-break: break-all;margin-bottom: 8px;width: 100%;align-items: flex-start;"
      >
        <text style="color: #666;margin-right: 4px;">{{item.date}}</text>
        {{item.msg}}
      </view>
    </view>
    <popup-plugin visible="{{ show }}" bind:close="onClose" title="订单流程完成">
      <!-- <view wx:for="{{orders}}" wx:key="rel_order_no"
      style="border: 1rpx solid #ddd;border-radius: 4px;display: flex;flex-direction: column;margin-bottom: 12px;">
      <view style="padding: 8px;">
        <list-item label="流程单号" value="{{item.rel_order_no}}" />
        <list-item label="流程名称" value="{{item.p_process_name}}" />
        <list-item label="自定义名称" wx:if="{{item.process_custom_no}}" value="{{item.process_custom_no}}" />
        <list-item label="工序名称" value="{{item.c_process_name}}" />
        <list-item label="材料名称" wx:if="{{item.sale_info_str}}" value="{{item.sale_info_str}}" />
        <list-item wx:if="{{item.product_info_str}}" label="房柜名称" value="{{item.product_info_str}}" />
        <list-item label="状态" value="{{item.state== 2 ? '已完成' :''}}" />
      </view>
      <view style="display: flex;border-top: 1rpx solid #ddd;padding: 8px;justify-content: center;">
        <block wx:if="{{action == 'end'}}">
          <t-button size='small' type="primary" data-index="{{index}}" bind:tap="LCProcessEnter">完成</t-button>
        </block>
        <block wx:else>
          <t-button size='small' type="danger" data-index="{{index}}" bind:tap="LCProcessEnter">撤回</t-button>
        </block>
      </view>
    </view> -->
    </popup-plugin>

    <!-- <popup-plugin show="{{ showDefaultBonus }}" bind:close="closeDefaultBonusHandle" title="选择提成配置">
    <view class="table">
      <view class="tr">
        <view class="th">自定义字段</view>
        <view class="th">提成编码</view>

        <view class="th" style="width: 80px;">操作</view>
      </view>
      <block wx:for="{{defaultBonusConfigKeys}}" wx:key="index" wx:for-item="key">
        <view wx:for="{{defaultBonusConfig[key]}}" class="tr" wx:key="key">
          <view class="td">{{item.key}}</view>
          <view class="td">{{item.bonus_code}}</view>

          <view class="td">
            <t-button size="small" type="primary" data-order_no="{{key}}" data-key="{{item.bonus_code}}"
              bind:tap="onSelectBonus">选择</t-button>
          </view>
        </view>
      </block>
    </view>
  </popup-plugin> -->
  </view>

</page-plugin>
<tab-bar-plugin active="scan" />

