integrated_traffic_uniapp/pages/application/breakground/breakground-measures/breakground-measures-detail...

458 lines
14 KiB
Vue
Raw Normal View History

2024-02-22 11:39:41 +08:00
<template>
<view >
<cu-custom bgColor="bg-gradual-blueness" :isBack="true" >
<block slot="backText">返回</block>
<block slot="content">选择安全措施确认人</block>
2024-02-22 11:39:41 +08:00
</cu-custom>
<scroll-view scroll-y="false" >
<view class="form">
<detail v-if="pd.BREAKGROUND_ID" :breakgroundId="pd.BREAKGROUND_ID" :showMeasures="false"></detail>
<view class="wui-form-list" style="padding-top: 20upx;">
2024-02-29 08:59:44 +08:00
<view class="wui-title" style="margin-left: 20upx;display: flex;justify-content: space-between;align-items: center">
2024-02-22 11:39:41 +08:00
<text class="text-semi">安全防护措施</text>
2024-02-29 08:59:44 +08:00
<button class="cu-btn round bg-blue" @click="addMeasuresListCopy" style="margin-right: 20upx;">添加</button>
2024-02-22 11:39:41 +08:00
</view>
2024-02-29 08:59:44 +08:00
<view>
<view class="add_pard_item" v-for="(item,index) in measuresListCopy" :key="item.id">
<view class="add_pard_del" @click="removeMeasuresListCopy(index)" v-if="index !== 0">
<text class="cuIcon-roundclosefill text-red f40"></text>
</view>
<view class="cu-form-group" >
<view class="title">确认单位</view>
<view class="picker-tree-box">
<view class="picker-tree" @tap="showDeptTree(index)">
{{item.DEPARTMENT_NAME?item.DEPARTMENT_NAME:'请选择'}}
2024-02-22 11:39:41 +08:00
</view>
2024-02-29 08:59:44 +08:00
</view>
<tki-tree
:ref="'tkiTree'+index"
:selectParent=true
:range="treeNode"
rangeKey="name"
@confirm="deptTreeConfirm($event,index)"
@cancel="deptTreeCancel($event,index)">
</tki-tree>
</view>
<view class="cu-form-group" >
<view class="title">确认人</view>
<picker
@change="pickerUser($event,index)"
:value="item.userIndex"
:range="item.userList"
range-key="NAME"
:disabled="item.userList.length === 0"
@click="isBlankList(index)"
>
<view class="picker">
{{item.USER_NAME?item.USER_NAME:'请选择'}}
</view>
</picker>
</view>
<view class="measures cu-form-group">
<view style="flex: 1">
<view style="margin-top: 10upx;display: flex;justify-content: space-between;align-items: center">
<view class="title">安全措施</view>
<view>
<button class="cu-btn round bg-blue" @click="fnSelectMeasures(index)"></button>
2024-02-22 11:39:41 +08:00
</view>
</view>
2024-02-29 08:59:44 +08:00
<view class="content" v-for="(item1,index1) in item.selectMeasures" :key="index1">
{{index1+1}} . {{item1.PROTECTIVE_MEASURES}}
2024-02-22 11:39:41 +08:00
</view>
2024-02-29 08:59:44 +08:00
</view>
</view>
</view>
</view>
<view class="wui-sign" >
<view class="title"></view>
<button class="cu-btn bg-green shadow" @tap="showModal" data-target="Modal">手写签字</button>
</view>
<view class="wui-sign-box" v-show="imgList && imgList.length > 0">
<view class="sign-title">
签字照片
</view>
<view class="wui-sign-cotent">
<view class="sign-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" data-type="0" :data-url="imgList[index].filePath">
<image :src="imgList[index].filePath" mode="aspectFit"></image>
</view>
</view>
</view>
<view class="cu-modal" :class="modalName=='Modal'?'show':''">
<writing-board @confirm="subCanvas" @cancel="hideModal"></writing-board>
</view>
2024-02-22 11:39:41 +08:00
</view>
</view>
<view class="cu-bar btn-group" style="margin-top: 30upx;">
<button class="cu-btn bg-red margin-tb-sm lg" @click="$noMultipleClicks(goSubmit,'-1')"> </button>
<button class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(goSubmit,'1')"> </button>
</view>
<view class="padding flex flex-direction">
</view>
</scroll-view>
<select-measures :measures-list="measuresList" v-model="measuresListCopy" :visible.sync="selectMeasuresShow" :index="selectMeasuresIndex" row-key="BUS_BREAKGROUND_MEASURES_ID"/>
2024-02-22 11:39:41 +08:00
</view>
</template>
<script>
import {
basePath,corpinfoId,deptId,loginUser,formatDate,loginSession,baseImgPath
} from '@/common/tool.js';
import tkiTree from "@/components/select-tree/select-tree.vue"
import writingBoard from "@/components/writing-board/writing-board.vue"
import gcoord from '@/common/gcoord.js'
import ruiDatePicker from '@/components/rattenking-dtpicker/rattenking-dtpicker.vue';
import detail from '@/pages/application/breakground/breakground-detail/index'
2024-02-29 08:59:44 +08:00
import selectMeasures from "@/components/select_measures/index.vue";
2024-02-22 11:39:41 +08:00
export default {
components: {
2024-02-29 08:59:44 +08:00
tkiTree,ruiDatePicker,writingBoard,detail,selectMeasures
2024-02-22 11:39:41 +08:00
},
data() {
return {
baseImgPath:baseImgPath,
buttonloading: false,
noClick:true,
treeNode:[],//部门下拉数据
pd:{},// 数据
measuresList:[],
2024-02-29 08:59:44 +08:00
measuresListCopy:[],
2024-02-22 11:39:41 +08:00
modalName:null,
imgList:[],
2024-02-29 08:59:44 +08:00
selectMeasuresShow:false,
selectMeasuresIndex:-1,
2024-02-22 11:39:41 +08:00
}
},
onLoad(event){
this.pd.BREAKGROUND_ID = event.BREAKGROUND_ID;
this.getData();
// 初始化现场作业负责人
this.getDept();
this.getMeasures();
2024-02-29 08:59:44 +08:00
this.addMeasuresListCopy();
2024-02-22 11:39:41 +08:00
loginSession();
},
methods: {
//跳转事件
goToDetail(e) {
uni.navigateTo({
url: '/pages/application/breakground/breakground-gas/gas-list?BREAKGROUND_ID='+e
});
},
getData() {
var _this = this;
uni.showLoading({
title: '请稍候'
})
uni.request({
url: basePath + '/app/breakground/findById',
method: 'POST',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
data: {
BREAKGROUND_ID: _this.pd.BREAKGROUND_ID,
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
if ("success" == res.data.result) {
uni.hideLoading();
_this.pd = res.data.pd; //参数map
} else if ("exception" == data.result) {
uni.showToast({
title: '错误',
duration: 2000
});
}
}
});
},
goSubmit(APPLY_STATUS){
var _this = this;
uni.showLoading({
title: '请稍候'
})
if (_this.imgList.length <= 0) {
uni.showToast({
icon: 'none',
title: '请签字',
duration: 1500
});
return;
}
if(APPLY_STATUS == 1){
2024-02-29 08:59:44 +08:00
for (let i = 0; i < this.measuresListCopy.length; i++) {
const measures = this.measuresListCopy[i]
2024-02-22 11:39:41 +08:00
if(!measures.USER_ID){
uni.showToast({
icon: 'none',
title: '第'+(i+1)+'项未设置确认人',
duration: 1500
});
return;
}
2024-02-29 08:59:44 +08:00
if(measures.selectMeasures.length === 0){
uni.showToast({
icon: 'none',
title: '第'+(i+1)+'项未选择安全措施',
duration: 1500
});
return;
}
2024-02-22 11:39:41 +08:00
}
}
const formData={}
var files = [];
var signtime = [];
2024-02-29 08:59:44 +08:00
var signers = [];
for (let i = 0; i < this.measuresListCopy.length; i++) {
const measures = this.measuresListCopy[i]
for (let j = 0; j < measures.selectMeasures.length; j++) {
signers.push({
BUS_BREAKGROUND_MEASURES_ID: measures.selectMeasures[j].BUS_BREAKGROUND_MEASURES_ID,
USER_ID: measures.USER_ID
})
}
}
if(signers.length !== this.measuresList.length){
uni.showToast({
icon: 'none',
title: '请为每个安全措施选择确认人',
duration: 1500
});
return;
}
2024-02-22 11:39:41 +08:00
this.uploadImgFaults(files,signtime)
formData.BREAKGROUND_ID = _this.pd.BREAKGROUND_ID
formData.SIGNTIME = signtime.join(",")
formData.USER_ID = loginUser.USER_ID
formData.APPLY_STATUS = APPLY_STATUS
formData.PREPARERS = JSON.stringify(signers)
uni.uploadFile({
url: basePath+'app/breakground/nextStep',
files: files,
formData:formData,
success: (res) => {
uni.showToast({
icon:'none',
title: '保存成功',
duration: 2000
});
_this.goback()
},
fail: (err) => {
uni.hideLoading();
uni.showModal({
content: err.errMsg,
showCancel: false
});
}
})
},
uploadImgFaults(files,signtime) {
this.imgList.map((item,index) => {
var img = {}
img.name = 'file'+index
img.uri = item.filePath
files.push(img)
signtime.push(item.SIGNER_TIME)
})
},
getMeasures(){
var _this = this;
uni.request({
method: 'POST',
dataType: 'json',
header: {
'Content-type': 'application/x-www-form-urlencoded'
},
url: basePath + '/app/breakground/listAllMeasures?tm=' + new Date().getTime(),
data: {
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: function (res) {
2024-02-29 08:59:44 +08:00
_this.measuresList = res.data.measuresList
2024-02-22 11:39:41 +08:00
}
});
},
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:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: (res) => {
if("success" == res.data.result){
_this.treeNode=eval(res.data.zTreeNodes);
} else {
uni.showToast({
title: res.data.message,
duration: 2000
});
}
}
});
},
2024-02-29 08:59:44 +08:00
addMeasuresListCopy(){
this.measuresListCopy.push({
id:Math.random(),
DEPARTMENT_ID:'',
DEPARTMENT_NAME:'',
USER_ID:'',
USER_NAME:'',
userList:[],
userIndex:-1,
selectMeasures:[]
})
},
removeMeasuresListCopy(index){
this.measuresListCopy.splice(index,1)
},
fnSelectMeasures(index){
this.selectMeasuresShow = true
this.selectMeasuresIndex = index
},
2024-02-22 11:39:41 +08:00
showDeptTree(index) {
this.isUps=true
this.$refs['tkiTree'+index][0]._show();
},
deptTreeConfirm(e,i) {
this.isUps=false;
2024-02-29 08:59:44 +08:00
this.measuresListCopy[i].DEPARTMENT_ID=e[0].id;
this.measuresListCopy[i].DEPARTMENT_NAME=e[0].name;
this.measuresListCopy[i].USER_ID = ''
this.measuresListCopy[i].USER_NAME = ''
2024-02-22 11:39:41 +08:00
this.getUserList(e[0].id,i);
},
deptTreeCancel(e) {
this.isUps=false;
},
pickerUser(e,i) {
2024-02-29 08:59:44 +08:00
for (let j = 0; j < this.measuresListCopy.length; j++) {
if(this.measuresListCopy[j].USER_ID === this.measuresListCopy[i].userList[e.detail.value].USER_ID && i !== j){
uni.showToast({
icon: 'none',
title: '确认人不能重复',
duration: 1500
});
return;
}
}
this.measuresListCopy[i].userIndex = e.detail.value;
this.measuresListCopy[i].USER_ID=this.measuresListCopy[i].userList[e.detail.value].USER_ID;
this.measuresListCopy[i].USER_NAME=this.measuresListCopy[i].userList[e.detail.value].NAME;
2024-02-22 11:39:41 +08:00
this.$forceUpdate();//强制刷新
},
isBlankList(i) {
2024-02-29 08:59:44 +08:00
if (this.measuresListCopy[i].userList.length == 0) {
2024-02-22 11:39:41 +08:00
uni.showToast({
icon: 'none',
title: '请先选择确认单位',
duration: 1500
})
}
},
//获取人员列表
getUserList(dept,i){
//发送 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:dept,
tm:new Date().getTime(),
CORPINFO_ID:loginUser.CORPINFO_ID,
USER_ID:loginUser.USER_ID,
},
success: function(res){
if("success" == res.data.result){
2024-02-29 08:59:44 +08:00
_this.measuresListCopy[i].userList = res.data.userList;
2024-02-22 11:39:41 +08:00
}else{
uni.showToast({
title: res.data.message,
duration: 2000
});
}
}
})
},
/*
*手写板
*/
showModal(e) {
this.modalName = e.currentTarget.dataset.target
},
hideModal(e) {
this.modalName = null
},
//完成
subCanvas(e) {
e.SIGNER_TIME = formatDate(new Date(), 'yyyy-MM-dd hh:mm')
this.imgList.splice(0,this.imgList.length);
this.imgList.push(e);
this.hideModal()
},
ViewImage(e) {
let files =[];
files.push(e.currentTarget.dataset.url)
uni.previewImage({
urls: files,
current: e.currentTarget.dataset.url
});
},
goback(){
var pages = getCurrentPages(); // 获取当前页面栈
var prePage = pages[pages.length - 2]; // 上二级页面
prePage.$vm.initflag = true; // A 页面 init方法 为true
uni.navigateBack({delta: 1});
uni.hideLoading();
},
}
}
</script>
<style>
2024-02-29 08:59:44 +08:00
.measures{
padding-left: 16px;
padding-right: 16px;
.title{
font-weight: bold;
color: #000000;
font-size: 14px;
}
.content{
font-size: 14px;
color: #000000;
margin-top: 5px;
margin-bottom: 5px;
}
}
2024-02-22 11:39:41 +08:00
</style>