<template>
  <!-- 进度管理 -->
  <div class="items bgc" id="work5">
    <!-- 标题 -->
    <div class="title">
      <span class="icon"></span>
      <span class="text">进度管理</span>
    </div>
    <!-- 详情 -->
    <!-- tabs切换 -->
    <div class="main-content">
      <el-tabs type="border-card" v-model="activeName" @tab-click="handleClick">
        <!-- 工程月报 -->
        <el-tab-pane label="工程月报" name="establishment">
          <div class="table-border">
            <el-table
              :data="data"
              height="250"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
              @row-click="handleRowDBClick"
            >
              <el-table-column
                type="index"
                label="序号"
                width="60"
                align="center"
              >
              </el-table-column>
              <el-table-column
                prop="portDate"
                label="审定日期"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <a class="a-link">{{ row.portDate }}</a>
                </template>
              </el-table-column>
              <!-- <el-table-column
                prop="portType"
                label="填报类型"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  {{ getDictName('gcyb-tblx', row.portType) }}
                </template>
              </el-table-column> -->
              <el-table-column
                prop="progressDescription"
                label="审定支付金额(万元)"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  {{
                    row &&
                    row.progressDescription &&
                    parseInt(row.progressDescription / 10000)
                  }}
                </template>
              </el-table-column>
              <el-table-column
                prop="projectOvervie"
                label="累计总投资(万元)"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  {{
                    row &&
                    row.projectOvervie &&
                    parseInt(row.projectOvervie / 10000)
                  }}
                </template>
              </el-table-column>
              <el-table-column
                prop="engineeringChange"
                label="本月产值"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  {{
                    row &&
                    row.engineeringChange &&
                    parseInt(row.engineeringChange / 10000)
                  }}
                </template>
              </el-table-column>
              <el-table-column
                prop="remarks"
                label="备注"
                align="center"
                width="120"
                :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>
          </div>
          <el-dialog
            title="工程月报-详情"
            :visible.sync="dialogVisible"
            width="1000px"
          >
            <table align="center">
              <tr>
                <td class="bgColor" style="width: 150px">审定日期</td>
                <td>
                  {{ formData.portDate }}
                </td>
                <!-- <td class="bgColor" style="width: 130px">填报类型</td>
                <td>{{ getDictName('gcyb-tblx', formData.portType) }}</td> -->
                <td class="bgColor" style="width: 150px">审定支付金额(万元)</td>
                <td>
                  {{
                    formData.progressDescription &&
                    parseInt(formData.progressDescription / 10000)
                  }}
                </td>
              </tr>
              <tr>
                <td class="bgColor">累计总投资(万元)</td>
                <td>
                  {{
                    formData.projectOvervie &&
                    parseInt(formData.projectOvervie / 10000)
                  }}
                </td>

                <td class="bgColor">本月产值</td>
                <td>
                  {{
                    formData.engineeringChange &&
                    parseInt(formData.engineeringChange / 10000)
                  }}
                </td>
              </tr>
              <tr>
                <td class="bgColor">工程进度</td>
                <td colspan="3">{{ formData.imageProgress }}</td>
              </tr>
              <tr>
                <td class="bgColor">形象进度</td>
                <td colspan="3">{{ formData.weeklyMouthlyWork }}</td>
              </tr>
              <!-- <tr>
                <td class="bgColor">附件信息</td>
                <td colspan="3">
                  <el-link
                    type="primary"
                    @click="handleLook(formData.accessoryInfo)"
                    v-if="
                      formData.accessoryInfo &&
                      formData.accessoryInfo.length > 0
                    "
                  >查看附件({{ formData.accessoryInfo.length }}个)</el-link>
                  <span v-else></span>
                </td>
              </tr> -->
              <tr>
                <td class="bgColor">备注</td>
                <td colspan="3">{{ formData.remarks }}</td>
              </tr>
            </table>
            <dialog-accessory
              ref="accessory"
              :accessoryInfo="formData.accessoryInfo"
            />
            <div class="flexEnd">
              <div class="end">
                <!-- <span>项目名称：{{formData.projectInfo && formData.projectInfo.projectName}}</span> -->
                <span>{{
                  formData.projectInfo && formData.projectInfo.projectManager
                }}</span>
                <span>{{
                  formData.projectInfo && formData.projectInfo.commencementTime
                }}</span>
              </div>
            </div>
          </el-dialog>
        </el-tab-pane>
        <!-- 工程支付 -->
        <el-tab-pane label="工程支付" name="audit">
          <div class="table-border">
            <el-table
              :data="data2"
              height="230"
              border
              style="width: 100%"
              :header-cell-style="{background: '#f2f2f2', color: '#000'}"
              @row-click="handleRowDBClick2"
            >
              <el-table-column
                type="index"
                label="序号"
                width="60"
                align="center"
              >
              </el-table-column>
              <!-- <el-table-column
                prop="registerDate"
                label="审批日期"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column> -->
              <ht-table-column
                prop="purpose"
                label="用途"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <a class="a-link" v-if="row">{{
                    getDictName('jdgl-yt', row.purpose)
                  }}</a>
                </template>
              </ht-table-column>
              <el-table-column
                prop="totalInvestment"
                label="总投资额(万元)"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <!-- {{
                    row &&
                    row.totalInvestment &&
                    parseInt(row.totalInvestment / 10000)
                  }} -->
                  {{ row.totalInvestment }}
                </template>
              </el-table-column>
              <el-table-column
                prop="amountAppropriated"
                label="已拨款金额(万元)"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <!-- {{
                    row &&
                    row.amountAppropriated &&
                    parseInt(row.amountAppropriated / 10000)
                  }} -->
                  {{ row.amountAppropriated }}
                </template>
              </el-table-column>
              <el-table-column
                prop="measurementData"
                label="支付比例"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
              <el-table-column
                prop="outputValue"
                label="未拨款金额(万元)"
                align="center"
                :show-overflow-tooltip="true"
              >
                <template v-slot="{row}">
                  <!-- {{
                    row &&
                    row.outputValue &&
                    parseInt(row.outputValue / 10000)
                  }} -->
                  {{ row.outputValue }}
                </template>
              </el-table-column>
              <!-- <el-table-column
                prop="payeeAmountTotal"
                label="本次拨款额(元)"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column> -->
              <el-table-column
                prop="remarks"
                label="备注"
                align="center"
                width="120"
                :show-overflow-tooltip="true"
              >
              </el-table-column>
            </el-table>
            <div class="page-footer">
              <el-pagination
                @size-change="handleSizeChange2"
                @current-change="handleCurrentChange2"
                :current-page="pageResult2.page"
                :page-sizes="[5, 10, 20, 30, 50]"
                :page-size="pageResult2.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageResult2.total"
              >
              </el-pagination>
            </div>
          </div>
          <el-dialog
            title="工程支付-详情"
            :visible.sync="dialogVisible2"
            width="1000px"
          >
            <div class="table-border">
              <el-table
                :data="data2_"
                height="200"
                border
                style="width: 100%"
                :header-cell-style="{background: '#f2f2f2', color: '#000'}"
                @row-click="handleRowDBClick2_"
              >
                <el-table-column
                  type="index"
                  label="序号"
                  width="60"
                  align="center"
                >
                </el-table-column>
                <!-- <el-table-column
                prop="registerDate"
                label="审批日期"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column> -->
                <el-table-column
                  prop="purpose"
                  label="用途"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template v-slot="{row}">
                    <a class="a-link" v-if="row">{{
                      getDictName('jdgl-yt', row.purpose)
                    }}</a>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="registerDate"
                  label="审批日期"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                </el-table-column>
                <el-table-column
                  prop="totalInvestment"
                  label="总投资额(万元)"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template v-slot="{row}">
                    {{
                      row &&
                      row.totalInvestment &&
                      parseInt(row.totalInvestment / 10000)
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="payeeAmountTotal"
                  label="本次拨款额(万元)"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template v-slot="{row}">
                    {{
                      row &&
                      row.payeeAmountTotal &&
                      parseInt(row.payeeAmountTotal / 10000)
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="amountAppropriated"
                  label="已拨款金额(万元)"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template v-slot="{row}">
                    {{
                      row &&
                      row.amountAppropriated &&
                      parseInt(
                        row.amountAppropriated / 10000
                      )
                    }}
                  </template>
                </el-table-column>
                <el-table-column
                  prop="measurementData"
                  label="项目进度情况及已完成工作量"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                </el-table-column>
                <!-- <el-table-column
                  prop="outputValue"
                  label="未拨款金额(万元)"
                  align="center"
                  :show-overflow-tooltip="true"
                >
                  <template v-slot="{row}">
                    {{row.outputValue}}
                  </template>
                </el-table-column> -->
                <!-- <el-table-column
                prop="payeeAmountTotal"
                label="本次拨款额(元)"
                align="center"
                :show-overflow-tooltip="true"
              >
              </el-table-column> -->
                <el-table-column
                  prop="remarks"
                  label="备注"
                  align="center"
                  width="120"
                  :show-overflow-tooltip="true"
                >
                </el-table-column>
              </el-table>
              <div class="page-footer">
                <el-pagination
                  @size-change="handleSizeChange2_"
                  @current-change="handleCurrentChange2_"
                  :current-page="pageResult2_.page"
                  :page-sizes="[5, 10, 20, 30, 50]"
                  :page-size="pageResult2_.pageSize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="pageResult2_.total"
                >
                </el-pagination>
              </div>
            </div>
          </el-dialog>

          <el-dialog
            title="工程支付-详情"
            :visible.sync="dialogVisible2_"
            width="1000px"
          >
            <table align="center">
              <tr>
                <td class="bgColor" style="width: 130px">部室(子公司)</td>
                <td style="width: 300px">
                  {{ formData2.dept }}
                </td>
                <td class="bgColor" style="width: 130px">审批日期</td>
                <td>{{ formData2.registerDate }}</td>
              </tr>
              <tr>
                <td class="bgColor">用途</td>
                <td>{{ getDictName('jdgl-yt', formData2.purpose) }}</td>
                <td class="bgColor">总投资额(万元)</td>
                <td>
                  {{
                    formData2.totalInvestment &&
                    moneyFormatter(
                      (formData2.totalInvestment / 10000).toFixed(2)
                    )
                  }}
                </td>
              </tr>
              <tr>
                <td class="bgColor">已拨款额(万元)</td>
                <td>
                  {{
                    formData2.amountAppropriated &&
                    moneyFormatter(
                      (formData2.amountAppropriated / 10000).toFixed(2)
                    )
                  }}
                </td>
                <td class="bgColor">本次拨款额(万元)</td>
                <td>
                  {{
                    formData2.payeeAmountTotal &&
                    moneyFormatter(formData2.payeeAmountTotal)
                  }}
                </td>
              </tr>
              <tr>
                <td class="bgColor">票据号码</td>
                <td>{{ formData2.settlementBillNum }}</td>
                <td class="bgColor">收款单位</td>
                <td>{{ formData2.payeeUnit }}</td>
              </tr>
              <tr>
                <td class="bgColor">账号</td>
                <td>{{ formData2.payeeNum }}</td>
                <td class="bgColor">开户行</td>
                <td>{{ formData2.bankOfDeposit }}</td>
              </tr>
              <tr>
                <td class="bgColor">项目进度情况及已完成工作量</td>
                <td colspan="3">{{ formData2.measurementData }}</td>
              </tr>
              <!-- <tr>
                <td class="bgColor">附件信息</td>
                <td colspan="3">
                  <el-link
                    type="primary"
                    @click="handleLook(formData2.accessoryInfo)"
                    v-if="
                      formData2.accessoryInfo &&
                      formData2.accessoryInfo.length > 0
                    "
                  >查看附件({{ formData2.accessoryInfo.length }}个)</el-link>
                  <span v-else>无</span>
                </td>
              </tr> -->
              <tr>
                <td class="bgColor">备注</td>
                <td colspan="3">{{ formData2.remarks }}</td>
              </tr>
            </table>
            <dialog-accessory
              ref="accessory"
              :accessoryInfo="formData2.accessoryInfo"
            />
            <div class="flexEnd">
              <div class="end">
                <!-- <span>项目名称：{{formData2.projectInfo && formData2.projectInfo.projectName}}</span> -->
                <span>{{
                  formData2.projectInfo && formData2.projectInfo.projectManager
                }}</span>
                <span>{{
                  formData2.projectInfo &&
                  formData2.projectInfo.commencementTime
                }}</span>
              </div>
            </div>
          </el-dialog>
        </el-tab-pane>
      </el-tabs>
    </div>
    <!-- <dialog-accessory ref="accessory" /> -->
  </div>
</template>
<script>
import dialogAccessory from '../dialog/dialogAccessory.vue'
export default {
  name: 'schedule',
  components: {
    dialogAccessory,
  },
  data() {
    return {
      data: [],
      data2: [],
      data2_: [],
      activeName: 'establishment',
      dialogTitle: '详情',
      dialogVisible: false,
      formData: {},
      formData2: {},
      dialogVisible2: false,
      dialogVisible2_: false,
      pageResult: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
      pageResult2: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
      pageResult2_: {
        page: 1,
        pageSize: 10,
        total: 0,
      },
    }
  },
  mounted() {
    this.loadData()
    this.loadData2()
  },
  methods: {
    //tabs
    handleClick(tab, even) {
      // console.log(tab.paneName)
    },
    //附件
    handleLook(obj) {
      this.$refs.accessory.open(obj)
    },
    handleRowDBClick(data) {
      this.dialogVisible = true
      this.formData = data
    },

    handleSizeChange(val) {
      this.pageResult.pageSize = val
      this.loadData()
    },
    handleCurrentChange(val) {
      this.pageResult.page = val
      this.loadData()
    },
    handleSizeChange2(val) {
      this.pageResult2.pageSize = val
      this.loadData2()
    },
    handleCurrentChange2(val) {
      this.pageResult2.page = val
      this.loadData2()
    },
    handleRowDBClick2(data) {
      this.dialogVisible2 = true
      // this.formData2 = data
      this.loadData2_()
    },
    handleSizeChange2_(val) {
      this.pageResult2_.pageSize = val
      this.loadData2_()
    },
    handleCurrentChange2_(val) {
      this.pageResult2_.page = val
      this.loadData2_()
    },
    handleRowDBClick2_(data) {
      this.dialogVisible2_ = true
      let newData = {...data}
      if (newData.payeeAmountTotal) {
        newData.payeeAmountTotal = newData.payeeAmountTotal / 10000
      }
      this.formData2 = newData
    },
    loadData() {
      let param = {
        pageBean: {
          ...this.pageResult,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
        ],
        sorter: [{direction: 'DESC', property: 'portDate'}],
      }
      this.$http
        .post(
          '${cqxy}/biz/processManagement/progressManageReport/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)
          }
        )
    },
    loadData2() {
      let param = {
        pageBean: {
          ...this.pageResult2,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
          {
            group: 'filter',
            operation: 'EQUAL',
            property: 'purpose',
            relation: 'AND',
            value: '1',
          },
        ],
        sorter: [{direction: 'DESC', property: 'registerDate'}],
      }
      let param_ = {
        projectId: this.$route.params.id,
        purpose: 1,
      }
      this.$http
        .post(
          '${cqxy}/biz/processManagement/progressManage/v1/getProgressManageTotalByProjectId',
          param_
        )
        .then(
          (resp) => {
            let response = resp.data
            let arr = []
            arr.push(response.value)
            this.data2 = arr
            this.pageResult2 = {
              page: 1,
              pageSize: response.pageSize,
              total: 1,
            }
          },
          (error) => {
            reject(error)
          }
        )
    },
    loadData2_() {
      let param = {
        pageBean: {
          ...this.pageResult2_,
        },
        querys: [
          {
            group: 'advance',
            opener: 'LIKE',
            property: 'pm.ID_',
            relation: 'AND',
            value: this.$route.params.id,
          },
          {
            group: 'filter',
            operation: 'EQUAL',
            property: 'purpose',
            relation: 'AND',
            value: '1',
          },
        ],
        sorter: [{direction: 'DESC', property: 'registerDate'}],
      }
      this.$http
        .post('${cqxy}/biz/processManagement/progressManage/v1/page', param)
        .then(
          (resp) => {
            let response = resp.data.value
            this.data2_ = response.rows
            this.pageResult2_ = {
              page: response.page,
              pageSize: response.pageSize,
              total: response.total,
            }
          },
          (error) => {
            reject(error)
          }
        )
    },
  },
}
</script>
<style lang="scss" scoped>
@import '../css/projectCommon.scss';

/deep/ .el-tabs__content {
  padding: 10px !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: 515px;
}
/deep/ .el-table {
  height: calc(100% - 40px) !important;
}
</style>
