<template>
    <div style="overflow-y: auto;">
        <div class="common-card">
            <h3>审批进度</h3>
            <yl-step></yl-step>
        </div>
        <div class="common-card">
            <h3>调价信息</h3>
            <el-form :model="listForm" ref="listform" label-width="237px" class="grid-form-class">
            <div class="form-body">
            <div class="flex-css">
                <el-form-item label="申请单号" prop="aa">
                    <div class="content">
                        {{ listForm.aa }}
                    </div>
                </el-form-item>
                <el-form-item label="药品编码" prop="bb">
                    <div class="content">
                        {{ listForm.bb }}
                    </div>
                </el-form-item>
                <el-form-item label="药品名称" prop="cc">
                    <div class="content">
                        {{ listForm.cc }}
                    </div>
                </el-form-item>
            </div>
            <div class="flex-css">
                <el-form-item label="剂型" prop="dd">
                    <div class="content">
                        {{ listForm.dd }}
                    </div>
                </el-form-item>
                <el-form-item label="包装单位" prop="ee">
                    <div class="content">
                        {{ listForm.ee }}
                    </div>
                </el-form-item>
                <el-form-item label="生产企业" prop="ff">
                    <div class="content">
                        {{ listForm.ff }}
                    </div>
                </el-form-item>
            </div>
            <div class="flex-css">
                <el-form-item label="当前价格" prop="ii">
                    <div class="content">
                        {{ listForm.ii }}
                    </div>
                </el-form-item>
                <el-form-item label="调整后价格" prop="gg">
                    <div class="content">
                        {{ listForm.gg }}
                    </div>
                </el-form-item>
                <el-form-item label="申请原因" prop="hh">
                    <div class="content">
                        {{ listForm.hh }}
                    </div>
                </el-form-item>
            </div>
            </div>
            </el-form>
            <div class="foot-button" style="margin:200px 0 20px" v-if="isShow">
                <el-button type="primary" @click="handlePass" :loading="ppLoad">通过</el-button>
                <el-button type="danger" @click="handleNoPass" :loading="nnLoad">驳回</el-button>
            </div>
        </div>
    </div>
</template>

<script>
import ylStep from "@/components/yl-step";
import { apprPricChg } from "@/api/approve/index"
import { getGrpListByPage } from "@/api/consumCataManage-sup/index";
    export default {
        components:{
            ylStep
        },
        data() {
            return {
                listForm: {
                    aa: "信息",
                    bb: "信息",
                    cc: "信息",
                    dd: "信息",
                    ee: "信息",
                    ff: "信息",
                    gg: "信息",
                    hh: "信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息信息",
                    ii: "信息",
                },
                ppLoad: false,
                nnLoad: false,
                isShow: false,
                reason: "",
            }
        },
        created () {
            if(this.$route.query.stas == "待审核"){
                this.isShow = true;
            }else{
                this.isShow = false;
            }
        },
        mounted () {
            this.getData();
        },
        methods: {
            getData(){
                // getGrpListByPage({id: this.$route.query.id}).then((res) => {
                // }).catch((err) => {
                // });
            },
            // 通过
            handlePass() {
                this.$confirm("确认通过", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning"
                }).then(() => {
                    this.ppLoad = true;
                    let data = {
                        apprStas: "Y",
                        adjmprcId: [],
                    }
                    data.adjmprcId.push(this.$route.query.sourceId);
                    apprPricChg(data).then((res) => {
                        this.ppLoad = false;
                        this.$router.push('approveA')
                    })
                    .catch((err) => {
                        this.ppLoad = false;
                    });
                })
            },
            // 驳回
            handleNoPass() {
                this.$prompt("请输入驳回原因", "提示", {
                    confirmButtonText: "确定",
                    cancelButtonText: "取消",
                    type: "warning",
                    inputValidator: (value) => {
                    if (!value) {
                        return "驳回原因不能为空";
                    } else {
                        this.reason = value;
                    }
                    },
                }).then(() => {
                    this.nnLoad = true;
                    let data = {
                        apprStas: "R",
                        adjmprcId: [],
                        reason: this.reason
                    }
                    data.adjmprcId.push(this.$route.query.sourceId);
                    apprPricChg(data).then((res) => {
                        this.nnLoad = false;
                        this.$router.push('approveA')
                    })
                    .catch((err) => {
                        this.nnLoad = false;
                    });
                })
            }
        },
    }
</script>

<style lang="scss" scoped>

</style>@/api/consumCataManage-sup/index