<template>
    <div>
        <el-form
            :model="inputQuery"
            :rules="rules"
            ref="inputQuery"
            label-width="100px"
        >
            <el-card class="el-card">
                <div style="display: flex">
                    <!--                    <el-button-->
                    <!--                        type="primary"-->
                    <!--                        size="small"-->
                    <!--                        icon="search"-->
                    <!--                        style="margin: 0 100px 20px 0; width: 100px"-->
                    <!--                        @click="submitUpload()"-->
                    <!--                    >保存-->
                    <!--                    </el-button-->
                    <!--                    >-->
                    <el-button
                        :disabled="(
                         inputQuery.auditStatus === '4' ||
                         inputQuery.auditStatus === '5' ||
                         inputQuery.auditStatus === '1' ||
                         inputQuery.auditStatus === '6'
                         ) || companyEditDisabled"
                        type="primary"
                        size="small"
                        icon="search"
                        style="margin: 0 10px 20px 0; width: 100px"
                        @click="companySaveSubmit('inputQuery')"
                    >保存
                    </el-button
                    >
                    <el-button
                        :disabled="
                         inputQuery.auditStatus === '4' ||
                         inputQuery.auditStatus === '5' ||
                         inputQuery.auditStatus === '1' ||
                         inputQuery.auditStatus === '6'"
                        type="primary"
                        size="small"
                        icon="search"
                        style="margin: 0 10px 20px 0; width: 100px"
                        @click="editSwitch()"
                    >{{ companyEditButtonStr }}
                    </el-button
                    >
                    <el-button
                        :disabled="
                         inputQuery.auditStatus === '4' ||
                         inputQuery.auditStatus === '5' ||
                         inputQuery.auditStatus === '1' ||
                         inputQuery.auditStatus === '6'"
                        type="primary"
                        size="small"
                        icon="search"
                        style="margin: 0 10px 20px 0; width: 100px"
                        @click="onModifySubmit('inputQuery')"
                    >提交
                    </el-button
                    >
                    <el-button
                        :disabled="inputQuery.auditStatus !== '5' && inputQuery.auditStatus !== '1'"
                        type="primary"
                        size="small"
                        icon="search"
                        style="margin: 0 10px 20px 0; width: 100px"
                        @click="applyUpdate()"
                    >申请变更
                    </el-button
                    >
                </div>
                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="企业名称:" label-width="150px" prop="companyName">
                            <el-input
                                size="small"
                                splaceholder="请输入内容"
                                v-model="inputQuery.companyName"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="统一社会信用代码:" label-width="150px" prop="creditNum">
                            <el-input
                                size="small"
                                splaceholder="请输入内容"
                                v-model="inputQuery.creditNum"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <!--                    <el-col :span="20" class="el-col">-->
                    <!--                        <div class="text item">-->
                    <!--                            <div class="itemTag">-->
                    <!--                                <span>地址:&nbsp;</span> &lt;!&ndash;住所地址&ndash;&gt;-->
                    <!--                            </div>-->
                    <!--                            <el-form-item prop="area">-->
                    <!--                                <el-input-->
                    <!--                                    style="width: 80%"-->
                    <!--                                    size="small"-->
                    <!--                                    splaceholder="请输入内容"-->
                    <!--                                    v-model="inputQuery.area"-->
                    <!--                                ></el-input>-->
                    <!--                            </el-form-item>-->
                    <!--                        </div>-->
                    <!--                    </el-col>-->

                    <!--<el-col :span="20" class="el-col">-->
                    <!--<div class="text item">-->
                    <!--<div class="itemTag">-->
                    <!--<span>生产地址:&nbsp;</span>-->
                    <!--</div>-->
                    <!--<el-form-item prop="productAddr">-->
                    <!--<el-input-->
                    <!--style="width: 80%"-->
                    <!--size="small"-->
                    <!--splaceholder="请输入内容"-->
                    <!--v-model="inputQuery.productAddr"-->
                    <!--&gt;</el-input>-->
                    <!--</el-form-item>-->
                    <!--</div>-->
                    <!--</el-col>-->
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="企业类别:" label-width="150px" prop="classes">
                            <el-select
                                :disabled="true"
                                size="small"
                                v-model="inputQuery.classes"
                                placeholder="企业类别"
                                style="width: 100%;"
                            >
                                <el-option v-if="classesDisplay" label="医院" value="1"></el-option>
                                <el-option label="经营企业" value="2"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="所属地区:" label-width="150px" prop="area">
                            <el-cascader
                                size="small"
                                :options="options"
                                v-model="selectedOptions"
                                placeholder="请选择所属地区"
                                style="width: 100%"
                                @change="handleChange"
                                :disabled="companyEditDisabled"
                            >
                            </el-cascader>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="联系人:" label-width="150px" prop="contacts">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.contacts"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="详细地址:" label-width="150px" prop="detailAddr">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.detailAddr"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="联系电话:" label-width="150px" prop="mobile">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.mobile"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="邮箱:" label-width="150px" prop="email">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.email"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="证件类型:" label-width="150px" prop="contactsPapersType">
                            <el-select
                                size="small"
                                v-model="inputQuery.contactsPapersType"
                                placeholder="证件类型"
                                style="width: 100%;"
                                :disabled="companyEditDisabled"
                            >
                                <el-option label="身份证" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="证件号码:" label-width="150px" prop="contactsPapersCode">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.contactsPapersCode"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="登记状态:" label-width="150px" prop="registerStatus">
                            <el-select
                                size="small"
                                v-model="inputQuery.registerStatus"
                                placeholder="登记状态"
                                style="width: 100%;"
                                :disabled="companyEditDisabled"
                            >
                                <el-option label="续存（在营，开业，在册）" value="1"></el-option>
                                <el-option label="吊销" value="2"></el-option>
                                <el-option label="注销" value="3"></el-option>
                                <el-option label="迁出" value="4"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="经营许可证号:" label-width="150px" prop="jyxkzh">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.jyxkzh"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="经营许可证发证机关:" label-width="150px" prop="jyxkzfzjg">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.jyxkzfzjg"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="经营许可证有效期至:" label-width="150px" prop="jyxkzyxq">
                            <el-date-picker
                                style="width: 100%"
                                v-model="inputQuery.jyxkzyxq"
                                type="date"
                                placeholder="选择日期"
                                :disabled="companyEditDisabled"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="经营备案凭证号:" label-width="150px" prop="jybapzh">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.jybapzh"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="经营备案部门:" label-width="150px" prop="jybabm">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.jybabm"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="发证日期:" label-width="150px" prop="fzrq">
                            <el-date-picker
                                style="width: 100%"
                                v-model="inputQuery.fzrq"
                                type="date"
                                placeholder="选择日期"
                                :disabled="companyEditDisabled"
                            >
                            </el-date-picker>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="税号:" label-width="150px" prop="suihao">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.suihao"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" class="el-row" type="flex" style="margin-top: -10px">
                    <el-col :span="10" class="el-col">
                        <el-form-item label="开户行:" label-width="150px" prop="kaihuhang">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.kaihuhang"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" class="el-col">
                        <el-form-item label="开户账号:" label-width="150px" prop="kaihuzhanghao">
                            <el-input
                                size="small"
                                placeholder="请输入内容"
                                v-model="inputQuery.kaihuzhanghao"
                                @input="change()"
                                :disabled="companyEditDisabled"
                            ></el-input>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20">
                    <el-col :span="10">
                        <el-form-item label="营业执照电子档案:" label-width="150px">
                            <el-upload
                                class="upload-demo"
                                ref="upload"
                                :action="this.uploadUrl"
                                :on-preview="uploadHandlePreview"
                                :on-remove="uploadHandleRemove"
                                :limit="1"
                                :on-exceed="uploadHandleExceed"
                                accept=".jpg,.png"
                                :on-change="uploadOnchange"
                                :on-success="uploadHandleSuccess"
                                :on-error="uploadHandleError"
                                :file-list="fileList"
                                :data="{type:'image1'}"
                                :auto-upload="true"
                                :show-file-list="false"
                                :headers="headers"
                            >
                                <div>
                                    <el-button slot="trigger" size="small" type="primary"
                                               :disabled="companyEditDisabled">选取文件
                                    </el-button>
                                    <el-button
                                        :disabled="inputQuery.filePath === null || inputQuery.filePath === ''"
                                        @click.native="openFile(inputQuery.filePath)"
                                        size="small" type="primary">查看文件
                                    </el-button>
                                </div>
                                <!--                                <div slot="tip" class="el-upload__tip">只能上传 .jpg,.png 文件，且不超过 2 MB</div>-->
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="经营许可证电子档案:" label-width="150px">
                            <el-upload
                                class="upload-demo"
                                ref="upload2"
                                :action="this.uploadUrl"
                                :on-preview="uploadHandlePreview"
                                :on-remove="uploadHandleRemove"
                                :limit="1"
                                :on-exceed="uploadHandleExceed"
                                accept=".jpg,.png"
                                :on-change="uploadOnchange"
                                :on-success="uploadHandleSuccess2"
                                :on-error="uploadHandleError"
                                :file-list="fileList2"
                                :data="{type:'image1'}"
                                :auto-upload="true"
                                :show-file-list="false"
                                :headers="headers"
                            >
                                <div>
                                    <el-button slot="trigger" size="small" type="primary"
                                               :disabled="companyEditDisabled">选取文件
                                    </el-button>
                                    <el-button
                                        :disabled="inputQuery.filePath2 === null || inputQuery.filePath2 === ''"
                                        @click.native="openFile(inputQuery.filePath2)"
                                        size="small" type="primary">查看文件
                                    </el-button>
                                </div>
                                <!--                                <div slot="tip" class="el-upload__tip">只能上传 .jpg,.png 文件，且不超过 2 MB</div>-->
                            </el-upload>
                        </el-form-item>
                    </el-col>
                </el-row>

                <el-row :gutter="20" style="margin-top: -10px">
                    <el-col :span="10">
                        <el-form-item label="经营备案证电子档案:" label-width="150px">
                            <el-upload
                                class="upload-demo"
                                ref="upload3"
                                :action="this.uploadUrl"
                                :on-preview="uploadHandlePreview"
                                :on-remove="uploadHandleRemove"
                                :limit="1"
                                :on-exceed="uploadHandleExceed"
                                accept=".jpg,.png"
                                :on-change="uploadOnchange"
                                :on-success="uploadHandleSuccess3"
                                :on-error="uploadHandleError"
                                :file-list="fileList3"
                                :data="{type:'image1'}"
                                :auto-upload="true"
                                :show-file-list="false"
                                :headers="headers"
                            >
                                <div>
                                    <el-button slot="trigger" size="small" type="primary"
                                               :disabled="companyEditDisabled">选取文件
                                    </el-button>
                                    <el-button
                                        :disabled="inputQuery.filePath3 === null || inputQuery.filePath3 === ''"
                                        @click.native="openFile(inputQuery.filePath3)"
                                        size="small" type="primary">查看文件
                                    </el-button>
                                </div>
                                <!--                                <div slot="tip" class="el-upload__tip">只能上传 .jpg,.png 文件，且不超过 2 MB</div>-->
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10">
                        <el-form-item label="开户行电子档案:" label-width="150px">
                            <el-upload
                                class="upload-demo"
                                ref="upload4"
                                :action="this.uploadUrl"
                                :on-preview="uploadHandlePreview"
                                :on-remove="uploadHandleRemove"
                                :limit="1"
                                :on-exceed="uploadHandleExceed"
                                accept=".jpg,.png"
                                :on-change="uploadOnchange"
                                :on-success="uploadHandleSuccess4"
                                :on-error="uploadHandleError"
                                :file-list="fileList4"
                                :data="{type:'image1'}"
                                :auto-upload="true"
                                :show-file-list="false"
                                :headers="headers"
                            >
                                <div>
                                    <el-button slot="trigger" size="small" type="primary"
                                               :disabled="companyEditDisabled">选取文件
                                    </el-button>
                                    <el-button
                                        :disabled="inputQuery.filePath4 === null || inputQuery.filePath4 === ''"
                                        @click.native="openFile(inputQuery.filePath4)"
                                        size="small" type="primary">查看文件
                                    </el-button>
                                </div>
                                <!--                                <div slot="tip" class="el-upload__tip">只能上传 .jpg,.png 文件，且不超过 2 MB</div>-->
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="10" style="margin-top: -10px">
                        <el-form-item label="" label-width="150px">
                            <div>只能上传 .jpg,.png 文件，且不超过 2 MB</div>
                        </el-form-item>
                    </el-col>
                </el-row>


                <!--                <div style="display: flex">-->
                <!--                    <el-button-->
                <!--                        type="primary"-->
                <!--                        size="small"-->
                <!--                        icon="search"-->
                <!--                        @click="addCert()"-->
                <!--                    >添加电子档-->
                <!--                    </el-button-->
                <!--                    >-->
                <!--                </div>-->
                <!--                <el-table v-loading="certLoading"-->
                <!--                          :data="certList"-->
                <!--                          style="width: 100%">-->
                <!--                    <el-table-column type="index" label="序号" width="50"></el-table-column>-->
                <!--                    <el-table-column label="电子档名称" prop="name"></el-table-column>-->
                <!--                    <el-table-column label="备注" prop="remark"></el-table-column>-->
                <!--                    <el-table-column label="时间" prop="create_time" show-overflow-tooltip>-->
                <!--                        <template slot-scope="scope">-->
                <!--                            <i class="el-icon-time"></i>-->
                <!--                            <span>{{ scope.row.create_time }}</span>-->
                <!--                        </template>-->
                <!--                    </el-table-column>-->

                <!--                    <el-table-column label="操作" fixed="right" width="250">-->
                <!--                        <template slot-scope="scope">-->
                <!--                            <el-button-->
                <!--                                type="text"-->
                <!--                                size="small"-->
                <!--                                @click.native="toViewCompanyCert(scope.row)"-->
                <!--                            >查看文件-->
                <!--                            </el-button-->
                <!--                            >-->
                <!--                            <el-button-->
                <!--                                type="text"-->
                <!--                                size="small"-->
                <!--                                @click.native="deleteCompanyCert(scope.row)"-->
                <!--                            >删除-->
                <!--                            </el-button-->
                <!--                            >-->
                <!--                        </template>-->
                <!--                    </el-table-column>-->
                <!--                </el-table>-->
                <!--                <el-pagination-->
                <!--                    :page-size="certQuery.limit"-->
                <!--                    @current-change="certHandleCurrentChange"-->
                <!--                    layout="prev, pager, next"-->
                <!--                    :total="certTotal"-->
                <!--                >-->
                <!--                </el-pagination>-->
            </el-card>

            <!--            <el-card class="el-card">-->
            <!--                <el-form :inline="true" :model="productQuery" class="query-form" size="mini">-->
            <!--                    <el-row style="width: 100%">-->
            <!--                        <el-form-item class="query-form-item">-->
            <!--                            <el-input-->
            <!--                                v-model="productQuery.cpmctymc"-->
            <!--                                placeholder="产品名称"-->
            <!--                            ></el-input>-->
            <!--                        </el-form-item>-->
            <!--                        <el-form-item class="query-form-item">-->
            <!--                            <el-input-->
            <!--                                v-model="productQuery.ggxh"-->
            <!--                                placeholder="规格型号"-->
            <!--                            ></el-input>-->
            <!--                        </el-form-item>-->
            <!--                        <el-form-item class="query-form-item">-->
            <!--                            <el-input-->
            <!--                                v-model="productQuery.ylqxzcrbarmc"-->
            <!--                                placeholder="生产厂家"-->
            <!--                            ></el-input>-->
            <!--                        </el-form-item>-->

            <!--                        <el-form-item>-->
            <!--                            <el-button-group>-->
            <!--                                <el-button-->
            <!--                                    type="primary"-->
            <!--                                    icon="el-icon-refresh"-->
            <!--                                    @click="productOnReset"-->
            <!--                                ></el-button>-->
            <!--                                <el-button type="primary" icon="search" @click="productOnSubmit"-->
            <!--                                >查询-->
            <!--                                </el-button-->
            <!--                                >-->
            <!--                                <el-button-->
            <!--                                    type="primary"-->
            <!--                                    icon="search"-->
            <!--                                    @click="selectProduct()"-->
            <!--                                >选择产品-->
            <!--                                </el-button-->
            <!--                                >-->
            <!--                            </el-button-group>-->
            <!--                        </el-form-item>-->

            <!--                        <el-form-item style="margin: 0 100px 0 auto;">-->
            <!--                            <el-button-group>-->
            <!--                            </el-button-group>-->
            <!--                        </el-form-item>-->
            <!--                    </el-row>-->
            <!--                </el-form>-->

            <!--                <el-table v-loading="productLoading"-->
            <!--                          :data="productList"-->
            <!--                          style="width: 100%">-->
            <!--                    <el-table-column type="index" label="序号" width="50"></el-table-column>-->
            <!--                    <el-table-column label="产品名称" prop="cpmctymc"></el-table-column>-->
            <!--                    <el-table-column label="规格型号" prop="ggxh"></el-table-column>-->
            <!--                    <el-table-column label="批准文号" prop="zczbhhzbapzbh"></el-table-column>-->
            <!--                    <el-table-column label="生产厂家" prop="ylqxzcrbarmc"></el-table-column>-->
            <!--                    <el-table-column label="操作" fixed="right" width="250">-->
            <!--                        <template slot-scope="scope">-->
            <!--                            <el-button-->
            <!--                                type="text"-->
            <!--                                size="small"-->
            <!--                                @click.native="selectProduct(scope.row)"-->
            <!--                            >详情-->
            <!--                            </el-button-->
            <!--                            >-->
            <!--                            <el-button-->
            <!--                                type="text"-->
            <!--                                size="small"-->
            <!--                                @click.native="deleteCompanyProductRelevance(scope.row)"-->
            <!--                            >删除-->
            <!--                            </el-button-->
            <!--                            >-->
            <!--                        </template>-->
            <!--                    </el-table-column>-->
            <!--                </el-table>-->
            <!--                <el-pagination-->
            <!--                    :page-size="productQuery.limit"-->
            <!--                    @current-change="salesmanHandleCurrentChange"-->
            <!--                    layout="prev, pager, next"-->
            <!--                    :total="productTotal"-->
            <!--                >-->
            <!--                </el-pagination>-->
            <!--            </el-card>-->

            <el-card class="el-card">
                <el-form :inline="true" :model="salesmanQuery" class="query-form" size="mini">
                    <el-row style="width: 100%">
                        <el-form-item class="query-form-item">
                            <el-input
                                v-model="salesmanQuery.name"
                                placeholder="业务员姓名"
                            ></el-input>
                        </el-form-item>

                        <el-form-item>
                            <el-button-group>
                                <el-button
                                    type="primary"
                                    icon="el-icon-refresh"
                                    @click="salesmanOnReset"
                                ></el-button>
                                <el-button type="primary" icon="search" @click="salesmanOnSubmit"
                                >查询
                                </el-button
                                >
                                <el-button
                                    type="primary"
                                    icon="search"
                                    @click="addSalesman()"
                                >新增
                                </el-button
                                >
                            </el-button-group>
                        </el-form-item>

                        <el-form-item style="margin: 0 100px 0 auto;">
                            <el-button-group>
                            </el-button-group>
                        </el-form-item>
                    </el-row>
                </el-form>

                <el-table v-loading="salesmanLoading"
                          :data="salesmanList"
                          style="width: 100%">
                    <el-table-column type="index" label="序号" width="50"></el-table-column>
                    <el-table-column label="姓名" prop="name"></el-table-column>
                    <el-table-column label="电话" prop="tel"></el-table-column>
                    <el-table-column label="手机" prop="phone"></el-table-column>
                    <el-table-column label="邮箱" prop="email"></el-table-column>
                    <el-table-column label="证件类型" prop="certType" width="120">
                        <template slot-scope="scope">
                            <span>{{ certTypeMap[scope.row.certType] }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="审核状态" prop="auditStatus" width="120">
                        <template slot-scope="scope">
                            <span>{{ auditStatusMap[scope.row.auditStatus] }}</span>
                        </template>
                    </el-table-column>
                    <el-table-column label="证件号" prop="certCode"></el-table-column>
                    <el-table-column label="操作" fixed="right" width="250">
                        <template slot-scope="scope">
                            <el-button
                                :disabled="scope.row.auditStatus === '1'
                                && scope.row.auditStatus === '4'
                                && scope.row.auditStatus === '5'"
                                type="text"
                                size="small"
                                @click.native="addSalesman(scope.row)"
                            >详情
                            </el-button
                            >
                            <!--                            <el-button-->
                            <!--                                :disabled="scope.row.auditStatus !== '1'"-->
                            <!--                                type="text"-->
                            <!--                                size="small"-->
                            <!--                                @click.native="applyAudit(scope.row)"-->
                            <!--                            >申请反审-->
                            <!--                            </el-button-->
                            <!--                            >-->
                            <el-button
                                :disabled="scope.row.auditStatus !== '0' ||
                                  scope.row.auditStatus !== '2' ||
                                  scope.row.auditStatus !== '3'"
                                type="text"
                                size="small"
                                @click.native="deleteCompanySalesman(scope.row)"
                            >删除
                            </el-button
                            >
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                    :page-size="salesmanQuery.limit"
                    @current-change="salesmanHandleCurrentChange"
                    layout="prev, pager, next"
                    :total="salesmanTotal"
                    :current-page="salesmanQuery.page"
                >
                </el-pagination>
            </el-card>

            <el-dialog
                title="添加电子档"
                :visible.sync="addCertVisible"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                width="70%"
                v-if="addCertVisible"
                @close='closeDialog'
            >
                <companyAddCert
                    :closeDialog="closeDialog"
                    :idQuery="idQuery"
                ></companyAddCert>
            </el-dialog>

            <el-dialog
                title="添加业务员"
                :visible.sync="addSalesmanVisible"
                width="70%"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                v-if="addSalesmanVisible"
                @close='closeDialog'
            >
                <companyAddSalesman
                    :closeDialog="closeDialog"
                    :idQuery="idQuery"
                ></companyAddSalesman>
            </el-dialog>

            <el-dialog
                title="申请变更"
                :visible.sync="companyApplyUpdateVisible"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                width="70%"
                v-if="companyApplyUpdateVisible"
                @close='closeDialog'
            >
                <companyApplyUpdate
                    :closeDialog="closeDialog"
                    :idQuery="idQuery"
                ></companyApplyUpdate>
            </el-dialog>

            <el-dialog
                title="医疗器械信息"
                :visible.sync="selectLocalVisible"
                :close-on-click-modal="false"
                :close-on-press-escape="false"
                width="85%"
                v-if="selectLocalVisible"
            >
                <selectProduct
                    :closeDialog="closeDialog"
                    :uuid="uuid"
                ></selectProduct>
            </el-dialog>

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

<script>
import {getCompany, modifyCompany} from "../../api/warehouse/company";
import store from "../../store/index";
import {
    provinceAndCityData,
    regionData,
    provinceAndCityDataPlus,
    regionDataPlus,
    CodeToText,
    TextToCode,
} from "element-china-area-data";
import {BASE_URL} from "../../config/app";
import {filterCompanyCert, deleteCompanyCert} from "../../api/warehouse/companyCert";
import {filterCompanySalesman, deleteCompanySalesman} from "../../api/warehouse/companySalesman";
import {
    deleteCompanyProductRelevance,
    filterCompanyProductRelevance
} from "../../api/warehouse/companyProductRelevance";
import companyAddCert from "../warehouse/companyAddCert";
import companyAddSalesman from "../warehouse/companyAddSalesman";
import selectProduct from "../warehouse/selectProduct";
import companyApplyUpdate from "../warehouse/companyApplyUpdate";
import draggable from "vuedraggable";
import {deleteCodesTempById} from "../../api/warehouse/order";
import {getBasicInstrumentMaintainRelevances} from "../../api/basic/basicInstrumentMaintainRelevance";
import {insertCompanySalesmanUpdateLog} from "../../api/warehouse/companySalesmanUpdateLog";
import {addCompanyUpdateLog} from "../../api/warehouse/companyUpdateLog";

export default {
    data() {
        return {
            inputQuery: {
                cpmpanyName: null,
                category: "",
                creditNum: "",
                area: "",
                classes: "",
                appId: "",
                appSecret: "",
                contact: "",
                mobile: "",
                email: "",
                customerId: store.getters.customerId,
                filePath: "",
                filePath2: "",
                filePath3: "",
                filePath4: "",
            },
            headers: {},
            classesDisplay: false,
            selectedOptions: [],
            options: regionDataPlus,
            rules: {
                companyName: [
                    {
                        required: true,
                        message: "请输入企业名称",
                        trigger: "blur"
                    }
                ],
                creditNum: [
                    {
                        required: true,
                        message: "请输入统一社会信用代码",
                        trigger: "blur"
                    }
                ],
                classes: [
                    {
                        required: true,
                        message: "请选择企业类别",
                        trigger: "change"
                    }
                ],
                area: [
                    {
                        required: true,
                        message: "请选择所属地区",
                        trigger: "change"
                    }
                ],
                detailAddr: [
                    {
                        required: true,
                        message: "请输入详细地址",
                        trigger: "change"
                    }
                ],
                contacts: [
                    {
                        required: true,
                        message: "请输入联系人",
                        trigger: "change"
                    }
                ],
                mobile: [
                    {
                        required: true,
                        message: "请输入联系电话",
                        trigger: "change"
                    }
                ],
                email: [
                    {
                        required: true,
                        message: "请输入邮箱",
                        trigger: "change"
                    }
                ],
                updateCause: [
                    {
                        required: true,
                        message: "请输入变更原因",
                        trigger: "change"
                    }
                ],
            },
            uploadUrl: "",
            fileList: [],
            fileList2: [],
            fileList3: [],
            fileList4: [],
            fileUrl: "",
            certFileUrl: "",
            url: 'http://127.0.0.1:9996/udiwms/image/register/file/getImage?type=image1&name=t11111.jpg',
            certQuery: {
                page: 1,
                limit: 20
            },
            certList: [],
            certTotal: 0,
            certLoading: false,
            addCertVisible: false,
            idQuery: {
                id: "",
            },
            salesmanQuery: {
                name: "",
                page: 1,
                limit: 20
            },
            salesmanList: [],
            salesmanTotal: 0,
            salesmanLoading: false,
            addSalesmanVisible: false,
            certTypeMap: {
                1: '身份证'
            },
            auditStatusMap: {
                1: '通过',
                2: '不通过',
                3: '反审',
                4: '申请反审',
                5: '拒绝反审',
            },
            selectLocalVisible: false,
            productQuery: {
                ylqxzcrbarmc: "",
                cpmctymc: "",
                ggxh: "",
                page: 1,
                limit: 20
            },
            productList: [],
            productTotal: 0,
            productLoading: false,
            uuid: null,
            companyApplyUpdateVisible: false,
            companyEditDisabled: true,
            companyEditButtonStr: "编辑",
        };
    },
    created() {
        this.getData();
        // this.getCompanyCertList();
        // this.getProductRelevanceList();
        this.getCompanySalesmanList();
        if (store.getters.customerId === 110) {
            this.classesDisplay = true;
        }
        this.uploadUrl = BASE_URL + "/udiwms/upload/register/file";
        this.fileUrl = BASE_URL + "/udiwms/image/register/file/getImage?type=image1&name=";
        this.certFileUrl = BASE_URL + "/udiwms/image/register/file/getImage?type=image2&name=";

        this.headers = {
            ADMIN_ID: store.getters.adminId,
            ADMIN_TOKEN: store.getters.token,
        };
    },
    components: {
        draggable,
        companyAddCert,
        companyAddSalesman,
        selectProduct,
        companyApplyUpdate,
    },
    methods: {
        submitUpload() {
            this.$refs["inputQuery"].validate(valid => {
                if (valid) {
                    if (this.$refs.upload.uploadFiles.length > 0) {
                        this.$refs.upload.submit();
                    } else if (this.$refs.upload2.uploadFiles.length > 0) {
                        this.$refs.upload2.submit();
                    } else if (this.$refs.upload3.uploadFiles.length > 0) {
                        this.$refs.upload3.submit();
                    } else if (this.$refs.upload4.uploadFiles.length > 0) {
                        this.$refs.upload4.submit();
                    } else {
                        this.onModifySubmit('inputQuery');
                    }
                }
            });
        },
        companySaveSubmit(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$confirm("是否保存变更?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    }).then(() => {
                        this.loading = true;
                        this.inputQuery.customerId = store.getters.customerId;
                        this.inputQuery.newAuditStatus = '0';
                        modifyCompany(this.inputQuery).then(response => {
                            this.loading = false;
                            if (response.code === 20000) {
                                this.$message.success("保存成功");
                            }
                            this.getData();
                            this.companyEditDisabled = true;
                            this.companyEditButtonStr = "编辑";
                        });
                    }).catch(() => {
                    });
                } else {
                    return false;
                }
            });
        },
        onModifySubmit(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$confirm("是否提交变更?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    }).then(() => {
                        this.loading = true;
                        this.inputQuery.customerId = store.getters.customerId;
                        this.inputQuery.newAuditStatus = '6';
                        modifyCompany(this.inputQuery).then(response => {
                            this.loading = false;
                            if (response.code === 20000) {
                                this.$message.success("提交成功");
                            }
                            this.getData();
                            this.companyEditDisabled = true;
                            this.companyEditButtonStr = "编辑";
                        });
                    }).catch(() => {
                    });
                } else {
                    return false;
                }
            });
        },
        editSwitch() {
            if (this.companyEditDisabled) {
                this.companyEditDisabled = false;
                this.companyEditButtonStr = "取消编辑";
            } else {
                this.companyEditDisabled = true;
                this.companyEditButtonStr = "编辑";
            }
        },
        addUpdateLog(formName) {
            this.$refs[formName].validate(valid => {
                if (valid) {
                    this.$confirm("是否提交变更?", "提示", {
                        confirmButtonText: "确定",
                        cancelButtonText: "取消",
                        type: "warning",
                    }).then(() => {
                        this.loading = true;
                        this.inputQuery.customerId = store.getters.customerId;
                        addCompanyUpdateLog(this.inputQuery).then(response => {
                            this.loading = false;
                            if (response.code === 20000) {
                                this.getData();
                                this.$message.success("提交成功");
                            } else {
                                this.$message.error(response.message);
                            }
                        });
                    }).catch(() => {
                    });
                } else {
                    return false;
                }
            });
        },
        getData() {
            this.loading = true;
            let tquery = {
                customerId: store.getters.customerId,
            };
            getCompany(tquery).then((response) => {
                this.loading = false;
                this.inputQuery = response.data;
                this.inputQuery.bussinessStatus = this.inputQuery.bussinessStatus + "";
                this.selectedOptions = this.inputQuery.areaCode.split(",");
            });
        },
        applyUpdate() {
            this.companyApplyUpdateVisible = true;
        },
        salesmanOnReset() {
            this.salesmanQuery = {
                name: "",
                auditStatus: "",
                page: 1,
                limit: 20
            };
            this.getCompanySalesmanList();
        },
        salesmanOnSubmit() {
            this.getCompanySalesmanList();
        },
        productOnReset() {
            this.productQuery = {
                ylqxzcrbarmc: "",
                cpmctymc: "",
                ggxh: "",
                auditStatus: "",
                page: 1,
                limit: 20
            };
            this.getProductRelevanceList();
        },
        productOnSubmit() {
            this.getProductRelevanceList();
        },
        openFile(path) {
            window.open(this.fileUrl + path);
        },
        selectProduct(row) {
            this.uuid = null;
            if (this.$isNotBlank(row)) {
                this.uuid = row.uuid;
            }
            this.selectLocalVisible = true;
        },
        certHandleCurrentChange(val) {
            this.certQuery.page = val;
            this.getCompanyCertList();
        },
        salesmanHandleCurrentChange(val) {
            this.salesmanQuery.page = val;
            this.getCompanySalesmanList();
        },
        productHandleCurrentChange(val) {
            this.productQuery.page = val;
            this.getProductRelevanceList();
        },
        getCompanyCertList() {
            this.certLoading = true;
            this.certQuery.customerId = store.getters.customerId;
            filterCompanyCert(this.certQuery)
                .then((response) => {
                    this.certLoading = false;
                    this.certList = response.data.list || [];
                })
                .catch(() => {
                    this.certLoading = false;
                    this.certList = [];
                });
        },
        getCompanySalesmanList() {
            this.salesmanLoading = true;
            this.salesmanQuery.customerId = store.getters.customerId;
            filterCompanySalesman(this.salesmanQuery)
                .then((response) => {
                    this.salesmanLoading = false;
                    this.salesmanList = response.data.list || [];
                })
                .catch(() => {
                    this.salesmanLoading = false;
                    this.salesmanList = [];
                });
        },
        getProductRelevanceList() {
            this.erpDisplay = false;
            this.productLoading = true;
            this.productQuery.customerId = store.getters.customerId;
            filterCompanyProductRelevance(this.productQuery)
                .then((response) => {
                    this.productLoading = false;
                    this.productList = response.data.list || [];
                    this.productTotal = response.data.total || 0;
                })
                .catch(() => {
                    this.productLoading = false;
                    this.productList = [];
                    this.productTotal = 0;
                });
        },
        addCert(index, row) {
            this.idQuery.id = '';
            if (this.$isNotBlank(row) && this.$isNotBlank(row.id)) {
                this.idQuery.id = row.id;
                this.idQuery.formData = row;
            }
            this.addCertVisible = true;
        },
        addSalesman(row) {
            this.idQuery.id = '';
            if (this.$isNotBlank(row) && this.$isNotBlank(row.id)) {
                this.idQuery.id = row.id;
                this.idQuery.formData = row;
            }
            this.addSalesmanVisible = true;
        },
        applyAudit(row) {
            this.$confirm("是否提交申请?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {
                this.certLoading = true;
                let tQuery = {
                    salesmanId: row.id,
                    customerId: store.getters.customerId,
                    name: row.name
                };
                insertCompanySalesmanUpdateLog(tQuery)
                    .then((response) => {
                        this.certLoading = false;
                        if (response.code === 20000) {
                            this.getCompanySalesmanList();
                            this.$message({
                                type: "success",
                                message: "提交成功！",
                            });
                        } else {
                            this.$message.error(response.message);
                        }
                    })
                    .catch(() => {
                        this.certLoading = false;
                    });
            }).catch(() => {
            });
        },
        toViewCompanyCert(row) {
            window.open(this.certFileUrl + row.filePath);
        },
        deleteCompanyCert(row) {
            this.$confirm("是否删除?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {
                this.certLoading = true;
                let tquery = {
                    id: row.id,
                    filePath: row.filePath,
                };
                deleteCompanyCert(tquery)
                    .then((response) => {
                        this.certLoading = false;
                        if (response.code === 20000) {
                            this.getCompanyCertList();
                            this.$message({
                                type: "success",
                                message: "删除成功！",
                            });
                        } else {
                            this.$message.error(response.message);
                        }
                    })
                    .catch(() => {
                        this.certLoading = false;
                    });
            }).catch(() => {
            });
        },
        deleteCompanySalesman(row) {
            this.$confirm("是否删除?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {
                this.salesmanLoading = true;
                let tquery = {
                    id: row.id,
                    filePath: row.filePath,
                    filePath2: row.filePath2,
                };
                deleteCompanySalesman(tquery)
                    .then((response) => {
                        this.salesmanLoading = false;
                        if (response.code === 20000) {
                            this.getCompanySalesmanList();
                            this.$message({
                                type: "success",
                                message: "删除成功！",
                            });
                        } else {
                            this.$message.error(response.message);
                        }
                    })
                    .catch(() => {
                        this.salesmanLoading = false;
                    });
            }).catch(() => {
            });
        },
        deleteCompanyProductRelevance(row) {
            this.$confirm("是否删除?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {
                this.productLoading = true;
                let tquery = {
                    id: row.id,
                };
                deleteCompanyProductRelevance(tquery)
                    .then((response) => {
                        this.productLoading = false;
                        if (response.code === 20000) {
                            this.getProductRelevanceList();
                            this.$message({
                                type: "success",
                                message: "删除成功！",
                            });
                        } else {
                            this.$message.error(response.message);
                        }
                    })
                    .catch(() => {
                        this.productLoading = false;
                    });
            }).catch(() => {
            });
        },
        closeDialog(type) {
            this.addCertVisible = false;
            this.addSalesmanVisible = false;
            this.selectLocalVisible = false;
            this.companyApplyUpdateVisible = false;
            this.getData();
            this.getCompanyCertList();
            this.getCompanySalesmanList();
        },
        handleChange(value) {
            this.inputQuery.area =
                CodeToText[value[0]] + CodeToText[value[1]] + CodeToText[value[2]];
            this.inputQuery.areaCode = value.toString();
        },
        uploadHandleRemove(file, fileList) {
        },
        uploadHandlePreview(file) {
        },
        uploadHandleExceed(files, fileList) {
            this.$message.warning(`当前限制选择 1 个文件，本次选择了 ${files.length} 个文件，共选择了 ${files.length + fileList.length} 个文件`);
        },
        uploadOnchange(file, fileList) {
            let fileName = file.name;
            let uid = file.uid
            let pos = fileName.lastIndexOf(".");
            let lastName = fileName.substring(pos, fileName.length);
            if (lastName.toLowerCase() !== ".jpg" && lastName.toLowerCase() !== ".png") {
                this.$message.error("上传文件只能是 .jpg,.png 格式");
                for (let i = 0; i < fileList.length; i++) {//从list删除
                    if (fileList[i].uid === uid) {
                        fileList.splice(i, 1)
                    }
                }
                return;
            }
            // 限制上传文件的大小
            const isLt = file.size / 1024 / 1024 / 2 <= 1;
            if (!isLt) {
                this.$message.error("上传文件大小不能超过 2MB");
                for (let i = 0; i < fileList.length; i++) {
                    if (fileList[i].uid === uid) {
                        fileList.splice(i, 1)
                    }
                }
            }
            return isLt;
        },
        uploadHandleSuccess(response, file, fileList) {
            if (response.code === 20000) {
                this.uploadFilePath('', response.data.name);

                // if (this.$isBlank(this.inputQuery.filePath)) {
                //     this.inputQuery.filePath = response.data.name;
                // } else {
                //     this.inputQuery.newFilePath = response.data.name;
                // }if (this.$refs.upload2.uploadFiles.length > 0) {
                //     this.$refs.upload2.submit();
                // } else if (this.$refs.upload3.uploadFiles.length > 0) {
                //     this.$refs.upload3.submit();
                // } else if (this.$refs.upload4.uploadFiles.length > 0) {
                //     this.$refs.upload4.submit();
                // } else {
                //     this.onModifySubmit('inputQuery');
                // }
            } else {
                this.$message.error("文件上传失败：" + response.message);
            }
        },
        uploadHandleSuccess2(response, file, fileList) {
            if (response.code === 20000) {
                this.uploadFilePath('2', response.data.name);

                // if (this.$isBlank(this.inputQuery.filePath2)) {
                //     this.inputQuery.filePath2 = response.data.name;
                // } else {
                //     this.inputQuery.newFilePath2 = response.data.name;
                // }
                // if (this.$refs.upload3.uploadFiles.length > 0) {
                //     this.$refs.upload3.submit();
                // } else if (this.$refs.upload4.uploadFiles.length > 0) {
                //     this.$refs.upload4.submit();
                // } else {
                //     this.onModifySubmit('inputQuery');
                // }
            } else {
                this.$message.error("文件上传失败：" + response.message);
            }
        },
        uploadHandleSuccess3(response, file, fileList) {
            if (response.code === 20000) {
                this.uploadFilePath('3', response.data.name);

                // if (this.$isBlank(this.inputQuery.filePath3)) {
                //     this.inputQuery.filePath3 = response.data.name;
                // } else {
                //     this.inputQuery.newFilePath3 = response.data.name;
                // }
                // if (this.$refs.upload4.uploadFiles.length > 0) {
                //     this.$refs.upload4.submit();
                // } else {
                //     this.onModifySubmit('inputQuery');
                // }
            } else {
                this.$message.error("文件上传失败：" + response.message);
            }
        },
        uploadHandleSuccess4(response, file, fileList) {
            if (response.code === 20000) {
                this.uploadFilePath('4', response.data.name);

                // if (this.$isBlank(this.inputQuery.filePath4)) {
                //     this.inputQuery.filePath4 = response.data.name;
                // } else {
                //     this.inputQuery.newFilePath4 = response.data.name;
                // }
                // this.onModifySubmit('inputQuery');
            } else {
                this.$message.error("文件上传失败：" + response.message);
            }
        },
        uploadHandleError() {
        },
        deleteFile(num) {
            this.$confirm("是否删除该文件?", "提示", {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning",
            }).then(() => {

            }).catch(() => {
            });
        },
        uploadFilePath(num, fileName) {
            let fileField = 'filePath' + num;
            let newFileField = 'newFilePath' + num;
            this.loading = true;
            let tQuery = {
                customerId: store.getters.customerId,
                // fName: this.inputQuery.filePath,
                // newFilePath: response.data.name,
            };
            tQuery[fileField] = this.inputQuery[fileField];
            tQuery[newFileField] = fileName;
            // tQuery.customerId = store.getters.customerId;
            modifyCompany(tQuery).then(response => {
                this.loading = false;
                if (response.code === 20000) {
                    this.inputQuery[fileField] = fileName;
                    this.fileList = [];
                    this.fileList2 = [];
                    this.fileList3 = [];
                    this.fileList4 = [];
                    this.$message.success("上传成功");
                }
            });
        }
    }
};
</script>
<style>
.itemTag {
    float: left;
    text-align: left;
    margin-top: 10px;
    width: 120px;
}

.text {
    width: 100%;
    font-size: 13px;
    font-family: "Microsoft YaHei";
}

.el-card {
    margin-right: 20px;
    margin-top: 15px;
    /*transition: all .5s;*/
}

.el-row {
    display: flex;
    flex-wrap: wrap;
}

.el-col {
    border-radius: 4px;
    flex-wrap: wrap;
}
</style>
