<!--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 wx:if="{{billData.status!='待接单' &&billData.status!='待开始'}}" slot="right" class="colorInfo small">
      <t-button disabled="{{stopClick}}" 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 class="small"><text class="label">工单状态:</text><text style='color: var(--error);'>{{billData.status}}</text></view>
      <view style="margin-bottom: 5px;" class="small" wx:if="{{billData.status!='待接单' &&billData.status!='待开始'}}">
        <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>
  </card>
  <card>
    <view slot="content">
      <view 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;" class="small"><text class="label">项目成员</text></view>
  <card bindtap="checkTeam">
    <view 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="{{billData.status=='进行中'?2:3}}" slot="content" data="{{item}}" changeQty="{{false}}" bind:delete="deleteMaterial" bind:input="qtyChange" bind:changeItem="changeItem" />
          </card>
          <view wx:if="{{billData.status=='进行中'}}" style="width: 100%; text-align: center;">
            <t-button size="extra-small" variant="primary" bind:tap="addProduct">添加产品</t-button>
          </view>
        </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}}" />
          <navigator url="{{billData.status=='进行中'?('/Eservice/nodeDetail/index?id=' + child.sa_workorder_nodeid + '&wid=' + id +'&class=' + stopClick):'#'}}" class="textIndentNodeChild smallChild" wx:for="{{item.child}}" wx:key="sa_workorder_nodeid" bindtap="isStopToPage" 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}}" />
            <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">
      <view style="padding:10px;text-align:center;color:#999" wx:if="{{confirmBills.length === 0}}">
        暂无更多服务确认单
      </view>
      <t-cell wx:for="{{confirmBills}}" wx:key="sa_workorder_confirmationid" note="{{item.status}}" title="{{item.confirmationno}}" data-item="{{item}}" hover arrow bind:click="toConfirmBill"></t-cell>
    </t-tab-panel>
  </t-tabs>
</view>

<view style="height: 160rpx;" />
<view class="footer">
  <view wx:if="{{!stopClick}}" class="{{stopClick}}" style="padding:0 10px 10px 10px">
    <t-button wx:if="{{billData.status === '待接单'}}" theme="dark" variant="primary" data-id="20230210101103" bind:tap="changeBillStatus" block>接单</t-button>
    <t-button wx:if="{{billData.status === '待开始'}}" theme="dark" variant="primary" data-id="20230209144503" bind:tap="changeBillStatus" block>开始工单</t-button>
    <t-button wx:if="{{billData.status === '进行中'}}" theme="dark" variant="primary" data-id="20230209144903" bind:tap="changeBillStatus" block>完结工单</t-button>
  </view>
</view>

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