<template>
    <div>
        <el-form :model="formData" :rules="formRules" ref="dataForm">

            <el-card style="margin-top: -30px">
                <el-button-group style="display: flex">
                    <el-button
                        type="primary"
                        @click.native="submit()"
                        style="margin: 0 60px 10px auto; height: 35px"
                        :loading="loading"
                    >申请变更
                    </el-button
                    >
                </el-button-group>

                <el-row :gutter="20" class="el-row" type="flex">
                    <el-col :span="20" class="el-col">
                        <el-form-item label="变更原因:" label-width="100px" prop="updateCause">
                            <el-input
                                type="textarea"
                                size="small"
                                placeholder="请输入内容"
                                v-model="formData.updateCause"
                                @input="change()"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

            </el-card>
        </el-form>
    </div>
</template>

<script>
import draggable from "vuedraggable";
import {saveAs} from "file-saver";
import {parseTime} from "../../filtres/index";
import store from "../../store";
import {BASE_URL} from "../../config/app";
import {insertCompanySalesman, updateCompanySalesman} from "../../api/warehouse/companySalesman";
import {applyUpdate} from "../../api/warehouse/companyUpdateLog";

export default {
    name: "idQuery",
    props: {
        closeDialog: {
            type: Function,
            required: true,
        },
        idQuery: {
            type: Object,
            required: true,
        },
    },
    data() {
        return {
            code: "",
            formData: {
                certType: "1"
            },
            formRules: {
                updateCause: [
                    {required: true, message: "请输入变更原因", trigger: "blur"}
                ],
            },
            loading: false,
        };
    },
    components: {
        draggable,
    },
    methods: {
        submit() {
            this.$refs['dataForm'].validate(valid => {
                if (valid) {
                    this.$confirm("是否提交申请?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    }).then(() => {
                        this.loading = true;
                        this.formData.customerId = store.getters.customerId;
                        this.formData.submit = store.getters.employeeName;
                        applyUpdate(this.formData).then(response => {
                            this.loading = false;
                            if (response.code === 20000) {
                                this.closeDialog();
                                this.$message.success("提交成功");
                            } else {
                                this.$message.error(response.message);
                            }
                        });
                    }).catch(() => {
                    });
                } else {
                    console.log("error submit!!");
                    return false;
                }
            });
        }
    },
    filters: {},
    mounted() {
        document.body.ondrop = function (event) {
            event.preventDefault();
            event.stopPropagation();
        };
    },
    created() {
        // if (this.$isNotBlank(this.idQuery)) {
        //     this.formData = this.idQuery.formData;
        // }
    },
};
</script>
<style>

.ao-text {
    width: 100%;
    font-size: 13px;
    font-family: "Microsoft YaHei";
    float: right;
    text-align: right;
    margin-top: 10px;
}

</style>



