<template>
    <div class="project-schedule-dlg">
        <el-dialog title="项目进度管理" :visible.sync="open" width="1200px" append-to-body :close-on-click-modal="false"
            :close-on-press-escape="false">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-col :span="24">
                    <el-form-item label="形象图片" prop="image">
                        <image-upload v-model="form.image" :limit="2" />
                    </el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item label="计划节点" prop="plannedNode">
                        <el-input v-model="form.plannedNode" type="textarea" placeholder="请输入内容" />
                    </el-form-item>
                </el-col>
                <el-col :span="12"> <el-form-item label="实际节点" prop="actualNode">
                        <el-input v-model="form.actualNode" type="textarea" placeholder="请输入内容" />
                    </el-form-item>
                </el-col><el-col :span="12">
                    <el-form-item label="融资、招采进展" prop="purchaseProgress">
                        <el-input v-model="form.purchaseProgress" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>
                <el-col :span="12"> <el-form-item label="报建、设计进展" prop="designProgress">
                        <el-input v-model="form.designProgress" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>

                <el-col :span="24"> <el-form-item label="施工进展" prop="constructionProgress">
                        <el-input v-model="form.constructionProgress" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>
                <el-col :span="12"><el-form-item label="验收进展" prop="acceptanceProgress">
                        <el-input v-model="form.acceptanceProgress" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>
                <el-col :span="12"><el-form-item label="下周计划" prop="planForNextWeek">
                        <el-input v-model="form.planForNextWeek" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>
                <el-col :span="24"><el-form-item label="存在问题" prop="existingProblem">
                        <el-input v-model="form.existingProblem" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>
                <el-col :span="24"> <el-form-item label="问题推进情况" prop="problemProgress">
                        <el-input v-model="form.problemProgress" type="textarea" placeholder="请输入内容" />
                    </el-form-item></el-col>


            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancel">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
import { addSurProjectSchedule, getLastOne } from "@/api/project/surProjectSchedule";
export default {
    name: 'RuoyiUiProjectScheduleDlg',
    dicts: ['sys_common_isdel'],
    data() {
        return {
            elKey: 0,
            open: false,
            prj: null,
            // 表单参数
            form: {
                id: null,
                projectId: null,
                image: null,
                plannedNode: null,
                actualNode: null,
                purchaseProgress: null,
                designProgress: null,
                constructionProgress: null,
                acceptanceProgress: null,
                planForNextWeek: null,
                existingProblem: null,
                problemProgress: null,
                isDel: null,
                createBy: null,
                createTime: null,
                updateBy: null,
                updateTime: null,
                remark: null
            },
            // 表单校验
            rules: {
            }
        };
    },

    mounted() {

    },

    methods: {
        submitForm() {
            this.$refs["form"].validate(valid => {
                if (valid) {
                    this.form.projectId = this.prj.id;
                    addSurProjectSchedule(this.form).then(response => {
                        this.$modal.msgSuccess("新增成功");
                        this.open = false;
                        this.getList();
                    });

                }
            });
        },
        cancel() {
            this.open = false;
        },
        reset() {
            let obj = {};
            this.id = "";
            this.form.image = obj.image || '';
            this.form.plannedNode = obj.plannedNode || '';
            this.form.actualNode = obj.actualNode || '';
            this.form.purchaseProgress = obj.purchaseProgress || '';
            this.form.designProgress = obj.designProgress || '';
            this.form.constructionProgress = obj.constructionProgress || '';
            this.form.acceptanceProgress = obj.acceptanceProgress || '';
            this.form.planForNextWeek = obj.planForNextWeek || '';
            this.form.existingProblem = obj.existingProblem || '';
            this.form.problemProgress = obj.problemProgress || '';
            this.resetForm("form");
        },
        showDialog(prj) {
            this.prj = prj;
            this.open = true;
            this.loadLastData();
        },
        loadLastData() {
            getLastOne(this.prj.id).then(d => {
                let obj = d.data || {};
                this.form.image = obj.image || '';
                this.form.plannedNode = obj.plannedNode || '';
                this.form.actualNode = obj.actualNode || '';
                this.form.purchaseProgress = obj.purchaseProgress || '';
                this.form.designProgress = obj.designProgress || '';
                this.form.constructionProgress = obj.constructionProgress || '';
                this.form.acceptanceProgress = obj.acceptanceProgress || '';
                this.form.planForNextWeek = obj.planForNextWeek || '';
                this.form.existingProblem = obj.existingProblem || '';
                this.form.problemProgress = obj.problemProgress || '';
            })
        }
    },
};
</script>

<style lang="scss" scoped></style>
