<template>
    <div class="auditDataModel">
        <el-dialog
                title="企业归属地变更审核"
                :visible.sync="auditData.dialogVisible"
                width="800px"
                center
                :close-on-click-modal="false"
        >
            <el-form :label-width="labelwidthStyle" :rules="rules" ref="auditFormData" :model="auditFormData">
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="企业名称：">
                            <el-input v-model="auditFormData.qymc" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="统一社会信用代码：">
                            <el-input v-model="auditFormData.tyshxydm" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="申请区域：">
                            <el-input v-model="auditFormData.sqqybmmc" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <el-form-item label="申请原因：">
                            <el-input v-model="auditFormData.sqqy" type="textarea" disabled></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="12">
                        <el-form-item label="申请人：">
                            <el-input v-model="auditFormData.sqridmc" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="申请时间：">
                            <el-date-picker v-model="auditFormData.sqsj" disabled type="date" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>

                <h3 style="text-indent: 50px; font-weight: bold">审批:</h3>
                <el-row :gutter="10">
                    <el-col :span="12">
                        <el-form-item label="是否同意：" prop="sfty">
                            <el-radio-group  v-model="auditFormData.sfty">
                                <el-radio :label="1">是</el-radio>
                                <el-radio :label="0">否</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row :gutter="10">
                    <el-col :span="24">
                        <el-form-item label="审批意见：" :prop="auditFormData.sfty == 0 ?'spyj':null">
                            <el-input v-model="auditFormData.spyj" type="textarea"></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="10">
                    <el-col :span="12">
                        <el-form-item label="审批人：">
                            <el-input v-model="auditFormData.spridmc" disabled></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="审批时间：">
                            <el-date-picker v-model="auditFormData.spsj" disabled type="date" value-format="yyyy-MM-dd"></el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="btnSave(1,'auditFormData')" class="iconfont icontijiao"> 提交</el-button>
                <el-button type="primary" @click="btnSave(0,'auditFormData')" class="iconfont iconquxiao"> 取消</el-button>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import { fileApi } from "@/api";
    import {getCompanyInfo} from "@/api/jcxxwh/qyjcxx";
    import { getList,xzqyFun,insertEntitySelective,selectByEntity,updateByEntitySelective } from '@/api/enterpriseInformationBase/index';
    export default {
        props: {
            auditData: Object,
        },
        components: {},
        data() {
            return {
                labelwidthStyle: "150px",
                list: [],
                auditFormData:{
                    sfrgsd:1,
                    tzyy:null,
                    jsr:'',
                    sdsj:'',
                    fileList:[],
                },
                rules:{
                    sfty: [{ required: true, message: '请选择是否同意', trigger: 'change' }],
                    spyj:[{ required: true, message: '请输入审批意见', trigger: 'blur' }],
                },
                fileList:[],
                actionUrl: fileApi + "/file/upload",
            };
        },
        created() {
            this.getInfo(this.auditData.code)
        },
        methods: {
            btnSave(type,formName){
                if(type){
                    this.$refs[formName].validate((valid,dom) => {
                        if (valid) {
                            let params = this.auditFormData
                            updateByEntitySelective(params).then(res => {
                                if (!res) return;
                                this.$message.success('提交成功')
                                this.auditData.dialogVisible = false
                                this.$emit('getList');
                            }).catch()

                        } else {

                        }
                    });
                }else{
                    this.auditData.dialogVisible = false
                }
            },
            getInfo(code){
                let params = {
                    tyshxydm: code
                }
                selectByEntity(params).then(res => {
                    if (!res) return;
                    this.auditFormData = res.data?res.data[0]: {};
                    this.auditFormData.spridmc = sessionStorage.getItem('userName')
                    this.auditFormData.sprid = sessionStorage.getItem('userCode')
                    this.auditFormData.spsj = this.formatDateTimes(new Date())
                }).catch()
            },
            formatDateTimes (date) {
                let y = date.getFullYear();
                let m = date.getMonth() + 1;
                m = m < 10 ? ('0' + m) : m;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                let h = date.getHours();
                h=h < 10 ? ('0' + h) : h;
                let minute = date.getMinutes();
                minute = minute < 10 ? ('0' + minute) : minute;
                let second=date.getSeconds();
                second=second < 10 ? ('0' + second) : second;
                return y + '-' + m + '-' + d + ' ' + h +':'+minute + ':'+second;
            },
            //转时间方法
            formatDateTime (date) {
                let y = date.getFullYear();
                let m = date.getMonth() + 1;
                m = m < 10 ? ('0' + m) : m;
                let d = date.getDate();
                d = d < 10 ? ('0' + d) : d;
                let h = date.getHours();
                h=h < 10 ? ('0' + h) : h;
                let minute = date.getMinutes();
                minute = minute < 10 ? ('0' + minute) : minute;
                let second=date.getSeconds();
                second=second < 10 ? ('0' + second) : second;
                return y + '-' + m + '-' + d;
            },
        },
    };
</script>

<style scoped="scoped">
    .rowBottom{
        margin-bottom: 10px;
    }
</style>
