<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="mini" :inline="true" label-width="90px">
      <el-row>
        <el-col :span="8">
          <el-form-item class="treeselectForm treeselectForm2" label="组织架构" prop="deptIds">
            <tree @treeselectFn="treeselectFn" :treeval="deptIds" style="width: 193px;"></tree>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table v-loading="loading" :data="zipList">
      <el-table-column label="文件名" align="center" prop="fileName" width="260" :show-overflow-tooltip="true" />
      <el-table-column label="文件大小" align="center" prop="fileSize"/>
      <el-table-column label="数量" align="center" prop="num"/>
      <el-table-column label="关联文件地址" align="center" prop="fileUrl" width="260" :show-overflow-tooltip="true" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
      <el-table-column label="创建人员" align="center" prop="createBy"/>
<!--      <el-table-column label="描述" align="center" prop="remark" />-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-download"
            @click="handleExport(scope.row)"
          >下载</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
    import { zipList } from "@/api/sfa/zip";
    import tree from "@/views/components/sfa/treeselectParent2";
    export default {
        name: "Zip",
        components: { tree },
        data() {
            return {
                // 查询参数
                queryParams: {
                    deptIds:[],
                    pageNum: 1,
                    pageSize: 10,
                },
                deptIds:[],
                zipList:[],
                loading: true,
                total: 0,
            };
        },
        created() {
            this.getList();
        },
        methods: {
            /** 查询产品信息列表 */
            getList() {
                let url = '';
                this.zipList = [];
                this.queryParams.deptIds= this.deptIds.join(",");
                zipList(this.queryParams).then(response => {
                    this.loading = false;
                    console.log(response);
                    this.zipList =  response.rows;
                    this.total = response.total;
                });
            },
            treeselectFn(val){
                this.deptIds = val;
            },

            /** 搜索按钮操作 */
            handleQuery() {
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.deptIds = [];
                this.handleQuery();
            },

            handleExport(row){
                let obj= {
                    fileName:row.fileName
                }
                // this.download('sfa/performance/download', {
                //     ...obj
                // }, `${row.fileName}`)
                window.location.href = row.fileUrl;
            }
        }
    };
</script>
