<template>
  <div>
    <!--内容-->
    <div class="layout-content-padding">
      <div class="layout-content-main">
        <Row>
          <!--查询-->
          <Col span="24" style="margin-top:10px">
            <Form v-show="searchOpen" :d="formId" :label-width="90" inline onsubmit="return false">
              <label class="label-sign"></label>
              <Form-item class="search-item" label="委托单位:" style="margin-left: -20px">
                <Input v-model="formObj.client" name="client" placeholder="请输入委托单位" clearable @on-enter="_formSearch"/>
              </Form-item>
              <Form-item class="search-item" label="委托编号:">
                <Input v-model="formObj.entrustCode"  name="entrustCode" placeholder="请输入委托编号" clearable @on-enter="_formSearch"/>
              </Form-item>
              <Form-item class="search-item" label="样品名称:">
                <Input v-model="formObj.name"  name="name" placeholder="请输入样品名称" clearable @on-enter="_formSearch"/>
              </Form-item>
              <Form-item class="search-item" label="样品编号:">
                <Input v-model="formObj.code"  name="code" placeholder="请输入样品编号" clearable @on-enter="_formSearch"/>
              </Form-item>

              <Form-item class="search-item" label="出厂编号:">
                <Input v-model="formObj.factoryNumber"  name="factoryNumber" placeholder="请输入出厂编号" clearable @on-enter="_formSearch"/>
              </Form-item>
              <Form-item class="search-btn">
                <Button type="primary" @click="_formSearch">搜索</Button>
              </Form-item>
            </Form>
          </Col>
          <!--操作-->
          <Col span="24">
            <btn-list :msg="btn" :open="searchOpen" :show-search-btn="true" class="contHide"
                     @on-result-change="_btnClick"></btn-list>
          </Col>
          <!-- 表格 -->
          <Col span="24">
            <PTVXETable
              ref="pageTable"
              :form-id="formId"
              :table-height="tableHeight"
              :get-page="getPage"
              :icon-msg="iconMsg"
              @on-result-change="_tableResultChange">
              <vxe-table-column
                v-for="item in pageColumns"
                :key="item.key"
                :field="item.key"
                :title="item.title"
                :width="item.width"
                :min-width="200"
                :fixed="item.fixed?item.fixed:undefined"
                sortable
              >
                <template slot-scope="scope">
                  <span v-if="item.dateTime">{{scope.row[item.key]?$dateformat(scope.row[item.key],'yyyy-mm-dd HH:MM:ss'):''}}</span>
                  <span v-else-if="item.status">{{scope.row[item.key].display}}</span>
                  <span v-else-if="item.entrustType">
                      {{scope.row[item.key]===1?'出检':'送检'}}
                  </span>
                  <span v-else>{{scope.row[item.key]}}</span>
                </template>
              </vxe-table-column>
            </PTVXETable>
          </Col>
        </Row>
      </div>
    </div>
    <!-- 添加、编辑 -->
<!--    <MeterAptitudeStandardEdit ref="editModal" @on-result-change="_page"></MeterAptitudeStandardEdit>-->
    <!--导入资质项目-->
<!--    <DownloadTemplateImport ref="sampleModal" @on-result-change="_page"></DownloadTemplateImport>-->
  </div>
</template>
<script>
import { meterSample } from '../../../api'
export default {
  name: 'MeterSampleProgress',
  components: {},
  data() {
    return {
      formId: 'meterSampleProgressFormId',
      pageColumns: [
        { title: '委托单位', key: 'client', width: 140 },
        { title: '委托单号', key: 'entrustCode', width: 130 },
        {
          title: '委托类型',
          key: 'entrustType',
          width: 110,
          entrustType: true
        },
        { title: '样品名称', key: 'name', width: 140 },
        { title: '样品编号', key: 'code', width: 130 },
        { title: '出厂编号', key: 'factoryNumber', width: 130 },
        { title: '处理进度', key: 'status', status: true, width: 120 },
        { title: '收样人', key: 'receiver', width: 120 },
        { title: '收样人时间', key: 'receiveTime', width: 120 },
        { title: '任务分配人', key: 'assignor', width: 120 },
        { title: '任务分配时间', key: 'allocateTime', width: 120 },
        { title: '领用人', key: 'flower', width: 120 },
        { title: '领用时间', key: 'flowTime', width: 120 },
        { title: '入库人', key: 'sampleInner', width: 120 },
        { title: '入库时间', key: 'sampleInnerTime', width: 120 },
        { title: '出库人', key: 'sampleOuter', width: 120 },
        { title: '出库时间', key: 'outTime', width: 120 }
      ],
      btn: [],
      iconMsg: [],
      formObj: {
        entrustCode: undefined,
        client: undefined,
        name: undefined,
        factoryNumber: undefined,
        code: undefined
      },
      searchOpen: true,
      selectIds: [],
      getPage: {},
      typeData: []
    }
  },
  computed: {
    tableHeight: function() {
      if (this.searchOpen) {
        return this.$tableHeight('search')
      } else {
        return this.$tableHeight('noSearch')
      }
    }
  },
  mounted() {
    this._page()
  },
  methods: {
    _btnClick(msg) {
      switch (msg) {
        case 'search':
          this.searchOpen = !this.searchOpen
          break
      }
    },
    _iconClick(res, data) {
      switch (res) {
        case '操作日志':
          this._record(data.id)
          break
      }
    },
    _page: async function() {
      Object.assign(this.formObj, this.$refs.pageTable._searchParams())
      const result = await meterSample.pageSampleProgress(this.formObj)
      if (result) {
        this.getPage = result
        this.$refs.pageTable._hideLoading()
      }
    },
    _formSearch() {
      this.$refs.pageTable._pageChange(1)
    },
    _tableResultChange(msg, data) {
      switch (msg) {
        case 'selectIds':
          this.selectIds = data
          break
        case 'iconClick':
          this._iconClick(data.name, data.rowData)
          break
        case 'changeSize':
          this._page()
          break
      }
    }
  }
}
</script>

<style scoped>
</style>
