<template xmlns:el-row="http://www.w3.org/1999/html">
  <div class="app-container">
    <div class="filter-container">
      <sticky v-show="ifCorrectionsCost" style="margin-bottom: 10px;">
        <div class="sub-navbar">
          <el-button type="primary" icon="el-icon-circle-check" @click="approved">
            生成报告
          </el-button>
          <el-button type="danger" icon="el-icon-delete" @click="taskInvalidation">
            任务作废
          </el-button>
        </div>
      </sticky>
      <el-form>
        <el-form-item>
          <el-input v-model="listQuery.searchYsjl.jilubianhao" placeholder="记录编号" clearable size="small" style="width: 200px" @keyup.enter.native="handleFilter" />
          <el-input v-model="listQuery.searchYsjl.zhizaodanwei" placeholder="单位名称" clearable size="small" style="width: 200px" @keyup.enter.native="handleFilter" />
          <el-input v-model="listQuery.searchYsjl.chanpinbianhao" placeholder="产品编号" clearable size="small" style="width: 200px" @keyup.enter.native="handleFilter" />
          <el-input v-model="listQuery.searchYsjl.shebeipinzhong" placeholder="设备种类" clearable size="small" style="width: 200px" @keyup.enter.native="handleFilter" />
          <el-button size="small" type="primary" icon="el-icon-search" @click="handleFilter">
            查询
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table
      ref="list"
      v-adaptive="{bottomOffset: 50}"
      height="0"
      :data="list"
      :row-class-name="tableRowClassName"
      border
      fit
      highlight-current-row
      stripe
      size="mini"
      width="100%"
      :cell-style="cellStyle"
      @row-click="onRowClick"
      @selection-change="handleSelectionChange"
      @sort-change="sortChange"
    >
      <el-table-column type="selection" fixed="left" width="40px" />
      <el-table-column type="index" align="center" fixed="left" label="序号" width="60px" />
      <el-table-column align="center" label="记录编号" fixed="left" prop="jilubianhao" width="140px" sortable="custom" />
      <el-table-column :formatter="formatter.formatterCategory" align="center" label="检验类别" prop="jianyanleibie" width="80px" />
      <el-table-column align="center" label="设备种类" prop="shebeizhonglei" width="80px" />
      <el-table-column align="center" label="设备品种" prop="shebeipinzhong" width="110px" />
      <el-table-column align="center" label="单位名称" prop="zhizaodanwei" width="250px" />
      <el-table-column align="center" label="产品编号" prop="chanpinbianhao" width="120px" />
      <el-table-column align="center" label="产品名称" prop="shebeimingcheng" width="120px" />
      <el-table-column align="center" label="设备型号" prop="guigexinghao" width="110px" />
      <el-table-column :formatter="getProductionName" align="center" label="生产形式" prop="shengchanxingshi" width="110px" />
      <el-table-column align="center" label="设计日期" prop="shejiriqi" width="120px" />
      <el-table-column :formatter="formatter.getChineseName" align="center" label="检验人员" prop="jianyanrenyuan" width="100px" />
      <el-table-column align="center" label="编辑" fixed="right" width="150px">
        <template slot-scope="{row}">
          <el-dropdown trigger="click">
            <el-button type="text" round plain class="el-dropdown-link" style="color: #13ce66">
              功能列表<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <el-upload
                  class="upload inline-block margin-right-10"
                  action=""
                  accept="application/vnd.ms-excel"
                  :http-request="handleUploadYsjl"
                  :show-file-list="false"
                >
                  <el-button type="text">
                    {{ row.shebeileibiedaima === '2100' && row.shengchanxingshi === '5' ? '上传批量原始记录' : '上传原始记录' }}
                  </el-button>
                </el-upload>
              </el-dropdown-item>
              <el-dropdown-item v-if="row.shebeileibiedaima === '2100' && row.shengchanxingshi === '8'">
                <router-link :to="{ path: '2000/2100/zjqg/' + row.id + '/edit'}" class="link-type">
                  <el-button type="text" icon="edit">
                    编辑项目表
                  </el-button>
                </router-link>
              </el-dropdown-item>
              <el-dropdown-item v-if="row.shebeileibiedaima === '2100' || row.shebeileibiedaima === '2200'">
                <el-upload
                  action=""
                  accept="application/vnd.ms-excel"
                  :http-request="handleUploadParam"
                  :show-file-list="false"
                >
                  <el-button type="text">
                    上传数据表
                  </el-button>
                </el-upload>
              </el-dropdown-item>
              <el-dropdown-item v-else>
                <template v-if="row.shebeipinzhongdaima === '2310'">
                  <el-upload
                    action=""
                    accept="application/vnd.ms-excel"
                    :http-request="handleUploadProof"
                    :show-file-list="false"
                  >
                    <el-button type="text">
                      上传批量数据
                    </el-button>
                  </el-upload>
                </template>
                <template v-else>
                  <el-button type="text" @click="showVerificationProof(row.id)">
                    上传批量数据
                  </el-button>
                </template>
              </el-dropdown-item>
              <el-dropdown-item v-if="row.shebeileibiedaima === '2100' && (row.shengchanxingshi === '5' || row.shengchanxingshi === '6')">
                <el-button type="text" @click="fillInVacancy(row)">
                  手动补填
                </el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button type="text" @click="showVerification(row.renwuId,true)">
                  上传相关鉴证
                </el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button type="text" @click="showUpdateReportNotes(row)">
                  报告备注
                </el-button>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
      <el-table-column align="center" label="查看" fixed="right" width="150px">
        <template slot-scope="{row}">
          <el-dropdown trigger="click">
            <el-button type="text" round plain class="el-dropdown-link" style="color: #13ce66">
              功能列表<i class="el-icon-arrow-down el-icon--right" />
            </el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item>
                <el-button type="text" @click="common.viewYsjl(row.id, 'YSJL')">
                  {{ row.shebeileibiedaima === '2100' && row.shengchanxingshi === '5' ? '预览批量原始记录' : '预览原始记录' }}
                </el-button>
              </el-dropdown-item>
              <el-dropdown-item v-if="row.shebeileibiedaima === '2100' && row.shengchanxingshi === '8'">
                <router-link :to="{ path: '2000/2100/zjqg/' + row.id + '/view'}" class="link-type">
                  <el-button type="text" icon="edit">
                    查看项目表
                  </el-button>
                </router-link>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button type="text" @click="common.viewYsjl(row.id, 'OTHER')">
                  {{ row.shebeileibiedaima === '2300' ? '预览批量证明' : '预览数据表' }}
                </el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button type="text" @click="showDataComparison(row)">
                  数据对比
                </el-button>
              </el-dropdown-item>
              <el-dropdown-item>
                <el-button type="text" @click="showVerification(row.renwuId,false)">
                  查看相关鉴证
                </el-button>
              </el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </template>
      </el-table-column>
    </el-table>
    <div>
      <pagination v-show="totalCount>0" :total="totalCount" :page-num.sync="listQuery.pageNum" :page-row.sync="listQuery.pageRow" style="float: left;" @pagination="getList" />
      <div style="float: right;margin-top:8px;;margin-right: 30px;">
        <div style="float:left;margin-left: 20px;">
          上传记录数据有空值：
        </div>
        <div class="identification" style="background-color:red;" />
      </div>
    </div>
    <el-dialog title="查看相关鉴证" :modal-append-to-body="false" :visible.sync="dialogFormVisible">
      <enclosure :relation-id.sync="currentRenwuId" :if-liaison.sync="ifLiaison" :view-button.sync="viewButton" />
    </el-dialog>
    <!--打开焊接气瓶批量上传框-->
    <el-dialog title="焊接气瓶批量证明上传" :visible.sync="dialogFormVisibleProof" @close="closeDialog">
      <el-form>
        <el-form-item>
          <el-col>
            <el-upload
              class="upload inline-block margin-right-10"
              action=""
              accept="application/vnd.ms-excel"
              :http-request="handleUploadProof"
              :show-file-list="false"
            >
              <el-button type="primary" size="small">
                上传证明数据表<i class="el-icon-upload el-icon--right" />
              </el-button>
            </el-upload>
          </el-col>
          <fieldset style="width: 100%">
            <legend>附图照片</legend>
            <el-form-item>
              <el-upload
                action="123"
                list-type="picture-card"
                :before-upload="handleUploadDrawings"
                :on-remove="handleRemove"
                :file-list="fileListDrawings"
                :disabled="false"
                accept="image/png,image/gif,image/jpg,image/jpeg"
              >
                <i class="el-icon-plus" />
              </el-upload>
            </el-form-item>
          </fieldset>
        </el-form-item>
      </el-form>
    </el-dialog>
    <!--打开任务单与原始记录上传对比-->
    <el-dialog title="数据对比" :visible.sync="dialogFormComparison" @close="closeComparison">
      <el-form class="small-space" label-position="left" label-width="140px">
        <fieldset style="width: 100%;">
          <legend>原始记录数据</legend>
          <el-row :gutter="9">
            <el-col :span="12">
              <el-form-item label="产品名称:">
                <span :style="{'color':color_1}">{{ selection.shebeimingcheng }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="产品编号:">
                <span :style="{'color':color_2}">{{ selection.chanpinbianhao }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设计图号:">
                <span :style="{'color':color_3}">{{ ysjlParam.rongqituhao }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="容器类别:">
                <span :style="{'color':color_4}">{{ ysjlParam.rongqileibie }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设备型号:">
                <span :style="{'color':color_5}">{{ selection.guigexinghao }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </fieldset>
        <fieldset style="width: 100%;">
          <legend>任务单数据</legend>
          <el-row :gutter="9">
            <el-col :span="12">
              <el-form-item label="产品名称:">
                <span>{{ renwu.shebeimingcheng }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="产品编号:">
                <span>{{ renwu.chanpinbianhao }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设计图号:">
                <span>{{ renwu.s29 }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="容器类别:">
                <span>{{ renwu.s27 }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="设备型号:">
                <span>{{ renwu.guigexinghao }}</span>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="生产形式:">
                <span>{{ renwu.s107 }}</span>
              </el-form-item>
            </el-col>
          </el-row>
        </fieldset>
      </el-form>
    </el-dialog>
    <!--手动补填缺失（固定式压力容器批量证明、固定式压力容器承压部件证明）-->
    <el-dialog title="补填缺失内容" :visible.sync="dialogFillInVacancyVisible" style="margin-top: -7vh;" @close="closeDialog">
      <el-form class="small-space" label-position="left" label-width="100px" style="height: 300px;">
        <fieldset style="width: 100%;">
          <legend>补填内容</legend>
          <el-row v-if="showWhis" :gutter="9">
            <el-col :span="12">
              <el-form-item label="型式规格" prop="xingshiguige">
                <el-input v-model="beizhu.xingshiguige" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="材料" prop="cailiao">
                <el-input v-model="beizhu.cailiao" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-if="showWhis" :gutter="9">
            <el-col :span="12">
              <el-form-item label="数量" prop="shuliang">
                <el-input v-model="beizhu.shuliang" type="text" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="是否来料加工" prop="jiagongxingshi">
                <el-radio v-model="beizhu.jiagongxingshi" label="是">
                  是
                </el-radio>
                <el-radio v-model="beizhu.jiagongxingshi" label="否">
                  否
                </el-radio>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row v-else :gutter="9">
            <el-col :span="12">
              <el-form-item label="适用编号" prop="shiyongbianhao">
                <el-input v-model="beizhu.shiyongbianhao" type="text" />
              </el-form-item>
            </el-col>
          </el-row>
        </fieldset>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFillInVacancyVisible = false">
          取 消
        </el-button>
        <el-button v-if="dialogStatus==='create'" type="success" @click="createOrUpdateBeizhu">
          保 存
        </el-button>
        <el-button v-else type="primary" @click="createOrUpdateBeizhu">
          修 改
        </el-button>
      </div>
    </el-dialog>
    <!--备注填写-->
    <el-dialog title="备注填写" :visible.sync="dialogShowUpdateReportNotesVisible" width="40%">
      <el-form class="small-space" label-width="6%" style="height: 200px;">
        <fieldset style="width: 100%;height: 90%">
          <legend>备注填写</legend>
          <el-form-item label="备注">
            <el-input v-model="ysjlParam.reportNotesNeirong" type="textarea" :autosize="{ minRows: 5, maxRows: 5}" />
          </el-form-item>
        </fieldset>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogShowUpdateReportNotesVisible = false">
          取 消
        </el-button>
        <el-button type="primary" @click="updateYjslParam">
          更 改
        </el-button>
      </div>
    </el-dialog>
    <!--生成报告前的检验核定窗口-->
    <el-dialog title="检验核定费用" :visible.sync="dialogInspectionVisible" width="80%">
      <div class="filter-container">
        <sticky style="margin-bottom: 10px;">
          <div class="sub-navbar">
            <el-button type="primary" icon="el-icon-circle-check" @click="batchGenerate">
              确   定
            </el-button>
            <el-button @click="dialogInspectionVisible = false">
              取   消
            </el-button>
          </div>
        </sticky>
      </div>
      <el-table
        ref="listInspection"
        :data="listInspection"
        fit
        size="mini"
        width="100%"
      >
        <el-table-column type="index" align="center" label="序号" />
        <el-table-column align="center" label="记录编号" prop="jilubianhao" />
        <el-table-column align="center" label="产品名称" prop="shebeimingcheng" />
        <el-table-column align="center" label="产品编号" prop="chanpinbianhao" :show-overflow-tooltip="true" />
        <el-table-column align="center" label="合同编号" prop="hetongbianhao" />
        <el-table-column align="center" label="材质/重量收费" prop="caizhihuozhongliang" />
        <el-table-column align="center" label="造价" prop="zaojiao" />
        <el-table-column align="center" label="收费比例（%）" prop="shoufeibili" />
        <el-table-column align="center" label="系统核算" prop="xitongheding" />
        <el-table-column align="center" label="费用更改" prop="datingheding" />
        <el-table-column align="center" label="检验核算" prop="jianyanheding">
          <template slot-scope="{row}">
            <el-input v-model="row.jianyanheding" :disabled="row.retreatState === 2 && row.jfState !== null && row.jfState" />
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </div>
</template>

<script>
import Sticky from '@/components/Sticky'
import Pagination from '@/components/Pagination'
import Enclosure from '@/views/common/Enclosure'
import Utils from '../../../utils/contact.js'
import { getNeedRecordList } from '@/api/ysjl'
import qs from 'qs'

export default {
  components: { Sticky, Pagination, Enclosure },
  data() {
    return {
      totalCount: 0,
      list: [],
      listQuery: {
        pageNum: 1, // 页码
        pageRow: 20, // 每页条数
        order: 'update_time', // 排序字段
        sort: 'desc', // 排序方式
        searchYsjl: {
          shebeizhongleidaima: '2000',
          jianyanleibie: 'ZJ'
        }
      },
      multipleSelection: [],
      multipleProveSelection: [],
      listInspection: [],
      selection: {
        jianyanheding: ''
      },
      beizhu: {
        shiyongbianhao: '',
        xingshiguige: '',
        cailiao: '',
        shuliang: '',
        jiagongxingshi: '是'
      },
      dialogStatus: 'create',
      dialogFormVisible: false,
      dialogFormVisibleProof: false,
      dialogFormComparison: false,
      dialogFillInVacancyVisible: false,
      dialogShowUpdateReportNotesVisible: false,
      dialogInspectionVisible: false,
      showWhis: true,
      viewButton: true,
      ifLiaison: false,
      fileList: [],
      fileListDrawings: [],
      currentRenwuId: 0,
      renwu: {},
      ysjlParam: {
        rongqituhao: '',
        rongqileibie: '',
        reportNotesNeirong: ''
      },
      productions: [], // 生产形式
      typeCode: 'PRODUCTION_FORM', // 生产形式代码
      color_1: 'black',
      color_2: 'black',
      color_3: 'black',
      color_4: 'black',
      color_5: 'black',
      ifCorrectionsCost: this.$store.getters.clientType === 'System',
      biliOptions: ['0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8', '0.9', '1', '1.1', '1.2']
    }
  },
  created() {
    this.getList()
    this.getProductions()
  },
  mounted() {
    const that = this
    this.common.$on('manufacture-list', function() {
      that.handleFilter()
    })
  },
  methods: {
    /**
     * 进入球罐项目表编辑页
     */
    editCategory(row) {

    },
    /**
     *  上传原始记录有空标红
     */
    tableRowClassName({ row }) {
      if (row.highlight === 1) {
        return 'restartdw-row'
      } else {
        return ''
      }
    },
    // 原始记录作废
    taskInvalidation() {
      if (this.multipleSelection.length === 0) {
        this.$message({
          type: 'error',
          message: '请选择需要删除的数据！'
        })
        return false
      } else {
        this.$confirm('确定作废当前选中记录?', '提示', {
          confirmButtonText: '确定',
          showCancelButton: true,
          type: 'warning'
        }).then(() => {
          const ids = []
          const qs = require('qs')
          this.multipleSelection.forEach(data => {
            ids.push(data.id)
          })
          this.api({
            url: '/ysjl/zfYsjl',
            method: 'get',
            params: { ids: ids },
            paramsSerializer: function(params) {
              return qs.stringify(params, { indices: false })
            }
          }).then(() => {
            this.$message.success('作废成功！')
            this.getList()
          })
        })
      }
    },
    getProductions() {
      this.api({
        url: '/dicData/getDicDataByTypeCode',
        method: 'get',
        params: {
          typeCode: this.typeCode
        }
      }).then(data => {
        this.productions = data
        this.productions.forEach(item => { item.value = item.value + '' })
      })
    },
    getList() {
      this.listQuery.searchYsjl.cjState = 'ysjl'
      getNeedRecordList(this.listQuery).then(data => {
        this.list = data.list
        this.totalCount = data.totalCount
      })
    },
    sortChange(column) {
      this.listQuery.order = column.prop
      this.listQuery.sort = column.order.replace('ending', '')
      this.getList()
    },
    handleFilter() {
      // 查询事件
      this.listQuery.pageNum = 1
      this.getList()
    },
    onRowClick(row) {
      this.selection = row
      this.$refs.list.toggleRowSelection(row)
    },
    handleSelectionChange: function(val) {
      this.multipleSelection = val
    },
    onProveRowClick(row) {
      this.$refs.fileList.toggleRowSelection(row)
    },
    proveSelectionChange: function(val) {
      this.multipleProveSelection = val
    },
    handleUploadYsjl(back) {
      const fd = new FormData()
      fd.append('file', back.file)
      fd.append('ysjlId', this.selection.id)
      this.preview({
        method: 'post',
        url: '/upload/uploadZzRqYsjl',
        data: fd
      }).then(() => {
        this.getYsjlBianhao()
      })
    },
    handleUploadParam(back) {
      const fd = new FormData()
      fd.append('file', back.file)
      fd.append('ysjlId', this.selection.id)
      this.preview({
        method: 'post',
        url: '/upload/uploadZzRqParam',
        data: fd
      }).then(() => {
        this.getList()
        this.$message({
          message: '上传成功！',
          type: 'success'
        })
      })
    },
    handleUploadProof(back) {
      const fd = new FormData()
      fd.append('file', back.file)
      fd.append('ysjlId', this.selection.id)
      this.preview({
        method: 'post',
        url: '/upload/uploadZzRqProof',
        data: fd
      }).then(() => {
        if (this.selection.shebeileibiedaima === '2100' && this.selection.shengchanxingshi === '5') {
          this.getYsjlBianhao()
        } else {
          this.getList()
          this.$message({
            message: '上传成功！',
            type: 'success'
          })
        }
      })
    },
    handleUploadDrawings(file) {
      const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
      if (!isJPG) {
        this.$message.error('只能上传jpg/png格式的图片')
        return false
      }
      const fd = new FormData()
      fd.append('file', file)
      fd.append('ysjlId', this.selection.id)
      this.api({
        url: '/upload/uploadZzQpplDrawings',
        method: 'post',
        data: fd
      }).then(data => {
        if (data !== null && data !== undefined) {
          this.fileListDrawings.push(this.getAryDate('url', JSON.parse(data).name))
        }
      })
    },
    getAryDate(key, value) {
      const arr = {}
      this.$set(arr, key, process.env.VUE_APP_BASE_API + 'showImage/2000/weldingDrawings/' + value)
      return arr
    },
    handleRemove(file) {
      const fileDetails = file.url.split('/')
      const fileName = fileDetails[fileDetails.length - 1]
      this.api({
        url: '/ysjl/deleteParamImg',
        method: 'get',
        params: { fileName: fileName, ysjlId: this.selection.id }
      }).then(() => {
        const afl = []
        this.fileListDrawings.forEach(v => {
          if (v.url !== this.getAryDate('url', fileName).url) {
            afl.push(v)
          }
        })
        this.fileListDrawings = afl
      })
    },
    closeDialog() {
      this.fileListDrawings = []
    },
    closeComparison() {
      this.color_1 = 'black'
      this.color_2 = 'black'
      this.color_3 = 'black'
      this.color_4 = 'black'
      this.color_5 = 'black'
    },
    handleUploadProve(back) {
      const fd = new FormData()
      fd.append('file', back.file)
      fd.append('ysjlId', this.selection.id)
      fd.append('userId', this.$store.getters.userId)
      this.preview({
        method: 'post',
        url: '/upload/uploadProve',
        data: fd
      }).then(() => {
        this.getProveList(this.selection.id)
      })
    },
    async showDataComparison(row) {
      this.api({
        url: '/ysjl/getYsjlById',
        method: 'get',
        params: {
          ysjlId: row.id
        }
      }).then(async data => {
        this.selection = data.ysjl
        await this.getParamByYsjlId(this.selection.id, this.selection.shebeizhongleidaima)
        this.api({
          url: '/renwu/get',
          method: 'get',
          params: {
            renwuId: this.selection.renwuId
          }
        }).then(data => {
          this.renwu = data
          this.setSpanTextColor(this.renwu, this.selection, this.ysjlParam)
          this.productions.forEach(item => {
            if (item.value === this.renwu.s107) {
              this.renwu.s107 = item.name
            }
          })
        })
        this.dialogFormComparison = true
      })
    },
    setSpanTextColor(renwu, ysjl, ysjlParam) {
      if (renwu.shebeimingcheng !== ysjl.shebeimingcheng) {
        this.color_1 = 'red'
      }
      if (renwu.chanpinbianhao !== ysjl.chanpinbianhao) {
        this.color_2 = 'red'
      }
      if (renwu.s29 !== ysjlParam.rongqituhao) {
        this.color_3 = 'red'
      }
      if (renwu.s27 !== ysjlParam.rongqileibie) {
        this.color_4 = 'red'
      }
      if (renwu.guigexinghao !== ysjl.guigexinghao) {
        this.color_5 = 'red'
      }
    },
    showVerification(renwuId, viewButton) {
      this.currentRenwuId = renwuId
      this.viewButton = viewButton
      this.dialogFormVisible = true
    },
    showVerificationProof(ysjlId) {
      this.getProveListDrawings(ysjlId)
      this.dialogFormVisibleProof = true
    },
    getProveList(ysjlId) {
      this.preview({
        method: 'get',
        url: '/download/getProveListByYsjlId',
        params: {
          ysjlId: ysjlId
        }
      }).then(data => {
        this.fileList = data
      })
    },
    getParamByYsjlId: async function(ysjlId, sbzldm) {
      await this.api({
        method: 'get',
        url: '/ysjl/getParamByYsjlId',
        params: {
          ysjlId: ysjlId,
          sbzldm: sbzldm
        }
      }).then(data => {
        this.ysjlParam = data
      })
    },
    getProveListDrawings(ysjlId) {
      this.getParamByYsjlId(ysjlId, '2000')
      if (this.ysjlParam !== null && this.ysjlParam.img1 !== null && this.ysjlParam.img1 !== undefined) {
        const alf = JSON.parse(this.ysjlParam.img1)
        alf.forEach(v => {
          this.fileListDrawings.push(this.getAryDate('url', v.name))
        })
      }
    },
    deleteProve() {
      if (this.multipleProveSelection.length === 0) {
        this.$message({
          type: 'error',
          message: '请选中需要删除的数据！'
        })
        return false
      } else {
        this.$confirm('确定删除当前选中记录?', '提示', {
          confirmButtonText: '确定',
          showCancelButton: true,
          type: 'warning'
        }).then(() => {
          const pks = []
          this.multipleProveSelection.forEach(prove => {
            pks.push(prove.id)
          })
          this.preview({
            url: '/upload/deleteProve',
            method: 'delete',
            params: {
              pks: pks
            },
            paramsSerializer: function(params) {
              return qs.stringify(params, { indices: false })
            }
          }).then(() => {
            this.$message({ message: '删除成功。', type: 'success' })
            this.getProveList(this.selection.id)
          })
        })
      }
    },
    //  检验员核算费用弹窗
    approved() {
      if (this.multipleSelection.length === 0) {
        this.$message({
          type: 'error',
          message: '请在列表选择要生成报告的数据！'
        })
        return false
      } else {
        const pks = []
        let ifRun = true
        let ifParam = true
        this.multipleSelection.forEach(ysjl => {
          if (!ysjl.jilubianhao || ysjl.jilubianhao === '') {
            ifRun = false
          }
          if (!ysjl.zhizaoriqi || ysjl.zhizaoriqi === '' || !ysjl.bianzhiriqi || ysjl.bianzhiriqi === '') {
            ifParam = false
          }
          pks.push(ysjl.id)
        })
        if (ifRun && ifParam) {
          this.api({
            url: '/ysjl/inspectionApproved',
            method: 'POST',
            params: { pks: pks },
            paramsSerializer: function(params) {
              return qs.stringify(params, { indices: false })
            }
          }).then((data) => {
            this.listInspection = data
            this.dialogInspectionVisible = true
          })
        } else {
          const message = !ifRun ? '存在未上传原始记录数据！' : '存在未上传数据表或批量证明数据！'
          this.$message({ type: 'error', message: message })
        }
      }
    },
    //  生成报告
    batchGenerate() {
      //  检验员核算保存
      this.api({
        url: '/ysjl/inspectionApprovedSave',
        method: 'POST',
        data: this.listInspection
      }).then(() => {
        const pks = []
        this.multipleSelection.forEach(ysjl => {
          pks.push(ysjl.id)
        })
        this.api({
          url: '/ysjl/batchGenerateReport',
          method: 'POST',
          params: { pks: pks },
          paramsSerializer: function(params) {
            return qs.stringify(params, { indices: false })
          }
        }).then(() => {
          this.dialogInspectionVisible = false
          this.$message({ message: '生成报告成功。', type: 'success' })
          this.getList()
          Utils.$emit('bggl-daiban-list')
          Utils.$emit('manufacture-done-list')
        })
      })
    },
    fillInVacancy(ysjl) {
      if (ysjl) {
        // 固定式承压部件
        this.showWhis = ysjl.shengchanxingshi === '6'
        if (ysjl.beizhu !== null && ysjl.beizhu !== '') {
          this.beizhu = JSON.parse(ysjl.beizhu)
          this.dialogStatus = 'update'
        }
      }
      this.dialogFillInVacancyVisible = true
    },
    /**
     * 填写报告备注
     */
    async showUpdateReportNotes(ysjl) {
      await this.getParamByYsjlId(ysjl.id, ysjl.shebeizhongleidaima)
      this.ysjlParam.ysjlId = ysjl.id
      this.dialogShowUpdateReportNotesVisible = true
    },
    /**
     *  原始记录参数修改
     */
    updateYjslParam() {
      if (this.ysjlParam) {
        const param = {}
        param.ysjlId = this.ysjlParam.ysjlId
        if (this.ysjlParam.reportNotesNeirong) {
          param.s110 = '备注：'
        } else {
          param.s110 = ''
        }
        param.s111 = this.ysjlParam.reportNotesNeirong
        this.api({
          url: '/ysjl/updateYsjlSelectiveParam',
          method: 'post',
          data: param
        }).then(() => {
          this.$message.success('操作成功！')
          this.dialogShowUpdateReportNotesVisible = false
          this.getList()
        })
      }
    },
    cellStyle() {
      return 'padding: 0'
    },
    editYsjl(ysjl) {
      this.api({
        url: '/template/getById',
        method: 'get',
        params: {
          id: ysjl.modelId
        }
      }).then(data => {
        const queryParam = {
          id: ysjl.id,
          jyxm: ysjl.jianyanxiangmu,
          departmentId: this.$store.getters.departmentId,
          jianyanrenyuan: ysjl.jianyanrenyuan,
          state: 'update',
          renwuId: ysjl.renwuId,
          modelId: ysjl.modelId,
          jylb: ysjl.jianyanleibie,
          neibuleibie: ysjl.neibuleibie,
          sbzldm: ysjl.shebeizhongleidaima,
          sblbdm: ysjl.shebeileibiedaima,
          sbpzdm: ysjl.shebeipinzhongdaima,
          chargeId: ysjl.chargeId
        }
        if (ysjl.bglx === 1) {
          this.$router.push({ path: data.tempPath + '/' + ysjl.id, query: queryParam })
        } else {
          this.$router.push({ path: data.tempPath, query: queryParam })
        }
      })
    },
    createOrUpdateBeizhu() {
      if (this.beizhu) {
        this.selection.beizhu = JSON.stringify(this.beizhu)
        this.api({
          url: '/ysjl/updateYsjlOne',
          method: 'post',
          data: this.selection
        }).then(() => {
          this.$message.success('编辑成功！')
          this.dialogFillInVacancyVisible = false
          this.getList()
        })
      }
    },
    /**
     * 生产形式
     */
    getProductionName(row, column, cellValue) {
      const data = this.productions
      for (let i = 0; i < data.length; i++) {
        if (data[i].value === cellValue) {
          return data[i].name
        }
      }
    },
    /**
     *  创建原始记录编号
     */
    getYsjlBianhao() {
      this.apibjd({
        url: '/ysjl/getYsjlBianhao',
        method: 'get',
        params: { ysjlId: this.selection.id }
      }).then(() => {
        this.getList()
        this.showDataComparison(this.selection)
        this.$message({
          message: '上传成功！',
          type: 'success'
        })
      })
    }
  }
}
</script>
<style>
  .el-table .restartdw-row {
    color: red;
  }
  .identification{
    width: 30px;
    height:15px;
    display: inline-block;
    border:gray 1px solid;
    border-radius:15px;
    float: left;
  }
   input::-webkit-outer-spin-button,
   input::-webkit-inner-spin-button {
     -webkit-appearance: none !important;
     margin: 0;
   }
</style>
