<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="产品名称">
              <a-input placeholder="请输入产品名称" v-model="queryParam.taskname"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="任务号">
              <a-input placeholder="请输入任务号" v-model="queryParam.taskno"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="型号">
                <a-input placeholder="请输入型号" v-model="queryParam.xhname"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="阶段">
                <a-input placeholder="请输入阶段" v-model="queryParam.yzjdname"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="计划完成时间">
                <j-date placeholder="请选择计划完成时间" v-model="queryParam.jhwcsj"></j-date>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="任务类型">
                <a-input placeholder="请输入任务类型" v-model="queryParam.tasktype"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="审计审价">
                <a-input placeholder="请输入审计审价" v-model="queryParam.auditprice"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="任务状态">
                <a-input placeholder="请输入任务状态" v-model="queryParam.iflag"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="项目进度">
                <a-input placeholder="请输入项目进度" v-model="queryParam.processpercent"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="成本进度">
                <a-input placeholder="请输入成本进度" v-model="queryParam.costPercent"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="业务员">
                <a-input placeholder="请输入业务员" v-model="queryParam.businessman"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="下达部门id">
                <a-input placeholder="请输入下达部门id" v-model="queryParam.jycsid"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="下达部门">
                <a-input placeholder="请输入下达部门" v-model="queryParam.jycs"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="责任部门">
                <a-input placeholder="请输入责任部门" v-model="queryParam.zrbm"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="批产任务号">
                <a-input placeholder="请输入批产任务号" v-model="queryParam.pccode"></a-input>
              </a-form-item>
            </a-col> -->
            <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="备产任务号">
                <a-input placeholder="请输入备产任务号" v-model="queryParam.bccode"></a-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="备料任务号">
                <a-input placeholder="请输入备料任务号" v-model="queryParam.blcode"></a-input>
              </a-form-item>
            </a-col> -->
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <!-- <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a> -->
            </span>
          </a-col>
        </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('kzks_cost_model_product_price')">导出</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"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <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-popconfirm title="确定移除吗?" @confirm="() => handleDelete(record.id)">
            <a>移除</a>
          </a-popconfirm>
          <!-- <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>

    <cost-model-product-price-modal ref="modalForm" @ok="modalFormOk"></cost-model-product-price-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import CostModelProductPriceModal from './modules/CostModelProductPriceModal'

  export default {
    name: 'CostModelProductPriceList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      CostModelProductPriceModal
    },
    data () {
      return {
        description: 'kzks_cost_model_product_price管理页面',
        // 表头
        columns: [
          {
            title:'产品名称',
            align:"center",
            fixed:"left",
            width: 120,
            dataIndex: 'taskname'
          },
          {
            title:'任务号',
            align:"center",
            fixed:"left",
            width: 140,
            dataIndex: 'taskno',
          },
          {
            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',
          //   customRender: (text, record) => {
          //     return record.id === 'amount'?null:parseInt(text)+ '%'
          //   },
          // },
          // {
          //   title:'成本进度',
          //   align:"center",
          //   dataIndex: 'costPercent',
          //   customRender: (text, record) => {
          //     return record.id === 'amount'?null:(Number(text)).toFixed(1) + '%'
          //   },
          // },
          {
            title:'已收款',
            align:"center",
            dataIndex: 'taskmoney',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          {
            title:'合同额',
            align:"center",
            dataIndex: 'contractfpe',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          // {
          //   title:'预估价',
          //   align:"center",
          //   dataIndex: 'estimationcoat',
          //   customRender: (text, record) => {
          //     return record.contractfpe ? '-' : Number(text).toFixed(2)
          //   },
          // },
          // {
          //   title:'总成本',
          //   align:"center",
          //   dataIndex: 'zcb',
          //   customRender: (text) => {
          //     return (Number(text)/10000).toFixed(2)
          //   },
          // },
          // {
          //   title:'利润额',
          //   align:"center",
          //   dataIndex: 'lre',
          //   customRender: (text) => {
          //     return (Number(text)/10000).toFixed(2)
          //   },
          // },
          // {
          //   title:'利润率',
          //   align:"center",
          //   dataIndex: 'lrl',
          //   customRender: (text) => {
          //     return (Number(text) * 100).toFixed(1) + '%'
          //   },
          // },
          // {
          //   title:'研制数量',
          //   align:"center",
          //   dataIndex: 'yzsl'
          // },
          {
            title:'单台利润',
            align:"center",
            dataIndex: 'oneProfit',
            customRender: (text, record) => {
              // return record.id === 'amount'?null:(Number(text)/10000).toFixed(2)
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'单台收入',
            align:"center",
            dataIndex: 'oneIncome',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'单台成本',
            align:"center",
            dataIndex: 'oneCost',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          // {
          //   title:'材料预算',
          //   align:"center",
          //   dataIndex: 'clys',
          //   customRender: (text) => {
          //     return Number(text).toFixed(2)
          //   },
          // },
          {
            title:'材料费',
            align:"center",
            dataIndex: 'clf',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          {
            title:'专用费',
            align:"center",
            dataIndex: 'zyf',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          {
            title:'事务费',
            align:"center",
            dataIndex: 'swf',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          // {
          //   title:'外协预算',
          //   align:"center",
          //   dataIndex: 'wxys',
          //   customRender: (text) => {
          //     return Number(text).toFixed(2)
          //   },
          // },
          {
            title:'外协费',
            align:"center",
            dataIndex: 'wxf',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          {
            title:'燃动费',
            align:"center",
            dataIndex: 'rldlf',
            customRender: (text) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'固资费',
            align:"center",
            dataIndex: 'gdzczj',
            customRender: (text) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'工时费',
            align:"center",
            dataIndex: 'gzjlwf',
            customRender: (text) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'管理费',
            align:"center",
            dataIndex: 'glf',
            customRender: (text) => {
              return (Number(text)/10000).toFixed(2)
            },
          },
          {
            title:'装机成本',
            align:"center",
            dataIndex: 'zjcb',
            customRender: (text, record) => {
              return (Number(text)/10000).toFixed(2)
            },
            // customCell: this.getClickColumn,
          },
          {
            title:'内部试验',
            align:"center",
            dataIndex: 'lbsy'
          },
          {
            title:'工时(h)',
            align:"center",
            dataIndex: 'workhour',
            // scopedSlots: {
            //   customRender: 'workhour',
            // },
            // customCell: this.getClickColumn,
          },
          {
            title:'设计工时',
            align:"center",
            dataIndex: 'sjgs'
          },
          {
            title:'生产工时',
            align:"center",
            dataIndex: 'scgs'
          },
          {
            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: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/costModelProductPrice/costModelProductPrice/list",
          delete: "/costModelProductPrice/costModelProductPrice/delete",
          deleteBatch: "/costModelProductPrice/costModelProductPrice/deleteBatch",
          exportXlsUrl: "/costModelProductPrice/costModelProductPrice/exportXls",
          importExcelUrl: "costModelProductPrice/costModelProductPrice/importExcel",
          
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'cpname',text:'产品名称'})
        fieldList.push({type:'string',value:'yzjdname',text:'阶段'})
        fieldList.push({type:'number',value:'contractfpe',text:'合同额/来自收款合同的合同分配额 '})
        fieldList.push({type:'int',value:'yzsl',text:'研制数量/来自科研任务'})
        fieldList.push({type:'number',value:'oneIncome',text:'单台收入/（合同额or预估价）/研制数量'})
        fieldList.push({type:'string',value:'brief',text:'提出单位简称'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>