<template>
  <page-layout>
  <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="8">
            <a-form-item label="需求名称">
              <a-input placeholder="请输入需求名称" v-model="queryParam.name"></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>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus" v-has="'hlgrequirement:add'">新增</a-button>
    </div>

    <!-- table区域-begin -->
    <div>


      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="图片不存在" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无此文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="uploadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" v-has="'hlgrequirement:edit'">编辑</a>

          <a-divider type="vertical" v-has="'hlgrequirement:delete'"/>
          <a-dropdown>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a v-has="'hlgrequirement:delete'">删除</a>
                </a-popconfirm>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <hlgRequirement-modal ref="modalForm" @ok="modalFormOk"></hlgRequirement-modal>
  </a-card>
  </page-layout>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import HlgRequirementModal from './modules/HlgRequirementModal'
  import PageLayout from '@/components/page/PageLayout'

  export default {
    name: "HlgRequirementList",
    mixins:[JeecgListMixin],
    components: {
      HlgRequirementModal,
      PageLayout
    },
    data () {
      return {
        description: 'hlg_requirement管理页面',
        // 表头
        columns: [
          {
            title:'需求名称',
            align:"left",
            dataIndex: 'name'
          },
          {
            title:'需求描述',
            align:"left",
            dataIndex: 'description'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"left",
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/hlgrequirement/hlgRequirement/list",
          delete: "/hlgrequirement/hlgRequirement/delete",
          deleteBatch: "/hlgrequirement/hlgRequirement/deleteBatch",
          exportXlsUrl: "/hlgrequirement/hlgRequirement/exportXls",
          importExcelUrl: "hlgrequirement/hlgRequirement/importExcel",
        },
        dictOptions:{
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      initDictConfig(){
      }
       
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>