<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item v-if="false" label="计划id" prop="planId">
        <el-input
          v-model="queryParams.planId"
          placeholder="请输入计划id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="计划编码" prop="planCode">
        <el-input
          v-model="queryParams.planCode"
          placeholder="请输入计划编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="工单号" prop="orderCode">
        <el-input
          v-model="queryParams.orderCode"
          placeholder="请输入工单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="车间编码" prop="planWorkshop">
        <el-select v-model="queryParams.planWorkshop" placeholder="请选择车间" clearable>
          <el-option
            v-for="work in workCenterList"
            :key="work.factoryCode"
            :label="work.factoryName"
            :value="work.factoryCode"
          />
        </el-select>
      </el-form-item>
      <el-form-item v-if="false" label="产线" prop="planProdLine">
        <el-input
          v-model="queryParams.planProdLine"
          placeholder="请输入产线"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="循环周期" prop="planLoop">
        <el-select v-model="queryParams.planLoopType" placeholder="请选择循环周期" clearable>
          <el-option
            v-for="dict in dict.type.device_loop_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item v-if="false" label="循环周期" prop="planLoop">
        <el-input
          v-model="queryParams.planLoop"
          placeholder="请输入循环周期"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="循环执行时间开始" prop="planLoopStart">
        <el-date-picker clearable
                        v-model="queryParams.planLoopStart"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择循环执行时间开始">
        </el-date-picker>
      </el-form-item>
      <el-form-item v-if="false" label="循环执行时间结束" prop="planLoopEnd">
        <el-date-picker clearable
                        v-model="queryParams.planLoopEnd"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择循环执行时间结束">
        </el-date-picker>
      </el-form-item>
      <el-form-item v-if="false" label="实际开始时间" prop="orderStart">
        <el-date-picker clearable
                        v-model="queryParams.orderStart"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择实际开始时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item v-if="false" label="实际结束时间" prop="orderEnd">
        <el-date-picker clearable
                        v-model="queryParams.orderEnd"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择实际结束时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="设备编码" prop="equipmentCode">
        <el-input
          v-model="queryParams.equipmentCode"
          placeholder="请输入设备编码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备名称" prop="equipmentCode">
        <el-input
          v-model="queryParams.equipmentName"
          placeholder="请输入设备名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="工单费用" prop="orderCost">
        <el-input
          v-model="queryParams.orderCost"
          placeholder="请输入工单费用"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="点检人" prop="planPerson">
        <el-input
          v-model="queryParams.planPerson"
          placeholder="请输入点检人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="工单用时" prop="orderCostTime">
        <el-input
          v-model="queryParams.orderCostTime"
          placeholder="请输入工单用时"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="签字" prop="orderSignPerson">
        <el-input
          v-model="queryParams.orderSignPerson"
          placeholder="请输入签字"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="工厂" prop="factoryCode">
        <el-input
          v-model="queryParams.factoryCode"
          placeholder="请输入工厂"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="备用字段1" prop="attr1">
        <el-input
          v-model="queryParams.attr1"
          placeholder="请输入备用字段1"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="备用字段2" prop="attr2">
        <el-input
          v-model="queryParams.attr2"
          placeholder="请输入备用字段2"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="备用字段3" prop="attr3">
        <el-input
          v-model="queryParams.attr3"
          placeholder="请输入备用字段3"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="删除标志" prop="delFlag">
        <el-input
          v-model="queryParams.delFlag"
          placeholder="请输入删除标志"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="创建人" prop="createBy">
        <el-input
          v-model="queryParams.createBy"
          placeholder="请输入创建人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="创建时间" prop="createTime">
        <el-date-picker clearable
                        v-model="queryParams.createTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择创建时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item v-if="false" label="更新人" prop="updateBy">
        <el-input
          v-model="queryParams.updateBy"
          placeholder="请输入更新人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item v-if="false" label="更新时间" prop="updateTime">
        <el-date-picker clearable
                        v-model="queryParams.updateTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择更新时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label-width="100px" label="循环开始时间" prop="planLoopStart">
        <el-date-picker
          v-model="queryParams.loopStartArray"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>
      <el-form-item label-width="100px" label="执行开始时间" prop="orderStart">
        <el-date-picker
          v-model="queryParams.orderStartArray"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>
      <el-form-item label-width="100px" label="执行结束时间" prop="orderEnd">
        <el-date-picker
          v-model="queryParams.orderEndArray"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd"
          :picker-options="pickerOptions">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col v-if="false" :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['device:inspectionWork:add']"
        >新增</el-button>
      </el-col>
      <el-col v-if="false" :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['device:inspectionWork:edit']"
        >修改</el-button>
      </el-col>
      <el-col v-if="false" :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['device:inspectionWork:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['device:inspectionWork:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="inspectionWorkList">
      <el-table-column v-if="false" label="主键" align="center" prop="orderId" />
      <el-table-column v-if="false" label="计划id" align="center" prop="planId" />
      <el-table-column width="150" label="计划编码" align="center" prop="planCode" />
      <el-table-column v-if="false" label="计划类型" align="center" prop="planType" />
      <el-table-column width="150" label="点检单号" align="center" prop="orderCode" fixed>
        <template slot-scope="scope">
          <el-button
            type="text"
            @click="showWork(scope.row)"
          >{{ scope.row.orderCode }}</el-button
          >
        </template>
      </el-table-column>
      <el-table-column label="车间编码" align="center" prop="planWorkshop" />
      <el-table-column width="150" label="车间" align="center" prop="workCenterName"/>
      <el-table-column v-if="false" label="产线" align="center" prop="planProdLine" />
      <el-table-column label="循环周期" align="center" prop="planLoop" />
      <el-table-column width="120" label="循环周期类型" align="center" prop="planLoopType" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_loop_type" :value="scope.row.planLoopType"/>
        </template>
      </el-table-column>
      <el-table-column width="120" label="循环开始时间" align="center" prop="planLoopStart">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planLoopStart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="false" width="120" label="循环范围结束" align="center" prop="planLoopEnd">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.planLoopEnd, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column width="120" label="执行开始时间" align="center" prop="orderStart">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderStart, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column width="120" label="执行结束时间" align="center" prop="orderEnd">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.orderEnd, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column width="100" label="设备编码" align="center" prop="equipmentCode" />
      <el-table-column width="120" label="设备名称" align="center" prop="equipmentName" />
      <el-table-column label="工单状态" align="center" prop="orderStatus" >
        <template slot-scope="scope">
          <dict-tag :options="dict.type.device_order_status" :value="scope.row.orderStatus"/>
        </template>
      </el-table-column>
      <el-table-column v-if="false" label="工单费用" align="center" prop="orderCost" />
      <el-table-column label="点检人" align="center" prop="planPerson" />
      <el-table-column v-if="false" label="工单用时" align="center" prop="orderCostTime" />
      <el-table-column v-if="false" label="签字" align="center" prop="orderSignPerson" />
      <el-table-column v-if="false" label="工厂" align="center" prop="factoryCode" />
      <el-table-column v-if="false" label="备用字段1" align="center" prop="attr1" />
      <el-table-column v-if="false" label="备用字段2" align="center" prop="attr2" />
      <el-table-column v-if="false" label="备用字段3" align="center" prop="attr3" />
      <el-table-column v-if="false" label="删除标志" align="center" prop="delFlag" />
      <el-table-column label="创建人" align="center" prop="createBy" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="更新人" align="center" prop="updateBy" />
      <el-table-column label="更新时间" align="center" prop="updateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column v-if="false" label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['device:inspectionWork:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['device:inspectionWork:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      title="点检详情"
      :visible.sync="workDetail"
      width="1000px"
    >
      <el-tabs type="border-card">
        <el-tab-pane label="点检信息">
          <el-descriptions title="" border :column="2">
            <el-descriptions-item label="计划编码">{{ workVO.order.planCode }}</el-descriptions-item>
            <el-descriptions-item label="计划名称">{{ workVO.order.planName }}</el-descriptions-item>
            <el-descriptions-item label="循环周期">{{ workVO.order.planLoop }}{{ workVO.order.planLoopType }}
            </el-descriptions-item>
            <el-descriptions-item label="工单编码">{{ workVO.order.orderCode }}</el-descriptions-item>
            <el-descriptions-item label="车间编码">{{ workVO.order.planWorkshop }}</el-descriptions-item>
            <el-descriptions-item label="循环开始时间">{{ workVO.order.planLoopStart }}</el-descriptions-item>
            <el-descriptions-item v-if="false" label="点检执行结束时间">{{ workVO.order.planLoopEnd }}</el-descriptions-item>
            <el-descriptions-item v-if="false" label="执行开始时间">{{ workVO.order.orderStart }}</el-descriptions-item>
            <el-descriptions-item v-if="false" label="执行结束时间">{{ workVO.order.orderEnd }}</el-descriptions-item>
            <el-descriptions-item label="点检人">{{ workVO.order.planPerson }}</el-descriptions-item>
            <el-descriptions-item label="报修单号">{{ workVO.order.repairCode }}</el-descriptions-item>
          </el-descriptions>
        </el-tab-pane>
        <el-tab-pane label="设备信息">
          <el-descriptions class="my-margin-top" title="" :column="2" border>
            <el-descriptions-item label="设备编码">{{ workVO.equ.equipmentCode }}</el-descriptions-item>
            <el-descriptions-item label="设备名称">{{ workVO.equ.equipmentName }}</el-descriptions-item>
            <el-descriptions-item label="设备位置">{{ workVO.equ.equipmentLocation }}</el-descriptions-item>
            <el-descriptions-item label="设备类型编码">{{ workVO.equ.equipmentTypeCode }}</el-descriptions-item>
            <el-descriptions-item label="设备类型名称">{{ workVO.equ.equipmentTypeName }}</el-descriptions-item>
            <el-descriptions-item label="所属工作中心编码">{{ workVO.equ.workshopCode }}</el-descriptions-item>
            <el-descriptions-item label="所属工作中心名称">{{ workVO.equ.workshopName }}</el-descriptions-item>
          </el-descriptions>
        </el-tab-pane>
        <el-tab-pane label="检查项信息">
            <el-table
              :data="standardListVo"
              border
              style="width: 100%">
              <el-table-column
                prop="itemName"
                label="检查项"
                width="180">
              </el-table-column>
              <el-table-column
                prop="standardName"
                label="标准名称"
                width="180">
              </el-table-column>
              <el-table-column
                prop="standardTypeName"
                label="标准类型"
                width="80">
              </el-table-column>
              <el-table-column
                prop="detailReach"
                label="是否达标">
              </el-table-column>
              <el-table-column
                prop="actualValue"
                label="实际值">
              </el-table-column>
              <el-table-column
                prop="detailUpLimit"
                label="上限">
              </el-table-column>
              <el-table-column
                prop="detailDownLimit"
                label="下限">
              </el-table-column>
              <el-table-column
                prop="detailUnit"
                label="单位">
              </el-table-column>
              <el-table-column
                prop="picturePath"
                label="图片">
                <template slot-scope="scope">
                  <el-popover
                    placement="right"
                    width="300"
                    trigger="hover">
                    <div class="demo-image__lazy">
                      <el-empty :image-size="200" v-if="scope.row.checkPictrueList.length == 0"></el-empty>
                      <div v-for="(url, index) in scope.row.checkPictrueList" :key="index">
                        <el-image
                          :src="url"
                        ></el-image>
                      </div>
                    </div>
                    <el-button slot="reference" type="primary" icon="el-icon-picture" circle></el-button>
                  </el-popover>
                </template>
              </el-table-column>
            </el-table>
        </el-tab-pane>
      </el-tabs>
      <span slot="footer" class="dialog-footer">
    <el-button @click="workDetail = false">取 消</el-button>
    <el-button type="primary" @click="workDetail = false">确 定</el-button>
  </span>
    </el-dialog>

    <!-- 添加或修改点检记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listInspectionWork, getInspectionWork, delInspectionWork, addInspectionWork, updateInspectionWork } from "@/api/device/inspectionWork";
import {getWorkCenter} from "@/api/device/plan";
import {listDeviceOrder} from "@/api/device/deviceOrder";

export default {
  name: "InspectionWork",
  dicts: ['device_order_status', 'device_loop_type'],
  data() {
    return {
      standardListVo:[],
      // 日期范围选择快捷
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近一个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
            picker.$emit('pick', [start, end]);
          }
        }, {
          text: '最近三个月',
          onClick(picker) {
            const end = new Date();
            const start = new Date();
            start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
            picker.$emit('pick', [start, end]);
          }
        }]
      },
      // 工作中心
      workCenterList:[],
      // 初始化VO
      workVO: {
        order: {
          planCode:null,
          planName:null,
          planLoop:null,
          planLoopType:null,
          orderCode:null,
          planWorkShop:null,
          planLoopStart:null,
          planLoopEnd:null,
          orderStart:null,
          orderEnd:null,
          planPerson:null,
        },equ: {
          equipmentCode:null,
          equipmentName: null,
          equipmentLocation:null,
          equipmentTypeCode:null,
          equipmentTypeName:null,
          workshopCode:null,
          workshopName:null,
        },detailList:[]
      },
      // 工单详情抽屉
      workDetail: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 点检记录表格数据
      inspectionWorkList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        planId: null,
        planCode: null,
        planType: "spotInspection",
        orderCode: null,
        planWorkshop: null,
        planProdLine: null,
        planLoop: null,
        planLoopType: null,
        planLoopStart: null,
        planLoopEnd: null,
        orderStart: null,
        orderEnd: null,
        equipmentCode: null,
        orderStatus: '1',
        orderCost: null,
        planPerson: null,
        orderCostTime: null,
        orderSignPerson: null,
        factoryCode: null,
        attr1: null,
        attr2: null,
        attr3: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        loopStartArray: [],
        orderStartArray: [],
        orderEndArray: [],
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.setWorkCenter();
    this.getList();
  },
  methods: {
    // 获取工作中心
    setWorkCenter() {
      getWorkCenter().then(response => {
        this.workCenterList = response.data;
      })
    },
    // 展示
    showWork(row) {
      this.reset();
      this.standardListVo = [];
      const orderId = row.orderId || this.ids
      getInspectionWork(orderId).then(response => {
        this.workVO = response.data;
        for (let i = 0; i < this.workVO.detailList.length; i++) {
          for (let j = 0; j < this.workVO.detailList[i].standardList.length; j++) {
            this.workVO.detailList[i].standardList[j].itemName = this.workVO.detailList[i].itemName;
            this.standardListVo.push(this.workVO.detailList[i].standardList[j]);
          }
        }
        this.workDetail = true;
      });

    },
    /** 查询点检记录列表 */
    getList() {
      this.loading = true;
      listDeviceOrder(this.queryParams).then(response => {
        this.inspectionWorkList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderId: null,
        planId: null,
        planCode: null,
        planType: "spotInspection",
        orderCode: null,
        planWorkshop: null,
        planProdLine: null,
        planLoop: null,
        planLoopType: null,
        planLoopStart: null,
        planLoopEnd: null,
        orderStart: null,
        orderEnd: null,
        equipmentCode: null,
        orderStatus: '1',
        orderCost: null,
        planPerson: null,
        orderCostTime: null,
        orderSignPerson: null,
        factoryCode: null,
        attr1: null,
        attr2: null,
        attr3: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        loopStartArray: [],
        orderStartArray: [],
        orderEndArray: [],
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.queryParams.loopStartArray = [];
      this.queryParams.orderStartArray = [];
      this.queryParams.orderEndArray = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.orderId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加点检记录";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const orderId = row.orderId || this.ids
      getInspectionWork(orderId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改点检记录";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.orderId != null) {
            updateInspectionWork(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addInspectionWork(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const orderIds = row.orderId || this.ids;
      this.$modal.confirm('是否确认删除点检记录编号为"' + orderIds + '"的数据项？').then(function() {
        return delInspectionWork(orderIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('device/inspectionWork/export', {
        ...this.queryParams
      }, `inspectionWork_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
<style>
.my-margin-lr{
  margin-right: 20px;
  margin-left: 20px;
}
.my-margin-top{
  margin-top: 10px;
}
.demo-image__lazy{
  height: 400px;
  overflow-y: auto;
}
</style>
