SmartStorage/pages/crashExam/crashExamDetails.vue

345 lines
7.1 KiB
Vue

<template>
<view>
<view
class="single-fetch"
v-for="(fetch, index) in fetchList"
:key="index"
>
<checkbox-group
@change="checkClick(fetch)"
v-show="taskStatus == 58 && ableNum == 1 && fetch.status == '未审核'"
>
<checkbox :checked="fetch.checked" />
</checkbox-group>
<view class="slots">
<view>
<span>类型名称</span>
<h4>{{ fetch.machineTypeName }}</h4>
</view>
<view>
<span>规格型号</span>
<h4>{{ fetch.specificationType }}</h4>
</view>
<view>
<span>设备编号</span>
<h4>{{ fetch.maCode }}</h4>
</view>
<!-- <view>
<span>维修数量</span>
<h4>{{ fetch.repairNum }}</h4>
</view>
<view>
<span>维修合格数量</span>
<h4>{{ fetch.repairedNum }}</h4>
</view> -->
<view>
<span>报废数量</span>
<h4>{{ fetch.scrapNum }}</h4>
</view>
<view>
<span>状态</span>
<h4>{{ fetch.status }}</h4>
</view>
</view>
</view>
<!-- <view class="btm-exam">
<view
class="exam"
@click="exam"
>
审核
</view>
</view> -->
<view
class="buy"
style="background-color: #fff;"
v-show="taskStatus == 58 && ableNum == 1"
>
<view class="checked">
<checkbox-group @tap="checkAll">
<checkbox :checked="allChecked" />
</checkbox-group>
<text>全选</text>
</view>
<view class="total">
<view class="bill" @click="finishCart">
<text>审核</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
fetchList: [
],
allChecked: false,
auditDetailList: [],
taskId: '',
taskIdList: [],
taskStatus: '',
status: '',
ableNum: '',
subObj: {}
}
},
methods: {
checkClick(item) {
item.checked = !item.checked
if (!item.checked) {
this.allChecked = false
} else {
// 判断每一个商品是否是被选择的状态
const goods = this.fetchList.every(item => {
return item.checked === true
})
if (goods) {
this.allChecked = true
} else {
this.allChecked = false
}
}
},
//全选、全不选
checkAll() {
this.allChecked = !this.allChecked
console.log(this.fetchList);
if (this.allChecked) {
this.fetchList.filter(item => {
return item.checked == true || item.checked == false
}).map(subItem => {
subItem.checked = true
})
/* this.fetchList.map(item => {
item.checked = true
}) */
} else {
this.fetchList.filter(item => {
return item.checked == true || item.checked == false
}).map(subItem => {
subItem.checked = false
})
/* this.fetchList.map(item => {
item.checked = false
}) */
}
},
finishCart () {
let that = this
that.taskIdList = []
that.auditDetailList = that.fetchList.filter((item) => {
return item.checked == true
})
if (that.auditDetailList.length == 0) {
uni.showToast({
icon: 'none',
title: '未选中审核项!'
})
} else {
uni.showModal({
title: '确认审核',
content: '是否通过审核?',
confirmText: '通过',
// cancelText: '驳回',
success: (res) => {
if (res.confirm) {
console.log(that.taskId);
that.taskIdList.push(that.taskId)
that.subObj = {
checkResult: '通过',
taskIdList: that.taskIdList,
scrapDetailList: that.auditDetailList
}
console.log(that.subObj);
that.subInStore(that.subObj)
}/* else if (res.cancel) {
that.inStoreList.forEach((item) => {
item.checkType = 2
})
console.log(that.inStoreList);
that.subInStore(that.inStoreList)
} */
}
})
}
},
subInStore (obj) {
let that = this
// 通过审核或驳回
that.$api.crashExam.crashExamAudit(obj).then(res => {
console.log(res);
if (res.data.code == 200) {
uni.showToast({
icon: 'none',
title: res.data.msg,
success: () => {
/* uni.redirectTo({
url: '/pages/repairTestInStore/repairTestInStore'
}) */
uni.navigateBack()
}
})
} else {
uni.showToast({
icon: 'none',
title: res.data.msg
})
}
})
}
},
onLoad(params) {
let that = this
console.log(params);
// that.status = params.taskStatus
that.taskId = params.taskId
that.taskStatus = params.taskStatus
that.ableNum = params.able
// 获取试验检验审核明细
that.$api.crashExam.crashExamDetails({
taskId: params.taskId
}).then(res => {
console.log(res);
if (res.data.code == 200) {
for (let i = 0; i < res.data.rows.length; i++) {
if (res.data.rows[i].maCode == null) {
res.data.rows[i].maCode = '暂无'
}
switch (res.data.rows[i].status) {
case '0':
res.data.rows[i].status = '未审核'
break;
case '1':
res.data.rows[i].status = '已审核'
break;
case '2':
res.data.rows[i].status = '驳回'
break;
}
if (res.data.rows[i].status == '未审核') {
res.data.rows[i].checked = false
}
}
that.fetchList = res.data.rows
console.log(that.fetchList);
}
}).catch(err => {
console.log(err);
})
}
}
</script>
<style lang="scss">
body{
box-sizing: border-box;
padding-bottom: 10vh;
}
.single-fetch{
width: 100%;
box-sizing: border-box;
padding: 20rpx 35rpx;
display: flex;
align-items: center;
border-bottom: 1px solid #DDDDDD;
.slots{
display: flex;
flex-direction: column;
margin-left: 30rpx;
view{
display: flex;
align-items: center;
margin-bottom: 25rpx;
span{
color: #A7A7A7;
padding-right: 20rpx;
}
h4{
font-size: 14px;
font-weight: normal;
}
}
view:last-child{
margin-bottom: 0;
}
}
}
.btm-exam{
position: fixed;
left: 0;
bottom: 0;
width: 100%;
box-sizing: border-box;
padding: 20rpx 40rpx;
display: flex;
justify-content: flex-end;
border-top: 2px solid #F6F8FF;
.exam{
box-sizing: border-box;
padding: 10rpx 50rpx;
border-radius: 30rpx;
background-color: #3788FF;
font-size: 14px;
color: #fff;
}
}
.buy {
display: flex;
align-items: center;
justify-content: space-between;
position: fixed;
left: 50%;
bottom: 0;
width: 95%;
transform: translate(-50%, 0);
}
.buy .checked {
display: flex;
align-items: center;
}
.buy .checked text {
font-size: 25rpx;
color: #000;
padding: 0 12rpx;
}
.buy .total {
display: flex;
align-items: center;
justify-content: space-between;
}
.buy .total .price {
padding-right: 20rpx;
}
.buy .total .price text {
font-size: 27rpx;
color: #C8C7CC;
display: inline-block;
}
.buy .total .price text:last-child {
color: red;
font-weight: bold;
}
.buy .total .bill text {
font-size: 25rpx;
color: #fff;
display: inline-block;
background-color: red;
line-height: 70rpx;
width: 150rpx;
text-align: center;
}
</style>