<!--pages/workOrderDetail/index.wxml-->
<view style="padding:10px">
  <card>
    <view style="width: 35px;" slot="left">
      <view class="type">{{billData.type}}</view>
    </view>
    <view style="flex:1" slot="content">
      <view class="flex-column-between">
        <view>
          {{billData.province}}{{billData.city}}{{billData.county}}{{billData.address}}
        </view>
        <view class="colorInfo">
          指派日期:{{billData.createdate}}
        </view>
      </view>
    </view>
    <!-- <view slot="right" class="colorInfo small">
      <t-button size="extra-small" theme="light" bind:tap="addConfirmBill">发起服务确认单</t-button>
    </view> -->
  </card>
  <card>
    <view slot="content">
      <view style="margin-bottom: 5px;" class="small"><text class="label">工单编号:</text>{{billData.billno}}</view>
      <view style="margin-bottom: 5px;" class="small">
        <t-button size="extra-small" theme="light" bind:tap="toWorkConfirmInfo">查看工单确认信息</t-button>
      </view>
      <view style="margin-bottom: 5px;" class="small"><text class="label">现场联系人:</text>{{billData.scenecontact}}</view>
      <view class="small flex-align-center"><text class="label">联系电话:</text>
        <t-call phone="{{billData.scenecontactphonenumber}}">{{billData.scenecontactphonenumber}}</t-call>
      </view>
      <view class="small"><text class="label">岗位:</text>{{billData.scenecontactrole}}</view>
      <view class="small"><text class="label">开始时间:</text>{{billData.begdate}}</view>
      <view class="small"><text class="label">结束时间:</text>{{billData.enddate}}</view>
      <view style="margin-bottom: 5px;" class="small"><text class="label">业务员:</text>{{billData.saler_name ||" --"}}</view>
      <view class="small flex-align-center"><text class="label">联系电话:</text>
        <t-call wx:if="{{billData.salerphonenumber}}" phone="{{billData.salerphonenumber}}" />
        <text wx:else> --</text>
      </view>
    </view>
  </card>

  <view style="margin-bottom: 5px;display: flex;justify-content: space-between;" class="small"><text class="label">项目成员</text>
    <view wx:if="{{billData.status!='已完成'}}">
      <t-tag class="mt-5" style="margin-right: 8rpx;" variant="outline" theme="warning" variant="dark" bind:click="showTeamDialog">
        添加成员
      </t-tag>
      <t-tag class="mt-5" variant="outline" theme="warning" variant="dark" bind:click="showWorkerDialog">
        修改负责人
      </t-tag>
    </view>
  </view>

  <card>
    <view class="tags" slot="content">
      <t-tag class="mr-5 mt-5" wx:for="{{billData.team}}" wx:key="userid" variant="{{item.isleader === 1?'dark':'outline'}}" theme="{{item.isleader === 1?'primary':''}}">{{item.name}}</t-tag>
    </view>
  </card>

  <t-tabs defaultValue="{{0}}" bind:change="onTabsChange" bind:click="onTabsClick" t-class="custom-tabs">
    <t-tab-panel label="工单进度" value="0">

      <view wx:if="{{billData.actiontype=='非工序模板'}}">
        <view class="panel">
          <card style="margin-top:10px" wx:for="{{billData.titems}}" wx:key="itemid">
            <product-card style="flex:1" model='3' slot="content" data="{{item}}" changeQty="{{false}}" bind:delete="deleteMaterial" bind:input="qtyChange" bind:changeItem="changeItem" />
          </card>
        </view>
      </view>
      <view wx:else style="padding:10px">
        <view class="small mt-5" wx:for="{{billData.nodes}}" wx:key="sa_workorder_nodeid">
          {{index + 1}}.{{item.workpresetjson.workname}}
          <image-view isdelete="{{false}}" wx:if="{{item.attinfos.length > 0}}" list="{{item.attinfos}}"></image-view>
          <navigator url="{{'/Eservice/nodeDetail/index?class=stopClick&id=' + child.sa_workorder_nodeid + '&wid=' + id}}" class="textIndentNodeChild smallChild" wx:for="{{item.child}}" wx:key="sa_workorder_nodeid" wx:for-item="child" wx:for-index="childIndex">
            {{index + 1}}-{{childIndex + 1}}.{{child.workpresetjson.workname}}
            <image-view isdelete="{{false}}" wx:if="{{child.attinfos.length > 0}}" list="{{child.attinfos}}"></image-view>
            <view class="small">
              <text class="colorInfo">{{child.finishdate}}</text>
              <t-tag class="mr-5 mt-5" variant="dark" theme="{{child.status == 0?'danger':child.status == 1?'success':'primary'}}" size="small">{{child.status == 0?'未完成':child.status == 1?'完成':'进行中'}}</t-tag>
              <t-tag wx:if="{{child.finishby}}" class="mr-5 mt-5" variant="dark" theme="primary" size="small">{{child.finishby}}</t-tag>
            </view>
          </navigator>
          <t-divider dashed />
        </view>
      </view>
    </t-tab-panel>
    <t-tab-panel label="确认单" value="1">
      <t-cell wx:for="{{confirmBills}}" wx:key="sa_workorder_confirmationid" title="{{item.confirmationno}}" data-item="{{item}}" hover arrow bind:click="toConfirmBill"></t-cell>
    </t-tab-panel>
  </t-tabs>
</view>
<block wx:if="{{billData.status !== '作废'}}">
  <view style="height: 160rpx;" />
  <view class="footer">
    <view />
    <view class="but-box" bindtap="changeBillStatus">
      <van-button wx:if="{{billData.status !== '完成'}}" data-name="作废" data-id="20230209144803" custom-class='but abandon' bind:click="submit">作废</van-button>
      <van-button wx:if="{{billData.status === '进行中'}}" data-name="暂停" data-id="20230209144603" custom-class='but delete' bind:click="deleteItem">暂停</van-button>
      <van-button wx:if="{{billData.status === '暂停'}}" data-name="启用" data-id="20230209144703" custom-class='but' bind:click="notarize">启用</van-button>
    </view>
  </view>
</block>

<t-dialog id="t-dialog" />

<t-dialog visible="{{showTeams}}" title="参与成员" confirm-btn="确定" cancel-btn="取消" bind:confirm="addUser" bind:cancel="showTeamDialog">
  <view slot="content">
    <view style="height: 40rpx;" />
    <view>
      <block wx:for="{{workers}}" wx:key="rowindex">
        <t-tag wx:if="{{billData.projectleader!=item.name}}" class="mr-5 mt-5" variant="{{wqp.query(teams,item.userid)?'dark':'outline'}}" theme="primary" data-item="{{item}}" bindtap="selectTeams">{{ item.position?item.position + '-':'' }}{{ item.name }}</t-tag>
      </block>
    </view>
  </view>
</t-dialog>
<wxs src="../../../utils/wxmlQueryPer.wxs" module="wqp" />
<t-dialog visible="{{workLeaderDialog}}" title="转工单" confirm-btn="确定" cancel-btn="取消" bind:confirm="toWorker" bind:cancel="showWorkerDialog">
  <view slot="content">
    <view class="d-title">
      选择负责人:
    </view>
    <view>
      <block wx:for="{{workers}}" wx:key="rowindex">
        <t-tag class="mr-5 mt-5" variant="{{actLeader.userid === item.userid?'dark':'outline'}}" theme="primary" data-item="{{item}}" bindtap="selectLeader">{{ item.position?item.position + '-':'' }}{{ item.name }}</t-tag>
      </block>
    </view>
  </view>
</t-dialog>