<template>
  <div>
    <el-table :data="params.data" v-loading="params.loading" :ref="'multipleTable' + params.index" class="xg-ytg-line-hei">
      <el-table-column type="index" align="center" label="序号" width="40px"></el-table-column>
      <el-table-column white-space-nowrap label="计划号" align="left" prop="PACT_INDEX" min-width="110"></el-table-column>
      <el-table-column white-space-nowrap label="订单号" align="left" prop="ORDER_NO" show-overflow-tooltip min-width="140" :filter-method="filterColumn"></el-table-column>
      <el-table-column white-space-nowrap label="生产订单号" align="left" prop="PROD_ORDER_NO" show-overflow-tooltip min-width="100" :filter-method="filterColumn"></el-table-column>
      <el-table-column white-space-nowrap label="设计子板规格(长度：mm 重量：t)">
        <el-table-column white-space-nowrap label="厚" prop="CHILD_THK" align="right" min-width="50"></el-table-column>
        <el-table-column white-space-nowrap label="宽" prop="CHILD_WTH" align="right" min-width="50"></el-table-column>
        <el-table-column white-space-nowrap label="长" prop="CHILD_LEN" align="right" min-width="50"></el-table-column>
        <el-table-column white-space-nowrap label="重" prop="CHILD_WGT" align="right" min-width="50">
          <template slot-scope="scope">
            <span>{{scope.row.CHILD_WGT | weightTrans}}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column white-space-nowrap label="订单要求规格(长度：mm 重量：t)">
        <el-table-column white-space-nowrap label="厚" prop="THICK" align="right" min-width="50"></el-table-column>
        <el-table-column white-space-nowrap label="宽" prop="WIDTH" align="right" min-width="50"></el-table-column>
        <el-table-column white-space-nowrap label="长" prop="LENGTH" align="right" min-width="50"></el-table-column>
        <el-table-column white-space-nowrap label="重" prop="SINGLE_WEIGHT" align="right" min-width="50">
          <template slot-scope="scope">
            <span>{{scope.row.SINGLE_WEIGHT | weightTrans}}</span>
          </template>
        </el-table-column>
        <el-table-column white-space-nowrap label="长度上限" prop="LENGTH_MAX" align="right" min-width="60"></el-table-column>
        <el-table-column white-space-nowrap label="长度下限" prop="LENGTH_MIN" align="right" min-width="60"></el-table-column>
        <el-table-column white-space-nowrap label="宽度上限" prop="WIDTH_MAX" align="right" min-width="60"></el-table-column>
        <el-table-column white-space-nowrap label="宽度下限" prop="WIDTH_MIN" align="right" min-width="60"></el-table-column>
        <el-table-column white-space-nowrap label="单重上限" prop="SINGLE_WEIGHT_MAX" align="right" min-width="60">
          <template slot-scope="scope">
            <span>{{scope.row.SINGLE_WEIGHT_MAX | weightTrans}}</span>
          </template>
        </el-table-column>
        <el-table-column white-space-nowrap label="单重下限" prop="SINGLE_WEIGHT_MIN" align="right" min-width="60">
          <template slot-scope="scope">
            <span>{{scope.row.SINGLE_WEIGHT_MIN | weightTrans}}</span>
          </template>
        </el-table-column>
      </el-table-column>
      <el-table-column white-space-nowrap label="定尺方式" prop="FIX_SIZE_DESC" align="left" show-overflow-tooltip min-width="80"></el-table-column>
      <el-table-column white-space-nowrap label="切边方式" prop="CUT_EDGE_TYPE_NAME" align="left" show-overflow-tooltip min-width="80"></el-table-column>
      <el-table-column white-space-nowrap label="交货重量下限(t)" prop="DELIVERY_ERROR_MAX" align="right" min-width="60">
        <template slot-scope="scope">
          <span>{{scope.row.DELIVERY_ERROR_MAX | weightTrans}}</span>
        </template>
      </el-table-column>
      <el-table-column white-space-nowrap label="交货重量上限(t)" prop="DELIVERY_ERROR_MIN" align="right" min-width="60">
        <template slot-scope="scope">
          <span>{{scope.row.DELIVERY_ERROR_MIN | weightTrans}}</span>
        </template>
      </el-table-column>
      <el-table-column label="取样要求" prop="SAMPING" align="left" min-width="100"></el-table-column>
      <el-table-column label="特殊要求" align="left" show-overflow-tooltip prop="SPECIAL" min-width="80">
        <template slot-scope="props">
          <el-button type="text" size="small" @click="showSpecialDetail(props.row)">{{props.row.SPECIAL}}</el-button>
        </template>
      </el-table-column>
      <el-table-column label="附加要求" align="left" show-overflow-tooltip prop="ADD_ASK_DESC" min-width="80"></el-table-column>
      <el-table-column label="检验机构" align="left" show-overflow-tooltip prop="ORG" min-width="80"></el-table-column>
      <el-table-column white-space-nowrap label="收货单位" align="left" show-overflow-tooltip prop="RECIVER_UNIT_NAM" min-width="100"></el-table-column>
      <el-table-column label="工艺要求" align="left" prop="PROCESS" show-overflow-tooltip min-width="80"></el-table-column>
      <el-table-column white-space-nowrap label="交货日期" prop="DELIVER_DATE" min-width="100"></el-table-column>
      <el-table-column white-space-nowrap label="交货状态" prop="DELIVERY_STATE_DESC" min-width="80" :filter-method="filterColumn"></el-table-column>
    </el-table>
  </div>
</template>
<script>
import {formatDate} from '@/utils/util.js';
export default {
  props: ['params', 'isshow'],
  data () {
    return {
      isSearch: true
    }
  },
  mounted () {
    this.getOrderDetailData(this.params)
  },
  methods: {
    showSpecialDetail (row) {
      this.$emit('showdetail', row)
    },
    getOrderDetailData (row) {
      let _this = this;
      let designNo = row.design_no || row.DESIGN_NO || row.object_type
      if (designNo) {
        _this.$set(row, 'loading', true)
        _this.axios.post('/PlnSlabdesignMultinfoService/doQueryWaitApplyFictitiousChildWeb', [{object: {design_no: designNo}}])
          .then(function (response) {
            if (response) {
              for (let item of response.data.data) {
                item.DELIVER_DATE = formatDate(item.DELIVER_DATE, 'yyyy-MM-dd')
              }
              _this.$set(row, 'data', response.data.data)
              _this.$refs['multipleTable' + row.index].clearFilter();
              _this.setFilterDatas(_this.$refs['multipleTable' + row.index].columns, row.data, ['ORDER_NO', 'PROD_ORDER_NO', 'DELIVERY_STATE_DESC']);
            }
            _this.$set(row, 'loading', false)
            console.log('执行了', row.loading)
          }).catch(function () {
            _this.$set(row, 'loading', false)
          })
      }
    }
  },
  watch: {
    // params: {
    //   // console.log('执行了监听')
    //   handler () {
    //     console.log('监听到了变化')
    //     if ('isShow' in this.params) {
    //       this.getOrderDetailData(this.params)
    //     }
    //   },
    //   deep: true
    // }
    isshow () {
      this.getOrderDetailData(this.params)
    }
  }
}
</script>
