<template>
  <div>
    <Modal fullscreen
           :title="title"
           v-model="show"
           @on-ok="then">
      <Topsearch ref="topsearch"
                 :list="set_list"
                 @init="init"
                 @searchData="init">

      </Topsearch>
      <Table @on-select="selectTableProject"
             :max-height="maxHeight"
             stripe
             border
             :columns="project_tableColumns"
             :data="project_tableData"></Table>
      <div ref="footercenter"
           class="footer-center">
        <Page :total="total"
              :current.sync="pageIndex"
              :show-total="true"
              :page-size="pageSize"
              :show-sizer="true"
              :show-elevator="true"
              @on-change="changePage"
              @on-page-size-change="changeSize">
        </Page>
      </div>
      <Topsearch ref="topsearch"
                 :list="set_childrenList"
                 :showbtn='set_childrenList.length>0?true:false'
                 @searchData="childrenSearch"></Topsearch>
      <Table row-key="__index"
             @on-selection-change="selectTable"
             :max-height="maxHeight"
             stripe
             border
             v-if="type!=9"
             v-show="type!=14"
             :columns="parts_tableColumns"
             :data="parts_tableData"></Table>
      <vxe-table resizable
                 border
                 size="mini"
                 align="center"
                 ref="xTree"
                 v-else
                 v-show="type!=14"
                 highlight-hover-row
                 :scroll-y="{enabled: false}"
                 :scroll-x="{enabled: false}"
                 :tree-config="{children: 'children',indent:10,line:true}"
                 :data="parts_tableData"
                 @toggle-tree-expand="toggleExpandChangeEvent"
                 @checkbox-change="selectChangeEvent">
        <vxe-table-column field="laravel"
                          title="展开"
                          type="checkbox"
                          tree-node
                          min-width="50"></vxe-table-column>
        <vxe-table-column field="stock_type_title"
                          title="存货分类名称"
                          min-width="70"></vxe-table-column>
        <vxe-table-column field="code"
                          title="存货编码"
                          min-width="80"></vxe-table-column>
        <vxe-table-column field="title"
                          title="存货名称"
                          :edit-render="{enabled:false}"
                          min-width="100">
          <template #default="{ row }">
            <vxe-button type="text"
                        style="color:#606266">{{row.title}}</vxe-button>
          </template>
        </vxe-table-column>
        <vxe-table-column field="model"
                          title="规格型号"
                          min-width="20"></vxe-table-column>
        <vxe-table-column field="matching_number"
                          title="配比数量"
                          min-width="40"
                          :edit-render="{enabled:false}"></vxe-table-column>
        <vxe-table-column field="number"
                          title="数量"
                          min-width="40"
                          :edit-render="{enabled:false}">
        </vxe-table-column>
        <vxe-table-column field="unit"
                          title="计量单位"
                          min-width="20"></vxe-table-column>
        <vxe-table-column field="single"
                          title="单重"
                          min-width="20"></vxe-table-column>
        <vxe-table-column field="total_single"
                          title="总重"
                          min-width="20">
          <template #default="{ row }">
            <span>{{ countAmount(row) }} </span>
          </template>
        </vxe-table-column>
        <vxe-table-column field="img_number"
                          title="工程图号"
                          min-width="40"></vxe-table-column>
        <vxe-table-column field="attr"
                          title="存货属性"
                          width="180"
                          :edit-render="{enabled:false,name: '$select', options: stockGoodsList, props: {multiple: true}}"></vxe-table-column>
        <vxe-table-column field="remark"
                          title="备注"
                          min-width="80"></vxe-table-column>
      </vxe-table>
    </Modal>
  </div>
</template>

<script>
export default {
  data () {
    return {
      show: false,
      list: [],
      childrenList: [],
      stockGoodsList: [],
      project_tableColumns: [],
      project_tableData: [],
      parts_tableColumns: [],
      parts_tableData: [],
      total: 100,
      pageIndex: 1,
      pageSize: 10,
      maxHeight: null,
      proxyObj: {},
      get_project_url: '',
      params: {},
      childrenParams: {},
      get_child_url: '',
      tableResult: [],
      projectDetail: {},
      detailProxy: {},
      detailChangeProxy: {},
      supplierList: [{ label: "1", value: 1 }],
      childrenCheck: {},
      purchaseTypeList: [],
      materialTypeList: [],
      currencyOrder: null
    }
  },
  computed: {
    set_list () {
      switch (this.type) {
        case 1:
          return [//参照请购单
            { title: '订单号', name: 'Input', value: '', placeholder: '请输入订单号', serverName: 'purchase_order_apply_no' },
            { title: '请购类型', name: 'Select', value: '', placeholder: '请选择请购类型', serverName: 'type_id', option: this.purchaseTypeList },
            { title: '项目名称', name: 'Input', value: '', placeholder: '请输入项目名称', serverName: 'title', },
            { title: '制单时间', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', },
          ]
        case 2:
        case 3:
        case 5:
          return [//参照采购单
            { title: '订单号', name: 'Input', value: '', placeholder: '请输入订单号', serverName: 'purchase_order_no' },
            { title: '采购类型', name: 'Select', value: '', placeholder: '请选择采购类型', serverName: 'type_id', option: this.purchaseTypeList },
            { title: '项目名称', name: 'Input', value: '', placeholder: '请输入项目名称', serverName: 'client_name', },
            { title: '供应商名称', name: 'Input', value: '', placeholder: '请输入供应商名称', serverName: 'supply_title', },
            { title: '制单时间', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', },
          ]
        case 4:
        case 6:
        case 7:
        case 8:
        case 9:
          return [//参照质检单
            { title: '订单号', name: 'Input', value: '', placeholder: '请输入订单号', serverName: 'purchase_order_quality_no' },
            { title: '项目名称', name: 'Input', value: '', placeholder: '请输入项目名称', serverName: 'type_title', },
            { title: '制单时间', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', },
          ]
      }
    },
    set_childrenList () {
      switch (this.type) {
        case 1:
          return [//采购参照请购单
            { title: '物料分类', name: 'Select', value: '', placeholder: '请选择物料分类', serverName: 'type_id', option: this.materialTypeList },
            { title: '物料名称', name: 'Input', value: '', placeholder: '请输入物料名称', serverName: 'title' },
          ]
        case 2:
        case 3:
        case 5:
          return [//到货参照采购单
            { title: '物料分类', name: 'Select', value: '', placeholder: '请选择物料分类', serverName: 'type_id', option: this.materialTypeList },
            { title: '物料名称', name: 'Input', value: '', placeholder: '请输入物料名称', serverName: 'title' },
          ]
        case 4:
        case 6:
          return [//质检参照到货单
            { title: '物料分类', name: 'Select', value: '', placeholder: '请选择物料分类', serverName: 'type_id', option: this.materialTypeList },
            { title: '物料名称', name: 'Input', value: '', placeholder: '请输入物料名称', serverName: 'title' },
          ]
        case 7:
        case 8:
        case 9:
          return [//参照质检单
            { title: '物料分类', name: 'Select', value: '', placeholder: '请选择物料分类', serverName: 'type_id', option: this.materialTypeList },
            { title: '物料名称', name: 'Input', value: '', placeholder: '请输入物料名称', serverName: 'title' },
          ]
      }
    }
  },
  watch: {},
  created () {
    this.axios({
      method: 'get',
      url: '/api/basics_material_index',
    }).then((res) => {
      this.materialTypeList = res.data.data
      this.materialTypeList.forEach(element => {
        element.label = element.title
        element.value = element.type_id
      });

    }).catch((err) => { });
    switch (this.type) {
      case 1: //采购单参照请购单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          // { title: '订单号', align: 'center', key: 'purchase_order_apply_no', minWidth: 200, },
          { title: '订单号', align: 'center', key: 'purchase_order_apply_no', minWidth: 200, },
          { title: '请购类型', align: 'center', key: 'type_title', minWidth: 150, },
          { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 150 },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '请购数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_apply_list'
        this.get_child_url = '/api/purchase_refer_apply'
        this.childrenParams = {}
        break
      case 2: //到货单参照采购单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_no', minWidth: 200, },
          { title: '采购类型', align: 'center', key: 'type_title', minWidth: 100, },
          { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '预计到货', align: 'center', key: 'arrive_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.arrive_time * 1)),
          },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '采购数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_list'
        this.get_child_url = '/api/purchase_refer'
        this.childrenParams = {}
        break
      case 3: //质检单参照采购单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_no', minWidth: 200, },
          { title: '采购类型', align: 'center', key: 'type_title', minWidth: 100, },
          { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '预计到货', align: 'center', key: 'arrive_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.arrive_time * 1)),
          },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '采购数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_list'
        this.get_child_url = '/api/quality_refer'
        this.childrenParams = { type: this.refer_type }
        break
      case 4: //质检单参照到货单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_arrive_no', minWidth: 200, },
          { title: '项目名称', align: 'center', key: 'type_title', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '到货数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_arrive_list'
        this.get_child_url = '/api/quality_refer'
        this.childrenParams = { type: this.refer_type }
        break
      case 5: //入库单参照采购单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_no', minWidth: 200, },
          { title: '采购类型', align: 'center', key: 'type_title', minWidth: 100, },
          { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '预计到货', align: 'center', key: 'arrive_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.arrive_time * 1)),
          },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '采购数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_list'
        this.get_child_url = '/api/warehouse_order_in_refer'
        this.childrenParams = { type: this.refer_type }
        break
      case 6: //入库单参照到货单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_arrive_no', minWidth: 200, },
          { title: '项目名称', align: 'center', key: 'type_title', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '到货数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_arrive_list'
        this.get_child_url = '/api/warehouse_order_in_refer'
        this.childrenParams = { type: this.refer_type }
        break
      case 7: //入库单参照质检单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_quality_no', minWidth: 200, },
          { title: '项目名称', align: 'center', key: 'type_title', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '质检数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_quality_list'
        this.get_child_url = '/api/warehouse_order_in_refer'
        this.childrenParams = { type: this.refer_type }
        break
      case 8: //出库单参照入库单
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'order_in_no', minWidth: 200, },
          { title: '项目名称', align: 'center', key: 'residential_name', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          { title: '操作员', align: 'center', key: 'nickname', minWidth: 100 },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '派工数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/warehouse_order_in_list'
        this.get_child_url = '/api/warehouse_order_out_refer'
        this.childrenParams = { type: this.refer_type }
        break
      case 9: //出库单参照派工单
        break
      case 15: //参照质检单
        this.list = [
          { title: '订单号', name: 'Input', value: '', placeholder: '请输入订单号', serverName: 'purchase_order_quality_no' },
          { title: '项目名称', name: 'Input', value: '', placeholder: '请输入项目名称', serverName: 'type_title', },
          { title: '制单时间', start_server: 'start_time', end_server: 'end_time', name: 'Input', start_value: '', end_value: '', isDate: true, start_placeholder: '开始日期', end_placeholder: '结束日期', },
        ]
        this.project_tableColumns = [
          { title: '选择', align: 'center', minWidth: 100, type: 'selection' },
          { title: '订单号', align: 'center', key: 'purchase_order_quality_no', minWidth: 200, },
          { title: '项目名称', align: 'center', key: 'type_title', minWidth: 150 },
          { title: '供应商名称', align: 'center', key: 'supply_title', minWidth: 150 },
          {
            title: '制单日期', align: 'center', key: 'crt_time', minWidth: 200,
            render: (h, params) =>
              h('span', this.func.replaceDate(params.row.crt_time * 1)),
          },
        ]
        this.parts_tableColumns = [
          { type: 'selection', align: 'center', minWidth: 100, fixed: 'left' },
          { title: '物料分类', key: 'type_title', align: 'center', minWidth: 150 },
          { title: '物料名称', key: 'title', align: 'center', minWidth: 150 },
          {
            title: '物料规格', key: '', align: 'center', minWidth: 150,
            render: (h, params) => {
              const { row } = params
              let text = `${row.long}*${row.width}*${row.high}`
              return h('span', {}, text)
            }
          },
          { title: '计量单位', key: 'unit', align: 'center', minWidth: 150 },
          { title: '质检数量', key: 'num', align: 'center', minWidth: 150 },
        ]
        this.get_project_url = '/api/purchase_quality_list'
        this.get_child_url = '/api/purchase_quality_detail'
        // this.childrenParams = { type: 3}
        break

    }
  },
  mounted () {
    // 获取采购类型
    this.axios({ method: 'get', url: '/api/basic_purchase_list', }).then((res) => {
      this.purchaseTypeList = res.data.data
      this.purchaseTypeList.forEach(element => {
        element.value = element.type_id
        element.label = element.title
      })
    }).catch((err) => { });
    this.$nextTick((e) => {
      const clientTableHeight = window.innerHeight - 51 - 57 -
        this.$refs['topsearch'].$el.clientHeight -
        this.$refs['footercenter'].clientHeight
      this.maxHeight = Math.floor(clientTableHeight / 2) - 20
    })
  },
  methods: {
    selectChangeEvent ({ records }) {
      this.tableResult = JSON.parse(JSON.stringify(records))
    },
    toggleExpandChangeEvent () { },
    countAmount (row) {
      return row.single * row.number
    },
    then () {
      this.$emit('then')
    },
    init (row) {
      row.page_index = 1
      row.page_size = this.pageSize
      let params = {
        ...this.params,
        ...row,
        sub_state: 1,
      }
      this.proxyObj = params
      this.parts_tableData = []
      this.getData(params)
    },
    childrenSearch (row) {
      switch (this.type) {
        case 1:
          row.purchase_order_apply_no = this.currencyOrder
          break;
        case 2:
          row.purchase_order_no = this.currencyOrder
          break;
        case 3:
        case 4:
        case 5:
        case 6:
        case 7:
        case 8:
        case 9:
          row.refer_order_no = this.currencyOrder
          break;
        // case 3:
        //   row.purchase_order_arrive_no = this.currencyOrder
        //   break;
        // case 4:
        //   row.purchase_order_quality_no = this.currencyOrder
        //   break;
      }
      this.axios({
        method: 'get',
        url: this.get_child_url,
        params: {
          ...row,
          type: this.refer_type
        }
      }).then((res) => {
        if (res.code == 200) {
          const deep_obj = JSON.parse(JSON.stringify(res.data))
          this.projectDetail = deep_obj
          this.parts_tableData = res.data.list
        }
      }).catch((err) => { });
    },
    getData (params) {
      params.end_time = Date.parse(params.end_time).toString().slice(0,10)
      params.start_time = Date.parse(params.start_time).toString().slice(0,10)
      this.axios(this.get_project_url, { params: params }).then((res) => {
        if (res.code == 200) {
          res.data.data.map((v) => (v.check = false))
          this.project_tableData = res.data.data
          this.total = res.data.total
        }
      })
    },
    renderRadio (h, params) {
      const { row, index } = params
      return h('Radio', {
        props: {
          value: row.check,
        },
        on: {
          'on-change': (e) => {
            if (this.type != 14) {
              this.project_tableData.forEach((item) => (item.check = false))
              this.project_tableData[index].check = true
              this.childrenCheck = this.params
              this.childrenCheck.id = row.id
              this.childrenCheck.project_sub_id = row.project_sub_id
              this.changeRadio(this.project_tableData[index])
            } else {
              // console.log('this.project_tableData[index] :>> ', this.project_tableData[index]);
              this.tableResult = [this.project_tableData[index]]
            }
          },
        },
      })
    },
    changeRadio (row) {
      console.log('row :>> ', row);
    },
    changePage (e) {
      this.pageIndex = e
      this.proxyObj.page_index = this.pageIndex
      this.getData(this.proxyObj)
    },
    changeSize (e) {
      this.pageSize = e
      this.proxyObj.page_size = this.pageSize
      this.getData(this.proxyObj)
    },
    selectTable (result) {
      this.tableResult = result
      this.tableResult.forEach(element => {
        //入库参照//0未参照1参照采购单2参照到货单3参照质检
        //出库参照//0未参照1参照入库单2参照派工单
        switch (this.type) {
          case 5:
            element.type = 1
            break;
          case 6:
            element.type = 2
            break;
          case 7:
            element.type = 3
            break;
          case 8:
            element.type = 1
            break;
          case 9:
            element.type = 2
            break;
          default:
            break;
        }
      });
    },
    selectTableProject (selection, row) {
      switch (this.type) {
        case 1://采购单参照请购单
          this.currencyOrder = row.purchase_order_apply_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              purchase_order_apply_no: row.purchase_order_apply_no
            }
          }).then((res) => {
            res.data.forEach(element => {
              element.residential_name = row.residential_name
            });
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break;
        case 2://到货单参照采购单
          this.currencyOrder = row.purchase_order_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              purchase_order_no: row.purchase_order_no
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break;
        case 3://质检单参照采购单
          this.currencyOrder = row.purchase_order_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              refer_order_no: row.purchase_order_no,
              type: this.refer_type
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break;
        case 4://质检单参照到货单
          this.currencyOrder = row.purchase_order_arrive_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              refer_order_no: row.purchase_order_arrive_no,
              type: this.refer_type
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break;
        case 5://入库单参照采购单
          this.currencyOrder = row.purchase_order_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              refer_order_no: row.purchase_order_no,
              type: this.refer_type
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break
        case 6://入库单参照到货单
          this.currencyOrder = row.purchase_order_arrive_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              refer_order_no: row.purchase_order_arrive_no,
              type: this.refer_type
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break
        case 7://入库单参照质检单
          this.currencyOrder = row.purchase_order_quality_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              refer_order_no: row.purchase_order_quality_no,
              type: this.refer_type
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break
        case 8://出库单参照入库单
          this.currencyOrder = row.order_in_no
          this.axios({
            method: 'get',
            url: this.get_child_url,
            params: {
              refer_order_no: row.order_in_no,
              type: this.refer_type
            }
          }).then((res) => {
            this.parts_tableData = [...this.parts_tableData, ...res.data]
          }).catch((err) => { });
          break
        default:
          break;
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.footer-center {
  display: flex;
  justify-content: center;
  padding: 10px 0;
}
/deep/.ivu-table-fixed-body {
  padding-bottom: 20px;
}
</style>
