<template>
  <div>
    <at-table
      @load="loadData"
      :data="data"
      :page-result="pageResult"
      ref="AtTable"
      :dialogTitle="dialogTitle"
      :cellClassNameFn="cellClassNameFn"
      @select-all="handleSelect"
      @select="handleSelect"
      @handleDialogCancel="handleDialogCancel"
      @handleDialogClose="handleDialogClose"
      @handleDialogSubmit="handleDialogSubmit"
      @row-dblclick="handleRowDBClick"
      :justShowSearch="justShowSearch"
    >
      <template v-slot:searchInput>
        <el-form
          ref="searchForm"
          :model="searchForm"
          label-width="80px"
          class="search-top"
          @submit.native.prevent
        >
          <el-select
            v-if="isShow"
            v-model="searchForm.createTime"
            clearable
            placeholder="请选择年份"
            @change="findinfo"
          >
            <el-option
              v-for="item in optionYears"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <dict-select
            v-if="isShow"
            v-model="searchForm.projectType"
            dictCode="xmgl-xmlx"
            validate="required"
            placeholder="请选择项目类型"
            :clearable="true"
            @input="findinfo"
          />
          <el-input
            v-if="isShow"
            v-model="searchForm.projectName"
            placeholder="请输入项目名称"
            style="width: 100%"
            @input="findinfo"
          ></el-input>
          <el-input
            v-model="searchForm.typeValue"
            placeholder="请输入合同类型"
            clearable
            @keyup.enter.native="findinfo"
          ></el-input>
          <el-input
            v-model="searchForm.contractReceiver"
            placeholder="请输入经办人"
            clearable
            @keyup.enter.native="findinfo"
          ></el-input>
          <!-- <dict-select
            v-model="searchForm.type"
            dictCode="htgl-htlb"
            validate="required"
            placeholder="请选择合同类别"
            :clearable="true"
            @input="findinfo"
          /> -->
          <!-- <el-select
            v-model="searchForm.type"
            placeholder="请选择合同类型"
            clearable
            @keyup.enter.native="findinfo"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select> -->
          <el-button
            size="small"
            @click="findinfo"
            type="primary"
            class="el-icon-search search-btn"
            >查询</el-button
          >
          <el-button
            size="small"
            @click="handleReset"
            type="primary"
            plain
            class="el-icon-refresh"
            >重置</el-button
          >
          <el-button
            size="small"
            type="primary"
            @click="handleExport"
            :loading="loading"
            icon="el-icon-download"
            plain
            style="margin-left: 10px"
            >导出</el-button
          >
        </el-form>
      </template>
      <template v-slot:seacrhMoreInput>
        <div class="moreInput">
          <el-date-picker
            unlink-panels
            v-model="searchForm.yearMonth"
            value-format="yyyy-MM"
            type="monthrange"
            range-separator="至"
            start-placeholder="开始签订日期"
            end-placeholder="结束签订日期"
            @change="findinfo"
          >
          </el-date-picker>
          <el-select
            v-model="searchForm.contractAmount"
            placeholder="请选择合同金额区间"
            clearable
            @change="findinfo"
          >
            <el-option
              v-for="item in AmountOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
      </template>
      <template>
        <!-- <el-table-column type="selection" width="55" align="center">
        </el-table-column> -->
        <el-table-column type="index" label="序号" width="55" align="center">
        </el-table-column>
        <el-table-column
          prop="projectName"
          label="项目名称"
          width="270"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="contractNumber"
          label="合同编号"
          :show-overflow-tooltip="true"
          width="230"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="name"
          label="合同涉及事项"
          width="300"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column>
        <!-- <el-table-column
          prop="secondLevelType"
          label="二级分类"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column> -->
        <!-- <el-table-column
          prop="biddingChargeType"
          label="招标方式"
          :show-overflow-tooltip="true"
          align="center"
        >
        <template v-slot="{row}">
          {{row.biddingChargeType}}
        </template>
        </el-table-column> -->
        <!-- <el-table-column
          prop="decisionDocuments"
          label="决策文件"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column> -->
        <el-table-column
          prop="typeValue"
          label="合同类别"
          width="180"
          :show-overflow-tooltip="true"
          align="center"
        >
          <!-- <template v-slot="{row}">
            {{ row.type }}
          </template> -->
        </el-table-column>
        <!-- <el-table-column
          prop="contractInvolved"
          label="合同事项"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column> -->
        <el-table-column
          prop="ourPart"
          label="我方主体"
          width="200"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="otherPart"
          label="其他主体"
          width="280"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="contractAmount"
          label="合同金额(元)"
          :show-overflow-tooltip="true"
          width="150"
          align="center"
        >
        </el-table-column>

        <el-table-column
          prop="contractDate"
          label="签订时间"
          :show-overflow-tooltip="true"
          width="130"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="contractReceiver"
          label="经办人"
          :show-overflow-tooltip="true"
          width="130"
          align="center"
        >
          <template v-slot="{row}">
            <el-input
              v-if="row.contractReceiver !== '----'"
              v-model="row.contractReceiver"
              @blur="(e) => contractReceiverBlur(e, row)"
            ></el-input>
            <span v-else>----</span>
          </template>
        </el-table-column>
        <!-- <el-table-column
        prop=""
        label="合同时间"
        :show-overflow-tooltip="true"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop=""
        label="投资金额(元)"
        :show-overflow-tooltip="true"
        width="110"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop=""
        label="异常记录"
        :show-overflow-tooltip="true"
        align="center"
      >
      </el-table-column> 
       <el-table-column
        prop=""
        label="执行进度"
        :show-overflow-tooltip="true"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop=""
        label="经办人"
        :show-overflow-tooltip="true"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop=""
        label="留存份数"
        :show-overflow-tooltip="true"
        align="center"
      >
      </el-table-column>
      <el-table-column
        prop=""
        label="备注"
        :show-overflow-tooltip="true"
        align="center"
      >
      </el-table-column>
        <el-table-column
          prop="contractStorage"
          label="合同存放处"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column>
         <el-table-column
          prop="RecipientSign"
          label="领取人签字"
          :show-overflow-tooltip="true"
          align="center"
        >
        </el-table-column> -->
        <el-table-column
          prop="establishmentRemarks"
          label="备注"
          :show-overflow-tooltip="true"
          width="80"
          align="center"
        >
        </el-table-column>
      </template>
    </at-table>
    <el-dialog
      title="详情"
      :visible.sync="dialogVisible"
      width="1200px"
      top="8vh"
    >
      <div class="mainBox">
        <table align="center">
          <tr>
            <td class="bgColor">项目名称</td>
            <td style="width: 390px">{{ details.projectName }}</td>
            <td class="bgColor">合同名称</td>
            <td style="width: 380px">{{ details.name }}</td>
          </tr>
          <tr>
            <td class="bgColor">合同编号</td>
            <td>{{ details.contractNumber }}</td>
            <!-- <td class="bgColor">经办人</td> -->
            <td class="bgColor">项目负责人</td>
            <td>{{ details.agent }}</td>
          </tr>
          <tr>
            <td class="bgColor">二级分类</td>
            <td>{{ getDictName('htgl-htfl', details.secondLevelType) }}</td>
            <td class="bgColor">招标方式</td>
            <td>{{ getDictName('zbfs', details.biddingChargeType) }}</td>
          </tr>
          <tr>
            <td class="bgColor">决策依据</td>
            <td>{{ details.decisionDocuments }}</td>
            <td class="bgColor">合同类别</td>
            <td>{{ details.typeValue }}</td>
          </tr>
          <tr>
            <td class="bgColor">合同涉及事项</td>
            <td>{{ details.contractInvolved }}</td>
            <td class="bgColor">我方主体</td>
            <td>{{ details.ourPart }}</td>
          </tr>
          <tr>
            <td class="bgColor">其它相对方主体</td>
            <td>{{ details.otherPart }}</td>
            <td class="bgColor">签订时间</td>
            <td>{{ details.contractDate }}</td>
          </tr>
          <tr>
            <td class="bgColor">合同约定完成时间</td>
            <td>{{ details.endDate }}</td>
            <td class="bgColor">合同金额(元)</td>
            <td>{{ details.contractAmount }}</td>
          </tr>
          <tr>
            <td class="bgColor">合同履行异常记录</td>
            <td>{{ details.contractExceptionLog }}</td>
            <td class="bgColor">合同执行进度</td>
            <td>{{ details.contractSchedule }}</td>
          </tr>
          <tr>
            <!-- <td class="bgColor">留存份数</td>
            <td>{{ details.contractCopsNum }}</td> -->
            <td class="bgColor">合同约定付款方式</td>
            <td>{{ details.treatyContents }}</td>
            <td class="bgColor">合同存放处</td>
            <td>{{ details.contractStorage }}</td>
          </tr>
          <tr>
            <!-- <td class="bgColor">保证金</td>
            <td>{{ details.retentionMoney }}</td> -->
            <!-- <td class="bgColor">合同领取人</td>
            <td>{{ details.contractReceiver }}</td> -->
          </tr>
          <tr>
            <!-- <td class="bgColor">合同保管人</td>
            <td>{{ details.contractKeeper }}</td> -->
            <td class="bgColor">收款人及账号、电话</td>
            <td>{{ details.payeeAccountPhone }}</td>
            <td class="bgColor">经办人</td>
            <td v-if="isShowInput">
              <el-input
                v-model="details.contractReceiver"
                @blur="(e) => contractReceiverBlur(e, details)"
              ></el-input>
            </td>
            <td v-else @click="isShowInput = true">
              {{ details.contractReceiver }}
            </td>
          </tr>
          <tr>
            <td class="bgColor">备注</td>
            <td colspan="3">
              {{ details.establishmentRemarks }}
            </td>
          </tr>
        </table>
        <!-- <div class="flexEnd">
          <div class="end">
            <span>项目名称：{{details.projectInfo && details.projectInfo.projectName}}</span>
            <span>创建负责人：{{details.projectInfo && details.projectInfo.projectManager}}</span>
            <span>创建时间：{{details.projectInfo && details.projectInfo.commencementTime}}</span>
          </div>
        </div> -->
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="saveContractReceiver">
          保存
        </el-button>
        <el-button @click="dialogVisible = false"> 关闭 </el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import date from '@/api/date.js'
import req from '@/request.js'
const BigNumber = require('bignumber.js')
import ProjectInfoDialog from '@/components/dialog/ProjectInfoDialog.vue'
const eipUserSelector = () =>
  import('@/components/selector/EipUserSelector.vue')
export default {
  name: 'contractAccount',
  components: {
    // ProjectInfoDialog,
    // eipUserSelector,
  },
  props: {
    pid: {
      type: String,
      default: '',
    },
    isShow: {
      type: Boolean,
      default: true,
    },
    alias: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      total: {
        projectName: '合计',
        contractNumber: '----',
        name: '----',
        typeValue: '----',
        ourPart: '----',
        otherPart: '----',
        contractAmount: 0,
        contractDate: '----',
        contractReceiver: '----',
        establishmentRemarks: '----',
      },
      AmountOptions: [
        {
          label: '小于20万',
          value: 'less,20',
        },
        {
          label: '50 ~ 100万',
          value: '50,100',
        },
        {
          label: '100 ~ 200万',
          value: '100,200',
        },
        {
          label: '200 ~ 400万',
          value: '200,400',
        },
        {
          label: '400万以上',
          value: 'great,400',
        },
      ],
      justShowSearch: true,
      details: {},
      loading: false,
      searchForm: {
        projectName: '',
        // projectCode: '',
        type: '',
        // handler: '',
        // contractDate: '',
        // contractNumber: '',
        createTime: new Date().getFullYear(), //当前年份
        projectType: '', //项目类型
        typeValue: '',
        contractReceiver: '',
      },
      optionYears: [], //顶部搜索年份选择数组
      data: [], //表格数据
      pageResult: {
        page: 1,
        pageSize: 20,
        total: 0,
      },
      form: {},
      dialogVisible: false,
      dialogTitle: '添加',
      isShowInput: false,
      contractReceiverParams: {}, // 经办人单独请求参数
    }
  },
  created() {
    this.getYear()
  },
  computed: {
    deleteUrl: function () {
      return (
        window.context.cqxy +
        '/biz/completionAcceptance/acceptanceSettlement/v1/delete'
      )
    },
  },

  methods: {
    saveContractReceiver() {
      // console.log(this.contractReceiverParams)
      // return
      this.$http
        .post(
          '${cqxy}/biz/ledger/contractLedger/v1/updateContractReceiverById',
          this.contractReceiverParams
        )
        .then((res) => {
          this.dialogVisible = false // 关闭弹层,重新刷新数据
          this.load()
        })
    },
    contractReceiverBlur(e, row) {
      this.isShowInput = false // 关闭显示输入框
      let data = {
        id: row.contractId,
        contractReceiver: e.target.value,
      }
      this.contractReceiverParams = data
    },
    //获取顶部搜索的年份区间
    getYear() {
      const myDate = new Date()
      const startYear = 2006 //起始年份
      const endYear = myDate.getFullYear() //结束年份
      for (let i = endYear; i >= startYear; i--) {
        this.optionYears.push({
          label: i + '年',
          value: i,
        })
      }
    },
    handleReset() {
      this.searchForm.projectName = ''
      // this.searchForm.projectCode = ''
      this.searchForm.typeValue = ''
      // this.searchForm.handler = ''
      // this.searchForm.contractDate = ''
      // this.searchForm.contractNumber = ''
      this.searchForm.createTime = ''
      this.searchForm.projectType = ''
      this.searchForm.yearMonth = ''
      this.searchForm.contractAmount = ''
      this.searchForm.contractReceiver = ''
      this.$refs['searchForm'].resetFields()
      this.pageResult = {
        page: 1,
        pageSize: 20,
        total: 0,
      }
      this.$nextTick(() => {
        this.$refs.AtTable.load()
      })
    },

    //导入后重新加载数据
    load() {
      this.$refs.AtTable.load()
    },
    //导出
    handleExport() {
      this.loading = true
      let query = []
      let search = {
        'pm.PROJECT_NAME_': this.searchForm.projectName,
        'bc.type_value_': this.searchForm.typeValue,
        project_type_: this.searchForm.projectType,
        CREATE_TIME_: this.searchForm.createTime,
        year_month_: this.searchForm.yearMonth,
        contract_amount_: this.searchForm.contractAmount,
        'bc.contract_receiver_': this.searchForm.contractReceiver,
      }
      if (!this.isShow) {
        search['pm.ID_'] = this.pid
        search['pm.PROJECT_NAME_'] = this.searchForm.projectName
        delete search.CREATE_TIME_
      }
      for (let i in search) {
        if (search[i]) {
          if (i == 'CREATE_TIME_') {
            query.push(
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN', //BETWEEN
                parentGroup: '',
                property: ' commencement_time_',
                relation: 'AND',
                value: [
                  `${search[i]}-01-01 00:00:00`,
                  `${search[i]}-12-31 23:59:59`,
                ],
              }
              // {
              //   group: 'createTimeGroup',
              //   operation: 'BETWEEN',
              //   parentGroup: '',
              //   property: 'contract_date_',
              //   relation: 'AND',
              //   value: [
              //     `${search[i]}-01-01 00:00:00`,
              //     `${search[i]}-12-31 23:59:59`,
              //   ],
              // },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS_EQUAL',
              //   parentGroup: 'createTimeGroup',
              //   property: 'commencement_time_',
              //   relation: 'AND',
              //   value: `${search[i]}-12-31 23:59:59`,
              // },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS',
              //   parentGroup: 'createTimeGroup',
              //   property: 'PROJECT_STATUS_',
              //   relation: 'AND',
              //   value: '12',
              // }
            )
          } else if (i == 'year_month_') {
            let lastDate = search[i][1]
            let str = lastDate.split('-')
            let year = parseInt(str[0])
            let month = parseInt(str[1])
            let date = new Date(year, month, 0).getDate()
            let arr = [`${search[i][0]}-01`, `${search[i][1]}-${date}`]
            query.push(
              {
                group: 'contractDateGroup',
                operation: 'GREAT_EQUAL',
                parentGroup: '',
                property: 'contract_date_',
                relation: 'AND',
                value: arr[0],
              },
              {
                group: 'contractDateGroup',
                operation: 'LESS_EQUAL',
                parentGroup: '',
                property: 'contract_date_',
                relation: 'AND',
                value: arr[1],
              }
            )
          } else if (i == 'contract_amount_') {
            let arr = search[i].split(',')
            if (arr[0] == 'less') {
              query.push({
                group: 'advance',
                operation: 'LESS',
                property: i,
                relation: 'AND',
                value: arr[1],
              })
            } else if (arr[0] == 'great') {
              query.push({
                group: 'advance',
                operation: 'GREAT',
                property: i,
                relation: 'AND',
                value: arr[1],
              })
            } else {
              query.push(
                {
                  group: 'advance',
                  operation: 'GREAT_EQUAL',
                  property: i,
                  relation: 'AND',
                  value: arr[0],
                },
                {
                  group: 'advance',
                  operation: 'LESS_EQUAL',
                  property: i,
                  relation: 'AND',
                  value: arr[1],
                }
              )
            }
          } else if (i == 'project_type_') {
            query.push({
              group: 'advance',
              operation: 'EQUAL',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          } else if (i == 'pm.PROJECT_NAME_') {
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          } else if (i == 'bc.contract_receiver_' || i == 'bc.type_value_') {
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          } else {
            query.push({
              group: 'advance',
              operation: 'EQUAL',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          }
        }
      }
      let param = {
        pageBean: {
          page: 1,
          pageSize: -1,
          showTotal: true,
        },
        querys: query,
        sorter: [
          {
            direction: 'ASC',
            property: 'contract_number_',
          },
          {
            direction: 'ASC',
            property: 'mold_value_',
          },
          {
            direction: 'ASC',
            property: 'contract_date_',
          },
        ],
      }
      req
        .downloadPostCopy(
          '${cqxy}/biz/ledger/contractLedger/v1/exportDataToExcel',
          param
        )
        .then((res) => {
          if (res.status === 200) {
            this.loading = false
            this.$message.success('导出成功')
          } else {
            this.loading = false
            this.$message.error('导出失败')
          }
        })
    },
    handleFile(file) {
      this.form.accessoryInfo = file
    },

    handleRowDBClick(data) {
      // this.dialogTitle = '详情'
      // this.form = {...data}
      this.details = data
      this.dialogVisible = true
    },
    handleFocusProject() {
      this.$refs.project.open()
    },
    openProject() {
      this.$refs.project.open()
    },
    handleSelect(selection) {
      console.log(selection)
    },
    handleDialogCancel() {
      this.dialogVisible = false
      this.form = {
        projectInfo: {},
        accessoryInfo: [],
        contractInfo: {},
      }
    },
    handleDialogClose() {
      this.form = {
        projectInfo: {},
        accessoryInfo: [],
        contractInfo: {},
      }
      this.dialogVisible = false
    },
    //提交保存
    handleDialogSubmit() {
      this.$refs.form.validate((valid) => {
        if (valid && this.form.accessoryInfo.length !== 0) {
          // if (this.form.accessoryInfo && this.form.accessoryInfo.length) {
          this.form.accessoryInfo.forEach((item) => {
            if (item.id) {
              delete item.id
            }
          })
          // }
          this.loading = true
          this.$http
            .post(
              '${cqxy}/biz/completionAcceptance/acceptanceSettlement/v1/save',
              this.form
            )
            .then((res) => {
              if (res.data.state) {
                this.$refs.form.resetFields()
                this.$message.success(res.data.message)
                this.dialogVisible = false
                this.$refs.AtTable.load()
              } else {
                this.$message.error(res.data.message)
              }
              this.loading = false
            })
        } else if (this.form.accessoryInfo.length === 0) {
          this.$message.error('请至少上传一个附件')
        } else {
          this.$message({
            message: '*号必填项,不能为空!',
            type: 'warning',
          })
          return false
        }
      })
    },
    loadData(param, cb) {
      // this.$refs.projectInfo.getProjectData(this.searchForm.createTime)
      let query = []
      let search = {
        'pm.PROJECT_NAME_': this.searchForm.projectName,
        'bc.type_value_': this.searchForm.typeValue,
        'bc.contract_receiver_': this.searchForm.contractReceiver,
        project_type_: this.searchForm.projectType,
        CREATE_TIME_: this.searchForm.createTime,
        year_month_: this.searchForm.yearMonth,
        contract_amount_: this.searchForm.contractAmount,
      }
      if (!this.isShow) {
        search['pm.ID_'] = this.pid
        search['pm.PROJECT_NAME_'] = this.searchForm.projectName
        delete search.CREATE_TIME_
      }
      for (let i in search) {
        if (search[i]) {
          if (i == 'CREATE_TIME_') {
            query.push(
              // {
              //   group: 'createTimeGroup',
              //   operation: 'BETWEEN',
              //   parentGroup: '',
              //   property: 'commencement_time_',
              //   relation: 'OR',
              //   value: [
              //     `${search[i]}-01-01 00:00:00`,
              //     `${search[i]}-12-31 23:59:59`,
              //   ],
              // },
              // {
              //   group: 'createTimeSubGroup',
              //   operation: 'LESS_EQUAL',
              //   parentGroup: 'createTimeGroup',
              //   property: 'commencement_time_',
              //   relation: 'AND',
              //   value: `${search[i]}-12-31 23:59:59`,
              // },
              //   {
              //     group: 'createTimeSubGroup',
              //     operation: 'LESS',
              //     parentGroup: 'createTimeGroup',
              //     property: 'PROJECT_STATUS_',
              //     relation: 'AND',
              //     value: '12',
              //   },
              {
                group: 'createTimeGroup',
                operation: 'BETWEEN', //BETWEEN
                parentGroup: '',
                property: ' commencement_time_',
                relation: 'AND',
                value: [
                  `${search[i]}-01-01 00:00:00`,
                  `${search[i]}-12-31 23:59:59`,
                ],
              }
            )
          } else if (i == 'year_month_') {
            let lastDate = search[i][1]
            let str = lastDate.split('-')
            let year = parseInt(str[0])
            let month = parseInt(str[1])
            let date = new Date(year, month, 0).getDate()
            let arr = [`${search[i][0]}-01`, `${search[i][1]}-${date}`]
            query.push(
              {
                group: 'contractDateGroup',
                operation: 'GREAT_EQUAL',
                parentGroup: '',
                property: 'contract_date_',
                relation: 'AND',
                value: arr[0],
              },
              {
                group: 'contractDateGroup',
                operation: 'LESS_EQUAL',
                parentGroup: '',
                property: 'contract_date_',
                relation: 'AND',
                value: arr[1],
              }
            )
          } else if (i == 'contract_amount_') {
            let arr = search[i].split(',')
            if (arr[0] == 'less') {
              query.push({
                group: 'advance',
                operation: 'LESS',
                property: i,
                relation: 'AND',
                value: arr[1],
              })
            } else if (arr[0] == 'great') {
              query.push({
                group: 'advance',
                operation: 'GREAT',
                property: i,
                relation: 'AND',
                value: arr[1],
              })
            } else {
              query.push(
                {
                  group: 'advance',
                  operation: 'GREAT_EQUAL',
                  property: i,
                  relation: 'AND',
                  value: arr[0],
                },
                {
                  group: 'advance',
                  operation: 'LESS_EQUAL',
                  property: i,
                  relation: 'AND',
                  value: arr[1],
                }
              )
            }
          } else if (i == 'project_type_') {
            query.push({
              group: 'advance',
              operation: 'EQUAL',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          } else if (i == 'pm.PROJECT_NAME_') {
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          } else if (i == 'bc.type_value_' || i == 'bc.contract_receiver_') {
            query.push({
              group: 'advance',
              operation: 'LIKE',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          } else {
            query.push({
              group: 'advance',
              operation: 'EQUAL',
              property: i,
              relation: 'AND',
              value: search[i],
            })
          }
        }
      }
      if (param.querys && param.querys.length) {
        param.querys.push(...query)
      } else {
        param.querys = query
      }
      this.$http
        .post('${cqxy}/biz/ledger/contractLedger/v1/page', param)
        .then(
          (resp) => {
            let response = resp.data.value
            let data = response.data
            let total = this.calculationTotal(data, 'contractAmount')
            this.total.contractAmount = total
            if (data.length !== 0) {
              data.push(this.total)
            }
            this.data = data
            this.pageResult = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total,
            }
          },
          (error) => {
            reject(error)
          }
        )
        .finally(() => {
          if (cb) {
            cb()
            // this.data = [{contractReceiver: '4444'}]
          }
        })
    },
    findinfo() {
      this.$refs.AtTable.load()
    }, // 计算列表合同金额合计金额
    calculationTotal(data, key) {
      let total = new BigNumber(0)
      if (key && data && data.length !== 0) {
        data.forEach((item) => {
          if (item[key]) {
            total = total.plus(item[key])
          } else {
            total = total.plus(0)
          }
        })
      }
      return this.moneyFormatter(total)
    },
    cellClassNameFn(row) {
      // 列表项目名称为【合计】隐藏复选框
      if (row.row.projectName === '合计') {
        return 'table-column-hidden'
      }
    },
  },
}
</script>
<style lang="scss" scoped>
@import '@/assets/css/common.scss';

/deep/ .el-range-editor--small .el-range-separator {
  display: contents;
}

table {
  width: 100%;
  border-collapse: collapse;
}

/deep/ .el-dialog__body {
  padding-top: 20px;
  padding-bottom: 20px;
}

table,
table tr td {
  border: 1px solid #ebeef5;
}

table tr td {
  padding: 15px 10px;
  // text-align: center;
}

.bgColor {
  background: #fafafa;
  color: #909399;
  // font-weight: bold;
}

/deep/ .el-table thead.is-group th {
  border-color: #ebeef5;
}

.flexEnd {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  margin-right: 5px;

  .end {
    display: flex;
    flex-direction: column;
    color: #33333385;
  }
}
.moreInput {
  /deep/ .el-date-editor.el-input,
  .el-date-editor.el-input__inner {
    height: 4vh !important;
  }
}
.show-slected {
  font-size: 18px;
  i {
    font-style: normal;
    font-weight: 700;
    margin: 0 5px;
    color: #f40;
  }
}
/deep/ .table-column-hidden .el-checkbox__input {
  display: none;
}
/deep/ .table-column-hidden .cell > div {
  display: none;
}
</style>
