123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258 |
- <template>
- <view class="page">
- <view class="wrap">
- <template v-if="itemList.length>0">
- <view class="checklist" v-for="(checklist,idx) in itemList" :key="idx">
- <view class="title more">{{checklist.itemTitle}}</view>
- <view class="item-cont" v-if="checklist.children&&checklist.children.length>0">
- <view class="checklistItem" v-for="(checklistItem,itemIdx) in checklist.children" :key="itemIdx">
- <view class="itemTitle more">{{checklistItem.itemTitle}}</view>
- <view class="point-cont" v-if="checklistItem.recordList&&checklistItem.recordList.length>0">
- <view class="point" v-for="(point,pointIdx) in checklistItem.recordList" :key="pointIdx" @click="check(point)">
- <view class="pointContent">{{point.pointContent}}</view>
- <view class="status" v-if="point.checkResult===1">【通过】</view>
- <view class="status" v-if="point.checkResult===-1">【不通过】</view>
- <view class="status" v-if="!(point.checkResult===-1||point.checkResult===1)">【未检查】</view>
- </view>
- </view>
- </view>
- </view>
- <view class="item-cont" v-if="checklist.recordList&&checklist.recordList.length>0">
- <view class="checklistItem" v-for="(checklistItem,itemIdx) in checklist.recordList" :key="itemIdx">
- <view class="point-cont">
- <view class="point" @click="check(checklistItem)">
- <view class="pointContent">{{checklistItem.pointContent}}</view>
- <view class="status" v-if="checklistItem.checkResult===1">【通过】</view>
- <view class="status" v-if="checklistItem.checkResult===-1">【不通过】</view>
- <view class="status" v-if="!(checklistItem.checkResult===-1||checklistItem.checkResult===1)">【未检查】</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="handle" @click="handleSubmit(2)">撤销</view> -->
- </view>
- </template>
- <template v-else>没有可处理的清单^-_-^</template>
- </view>
- </view>
- </template>
- <script>
- import {
- checklistInit,
- getchecklistRecord,
- checklistComplete,
- checklistCancel,
- checklistBatchUpdate,
- } from '@/api/aqpt/checklistPoint.js'
- export default {
- data() {
- return {
- defaultProps: {
- id: 'itemId',
- children: 'children',
- label: 'itemTitle'
- },
- divider: false,
- edit: true,
- itemList:[],
- recordId:undefined,
- checklistId:undefined,
- handleVisiable:false,
- type:undefined,
- status:undefined
- }
- },
- onLoad({id,recordId,type}) {
- this.checklistId=id
- this.recordId=recordId
- this.type=type
- if(type==="app"){
- this.initCheckList(id)
- this.handleVisiable=true
- }else{
- this.getchecklistRecord(id,recordId)
- }
- },
- methods: {
- async initCheckList(checklistId){
- let qrcode=uni.getStorageSync('qrcode')
- let {data}=await checklistInit({
- ocId:qrcode.ocId,
- targetId:qrcode.targetId,
- targetType:qrcode.targetType,
- targetTitle:qrcode.targetTitle,
- targetGroupId:qrcode.groupId,
- targetGroupName:qrcode.groupName,
- checklistId
- })
- this.itemList=data.itemList
- this.recordId=data.recordId
- },
- getchecklistRecord(checklistId,recordId){
- /* status
- 0-未初始化;1-初始化完成 2-完成 -1-巡检完成【异常】
- */
- getchecklistRecord(checklistId,recordId).then((res)=>{
- this.itemList=res.data.itemList
- 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(point){
- uni.setStorageSync('point',point)
- if(this.type==='history'){
- if(this.status===2||this.status===-1){
- uni.navigateTo({
- url:"/pages/app_views/checkList/detail/detail"
- })
- }
- if(this.handleVisiable){
- uni.navigateTo({
- url:"/pages/app_views/checkList/form/form"
- })
- }
- }else{
- if(!this.handleVisiable) return
- uni.navigateTo({
- url:"/pages/app_views/checkList/form/form"
- })
- }
- },
- handleSubmit(type){
- let recordId=this.recordId;
- let checklistId=this.checklistId;
- if(type===1){//完成
- checklistComplete(recordId,checklistId).then(()=>{
- uni.$emit('type',1)
- uni.switchTab({
- url:'/pages/history/history'
- })
- }).catch(()=>{
- uni.showToast({
- icon:"none",
- title:"操作失败"
- })
- })
- }
- if(type===2){//放弃
- checklistCancel(recordId).then(()=>{
- uni.switchTab({
- url:'/pages/history/history'
- })
- }).catch(()=>{
- uni.showToast({
- icon:"none",
- title:"操作失败"
- })
- })
- }
- if(type===3){
- checklistBatchUpdate(recordId,1).then(()=>{
- this.getchecklistRecord(checklistId,recordId)
- })
- }
- if(type===4){
- checklistBatchUpdate(recordId,-1).then(()=>{
- this.getchecklistRecord(checklistId,recordId)
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .page{
- background-color: #F5F6F8;
- padding: 20rpx;
- min-height: 100vh;
- box-sizing: border-box;
- margin-bottom: 100rpx;
- }
- .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;
- }
- }
- }
- }
- }
- .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: 10rpx 0;
- .handle{
- display: inline-block;
- color: #222;
- padding: 15rpx 20rpx;
- max-width: 25%;
- box-sizing: border-box;
- border: 1rpx solid #eaeaea;
- font-size: 28rpx;
- text-align: center;
- border-radius: 40rpx;
- margin-right: 20rpx;
- &.submit{
- background-color: #3384FF;
- color: #fff;
- padding: 15rpx 40rpx;
- }
- &:nth-child(4){
- border: 0;
- }
- }
- }
- }
- </style>
|