<template>
  <el-dialog :modal-append-to-body="false" :title="title" v-bind="$attrs" width="700px"
             @close="onClose"
             @open="onOpen"
             v-on="$listeners"
  >
    <el-form v-show="showSearch" ref="queryForm" :inline="true" :model="queryParams" label-width="90px"
             size="small"
    >
      <el-form-item label="安装包名称" prop="installpackName">
        <el-input
          v-model="queryParams.installpackName"
          clearable
          placeholder="请输入安装包名称"
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button icon="el-icon-search" size="mini" type="primary" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column align="center" label="安装包名称" prop="configId"/>
      <el-table-column :show-overflow-tooltip="true" align="center" label="版本号" prop="configName"/>
      <el-table-column :show-overflow-tooltip="true" align="center" label="安装包大小" prop="configName"/>
      <el-table-column :show-overflow-tooltip="true" align="center" label="适用系统" prop="configValue"/>
      <el-table-column align="center" label="状态" prop="configType">
        <template slot-scope="scopeA">
          <dict-tag :options="dict.type.sys_yes_no" :value="scopeA.row.type"/>
        </template>
      </el-table-column>
      <el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="50">
        <template slot-scope="scope">
          <el-button circle icon="el-icon-plus" size="20" type="primary" @click="addPack"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--    <div slot="footer" class="dialog-footer">-->
    <!--      <el-button type="primary" @click="submitAddForm()">确 定</el-button>-->
    <!--    </div>-->
  </el-dialog>
</template>
<script>

import { listConfig } from '@/api/system/config'

export default {
  name: 'AddPack',
  dicts: ['sys_yes_no'],
  data() {
    return {
      // 遮罩层
      title: '添加安装包',
      loading: true,
      configName: undefined,
      form: {},
      dataList: [],
      // 显示搜索条件
      showSearch: true,
      total: 0,
      // 白名单配置表单验证
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        installpackName: undefined
      }
    }

  },
  created() {
    this.getList()
  },
  methods: {

    /** 查询参数列表 */
    getList() {
      this.loading = true
      listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
          this.dataList = response.rows
          this.total = response.total
          this.loading = false
        }
      )
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = []
      this.resetForm('queryForm')
      this.handleQuery()
    },
    // 确定安装包
    submitAddForm() {

    },

    /** 新增当前包的按钮 */
    addPack() {

    },

    closeModal() {
      this.$emit('close')
    },
    onOpen() {
      this.active = this.current
      this.key = ''
    },
    onClose() {
    }
  }
}
</script>
