<template>
  <a-card :bordered="false" class="u-dialog-card">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator" style="padding: -24px !important;">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <a-button type="primary" icon="download" @click="handleExportXls(taskno+'合同额明细')">导出</a-button>
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!-- <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <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">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <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"
        @change="handleTableChange">
        <!-- :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}" -->

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" 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>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@/api/manage'

  export default {
    name: 'ContractDetailList',
    mixins:[JeecgListMixin, mixinDevice],
    props: {
      taskno: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        description: '合同信息存储表管理页面',
        // 表头
        columns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            },
            fixed: 'left',
          },
          // {
          //   title:'序号',
          //   align:"center",
          //   dataIndex: 'xh',
          //   fixed: 'left',
          // },
          {
            title:'任务编号',
            align:"center",
            dataIndex: 'rwbh',
            width: 120,
            fixed: 'left',
          },
          {
            title:'任务名称',
            align:"center",
            dataIndex: 'rwmc',
            width: 120,
            fixed: 'left',
          },
          {
            title:'所属型号',
            align:"center",
            dataIndex: 'ssxh'
          },
          {
            title:'产品型号',
            align:"center",
            dataIndex: 'cpxh'
          },
          {
            title:'阶段',
            align:"center",
            dataIndex: 'jd'
          },
          {
            title:'研制部门',
            align:"center",
            dataIndex: 'yzbm'
          },
          {
            title:'主管设计师',
            align:"center",
            dataIndex: 'zgsjs'
          },
          {
            title:'已收款(元)',
            align:"center",
            dataIndex: 'ysk'
          },
          {
            title:'合同编号',
            align:"center",
            dataIndex: 'htbh'
          },
          {
            title:'合同名称',
            align:"center",
            dataIndex: 'htmc'
          },
          {
            title:'合同状态',
            align:"center",
            dataIndex: 'htzt'
          },
          {
            title:'合同类型',
            align:"center",
            dataIndex: 'htlx'
          },
          // 签署日期
          {
            title:'合同密级',
            align:"center",
            dataIndex: 'htmj'
          },
          {
            title:'项目密级',
            align:"center",
            dataIndex: 'xmmj'
          },
          {
            title:'合同数量',
            align:"center",
            dataIndex: 'htsl'
          },
          {
            title:'合同页数',
            align:"center",
            dataIndex: 'htys'
          },
          {
            title:'归档编号',
            align:"center",
            dataIndex: 'gdbh'
          },
          {
            title:'归档日期',
            align:"center",
            dataIndex: 'gdrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'合同款状态',
            align:"center",
            dataIndex: 'htkzt'
          },
          {
            title:'甲方（付款方）',
            align:"center",
            dataIndex: 'jf'
          },
          {
            title:'甲方简称',
            align:"center",
            dataIndex: 'jfyhjc'
          },
          {
            title:'乙方（收款方）',
            align:"center",
            dataIndex: 'yf'
          },
          {
            title:'金额（元）', // 、收款总金额、开票金额
            align:"center",
            dataIndex: 'jeskzkp'
          },
          {
            title:'自筹（元）',
            align:"center",
            dataIndex: 'zc'
          },
          {
            title:'到款（元）',
            align:"center",
            dataIndex: 'dk'
          },
          {
            title:'待付款（元）',
            align:"center",
            dataIndex: 'dfk'
          },
          {
            title:'开票状态',
            align:"center",
            dataIndex: 'kpzt'
          },
          {
            title:'已开票（元）',
            align:"center",
            dataIndex: 'ykp'
          },
          {
            title:'待开票（元）',
            align:"center",
            dataIndex: 'dkp'
          },
          {
            title:'联系人（对方）',
            align:"center",
            dataIndex: 'lxr'
          },
          {
            title:'电话',
            align:"center",
            dataIndex: 'dh'
          },
          {
            title:'合同起草人',
            align:"center",
            dataIndex: 'htqcr'
          },
          {
            title:'起草日期', // 、录入日期、申请日期
            align:"center",
            dataIndex: 'qclrsqrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'合同主管部门',
            align:"center",
            dataIndex: 'htzgbm'
          },
          {
            title:'业务员',
            align:"center",
            dataIndex: 'ywy'
          },
          {
            title:'抓总部门',
            align:"center",
            dataIndex: 'zzbm'
          },
          {
            title:'合同履行情况',
            align:"center",
            dataIndex: 'htlxqk'
          },
          {
            title:'合同状态说明',
            align:"center",
            dataIndex: 'htztsm'
          },
          {
            title:'合同分配额(元)',
            align:"center",
            dataIndex: 'htfpe',
            width: 120,
            fixed: 'right',
          },



          // {
          //   title:'id',
          //   align:"center",
          //   dataIndex: 'id'
          // },

          // {
          //   title:'开票时间',
          //   align:"center",
          //   dataIndex: 'kpsj',
          //   customRender:function (text) {
          //     return !text?"":(text.length>10?text.substr(0,10):text)
          //   }
          // },
          // {
          //   title:'客户id',
          //   align:"center",
          //   dataIndex: 'khid'
          // },


          // {
          //   title:'数据来源：10：合同管理，20：合同任务，30：任务合同，40：合同付款，50：合同发票，60：外协合同',
          //   align:"center",
          //   dataIndex: 'sjly'
          // },
          // {
          //   title:'用户id',
          //   align:"center",
          //   dataIndex: 'yhid'
          // },

          // {
          //   title:'类型（无用）',
          //   align:"center",
          //   dataIndex: 'pici'
          // },
        ],
        url: {
          list: "/xmcbDetail/comContractInfoExchange/getCrmHteDetail",
          // delete: "/xmcbDetail/comContractInfoExchange/delete",
          // deleteBatch: "/xmcbDetail/comContractInfoExchange/deleteBatch",
          exportXlsUrl: "/xmcbDetail/comContractInfoExchange/exportHteDetail",
          // importExcelUrl: "xmcbDetail/comContractInfoExchange/importExcel",

        },
        dictOptions:{},
        superFieldList:[],
        queryParam: {
          taskno: this.taskno
        }
      }
    },
    created() {
      this.getSuperFieldList();
      this.loadData()
    },
    computed: {
      // importExcelUrl: function(){
      //   return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      // },
    },
    methods: {
      loadData() {
        this.loading = true;
        getAction(this.url.list, {taskno: this.taskno}).then((res) => {
          console.log(res)
          this.dataSource = res
        }).finally(() => {
          this.loading = false
        })
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'cpxh',text:'产品型号.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'dfk',text:'待付款（元）.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'dkp',text:'待开票（元）.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'dk',text:'到款（元）.',dictCode:''})
        fieldList.push({type:'string',value:'dh',text:'电话.',dictCode:''})
        fieldList.push({type:'string',value:'gdbh',text:'归档编号.',dictCode:''})
        fieldList.push({type:'date',value:'gdrq',text:'归档日期.'})
        fieldList.push({type:'string',value:'htbh',text:'合同编号.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'htfpe',text:'合同分配额.',dictCode:''})
        fieldList.push({type:'string',value:'htkzt',text:'合同款状态.',dictCode:''})
        fieldList.push({type:'string',value:'htlx',text:'合同类型.',dictCode:''})
        fieldList.push({type:'string',value:'htlxqk',text:'合同履行情况.',dictCode:''})
        fieldList.push({type:'string',value:'htmj',text:'合同密级.',dictCode:''})
        fieldList.push({type:'string',value:'htmc',text:'合同名称.',dictCode:''})
        fieldList.push({type:'string',value:'htqcr',text:'合同起草人.',dictCode:''})
        fieldList.push({type:'int',value:'htsl',text:'合同数量.',dictCode:''})
        fieldList.push({type:'int',value:'htys',text:'合同页数.',dictCode:''})
        fieldList.push({type:'string',value:'htzgbm',text:'合同主管部门.',dictCode:''})
        fieldList.push({type:'string',value:'htzt',text:'合同状态.',dictCode:''})
        fieldList.push({type:'string',value:'htztsm',text:'合同状态说明.',dictCode:''})
        fieldList.push({type:'string',value:'jf',text:'甲方（付款方）.',dictCode:''})
        fieldList.push({type:'string',value:'jfyhjc',text:'甲方简称、用户简称.',dictCode:''})
        fieldList.push({type:'string',value:'jd',text:'阶段.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'jeskzkp',text:'金额（元）、收款总金额、开票金额.',dictCode:''})
        fieldList.push({type:'date',value:'kpsj',text:'开票时间.'})
        fieldList.push({type:'string',value:'kpzt',text:'开票状态.',dictCode:''})
        fieldList.push({type:'string',value:'khid',text:'客户id.',dictCode:''})
        fieldList.push({type:'string',value:'lxr',text:'联系人（对方）.',dictCode:''})
        fieldList.push({type:'date',value:'qclrsqrq',text:'起草日期、录入日期、申请日期.'})
        fieldList.push({type:'string',value:'rwbh',text:'任务编号.',dictCode:''})
        fieldList.push({type:'string',value:'rwmc',text:'任务名称.',dictCode:''})
        fieldList.push({type:'int',value:'sjly',text:'数据来源：10：合同管理，20：合同任务，30：任务合同，40：合同付款，50：合同发票，60：外协合同.',dictCode:''})
        fieldList.push({type:'string',value:'ssxh',text:'所属型号.',dictCode:''})
        fieldList.push({type:'string',value:'xmmj',text:'项目密级.',dictCode:''})
        fieldList.push({type:'string',value:'xh',text:'序号.',dictCode:''})
        fieldList.push({type:'string',value:'yzbm',text:'研制部门.',dictCode:''})
        fieldList.push({type:'string',value:'ywy',text:'业务员.',dictCode:''})
        fieldList.push({type:'string',value:'yf',text:'乙方（收款方）.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'ykp',text:'已开票（元）.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'ysk',text:'已收款.',dictCode:''})
        fieldList.push({type:'string',value:'yhid',text:'用户id.',dictCode:''})
        fieldList.push({type:'string',value:'zgsjs',text:'主管设计师.',dictCode:''})
        fieldList.push({type:'string',value:'zzbm',text:'抓总部门.',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'zc',text:'自筹（元）.',dictCode:''})
        fieldList.push({type:'string',value:'pici',text:'类型（无用）.',dictCode:''})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
<style lang="less" scoped>
  .u-dialog-card{
    /deep/.ant-card-body{
      padding: 0 !important;
    }
  }
</style>