<!--
 * @Author: @liulin
 * @Date: 2022-05-18 10:37:30
 * @LastEditTime: 2022-06-15 17:42:38
 * @LastEditors: @liulin
 * @Description: 
 * @FilePath: \cqxy_pm_web\src\views\projectManagent\modules\dialog\contractListDialog.vue
-->
<template>
  <!-- 合同管理 -->
  <!-- 详情 -->
  <el-dialog
    title="合同管理详情"
    :visible.sync="dialogVisibleContract"
    width="1000px"
  >
    <div class="table-border">
      <el-table
        :data="data"
        height="230"
        border
        style="width: 100%"
        :header-cell-style="{background: '#f2f2f2', color: '#000'}"
        @row-dblclick="handleRowDBClick"
      >
        <el-table-column
          type="index"
          label="序号"
          width="60"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="contract.name"
          label="合同名称"
          align="center"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <!-- <el-table-column
            prop="contract.contractNumber"
            label="合同编号"
            align="center"
            :show-overflow-tooltip="true"
            >
          </el-table-column> -->
        <ht-table-column
          prop="contract.type"
          label="合同类型"
          align="center"
          width="180"
          :show-overflow-tooltip="true"
        >
          <template v-slot="{row}">
            {{ getDictName('htgl-htlb', row.contract.type) }}
          </template>
        </ht-table-column>
        <el-table-column
          prop="contract.contractAmount"
          label="合同金额(元)"
          align="center"
          width="160"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
        <el-table-column
          prop="contract.establishmentRemarks"
          label="备注"
          align="center"
          width="130"
          :show-overflow-tooltip="true"
        >
        </el-table-column>
      </el-table>
      <div class="page-footer">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageResult.page"
          :page-sizes="[5, 10, 20, 30, 50]"
          :page-size="pageResult.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="pageResult.total"
        >
        </el-pagination>
      </div>
      <el-dialog
        title="详情"
        :visible.sync="dialogVisible"
        width="1000px"
        :modal='false'
      >
        <table align="center">
          <tr>
            <td
              class="bgColor"
              style="width:100px"
            >合同名称</td>
            <td>{{ form.name }}</td>
            <td
              class="bgColor"
              style="width:100px"
            >合同编号</td>
            <td>{{ form.contractNumber }}</td>
          </tr>
          <tr>
            <td class="bgColor">签订日期</td>
            <td>{{ form.contractDate }}</td>
            <td class="bgColor">合同金额(元)</td>
            <td>{{form.contractAmount}}</td>
          </tr>
          <tr>
            <td class="bgColor">甲方单位</td>
            <td>{{ form.firstParty }}</td>
            <td class="bgColor">乙方单位</td>
            <td>{{ form.secondParty }}</td>
          </tr>
          <tr>
            <td class="bgColor">丙方单位</td>
            <td>{{ form.thirdParty }}</td>
            <td class="bgColor"></td>
            <td></td>
          </tr>
          <!-- <tr>
            <td class="bgColor">附件信息</td>
            <td colspan="3">
              <el-link
                type="primary"
                @click="handleLook(form.accessoryInfo)"
                v-if="
                  form.accessoryInfo && form.accessoryInfo.length > 0
                "
              >查看附件({{ form.accessoryInfo.length }}个)</el-link>
              <span v-else></span>
            </td>
          </tr> -->
          <tr>
            <td class="bgColor">备注</td>
            <td colspan="3">{{ form.remarks }}</td>
          </tr>
        </table>
        <dialog-accessory ref="accessory" :accessoryInfo="form.accessoryInfo" />
        <div class="flexEnd">
          <div class="end">
            <span>项目名称：{{form.projectInfo && form.projectInfo.projectName}}</span>
            <span>创建负责人：{{form.projectInfo && form.projectInfo.projectManager}}</span>
            <span>创建时间：{{form.projectInfo && form.projectInfo.commencementTime}}</span>
          </div>
        </div>
      </el-dialog>
      <!-- <dialog-accessory ref="accessory" /> -->
    </div>
  </el-dialog>
</template>
<script>
import dialogAccessory from './dialogAccessory.vue'
export default {
  name: 'contract',
  props: {
    querysValue: {
      type: String,
      default: ''
    }
  },
  components: {
    dialogAccessory
  },
  data() {
    return {
      data: [], //表格数据
      pageResult: {
        page: 1,
        pageSize: 10,
        total: 0
      },
      form: {},
      dialogVisible: false,
      dialogTitle: '添加',
      dialogVisibleContract: false
    }
  },
  mounted() {
    // this.loadData()
  },
  methods: {
    open() {
      this.dialogVisibleContract = true
      this.$nextTick(()=>{
          this.loadData()
      })
      
    },
    //附件
    handleLook(obj) {
      this.$refs.accessory.open(obj)
    },
    handleSizeChange(val) {
      this.pageResult.pageSize = val
      this.loadData()
    },
    handleCurrentChange(val) {
      this.pageResult.page = val
      this.loadData()
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      data.contract.accessoryInfo = data.accessoryInfo
      this.form = data.contract
    },
    loadData() {
      let param = {
        pageBean: {
          ...this.pageResult
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id
          },
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'bc.second_party_',
            relation: 'AND',
            value: this.querysValue
          }
        ]
      }
      this.$http.post('${cqxy}/biz/contract/v1/page', param).then(
        resp => {
          let response = resp.data.value
          this.data = response.rows
          this.pageResult = {
            page: response.page,
            pageSize: response.pageSize,
            total: response.total
          }
        },
        error => {
          reject(error)
        }
      )
    }
  }
}
</script>
<style lang="scss" scoped>
@import '../css/projectCommon.scss';
/deep/ .el-empty {
  padding: 0 !important;
}
/deep/ .el-main .content {
  padding: 0 !important;
}
.page-footer {
  padding-top: 10px;
  float: right;
}
/deep/ .el-dialog__body {
  padding-top: 10px;
}
.table-border {
  height: 360px;
}
/deep/ .el-table {
  height: calc(100% - 40px) !important;
}
</style>
