<template>
    <view>
        <cu-custom bgColor="bg-gradual-blueness" :isBack="true">
            <block slot="backText">返回</block>
            <block slot="content">动火作业申请</block>
        </cu-custom>
        <view class="form">
            <view class="wui-form-list">
                <view class="cu-form-group">
                    <view class="title">申请单位：</view>
                    {{ form.APPLY_DEPARTMENT_NAME }}
                </view>
                <view class="cu-form-group">
                    <view class="title">申请办理人：</view>
                    {{ form.APPLY_USER_NAME }}
                </view>
                <view class="cu-form-group">
                    <view class="title">作业编号：</view>
<!--                    <input :disabled="forbidEdit" v-model="form.JOB_NUMBER" placeholder="请输入编号"></input>-->
                    {{ form.JOB_NUMBER }}
                </view>
                <view class="cu-form-group">
                    <view class="title">申请日期：</view>
                    <ruiDatePicker v-if="!forbidEdit" :start="todayDate" fields="minute"
                                   :value="form.APPLICATION_DATE || '请选择'"
                                   @change="changeApplicationDate"></ruiDatePicker>
                    <text v-else>{{ form.APPLICATION_DATE }}</text>
                </view>
                <view class="cu-form-group">
                    <view class="title">作业类型：</view>
                    <picker @change="jobTypeChange" :disabled="forbidEdit" :value="form.JOB_TYPE_INDEX"
                            :range="jobTypeList"
                            range-key="name">
                        <view class="picker">
                            {{ form.JOB_TYPE_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>
                <view class="cu-form-group">
                    <view class="title">动火部位：</view>
                    <input :disabled="forbidEdit" v-model="form.HOT_WORK_POSITION" placeholder="请输入动火部位"></input>
                </view>
                <view class="cu-form-group">
                    <view class="title">动火方法：</view>
                    <ld-select :multiple="true" :list="hotWorkMethodList" :disabled="forbidEdit"
                               label-key="NAME" value-key="DICTIONARIES_ID"
                               placeholder="请选择"
                               v-model="form.HOT_WORK_METHOD_ID"
                               @change="hotWorkMethodChange"></ld-select>
<!--                    <picker @change="hotWorkMethodChange" :disabled="forbidEdit" :value="form.HOT_WORK_METHOD_INDEX"-->
<!--                            :range="hotWorkMethodList" range-key="NAME">-->
<!--                        <view class="picker">-->
<!--                            {{ form.HOT_WORK_METHOD_NAME || '请选择' }}-->
<!--                        </view>-->
<!--                    </picker>-->
                </view>
                <view class="cu-form-group">
                    <view class="title">动火等级：</view>
                    <picker @change="hotWorkLevelChange" :disabled="forbidEdit" :value="form.HOT_WORK_LEVEL_INDEX"
                            :range="hotWorkLevelList" range-key="name">
                        <view class="picker">
                            {{ form.HOT_WORK_LEVEL_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>
                <view class="cu-form-group" v-if="form.HOT_WORK_LEVEL_INDEX =='0'">
                    <view class="title">动火负责人确认部门：</view>
                    <block v-if="!forbidEdit">
                        <view class="picker-tree-box">
                            <view class="picker-tree" @tap="showZgTree('tkiTree30')">
                                {{ form.CHARGECONFIRM_DEPT_NAME || '请选择' }}
                            </view>
                        </view>
                        <tki-tree ref="tkiTree30" :selectParent=true :range="treeNode" rangeKey="name"
                                  @confirm="zgtreeConfirm($event,'chargeConfirmList')"
                                  @cancel="zgtreeCancel"></tki-tree>
                    </block>
                    <block v-else>{{ form.CHARGECONFIRM_DEPT_NAME }}</block>
                </view>
                <view class="cu-form-group" v-if="form.CHARGECONFIRM_DEPT_NAME && form.HOT_WORK_LEVEL_INDEX =='0'">
                    <view class="title">动火负责人确认负责人：</view>
                    <picker @change="chargeConfirmChange" :disabled="forbidEdit" :value="form.CHARGECONFIRM_INDEX"
                            :range="chargeConfirmList" range-key="NAME">
                        <view class="picker">
                            {{ form.CHARGECONFIRM_USER_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>

                <view class="cu-form-group">
                    <view class="title">动火开始时间：</view>
                    <ruiDatePicker v-if="!forbidEdit" :start="todayDate" fields="minute"
                                   :value="form.HOT_WORK_TIME_START || '请选择'"
                                   @change="changehotWorkTimeStart"></ruiDatePicker>
                    <text v-else>{{ form.HOT_WORK_TIME_START }}</text>
                </view>
                <view class="cu-form-group">
                    <view class="title">动火结束时间：</view>
                    <ruiDatePicker v-if="!forbidEdit" :start="todayDate" fields="minute"
                                   :value="form.HOT_WORK_TIME_END || '请选择'"
                                   @change="changehotWorkTimeEnd"></ruiDatePicker>
                    <text v-else>{{ form.HOT_WORK_TIME_END }}</text>
                </view>
                <view class="cu-form-group">
                    <view class="title">作业地点：</view>
                    <button class="cu-btn shadow bg-blue" @click="chooseLocation" v-if="!forbidEdit">地图选择</button>
                </view>
                <view class="cu-form-group" v-if="form.WORK_LONGITUDE">
                    <view class="title">经度：</view>
                    <view>{{form.WORK_LONGITUDE}}</view>
                </view>
                <view class="cu-form-group" v-if="form.WORK_LATITUDE">
                    <view class="title">纬度：</view>
                    <view>{{form.WORK_LATITUDE}}</view>
                </view>
                <view class="cu-form-group">
                    <view class="title">作业内容：</view>
                    <input :disabled="forbidEdit" v-model="form.JOB_CONTENT" placeholder="请输入作业内容"></input>
                </view>
            </view>
                <view class="wui-form-list">
                    <view class="cu-form-group">
                        <view class="title">现场负责人部门：</view>
                        <block v-if="!forbidEdit">
                            <view class="picker-tree-box">
                                <view class="picker-tree" @tap="showZgTree('tkiTree3')">
                                    {{ form.SITE_LEADER_DEPARTMENT_NAME || '请选择' }}
                                </view>
                            </view>
                            <tki-tree ref="tkiTree3" :selectParent=true :range="treeNode" rangeKey="name"
                                      @confirm="zgtreeConfirm($event,'siteLeaderList')"
                                      @cancel="zgtreeCancel"></tki-tree>
                        </block>
                        <block v-else>{{ form.SITE_LEADER_DEPARTMENT_NAME }}</block>
                    </view>
                    <view class="cu-form-group" v-if="form.SITE_LEADER_DEPARTMENT_NAME">
                        <view class="title">现场负责人：</view>
                        <picker @change="siteLeaderChange" :disabled="forbidEdit" :value="form.SITE_LEADER_INDEX"
                                :range="siteLeaderList" range-key="NAME">
                            <view class="picker">
                                {{ form.SITE_LEADER_NAME || '请选择' }}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group" v-if="form.SITE_LEADER_PHONE">
                        <view class="title">现场负责人电话：</view>
                        {{ form.SITE_LEADER_PHONE }}
                    </view>
                </view>
            <view class="wui-form-list">
                <view class="cu-form-group" v-if="!forbidEdit">
                    <view class="title">动火操作人：</view>
                    <view class="add_pard_b">
                        <button class="cu-btn round bg-blue" @click="addOther">添加</button>
                    </view>
                </view>
                <view class="add_pard_box" v-if="showAddOther && !forbidEdit">
                    <view class="cu-form-group">
                        <button class="cu-btn round bg-blue" @click="hotWorkOperatorSelectShow">特种作业人员</button>
                        <button class="cu-btn round bg-blue" @click="addSpecialInputAdd">临时人员</button>
                        <button class="cu-btn round bg-blue" @click="addOtherInputAdd">其他</button>
                    </view>
                    <view class="add_pard_item" v-for="(item,index) of other">
                        <view class="add_pard_del" @click="removeOther(index)">
                            <text class="cuIcon-roundclosefill text-red f40"></text>
                        </view>
                        <view class="cu-form-group">
                            <picker @change="PickerYsr($event,index)" :value="other[index].index"
                                    @click="haveUser(other[index])"
                                    :disabled="otherUserList[index] ==null || otherUserList[index].length==0"
                                    :range="otherUserList[index]" range-key="NAME">
                                <view class="picker">
                                    {{other[index].USER_NAME?other[index].USER_NAME:'请选择'}}
                                </view>
                            </picker>
                        </view>
                    </view>
                </view>
                <view class="cu-form-group" v-if="forbidEdit">
                    <view class="title">动火操作人：</view>
                    <uni-table border stripe emptyText="暂无更多数据" style="flex:1;margin: 20upx 0">
                        <uni-tr></uni-tr>
                        <uni-tr v-for="item in other" :key="item">
                            <uni-td>{{ item.USER_NAME }}</uni-td>
                        </uni-tr>
                    </uni-table>
                </view>
                <view class="cu-form-group">
                    <view class="title">动火监火人：</view>
                    <input :disabled="forbidEdit" v-model="form.SUPERVISOR_OF_HOT_WORK_UNIT"
                           placeholder="请输入动火监火人"></input>
                </view>
            </view>

            <!-- 动火单位(部门) 1-->
            <view class="wui-form-list">
                <view class="cu-form-group">
                    <view class="title">动火单位(部门)：</view>
                    <block v-if="!forbidEdit">
                        <view class="picker-tree-box">
                            <view class="picker-tree" @tap="showZgTree('tkiTree1')">
                                {{ form.HOT_WORK_DEPARTMENT_NAME || '请选择' }}
                            </view>
                        </view>
                        <tki-tree ref="tkiTree1" :selectParent=true :range="treeNode" rangeKey="name"
                                  @confirm="zgtreeConfirm($event,'hotWorkUserList')"
                                  @cancel="zgtreeCancel"></tki-tree>
                    </block>
                    <block v-else>{{ form.HOT_WORK_DEPARTMENT_NAME }}</block>
                </view>
                <view class="cu-form-group" v-if="form.HOT_WORK_DEPARTMENT_NAME">
                    <view class="title">动火单位(部门)负责人：</view>
                    <picker @change="hotWorkChange" :disabled="forbidEdit" :value="form.HOT_WORK_PERSONNEL_INDEX"
                            :range="hotWorkUserList" range-key="NAME">
                        <view class="picker">
                            {{ form.HOT_WORK_USER_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>
                <view class="cu-form-group" v-if="form.HOT_WORK_USER_PHONE">
                    <view class="title">动火单位(部门)负责人电话：</view>
                    {{ form.HOT_WORK_USER_PHONE }}
                </view>
            </view>
            <!-- 项目发包人2 v-if="form.JOB_TYPE_INDEX == '1'" -->
            <view class="wui-form-list" v-if="form.JOB_TYPE_INDEX == '1'">
                <view class="cu-form-group">
                    <view class="title">项目发包单位负责人部门：</view>
                    <block v-if="!forbidEdit">
                        <view class="picker-tree-box">
                            <view class="picker-tree" @tap="showZgTree('tkiTree2')">
                                {{ form.PROJECT_UNIT_LEADER_DEPARTMENT_NAME || '请选择' }}
                            </view>
                        </view>
                        <tki-tree ref="tkiTree2" :selectParent=true :range="treeNode" rangeKey="name"
                                  @confirm="zgtreeConfirm($event,'projectUnitLeaderList')"
                                  @cancel="zgtreeCancel"></tki-tree>
                    </block>
                    <block v-else>{{ form.PROJECT_UNIT_LEADER_DEPARTMENT_NAME }}</block>
                </view>
                <view class="cu-form-group" v-if="form.PROJECT_UNIT_LEADER_DEPARTMENT_NAME">
                    <view class="title">项目发包单位负责人：</view>
                    <picker @change="projectUnitLeaderChange" :disabled="forbidEdit"
                            :value="form.PROJECT_UNIT_LEADER_INDEX"
                            :range="projectUnitLeaderList" range-key="NAME">
                        <view class="picker">
                            {{ form.PROJECT_UNIT_LEADER_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>
                <view class="cu-form-group" v-if="form.PROJECT_UNIT_LEADER_PHONE">
                    <view class="title">项目发包单位负责人电话：</view>
                    {{ form.PROJECT_UNIT_LEADER_PHONE }}
                </view>
            </view>
            <!-- 现场负责部门 3    -->

            <!-- 现场管辖单位负责人 4     -->
            <view class="wui-form-list">
                <view class="cu-form-group">
                    <view class="title">现场管辖单位(部门)：</view>
                    <block v-if="!forbidEdit">
                        <view class="picker-tree-box">
                            <view class="picker-tree" @tap="showZgTree('tkiTree7')">
                                {{ form.UNIT_LEADER_DEPARTMENT_NAME || '请选择' }}
                            </view>
                        </view>
                        <tki-tree ref="tkiTree7" :selectParent=true :range="treeNode" rangeKey="name"
                                  @confirm="zgtreeConfirm($event,'unitLeaderList')"
                                  @cancel="zgtreeCancel"></tki-tree>
                    </block>
                    <block v-else>{{ form.UNIT_LEADER_DEPARTMENT_NAME }}</block>
                </view>
                <view class="cu-form-group" v-if="form.UNIT_LEADER_DEPARTMENT_NAME">
                    <view class="title">现场管辖单位(部门)负责人：</view>
                    <picker @change="unitLeaderChange" :disabled="forbidEdit" :value="form.UNIT_LEADER_INDEX"
                            :range="unitLeaderList" range-key="NAME">
                        <view class="picker">
                            {{ form.UNIT_LEADER_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>
                <view class="cu-form-group" v-if="form.UNIT_LEADER_PHONE">
                    <view class="title">现场管辖单位(部门)负责人电话：</view>
                    {{ form.UNIT_LEADER_PHONE }}
                </view>
            </view>
            <!-- 动火许可证签发单位5 -->
            <view class="wui-form-list">
                <view class="cu-form-group">
                    <view class="title">动火许可证签发单位：</view>
                    <block v-if="!forbidEdit">
                        <view class="picker-tree-box">
                            <view class="picker-tree" @tap="showZgTree('tkiTree4')">
                                {{ form.ISSUING_DEPARTMENT_NAME || '请选择' }}
                            </view>
                        </view>
                        <tki-tree ref="tkiTree4" :selectParent=true :range="treeNode" rangeKey="name"
                                  @confirm="zgtreeConfirm($event,'issunigUserList')"
                                  @cancel="zgtreeCancel"></tki-tree>
                    </block>
                    <block v-else>{{ form.ISSUING_DEPARTMENT_NAME }}</block>
                </view>
                <view class="cu-form-group" v-if="form.ISSUING_DEPARTMENT_NAME">
                    <view class="title">动火许可证签发负责人：</view>
                    <picker @change="issungChange" :disabled="forbidEdit" :value="form.ISSUING_INDEX"
                            :range="issunigUserList" range-key="NAME">
                        <view class="picker">
                            {{ form.ISSUING_USER_NAME || '请选择' }}
                        </view>
                    </picker>
                </view>
                <view class="cu-form-group" v-if="form.ISSUING_USER_PHONE">
                    <view class="title">动火许可证签发负责人电话：</view>
                    {{ form.ISSUING_USER_PHONE }}
                </view>
            </view>
            <!-- 是否安全总监审批6 -->
            <view class="wui-form-list">
                <view class="cu-form-group ">
                    <view class="title text-hui">是否安全总监审批</view>
                    <radio-group class="selected" @change="radioType" :disabled="forbidEdit">
                        <view class="group mr20">
                            <radio class='radio' :disabled="forbidEdit" value="1"
                                   :checked="form.IS_SAFETY_DIRECTOR==1"></radio>
                            <text>是</text>
                        </view>
                        <view class="group">
                            <radio class='radio' :disabled="forbidEdit" value="0"
                                   :checked="form.IS_SAFETY_DIRECTOR==0"></radio>
                            <text>否</text>
                        </view>
                    </radio-group>
                </view>
                <div v-if="form.IS_SAFETY_DIRECTOR =='1'">
                    <view class="cu-form-group">
                        <view class="title">安全总监单位：</view>
                        <block v-if="!forbidEdit">
                            <view class="picker-tree-box">
                                <view class="picker-tree" @tap="showZgTree('tkiTree5')">
                                    {{ form.SAFETY_DIRECTOR_DEPARTMENT_NAME || '请选择' }}
                                </view>
                            </view>
                            <tki-tree ref="tkiTree5" :selectParent=true :range="treeNode" rangeKey="name"
                                      @confirm="zgtreeConfirm($event,'safetyDirectorList')"
                                      @cancel="zgtreeCancel"></tki-tree>
                        </block>
                        <block v-else>{{ form.SAFETY_DIRECTOR_DEPARTMENT_NAME }}</block>
                    </view>
                    <view class="cu-form-group" v-if="form.SAFETY_DIRECTOR_DEPARTMENT_NAME">
                        <view class="title">安全总监：</view>
                        <picker @change="safetyDirectorChange" :disabled="forbidEdit"
                                :value="form.SAFETY_DIRECTOR_INDEX"
                                :range="safetyDirectorList" range-key="NAME">
                            <view class="picker">
                                {{ form.SAFETY_DIRECTOR_USER_NAME || '请选择' }}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group" v-if="form.SAFETY_DIRECTOR_PHONE">
                        <view class="title">安全总监电话：</view>
                        {{ form.SAFETY_DIRECTOR_PHONE }}
                    </view>
                </div>

            </view>
            <!-- 是否 需要气体检测 7 -->
			<view class="wui-form-list">
                <view class="cu-form-group ">
                    <view class="title text-hui">是否需要气体检测</view>
                    <radio-group class="selected" @change="radioType2" :disabled="forbidEdit">
                        <view class="group mr20">
                            <radio class='radio' :disabled="forbidEdit" value="1"
                                   :checked="form.IS_GAS_TESTING==1"></radio>
                            <text>是</text>
                        </view>
                        <view class="group">
                            <radio class='radio' :disabled="forbidEdit" value="0"
                                   :checked="form.IS_GAS_TESTING==0"></radio>
                            <text>否</text>
                        </view>
                    </radio-group>
                </view>
				<div v-if="form.IS_GAS_TESTING =='1'">
                    <view class="cu-form-group">
                        <view class="title">气体检测人员单位：</view>
                        <block v-if="!forbidEdit">
                            <view class="picker-tree-box">
                                <view class="picker-tree" @tap="showZgTree('tkiTree6')">
                                    {{ form.GAS_TESTING_DEPARTMENT_NAME || '请选择' }}
                                </view>
                            </view>
                            <tki-tree ref="tkiTree6" :selectParent=true :range="treeNode" rangeKey="name"
                                      @confirm="zgtreeConfirm($event,'gasTestingList')"
                                      @cancel="zgtreeCancel"></tki-tree>
                        </block>
                        <block v-else>{{ form.GAS_TESTING_DEPARTMENT_NAME }}</block>
                    </view>
                    <view class="cu-form-group" v-if="form.GAS_TESTING_DEPARTMENT_NAME">
                        <view class="title">气体检测人员：</view>
                        <picker @change="gasTestingChange" :disabled="forbidEdit" :value="form.GAS_TESTING_INDEX"
                                :range="gasTestingList" range-key="NAME">
                            <view class="picker">
                                {{ form.GAS_TESTING_USER_NAME || '请选择' }}
                            </view>
                        </picker>
                    </view>
                    <view class="cu-form-group" v-if="form.GAS_TESTING_USER_PHONE">
                        <view class="title">气体检测人员电话：</view>
                        {{ form.GAS_TESTING_USER_PHONE }}
                    </view>
                </div>

            </view>
            <view class="wui-form-list">
                <view class="cu-form-group">
                    <view class="title">其他安全措施：</view>
                    <button class="cu-btn round bg-blue" @click="addQtcsOther" v-if="!forbidEdit" >添加</button>
                </view>
                <view class="ace-content" v-show="otherMeasure && otherMeasure.length > 0">
                    <view class="add_pard_item" v-for="(item,index) of otherMeasure">
                        <view class="add_pard_del" @click="removeQtcsMeasure(index)">
                            <text class="cuIcon-roundclosefill text-red f40"></text>
                        </view>
                        <view class="cu-form-textarea">
                            <textarea placeholder="请输入其他安全措施..." v-model="otherMeasure[index]"></textarea>
                        </view>
                    </view>
                </view>
            </view>
			<!-- 被打回时，显示打回原因 -->
			<view v-if="(form.STATE == '-1' || form.STATE == '-2') && repulseList && repulseList.length > 0">
				<view class="wui-form-list" v-for="item in repulseList">
					<view class="cu-form-group">
					    <view class="title">打回人：</view>
					    {{ item.userName || item.userName2 || item.REGULATORY_USER_NAME}}
					</view>
					<view v-if="item.OPINION" class="cu-form-textarea  bb-default" style="border-top: 1upx solid #eee;" >
						<view class="cu-form-title">打回意见</view>
						<textarea :disabled="true" v-model="item.OPINION"></textarea>
					</view>
				</view>
			</view>


        </view>
        <view class="cu-bar btn-group" style="margin-top: 30upx;">
            <button v-if="!forbidEdit" class="cu-btn bg-blue margin-tb-sm lg" @click="$noMultipleClicks(goSubmit,1)">
                提交
            </button>
            <button v-if="forbidEdit" class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(goback)">返回
            </button>
        </view>

        <view class="padding flex flex-direction"></view>
        <uni-popup ref="cityMore" type="bottom" :maskClick="false">
            <more-select
                    title="选择特种操作人"
                    :cityData="hotWorkOperatorDepartmentList"
                    @closeCity="hotWorkOperatorSelectHide('close')"
                    @queryCity="hotWorkOperatorSelectHide('query')"
                    @switchCity="switchCity"
                    @chooseCity="chooseCity"
                    :cityIndex="cityIndex"
                    :cityIdArr="form.HOT_WORK_OPERATOR_ID"
                    :maxCount="99"
            ></more-select>
        </uni-popup>

        <view :class="['cu-modal',{'show':addModal}]">
            <view class="cu-dialog">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">添加动火操作人</view>
                    <view class="action" @tap="addModal = false">
                        <text class="cuIcon-close text-red"></text>
                    </view>
                </view>
                <view>
                    <view class="wrapper">
                        <view class="handCenter">
                            <view class="form">
                                <view class="wui-form-list">
                                    <view class="cu-form-group">
                                        <view class="title">人员姓名：</view>
                                        <input v-model="addOtherInput.USERNAME" placeholder="请输入人员姓名"></input>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="cu-bar bg-white justify-end">
                    <view class="action">
                        <button class="cu-btn bg-green margin-left" @click="addOtherInputSubmit">确认</button>
                    </view>
                </view>
            </view>
        </view>

        <view :class="['cu-modal',{'show':addSpecial}]">
            <view class="cu-dialog">
                <view class="cu-bar bg-white justify-end">
                    <view class="content">添加动火操作人</view>
                    <view class="action" @tap="addSpecial = false">
                        <text class="cuIcon-close text-red"></text>
                    </view>
                </view>
                <view>
                    <view class="wrapper">
                        <view class="handCenter">
                            <view class="form">
                                <view class="wui-form-list">
                                    <view class="cu-form-group">
                                        <view class="title">人员单位：</view>
                                        <input v-model="addSpecialInput.DEPTNAME" placeholder="请输入人员单位"></input>
                                    </view>
                                    <view class="cu-form-group">
                                        <view class="title">人员姓名：</view>
                                        <input v-model="addSpecialInput.USERNAME" placeholder="请输入人员姓名"></input>
                                    </view>
                                    <view class="cu-form-group">
                                        <view class="title">人员照片：</view>
                                        <button class="cu-btn bg-blue margin-tb-sm sm" @click="ChooseImageUser"
                                                v-if="addSpecialInput.userImgList.length === 0">点击上传
                                        </button>
                                        <block v-else>
                                            <view class="bg-img" v-for="(item,index) in addSpecialInput.userImgList"
                                                  :key="index" @tap="ViewImageUser" :data-url="item">
                                                <image :src="item" style="width: 200upx ;height: 200upx"></image>
                                                <view class="cu-tag bg-red" @tap.stop="DelImgUser" :data-index="index">
                                                    <text class='cuIcon-close'></text>
                                                </view>
                                            </view>
                                        </block>
                                    </view>
                                    <view class="cu-form-group">
                                        <view class="title">证件照片：</view>
                                        <button class="cu-btn bg-blue margin-tb-sm sm" @click="ChooseImageCard"
                                                v-if="addSpecialInput.cardImgList.length === 0">点击上传
                                        </button>
                                        <block v-else>
                                            <view class="bg-img" v-for="(item,index) in addSpecialInput.cardImgList"
                                                  :key="index" @tap="ViewImageCard" :data-url="item">
                                                <image :src="item" style="width: 200upx ;height: 200upx"></image>
                                                <view class="cu-tag bg-red" @tap.stop="DelImgCard" :data-index="index">
                                                    <text class='cuIcon-close'></text>
                                                </view>
                                            </view>
                                        </block>
                                    </view>
                                </view>
                            </view>
                        </view>
                    </view>
                </view>
                <view class="cu-bar bg-white justify-end">
                    <view v-if="SPECIALUSER_ID == ''" class="action">
                        <button class="cu-btn bg-green margin-left" @click="addSpecialInputSubmit">确认</button>
                    </view>
                </view>
            </view>
        </view>
    </view>
</template>

<script>
    import {
        basePath,
        corpinfoId,
        loginUser,
        loginSession,
        formatDate,
        loginUserId
    } from '@/common/tool.js';
    import tkiTree from "@/components/select-tree/select-tree.vue"
    import ruiDatePicker from '@/components/rattenking-dtpicker/rattenking-dtpicker.vue';
    import moreSelect from '@/components/more-select/more-select.vue';
    import uniPopup from '@/components/more-select/uni-popup/uni-popup.vue';
    import ldSelect from '@/components/ld-select/ld-select.vue'

    export default {
        components: {
            tkiTree,
            ruiDatePicker,
            moreSelect,
            uniPopup,
            ldSelect
        },
        data() {
            return {
                msg: 'add',
                noClick: true,
                form: {
                    HOTWORKAPPLICATION_ID: '',
                    APPLY_DEPARTMENT_ID: '',
                    APPLY_DEPARTMENT_NAME: '',
                    APPLY_USER_ID: '',
                    APPLY_USER_NAME: '',
                    JOB_NUMBER: '',
                    APPLICATION_DATE: formatDate(new Date(), 'yyyy-MM-dd hh:mm'),
                    JOB_TYPE_INDEX: '',
                    JOB_TYPE_ID: '',
                    JOB_TYPE_NAME: '',
                    HOT_WORK_POSITION: '',
                    HOT_WORK_METHOD_INDEX: '',
                    DICTIONARIES_ID: '',
                    HOT_WORK_METHOD_ID: [],
                    HOT_WORK_METHOD_NAME: '',
                    HOT_WORK_LEVEL_INDEX: '',
                    HOT_WORK_LEVEL_ID: '',
                    HOT_WORK_LEVEL_NAME: '',
                    HOT_WORK_APPLICATION_DEPARTMENT_ID: '',
                    HOT_WORK_APPLICATION_DEPARTMENT_NAME: '',
                    DEPARTMENT_PERSONNEL_INDEX: '',
                    DEPARTMENT_PERSONNEL_ID: '',
                    DEPARTMENT_PERSONNEL_NAME: '',
                    JOB_CONTENT: '',
                    SITE_LEADER_DEPARTMENT_ID: '',
                    SITE_LEADER_DEPARTMENT_NAME: '',
                    SITE_LEADER_INDEX: '',
                    SITE_LEADER_ID: '',
                    SITE_LEADER_NAME: '',
                    SITE_LEADER_PHONE: '',
                    SUPERVISOR_OF_HOT_WORK_UNIT: '',
                    HOT_WORK_TIME_START: '',
                    HOT_WORK_TIME_END: '',
                    WORK_LONGITUDE: '',
                    WORK_LATITUDE: '',
                    HOT_WORK_UNIT_LEADER_DEPARTMENT_ID: '',
                    HOT_WORK_UNIT_LEADER_DEPARTMENT_NAME: '',
                    HOT_WORK_UNIT_LEADER_INDEX: '',
                    HOT_WORK_UNIT_LEADER_ID: '',
                    HOT_WORK_UNIT_LEADER_NAME: '',
                    HOT_WORK_UNIT_LEADER_PHONE: '',
                    UNIT_LEADER_DEPARTMENT_ID: '',
                    UNIT_LEADER_DEPARTMENT_NAME: '',
                    UNIT_LEADER_INDEX: '',
                    UNIT_LEADER_ID: '',
                    UNIT_LEADER_NAME: '',
                    UNIT_LEADER_PHONE: '',
                    PROJECT_UNIT_LEADER_DEPARTMENT_ID: '',
                    PROJECT_UNIT_LEADER_DEPARTMENT_NAME: '',
                    PROJECT_UNIT_LEADER_INDEX: '',
                    PROJECT_UNIT_LEADER_ID: '',
                    PROJECT_UNIT_LEADER_NAME: '',
                    PROJECT_UNIT_LEADER_PHONE: '',
                    HOT_WORK_PERMIT_ISSUING_UNIT: '',
                    HOT_WORK_OPERATOR_ID: [],
                    HOT_WORK_OPERATOR_NAME: [],
                    LEADER_DEPARTMENT_ID: '',
                    LEADER_DEPARTMENT_NAME: '',
                    LEADER_USER_ID: '',
                    LEADER_USER_NAME: '',
                    LEADER_USER_PHONE: '',
                    LEADER_USER_INDEX: '',
                    HOT_WORK_DEPARTMENT_ID: '',
                    HOT_WORK_DEPARTMENT_NAME: '',
                    HOT_WORK_PERSONNEL_INDEX: '',
                    HOT_WORK_USER_ID: '',
                    HOT_WORK_USER_NAME: '',
                    IS_SAFETY_DIRECTOR: '0',
                    SAFETY_DIRECTOR_DEPARTMENT_ID: '',
                    SAFETY_DIRECTOR_DEPARTMENT_NAME: '',
                    SAFETY_DIRECTOR_INDEX: '',
                    SAFETY_DIRECTOR_USER_ID: '',
                    SAFETY_DIRECTOR_USER_NAME: '',
                    SAFETY_DIRECTOR_PHONE: '',
                    IS_GAS_TESTING: '0',
                    GAS_TESTING_DEPARTMENT_ID: '',
                    GAS_TESTING_DEPARTMENT_NAME: '',
                    GAS_TESTING_INDEX: '',
                    GAS_TESTING_USER_ID: '',
                    GAS_TESTING_USER_NAME: '',
                    GAS_TESTING_USER_PHONE: '',
                    ISSUING_DEPARTMENT_ID: '',
                    ISSUING_DEPARTMENT_NAME: '',
                    ISSUING_INDEX: '',
                    ISSUING_USER_ID: '',
                    ISSUING_USER_NAME: '',
                    ISSUING_USER_PHONE: '',
                    CHARGECONFIRM_DEPT_ID: '',
                    CHARGECONFIRM_DEPT_NAME: '',
                    CHARGECONFIRM_USER_NAME: '',
                    CHARGECONFIRM_USER_ID: '',
                    CHARGECONFIRM_INDEX: '',
                    CHARGECONFIRM_PHONE: '',
                },
                rules: [
                    {name: 'APPLY_DEPARTMENT_NAME', message: '请输入申请单位'},
                    {name: 'APPLY_USER_NAME', message: '请输入申请办理人'},
                    {name: 'JOB_NUMBER', message: '请输入作业编号'},
                    {name: 'APPLICATION_DATE', message: '请选择申请日期'},
                    {name: 'JOB_TYPE_INDEX', message: '请选择作业类型'},
                    {name: 'HOT_WORK_POSITION', message: '请输入动火部位'},
                    {name: 'HOT_WORK_METHOD_ID', message: '请选择动火方法'},
                    {name: 'HOT_WORK_LEVEL_ID', message: '请选择动火等级'},
                    {name: 'JOB_CONTENT', message: '请输入作业内容'},
                    {name: 'HOT_WORK_TIME_START', message: '请选择动火开始时间'},
                    {name: 'HOT_WORK_TIME_END', message: '请选择动火结束时间'},
                    {name: 'SUPERVISOR_OF_HOT_WORK_UNIT', message: '请输入动火监火人'},
                ],
                treeNode: [],
                forbidEdit: false,
                todayDate: formatDate(new Date(), 'yyyy-MM-dd hh:mm'),
                endTime: "",
                jobTypeList: [
                    {id: '0', name: '内部作业'},
                    {id: '1', name: '相关方作业'},
                ],
                hotWorkMethodList: [],
                hotWorkLevelList: [
                    {id: '0', name: '特级'},
                    {id: '1', name: '一级'},
                    {id: '2', name: '二级'},
                    {id: '3', name: '三级'},
                ],
                SPECIALUSER_ID: '',
                hotWorkUserList: [],
                departmentPersonnelList: [],
                siteLeaderList: [],
                hotWorkUnitLeaderList: [],
                unitLeaderList: [],
                hotWorkLssuedLisr: [],
                projectUnitLeaderList: [],
                chargeConfirmList: [],
                issunigUserList: [],
                hotWorkOperatorDepartmentList: [],
                safetyDirectorList: [],
                gasTestingList: [],
                cityIndex: 0,
                showAddOther: false,
                other: [],
                otherUserList: [],
                addModal: false,
                addOtherInput: {
                    DEPTNAME: '',
                    USERNAME: '',
                    userImgList: [],
                    cardImgList: []
                },
                addSpecial: false,
                addSpecialInput: {
                    DEPTNAME: '',
                    USERNAME: '',
                    userImgList: [],
                    cardImgList: []
                },
                temID: '',
				OLD_HOT_WORK_OPERATOR_ID: [],
				OLD_HOT_WORK_OPERATOR_NAME: [],
				otherUserNameList:[],
				repulseList: [],
                oldOtherMeasure:[],
                otherMeasure: [],
            }
        },
        async onLoad(event) {
            if (event.id) {
                this.form.HOTWORKAPPLICATION_ID = event.id
                await this.getHotWorkMethodList()
                this.getData();
            } else {
                // 初始化作业负责人
                this.form.APPLY_DEPARTMENT_ID = loginUser.DEPARTMENT_ID;
                this.form.APPLY_DEPARTMENT_NAME = loginUser.DEPARTMENT_NAME;
                this.form.APPLY_USER_ID = loginUser.USER_ID;
                this.form.APPLY_USER_NAME = loginUser.NAME;
                // this.form.SITE_LEADER_PHONE = loginUser.USERNAME;
                this.getHotJobNumber()
                await this.getHotWorkMethodList()
            }
            loginSession();
            this.getDept()
        },
        methods: {
            getHotJobNumber(){
                var _this = this;
                uni.showLoading({
                    title: '请稍候'
                })
                uni.request({
                    url: basePath + '/app/hotworkapplication/addHotJobNumber',
                    method: 'POST',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        CORPINFO_ID: corpinfoId,
                    },
                    success: (res) => {
                        uni.hideLoading();
                        if ("success" == res.data.result) {
                            _this.form.JOB_NUMBER =  res.data.JOB_NUMBER

                        } else if ("error" == res.data.result) {
                            uni.showToast({
                                title: res.data.msg,
                                duration: 2000
                            });
                        }

                    }
                });
            },
            getData() {
                var _this = this;
                uni.showLoading({
                    title: '请稍候'
                })
                uni.request({
                    url: basePath + '/app/hotworkapplication/goEdit',
                    method: 'POST',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        HOTWORKAPPLICATION_ID: _this.form.HOTWORKAPPLICATION_ID,
                    },
                    success: (res) => {
                        if ("success" == res.data.result) {
                            this.form = res.data.pd;
                            let HOT_WORK_OPERATOR_NAME = res.data.pd.specialUserName
							if(HOT_WORK_OPERATOR_NAME && HOT_WORK_OPERATOR_NAME.length > 0){
								this.form.HOT_WORK_OPERATOR_NAME = HOT_WORK_OPERATOR_NAME.substring(0, HOT_WORK_OPERATOR_NAME.length - 1).split(',');
							}
							let HOT_WORK_OPERATOR_ID = res.data.pd.specialUserId
							if(HOT_WORK_OPERATOR_ID && HOT_WORK_OPERATOR_ID.length > 0){
								this.form.HOT_WORK_OPERATOR_ID = HOT_WORK_OPERATOR_ID.substring(0, HOT_WORK_OPERATOR_ID.length - 1).split(',');
							}
							this.other = res.data.pd.specialUserList
							this.showAddOther = true
                            // this.msg = 'edit';
							if (res.data.pd.STATE === -1 || res.data.pd.STATE === -2 || res.data.pd.STATE === -5 || res.data.pd.STATE === -7){
								this.forbidEdit = false
							}else {
								this.forbidEdit = true;
							}
							this.initUserList()
                            if(res.data.pd.STATE != -7 && !this.forbidEdit){  //不是撤回状态不加编号
                                this.getHotJobNumber()
                            }
                            let HOT_WORK_METHOD_ID = res.data.pd.HOT_WORK_METHOD_ID
                            this.form.HOT_WORK_METHOD_ID = HOT_WORK_METHOD_ID.split(",")
                            console.log(this.form.HOT_WORK_METHOD_ID)
                            console.log(this.hotWorkMethodList)
							this.repulseList = res.data.repulseList
							uni.hideLoading();
                        } else if ("exception" == res.data.result) {
                            uni.showToast({
                                title: '错误',
                                duration: 2000
                            });
                        }
                    }
                });
            },
			// 初始化用户列表
			initUserList(){
				if(this.form.HOT_WORK_DEPARTMENT_ID){
					this.getUserList("hotWorkUserList", this.form.HOT_WORK_DEPARTMENT_ID);
				}
				if(this.form.PROJECT_UNIT_LEADER_DEPARTMENT_ID){
					this.getUserList("projectUnitLeaderList", this.form.PROJECT_UNIT_LEADER_DEPARTMENT_ID);
				}
				if(this.form.SAFETY_DIRECTOR_DEPARTMENT_ID){
					this.getUserList("safetyDirectorList", this.form.SAFETY_DIRECTOR_DEPARTMENT_ID);
				}
				if(this.form.GAS_TESTING_DEPARTMENT_ID){
					this.getUserList("gasTestingList", this.form.GAS_TESTING_DEPARTMENT_ID);
				}
				if(this.form.ISSUING_DEPARTMENT_ID){
					this.getUserList("issunigUserList", this.form.ISSUING_DEPARTMENT_ID);
				}
				if(this.form.HOT_WORK_APPLICATION_DEPARTMENT_ID){
					this.getUserList("departmentPersonnelList", this.form.HOT_WORK_APPLICATION_DEPARTMENT_ID);
				}
				if(this.form.SITE_LEADER_DEPARTMENT_ID){
					this.getUserList("siteLeaderList", this.form.SITE_LEADER_DEPARTMENT_ID);
				}
				if(this.form.HOT_WORK_UNIT_LEADER_DEPARTMENT_ID){
					this.getUserList("hotWorkUnitLeaderList", this.form.HOT_WORK_UNIT_LEADER_DEPARTMENT_ID);
				}
				if(this.form.UNIT_LEADER_DEPARTMENT_ID){
					this.getUserList("unitLeaderList", this.form.UNIT_LEADER_DEPARTMENT_ID);
				}
				if(this.form.LEADER_DEPARTMENT_ID){
					this.getUserList("hotWorkLssuedLisr", this.form.LEADER_DEPARTMENT_ID);
				}
				if(this.form.CHARGECONFIRM_DEPT_ID){
					this.getUserList("chargeConfirmList", this.form.CHARGECONFIRM_DEPT_ID);
				}
			},
            haveUser(e) {
                console.log(e)
                this.addSpecial = true
            },
            goSubmit(STATUS) {
                if(this.form.STATE === -7){
                    STATUS = -7
                }
                var _this = this;
                let required = true
				if(!_this.form.WORK_LONGITUDE||!_this.form.WORK_LATITUDE){
					uni.showToast({
					    title:'请选择地图，确认经纬度',
					    icon:'none'
					})
					return;
				}
                if(this.form.HOT_WORK_METHOD_ID != '' ||this.form.HOT_WORK_METHOD_ID.length==0){
                    uni.showToast({
                        title:'请选择动火方法',
                        icon:'none'
                    })
                    return;
                }
                if (STATUS == 1) {
                    this.rules.map(({name, message}) => {
                        if (this.form[name] == '' || this.form[name] == '请选择') {
                            uni.showToast({
                                icon: 'none',
                                title: message,
                                duration: 1500
                            });
                            required = false
                            return
                        }
                    })
                    let startTime = this.form.HOT_WORK_TIME_START
                    let endTime = this.form.HOT_WORK_TIME_END
                    let timeStamp = 86400000 * 3
                    if(new Date(endTime).getTime() - new Date(startTime).getTime() > timeStamp){
                        uni.showToast({
                            title:'动火结束时间不能大于动火开始时间三天',
                            icon:'none'
                        })
                        return;
                    }
					if(new Date(this.form.HOT_WORK_TIME_START.replace(/-/g,'/')) > new Date(this.form.HOT_WORK_TIME_END.replace(/-/g,'/'))){
						uni.showToast({
						    icon: 'none',
						    title: '动火结束时间应在动火开始结束时间之后',
						    duration: 1500
						});
						required = false
					}
                    if (this.form.HOT_WORK_USER_ID == '') {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择动火确认人',
                            duration: 1500
                        });
                        required = false
                    }
                    if (this.form.JOB_TYPE_INDEX =='1' && this.form.HOT_WORK_USER_ID == '') {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择项目发包人',
                            duration: 1500
                        });
                        required = false
                    }
                    if (this.form.SITE_LEADER_ID == '') {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择现场负责人',
                            duration: 1500
                        });
                        required = false
                    }
                  if (this.form.SITE_LEADER_ID == '') {
                    uni.showToast({
                      icon: 'none',
                      title: '请选择现场管辖负责人',
                      duration: 1500
                    });
                    required = false
                  }

                  if (this.form.ISSUING_USER_ID == '') {
                    uni.showToast({
                      icon: 'none',
                      title: '请选择动火许可证签发负责人',
                      duration: 1500
                    });
                    required = false
                  }
                    if (this.form.IS_SAFETY_DIRECTOR == '1' && this.form.SAFETY_DIRECTOR_USER_ID =='') {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择动安全总监',
                            duration: 1500
                        });
                        required = false
                    }
                    if (this.form.IS_GAS_TESTING == '1' &&  this.form.GAS_TESTING_USER_ID =='') {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择气体检测人员',
                            duration: 1500
                        });
                        required = false
                    }
                    console.info(this.other)
                    if (this.other.length === 0) {
                        uni.showToast({
                            icon: 'none',
                            title: '请选择动火操作人',
                            duration: 1500
                        });
                        required = false
                    }
                    if (this.form.HOT_WORK_METHOD_NAME == '电焊') {
                        if (!this.form.HOT_WORK_OPERATOR_ID || this.form.HOT_WORK_OPERATOR_ID.length === 0) {
                            uni.showToast({
                                icon: 'none',
                                title: '请选择特种作业动火操作人',
                                duration: 1500
                            });
                        }
                    }
                    if (!required) {
                        return
                    }
                }
                var operatorUser = ''
                _this.other.forEach((item) => {
                    operatorUser += item.USER_ID + ';'
                    // operatorUser += item.
                })
                uni.showLoading({
                    title: '请稍候'
                })
                if(STATUS == 1){  //打回走的提交
                    uni.request({
                        url: basePath + "/app/hotworkapplication/" + _this.msg,
                        method: 'POST',
                        dataType: 'json',
                        header: {
                            'Content-type': 'application/x-www-form-urlencoded'
                        },
                        // mode.forEach((item) => {
                        //   modestr += (item + '-' + type + ',')
                        // })

                        data: {
                            ...this.form,
                            STATUS,
                            CORPINFO_ID: corpinfoId,
                            operatorUser: operatorUser,
                            loginUserId: loginUserId,
                            OTHERMEASURE: _this.otherMeasure.join(","),
                        },
                        success: (res) => {
                            uni.showToast({
                                icon: 'none',
                                title: '保存成功',
                                duration: 2000
                            });
                            _this.goback()
                        },
                        fail: (err) => {
                            uni.hideLoading();
                            uni.showModal({
                                content: err.errMsg,
                                showCancel: false
                            });
                        }
                    })
                }
                if(STATUS === -7){  //撤回走的提交
                    let startTime = this.form.HOT_WORK_TIME_START
                    let endTime = this.form.HOT_WORK_TIME_END
                    let timeStamp = 86400000 * 3
                    if(new Date(endTime).getTime() - new Date(startTime).getTime() > timeStamp){
                        uni.showToast({
                            title:'动火结束时间不能大于动火开始时间三天',
                            icon:'none'
                        })
                        return;
                    }
                    uni.request({
                        url: basePath + "/app/hotworkapplication/recallEdit",
                        method: 'POST',
                        dataType: 'json',
                        header: {
                            'Content-type': 'application/x-www-form-urlencoded'
                        },
                        // mode.forEach((item) => {
                        //   modestr += (item + '-' + type + ',')
                        // })

                        data: {
                            ...this.form,
                            STATUS,
                            CORPINFO_ID: corpinfoId,
                            operatorUser: operatorUser,
                            loginUserId: loginUserId,
                            OTHERMEASURE: _this.otherMeasure.join(","),
                        },
                        success: (res) => {
                            uni.showToast({
                                icon: 'none',
                                title: '保存成功',
                                duration: 2000
                            });
                            _this.goback()
                        },
                        fail: (err) => {
                            uni.hideLoading();
                            uni.showModal({
                                content: err.errMsg,
                                showCancel: false
                            });
                        }
                    })
                }

            },
            hotWorkChange(e) {
				this.$set(this.form,'HOT_WORK_USER_NAME', this.hotWorkUserList[e.detail.value].NAME);
				this.$set(this.form,'HOT_WORK_USER_ID', this.hotWorkUserList[e.detail.value].USER_ID);
				this.$set(this.form,'HOT_WORK_USER_PHONE', this.hotWorkUserList[e.detail.value].USERNAME);
                // this.form.HOT_WORK_USER_NAME = this.hotWorkUserList[e.detail.value].NAME
                // this.form.HOT_WORK_USER_ID = this.hotWorkUserList[e.detail.value].USER_ID
                // this.form.HOT_WORK_USER_PHONE = this.hotWorkUserList[e.detail.value].USERNAME
            },

            jobTypeChange(e) {
				this.$set(this.form,'JOB_TYPE_INDEX', this.jobTypeList[e.detail.value].id);
				this.$set(this.form,'JOB_TYPE_NAME', this.jobTypeList[e.detail.value].name);
				this.$set(this.form,'JOB_TYPE_ID', this.jobTypeList[e.detail.value].id);
                // this.form.JOB_TYPE_INDEX = e.detail.value
                // this.form.JOB_TYPE_NAME = this.jobTypeList[e.detail.value].name
                // this.form.JOB_TYPE_ID = this.jobTypeList[e.detail.value].id
            },
            hotWorkMethodChange(val) {
                console.log(val)
                this.$set(this.form,'form.HOT_WORK_METHOD_ID',val)
				// this.$set(this.form,'HOT_WORK_METHOD_INDEX', e.detail.value);
				// this.$set(this.form,'HOT_WORK_METHOD_NAME', this.hotWorkMethodList[e.detail.value].NAME);
				// this.$set(this.form,'HOT_WORK_METHOD_ID', this.hotWorkMethodList[e.detail.value].DICTIONARIES_ID);
                // this.form.HOT_WORK_METHOD_INDEX = e.detail.value
                // this.form.HOT_WORK_METHOD_NAME = this.hotWorkMethodList[e.detail.value].NAME
                // this.form.HOT_WORK_METHOD_ID = this.hotWorkMethodList[e.detail.value].DICTIONARIES_ID
            },
            hotWorkLevelChange(e) {
                if(this.form.HOTWORKAPPLICATION_ID && e.detail.value !== 0){
                    this.form.CHARGECONFIRM_USER_ID = ''
                    console.log(this.form.CHARGECONFIRM_USER_ID)
                }
				this.$set(this.form,'HOT_WORK_LEVEL_INDEX', e.detail.value);
				this.$set(this.form,'HOT_WORK_LEVEL_NAME', this.hotWorkLevelList[e.detail.value].name);
				this.$set(this.form,'HOT_WORK_LEVEL_ID', this.hotWorkLevelList[e.detail.value].id);
                // this.form.HOT_WORK_LEVEL_INDEX = e.detail.value
                // this.form.HOT_WORK_LEVEL_NAME = this.hotWorkLevelList[e.detail.value].name
                // this.form.HOT_WORK_LEVEL_ID = this.hotWorkLevelList[e.detail.value].id
            },
            departmentPersonnelChange(e) {
				this.$set(this.form,'DEPARTMENT_PERSONNEL_INDEX', e.detail.value);
				this.$set(this.form,'DEPARTMENT_PERSONNEL_ID', this.departmentPersonnelList[e.detail.value].USER_ID);
				this.$set(this.form,'DEPARTMENT_PERSONNEL_NAME', this.departmentPersonnelList[e.detail.value].NAME);
                // this.form.DEPARTMENT_PERSONNEL_INDEX = e.detail.value;
                // this.form.DEPARTMENT_PERSONNEL_ID = this.departmentPersonnelList[e.detail.value].USER_ID;
                // this.form.DEPARTMENT_PERSONNEL_NAME = this.departmentPersonnelList[e.detail.value].NAME;
            },
            siteLeaderChange(e) {
				this.$set(this.form,'SITE_LEADER_INDEX', e.detail.value);
				this.$set(this.form,'SITE_LEADER_ID', this.siteLeaderList[e.detail.value].USER_ID);
				this.$set(this.form,'SITE_LEADER_NAME', this.siteLeaderList[e.detail.value].NAME);
				this.$set(this.form,'SITE_LEADER_PHONE', this.siteLeaderList[e.detail.value].USERNAME);
                // this.form.SITE_LEADER_INDEX = e.detail.value;
                // this.form.SITE_LEADER_ID = this.siteLeaderList[e.detail.value].USER_ID;
                // this.form.SITE_LEADER_NAME = this.siteLeaderList[e.detail.value].NAME;
                // this.form.SITE_LEADER_PHONE = this.siteLeaderList[e.detail.value].USERNAME;
            },
            hotWorkUnitLeaderChange(e) {
				this.$set(this.form,'HOT_WORK_UNIT_LEADER_INDEX', e.detail.value);
				this.$set(this.form,'HOT_WORK_UNIT_LEADER_ID', this.hotWorkUnitLeaderList[e.detail.value].USER_ID);
				this.$set(this.form,'HOT_WORK_UNIT_LEADER_NAME', this.hotWorkUnitLeaderList[e.detail.value].NAME);
				this.$set(this.form,'HOT_WORK_UNIT_LEADER_PHONE', this.hotWorkUnitLeaderList[e.detail.value].USERNAME);
                // this.form.HOT_WORK_UNIT_LEADER_INDEX = e.detail.value;
                // this.form.HOT_WORK_UNIT_LEADER_ID = this.hotWorkUnitLeaderList[e.detail.value].USER_ID;
                // this.form.HOT_WORK_UNIT_LEADER_NAME = this.hotWorkUnitLeaderList[e.detail.value].NAME;
                // this.form.HOT_WORK_UNIT_LEADER_PHONE = this.hotWorkUnitLeaderList[e.detail.value].USERNAME;
            },
            unitLeaderChange(e) {
				this.$set(this.form,'UNIT_LEADER_INDEX', e.detail.value);
				this.$set(this.form,'UNIT_LEADER_ID', this.unitLeaderList[e.detail.value].USER_ID);
				this.$set(this.form,'UNIT_LEADER_NAME', this.unitLeaderList[e.detail.value].NAME);
				this.$set(this.form,'UNIT_LEADER_PHONE', this.unitLeaderList[e.detail.value].USERNAME);
                // this.form.UNIT_LEADER_INDEX = e.detail.value;
                // this.form.UNIT_LEADER_ID = this.unitLeaderList[e.detail.value].USER_ID;
                // this.form.UNIT_LEADER_NAME = this.unitLeaderList[e.detail.value].NAME;
                // this.form.UNIT_LEADER_PHONE = this.unitLeaderList[e.detail.value].USERNAME;
            },
/*            hotWorkLeaderLeaderChange(e) {
				this.$set(this.form,'HOT_WORK_UNIT_LEADER_INDEX', e.detail.value);
				this.$set(this.form,'LEADER_USER_ID', this.hotWorkLssuedLisr[e.detail.value].USER_ID);
				this.$set(this.form,'LEADER_USER_NAME', this.hotWorkLssuedLisr[e.detail.value].NAME);
				this.$set(this.form,'HOT_WORK_DEPARTMENT_PHONE', this.hotWorkLssuedLisr[e.detail.value].USERNAME);
                // this.form.HOT_WORK_UNIT_LEADER_INDEX = e.detail.value;
                // this.form.LEADER_USER_ID = this.hotWorkLssuedLisr[e.detail.value].USER_ID;
                // this.form.LEADER_USER_NAME = this.hotWorkLssuedLisr[e.detail.value].NAME;
                // this.form.HOT_WORK_DEPARTMENT_PHONE = this.hotWorkLssuedLisr[e.detail.value].USERNAME;
            }, */
            projectUnitLeaderChange(e) {
				this.$set(this.form,'PROJECT_UNIT_LEADER_INDEX', e.detail.value);
				this.$set(this.form,'PROJECT_UNIT_LEADER_ID', this.projectUnitLeaderList[e.detail.value].USER_ID);
				this.$set(this.form,'PROJECT_UNIT_LEADER_NAME', this.projectUnitLeaderList[e.detail.value].NAME);
				this.$set(this.form,'PROJECT_UNIT_LEADER_PHONE', this.projectUnitLeaderList[e.detail.value].USERNAME);
                // this.form.PROJECT_UNIT_LEADER_INDEX = e.detail.value;
                // this.form.PROJECT_UNIT_LEADER_ID = this.projectUnitLeaderList[e.detail.value].USER_ID;
                // this.form.PROJECT_UNIT_LEADER_NAME = this.projectUnitLeaderList[e.detail.value].NAME;
                // this.form.PROJECT_UNIT_LEADER_PHONE = this.projectUnitLeaderList[e.detail.value].USERNAME;
            },
            safetyDirectorChange(e) {
				this.$set(this.form,'SAFETY_DIRECTOR_INDEX', e.detail.value);
				this.$set(this.form,'SAFETY_DIRECTOR_USER_ID', this.safetyDirectorList[e.detail.value].USER_ID);
				this.$set(this.form,'SAFETY_DIRECTOR_USER_NAME', this.safetyDirectorList[e.detail.value].NAME);
				this.$set(this.form,'SAFETY_DIRECTOR_PHONE', this.safetyDirectorList[e.detail.value].USERNAME);
            //     this.form.SAFETY_DIRECTOR_INDEX = e.detail.value;
            //     this.form.SAFETY_DIRECTOR_USER_ID = this.safetyDirectorList[e.detail.value].USER_ID;
            //     this.form.SAFETY_DIRECTOR_USER_NAME = this.safetyDirectorList[e.detail.value].NAME;
            //     this.form.SAFETY_DIRECTOR_PHONE = this.safetyDirectorList[e.detail.value].USERNAME;

            // this.$forceUpdate()
			},
            gasTestingChange(e) {

				this.$set(this.form,'GAS_TESTING_INDEX', e.detail.value);
				this.$set(this.form,'GAS_TESTING_USER_ID', this.gasTestingList[e.detail.value].USER_ID);
				this.$set(this.form,'GAS_TESTING_USER_NAME', this.gasTestingList[e.detail.value].NAME);
				this.$set(this.form,'GAS_TESTING_USER_PHONE', this.gasTestingList[e.detail.value].USERNAME);
                // this.form.GAS_TESTING_INDEX = e.detail.value;
                // this.form.GAS_TESTING_USER_ID = this.gasTestingList[e.detail.value].USER_ID;
                // this.form.GAS_TESTING_USER_NAME = this.gasTestingList[e.detail.value].NAME;
                // this.form.GAS_TESTING_USER_PHONE = this.gasTestingList[e.detail.value].USERNAME;
            },
            issungChange(e) {
				this.$set(this.form,'ISSUING_INDEX', e.detail.value);
				this.$set(this.form,'ISSUING_USER_ID', this.issunigUserList[e.detail.value].USER_ID);
				this.$set(this.form,'ISSUING_USER_NAME', this.issunigUserList[e.detail.value].NAME);
				this.$set(this.form,'ISSUING_USER_PHONE', this.issunigUserList[e.detail.value].USERNAME);
                // this.form.ISSUING_INDEX = e.detail.value;
                // this.form.ISSUING_USER_ID = this.issunigUserList[e.detail.value].USER_ID;
                // this.form.ISSUING_USER_NAME = this.issunigUserList[e.detail.value].NAME;
                // this.form.ISSUING_USER_PHONE = this.issunigUserList[e.detail.value].USERNAME;
            },
            chargeConfirmChange(e) {
				this.$set(this.form,'CHARGECONFIRM_INDEX', e.detail.value);
				this.$set(this.form,'CHARGECONFIRM_USER_ID', this.chargeConfirmList[e.detail.value].USER_ID);
				this.$set(this.form,'CHARGECONFIRM_USER_NAME', this.chargeConfirmList[e.detail.value].NAME);
				this.$set(this.form,'CHARGECONFIRM_PHONE', this.chargeConfirmList[e.detail.value].USERNAME);
                // this.form.CHARGECONFIRM_INDEX = e.detail.value;
                // this.form.CHARGECONFIRM_USER_ID = this.chargeConfirmList[e.detail.value].USER_ID;
                // this.form.CHARGECONFIRM_USER_NAME = this.chargeConfirmList[e.detail.value].NAME;
                // this.form.CHARGECONFIRM_PHONE = this.chargeConfirmList[e.detail.value].USERNAME;
            },
            hotWorkOperatorSelectShow() {
				this.OLD_HOT_WORK_OPERATOR_ID = this.form.HOT_WORK_OPERATOR_ID.map((value, index, array) => {
					return value;
				})
				this.OLD_HOT_WORK_OPERATOR_NAME = this.form.HOT_WORK_OPERATOR_NAME.map((value, index, array) => {
					return value;
				})
				// this.OLD_HOT_WORK_OPERATOR_NAME = this.form.HOT_WORK_OPERATOR_NAME
                this.$refs.cityMore.open();
            },
            hotWorkOperatorSelectHide(type) {
				console.info(this.OLD_HOT_WORK_OPERATOR_ID)
				if(type == 'query'){
					var _this = this
					var copyother = _this.other
					_this.other = []
					for (let i = 0; i < copyother.length; i++) {
						if (copyother[i].USER_TYPE && copyother[i].USER_TYPE != '1') {
							_this.other.push(copyother[i]);
						}
					}
					for (let i = 0; i < _this.form.HOT_WORK_OPERATOR_ID.length; i++) {
						let o = {
							"USER_TYPE": '1',
							"USER_ID": this.form.HOT_WORK_OPERATOR_ID[i],
							"USER_NAME": this.form.HOT_WORK_OPERATOR_NAME[i]
						};
						_this.other.push(o);
					}
				} else {

					this.form.HOT_WORK_OPERATOR_ID = this.OLD_HOT_WORK_OPERATOR_ID.map((value, index, array) => {
						return value;
					})
					this.form.HOT_WORK_OPERATOR_NAME = this.OLD_HOT_WORK_OPERATOR_NAME.map((value, index, array) => {
						return value;
					})
					// this.form.HOT_WORK_OPERATOR_ID = this.OLD_HOT_WORK_OPERATOR_ID
					// this.form.HOT_WORK_OPERATOR_NAME = this.OLD_HOT_WORK_OPERATOR_NAME
					// console.info(this.form.HOT_WORK_OPERATOR_ID)
				}
                this.$refs.cityMore.close();
            },
            switchCity(index) {
                this.cityIndex = index
            },
            chooseCity(item) { // 点击选择特种作业人员
                if (!this.form.HOT_WORK_OPERATOR_ID || this.form.HOT_WORK_OPERATOR_ID.indexOf(item.id) == -1) { // 如果没有找到匹配的字符串则返回 -1。
                    if(!this.form.HOT_WORK_OPERATOR_ID){
						this.$set(this.form,'HOT_WORK_OPERATOR_ID',[])
						// this.form.HOT_WORK_OPERATOR_ID = []
					}
					// 此处先存储起来再赋值，再强制刷新，否则组件不渲染

					let HOT_WORK_OPERATOR_ID = this.form.HOT_WORK_OPERATOR_ID
					let HOT_WORK_OPERATOR_NAME = this.form.HOT_WORK_OPERATOR_NAME
					HOT_WORK_OPERATOR_ID.push(item.id)
                    HOT_WORK_OPERATOR_NAME.push(item.name)
					this.form.HOT_WORK_OPERATOR_ID = [...HOT_WORK_OPERATOR_ID]
					this.form.HOT_WORK_OPERATOR_NAME = [...HOT_WORK_OPERATOR_NAME]
					this.$forceUpdate()
                } else {
					let HOT_WORK_OPERATOR_ID = this.form.HOT_WORK_OPERATOR_ID
					let HOT_WORK_OPERATOR_NAME = this.form.HOT_WORK_OPERATOR_NAME
                    HOT_WORK_OPERATOR_ID.splice(this.form.HOT_WORK_OPERATOR_ID.indexOf(item.id), 1)
                    HOT_WORK_OPERATOR_NAME.splice(this.form.HOT_WORK_OPERATOR_NAME.indexOf(item.name), 1)
					this.form.HOT_WORK_OPERATOR_ID = [...HOT_WORK_OPERATOR_ID]
					this.form.HOT_WORK_OPERATOR_NAME = [...HOT_WORK_OPERATOR_NAME]
					this.$forceUpdate()
				}
            },
            changeApplicationDate(e) {
                this.form.APPLICATION_DATE = e
            },
            changehotWorkTimeEnd(e) {
                this.form.HOT_WORK_TIME_END = e
            },
            changehotWorkTimeStart(e) {
                this.form.HOT_WORK_TIME_START = e
            },
            getDept() {
                var _this = this;
                uni.request({
                    url: basePath + '/app/sys/listTree', //部门下拉接口
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        CORPINFO_ID: corpinfoId,
                    },
                    success: (res) => {
                        if ("success" == res.data.result) {
                            _this.treeNode = eval(res.data.zTreeNodes);
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                });
                uni.request({
                    url: basePath + '/app/relevantunit/listAllTree',
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        CORPINFO_ID: corpinfoId,
                    },
                    success: (res) => {
                        if ("success" === res.data.result) {
                            _this.hotWorkOperatorDepartmentList = JSON.parse(res.data.varList);
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                });
            },
            getHotWorkMethodList(){
                return new Promise((resolve,reject)=>{
                    uni.request({
                        url: basePath + '/dictionaries/getLevels',
                        method: 'POST',
                        dataType: 'json',
                        header: {
                            'Content-type': 'application/x-www-form-urlencoded'
                        },
                        data: {
                            DICTIONARIES_ID: "63cf39931a89467594efc441bf67f6dd",
                        },
                        success: (res) => {
                            if ("success" === res.data.result) {
                                this.hotWorkMethodList = res.data.list
                                resolve()
                            } else {
                                uni.showToast({
                                    title: res.data.message,
                                    duration: 2000
                                });
                            }
                        }
                    });
                })
            },
            showZgTree(ref) {
                this.$refs[ref]._show();
            },
            zgtreeConfirm(e, list) {
				console.info(list)
                if (list === "hotWorkUserList") {
					this.$set(this.form,'HOT_WORK_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'HOT_WORK_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'HOT_WORK_PERSONNEL_INDEX', '');
					this.$set(this.form,'HOT_WORK_USER_ID', '');
					this.$set(this.form,'HOT_WORK_USER_NAME', '');
					this.$set(this.form,'HOT_WORK_USER_PHONE', '');
                    // this.form.HOT_WORK_DEPARTMENT_ID = e[0].id;
                    // this.form.HOT_WORK_DEPARTMENT_NAME = e[0].name;
                    // this.form.HOT_WORK_PERSONNEL_INDEX = '';
                    // this.form.HOT_WORK_USER_ID = '';
                    // this.form.HOT_WORK_USER_NAME = '';
                    // this.form.HOT_WORK_USER_PHONE = '';
                }
                if (list === "projectUnitLeaderList") {

					this.$set(this.form,'PROJECT_UNIT_LEADER_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'PROJECT_UNIT_LEADER_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'PROJECT_UNIT_LEADER_INDEX', '');
					this.$set(this.form,'PROJECT_UNIT_LEADER_ID', '');
					this.$set(this.form,'PROJECT_UNIT_LEADER_NAME', '');
					this.$set(this.form,'PROJECT_UNIT_LEADER_PHONE', '');
                    // this.form.PROJECT_UNIT_LEADER_DEPARTMENT_ID = e[0].id;
                    // this.form.PROJECT_UNIT_LEADER_DEPARTMENT_NAME = e[0].name;
                    // this.form.PROJECT_UNIT_LEADER_INDEX = '';
                    // this.form.PROJECT_UNIT_LEADER_ID = '';
                    // this.form.PROJECT_UNIT_LEADER_NAME = '';
                    // this.form.PROJECT_UNIT_LEADER_PHONE = '';

                }
                if (list === "safetyDirectorList") {
                    // this.form.SAFETY_DIRECTOR_DEPARTMENT_ID = e[0].id;
                    // this.form.SAFETY_DIRECTOR_DEPARTMENT_NAME = e[0].name;
                    // this.form.SAFETY_DIRECTOR_INDEX = '';
                    // this.form.SAFETY_DIRECTOR_USER_ID = '';
                    // this.form.SAFETY_DIRECTOR_USER_NAME = '';
                    // this.form.SAFETY_DIRECTOR_PHONE = '';
					this.$set(this.form,'SAFETY_DIRECTOR_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'SAFETY_DIRECTOR_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'SAFETY_DIRECTOR_INDEX', '');
					this.$set(this.form,'SAFETY_DIRECTOR_USER_ID', '');
					this.$set(this.form,'SAFETY_DIRECTOR_USER_NAME', '');
					this.$set(this.form,'SAFETY_DIRECTOR_PHONE', '');
                }

                if (list === "gasTestingList") {
					this.$set(this.form,'GAS_TESTING_DEPARTMENT_ID' , e[0].id);
					this.$set(this.form,'GAS_TESTING_DEPARTMENT_NAME' , e[0].name);
					this.$set(this.form,'GAS_TESTING_INDEX' , '');
					this.$set(this.form,'GAS_TESTING_USER_ID' , '');
					this.$set(this.form,'GAS_TESTING_USER_NAME' , '');
					this.$set(this.form,'GAS_TESTING_USER_PHONE' , '');
                    // this.form.GAS_TESTING_DEPARTMENT_ID = e[0].id;
                    // this.form.GAS_TESTING_DEPARTMENT_NAME = e[0].name;
                    // this.form.GAS_TESTING_INDEX = '';
                    // this.form.GAS_TESTING_USER_ID = '';
                    // this.form.GAS_TESTING_USER_NAME = '';
                    // this.form.GAS_TESTING_USER_PHONE = '';
                }
                if (list === "issunigUserList") {
					this.$set(this.form,'ISSUING_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'ISSUING_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'ISSUING_INDEX', '');
					this.$set(this.form,'ISSUING_USER_ID', '');
					this.$set(this.form,'ISSUING_USER_NAME', '');
					this.$set(this.form,'ISSUING_USER_PHONE', '');
                    // this.form.ISSUING_DEPARTMENT_ID = e[0].id;
                    // this.form.ISSUING_DEPARTMENT_NAME = e[0].name;
                    // this.form.ISSUING_INDEX = '';
                    // this.form.ISSUING_USER_ID = '';
                    // this.form.ISSUING_USER_NAME = '';
                    // this.form.ISSUING_USER_PHONE = '';
                }
                // ===================
                if (list === "departmentPersonnelList") {
					this.$set(this.form,'HOT_WORK_APPLICATION_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'HOT_WORK_APPLICATION_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'DEPARTMENT_PERSONNEL_INDEX', '');
					this.$set(this.form,'DEPARTMENT_PERSONNEL_ID', '');
					this.$set(this.form,'DEPARTMENT_PERSONNEL_NAME', '');
					this.$set(this.form,'DEPARTMENT_PERSONNEL_PHONE', '');
                    // this.form.HOT_WORK_APPLICATION_DEPARTMENT_ID = e[0].id;
                    // this.form.HOT_WORK_APPLICATION_DEPARTMENT_NAME = e[0].name;
                    // this.form.DEPARTMENT_PERSONNEL_INDEX = '';
                    // this.form.DEPARTMENT_PERSONNEL_ID = '';
                    // this.form.DEPARTMENT_PERSONNEL_NAME = '';
                    // this.form.DEPARTMENT_PERSONNEL_PHONE = '';
                }
                if (list === "siteLeaderList") {
					this.$set(this.form,'SITE_LEADER_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'SITE_LEADER_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'SITE_LEADER_INDEX', '');
					this.$set(this.form,'SITE_LEADER_ID', '');
					this.$set(this.form,'SITE_LEADER_NAME', '');
					this.$set(this.form,'SITE_LEADER_PHONE', '');
                    // this.form.SITE_LEADER_DEPARTMENT_ID = e[0].id;
                    // this.form.SITE_LEADER_DEPARTMENT_NAME = e[0].name;
                    // this.form.SITE_LEADER_INDEX = '';
                    // this.form.SITE_LEADER_ID = '';
                    // this.form.SITE_LEADER_NAME = '';
                    // this.form.SITE_LEADER_PHONE = '';
                }
                if (list === "hotWorkUnitLeaderList") {
					this.$set(this.form,'HOT_WORK_UNIT_LEADER_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'HOT_WORK_UNIT_LEADER_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'HOT_WORK_UNIT_LEADER_INDEX', '');
					this.$set(this.form,'HOT_WORK_UNIT_LEADER_ID', '');
					this.$set(this.form,'HOT_WORK_UNIT_LEADER_NAME', '');
					this.$set(this.form,'HOT_WORK_UNIT_LEADER_PHONE', '');
                    // this.form.HOT_WORK_UNIT_LEADER_DEPARTMENT_ID = e[0].id;
                    // this.form.HOT_WORK_UNIT_LEADER_DEPARTMENT_NAME = e[0].name;
                    // this.form.HOT_WORK_UNIT_LEADER_INDEX = '';
                    // this.form.HOT_WORK_UNIT_LEADER_ID = '';
                    // this.form.HOT_WORK_UNIT_LEADER_NAME = '';
                    // this.form.HOT_WORK_UNIT_LEADER_PHONE = '';
                }
                if (list === "unitLeaderList") {
					this.$set(this.form,'UNIT_LEADER_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'UNIT_LEADER_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'UNIT_LEADER_INDEX', '');
					this.$set(this.form,'UNIT_LEADER_ID', '');
					this.$set(this.form,'UNIT_LEADER_NAME', '');
					this.$set(this.form,'UNIT_LEADER_PHONE', '');
                    // this.form.UNIT_LEADER_DEPARTMENT_ID = e[0].id;
                    // this.form.UNIT_LEADER_DEPARTMENT_NAME = e[0].name;
                    // this.form.UNIT_LEADER_INDEX = '';
                    // this.form.UNIT_LEADER_ID = '';
                    // this.form.UNIT_LEADER_NAME = '';
                    // this.form.UNIT_LEADER_PHONE = '';
                }

                if (list === "hotWorkLssuedLisr") {
					this.$set(this.form,'LEADER_DEPARTMENT_ID', e[0].id);
					this.$set(this.form,'LEADER_DEPARTMENT_NAME', e[0].name);
					this.$set(this.form,'LEADER_USER_ID', '');
					this.$set(this.form,'LEADER_USER_NAME', '');
					this.$set(this.form,'LEADER_USER_PHONE', '');
                    // this.form.LEADER_DEPARTMENT_ID = e[0].id;
                    // this.form.LEADER_DEPARTMENT_NAME = e[0].name;
                    // this.form.LEADER_USER_ID = '';
                    // this.form.LEADER_USER_NAME = '';
                    // this.form.LEADER_USER_PHONE = '';
                }
                if (list === "chargeConfirmList") {
					this.$set(this.form,'CHARGECONFIRM_DEPT_ID', e[0].id);
					this.$set(this.form,'CHARGECONFIRM_DEPT_NAME', e[0].name);
					this.$set(this.form,'CHARGECONFIRM_USER_ID', '');
					this.$set(this.form,'CHARGECONFIRM_USER_NAME', '');
					this.$set(this.form,'CHARGECONFIRM_USER_PHONE', '');
					this.$set(this.form,'CHARGECONFIRM_INDEX', '');
                    // this.form.CHARGECONFIRM_DEPT_ID = e[0].id;
                    // this.form.CHARGECONFIRM_DEPT_NAME = e[0].name;
                    // this.form.CHARGECONFIRM_USER_ID = '';
                    // this.form.CHARGECONFIRM_USER_NAME = '';
                    // this.form.CHARGECONFIRM_USER_PHONE = '';
                    // this.form.CHARGECONFIRM_INDEX = '';
                }
				// this.$forceUpdate()
                this.getUserList(list, e[0].id);
            },
            getUserList(list, DEPARTMENT_ID) {
                //发送 post 请求
                var _this = this;
                uni.request({
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    url: basePath + '/app/sys/listUser',
                    data: {
                        DEPARTMENT_ID, NOMAIN: '1',
                        tm: new Date().getTime()
                    },
                    success: function (res) {
                        if ("success" == res.data.result) {
                            _this[list] = res.data.userList;
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                })
            },
            zgtreeCancel(e) {
                this.isUps = false;
            },
            chooseLocation() {
                var _this = this
                uni.navigateTo({
                    url: '/pages/map/mapPro',
                    events: {
                        // 为指定事件添加一个监听器，获取被打开页面传送到当前页面的数据
                        acceptDataFromOpenedPage: function (e) {
                            _this.form.WORK_LONGITUDE = e.data.longitue;
                            _this.form.WORK_LATITUDE = e.data.latitude;
                        }
                    },
                })
            },
            goback() {
                uni.navigateBack({
                    delta: 1
                });
                uni.hideLoading();
            },
            addOther() {
                this.showAddOther = true
            },
            removeOther(index) {
                var item = this.other[index]
                if (item.USER_TYPE === '1') {
                    this.form.HOT_WORK_OPERATOR_ID.splice(this.form.HOT_WORK_OPERATOR_ID.indexOf(item.USER_ID), 1)
                    this.form.HOT_WORK_OPERATOR_NAME.splice(this.form.HOT_WORK_OPERATOR_NAME.indexOf(item.USER_NAME), 1)
                } else { //删除临时人员
                    uni.request({
                        url: basePath + '/app/hotworkapplication/deleteTem',
                        method: 'POST',
                        dataType: 'json',
                        header: {
                            'Content-type': 'application/x-www-form-urlencoded'
                        },
                        data: {
                            "SPECIALUSER_ID": item.USER_ID,
                            "FOREIGN_KEY": item.USER_ID
                        },
                        success: (res) => {
                            if ("success" === res.data.result) {
                            } else {
                                uni.showToast({
                                    title: res.data.message,
                                    duration: 2000
                                });
                            }
                        }
                    });
                }
                this.other.splice(index, 1);
                this.otherUserList.splice(index, 1);
            },
            addOtherInputAdd() {
                this.addModal = true
                this.addOtherInput = {}
            },
            addOtherInputSubmit() {
                if (this.addOtherInput.USERNAME == '' || undefined == this.addOtherInput.USERNAME) {
                    uni.showToast({
                        icon: 'none',
                        title: '请输入姓名',
                        duration: 2000
                    });
                    return;
                }
                uni.request({
                    url: basePath + '/app/hotworkapplication/addTemUser',
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        "USER_TYPE": '4',
                        "USER_ID": '',
                        "TEM_USER_NAME": this.addOtherInput.USERNAME,
                        loginUserId: loginUserId,
                    },
                    success: (res) => {
                        if ("success" === res.data.result) {
                            let o = {
                                "SPECIALUSER_ID": res.data.pd.SPECIALUSER_ID,
                                "USER_TYPE": '4',
                                "USER_ID": res.data.pd.SPECIALUSER_ID,
                                "USER_NAME": this.addOtherInput.USERNAME
                            };
                            this.other.push(o);
                        } else {
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                });
                this.addModal = false
            },
            addSpecialInputAdd() {
                this.addSpecial = true
                this.addSpecialInput = {
                    DEPTNAME: '',
                    USERNAME: '',
                    userImgList: [],
                    cardImgList: []
                }
            },
            addSpecialInputSubmit() {
                if (this.addSpecialInput.DEPTNAME == '' || undefined == this.addSpecialInput.DEPTNAME) {
                    uni.showToast({
                        icon: 'none',
                        title: '请输入人员单位',
                        duration: 2000
                    });
                    return;
                }
                if (this.addSpecialInput.USERNAME == '' || undefined == this.addSpecialInput.USERNAME) {
                    uni.showToast({
                        icon: 'none',
                        title: '请输入人员姓名',
                        duration: 2000
                    });
                    return;
                }
                if (this.addSpecialInput.userImgList.length === 0) {
                    uni.showToast({
                        icon: 'none',
                        title: '请上传人员照片',
                        duration: 2000
                    });
                    return;
                }
                if (this.addSpecialInput.cardImgList.length === 0) {
                    uni.showToast({
                        icon: 'none',
                        title: '请上传证件照片',
                        duration: 2000
                    });
                    return;
                }
                //先上传人员信息
                uni.request({
                    url: basePath + '/app/hotworkapplication/addTemUser',
                    method: 'POST',
                    dataType: 'json',
                    header: {
                        'Content-type': 'application/x-www-form-urlencoded'
                    },
                    data: {
                        "USER_TYPE": '3',
                        "USER_ID": '',
                        "TEM_USER_NAME": this.addSpecialInput.USERNAME,
                        "TEM_USER_DEPT_NAME": this.addSpecialInput.DEPTNAME,
                        loginUserId: loginUserId,
                    },
                    success: (res) => {
                        if ("success" === res.data.result) {
                            //上传照片
                            this.uploadImg(this.addSpecialInput.userImgList, '201', res.data.pd.SPECIALUSER_ID)
                            this.uploadImg(this.addSpecialInput.cardImgList, '202', res.data.pd.SPECIALUSER_ID)
                            this.SPECIALUSER_ID = res.data.pd.SPECIALUSER_ID
                            let o = {
                                "USER_TYPE": '3',
                                "USER_ID": res.data.pd.SPECIALUSER_ID,
                                "USER_NAME": this.addSpecialInput.USERNAME,
                                "SPECIALUSER_ID": res.data.pd.SPECIALUSER_ID
                            };
                            this.other.push(o);

                        } else {
                            uni.showToast({
                                title: res.data.message,
                                duration: 2000
                            });
                        }
                    }
                });
                this.addSpecial = false
            },
            ChooseImageUser() {
                var _this = this;
                uni.chooseImage({
                    count: 1, //默认9
                    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['camera', 'album'], //从相册选择
                    success: (res) => {
                        if (this.addSpecialInput.userImgList.length != 0) {
                            this.addSpecialInput.userImgList = this.addSpecialInput.userImgList.concat(res.tempFilePaths)
                        } else {
                            this.addSpecialInput.userImgList = res.tempFilePaths
                        }
                    }
                });
            },
            ViewImageUser(e) {
                uni.previewImage({
                    urls: this.addSpecialInput.userImgList,
                    current: e.currentTarget.dataset.url
                });
            },
            DelImgUser(e) {
                uni.showModal({
                    title: '双控平台',
                    content: '确定要删除这张图片吗？',
                    cancelColor: "#000000",
                    cancelText: '取消',
                    confirmText: '确定',
                    success: res => {
                        if (res.confirm) {
                            this.addSpecialInput.userImgList.splice(e.currentTarget.dataset.index, 1)
                        }
                    }
                })
            },
            ChooseImageCard() {
                var _this = this;
                uni.chooseImage({
                    count: 1, //默认9
                    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['camera', 'album'], //从相册选择
                    success: (res) => {
                        if (this.addSpecialInput.cardImgList.length != 0) {
                            this.addSpecialInput.cardImgList = this.addSpecialInput.cardImgList.concat(res.tempFilePaths)
                        } else {
                            this.addSpecialInput.cardImgList = res.tempFilePaths
                        }
                    }
                });
            },
            ViewImageCard(e) {
                uni.previewImage({
                    urls: this.addSpecialInput.cardImgList,
                    current: e.currentTarget.dataset.url
                });
            },
            DelImgCard(e) {
                uni.showModal({
                    title: '双控平台',
                    content: '确定要删除这张图片吗？',
                    cancelColor: "#000000",
                    cancelText: '取消',
                    confirmText: '确定',
                    success: res => {
                        if (res.confirm) {
                            this.addSpecialInput.cardImgList.splice(e.currentTarget.dataset.index, 1)
                        }
                    }
                })
            },
            radioType(e) {
                this.form.IS_SAFETY_DIRECTOR = e.detail.value
            },
            radioType2(e) {
                this.form.IS_GAS_TESTING = e.detail.value
            },
            uploadImg(tempFilePaths, type, key) {
                return new Promise((resolve, reject) => {
                    var _this = this;
                    if (tempFilePaths.length == 0) {
                        resolve();
                    }
                    uni.showLoading({
                        title: '上传中'
                    })
                    uni.uploadFile({
                        url: basePath + '/app/imgfiles/add',
                        filePath: tempFilePaths[0],
                        name: 'FFILE',
                        formData: {
                            'TYPE': type,
                            'FOREIGN_KEY': key
                        },
                        success: (res) => {
                            uni.hideLoading();
                            resolve();
                        },
                        fail: (err) => {
                            uni.hideLoading();
                            uni.showModal({
                                content: err.errMsg,
                                showCancel: false
                            });
                        }
                    })
                })
            },
            //添加其他安全措施
            addQtcsOther(){
                var _this = this;
                let o = '';
                _this.otherMeasure.push(o);
            },
            //删除其他安全措施
            removeQtcsMeasure (i) {
                var _this = this;
                uni.showModal({
                    title: '提示',
                    cancelText: '确认',
                    confirmText: '取消',
                    content: '确定删除其他安全措施吗？',
                    success: function (res) {
                        if (res.cancel) {
                            _this.otherMeasure.splice(i, 1)
                        }
                    }
                });
            },
        }
    }
</script>

<style lang="scss" scoped>
    .right_icon {
        position: relative;
        padding-right: 36upx;
        width: 200upx;
        text-align: right;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    .right_icon ::after {
        font-family: cuIcon;
        display: block;
        content: "\e6a3";
        position: absolute;
        font-size: 17px;
        color: #8799a3;
        line-height: 50px;
        width: 30px;
        text-align: center;
        top: -28upx;
        bottom: 0;
        right: -22upx;
        margin: auto;
    }

    .modal_content {
        display: flex;
        text-align: left;
    }

    .modal_left {
        flex-basis: 50%;
        padding: 50upx 20upx;
        border-right: 1px solid #000000;
    }

    .modal_right {
        flex-basis: 50%;
        padding: 50upx;
    }

    .modal_left_title, .modal_right_title {
        font-size: 16px;
        color: #000000;
        font-weight: 700;
    }

    .checkbox-item {
        display: flex;
        align-items: center;
        padding: 0 30upx;
        min-height: 100upx;
        background-color: #ffffff;
        border-bottom: 1upx solid #ddd;
    }

    .checkbox-item:last-child {
        border-bottom: none;
    }

    .selected {
        display: flex;
        align-items: center;
        height: 100upx;
    }

    .selected .radio {
        transform: scale(0.8);
        margin-right: 10upx;
    }
    .bg-img{
      position: relative;
    }
    .cu-tag{
      position: absolute;
      right: 0;
      top: 0;
      border-bottom-left-radius: 3px;
      padding: 3px 6px;
      height: auto;
      background-color: rgba(0, 0, 0, 0.5);
    }
</style>
