<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="关键字" prop="searchValue">
            <el-input v-model="queryParams.searchValue" placeholder="请输入员工姓名，编号，手机号" maxlength="20" clearable style="width: 240px"/>
        </el-form-item> 
        <el-form-item label="性别" prop="sex">
            <el-select v-model="queryParams.sex" style="width: 240px" clearable> 
                <el-option label="男" value="0"></el-option>
                <el-option label="女" value="1"></el-option>  
            </el-select>   
        </el-form-item>
        <el-form-item label="岗位" prop="postName">
            <el-input v-model="queryParams.postName" placeholder="请输入员工岗位" maxlength="20" clearable style="width: 240px"/>
        </el-form-item>
        <el-form-item label="人脸状态" prop="faceState">
            <el-select v-model="queryParams.faceState" style="width: 240px" clearable> 
                <el-option label="开启" value="0"></el-option>
                <el-option label="停用" value="1"></el-option>  
            </el-select>   
        </el-form-item>
        <el-form-item label="健康证" prop="healthCertStatus">
            <el-select v-model="queryParams.healthCertStatus" placeholder="健康证状态" style="width: 240px" clearable> 
                <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-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
        >新增</el-button>
      </el-col>  
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="tableListData" height="800">
        <el-table-column label="序号" align="center" width="80" type="index">
        <template slot-scope="scope">
            <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
        </template>
        </el-table-column>
        <el-table-column label="员工编号" align="center" prop="staffNo" :show-overflow-tooltip="true"/>
        <el-table-column label="员工名称" align="center" prop="staffName" :show-overflow-tooltip="true" />
        <el-table-column label="手机号" align="center" prop="mobile" :show-overflow-tooltip="true"/>
        <el-table-column label="性别" align="center" prop="sex" :show-overflow-tooltip="true">
            <template slot-scope="scope">
                <span v-if="scope.row.sex==0">男</span>
                <span v-if="scope.row.sex==1">女</span>
            </template>
        </el-table-column>
        <el-table-column label="岗位名称" align="center" prop="postName" :show-overflow-tooltip="true"/>
        <el-table-column label="员工照片" align="center" prop="faceUrl" :show-overflow-tooltip="true" width="120">
            <template slot-scope="scope">
                <img :src="scope.row.faceUrl" v-if="scope.row.faceUrl" alt="" style="width: 80px;height: 40px;" @click="openImg2(scope.row)">
                <span v-else>无</span>
            </template>
        </el-table-column>
        <el-table-column label="人脸状态" align="center" prop="faceState" :show-overflow-tooltip="true" width="150">
            <template slot-scope="scope">
                <!-- <span v-if="scope.row.faceState==0">开启</span>
                <span v-if="scope.row.faceState==1">关闭</span>  -->
                <el-switch @change="changeSwitch(scope.row)"
                    v-model="scope.row.faceState"
                    :active-value="1" active-text="开启"
                    :inactive-value="2" inactive-text="关闭">
                </el-switch>
            </template>
        </el-table-column>
        <el-table-column label="健康证照片" align="center" prop="healthCertFrontImg" :show-overflow-tooltip="true" width="120">
            <template slot-scope="scope">
                <img :src="scope.row.healthCertFrontImg" v-if="scope.row.healthCertFrontImg" alt="" style="width: 80px;height: 40px;" @click="openImg(scope.row)">
                <span v-else>无</span>
            </template>
        </el-table-column>
        <el-table-column label="出入权限" align="center" prop="" :show-overflow-tooltip="true" width="150">
            <template slot-scope="scope">
                <span style="color: #1890ff;" @click="openAccessAuth(scope.row)">查看</span> 
            </template>
        </el-table-column>
        <el-table-column label="健康证状态" align="center" prop="healthCertStatusName" :show-overflow-tooltip="true" width="150">
            <template slot-scope="scope">
                <div>{{ scope.row.healthCertStatusName }}</div>
                <div>有效期至{{ scope.row.healthCertExpire }}</div> 
            </template>
        </el-table-column>
        <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
        <template slot-scope="scope"> 
            <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)" 
            >编辑</el-button>
            <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)" 
            >删除</el-button>
        </template>
        </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改参数配置对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body> 
        <div style="width: 100%;height: 600px;overflow-y: auto;">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-row>
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            个人信息
                        </div>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="员工名称:" prop="staffName">
                            <el-input v-model="form.staffName"
                                placeholder="请输入员工名称"
                                maxlength="30"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="员工编号:" prop="staffNo">
                            <el-input v-model="form.staffNo"
                                placeholder="请输入员工编号"
                                maxlength="30"
                            />
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="员工性别:" prop="sex">
                            <el-select v-model="form.sex" clearable style="width: 100%;"> 
                                <el-option label="男" :value="0"></el-option>
                                <el-option label="女" :value="1"></el-option>  
                            </el-select>   
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="手机号:" prop="mobile">
                            <el-input v-model="form.mobile" placeholder="请输入手机号" maxlength="11"/>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="关联食堂:" prop="canteenId">
                            <el-select v-model="form.canteenId" style="width: 100%;" placeholder="请选择关联食堂">
                                <el-option
                                    v-for="item in canteenOptions"
                                    :key="item.canteenId"
                                    :label="item.canteenName"
                                    :value="item.canteenId" 
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="岗位名称:" prop="postName">
                            <el-input v-model="form.postName" placeholder="请输入岗位名称" maxlength="20" />
                        </el-form-item>
                    </el-col> 
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            人脸信息
                        </div>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="人脸照片:" prop="faceUrl">
                        <el-upload
                                :http-request="
                                    (obj) => imgUpLoad0(obj, 'fileUrl')
                                "
                                action="#"
                                :limit="1"
                                :file-list="fileList0"
                                :show-file-list="true"
                                list-type="picture-card"
                                accept=".png, .jpg, .jpeg" 
                                :class="{ disabled: uploadDisabled0 }"
                                :before-upload="handleBeforeUpload"
                                :on-preview="handlePictureCardPreview"
                                :on-remove="handleRemove0"
                            >
                                <i
                                    class="el-icon-plus avatar-uploader-icon"
                                ></i>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            健康证信息
                        </div>
                    </el-col>
                    
                    <el-col :span="24">
                        <el-form-item label="健康证到期:" prop="healthCertExpire">
                            <el-date-picker v-model="form.healthCertExpire" type="date" value-format="yyyy-MM-dd" placeholder="选择日期" style="width: 45%;">
                        </el-date-picker> 
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="健康证正面照片:" prop="healthCertFrontImg">
                        <el-upload
                                :http-request="
                                    (obj) => imgUpLoad1(obj, 'fileUrl')
                                "
                                action="#"
                                :limit="1"
                                :file-list="fileList1"
                                :show-file-list="true"
                                list-type="picture-card"
                                accept=".png, .jpg, .jpeg" 
                                :class="{ disabled: uploadDisabled1 }"
                                :before-upload="handleBeforeUpload"
                                :on-preview="handlePictureCardPreview"
                                :on-remove="handleRemove1"
                            >
                                <i
                                    class="el-icon-plus avatar-uploader-icon"
                                ></i>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="健康证反面照片:" prop="healthCertBackImg">
                        <el-upload
                                :http-request="
                                    (obj) => imgUpLoad2(obj, 'fileUrl')
                                "
                                action="#"
                                :limit="1"
                                :file-list="fileList2"
                                :show-file-list="true"
                                list-type="picture-card"
                                accept=".png, .jpg, .jpeg" 
                                :class="{ disabled: uploadDisabled2 }"
                                :before-upload="handleBeforeUpload"
                                :on-preview="handlePictureCardPreview"
                                :on-remove="handleRemove2"
                            >
                                <i
                                    class="el-icon-plus avatar-uploader-icon"
                                ></i>
                            </el-upload>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            出入权限
                        </div>
                    </el-col>
                </el-row>
                <el-row :span="24" v-for="(item,index) in accessAuthorityList" :key="index">
                    <el-col :span="8">
                        <el-form-item label="关联门禁设备:" prop="deviceId">
                            <el-select v-model="item.deviceId" style="width: 100%;" placeholder="请选择关联门禁设备" :loading="loading2" @change="chosenDevice">
                                <el-option
                                    v-for="items in devicesOptions"
                                    :disabled="items.disabled"
                                    :key="items.deviceId"
                                    :label="items.deviceName"
                                    :value="items.deviceId" 
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="设备位置:" prop="location">
                            <el-input v-model="item.location"
                                placeholder="设备位置"
                                maxlength="30" disabled
                            />
                        </el-form-item>
                    </el-col> 
                    <el-col :span="8" style="display: flex;align-items: center;height: 40px;padding-left: 20px;">
                        <el-button
                            type="primary"
                            plain 
                            size="mini" v-if="index==accessAuthorityList.length-1"
                            @click="addDevice"
                            >新增</el-button>
                        <el-button
                            type="info"
                            plain 
                            size="mini" v-if="accessAuthorityList.length>1"
                            @click="delDevice(index)"
                            >删除</el-button>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            留样柜权限
                        </div>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="留样柜权限:" prop="simpleCabinetStatus">
                            <el-switch v-model="simpleCabinetStatus"
                                active-text="开启" inactive-text="关闭"
                                :active-value="1" :inactive-value="2">
                            </el-switch>
                        </el-form-item>
                    </el-col> 
                </el-row>
            </el-form> 
        </div> 
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="cancel">取 消</el-button>
        </div>
    </el-dialog>

    <el-dialog :title="title" :visible.sync="open2" width="900px" append-to-body> 
        <div style="width: 100%;height: 300px;overflow-y: auto;">
            <el-form ref="form" :model="form" :rules="rules" label-width="120px">
                <el-row> 
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            出入权限
                        </div>
                    </el-col>
                </el-row>
                <el-row :span="24" v-for="(item,index) in accessAuthorityList" :key="index">
                    <el-col :span="8">
                        <el-form-item label="关联门禁设备:" prop="deviceId">
                            <el-select v-model="item.deviceId" style="width: 100%;" placeholder="请选择关联门禁设备" disabled @change="chosenDevice">
                                <el-option
                                    v-for="items in devicesOptions"
                                    :disabled="items.disabled"
                                    :key="items.deviceId"
                                    :label="items.deviceName"
                                    :value="items.deviceId" 
                                ></el-option>
                            </el-select>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8">
                        <el-form-item label="设备位置:" prop="location">
                            <el-input v-model="item.location"
                                placeholder="设备位置"
                                maxlength="30" disabled
                            />
                        </el-form-item>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div style="font-size: 18px;font-weight: bold;border-left: 4px solid #1890FF;padding-left: 4px;margin-bottom: 20px;">
                            留样柜权限
                        </div>
                    </el-col>
                    <el-col :span="12">
                        <el-form-item label="留样柜权限:" prop="simpleCabinetStatus">
                            <el-switch v-model="simpleCabinetStatus" disabled
                                active-text="开启" inactive-text="关闭"
                                :active-value="1" :inactive-value="2">
                            </el-switch>
                        </el-form-item>
                    </el-col> 
                </el-row>
            </el-form> 
        </div> 
        <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="open2=false">确 定</el-button>
            <el-button @click="open2=false">取 消</el-button>
        </div>
    </el-dialog>

    <el-dialog :visible.sync="dialogVisible" width="700px">
        <img style="width: 100%;height: 100%;" :src="dialogImageUrl" alt="">
    </el-dialog>
  </div>
</template>

<script> 
import { getCanteenByAreaApi } from "@/api/base/stall"; 
import { getKitchenDeviceSelectApi } from "@/api/kitchen/devices"; 
import { getStaffListApi,getStaffInfoApi,addKitchenStaffApi,editKitchenStaffApi,delStaffApi,editStaffFaceStateApi} from '@/api/kitchen/staff';
import { imgUpLoadTwo } from '@/api/system/upload';
export default {
    name: "",
    dicts: [],
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            // 总条数
            total: 0,
            //表格数据
            tableListData: [],
            // 食堂选项
            canteenOptions:[],
            // 设备选项
            devicesOptions:[],
            
            loading2: false,
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false, 
            open2: false, 
            // 查询参数
            queryParams: {
            pageNum: 1,
            pageSize: 10,
            canteenName: undefined,
            areaNameStr: undefined, 
            },
            // 表单参数
            form: {},
            //员工设备权限
            accessAuthorityList:[
                {
                    deviceId:"",
                    location:""
                }
            ],
            simpleCabinetStatus:1,
            // 表单校验
            rules: {
            staffName: [
                { required: true, message: "员工名称不能为空", trigger: "blur" }
            ],
            staffNo: [
                { required: true, message: "员工编号不能为空", trigger: "blur" }
            ],
            sex: [
                { required: true, message: "员工性别不能为空", trigger: "change" }
            ],
            mobile: [
                {
                    required: true,
                    message: '手机号不能为空',
                    trigger: 'blur',
                },
                {
                    pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
                    message: '请输入正确的手机号码',
                    trigger: 'blur',
                },
            ],
            canteenId: [
                { required: true, message: "关联食堂不能为空", trigger: "change" }
            ],
            postName: [
                { required: true, message: "员工岗位名称不能为空", trigger: "blur" }
            ],
            },
            fileList0: [],//图片
            checkUrlList0: [],//图片
            fileList1: [],//图片
            checkUrlList1: [],//图片
            fileList2: [],//图片
            checkUrlList2: [],//图片 
            dialogVisible:false,//图片弹窗
            dialogImageUrl:"",//图片弹窗  
        };
    },
    created() {  
        this.getList();
    },
    computed: {
        //图片上传1张后，隐藏上传框
        uploadDisabled0() {
            return this.checkUrlList0.length > 0
        },
        uploadDisabled1() {
            return this.checkUrlList1.length > 0
        },
        uploadDisabled2() {
            return this.checkUrlList2.length > 0
        },
    },
    methods: {
        // 食堂选项
        getCanteenList(){
            getCanteenByAreaApi({}).then((response) => {
                this.canteenOptions = response.rows 
            })
        },
        // 门禁设备选项
        getKitchenDeviceSelect(){
            getKitchenDeviceSelectApi({deviceType:3}).then((response) => {
                this.devicesOptions = response.data 
            })
        },
        /** 搜索按钮操作 */
        handleQuery() {
            this.queryParams.pageNum = 1;
            this.getList();
        },
        /** 重置按钮操作 */
        resetQuery() { 
            this.resetForm("queryForm");
            this.handleQuery();
        },
        /** 查询列表 */
        getList() {
            this.loading = true;
            let param = {
                "searchValue":this.queryParams.searchValue,
                "sex":this.queryParams.sex,
                "faceState":this.queryParams.faceState,
                "postName":this.queryParams.postName,
                "healthCertStatus":this.queryParams.healthCertStatus,
                "pageNum": this.queryParams.pageNum, 
                "pageSize": this.queryParams.pageSize
            } 
            getStaffListApi(param).then(response => {
                this.tableListData = response.rows;
                this.total = Number(response.total);
                this.loading = false;
            });
        },  
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "新增";
        },
        /** 修改按钮操作 */
        handleUpdate(row) {
            this.reset(); 
            getStaffInfoApi(row.staffId).then(response => {
                this.form = response.data;
                if(response.data.healthCertFrontImg){
                  this.fileList0=[{url:response.data.faceUrl}]
                  this.checkUrlList0=[response.data.faceUrl]
                }else{
                  this.fileList0=[]
                  this.checkUrlList0=[]
                }
                if(response.data.healthCertFrontImg){
                  this.fileList1=[{url:response.data.healthCertFrontImg}]
                  this.checkUrlList1=[response.data.healthCertFrontImg]
                }else{
                  this.fileList1=[]
                  this.checkUrlList1=[]
                }
                if(response.data.healthCertBackImg){
                  this.fileList2=[{url:response.data.healthCertBackImg}]
                  this.checkUrlList2=[response.data.healthCertBackImg]
                }else{
                  this.fileList2=[]
                  this.checkUrlList2=[]
                }
                console.log(this.form)
                if(this.form.accessAuthorityList&&this.form.accessAuthorityList.length>0){
                    console.log(this.form.accessAuthorityList)
                    this.accessAuthorityList = []
                    this.form.accessAuthorityList.forEach(item=>{
                        if(item.deviceType==3){
                            this.accessAuthorityList.push(item)
                            this.$forceUpdate()
                        }
                        if(item.deviceType==7){
                            this.simpleCabinetStatus = Number(item.privilegeValue)
                        }
                    })
                }
                console.log(this.accessAuthorityList)
                this.open = true;
                this.title = "修改";
            });
        },
        // 取消按钮
        cancel() {
            this.open = false;
        },
        // 表单重置
        reset() {
            this.getCanteenList();
            this.getKitchenDeviceSelect();
            this.fileList = []//图片
            this.checkUrlList = []//图片
            this.fileList2 = []//图片
            this.checkUrlList2 = []//图片 
            this.accessAuthorityList = [{
                deviceId:"",
                location:""
            }]
            this.simpleCabinetStatus=1
            this.form = {};
            this.resetForm("form");
        },
        changeSwitch(row){
            console.log(row.faceState)
            let param = {
                staffId:row.staffId,
                faceState:row.faceState
            }
            editStaffFaceStateApi(param).then(response => {
                this.$modal.msgSuccess("修改成功"); 
                this.getList();
            });

        },
        openAccessAuth(row){
            this.getKitchenDeviceSelect();
            if(row.accessAuthorityList&&row.accessAuthorityList.length>0){
                console.log(row.accessAuthorityList)
                this.accessAuthorityList = []
                row.accessAuthorityList.forEach(item=>{
                    if(item.deviceType==3){
                        this.accessAuthorityList.push(item)
                        this.$forceUpdate()
                    }
                    if(item.deviceType==7){
                        this.simpleCabinetStatus = Number(item.privilegeValue)
                    }
                })
            }
            console.log(this.accessAuthorityList) 
            this.open2=true
            this.title = "出入权限";
        },
        //添加设备
        addDevice(){
            if(this.accessAuthorityList.length<this.devicesOptions.length){
                this.accessAuthorityList.push({
                    deviceId:"",
                    location:""
                })
            } 
        },
        //删除设备
        delDevice(index){
            this.accessAuthorityList.splice(index,1)
        }, 
        chosenDevice(e){
            let index = this.devicesOptions.findIndex(v=>v.deviceId==e)
            let index2 = this.accessAuthorityList.findIndex(v=>v.deviceId==e)
            this.accessAuthorityList[index2].deviceName = this.devicesOptions[index].deviceName;
            this.accessAuthorityList[index2].deviceType = this.devicesOptions[index].deviceType;
            this.accessAuthorityList[index2].privilegeValue = 1;
            this.accessAuthorityList[index2].location = this.devicesOptions[index].subPlaceName;
            this.loading2=true
            this.setDisabled()
            this.loading2=false
        },
        //组成成分，已选过的原料不能再选择
        setDisabled(){ 
            this.devicesOptions.forEach(item=>{
                let index = this.accessAuthorityList.findIndex(v=>v.deviceId==item.deviceId)
                if(index!=-1){
                    item.disabled = true
                }else{
                    item.disabled = false
                }
            }) 
        }, 
        /** 提交按钮 */
        submitForm: function() {
            this.$refs["form"].validate(valid => {
            if (valid) {  
                let arr = [{
                    deviceId:"",
                    deviceName:"",
                    deviceType:7,
                    privilegeValue:this.simpleCabinetStatus,
                    location:""
                }]
                this.form.accessAuthorityList = this.accessAuthorityList.concat(arr) 
                console.log(this.form)
                if (this.form.staffId != undefined) {
                    editKitchenStaffApi(this.form).then(response => {
                        this.$modal.msgSuccess("修改成功");
                        this.open = false;
                        this.getList();
                    });
                } else {
                    addKitchenStaffApi(this.form).then(response => {
                        this.$modal.msgSuccess("新增成功");
                        this.open = false;
                        this.getList();
                    });
                }
            }
            });
        },
        /** 删除按钮操作 */
        handleDelete(row) { 
            this.$modal.confirm('是否确认删除数据项？').then(function() {
                return delStaffApi(row.staffId);
            }).then(() => {
                this.getList();
                this.$modal.msgSuccess("删除成功");
            }).catch(() => {});
        },
        // 图片上传
        imgUpLoad0(param, name, index) {
            param.type = 'canteen'
            imgUpLoadTwo(param).then((res) => {
                if (res.code == 200) {
                    this.checkUrlList0.push(res.data.url) 
                    this.$set(this.form,"faceUrl",res.data.url) 
                } else { 
                    this.$modal.msgError(res.msg)
                }
            })
            .catch((error) => { 
                this.$modal.msgError(error)
            })
        },
        imgUpLoad1(param, name, index) {
            param.type = 'canteen'
            imgUpLoadTwo(param).then((res) => {
                if (res.code == 200) {
                    this.checkUrlList1.push(res.data.url) 
                    this.$set(this.form,"healthCertFrontImg",res.data.url) 
                } else { 
                    this.$modal.msgError(res.msg)
                }
            })
            .catch((error) => { 
                this.$modal.msgError(error)
            })
        },
        imgUpLoad2(param, name, index) {
            param.type = 'canteen'
            imgUpLoadTwo(param).then((res) => {
                if (res.code == 200) {
                    this.checkUrlList2.push(res.data.url) 
                    this.$set(this.form,"healthCertBackImg",res.data.url) 
                } else { 
                    this.$modal.msgError(res.msg)
                }
            })
            .catch((error) => { 
                this.$modal.msgError(error)
            })
        },
        // 上传之前
        handleBeforeUpload(file) { 
            const isLt = file.size / 1024 / 1024 < 5
            if (!isLt) {
                this.$modal.msgError(`图片大小不能超过 5 MB`)
                return false
            }
        },
        handleExceed(files, fileList) {
            this.$message.warning('最多只可以上传一张图片')
        },
        handleRemove0(file, fileList) {
            let sum = 0
            this.checkUrlList.forEach((item, index) => {
                if (item == file.url) {
                    sum = index
                }
            })
            this.checkUrlList0.splice(sum, 1)
            this.$set(this.form,"faceUrl","") 
        },
        handleRemove1(file, fileList) {
            let sum = 0
            this.checkUrlList.forEach((item, index) => {
                if (item == file.url) {
                    sum = index
                }
            })
            this.checkUrlList1.splice(sum, 1)
            this.$set(this.form,"healthCertFrontImg","") 
        },
        handleRemove2(file, fileList) {
            let sum = 0
            this.checkUrlList2.forEach((item, index) => {
                if (item == file.url) {
                    sum = index
                }
            })
            this.checkUrlList2.splice(sum,1)
            this.$set(this.form,"healthCertBackImg","") 
        },
        //图片点击查看
        handlePictureCardPreview(file) {
            console.log(file)
            this.dialogImageUrl = file.url
            this.dialogVisible = true
        },
        openImg(row) {
          this.dialogImageUrl = row.healthCertFrontImg;
          this.dialogVisible = true;
        },
        openImg2(row) {
          this.dialogImageUrl = row.faceUrl;
          this.dialogVisible = true;
        }
  }
};
</script>
<style lang="scss" scoped>
  //隐藏图片上传框的css
  ::v-deep.disabled {
      .el-upload--picture-card {
          display: none;
      }
  }
</style>