cma_search/client_mp/pages/inspectrecord/index.vue

251 lines
7.1 KiB
Python

<template>
<view class="wrap">
<u-card :title="initData.dept__name" margin="6rpx" :border="false" :foot-border-top="false" border-radius="2rpx"
:head-style="headstyle" padding="10">
<view class="" slot="body">
<view class="u-body-item-title">
<span style="color:#2979FF;font-weight: bold;margin-right: 8rpx;">{{initData.state}}</span>
</view>
</view>
<view class="" slot="foot">
<view style="flex:true;text-align: right;">
<u-checkbox @change="selfChange" v-model="is_self">只看我的</u-checkbox>
<u-button type="primary" size="mini" style="margin-left:6rpx" @click="upReport" v-if="initData.state=='检查中'&&initData.leader==vuex_user.id">提交结果</u-button>
<u-button size="mini" style="margin-left:6rpx" @click="goReport" v-if="initData.state=='已提交'">查看报告</u-button>
</view>
</view>
</u-card>
<view style="margin:12rpx 6rpx 12rpx;">
<u-section title="详细项目" :right="false"></u-section>
</view>
<view style="background-color: #ffffff;padding: 8rpx;">
<u-tabs :list="list" :is-scroll="false" :current="currentIndex" @change="sectionChange"></u-tabs>
<!-- <u-card v-for="(item, index) in records" v-bind:key="index" margin="6rpx"
:border="false" :foot-border-top="false" border-radius="2rpx" :head-style="headstyle"
@body-click="clickRow" :index="item.id" padding="10" v-if="getShow(item.checked)">
<view class="" slot="body">
<view class="u-body-item-title">
{{item.item_.name}}
</view>
<view class="u-body-item">
<view>
<span>{{item.checker.name}}</span>
<span v-if="item.result=='发现'" style="color:red">{{item.result}}</span>
<span v-else-if="item.result=='未发现'" style="color:green">{{item.result}}</span>
<span v-else-if="item.result=='不适用'">{{item.result}}</span>
</view>
</view>
</view>
</u-card> -->
<view v-for="(item, index) in records" v-bind:key="index" v-if="getShow(item.checked)"
style="padding: 12rpx;">
<view class="u-body-item-title">{{item.item_.sortnum}}.{{item.item_.name}}</view>
<view class="u-body-item">
<span v-if="item.checker_">{{item.checker_.name}}</span>--
<span v-if="item.result=='发现'" style="color:red">{{item.result}}</span>
<span v-else-if="item.result=='未发现'" style="color:green">{{item.result}}</span>
<span v-else-if="item.result=='不适用'">{{item.result}}</span>
</view>
<view style="flex:true;text-align: right;">
<u-button type="primary" size="mini" style="margin-left:6rpx" @click="clickRow(item)">检查</u-button>
<u-button size="mini" style="margin-left:6rpx" @click="clickRow2(item)"
v-if="currentIndex==1"
>详情</u-button>
</view>
<view style="margin-top:6rpx">
<u-gap height="1" bg-color="#bbb"></u-gap>
</view>
</view>
<!-- <u-collapse ref="mycollapse">
<u-collapse-item :title="title1" :open="true">
<u-cell-group :border="false">
<u-cell-item :title="item.item_.name" v-for="(item, index) in records1" v-bind:key="index"
:label="item.checker_.name" >
</u-cell-item>
</u-cell-group>
</u-collapse-item>
<u-collapse-item :title="title2">
<u-cell-group :border="false">
<u-cell-item :title="item.item_.name" v-for="(item, index) in records2" v-bind:key="index"
:label="item.checker_.name" @click="clickRow(item)">
<span slot="right-icon" >
<span v-if="item.result=='发现'" style="color:red">{{item.result}}</span>
<span v-else-if ="item.result=='未发现'" style="color:green">{{item.result}}</span>
<span v-else>{{item.result}}</span>
</span>
</u-cell-item>
</u-cell-group>
</u-collapse-item>
</u-collapse> -->
</view>
<view style="margin-top:16rpx">
<u-divider bg-color="#ededed">没有更多了</u-divider>
</view>
</view>
</template>
<script>
export default {
data() {
return {
initData: {},
headstyle: {
"padding-top": "12rpx",
"padding-bottom": "12rpx"
},
currentIndex: 0,
list: [{
name: '未检查'
},
{
name: '已检查'
}
],
// title1:"未检查(0)",
// title2:"已检查(0)",
records: [],
records_: [],
// records1:[],
// records2:[],
is_self: false,
showNo: false
}
},
onLoad(options) {
this.initData = options;
},
onShow() {
this.getSubtaskDept();
this.$u.api.getInspectRecords({
subtask: this.initData.subtask,
dept: this.initData.dept,
pageoff: true
}).then(res => {
this.records_ = res.data
this.records = res.data
this.sectionChange(this.currentIndex)
// this.setCollapse(this.records_)
})
},
methods: {
getSubtaskDept() {
this.$u.api.getSubtaskDept(this.initData.id).then(res => {
this.initData = res.data
})
},
selfChange(val) {
if (val.value) {
let selfrecords = []
for (var i = 0; i < this.records_.length; i++) {
if (this.records_[i].checker == this.vuex_user.id) {
selfrecords.push(this.records_[i])
}
}
this.records = selfrecords
} else {
// this.setCollapse(this.records_)
this.records = this.records_
}
},
sectionChange(index) {
this.currentIndex = index;
},
getShow(val) {
if (val && this.currentIndex == 1) {
return true
} else if (!val && this.currentIndex == 0) {
return true
}
return false
},
// setCollapse(data){
// let records1 = []
// let records2 = []
// for(var i=0;i<data.length;i++){
// if(data[i].checked){
// records2.push(data[i])
// }else{
// records1.push(data[i])
// }
// }
// this.records1 = records1
// this.records2 = records2
// this.title1 = "未检查" + "("+this.records1.length+")"
// this.title2 = "已检查" + "("+this.records2.length+")"
// this.$nextTick(() => {
// this.$refs["mycollapse"].init();
// });
// },
clickRow(item) {
// uni.navigateTo({
// url:'/pages/inspectrecord/recorddo'
// })
if((item.checker!= this.vuex_user.id && item.checker == null) || this.initData.leader==this.vuex_user.id ){
this.$u.route({
url: '/pages/inspectrecord/recorddo',
params: {
id: item.id
}
})
}else{
this.$u.toast('该项检查已指派他人')
}
},
clickRow2(item) {
// uni.navigateTo({
// url:'/pages/inspectrecord/recorddo'
// })
this.$u.route({
url: '/pages/inspectrecord/recorddetail',
params: {
id: item.id
}
})
},
goReport(){
this.$u.toast('暂未开通')
},
upReport(){
let that = this
uni.showModal({
title: '提交',
content: '确认提交吗?',
success: function (res) {
if (res.confirm) {
that.$u.api.upInspectDept(that.initData.id).then(res=>{
this.initData = res.data
}).catch(e=>{})
} else if (res.cancel) {
}
}
});
}
}
}
</script>
<style>
page {
background-color: #ededed;
}
</style>
<style lang="scss" scoped>
.u-body-item-title {
font-size: 32rpx;
color: #333;
}
.u-body-item {
margin-top: 6rpx;
span {
color: #333;
}
}
</style>