<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap">
    </a-table>
    <!-- <list-modal-list :listData = "dataXQ"></list-modal-list> -->
    <template slot="footer">
        <a-button @click="handleCancel">取消</a-button>
    </template>
  </j-modal>
</template>

<script>
// import ListModalList from './listModalList.vue'
import { httpAction, getAction, postAction } from '@/api/manage'
import { filterObj } from '@/utils/util';

  export default {
    name: 'ListModal',
    props: {
        listData: {
            type: Object,
            default: function(){
                return {} // 使用工厂函数返回默认值
            }
        }
    },
    components: {
        // ListModalList
    },
    data () {
      return {
        title:'',
        width:1200,
        visible: false,
        disableSubmit: false,
        dataXQ: {},
        columns: [],
        dataSource: [],
        ipagination: {
            current: 1,
            pageSize: 10,
            pageSizeOptions: ['10', '20', '30'],
            showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " 共" + total + "条"
            },
            showQuickJumper: true,
            showSizeChanger: true,
            total: 0
        },
        loading: false,
        url: {
          htelist: "/index/getDetailIncome",
          skelist: "/index/getDetailReceived",
          zcelist: "",
          lrelist: "",
        },
      }
    },
    watch: {
      listData: {
        handler(newValue, oldValue){
        //   console.log(66666,newValue, oldValue)
          this.dataXQ = newValue
          this.getList()
        },
        immediate: true,
        deep: true
      }
    },
    methods: {
      getList () {
        console.log(99999,this.dataXQ)
        this.title = this.dataXQ.title
        this.loading = true
        var params = this.getQueryParams();//查询条件
        if (this.dataXQ.hdValue) {
            if (this.dataXQ.hdValue == 'hte') {
                this.columns= [
                    {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                        return parseInt(index)+1;
                    }
                    },
                    {
                    title:'任务编号',
                    align:"center",
                    dataIndex: 'rwbh'
                    },
                    {
                    title:'合同名称',
                    align:"center",
                    dataIndex: 'htmc'
                    },
                    {
                    title:'合同分配额',
                    align:"center",
                    dataIndex: 'htfpe'
                    },
                    {
                    title:'签署日期',
                    align:"center",
                    dataIndex: 'qsrq'
                    },
                ]
                getAction(this.url.htelist, params).then((response) => {
                    console.log(7777,response.result)
                    this.dataSource = response.result.records
                    this.ipagination.total = response.result.total
                    this.loading = false
                })
            }
            if (this.dataXQ.hdValue == 'ske') {
                this.columns= [
                    {
                    title: '序号',
                    dataIndex: '',
                    key:'rowIndex',
                    width:60,
                    align:"center",
                    customRender:function (t,r,index) {
                        return parseInt(index)+1;
                    }
                    },
                    {
                    title:'任务编号',
                    align:"center",
                    dataIndex: 'rwbh'
                    },
                    {
                    title:'任务收款金额',
                    align:"center",
                    dataIndex: 'rwskje'
                    },
                    {
                    title:'到款日期/汇票到期日期',
                    align:"center",
                    dataIndex: 'dkhpdqrq'
                    },
                ]
                getAction(this.url.skelist, params).then((response) => {
                    console.log(7777,response.result.records)
                    this.dataSource = response.result.records
                    this.ipagination.total = response.result.total
                    this.loading = false
                })
            }
            if (this.dataXQ.hdValue == 'zce') {
                
            }
            if (this.dataXQ.hdValue == 'lre') {
                
            }
            this.visible=true
        } else {
            this.visible=false
        }
      },
      getQueryParams() {
        //获取查询条件
        let sqp = {}
        if(this.superQueryParams){
            sqp['superQueryParams']=encodeURI(this.superQueryParams)
            sqp['superQueryMatchType'] = this.superQueryMatchType
        }
        var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
        param.pageNo = this.ipagination.current;
        param.pageSize = this.ipagination.pageSize;
        return filterObj(param);
      },
      close () {
        this.columns= []
        this.visible = false;
      },
      handleOk () {
        this.$refs.realForm.submitForm();
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>