<template>
    <!-- 决策依据 -->
    <div class="do-jump items bgc" id="page2">
        <!-- 标题 -->
        <div class="title">
            <span class="icon"></span>
            <span class="text">决策依据</span>
        </div>

        <!-- 详情 -->
        <div class="main-content" v-if="show">
            <el-table
                :data="data"
                height="300"
                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="decisionBasisTime"
                    label="决策时间"
                    align="center"
                    :show-overflow-tooltip="true"
                >
                    <template v-slot="{row}">
                        <a class="a-link">{{ row.decisionBasisTime }}</a>
                    </template>
                </el-table-column>
                <el-table-column prop="decisionBasisType" label="决策类型" width="180">
                    <template v-slot="{row}">
                        {{ getDictMultipleName('xmlx-jcyj-jcwjlx', row.decisionBasisType) }}
                    </template>
                </el-table-column>
                <el-table-column prop="decisionBasisDescribe" label="决策描述"> </el-table-column>
                <el-table-column prop="remarks" label="备注"> </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>
        <div class="main-content table-box" v-else>
            <el-empty description="暂无数据" :image-size="100"></el-empty>
        </div>
        <el-dialog title="决策依据-详情" :visible.sync="dialogVisible" width="1000px">
            <table align="center">
                <tr>
                    <td class="bgColor" style="width: 130px">决策时间</td>
                    <td>{{ form.decisionBasisTime }}</td>
                    <td class="bgColor" style="width: 130px">决策类型</td>
                    <td style="width: 240px">
                        {{ getDictMultipleName('xmlx-jcyj-jcwjlx', form.decisionBasisType) }}
                    </td>
                </tr>
                <tr>
                    <td class="bgColor">决策描述</td>
                    <td colspan="3">
                        {{ form.decisionBasisDescribe }}
                    </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.projectManager }}</span>
                    <span>{{ form.projectInfo && form.projectInfo.commencementTime }}</span>
                </div>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import dialogAccessory from '../dialog/dialogAccessory.vue'
export default {
    name: 'decision',
    components: {
        dialogAccessory,
    },
    data() {
        return {
            data: [],
            show: true,
            dialogVisible: false,
            form: {},
            pageResult: {
                page: 1,
                pageSize: 5,
                total: 0,
            },
        }
    },
    mounted() {
        this.loadData()
    },
    methods: {
        //附件
        handleLook(obj) {
            this.$refs.accessory.open(obj)
        },
        loadData() {
            let param = {
                pageBean: {
                    ...this.pageResult,
                },
                querys: [
                    {
                        group: 'main',
                        operation: 'EQUAL',
                        parentGroup: '',
                        property: 'PROJECT_ID_ ',
                        relation: 'AND',
                        value: this.$route.params.id,
                    },
                ],
            }
            this.$http.post('${cqxy}/biz/projectApproval/decisionBasis/v1/page', param).then(
                (resp) => {
                    let data = resp.data.value.rows
                    // data.forEach((item) => {
                    //     if (!item.hasOwnProperty('decisionBasisDescribe')) {

                    //         item.decisionBasisDescribe = ''
                    //     }
                    // })
                    if (data.length > 0) {
                        this.data = data
                        this.show = true
                        this.pageResult = {
                            page: resp.data.value.page,
                            pageSize: resp.data.value.pageSize,
                            total: resp.data.value.total,
                        }
                    } else {
                        this.show = false
                    }
                },
                (error) => {
                    reject(error)
                }
            )
        },
        handleRowDBClick(data) {
            this.dialogVisible = true
            this.form = data
        },
        handleSizeChange(val) {
            this.pageResult.pageSize = val
            this.loadData()
        },
        handleCurrentChange(val) {
            this.pageResult.page = val
            this.loadData()
        },
    },
}
</script>
<style lang="scss" scoped>
@import '../css/projectCommon.scss';
.page-footer {
    padding-top: 10px;
    float: right;
    height: 38px;
}
.main-content {
    height: 368px;
}
</style>