230 lines
5.3 KiB
Vue

<template>
<view class="control">
<view class="control-h2 flex j-between a-center" v-if="listData && listData.length>0">
管控要点
<view class="control-total">{{checkNum}}/{{listData.length}}</view>
</view>
<view class="control-list" v-if="listData && listData.length>0">
<view class="control-item" v-for="(item,index) in listData" :key="index">
<!-- <view class="item-title b-bottom">
安装过程
</view> -->
<view class="item-select-box flex j-between a-center" :class="{'b-bottom': index != (listData.length-1)}">
<view class="item-lable">{{item.controlContent}}</view>
<view class="item-switch flex j-between a-center">
<switch :disabled="dangerEngineering.finalAcceptanceStatus === 2 || isDisabled" :checked="item.chooseType == 1" style="transform: scale(0.7);"
@change="changStatus(item)" @click="disabledTip"/>
{{item.chooseType == 1 ? item.yesShowName:item.noShowName}}
</view>
</view>
</view>
</view>
<view class="no-data" v-else>
<image class="img" src="/static/noData.png"></image>
<text class="txt">暂无数据</text>
</view>
</view>
</template>
<script>
export default {
props:['detailId','info'],
data(){
return{
listData:[],
checkNum: 0,
dangerEngineering: {},
isDisabled: false,
userInfo:{}
}
},
mounted() {
this.userInfo = JSON.parse(uni.getStorageSync('userInfo'))
},
created(){
this.initData()
this.getDEById()
this.getApply()
},
onShow() {
this.getApply()
},
methods:{
initData(){
this.sendRequest({
url:'xmgl/dangerousEngineeringControlItem/selectControlItemList',
method:'post',
data: {engineeringId: this.detailId},
success:res=>{
uni.hideLoading()
if(res.code==200){
this.listData = res.result
let num = 0
res.result.forEach(item=>{
if(item.chooseType == 1){
num +=1
}
})
this.checkNum = num
console.log(res)
}
}
})
},
getApply(){
this.sendRequest({
url:'xmgl/xzDangerousEngineeringAcceptance/list',
method:'get',
data:{
engineeringId: this.detailId,
projectSn: JSON.parse(uni.getStorageSync('projectDetail')).projectSn,
},
success:res=>{
uni.hideLoading()
console.log("xmgl/xzDangerousEngineeringAcceptance/list",res);
let result = res.result
console.log(this.info,"8888888888888888888888888888888");
if(this.userInfo.accountType != 6 || this.userInfo.userId == this.info.personLiableId){
if(res.result.length>0){
if(res.result[0].acceptanceResult === null) this.isDisabled = true
if(res.result[0].acceptanceResult === 1) this.isDisabled = true
if(res.result[0].acceptanceResult === 2) this.isDisabled = false
}else{
this.isDisabled = false
}
}else{
this.isDisabled = true
}
console.log(this.isDisabled,"999999999999999999999999999");
}
})
},
getDEById(){
this.sendRequest({
url:'xmgl/dangerousEngineeringRecord/queryById',
method:'post',
data: {id: this.detailId},
success:res=>{
uni.hideLoading()
if(res.code==200){
this.dangerEngineering = res.result
}
}
})
},
changStatus(data){
if(data.chooseType != 1){
data.chooseType = 1
} else {
data.chooseType = 2
}
console.log(data)
this.sendRequest({
url:'xmgl/dangerousEngineeringControlItem/edit',
method:'post',
data: data,
success:res=>{
// uni.hideLoading()
if(res.code==200){
// uni.showToast({
// title:'保存成功'
// })
this.initData()
console.log(res)
}
}
})
},
disabledTip(){
if(this.userInfo.accountType != 6 || this.userInfo.userId == this.info.personLiableId){
if(this.dangerEngineering.finalAcceptanceStatus === 2){
uni.showToast({
title: '该项危大工程已闭合,请勿重复操作',
icon: "none",
duration: 2000
});
return;
}
if(this.isDisabled){
uni.showToast({
title: '等待验收中,请勿重复操作',
icon: "none",
duration: 2000
});
return;
}
}else{
uni.showToast({
title: '您没有权限操作!',
icon: "none",
duration: 2000
});
return;
}
}
}
}
</script>
<style lang="scss" scoped>
.control{
padding-top: 20rpx;
padding-bottom: 40rpx;
.flex{
display: flex;
}
.j-between{
justify-content: space-between;
}
.a-center{
align-items: center;
}
.b-bottom{
border-bottom: 1px solid #F6F6F6;
}
.control-h2{
font-size: 28rpx;
height: 60rpx;
padding: 0 20rpx;
background: rgba(255,255,255,0.5);
}
.control-list{
background: #fff;
font-size: 28rpx;
padding: 0 20rpx;
.control-item{
.item-title{
font-weight: 600;
height: 72rpx;
line-height: 72rpx;
}
}
.item-select-box{
padding: 30rpx 0;
.item-lable{
width: 70%;
}
.item-switch{
:deep(uni-switch .uni-switch-input:before){
background: #ccc;
}
}
}
}
.no-data{
text-align: center;
.img{
display: block;
height: 200rpx;
width: 200rpx;
margin: 0 auto;
margin-top: 60rpx;
margin-bottom: 60rpx;
}
.txt{
color: #C0C4CC;
}
}
}
</style>