<template>
    <div class="edit-view">
        <div v-for="(item, index) in audits" :key="index" class="div-style">
            <div style="padding-left: 40px;">
                <el-form :model="item" label-width="80">
                    <el-form-item label="时间">
                        <el-date-picker
                            v-model="item.createdAt"
                            type="datetime"
                            value-format="yyyy-MM-dd HH:mm:ss"
                            placeholder="选择日期时间"
                            style="width: 400px"
                            disabled
                        >
                        </el-date-picker>
                    </el-form-item>

                    <el-form-item label="进度">
                        <div class="tishi" v-if="item.status == 'REVIEW_DENY'">
                            <span>市文旅局退回意见：</span>
                        </div>
                        <div class="tishi" v-if="item.status == 'FIRST_REVIEW_DENY'">
                            <span>区文旅局退回意见：</span>
                        </div>
                        <el-input
                            v-if="item.status == 'REVIEW_DENY' || item.status == 'FIRST_REVIEW_DENY'"
                            style="width: 400px;margin-left: 40px"
                            type="textarea"
                            v-model="item.remark"
                            readonly
                            autosize
                        ></el-input>
                        <el-input
                            v-else
                            style="width: 400px;"
                            type="textarea"
                            v-model="item.remark"
                            readonly
                            autosize
                        ></el-input>
                    </el-form-item>
                </el-form>
            </div>
            <el-divider direction="horizontal" content-position="left"></el-divider>
        </div>
        <div style="padding:20px 100px;display:flex" class="fixed-btn">
            <el-button @click="$router.go(-1)">返回</el-button>
        </div>
    </div>
</template>
<script>
export default {
    name: 'RateAuditEdit',
    created() {
        if (this.$route.query.id) {
            this.$http
                .post('/rateAudit/all', { size: 100, query: { rateId: this.$route.query.id } }, { body: 'json' })
                .then(res => {
                    this.audits = res.content;
                })
                .catch(e => {
                    console.log(e);
                    this.$message.error(e.error);
                });
        }
    },
    data() {
        return {
            saving: false,
            formData: {},
            audits: []
        };
    },
    methods: {
        onSave() {
            this.$refs.form.validate(valid => {
                if (valid) {
                    this.submit();
                } else {
                    return false;
                }
            });
        },
        submit() {
            let data = { ...this.formData };

            this.saving = true;
            this.$http
                .post('/rateAudit/save', data, { body: 'json' })
                .then(res => {
                    this.saving = false;
                    this.$message.success('成功');
                    this.$router.go(-1);
                })
                .catch(e => {
                    console.log(e);
                    this.saving = false;
                    this.$message.error(e.error);
                });
        },
        onDelete() {
            this.$alert('删除将无法恢复，确认要删除么？', '警告', { type: 'error' })
                .then(() => {
                    return this.$http.post(`/rateAudit/del/${this.formData.id}`);
                })
                .then(() => {
                    this.$message.success('删除成功');
                    this.$router.go(-1);
                })
                .catch(e => {
                    if (e !== 'cancel') {
                        console.log(e);
                        this.$message.error((e || {}).error || '删除失败');
                    }
                });
        }
    }
};
</script>
<style lang="less" scoped>
.edit-view {
    height: 680px;
}
.div-style {
    margin-bottom: 10px;
}
/deep/ .el-input.is-disabled .el-input__inner {
    background-color: #ffffff;
    color: #606266;
}
.tishi {
    margin: 0 0 4px 40px;
    color: #606266;
    font-size: 14px;
}
</style>
