Files
GX.O3.WMS/APK/APP_O3/pages/views/MESQS42Item/MESQS42Item.vue
T

368 lines
8.9 KiB
Vue
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<view class="page">
<text class="detail-row-title-class">巡检任务:{{taskItem.FName}}</text>
<progressBar class="detail-row-progress-class" :completedCount="countFinished" :allCount="itemArray.length"/>
<view class="detail-row-sub-title-class">巡检项目</view>
<view v-for="(item,index) in itemArray">
<view class="detail-row-class" @tap="itemClick(index)">
<image src="../../../static/img/FCheckIteam.png" class="detail-row-image-class"></image>
<view class="detail-row-title1-class">
<view>项目序号:{{item.FEntryID}}</view>
<view>项目名称:{{item.FInspectName}}</view>
</view>
<text class="detail-row-content-red-class" v-if="item.isFinish == false">未完成</text>
<image class= "image" src="../../../static/img/rightarrowred.png" v-if="item.isFinish == false"></image>
<text class="detail-row-content-green-class" v-if="item.isFinish == true">已完成</text>
<image class= "image" src="../../../static/img/rightarrowgreen.png" v-if="item.isFinish == true"></image>
</view>
<view class="detail-row-line-class"/>
</view>
<view class="view-space-class" />
<view @tap="submitBtnClick()" class="detail-btn-class">上传报告</view>
</view>
</template>
<script>
import progressBar from '@/components/chocolate-progress-bar/chocolate-progress-bar.vue';
import Vue from 'vue';
import {
mapState,
mapMutations
} from 'vuex';
export default {
components: {progressBar},
data() {
return {
scrollTop: 0,
old: {
scrollTop: 0
},
itemArray: new Array(),
taskItem: new Object(),
newTaskItem: new Object(),
}
},
onLoad(options) {
if(options.item) {
this.taskItem = JSON.parse(options.item);
this.getItemList(this.taskItem);
}
},
onShow() {
this.newTaskItem = uni.getStorageSync(this.newTaskItem.taskItem.FNumber);
this.taskItem = this.newTaskItem.taskItem;
this.itemArray = this.newTaskItem.item;
},
computed: {
countFinished(){
let count = 0;
this.itemArray.forEach(
function(el){
if (el.isFinish == true) {
count++;
}
}
);
return count;
},
...mapState(['userInfo']),
},
methods: {
upper: function(e) {
console.log(e)
},
lower: function(e) {
console.log(e)
},
scroll: function(e) {
console.log(e)
this.old.scrollTop = e.detail.scrollTop
},
goTop: function(e) {
// 解决view层不同步的问题
this.scrollTop = this.old.scrollTop
this.$nextTick(function() {
this.scrollTop = 0
});
uni.showToast({
icon:"none",
title:"纵向滚动 scrollTop 值已被修改为 0"
})
},
getItemList: function(myItem) {
let key = myItem.FNumber;
this.newTaskItem = uni.getStorageSync(key);
if (this.newTaskItem && this.newTaskItem.item) {
this.newTaskItem.taskItem = myItem;
this.itemArray = this.newTaskItem.item;
this.newTaskItem.currentdIndex = 0;
uni.setStorageSync(this.newTaskItem.taskItem.FNumber, this.newTaskItem);
}
else {
let userID = this.userInfo.token;
let requestParams = {
"id": userID,
"InspectPlanId": myItem.FItemID
};
uni.showLoading({
icon:'loading',
title:'加载中……',
mask:true
});
this.$request.post(
{
data: {
action: 'GetInspectPlanDetail',
params: requestParams
}
}
).then(res => {
uni.hideLoading();
let data = JSON.parse(res);
this.itemArray = data;
this.itemArray.forEach(
function(el){
el.isFinish = (el.FResult==1 ? true : false);
}
)
this.newTaskItem = new Object();
this.newTaskItem.taskItem = myItem;
this.newTaskItem.item = this.itemArray;
this.newTaskItem.currentdIndex = 0;
uni.setStorageSync(this.newTaskItem.taskItem.FNumber, this.newTaskItem);
});
}
},
itemClick: function(index){
this.newTaskItem.currentdIndex = index;
uni.setStorageSync(this.newTaskItem.taskItem.FNumber, this.newTaskItem);
let itemString = JSON.stringify(this.newTaskItem);
uni.navigateTo({
// ? 后面加要传的参数, 多个参数用 & 隔开
url: '../../views/MESQS42Detail/MESQS42Detail?item='+itemString,
});
},
submitBtnClick: function(){
let isCompleted = true;
this.newTaskItem.item.forEach(
function(el){
if(el.isFinish == false){
isCompleted = false;
}
}
);
Date.prototype.Format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
const fDate = new Date().Format("yyyy-MM-dd HH:mm");
let userID = this.userInfo.token;
let sumbitData = new Array();
let inspectPlanId = this.newTaskItem.taskItem.FItemID;
this.newTaskItem.item.forEach(
function(el){
el.FResult = el.isFinish ? 1 : 0;
if (el.isFinish) {
let rowData = {
"FDetailID": el.FDetailID,
"FValue": el.FValue ? el.FValue : "",
"FResult": 1,
"FNote": el.FNote ? el.FNote : "",
"FPicture": el.FPicture ? el.FPicture : "",
};
sumbitData.push(rowData);
}
}
);
let requestParams = {
"id": userID,
"InspectPlanId": inspectPlanId,
"FDate": fDate,
"IsFinish": isCompleted ? 1 : (sumbitData.length == 0 ? 0:2)
};
uni.showLoading({
icon:'loading',
title:'加载中……',
mask:true
});
this.$request.post(
{
data: {
action: 'TaskSubmit',
params: requestParams,
"data": sumbitData
}
}
).then(res => {
uni.hideLoading();
let data = JSON.parse(res);
uni.showToast({
icon: 'none',
title: res
});
});
}
}
}
</script>
<style lang="scss">
.page{
width: auto;
height: 100%;
display: flex;
flex-direction:column;
flex-wrap: nowrap;
justify-content: flex-start;
}
.detail-btn-class{
flex-shrink: 0;
flex-grow: 0;
width: 100%;
height: 80rpx;
line-height: 80rpx;
background-color: #5778FF;
font-size: 32rpx;
font-family: MicrosoftYaHei;
text-align: center;
color: #FFFFFF;
bottom: 0rpx;
position: fixed;
}
.detail-row-class{
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
word-break: break-all;
font-size: 28rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
margin-left: 32rpx;
margin-right: 32rpx;
margin-top: 24rpx;
margin-bottom: 22rpx;
}
.detail-row-title-class{
height: 38px;
font-size: 29rpx;
font-family: MicrosoftYaHei;
color: #333333;
line-height: 38rpx;
margin-left: 32rpx;
margin-right: 32rpx;
}
.detail-row-progress-class{
margin-left: auto;
margin-right: auto;
width: 260rpx;
height: 238rpx;
}
.detail-row-sub-title-class{
height: 42rpx;
line-height: 42rpx;
font-size: 32rpx;
font-family: MicrosoftYaHei-Bold, MicrosoftYaHei;
font-weight: bold;
color: #666666;
margin-bottom: 8rpx;
margin-left: 32rpx;
margin-right: 32rpx;
}
.detail-row-image-class{
height: 88rpx;
width: 88rpx;
flex-shrink: 0;
flex-grow: 0;
}
.detail-row-title1-class{
width: auto;
flex-grow: 1;
color: #666666;
line-height: 40rpx;
padding-left: 24rpx;
padding-right: 24rpx;
}
.detail-row-content-green-class{
flex-shrink: 0;
flex-grow: 0;
color: #5EC02D;
width: 90rpx;
margin-right: 18rpx;
}
.detail-row-content-red-class{
flex-shrink: 0;
flex-grow: 0;
color: #FF4545;
width: 90rpx;
margin-right: 18rpx;
}
.image{
flex-shrink: 0;
flex-grow: 0;
height: 40rpx;
width: 40rpx;
}
.detail-row-line-class{
height: 1px;
border-top: 1px solid #F0F0F0;
margin-left: 25rpx;
margin-right: 25rpx;
flex-shrink: 0;
flex-grow: 0;
}
.view-space-class{
height: 81rpx;
flex-shrink: 0;
flex-grow: 0;
}
</style>