<template>
   <a-card :bordered="false" >
    <!-- 查询 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="6" :sm="12">
            <a-form-item label="设备名称">
              <a-input placeholder="输入设备名称查询" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="12">
            <a-form-item label="购买日期">
              <a-date-picker
               style="width: 100%"
               placeholder="请选择购买日期"
               v-model="queryParam.buyTime"
              />
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="12">
            <a-form-item label="状态">
              <a-input placeholder="输入设备状态查询" v-model="queryParam.type"></a-input>
            </a-form-item>
          </a-col>

          <a-col :md="6" :sm="8">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator" style="border-top: 5px">
      <a-button @click="handleAdd" type="primary" icon="plus">添加</a-button>
      <a-button @click="handleDelete" type="primary" icon="plus">删除</a-button>
    </div>

     <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="operation" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a @click="handleDetail(record)">详情</a>
        </span>


      </a-table>
    </div>
    <!-- 新增框 -->
    <add-material-registration ref='AddMaterialRegistration'></add-material-registration>
    <detail-material-registration ref="DetailMaterialRegistration"></detail-material-registration>
   </a-card>
   
</template>

<script>
  
  import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  import AddMaterialRegistration from './modules/AddMaterialRegistration'
  import DetailMaterialRegistration from './modules/DetailMaterialRegistration'

  export default {
    name: "MaterialRegistration",
    mixins: [JeecgListMixin],
    components: {
    AddMaterialRegistration,
    DetailMaterialRegistration
    },
    data() {
      return {
          queryParam:{   //查询条件

          },
        //   表头
        columns:[
            {
            title: '编号',
            align: "center",
            dataIndex: 'code',
            width: 120
          },
          {
            title: '设备名称',
            align: "center",
            dataIndex: 'name',
            width: 120
          },
          {
            title: '型号',
            align: "center",
            dataIndex: 'model',
            width: 120
          },
          {
            title: '购买日期',
            align: "center",
            dataIndex: 'buyTime',
            width: 120
          },
          {
            title: '购买数量',
            align: "center",
            dataIndex: 'buyNum',
            width: 120
          },
          {
            title: '单位',
            align: "center",
            dataIndex: 'unit',
            width: 120
          },
          {
            title: '购买金额',
            align: "center",
            dataIndex: 'amount',
            width: 120
          },
          {
            title: '使用者',
            align: "center",
            dataIndex: 'useId',
            width: 120
          },
          {
            title: '状态',
            align: "center",
            dataIndex: 'type',
            width: 120
          },
          {
            title: '供货方',
            align: "center",
            dataIndex: 'supply',
            width: 120
          },
          {
            title: '备注',
            align: "center",
            dataIndex: 'remarks',
            width: 120
          },
          {
            title: '来源',
            align: "center",
            dataIndex: 'source',
            width: 120
          },
          {
            title: '操作',
            align: "center",
            dataIndex: 'operation',
            scopedSlots: { customRender: 'operation' },
            width: 120
          },
        ]
      }
    },
    computed: {
    
    },
    created(){
        this.getData()
    },
    methods: {
        // 查询
        searchQuery(){

        },
        //重置
        searchReset(){
          this.queryParam ={}
        },
        // 获取数据
        getData(){
            
        },
        // 删除
        handleDelete(){

        },
        // 添加
        handleAdd(){
          this.$refs.AddMaterialRegistration.visible = true
        },
        //编辑
        handleEdit(record){
           this.$refs.AddMaterialRegistration.visible = true
            this.$refs.AddMaterialRegistration.defult = 'edit'
            this.$refs.AddMaterialRegistration.formState = record
        },
        //详情
        handleDetail(record){
           this.$refs.DetailMaterialRegistration.visible = true
           this.$refs.DetailMaterialRegistration.formState = record

        },
    }
     

  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>