<template>
  <div>
    <el-card>

      <el-form :model="query" v-if="showSearch" label-width="auto">
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="负责部门">
              <deptSelect :value.sync="query.chargeDeptCode"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="top-right-btn">
        <el-button-group>
          <el-button icon="el-icon-view" type="primary" @click="showSearch = !showSearch">显示/隐藏搜索栏</el-button>
          <el-button
              type="primary"
              icon="el-icon-refresh"
              @click="onReset"
          >重置
          </el-button>
          <el-button type="primary" icon="el-icon-search" @click="search"
          >查询
          </el-button>
        </el-button-group>
      </div>
      <el-divider style="margin: 15px"></el-divider>

      <el-table :data="list" @row-click="rowClick" v-loading="loading" click-row-light>
        <el-table-column label="序号" width="50" type="index"/>
        <el-table-column label="任务单号" width="150" prop="taskBillNo"/>
        <el-table-column label="任务名称" width="150" prop="name"/>
        <el-table-column label="计划名称" width="150" prop="planName"/>
        <el-table-column label="系统生成" width="80" prop="sysFlag">
          <template slot-scope="scope">
            {{ scope.row.sysFlag ? '是' : '否' }}
          </template>
        </el-table-column>
        <el-table-column label="完成情况" width="80" prop="finishFlag">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.finishFlag==true" type="success">已完成</el-tag>
            <el-tag v-if="scope.row.finishFlag==false" type="warning">未完成</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="负责部门" width="160" prop="chargeDeptName"/>
<!--        <el-table-column label="负责人" width="160" prop="checkUserName"/>-->
<!--        <el-table-column label="负责人联系方式" width="160" prop="checkUserPhone"/>-->
        <el-table-column label="设备数量" width="50" prop="deviceCount"/>
        <el-table-column label="完成数量" width="50" prop="finishCount"/>
        <el-table-column label="创建时间" width="160" prop="createTime"/>
        <el-table-column label="创建人" width="160" prop="createUserName"/>
        <!--        <el-table-column label="状态" width="120" prop="statusName">-->
        <!--          <template scope="scope">-->
        <!--            <el-tag :type="deviceStatus[scope.row.status].tagType">{{scope.row.statusName}}</el-tag>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <!--        <el-table-column label="数量" width="120" prop="count"/>-->
        <!--        <el-table-column label="计量单位" width="100" prop="measname"/>-->
        <!--        <el-table-column label="生产企业" width="180" prop="manufactory"/>-->
        <!--        <el-table-column label="批次号" width="100" prop="batchNo"/>-->
        <!--        <el-table-column label="序列号" width="100" prop="serialNo"/>-->
        <!--        <el-table-column label="生产日期" width="140" prop="productionDate"/>-->
        <!--        <el-table-column label="过期时间" width="140" prop="expireDate"/>-->
        <!--        <el-table-column label="供应商" width="100" prop="supName"/>-->
        <!--        <el-table-column label="udi码" width="150" prop="udi"/>-->
        <!--        <el-table-column label="注册/备案号" width="150" prop="zczbhhzbapzbh"/>-->
        <!--<el-table-column label="操作" width="120" fixed="right">-->
          <!--<template scope="scope">-->

          <!--  <el-button type="text" @click="print(scope.row.taskId)"-->
          <!--  >开始巡检-->
          <!--  </el-button>-->
          <!--</template>-->
        <!--</el-table-column>-->
      </el-table>
      <pagination
          v-show="total>0"
          :total="total"
          :page.sync="query.page"
          :limit.sync="query.limit"
          @pagination="getList"
      />
    </el-card>

    <el-card>
      <div slot="header" class="clearfix">
        <div class="fl">{{
            `任务详情 ${clickRow ? '——' + clickRow.name : ''}`
          }}
        </div>
        <div v-if="clickRow" class="fr">
          <el-button @click="getDetailList">刷新</el-button>
        </div>
      </div>
      <el-form v-if="clickRow" :model="detailQuery" inline label-width="auto">
        <el-row :gutter="20">
          <el-col>
            <el-form-item label="设备编码">
              <el-input  v-model.trim="detailQuery.deviceCode" clearable/>
            </el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="getDetailList"
            >查询
            </el-button>
          </el-col>
        </el-row>
      </el-form>
      <el-table :data="detailList" v-loading="detailLoading">
        <el-table-column label="序号" width="50" type="index"/>
        <el-table-column label="科室" width="150" prop="deptName"/>
        <el-table-column label="设备编码" width="150" prop="deviceCode"/>
        <el-table-column label="完成情况" width="80" prop="finishFlag">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.finishFlag==true" type="success">已完成</el-tag>
            <el-tag v-if="scope.row.finishFlag==false" type="warning">未完成</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="最小销售标识" width="150" prop="nameCode"/>
        <el-table-column label="名称" width="150" prop="productName"/>
        <el-table-column label="项目数量" width="50" prop="itemCount"/>
        <el-table-column label="完成数量" width="50" prop="finishCount"/>
        <el-table-column label="规格型号" width="160" prop="ggxh"/>
        <!--        <el-table-column label="状态" width="120" prop="statusName">-->
        <!--          <template scope="scope">-->
        <!--            <el-tag :type="deviceStatus[scope.row.status].tagType">{{ scope.row.statusName }}</el-tag>-->
        <!--          </template>-->
        <!--        </el-table-column>-->
        <el-table-column label="计量单位" width="100" prop="measname"/>
        <el-table-column label="生产企业" width="180" prop="manufactory"/>
        <el-table-column label="批次号" width="100" prop="batchNo"/>
        <el-table-column label="序列号" width="100" prop="serialNo"/>
        <el-table-column label="生产日期" width="140" prop="productionDate"/>
        <el-table-column label="过期时间" width="140" prop="expireDate"/>
        <el-table-column label="供应商" width="100" prop="supName"/>
        <el-table-column label="udi码" width="150" prop="udi"/>
        <el-table-column label="注册/备案号" width="150" prop="zczbhhzbapzbh"/>
        <el-table-column label="操作" width="170" fixed="right">
          <template slot-scope="scope">
            <el-button type="text" @click="openItem(scope.row)"
            >查看巡检项目
            </el-button>
            <el-button v-if="scope.row.repairId" type="text" @click="repairId = scope.row.repairId"
            >查看维修单
            </el-button>
<!--            <el-button type="text" @click="print(scope.row.taskId,scope.row.deviceCode)"-->
<!--            >打印-->
<!--            </el-button>-->
          </template>
        </el-table-column>
      </el-table>
      <pagination
          v-show="detailTotal>0"
          :total="detailTotal"
          :page.sync="detailQuery.page"
          :limit.sync="detailQuery.limit"
          @pagination="getDetailList"
      />

    </el-card>
    <el-dialog
        :visible="true"
        v-if="itemDialogFlag"
        width="80%"
        :title="`巡检项目${itemQuery.title?'--'+itemQuery.title:''}`"
        @close="itemDialogFlag = false"
    >
      <el-card>
        <div slot="header" class="clearfix">
          <div class="fr">
            <el-button type="" @click="getDetailItemList">刷新</el-button>
          </div>
        </div>
        <el-table :data="itemList" v-loading="itemLoading">
          <el-table-column label="序号" width="50" type="index"/>
          <el-table-column label="项目编码" width="150" prop="itemCode"/>
          <el-table-column label="完成情况" width="80" prop="finishFlag">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.finishFlag==true" type="success">已完成</el-tag>
              <el-tag v-if="scope.row.finishFlag==false" type="warning">未完成</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="完成时间" width="160" prop="finishTime"/>
          <el-table-column label="巡检部门" width="100" prop="checkDeptName"/>
          <el-table-column label="巡检人" width="100" prop="checkUserName"/>
          <el-table-column label="异常情况" width="80" prop="finishFlag">
            <template slot-scope="scope">
              <el-tag v-if="scope.row.normalFlag==true" type="success">正常</el-tag>
              <el-tag v-if="scope.row.normalFlag==false" type="danger">异常</el-tag>
            </template>
          </el-table-column>
          <el-table-column label="项目名称" width="150" prop="itemName"/>
          <el-table-column label="项目内容" width="450" prop="itemContent"/>
          <el-table-column label="巡检意见" width="450" prop="suggestion"/>
        </el-table>
        <pagination
            v-show="itemTotal>0"
            :total="itemTotal"
            :page.sync="itemQuery.page"
            :limit.sync="itemQuery.limit"
            @pagination="getDetailItemList"
        />
      </el-card>
    </el-dialog>

    <el-dialog
      visible
      v-if="repairId"
      @close="repairId=null"
      title="维修单信息"
      width="80%"
    >
      <deviceRepairDialog :repairId="repairId"/>
    </el-dialog>

<!--    <div id="printDiv" v-if="checkPrintData" v-show="false">-->
<!--      <div class="width-full p10" style="height:100vh;overflow-y: auto" v-for="item in checkPrintData.details">-->
<!--        <h1 align="center" style="font-size: 26px;font-weight: bolder;">巡检任务单</h1>-->
<!--        <el-descriptions colon column="2" label-style="width:100px;">-->
<!--          <el-descriptions-item label="任务标识">-->
<!--            {{ checkPrintData.info.taskId }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="任务时间">-->
<!--            {{ checkPrintData.info.createTime }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="打印时间">-->
<!--            {{ checkPrintData.printTime }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="任务名称">-->
<!--            {{ checkPrintData.info.name }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="计划名称">-->
<!--            {{ checkPrintData.info.planName }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="负责部门">-->
<!--            {{ checkPrintData.info.chargeDeptName }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="设备名称">-->
<!--            {{ item.deviceCode }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="设备编号">-->
<!--            {{ item.productName }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="设备规格">-->
<!--            {{ item.ggxh }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="销售标识">-->
<!--            {{ item.nameCode }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="注册/备案号">-->
<!--            {{ item.zczbhhzbapzbh }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="计量单位">-->
<!--            {{ item.measname }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="生产企业">-->
<!--            {{ item.manufactory }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="使用部门">-->
<!--            {{ item.deptName }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="UDI码">-->
<!--            {{ item.udi }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="有效期">-->
<!--            {{ item.productionDate }} ~ {{ item.expireDate }}-->
<!--          </el-descriptions-item>-->
<!--          <el-descriptions-item label="供应商">-->
<!--            {{ item.supName }}-->
<!--          </el-descriptions-item>-->
<!--        </el-descriptions>-->
<!--        <table border=1 cellspacing=0 cellpadding=1 width="100%" style="border-collapse:collapse" bordercolor="#333333">-->
<!--          <thead>-->
<!--          <th width="50px">-->
<!--            <b>序号</b>-->
<!--          </th>-->
<!--          <th style="width: calc((100vh - 50px) / 4)">-->
<!--            <b>项目名称</b>-->
<!--          </th>-->
<!--          <th style="width:calc((100vh - 50px) / 4)">-->
<!--            <b>项目编码</b>-->
<!--          </th>-->
<!--          <th style="width:calc((100vh - 50px) / 4)">-->
<!--            <b>项目内容</b>-->
<!--          </th>-->
<!--          <th style="width:calc((100vh - 50px) / 4)">-->
<!--            <b>巡检意见</b>-->
<!--          </th>-->
<!--          </thead>-->
<!--          <tbody>-->
<!--          <tr align="center" v-for="(v,i) in item.detailItems" style="height: 200px;">-->
<!--            <td>{{ i + 1 }}</td>-->
<!--            <td>{{ v.itemName }}</td>-->
<!--            <td>{{ v.itemCode }}</td>-->
<!--            <td>{{ v.itemContent }}</td>-->
<!--            <td>{{ v.suggestion }}</td>-->
<!--          </tr>-->
<!--          </tbody>-->
<!--          &lt;!&ndash;          <el-table-column :show-overflow-tooltip="false" label="序号" type="index" width="50px"/>&ndash;&gt;-->
<!--          &lt;!&ndash;          <el-table-column :show-overflow-tooltip="false" label="项目名称" prop="itemName"&ndash;&gt;-->
<!--          &lt;!&ndash;                           width="calc((100vh - 50px) / 4)"/>&ndash;&gt;-->
<!--          &lt;!&ndash;          <el-table-column :show-overflow-tooltip="false" label="项目编码" prop="itemCode"&ndash;&gt;-->
<!--          &lt;!&ndash;                           width="calc((100vh - 50px) / 4)"/>&ndash;&gt;-->
<!--          &lt;!&ndash;          <el-table-column :show-overflow-tooltip="false" label="项目内容" prop="itemContent"&ndash;&gt;-->
<!--          &lt;!&ndash;                           width="calc((100vh - 50px) / 4)"/>&ndash;&gt;-->
<!--          &lt;!&ndash;          <el-table-column :show-overflow-tooltip="false" label="巡检意见" prop="suggestion"&ndash;&gt;-->
<!--          &lt;!&ndash;                           width="calc((100vh - 50px) / 4)"/>&ndash;&gt;-->
<!--        </table>-->
<!--      </div>-->
<!--    </div>-->

  </div>

</template>

<script src="./js/deviceCheck.js"/>

<style scoped>

/deep/ .el-dialog__body {
  padding: 0 0 20px 0;
}
</style>
