<template>
  <a-modal
    :title="modalTitle"
    :width="300"
    :visible="visible"
    :confirmLoading="confirmLoading"
    class="ant-modal2"
    @cancel="handleCancel"
  >
    <div class="editable-cell-input-wrapper">
      <a-input-number :min='1' v-model='text'  />
    </div>
    <template slot="footer">
      <a-button :loading="confirmLoading" type="primary" @click="handleSelect()">确定</a-button>
    </template>
  </a-modal>
</template>

<script>
import { STable, Ellipsis } from '@/components'
export default {
  name: 'PurchaseSpareNumSelectModal',
  components: {
    STable,
    Ellipsis
  },
  data () {
    return {
      confirmLoading: false,
      text: 1,
      modalTitle: null,
      visible: false,
      id: null,
      warnStatus: null,
      price: null,
      expandedKeys: [],
      selectedKeys: [],
      selectedRowKeys: [],
      selectedRows: [],
      options: {
        alert: { show: true, clear: () => { this.selectedRowKeys = [] } },
        rowSelection: {
          selectedRowKeys: this.selectedRowKeys,
          onChange: this.onSelectChange
        }
      },
      optionAlertShow: false
    }
  },
  created () {
  },
  methods: {
    handleOk () {
      this.$refs.table.refresh()
    },
    onSelectChange (selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.selectedRows = selectedRows
    },
    base (record) {
      this.visible = true
      this.modalTitle = '填写数量'
      this.text = 1
      this.id = record.id
      this.warnStatus = record.warnStatus
      this.price = record.price
    },
    handleCancel () {
      this.visible = false
      this.confirmLoading = false
    },
    handleSelect () {
      this.confirmLoading = true
      const returnParam = {}
      returnParam.id = this.id
      returnParam.warnStatus = this.warnStatus
      returnParam.num = this.text
      returnParam.price = this.price
      this.$emit('selected', returnParam)
      this.confirmLoading = false
      this.visible = false
    },
    mySelect (selectedRowKeys, selectedRows) {
      this.$refs.table.updateSelect(selectedRowKeys, selectedRows)
      this.$refs.table.rowSelection.onChange(selectedRowKeys, selectedRows)
    },
    onSelect: function (selectedKeys, info) {
      this.selectedKeys = selectedKeys
      this.queryParam.typeId = selectedKeys.length > 0 ? selectedKeys[0] : ''
      this.queryParam.typeName = ''
      this.$refs.table.refresh(true)
    }
  }
}
</script>
