123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- <template>
- <view class="page">
- <view class="wrap">
- <template v-if="itemList.length>0">
- <view class="checklist" v-for="(hazardlist,idx) in itemList" :key="idx">
- <view class="title more">{{hazardlist.hazardTitle}}</view>
- <view class="item-cont" v-if="hazardlist.riskList&&hazardlist.riskList.length>0">
- <view class="checklistItem" v-for="(riskItem,itemIdx) in hazardlist.riskList" :key="itemIdx">
- <view class="itemTitle more"> {{riskItem.riskTitle}}</view>
- <view class="point-cont" v-if="riskItem.recordList&&riskItem.recordList.length>0">
- <view class="point" v-for="(measure,measureIdx) in riskItem.recordList" :key="measureIdx" @click="check(measure)">
- <view class="pointContent">
- <text style="padding-right: 5px;">{{measureIdx+1}})</text>
- <text>{{measure.measureContent}}</text>
- </view>
- <view class="status">【<span class="text">{{measure.checkResult|checkResultFilter}}</span>】</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="handle-container" v-if="handleVisiable">
- <view class="handle" @click="handleSubmit(3)">全部通过</view>
- <view class="handle" @click="handleSubmit(4)">全不通过</view>
- <view class="handle submit" @click="handleSubmit(1)">提交</view>
- <!-- <view class="more" @mouseenter="hover(1)" @mouseleave="hover">
- <text class="text">更多</text>
- <view class="list" v-if="showMore">
- <view class="hand-item-box">
- <view class="handle-item" @click="handleSubmit(2)">撤销</view>
- </view>
- </view>
- </view> -->
- </view>
- </template>
- <template v-else>没有可处理的清单^-_-^</template>
- </view>
- </view>
- </template>
- <script>
- import {
- initChecklistHazardRecord,
- getChecklistHazardRecordViewById,
- completeChecklistDoing,
- cancelChecklistDoing,
- batchUpdateChecklistHazardRecordDoing,
- } from '@/api/aqpt/checklistHazardRecordApi.js'
- export default {
- data() {
- return {
- defaultProps: {
- id: 'itemId',
- children: 'children',
- label: 'itemTitle'
- },
- divider: false,
- edit: true,
- itemList:[],
- recordId:undefined,
- checklistId:undefined,
- handleVisiable:false,
- showMore:false,
- submit_bt_state:false,
- type:undefined,
- status:undefined
- }
- },
- filters: {
- checkResultFilter(i) {
- if (i >= 0) {
- const strs = [
- '未检查',
- '通过'
- ]
- return strs[i]
- } else {
- if (i === -1) {
- return '未通过'
- } else if (i === -2) {
- return '发现隐患'
- }
- }
- }
- },
- onLoad({id,recordId,type}) {
- this.checklistId=id
- this.recordId=recordId
- this.type=type
- if(type==="app"){
- this.initCheckList(id)
- this.handleVisiable=true
- }else{
- this.getChecklistHazardRecordViewById(id,recordId)
- }
- },
- methods: {
- async initCheckList(checklistId){
- let qrcode=uni.getStorageSync('qrcode')
- let {data}=await initChecklistHazardRecord({
- ocId:qrcode.ocId,
- targetId:qrcode.targetId,
- targetType:qrcode.targetType,
- targetTitle:qrcode.targetTitle,
- targetGroupId:qrcode.groupId,
- targetGroupName:qrcode.groupName,
- checklistId
- })
- this.itemList=data.hazardList
- this.recordId=data.recordId
- },
- getChecklistHazardRecordViewById(checklistId,recordId){
- /* status 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】*/
- getChecklistHazardRecordViewById(recordId,checklistId).then((res)=>{
- this.itemList=res.data.hazardList
- let userId=uni.getStorageSync('userId')
- this.status=res.data.status
- this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===userId)
- })
- },
- check(measure){
- uni.setStorageSync('hazard',{
- ...measure,
- checklistId:this.checklistId,
- recordId:this.recordId
- })
- if(this.type==='history'){
- if(this.status===2||this.status===-1){
- uni.navigateTo({
- url:"/pages/app_views/hazard/detail/detail"
- })
- }
- if(this.handleVisiable){
- uni.navigateTo({
- url:"/pages/app_views/hazard/form/form"
- })
- }
- }else{
- if(!this.handleVisiable) return
- uni.navigateTo({
- url:"/pages/app_views/hazard/form/form"
- })
- }
- },
- handleSubmit(type){
- let recordId=this.recordId;
- let checklistId=this.checklistId;
- if(type===1){//完成
- completeChecklistDoing(recordId,checklistId).then(()=>{
- if(this.isAllPass()){
- uni.$emit('type',4)
- uni.switchTab({
- url:'/pages/history/history'
- })
- return
- }
- uni.showModal({
- title: '提示',
- content: '本次检查有未通过项,是否需要登记隐患?',
- success: function (res) {
- if (res.confirm) {
- uni.reLaunch({
- url:`/pages/app_views/danger/submit/submit?tid=${recordId}`
- })
- } else if (res.cancel) {
- uni.$emit('type',4)
- uni.switchTab({
- url:'/pages/history/history'
- })
- }
- }
- });
- }).catch(()=>{
- uni.showToast({
- icon:"none",
- title:"操作失败"
- })
- })
- }
- if(type===2){//放弃
- cancelChecklistDoing(recordId).then(()=>{
- uni.switchTab({
- url:'/pages/history/history'
- })
- }).catch(()=>{
- uni.showToast({
- icon:"none",
- title:"操作失败"
- })
- })
- }
- if(type===3){
- batchUpdateChecklistHazardRecordDoing(recordId,1).then(()=>{
- this.getChecklistHazardRecordViewById(checklistId,recordId)
- })
- }
- if(type===4){
- batchUpdateChecklistHazardRecordDoing(recordId,-1).then(()=>{
- this.getChecklistHazardRecordViewById(checklistId,recordId)
- })
- }
- },
- isAllPass(){
- let items=[]
- for(let i=0;i<this.itemList.length;i++){
- if(this.itemList[i].riskList){
- this.itemList[i].riskList.map(child=>{
- child.recordList.map(measure=>{
- items.push(measure)
- })
- })
- }
- }
- let index=items.findIndex(item=>item.checkResult===-1)
- return index<0
- },
- hover(state){
- this.showMore=state===1
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .page{
- background-color: #F5F6F8;
- padding: 20rpx;
- min-height: 100vh;
- box-sizing: border-box;
- padding-bottom: 120rpx;
- .page-head{
- text-align: right;
- padding-bottom: 10rpx;
- .handle{
- display: inline-block;
- background-color: #3384FF;
- color: #fff;
- padding: 10rpx 15rpx;
- box-sizing: border-box;
- border-right: 1rpx solid #eaeaea;
- font-size: 30rpx;
- text-align: center;
- &:nth-child(4){
- border: 0;
- }
- }
- }
- }
- .wrap{
- padding: 20rpx;
- background-color: #fff;
- .checklist{
- .title{
- color: #222222;
- font-size: 32rpx;
- height: 98rpx;
- line-height: 98rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- border-bottom: 1px dashed #E8E8E8;
- }
- .more{
- background-image: url('/static/tree_more.png');
- background-size: 30rpx 30rpx;
- padding-left: 40rpx;
- background-position: center left;
- background-repeat: no-repeat;
- }
- .item-cont{
- padding-left: 20rpx;
- border-bottom: 1px dashed #E8E8E8;
- .checklistItem{
- .itemTitle{
- color: #222222;
- font-size: 32rpx;
- height: 98rpx;
- line-height: 98rpx;
- }
- }
- .point-cont{
- padding-left: 30rpx;
- .point{
- display: flex;
- color: #666;
- font-size: 28rpx;
- // height: 98rpx;
- // line-height: 98rpx;
- .pointContent{
- flex: 1;
- }
- .status{
- .text{
- color: #3384FF;
- font-weight: 800;
- }
- }
- }
- }
- }
- }
-
- .handle-container{
- position: fixed;
- width: 100%;
- left: 0;
- bottom: 0;
- background-color: #fff;
- display: flex;
- justify-content: center;
- align-items: center;
- border-top: 1rpx solid #eaeaea;
- padding: 15rpx 0;
- .handle{
- display:inline-block;
- color: #222;
- padding: 15rpx 20rpx;
- box-sizing: border-box;
- border: 1rpx solid #eaeaea;
- font-size: 26rpx;
- text-align: center;
- border-radius: 50rpx;
- margin: 0 10rpx;
- &.danger{
- background-color: #FA5B41;
- color: #fff;
- }
- &.submit{
- background-color: #3384FF;
- color: #fff;
- padding: 18rpx 38rpx;
- }
- }
- .more{
- position: relative;
- padding: 15rpx 20rpx;
- // .text:hover{
- // &+.list>.hand-item-box{
- // display: block;
- // }
- // }
- .list{
- position: absolute;
- bottom: 100rpx;
- right: 0;
- box-shadow: 0px 2px 12px 0px #0000001F;
- padding:0 20rpx;
- background-color: #fff;
- .hand-item-box{
- position: relative;
- // display: none;
- &.show{
- display: block;
- }
- &::after{
- width: 0;
- height: 0;
- content: "";
- display: block;
- border-width: 26rpx 26rpx 0 0;
- border-color: #fff transparent;
- border-style: solid;
- position: absolute;
- bottom: -20rpx;
- right: -20rpx;
- }
- .handle-item{
- width: 180rpx;
- height: 50rpx;
- font-size: 26rpx;
- line-height: 50rpx;
- background-color: #fff;
- text-align: center;
- border-bottom: 1px solid #ccc;
- padding:10rpx 0;
- &:last-child{
- border: 0;
- }
- }
- }
- }
- }
- }
- }
- </style>
|