<template>
  <a-card :bordered="false">
    <!-- 查询区域 @submit="handleSubmit"-->
    <div class="table-page-search-wrapper">
      <l-q-k-form-build :value="jsonData" ref="KFormBuild" />
    </div> 
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 @click="handleExportXls('入仓单')" -->
    <div class="table-operator">
      <a-button type="primary" icon="download" >导出</a-button>
    </div>

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

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        
        >-->
        <!--:loading="loading"   :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" @change="handleTableChange"

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <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="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
-->
  </a-card>
</template>
<script>
/*
 * author kcz
 * date 2019-11-20
 */
import { getAction } from '@/api/manage'
export default {
  name: "LQKFListFormView",
  data() {
    return {
      visible: false,
      previewWidth: 850,
      jsonData: {},
      columns:{},
      dataSource:{},
      ipagination:{}
    };
  },
  beforeCreate(){
    console.log("创建前：");

    let id = this.$route.path.replace("/form/LQKForm/", "");
    let timestamp = new Date().getTime();

    let url = `${window._CONFIG['domianURL']}/online/cgreport/api/getQueryInfo/${id}?_t=${timestamp}`;
    getAction(url).then(res=>{
      console.log("res", res);
      if(res.success && res.result){
        this.jsonData.list = res.result;
        this.jsonData.config = {
                                  "layout": "horizontal",
                                  "labelCol": {
                                    "xs": 4,
                                    "sm": 4,
                                    "md": 4,
                                    "lg": 4,
                                    "xl": 4,
                                    "xxl": 4
                                  },
                                  "wrapperCol": {
                                    "xs": 18,
                                    "sm": 18,
                                    "md": 18,
                                    "lg": 18,
                                    "xl": 18,
                                    "xxl": 18
                                  },
                                  "hideRequiredMark": false,
                                  "customStyle": ""
                                };
        this.$refs.KFormBuild.setData(this.jsonData)
      }else{
        console.log(`获取${id}失败。`,res)
      }
    });
    
    let dataUrl = `${window._CONFIG['domianURL']}/online/cgreport/api/getColumnsAndData/${id}?_t=${timestamp}&order=desc&pageNo=1&pageSize=10`;
    getAction(dataUrl).then(res=>{
      if(res.success && res.result){
        this.columns = res.result.columns;
        this.dataSource = res.result.data;
      }else{
        console.log(`获取${id}失败。`,res)
      }
    });
  },
  methods: {
    handleGetData() {
      this.$refs.KFormBuild.bvvvnhhh()
        .then(res => {
          console.log(res, "获取数据成功");
        })
        .catch(err => {
          console.log(err, "获取数据失败");
        });
    },
    handleCancel() {
      this.visible = false;
    }
  }
};
</script>
