1028 lines
39 KiB
Vue
1028 lines
39 KiB
Vue
<template>
|
||
<view class="content">
|
||
<view class="card">
|
||
<u-cell-group :border="false">
|
||
<u-cell>
|
||
<view slot="title" class="title required">检查题目:</view>
|
||
<view slot="value">
|
||
<u-radio-group v-model="form.inspectionSubject" placement="row" :disabled="disabled">
|
||
<u-radio label="安全" name="安全"></u-radio>
|
||
<u-radio label="环保" name="环保" class="ml-10"></u-radio>
|
||
<u-radio label="综合" name="综合" class="ml-10"></u-radio>
|
||
</u-radio-group>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">被检查单位:</view>
|
||
<view slot="value">
|
||
<text @click="showTree('tkitree')">
|
||
{{ disabled ? form.inspectedCorpName : form.inspectedDepartmentName || '请选择' }}
|
||
</text>
|
||
<tki-tree ref="tkitree" :range="inspectedDepartmentTreeList" rangeKey="name" selectParent
|
||
@confirm="confirmTree($event,'inspectedSiteuserColumns')"/>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell v-show="form.inspectedDepartmentName">
|
||
<view slot="title" class="title required">被检查单位现场负责人:</view>
|
||
<view slot="value">
|
||
<text @click="disabled ? null : inspectedSiteuserShow = true">{{
|
||
form.inspectedUserName || '请选择'
|
||
}}
|
||
</text>
|
||
<u-picker :show="inspectedSiteuserShow" :columns="inspectedSiteuserColumns" keyName="NAME"
|
||
@cancel="inspectedSiteuserShow = false"
|
||
@confirm="inspectedSiteuserConfirmPicker"></u-picker>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">检查场所:</view>
|
||
<view slot="value">
|
||
<u--input v-model="form.inspectionPlace" border="none" placeholder="请输入检查场所" inputAlign="right"
|
||
:disabled="disabled"></u--input>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">检查类型:</view>
|
||
<view slot="value">
|
||
<text @click="showTree('tkitree1')">{{ form.inspectionTypeName || '请选择' }}</text>
|
||
<tki-tree ref="tkitree1" :range="inspectionTypeTreeList" rangeKey="name" selectParent children-name="nodes"
|
||
@confirm="confirmTree($event,'inspectionTypeTreeList')"/>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">检查开始时间:</view>
|
||
<view slot="value">
|
||
<text @click="disabled ? null : inspectionTimeStartShow = true">{{
|
||
form.inspectionTimeStart || '请选择'
|
||
}}
|
||
</text>
|
||
<u-datetime-picker :show="inspectionTimeStartShow" :value="form.inspectionTimeStart"
|
||
@cancel="inspectionTimeStartShow = false"
|
||
@confirm="inspectionTimeStartConfirm"></u-datetime-picker>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">检查结束时间:</view>
|
||
<view slot="value">
|
||
<text @click="disabled ? null : inspectionTimeEndShow = true">{{
|
||
form.inspectionTimeEnd || '请选择'
|
||
}}
|
||
</text>
|
||
<u-datetime-picker :show="inspectionTimeEndShow" :value="form.inspectionTimeEnd"
|
||
@cancel="inspectionTimeEndShow = false"
|
||
@confirm="inspectionTimeEndConfirm"></u-datetime-picker>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell v-if="disabled">
|
||
<view slot="title" class="title required">记录填写时间:</view>
|
||
<view slot="value">
|
||
<text>{{ form.creattime }}</text>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title">检查情况:</view>
|
||
<view slot="value">
|
||
<u-button type="primary" text="添加" size="mini" @click="addSituation"
|
||
v-if="!disabled"></u-button>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="label">
|
||
<view class="pr mt-10 textarea-box" v-for="(item,index) in form.situations" :key="item.id">
|
||
<u--textarea v-model="item.situation" placeholder="请输入检查情况" :disabled="disabled"></u--textarea>
|
||
<u-badge value="X" type="error" :offset="[-9,-10]" absolute
|
||
@click.native="removeSituation(item,index)" v-if="!disabled"></u-badge>
|
||
</view>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title">检查人员:</view>
|
||
<view slot="value">
|
||
<u-button type="primary" text="添加" size="mini" @click="addInspector"
|
||
v-if="!disabled"></u-button>
|
||
</view>
|
||
</u-cell>
|
||
<view class="title-none">
|
||
<u-cell>
|
||
<view slot="value" style="width: 100%">
|
||
<view class="pr mt-10" v-for="(item,index) in form.inspectionUsers" :key="item.id">
|
||
<u-cell-group :border="false" class="border">
|
||
<view class="title-show">
|
||
<u-cell>
|
||
<view slot="title">{{ index + 1 }}.检查人员单位</view>
|
||
<view slot="value">
|
||
<text @click="showTree('tkitreeInspector' + index,'arr')">
|
||
{{ item.inspectionDepartmentName || '请选择' }}
|
||
</text>
|
||
<tki-tree :ref="'tkitreeInspector' + index" :range="inspectedDepartmentTreeList"
|
||
rangeKey="name"
|
||
selectParent @confirm="confirmTree($event,'inspectionUsers',index)"/>
|
||
</view>
|
||
</u-cell>
|
||
</view>
|
||
<view class="title-show">
|
||
<u-cell :border="false" v-show="item.inspectionDepartmentName">
|
||
<view slot="title">{{ index + 1 }}.检查人员</view>
|
||
<view slot="value">
|
||
<text @click="inspectionUserShowPicker(index)">{{
|
||
item.inspectionUserName || '请选择'
|
||
}}
|
||
</text>
|
||
<u-picker :show="item.inspectionUserShow" :columns="[inspectionUsers[0][index]]" keyName="NAME"
|
||
@cancel="item.inspectionUserShow = false"
|
||
@confirm="inspectionUserConfirmPicker($event,index)"></u-picker>
|
||
</view>
|
||
</u-cell>
|
||
</view>
|
||
</u-cell-group>
|
||
<u-badge value="X" type="error" :offset="[-9,-10]" absolute
|
||
@click.native="removeInspector(item,index)" v-if="!disabled"></u-badge>
|
||
</view>
|
||
</view>
|
||
</u-cell>
|
||
</view>
|
||
<u-cell>
|
||
<view slot="title" class="title">发现问题:</view>
|
||
<view slot="value">
|
||
<u-button type="primary" text="添加" size="mini" @click="addHidden"
|
||
v-if="!disabled"></u-button>
|
||
</view>
|
||
</u-cell>
|
||
<view class="title-none">
|
||
<u-cell>
|
||
<view slot="value" style="flex: 1">
|
||
<uni-table border stripe emptyText="暂无更多数据">
|
||
<uni-tr>
|
||
<uni-th align="center">序号</uni-th>
|
||
<uni-th align="center">隐患部位</uni-th>
|
||
<uni-th align="center">隐患描述</uni-th>
|
||
<uni-th align="center">操作</uni-th>
|
||
</uni-tr>
|
||
<uni-tr v-for="(item,index) in form.hiddenList" :key="item.hiddenId == null ? index : item.hiddenId">
|
||
<uni-td>{{ index + 1 }}</uni-td>
|
||
<uni-td>{{ item.hiddenPartStr ? item.hiddenPartStr : item.hiddenPart }}</uni-td>
|
||
<uni-td>{{ item.hiddendescr }}</uni-td>
|
||
<uni-td>
|
||
<view class="flex-between">
|
||
<u-icon name="eye-fill" @tap="showHidden(item, index)"></u-icon>
|
||
<view class="ml-10">
|
||
<u-icon name="trash-fill" @tap="removeHidden(item, index)"
|
||
v-if="!disabled"/>
|
||
</view>
|
||
</view>
|
||
</uni-td>
|
||
</uni-tr>
|
||
</uni-table>
|
||
</view>
|
||
</u-cell>
|
||
</view>
|
||
<template v-for="item in form.inspectionUsers" v-if="!type||!(type==='add' || type==='edit')">
|
||
<u-cell v-show="item.inspectionUserOpinion">
|
||
<template #title>
|
||
<view class="title">检查人意见:</view>
|
||
</template>
|
||
<template #label>
|
||
<view class="mt-10 textarea-box">
|
||
<u--textarea v-model="item.inspectionUserOpinion" disabled
|
||
placeholder="请输入检查人意见"></u--textarea>
|
||
</view>
|
||
</template>
|
||
</u-cell>
|
||
<u-cell v-show="item.inspectionUserSignImg">
|
||
<view slot="title" class="title">签字:</view>
|
||
<view slot="label" class="mt-10">
|
||
<u--image :showLoading="true" :src="$store.state.filePath + item.inspectionUserSignImg"
|
||
width="100%" height="80px" mode="scaleToFill"
|
||
@click="previewImage($store.state.filePath + item.inspectionUserSignImg)">
|
||
</u--image>
|
||
</view>
|
||
</u-cell>
|
||
</template>
|
||
<template v-if="!type||!(type==='add' || type==='edit')">
|
||
<u-cell v-show="form.inspectedSiteuserSignImg">
|
||
<view slot="title" class="title">被检查人意见:</view>
|
||
</u-cell>
|
||
<u-cell v-show="form.inspectedSiteuserSignImg">
|
||
<view slot="title" class="title">签字:</view>
|
||
<view slot="label" class="mt-10">
|
||
<u--image :showLoading="true" :src="$store.state.filePath + form.inspectedSiteuserSignImg"
|
||
width="100%" height="80px" mode="scaleToFill"
|
||
@click="previewImage($store.state.filePath + form.inspectedSiteuserSignImg)"></u--image>
|
||
</view>
|
||
</u-cell>
|
||
</template>
|
||
<template v-if="type&&(type==='add' || type==='edit')">
|
||
<u-cell>
|
||
<view slot="title" class="title">检查人意见:</view>
|
||
<view slot="label" class="mt-10 textarea-box">
|
||
<u--textarea v-model="form.inspectionUserOpinion" placeholder="请输入检查人意见"></u--textarea>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell v-if="form.inspectionUserOpinion">
|
||
<view slot="title" class="title flex-between">
|
||
签字:
|
||
<view>
|
||
<u-button type="primary" text="手写添加" size="mini" @click="signShow = true"></u-button>
|
||
</view>
|
||
</view>
|
||
<view slot="label" class="mt-10">
|
||
<sign v-if="signShow" :signShow.sync="signShow" @confirm="signConfirm"></sign>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell v-if="form.inspectionUserSignImg">
|
||
<view slot="value" class="mt-10 flex-1" v-show="form.inspectionUserSignImg">
|
||
<u--image v-show="form.inspectionUserSignImg" :showLoading="true" :src="form.inspectionUserSignImg"
|
||
width="100%" height="80px" mode="scaleToFill"
|
||
@click="previewImage(form.inspectionUserSignImg)">
|
||
</u--image>
|
||
</view>
|
||
</u-cell>
|
||
</template>
|
||
<u-cell :border="false">
|
||
<view slot="label">
|
||
<u-button type="primary" text="提交" @click="$u.debounce(fnSubmit, 1000,true)" v-if="!disabled"></u-button>
|
||
</view>
|
||
</u-cell>
|
||
</u-cell-group>
|
||
</view>
|
||
<u-popup :key="popupShow" :show="popupShow" @close="popupShow = false" mode="right" :closeOnClickOverlay="false"
|
||
:customStyle="{width:'85vw',overflowY:'auto'}">
|
||
<view class="card">
|
||
<u-cell-group :border="false">
|
||
<u-cell>
|
||
<view slot="title" class="title required">隐患照片:</view>
|
||
<view slot="label" class="mt-10">
|
||
<u-upload
|
||
:disabled="popupDisabled"
|
||
:deletable="!popupDisabled"
|
||
uploadIcon="plus"
|
||
:fileList="hiddenForm.hiddenImgs"
|
||
@afterRead="afterRead"
|
||
@delete="deletePic"
|
||
multiple
|
||
:maxCount="popupDisabled?hiddenForm.hiddenImgs.length:4"
|
||
></u-upload>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell v-if="!(popupDisabled && hiddenForm.hiddenVideos.length ===0)">
|
||
<view slot="title" class="title flex-between">
|
||
隐患视频:
|
||
<u-icon v-if="hiddenForm.hiddenVideos.length !== 0 && hiddenForm.hiddenVideos[0].url"
|
||
name="play-circle-fill" size="30" @click="previewVideo(hiddenForm.hiddenVideos[0].url)"></u-icon>
|
||
</view>
|
||
<view slot="label" class="mt-10">
|
||
<u-upload
|
||
:disabled="popupDisabled"
|
||
:deletable="!popupDisabled"
|
||
accept="video"
|
||
uploadIcon="plus"
|
||
:fileList="hiddenForm.hiddenVideos"
|
||
@afterRead="afterRead1"
|
||
@delete="deletePic1"
|
||
multiple
|
||
:maxCount="1"
|
||
></u-upload>
|
||
<u-modal :show="modalShow" title="视频播放" confirmText="关闭" @confirm="modalShow = false">
|
||
<view>
|
||
<video v-if="modalShow" :src="videoUrl" :autoplay="true"></video>
|
||
</view>
|
||
</u-modal>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">隐患描述:</view>
|
||
<view slot="label" class="mt-10 textarea-box">
|
||
<u--textarea v-model="hiddenForm.hiddendescr" placeholder="请输入隐患描述"
|
||
:disabled="popupDisabled"></u--textarea>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title">隐患部位:</view>
|
||
<view slot="value">
|
||
<text @click="showTree('tkitree2')">
|
||
{{ hiddenForm.hiddenPartStr ? hiddenForm.hiddenPartStr : hiddenForm.hiddenPart || '请选择' }}
|
||
</text>
|
||
<tki-tree ref="tkitree2" :range="hiddenRegionTreeList" rangeKey="name" selectParent children-name="nodes"
|
||
@confirm="confirmTree($event,'hiddenRegionTreeList')"/>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">隐患级别:</view>
|
||
<view slot="value">
|
||
<text @click="showTree('tkitree3')">{{ hiddenForm.hiddenlevelName || '请选择' }}</text>
|
||
<tki-tree ref="tkitree3" :range="hiddenLevelTreeList" rangeKey="name" selectParent children-name="nodes"
|
||
@confirm="confirmTree($event,'hiddenLevelTreeList')"/>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">隐患类型:</view>
|
||
<view slot="value">
|
||
<text @click="showTree('tkitree4')">{{ hiddenForm.hiddenTypeName || '请选择' }}</text>
|
||
<tki-tree ref="tkitree4" :range="hiddenTypeTreeList" rangeKey="name" children-name="nodes"
|
||
@confirm="confirmTree($event,'hiddenTypeTreeList')"/>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">是否是相关方:</view>
|
||
<view slot="value">
|
||
<u-radio-group v-model="hiddenForm.isrelevant" placement="row" :disabled="disabled">
|
||
<u-radio label="是" name="1" class="ml-10"></u-radio>
|
||
<u-radio label="否" name="2" class="ml-10"></u-radio>
|
||
</u-radio-group>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">隐患发现时间:</view>
|
||
<view slot="value">
|
||
<text @click="popupDisabled ? null : discoveryTimeShow = true">{{
|
||
hiddenForm.discoverytime || '请选择'
|
||
}}
|
||
</text>
|
||
<u-datetime-picker :show="discoveryTimeShow" :value="hiddenForm.discoverytime" :minDate="Number(1970)"
|
||
@cancel="discoveryTimeShow = false"
|
||
@confirm="discoveryTimeConfirm"></u-datetime-picker>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title flex-between">
|
||
隐患上报位置:
|
||
<view>
|
||
<u-button type="primary" text="定位" size="mini" @click="showMapModal"
|
||
v-if="!popupDisabled"></u-button>
|
||
</view>
|
||
</view>
|
||
<view slot="label" class="mt-10" v-if="hiddenForm.longitude && hiddenForm.latitude">
|
||
<view>经度:{{ hiddenForm.longitude }}</view>
|
||
<view>纬度:{{ hiddenForm.latitude }}</view>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title">隐患位置描述:</view>
|
||
<view slot="label" class="mt-10 textarea-box">
|
||
<u--textarea v-model="hiddenForm.positiondesc" placeholder="请输入隐患位置描述"
|
||
:disabled="popupDisabled"></u--textarea>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell>
|
||
<view slot="title" class="title required">隐患发现人:</view>
|
||
<view slot="value">
|
||
<text @click="popupDisabled ? null : creatorShow = true">{{ hiddenForm.CREATOR_NAME || '请选择' }}</text>
|
||
<u-picker :show="creatorShow" :columns="creatorList" keyName="NAME"
|
||
@cancel="creatorShow = false"
|
||
@confirm="creatorConfirmPicker"></u-picker>
|
||
</view>
|
||
</u-cell>
|
||
<u-cell :border="false">
|
||
<view slot="label" class="flex-between">
|
||
<view class="flex1">
|
||
<u-button type="info" text="取消" @click="popupClose"></u-button>
|
||
</view>
|
||
<view class="flex1 ml-10">
|
||
<u-button type="primary" text="保存" @click="popupSave"
|
||
v-if="!popupDisabled"></u-button>
|
||
</view>
|
||
</view>
|
||
</u-cell>
|
||
</u-cell-group>
|
||
</view>
|
||
</u-popup>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
getDeptUser,
|
||
getHiddenRegion,
|
||
getHiddenType,
|
||
getInspectedDepartment,
|
||
getInspectionDepartment,
|
||
getInspectionType,
|
||
getInspectors,
|
||
getSafetyenvironmentalGoEdit,
|
||
setImgFilesAdd,
|
||
setSafetyenvironmentalAdd, setSafetyenvironmentalAdd_plus,
|
||
setSafetyenvironmentalEdit, setSafetyenvironmentalEdit_plus,
|
||
setVideoAdd
|
||
} from "@/api";
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
form: {
|
||
inspectionSubject: '',
|
||
inspectedDepartmentName: '',
|
||
inspectedCorpName: '',
|
||
inspectedDepartmentId: '',
|
||
inspectedUserName: '',
|
||
inspectedSiteuserId: '',
|
||
inspectionPlace: '',
|
||
inspectionTypeName: '',
|
||
inspectionTimeStart: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
|
||
inspectionTimeEnd: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
|
||
situations: [{id: Math.random(), inspectionSituationId: '', situation: ''}],
|
||
inspectionUsers: [{
|
||
id: Math.random(),
|
||
inspectionUserShow: false,
|
||
inspectionInspectorId: '',
|
||
inspectionDepartmentId: '',
|
||
inspectionDepartmentName: '',
|
||
inspectionUserId: '',
|
||
inspectionUserName: ''
|
||
}],
|
||
hiddenList: [],
|
||
creattime: '',
|
||
inspectionUserOpinion: '',
|
||
inspectionUserSignImg: ''
|
||
},
|
||
rules: {
|
||
'inspectionSubject': {required: true, message: '请选择检查题目'},
|
||
'inspectedDepartmentName': {required: true, message: '请选择被检查单位'},
|
||
'inspectedUserName': {required: true, message: '请选择被检查单位现场负责人'},
|
||
'inspectionPlace': {required: true, message: '请输入检查场所'},
|
||
'inspectionTypeName': {required: true, message: '请选择检查类型'},
|
||
'inspectionTimeStart': {required: true, message: '请选择检查开始时间'},
|
||
'inspectionTimeEnd': {required: true, message: '请选择检查结束时间'},
|
||
},
|
||
inspectedDepartmentTreeList: [],
|
||
inspectionDepartmentTreeList: [],
|
||
inspectionTypeTreeList: [],
|
||
inspectedSiteuserShow: false,
|
||
inspectionTimeStartShow: false,
|
||
inspectionTimeEndShow: false,
|
||
inspectedSiteuserColumns: [
|
||
[]
|
||
],
|
||
inspectionUsers: [[]],
|
||
inspectionId: '',
|
||
vector: '',
|
||
disabled: false,
|
||
delSituations: [],
|
||
delInspectors: [],
|
||
popupShow: false,
|
||
popupDisabled: false,
|
||
hiddenForm: {
|
||
id: Math.random(),
|
||
isrelevant: '2',//是否相关方
|
||
hiddenImgs: [],
|
||
hiddenVideos: [],
|
||
hiddendescr: '',
|
||
hiddenPartStr: '',
|
||
hiddenPart: '',
|
||
hiddenlevelName: '',
|
||
hiddenlevel: '',
|
||
hiddenTypeName: '',
|
||
hiddenType: '',
|
||
discoverytime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
|
||
longitude: '',
|
||
latitude: '',
|
||
CREATOR_NAME: '',
|
||
CREATOR: '',
|
||
positiondesc: '',
|
||
source: '4',
|
||
corpinfoId: '',
|
||
HIDDENFINDDEPT: ''
|
||
},
|
||
hiddenFormRules: {
|
||
'hiddenImgs': {required: true, message: '请上传隐患照片'},
|
||
'hiddendescr': {required: true, message: '请输入隐患描述'},
|
||
'hiddenlevelName': {required: true, message: '请选择隐患级别'},
|
||
'hiddenTypeName': {required: true, message: '请选择隐患类型'},
|
||
'discoverytime': {required: true, message: '请选择隐患发现时间'},
|
||
'CREATOR_NAME': {required: true, message: '请选择隐患发现人'},
|
||
},
|
||
hiddenRegionTreeList: [],
|
||
hiddenLevelTreeList: [
|
||
{id: 'hiddenLevel1004', name: '轻微隐患'},
|
||
{id: 'hiddenLevel1002', name: '一般隐患'},
|
||
],
|
||
hiddenTypeTreeList: [],
|
||
creatorList: [],
|
||
delHiddens: [],
|
||
delHiddenFiles: [],
|
||
discoveryTimeShow: false,
|
||
creatorShow: false,
|
||
modalShow: false,
|
||
videoUrl: '',
|
||
signShow: false,
|
||
type: ''
|
||
}
|
||
},
|
||
async onLoad(event) {
|
||
this.inspectionId = event.inspectionId
|
||
this.vector = event.vector
|
||
this.disabled = !(event.type === 'add' || event.type === 'edit');
|
||
if (this.inspectionId) {
|
||
await this.fnGetSafetyenvironmentalGoEdit()
|
||
}
|
||
this.type = event.type
|
||
if (event.type === 'add' || event.type === 'edit') {
|
||
await this.fnGetInspectedDepartment()
|
||
await this.fnGetInspectionDepartment()
|
||
await this.fnGetHiddenRegion()
|
||
await this.fnGetHiddenType()
|
||
await this.fnGetInspectionType()
|
||
}
|
||
},
|
||
computed: {
|
||
userInfo() {
|
||
return this.$store.getters.getUserInfo
|
||
}
|
||
},
|
||
methods: {
|
||
async fnGetInspectedDepartment() {
|
||
let resData = await getInspectedDepartment({'CORPINFO_ID': ''});
|
||
this.inspectedDepartmentTreeList = JSON.parse(resData.zTreeNodes);
|
||
},
|
||
async fnGetInspectionDepartment() {
|
||
let resData = await getInspectionDepartment();
|
||
this.inspectionDepartmentTreeList = JSON.parse(resData.zTreeNodes);
|
||
},
|
||
async fnGetHiddenRegion(id) {
|
||
if (!id) {
|
||
id = {parentId: '0', DEPARTMENT_ID: this.form.inspectedDepartmentId}
|
||
}
|
||
let { data } = await getHiddenRegion(id);
|
||
this.hiddenRegionTreeList = data;
|
||
},
|
||
async fnGetHiddenType() {
|
||
let resData = await getHiddenType();
|
||
this.hiddenTypeTreeList = JSON.parse(resData.zTreeNodes);
|
||
},
|
||
async fnGetInspectionType() {
|
||
let resData = await getInspectionType();
|
||
this.inspectionTypeTreeList = JSON.parse(resData.zTreeNodes);
|
||
},
|
||
async fnGetDeptUser(detpId) {
|
||
let resData = await getDeptUser({'DEPARTMENT_ID': detpId});
|
||
return resData.userList;
|
||
},
|
||
async fnGetInspectors(detpId) {
|
||
let resData = await getInspectors({'DEPARTMENT_ID': detpId});
|
||
return resData.userList;
|
||
},
|
||
async fnGetSafetyenvironmentalGoEdit() {
|
||
const { data } = await getSafetyenvironmentalGoEdit({ id: this.inspectionId });
|
||
this.form.situations = data.situations.map((item) => {
|
||
return {
|
||
situation: item,
|
||
id: Math.random(),
|
||
};
|
||
});
|
||
this.form = data;
|
||
},
|
||
showTree(ref, type) {
|
||
if (this.popupDisabled) return;
|
||
if (this.disabled) return;
|
||
if (type === 'arr') this.$refs[ref][0]._show();
|
||
else this.$refs[ref]._show()
|
||
},
|
||
confirmTree(e, list, index) {
|
||
if (list === 'inspectedSiteuserColumns') {
|
||
this.form.inspectedDepartmentId = e[0].id
|
||
this.form.inspectedDepartmentName = e[0].name
|
||
this.form.inspectedUserName = ''
|
||
this.form.inspectedSiteuserId = ''
|
||
this.fnGetHiddenRegion({parentId: '0', DEPARTMENT_ID: e[0].id})
|
||
this.fnGetDeptUser(e[0].id).then(res => {
|
||
this.$set(this.inspectedSiteuserColumns, 0, res)
|
||
})
|
||
}
|
||
if (list === 'inspectionTypeTreeList') {
|
||
this.form.inspectionType = e[0].id
|
||
this.form.inspectionTypeName = e[0].name
|
||
}
|
||
if (list === 'inspectionUsers') {
|
||
this.form.inspectionUsers[index].inspectionDepartmentId = e[0].id
|
||
this.form.inspectionUsers[index].inspectionDepartmentName = e[0].name
|
||
this.form.inspectionUsers[index].inspectionUserName = ''
|
||
this.form.inspectionUsers[index].inspectionUserId = ''
|
||
this.fnGetInspectors(e[0].id).then(res => {
|
||
this.$set(this.inspectionUsers[0], index, res)
|
||
})
|
||
}
|
||
if (list === 'hiddenRegionTreeList') {
|
||
this.hiddenForm.hiddenPart = e[0].id
|
||
this.hiddenForm.hiddenPartStr = e[0].name
|
||
}
|
||
if (list === 'hiddenLevelTreeList') {
|
||
this.hiddenForm.HIDDENLEVEL = e[0].id
|
||
this.hiddenForm.hiddenlevelName = e[0].name
|
||
}
|
||
if (list === 'hiddenTypeTreeList') {
|
||
this.hiddenForm.HIDDENTYPE = e[0].id
|
||
this.hiddenForm.hiddenTypeName = e[0].name
|
||
}
|
||
},
|
||
inspectedSiteuserConfirmPicker(e) {
|
||
this.form.inspectedUserName = e.value[0].NAME
|
||
this.form.inspectedSiteuserId = e.value[0].USER_ID
|
||
this.inspectedSiteuserShow = false;
|
||
},
|
||
inspectionTimeStartConfirm(e) {
|
||
this.form.inspectionTimeStart = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM')
|
||
this.inspectionTimeStartShow = false;
|
||
},
|
||
inspectionTimeEndConfirm(e) {
|
||
this.form.inspectionTimeEnd = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM')
|
||
this.inspectionTimeEndShow = false;
|
||
},
|
||
addSituation() {
|
||
this.form.situations.push({id: Math.random(), inspectionSituationId: '', situation: ''})
|
||
},
|
||
removeSituation(item, index) {
|
||
uni.showModal({
|
||
title: '提示',
|
||
cancelText: '确认',
|
||
confirmText: '取消',
|
||
content: '确定删除检查情况吗?',
|
||
success: (res) => {
|
||
if (res.cancel) {
|
||
this.form.situations.splice(index, 1)
|
||
if (item.inspectionSituationId) {
|
||
this.delSituations.push(item.inspectionSituationId)
|
||
}
|
||
}
|
||
}
|
||
});
|
||
},
|
||
addInspector() {
|
||
this.form.inspectionUsers.push(
|
||
{
|
||
id: Math.random(),
|
||
inspectionUserShow: false,
|
||
inspectionInspectorId: '',
|
||
inspectionDepartmentId: '',
|
||
inspectionDepartmentName: '',
|
||
inspectionUserId: '',
|
||
inspectionUserName: ''
|
||
}
|
||
)
|
||
},
|
||
removeInspector(item, index) {
|
||
uni.showModal({
|
||
title: '提示',
|
||
cancelText: '确认',
|
||
confirmText: '取消',
|
||
content: '确定移除检查人员吗?',
|
||
success: (res) => {
|
||
if (res.cancel) {
|
||
this.form.inspectionUsers.splice(index, 1);
|
||
if (item.inspectionInspectorId) {
|
||
this.delInspectors.push(item.inspectionInspectorId)
|
||
}
|
||
}
|
||
}
|
||
});
|
||
},
|
||
inspectionUserShowPicker(index) {
|
||
if (this.disabled) return;
|
||
this.form.inspectionUsers[index].inspectionUserShow = true
|
||
},
|
||
inspectionUserConfirmPicker(e, index) {
|
||
this.form.inspectionUsers[index].inspectionUserId = e.value[0].USER_ID
|
||
this.form.inspectionUsers[index].inspectionUserName = e.value[0].NAME
|
||
this.form.inspectionUsers[index].inspectionUserShow = false
|
||
},
|
||
async fnSubmit() {
|
||
for (const key in this.rules) {
|
||
if (!this.form[key]) {
|
||
uni.showToast({
|
||
title: this.rules[key].message,
|
||
icon: "none"
|
||
})
|
||
return;
|
||
}
|
||
}
|
||
for (let i = 0; i < this.form.situations.length; i++) {
|
||
if (!this.form.situations[i].situation) {
|
||
uni.showToast({
|
||
title: `请填写第${i + 1}项检查情况`,
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
}
|
||
for (let i = 0; i < this.form.inspectionUsers.length; i++) {
|
||
if (!this.form.inspectionUsers[i].inspectionUserName) {
|
||
uni.showToast({
|
||
title: `请选择第${i + 1}项检查人员`,
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
}
|
||
if (this.form.inspectionUserOpinion) {
|
||
if (!this.form.inspectionUserSignImg) {
|
||
uni.showToast({
|
||
title: `您还未签字`,
|
||
icon: 'none'
|
||
})
|
||
return
|
||
}
|
||
}
|
||
let vector = 0
|
||
for (let x in this.form.inspectionUsers) {
|
||
vector = 0
|
||
for (let y in this.form.inspectionUsers) {
|
||
if (this.form.inspectionUsers[y].inspectionUserId === this.form.inspectionUsers[x].inspectionUserId) vector++
|
||
}
|
||
if (vector > 1) {
|
||
uni.showToast({
|
||
title: '检查人重复!请检查数据',
|
||
icon: "none"
|
||
})
|
||
return
|
||
}
|
||
}
|
||
let index = this.form.inspectionUsers.findIndex(item => {
|
||
return item.inspectionUserId === this.userInfo.USER_ID
|
||
})
|
||
if (index < 0) {
|
||
this.form.inspectionUsers.push(
|
||
{
|
||
inspectionInspectorId: '', //检查人员主键
|
||
inspectionDepartmentId: this.userInfo.DEPARTMENT_ID, //检查人员部门ID
|
||
inspectionDepartmentName: this.userInfo.DEPARTMENT_NAME,
|
||
inspectionUserId: this.userInfo.USER_ID, //检查人员ID
|
||
inspectionUserName: this.userInfo.NAME
|
||
}
|
||
)
|
||
}
|
||
let hiddenIds;
|
||
if (this.form.inspectionUserSignImg) {
|
||
let params = {
|
||
filePath: this.form.inspectionUserSignImg,
|
||
name: 'file',
|
||
formData: {
|
||
inspectionId: this.inspectionId,
|
||
inspectionSubject: this.form.inspectionSubject,
|
||
inspectedDepartmentId: this.form.inspectedDepartmentId,
|
||
inspectedSiteuserId: this.form.inspectedSiteuserId,
|
||
inspectionPlace: this.form.inspectionPlace,
|
||
inspectionUserOpinion: this.form.inspectionUserOpinion,
|
||
inspectionType: this.form.inspectionType,
|
||
inspectionTimeStart: this.form.inspectionTimeStart,
|
||
inspectionTimeEnd: this.form.inspectionTimeEnd,
|
||
inspectionUsers: this.form.inspectionUsers,
|
||
situation: this.form.situations.map((item) => item.situation),
|
||
hiddenList: this.form.hiddenList.map((item) => ({
|
||
...item,
|
||
hiddenImgs: null,
|
||
hiddenVideos: null,
|
||
})),
|
||
inspectionStatus: '1',
|
||
deleteHiddenIds: this.delHiddens,
|
||
}
|
||
}
|
||
const { data } = this.inspectionId ? await setSafetyenvironmentalEdit_plus(params) : await setSafetyenvironmentalAdd_plus(params);
|
||
hiddenIds = data;
|
||
} else {
|
||
let params = {
|
||
inspectionId: this.inspectionId,
|
||
inspectionSubject: this.form.inspectionSubject,
|
||
inspectedDepartmentId: this.form.inspectedDepartmentId,
|
||
inspectedSiteuserId: this.form.inspectedSiteuserId,
|
||
inspectionPlace: this.form.inspectionPlace,
|
||
inspectionUserOpinion: this.form.inspectionUserOpinion,
|
||
inspectionType: this.form.inspectionType,
|
||
inspectionTimeStart: this.form.inspectionTimeStart,
|
||
inspectionTimeEnd: this.form.inspectionTimeEnd,
|
||
inspectionUsers: this.form.inspectionUsers,
|
||
situation: this.form.situations.map((item) => item.situation),
|
||
hiddenList: this.form.hiddenList.map((item) => ({
|
||
...item,
|
||
hiddenImgs: null,
|
||
hiddenVideos: null,
|
||
})),
|
||
inspectionStatus: '1',
|
||
deleteHiddenIds: this.delHiddens,
|
||
}
|
||
const { data } = this.inspectionId ? await setSafetyenvironmentalEdit(params) : await setSafetyenvironmentalAdd(params);
|
||
hiddenIds = data;
|
||
}
|
||
let PromiseArr = []
|
||
for (let i = 0; i < hiddenIds.length; i++) {
|
||
for (let j = 0; j < this.form.hiddenList[i].hiddenImgs.length; j++) {
|
||
let imgFiles = []
|
||
imgFiles.push({
|
||
uri: this.form.hiddenList[i].hiddenImgs[j].url,
|
||
FFILE: this.form.hiddenList[i].hiddenImgs[j].url,
|
||
})
|
||
PromiseArr.push(this.fnSetImgFilesAdd(imgFiles, hiddenIds[i]))
|
||
}
|
||
for (let j = 0; j < this.form.hiddenList[i].hiddenVideos.length; j++) {
|
||
PromiseArr.push(this.fnSetVideoAdd(this.form.hiddenList[i].hiddenVideos[j].url, hiddenIds[i]))
|
||
}
|
||
}
|
||
Promise.all(PromiseArr).then(() => {
|
||
uni.showToast({
|
||
title: this.inspectionId ? '修改成功' : '添加成功',
|
||
})
|
||
if (this.vector !== 'list') {
|
||
uni.$u.route({
|
||
type: 'navigateBack'
|
||
})
|
||
} else {
|
||
uni.$u.route({
|
||
type: 'navigateBack',
|
||
delta: 2
|
||
})
|
||
}
|
||
}).catch((e) => {
|
||
uni.showToast({
|
||
title: '添加失败!',
|
||
icon: 'error',
|
||
duration: 2000
|
||
});
|
||
})
|
||
},
|
||
async fnSetImgFilesAdd(imgFiles, FOREIGN_KEY) {
|
||
if (imgFiles[0].uri.indexOf('qgqy.qhdsafety.com') > 0) {
|
||
return await function () {
|
||
console.log('ok')
|
||
}
|
||
}
|
||
return await setImgFilesAdd({
|
||
files: imgFiles,
|
||
formData: {
|
||
FOREIGN_KEY,
|
||
TYPE: '3'
|
||
},
|
||
loading: false
|
||
})
|
||
},
|
||
async fnSetVideoAdd(filePath, FOREIGN_KEY) {
|
||
if (filePath && filePath.indexOf('qgqy.qhdsafety.com') > 0) {
|
||
return await function () {
|
||
console.log('ok')
|
||
}
|
||
}
|
||
return await setVideoAdd({
|
||
filePath,
|
||
name: 'FFILE',
|
||
formData: {
|
||
FOREIGN_KEY,
|
||
TYPE: 102,
|
||
CORPINFO_ID: this.userInfo.CORPINFO_ID,
|
||
},
|
||
loading: false
|
||
})
|
||
},
|
||
addHidden() {
|
||
this.clearHiddenForm()
|
||
this.creatorList = [[{NAME: this.userInfo.NAME, USER_ID: this.userInfo.USER_ID}]]
|
||
this.form.inspectionUsers.forEach(item => {
|
||
let index = this.creatorList[0].findIndex(items => items.USER_ID === item.inspectionUserId)
|
||
if (index < 0) {
|
||
this.creatorList[0].push({
|
||
USER_ID: item.inspectionUserId,
|
||
NAME: item.inspectionUserName,
|
||
DEPARTMENT_ID: item.inspectionDepartmentId
|
||
})
|
||
}
|
||
})
|
||
this.popupShow = true
|
||
this.popupDisabled = false
|
||
},
|
||
showHidden(item) {
|
||
this.clearHiddenForm()
|
||
this.creatorList = [[]]
|
||
this.form.inspectionUsers.forEach(item => {
|
||
this.creatorList[0].push({
|
||
USER_ID: item.inspectionUserId,
|
||
NAME: item.inspectionUserName,
|
||
DEPARTMENT_ID: item.inspectionDepartmentId
|
||
})
|
||
})
|
||
this.hiddenForm = item
|
||
this.popupShow = true
|
||
this.popupDisabled = true
|
||
},
|
||
clearHiddenForm() {
|
||
this.hiddenForm = {
|
||
id: Math.random(),
|
||
isrelevant: '2',//隐患类型
|
||
hiddenImgs: [],
|
||
hiddenVideos: [],
|
||
hiddendescr: '',
|
||
hiddenPartStr: '',
|
||
hiddenPart: '',
|
||
hiddenlevelName: '',
|
||
hiddenlevel: '',
|
||
hiddenTypeName: '',
|
||
hiddenType: '',
|
||
discoverytime: uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM'),
|
||
longitude: '',
|
||
latitude: '',
|
||
CREATOR_NAME: '',
|
||
CREATOR: '',
|
||
positiondesc: '',
|
||
source: '4'
|
||
}
|
||
},
|
||
removeHidden(item, index) {
|
||
uni.showModal({
|
||
title: '提示',
|
||
cancelText: '确认',
|
||
confirmText: '取消',
|
||
content: '确定移除发现问题吗?',
|
||
success: (res) => {
|
||
if (res.cancel) {
|
||
this.form.hiddenList.splice(index, 1);
|
||
if (item.hiddenId) {
|
||
this.delHiddens.push(item.hiddenId)
|
||
}
|
||
}
|
||
}
|
||
});
|
||
},
|
||
afterRead(event) {
|
||
this.hiddenForm.hiddenImgs = [...this.hiddenForm.hiddenImgs, ...event.file]
|
||
},
|
||
deletePic(event) {
|
||
if (this.hiddenForm.hiddenImgs[event.index].IMGFILES_ID) {
|
||
this.delHiddenFiles.push(this.hiddenForm.hiddenImgs[event.index].FILEPATH)
|
||
}
|
||
this.hiddenForm.hiddenImgs = this.hiddenForm.hiddenImgs.filter(item => item.url !== event.file.url)
|
||
},
|
||
afterRead1(event) {
|
||
this.hiddenForm.hiddenVideos = [...this.hiddenForm.hiddenVideos, ...event.file]
|
||
},
|
||
deletePic1(event) {
|
||
this.hiddenForm.hiddenVideos = this.hiddenForm.hiddenVideos.filter(item => item.url !== event.file.url)
|
||
},
|
||
discoveryTimeConfirm(e) {
|
||
this.hiddenForm.discoverytime = uni.$u.timeFormat(e.value, 'yyyy-mm-dd hh:MM')
|
||
this.discoveryTimeShow = false;
|
||
},
|
||
showMapModal() {
|
||
let _this = this
|
||
uni.navigateTo({
|
||
url: '/pages/map/map',
|
||
events: {
|
||
acceptDataFromOpenedPage: function (e) {
|
||
_this.hiddenForm.longitude = e.data.longitue;
|
||
_this.hiddenForm.latitude = e.data.latitude;
|
||
}
|
||
},
|
||
success: function (res) {
|
||
res.eventChannel.emit('acceptDataFromOpenerPage', {data: {title: '安全环保检查发起'}})
|
||
}
|
||
})
|
||
},
|
||
creatorConfirmPicker(e) {
|
||
this.hiddenForm.CREATOR = e.value[0].USER_ID
|
||
this.hiddenForm.CREATOR_NAME = e.value[0].NAME
|
||
this.hiddenForm.HIDDENFINDDEPT = e.value[0].DEPARTMENT_ID
|
||
this.creatorShow = false;
|
||
},
|
||
popupClose() {
|
||
this.popupShow = false
|
||
},
|
||
popupSave() {
|
||
for (const key in this.hiddenFormRules) {
|
||
if (!this.hiddenForm[key]) {
|
||
uni.showToast({
|
||
title: this.hiddenFormRules[key].message,
|
||
icon: "none"
|
||
})
|
||
return;
|
||
}
|
||
}
|
||
this.hiddenForm.SOURCE = 4
|
||
this.form.hiddenList.push(this.hiddenForm)
|
||
this.popupClose()
|
||
},
|
||
previewImage(current) {
|
||
if (false) {
|
||
uni.previewImage({
|
||
urls: [current],
|
||
current
|
||
});
|
||
}
|
||
},
|
||
previewVideo(videoUrl) {
|
||
this.modalShow = true;
|
||
this.videoUrl = videoUrl;
|
||
},
|
||
signConfirm({path}) {
|
||
this.form.inspectionUserSignImg = path
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.flex-1 {
|
||
flex: 1;
|
||
}
|
||
|
||
.title {
|
||
min-width: 170rpx;
|
||
}
|
||
|
||
.textarea-box {
|
||
width: 100%;
|
||
}
|
||
</style>
|