<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">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <!-- <a-button type="primary" icon="download" @click="handleExportXls('批产任务')">导出</a-button> -->
      <span style="float: right;font-weight: bold;margin-bottom: 10px;">占比：{{ pichanInfo.proportion * 100 + '%' }}</span>
      <!-- <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
        v-if="dataSource.length > 0"
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :loading="loading"
        defaultExpandAllRows
        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: 'PichanTaskList',
    mixins:[JeecgListMixin, mixinDevice],
    props: {
      pichanInfo: {
        type: Object,
        default: {}
      }
    },
    data () {
      return {
        description: '批产任务页面',
        // 表头
        columns: [],
        // settingColumns: ['taskno', 'pccode', 'taskname', 'zjcb', 'scgs', 'contractfpe', 'estimationcoat', 'costPercent', 'processpercent', 'sjgs', 'clf', 'zyf', 'swf', 'wxf', 'taskmoney', 'oneIncome', 'oneProfit', 'lrl', 'xhname', 'yzjdname', 'jhwcsj', 'yzsl', 'oneCost', 'lre', 'zcb', 'glf', 'lbsy', 'zrbm', 'gdzczj', 'gzjlwf', 'rldlf', 'tasktype', 'jycs', 'workhour', 'hxzxname', 'auditprice', 'brief', 'blcode', 'businessman', 'bccode', 'reftaskno', 'iflag'],
        settingColumns: ['taskno', 'pccode', 'taskname', 'estimationcoat', 'costPercent', 'processpercent', 'oneIncome', 'oneProfit', 'lrl', 'xhname', 'yzjdname', 'jhwcsj', 'yzsl', 'oneCost', 'lre', 'zcb', 'glf', 'lbsy', 'zrbm', 'gdzczj', 'gzjlwf', 'rldlf', 'tasktype', 'jycs', 'hxzxname', 'auditprice', 'brief', 'blcode', 'businessman', 'bccode', 'reftaskno', 'iflag'],
        //  'scgs', 'sjgs',
        defColumns: [
          {
            title: '序号',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            },
            fixed: 'left',
          },
          {
            title:'任务号',
            fixed:"left",
            dataIndex: 'taskno',
            width: 120,
            customHeaderCell:() => ({
              style: {
                textAlign: 'center', // 表头居中
              }
            }),
            fixed:"left",
          },
          {
            title:'任务名称',
            align:"center",
            dataIndex: 'taskname',
            width: 120,
            fixed:"left",
          },
          {
            title:'型号',
            align:"center",
            dataIndex: 'xhname'
          },
          {
            title:'计划完成时间',
            align:"center",
            dataIndex: 'jhwcsj',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'阶段',
            align:"center",
            dataIndex: 'yzjdname'
          },
          {
            title:'项目进度',
            align:"center",
            dataIndex: 'processpercent'
          },
          {
            title:'成本进度',
            align:"center",
            dataIndex: 'costPercent'
          },
          {
            title:'研制数量',
            align:"center",
            dataIndex: 'yzsl'
          },
          {
            title:'单台收入',
            align:"center",
            dataIndex: 'oneIncome'
          },
          {
            title:'单台成本',
            align:"center",
            dataIndex: 'oneCost'
          },
          {
            title:'单台利润',
            align:"center",
            dataIndex: 'oneProfit'
          },
          {
            title:'利润额',
            align:"center",
            dataIndex: 'lre'
          },
          {
            title:'利润率',
            align:"center",
            dataIndex: 'lrl'
          },
          {
            title:'预估价',
            align:"center",
            dataIndex: 'estimationcoat'
          },
          {
            title:'总成本',
            align:"center",
            dataIndex: 'zcb'
          },
          {
            title:'燃料动力费',
            align:"center",
            dataIndex: 'rldlf'
          },
          {
            title:'固定资产折旧',
            align:"center",
            dataIndex: 'gdzczj'
          },
          {
            title:'工资及劳务费',
            align:"center",
            dataIndex: 'gzjlwf'
          },
          {
            title:'管理费',
            align:"center",
            dataIndex: 'glf'
          },
          {
            title:'内部试验',
            align:"center",
            dataIndex: 'lbsy'
          },
          {
            title:'责任部门',
            align:"center",
            dataIndex: 'zrbm'
          },
          // {
          //   title:'下达部门id',
          //   align:"center",
          //   dataIndex: 'jycsid'
          // },
          {
            title:'下达部门',
            align:"center",
            dataIndex: 'jycs'
          },
          // {
          //   title:'1：横向 2：纵向',
          //   align:"center",
          //   dataIndex: 'hxzxid'
          // },
          {
            title:'横向纵向',
            align:"center",
            dataIndex: 'hxzxname'
          },
          {
            title:'任务类型',
            align:"center",
            dataIndex: 'tasktype'
          },
          {
            title:'审计审价',
            align:"center",
            dataIndex: 'auditprice'
          },
          {
            title:'任务状态',
            align:"center",
            dataIndex: 'iflag'
          },
          {
            title:'提出单位简称',
            align:"center",
            dataIndex: 'brief'
          },
          {
            title:'父级任务',
            align:"center",
            dataIndex: 'reftaskno'
          },
          // {
          //   title:'批产任务号',
          //   align:"center",
          //   dataIndex: 'pccode'
          // },
          {
            title:'备产任务号',
            align:"center",
            dataIndex: 'bccode'
          },
          {
            title:'备料任务号',
            align:"center",
            dataIndex: 'blcode'
          },
          {
            title:'业务员',
            align:"center",
            dataIndex: 'businessman'
          },
          {
            title:'设计工时',
            align:"center",
            dataIndex: 'sjgs'
          },
          {
            title:'生产工时',
            align:"center",
            dataIndex: 'scgs'
          },
          {
            title:'合同额',
            align:"center",
            dataIndex: 'contractfpe',
            fixed: 'right'
          },
          {
            title:'已收款',
            align:"center",
            dataIndex: 'taskmoney',
            fixed: 'right'
          },
          {
            title:'材料费',
            align:"center",
            dataIndex: 'clf',
            fixed: 'right'
          },
          {
            title:'专用费',
            align:"center",
            dataIndex: 'zyf',
            fixed: 'right'
          },
          {
            title:'事务费',
            align:"center",
            dataIndex: 'swf',
            fixed: 'right'
          },
          {
            title:'外协费',
            align:"center",
            dataIndex: 'wxf',
            fixed: 'right'
          },
          {
            title:'装机成本',
            align:"center",
            dataIndex: 'zjcb',
            fixed: 'right'
          },
          {
            title:'工时(h)',
            align:"center",
            dataIndex: 'workhour',
            fixed: 'right'
          },
        ],
        url: {
          list: "/projectCost/projectCost/getPCCostDetailList",
          // exportXlsUrl: "/projectChbWxf/projectChbWxf/exportXls",
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
      this.getSuperFieldList();
      this.loadData()
      this.initColumns()
    },
    computed: {
      // importExcelUrl: function(){
      //   return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      // },
    },
    methods: {
      loadData() {
        this.loading = true;
        getAction(this.url.list, this.pichanInfo).then((res) => {
          console.log(res)
          this.dataSource = []
          this.dataSource.push(res)
        }).finally(() => {
          this.loading = false
        })
      },
      initColumns(){
        console.log(this.pichanInfo.columnValue)
        this.settingColumns.push(this.pichanInfo.columnValue)
        const cols = this.defColumns.filter(item => {
          if(item.key =='rowIndex'|| item.dataIndex=='action'){
            return true;
          }
          if (this.settingColumns.includes(item.dataIndex)) {
            return true;
          }
          return false;
        })
        this.columns =  cols;
      },
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'nd',text:'年度',dictCode:''})
        fieldList.push({type:'string',value:'pzrq',text:'凭证日期',dictCode:''})
        fieldList.push({type:'string',value:'pzh',text:'凭证号',dictCode:''})
        fieldList.push({type:'string',value:'zy',text:'摘要',dictCode:''})
        fieldList.push({type:'string',value:'kmbh',text:'科目编号',dictCode:''})
        fieldList.push({type:'string',value:'km',text:'科目名称',dictCode:''})
        fieldList.push({type:'string',value:'fx',text:'方向',dictCode:''})
        fieldList.push({type:'string',value:'je',text:'金额',dictCode:''})
        fieldList.push({type:'string',value:'bm',text:'部门',dictCode:''})
        fieldList.push({type:'string',value:'wldw',text:'往来单位',dictCode:''})
        fieldList.push({type:'string',value:'fzje',text:'辅助金额',dictCode:''})
        fieldList.push({type:'string',value:'zdr',text:'制单人',dictCode:''})
        fieldList.push({type:'string',value:'kjqj',text:'会计期间',dictCode:''})
        fieldList.push({type:'string',value:'pznm',text:'凭证内码',dictCode:''})
        fieldList.push({type:'string',value:'xmbh',text:'项目编号',dictCode:''})
        fieldList.push({type:'string',value:'xmmc',text:'项目名称',dictCode:''})
        fieldList.push({type:'string',value:'xmlb',text:'项目类别',dictCode:''})
        fieldList.push({type:'string',value:'taskno',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>
