150 lines
3.1 KiB
Vue
Raw Normal View History

2022-06-08 15:48:09 +08:00
<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 :checked="item.chooseType == 1" style="transform: scale(0.7);" @change="changStatus(item)"/>
{{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'],
data(){
return{
listData:[],
checkNum: 0
}
},
created(){
this.initData()
},
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)
}
}
})
},
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)
}
}
})
}
}
}
</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: 14px;
height: 60rpx;
padding: 0 20rpx;
background: rgba(255,255,255,0.5);
}
.control-list{
background: #fff;
font-size: 14px;
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>