Files

780 lines
24 KiB
Vue
Executable File
Raw Permalink 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="content">
<view class="search">
<view class="search-type-select" @click="sourceSelClick" style="width: 280rpx;">
<view class="uni-input">
<view class="uni-input-text">{{sourceSelected}}</view>
<image src="../../../static/report/arrow_down.png" style="height: 32rpx;width: 32rpx;flex-shrink: 0;"></image>
</view>
</view>
<input class="search-input" placeholder="搜索……" placeholder-class="search-placeholder"
v-model="sourceCode" @confirm="searchClick"></input>
<image class="search-img" src="../../../static/report/scan_gray.png" @click="scanSearch"></image>
</view>
<view class="change-label">
<view class="label-type">
<view @click="spanClick(0)" :class="[spanSelected==0?'change-label-first-selected':'change-label-first-unselect']">未巡检</view>
<view @click="spanClick(1)" :class="[spanSelected==1?'change-label-second-selected':'change-label-second-unselect']">已巡检</view>
</view>
<view class="add-btn" @click="addListClick">+ 添加</view>
</view>
<view class="list-card" v-if="spanSelected==0" v-for="(item,index) in checkList" :key="index">
<view class="list-card-Info" @click="itemClick(item)">
<!-- <image class="list-card-img-left" src="../../../static/report/unCheck.png"></image> -->
<view class="list-card-Info-item" style="margin-left: 32rpx;">
<text class="list-card-Info-item-text">任务单号:{{item.FICMONO}}</text>
<text class="list-card-Info-item-text">产品名称:{{item.FMaterialName}}</text>
<text class="list-card-Info-item-text">创建时间:{{item.CreateTime}}</text>
</view>
<view class="list-card-Info-item">
<text class="list-card-Info-item-text">流转卡号:{{item.FFlowCardNo}}</text>
<text class="list-card-Info-item-text">资源代码:{{item.FResourceNo}}</text>
<text class="list-card-Info-item-text">检验结果:-</text>
</view>
<image class="list-card-img-right" src="../../../static/myinfo/right-arrow.png"></image>
</view>
<!-- <view class="delete-icon" @click="delItem(index)">
删除
</view> -->
</view>
<view class="list-card" v-if="spanSelected==1" v-for="(item,index) in unCheckList" :key="index">
<view class="list-card-Info" @click="itemClick(item)">
<!-- <image class="list-card-img-left" src="../../../static/report/unCheck.png"></image> -->
<view class="list-card-Info-item" style="margin-left: 32rpx;">
<text class="list-card-Info-item-text">任务单号:{{item.FICMONO}}</text>
<text class="list-card-Info-item-text">产品名称:{{item.FMaterialName}}</text>
<text class="list-card-Info-item-text">创建时间:{{item.CreateTime}}</text>
</view>
<view class="list-card-Info-item">
<text class="list-card-Info-item-text">流转卡号:{{item.FFlowCardNo}}</text>
<text class="list-card-Info-item-text">资源代码:{{item.FResourceNo}}</text>
<text class="list-card-Info-item-text" v-if="item.FTestResult == 0">检验结果:<span>合格</span></text>
<text class="list-card-Info-item-text" v-if="item.FTestResult ==1">检验结果:<span style="color: red;">不合格</span></text>
</view>
<image class="list-card-img-right" src="../../../static/myinfo/right-arrow.png"></image>
</view>
<!-- <view class="delete-icon" @click="delItem(index)">
删除
</view> -->
</view>
<view class="gray-layer" v-if="showGrayLayer" @click="hideGrayLayer"></view>
<view class="bottom-select" v-if="showSourceList">
<view class="bottom-select-head">
<view class="bottom_select-head-cancel" @click="sourceSelCancelClick">取消</view>
<view class="bottom_select-head-confirm" @click="sourceSelConfirmClick">确定</view>
</view>
<view style="display: flex;flex-direction: row;">
<scroll-view scroll-y="true" style="height: 150px;">
<view class="bottom-select-list" v-for="(item,index) in sourceCenter">
<view class="bottom-select-list-item" v-if="item.isChoose" style="color: #007AFF;"
@click="sourceWorkCenterItemSel(item,index)">{{item.FName}}</view>
<view class="bottom-select-list-item" v-if="!item.isChoose"
@click="sourceWorkCenterItemSel(item,index)">{{item.FName}}</view>
</view>
</scroll-view>
<scroll-view scroll-y="true" style="height: 150px;" v-if="sourceCenter[0].isChoose">
<view class="bottom-select-list" v-for="(item,index) in sourceList">
<view class="bottom-select-list-item" v-if="item.isChoose" style="color: #007AFF;"
@click="sourceItemSel(item)">{{item.FNO+'|'+item.FName}}</view>
<view class="bottom-select-list-item" v-if="!item.isChoose"
@click="sourceItemSel(item)">{{item.FNO+'|'+item.FName}}</view>
</view>
</scroll-view>
<scroll-view scroll-y="true" style="height: 150px;" v-if="sourceCenter[0].isChoose">
<view class="bottom-select-list" v-for="(item,index) in blankList">
<view class="bottom-select-list-item" v-if="item.isChoose" style="color: #007AFF;"
@click="sourceItemSel(item)">{{item.FName}}</view>
<view class="bottom-select-list-item" v-if="!item.isChoose"
@click="sourceItemSel(item)">{{item.FName}}</view>
</view>
</scroll-view>
<scroll-view scroll-y="true" style="height: 150px;" v-if="sourceCenter[1].isChoose">
<view class="bottom-select-list" v-for="(item,index) in centerList">
<view class="bottom-select-list-item" v-if="item.isChoose" style="color: #007AFF;"
@click="centerItemSel(item)">{{item.FName}}</view>
<view class="bottom-select-list-item" v-if="!item.isChoose"
@click="centerItemSel(item)">{{item.FName}}</view>
</view>
</scroll-view>
<scroll-view scroll-y="true" style="height: 150px;" v-if="sourceCenter[1].isChoose">
<view class="bottom-select-list" v-for="(item,index) in centerSubSourceList">
<view class="bottom-select-list-item" v-if="item.isChoose" style="color: #007AFF;"
@click="centerSourceItemSel(item)">{{item.FName}}</view>
<view class="bottom-select-list-item" v-if="!item.isChoose"
@click="centerSourceItemSel(item)">{{item.FName}}</view>
</view>
</scroll-view>
</view>
</view>
<view class="alter-window" v-if="showCreatOrderWindow" style="height: 600rpx;width: 720rpx;">
<view class="window-title">新建巡检单</view>
<view class="window-content">
<view class="search"
style="font-size: 28rpx;font-family: PingFangSC, PingFangSC-Regular;font-weight: 400;text-align: right;color: #727171;">
工序识别码</view>
<view class="search">
<input class="search-input" v-model="flowScanCode" placeholder="输入工序识别码" @confirm="flowScanCodeCpnfirm"
placeholder-class="search-placeholder" style="background-color: #FFFFFF;"></input>
<image class="search-img" src="../../../static/report/scan_gray.png" @click="scanFlowCodeClick">
</image>
</view>
<!-- <view class="search"
style="font-size: 28rpx;font-family: PingFangSC, PingFangSC-Regular;font-weight: 400;text-align: right;color: #727171;">
资源码</view>
<view class="search">
<input class="search-input" v-model="sourceScanCode" placeholder="输入资源码" @confirm="sourceScanCodeConfirm"
placeholder-class="search-placeholder" style="background-color: #FFFFFF;"></input>
<image class="search-img" src="../../../static/report/scan_gray.png" @click="scanSourceCodeClick">
</image>
</view> -->
</view>
<!-- <view class="window-btn">
<view class="window-btn-cancel" @click="resetClick">重置</view>
<view class="window-btn-confirm" @click="confirmClick">确定</view>
</view> -->
</view>
</view>
</template>
<script>
import errorUtil from '@/common/errorutil.js'
import {
mapState,
mapMutations
} from 'vuex'
export default {
data() {
return {
scrollTop: 0,
old: {
scrollTop: 0
},
pageIndex:1,
pageSize:6,
showTips:false,
leftStyle: 0,
startX: 0,
hiddenFlag: true,
delBtnWidth: 220,
currIndex:'',
showGrayLayer:false,
showSourceList:false,
showCreatOrderWindow:false,
sourceSelected:"选择资源",
sourceCenter:[{FName:"所有资源",isChoose:true},{FName:"工作中心",isChoose:false}],
centerList:[],
sourceList:[],
blankList:[{FName:"",isChoose:""}],
selectedCenterList:[],
centerSubSourceList:[],
selectedSourceList:[],
sourceCode:'',
spanSelected:0,
checkList:[],
unCheckList:[],
flowScanCode:'',
sourceScanCode:'',
isFlowCode:2,//1-工序识别码正确,2-工序识别码不正确
isSourceCode:2,//1-资源码正确,2-资源码不正确
isNewCreat:false,
}
},
components:{
},
onLoad() {
this.centerList = uni.getStorageSync('workCenterInfo');
this.sourceList = uni.getStorageSync('allSourceInfo');
this.getProcessInspection(0,this.spanSelected,1,6)
},
onPullDownRefresh:function(){
let _self = this;
_self.showTips = false;
this.getProcessInspection(0,this.spanSelected,1,this.pageSize);
setTimeout(()=>{
//停止下拉样式
uni.stopPullDownRefresh();
//隐藏标题读取
uni.hideNavigationBarLoading();
},
500);
},
onReachBottom:function(){
let _self = this;
if(!_self.showTips) {
this.getProcessInspection(0,this.spanSelected,this.pageIndex, this.pageSize);
}
else {
uni.showToast({
icon: 'none',
title: '已经到底了'
});
}
},
// onBackPress(options) {
// if(options.from === 'navigateBack'){
// return false;
// }
// this.back();
// return true;
// },
methods: {
hideGrayLayer(){
this.showGrayLayer = false;
this.showSourceList = false;
this.showCreatOrderWindow = false;
},
// back(){
// uni.redirectTo({
// url:'../../tabbar/home/home'
// })
// },
// 资源选择
sourceSelClick(){
this.selectedSourceList = uni.getStorageSync('allSourceInfo');
this.showSourceList = true;
this.showGrayLayer = true;
},
sourceWorkCenterItemSel(item,index){//选择所有资源或工作中心
let _self = this;
this.selectedSourceList = [];
let curItemIndex = index;
item.isChoose = !item.isChoose;
let selType = this.sourceCenter.filter(
function(el){
return el.isChoose == true;
}
)
if(selType.length>1){
this.sourceCenter.forEach(
function(el,index){
if(index == curItemIndex){
el.isChoose = true
}else{
el.isChoose = false
_self.selectedSourceList = uni.getStorageSync('allSourceInfo');
_self.sourceSelected = '所有资源';
}
}
)
if(this.sourceCenter[1].isChoose){
this.centerList = uni.getStorageSync('workCenterInfo');
this.selectedCenterList = uni.getStorageSync('workCenterInfo');
this.getResourceByWorkCenter(0);
this.selectedSourceList = this.centerSubSourceList;
}else if(this.sourceCenter[0].isChoose){
this.sourceList = uni.getStorageSync('allSourceInfo');
this.selectedSourceList = uni.getStorageSync('allSourceInfo');
}else{
this.sourceList = uni.getStorageSync('allSourceInfo');
this.selectedSourceList = uni.getStorageSync('allSourceInfo');
}
}else{
this.selectedSourceList = uni.getStorageSync('allSourceInfo');
}
},
sourceItemSel(item){//选取所有资源下的资源
let _self = this;
item.isChoose = !item.isChoose;
this.selectedSourceList = this.sourceList.filter(function(el){
return el.isChoose == true;
})
if(this.selectedSourceList.length == 0){
this.selectedSourceList = this.sourceList;
}
},
centerItemSel(item){//选取工作中心
item.isChoose = !item.isChoose;
this.selectedCenterList = this.centerList.filter(function(el){
return el.isChoose == true;
})
if(this.selectedCenterList.length == 0){
this.selectedCenterList = this.centerList;
}
this.getResourceByWorkCenter(0)
},
centerSourceItemSel(item){//选取工作中心下资源
item.isChoose = !item.isChoose;
this.selectedSourceList = this.centerSubSourceList.filter(function(el){
return el.isChoose == true;
})
if(this.selectedSourceList.length == 0){
this.selectedSourceList = this.centerSubSourceList;
}
},
sourceSelCancelClick(){
this.showSourceList = false;
this.showGrayLayer = false;
},
sourceSelConfirmClick(){
this.getProcessInspection(0,this.spanSelected,1,this.pageSize);
this.showSourceList = false;
this.showGrayLayer = false;
},
getResourceByWorkCenter(count){
let _self = this;
let workCenterFNOList = this.selectedCenterList.map(function(el){
return el.FNO
});
let tokenpara = uni.getStorageSync('token');
this.$request.get('/ReportInfoLoad/QueryResourceByWorkCenter?data='+JSON.stringify(workCenterFNOList)).then(res => {
let data = res;
let list = [];
data.forEach(
function(el){
let arr = {
"FID":el.FID,
"FNO":el.FNO,
"FName":el.FNAME,
"FPhoneID":el.FPHONEID,
"FCOMPANYID":el.FCOMPANYID,
"isChoose":false
}
list.push(arr)
}
)
this.centerSubSourceList = list;
this.selectedSourceList = this.centerSubSourceList;
}).catch(err => {
uni.hideLoading();
errorUtil.handle(err);
});
},
scanSearch(){
let _self = this;
this.selectedSourceList = [];
uni.scanCode({
success: function (res) {
_self.sourceCode = res.result;
let arr = {FNO:_self.sourceCode};
_self.selectedSourceList.push(arr);
_self.getProcessInspection(0,_self.spanSelected,1,6)
}
});
},
searchClick(){
let _self = this;
this.selectedSourceList = [];
if(_self.sourceCode){
let arr = {FNO:_self.sourceCode};
this.selectedSourceList.push(arr);
this.getProcessInspection(0,_self.spanSelected,1,6)
}else{
this.getProcessInspection(0,_self.spanSelected,1,6)
}
},
getProcessInspection(count,checkType,pageIndex,pageSize){
let _self = this;
if (count) {
count = count + 1;
if (count > 4) {
return
}
} else {
count = 1;
}
let requestParams;
let Resource = this.selectedSourceList.map(function(el){
return el.FNO
})
let userInfo = uni.getStorageSync('userInfo')
let tokenpara = uni.getStorageSync('tokenpara');
if (count > 1) {
requestParams = {
"id": userInfo.token,
"Resource":Resource,
"Page":pageIndex,
"Size":6,
"Status":checkType,
"FInterID":'',
"tokenpara": tokenpara
};
} else {
requestParams = {
"id": userInfo.token,
"Resource":Resource,
"Page":pageIndex,
"Size":6,
"Status":checkType,
"FInterID":''
};
}
this.$request.post({
data: {
action: 'GetProcessInspection',
params: requestParams,
}
}).then(res => {
if(res){
let data = res.processInspection;
// if(data.length>0){
if(checkType == 0){
if (pageIndex == 1) {
this.checkList = data;
pageIndex = pageIndex + 1;
this.pageIndex = pageIndex;
} else {
if (data.length != 0) {
let newArray = this.checkList.concat(data);
this.checkList = newArray;
pageIndex = pageIndex + 1;
this.pageIndex = pageIndex;
if (data.length < 6) {
_self.showTips = true;
}
} else {
_self.showTips = true;
}
}
}
if(checkType == 1){
if (pageIndex == 1) {
this.unCheckList = data;
pageIndex = pageIndex + 1;
this.pageIndex = pageIndex;
} else {
if (data.length != 0) {
let newArray = this.unCheckList.concat(data);
this.unCheckList = newArray;
pageIndex = pageIndex + 1;
this.pageIndex = pageIndex;
if (data.length < 6) {
_self.showTips = true;
}
} else {
_self.showTips = true;
}
}
}
// }else{
// this.checkList = [];
// this.unCheckList = [];
// }
}
}).catch(err => {
uni.hideLoading();
if (err.state == 400) {
this.getProcessInspection(count,checkType,pageIndex,pageSize);
if (count > 4) {
errorUtil.handle(err);
return;
}
} else {
errorUtil.handle(err);
}
});
},
//页签
spanClick(type){
this.spanSelected = type;
this.showTips = false;
this.getProcessInspection(0,this.spanSelected,1,6)
},
//添加
addListClick() {
this.showGrayLayer = true;
this.showCreatOrderWindow = true;
this.isNewCreat = true;
uni.setStorageSync('isNewCreat',this.isNewCreat);
},
// resetClick() {
// this.flowScanCode = '';
// this.sourceScanCode = '';
// this.isFlowCode = 2;
// this.isSourceCode = 2;
// },
// confirmClick() {
// this.flowScanCodeCpnfirm()
// if(this.isFlowCode == 1){
// this.showGrayLayer = false;
// this.showCreatOrderWindow = false;
// uni.navigateTo({
// url:'O3RP04Detail'
// })
// }
// },
flowScanCodeCpnfirm(){
this.ScanProcessCode(0)
},
scanFlowCodeClick(){
let _self = this;
uni.scanCode({
success: function (res) {
_self.flowScanCode = res.result;
_self.ScanProcessCode(0)
}
});
},
sourceScanCodeConfirm(){
this.ScanResourceCode(0);
},
scanSourceCodeClick(){
let _self = this;
uni.scanCode({
success: function (res) {
_self.sourceScanCode = res.result;
_self.ScanResourceCode(0)
}
});
},
ScanProcessCode(count){
let _self = this;
if (count) {
count = count + 1;
if (count > 4) {
return
}
} else {
count = 1;
}
let requestParams;
let userInfo = uni.getStorageSync('userInfo')
let tokenpara = uni.getStorageSync('tokenpara');
if (count > 1) {
requestParams = {
"id": userInfo.token,
"Barcode":this.flowScanCode,
"tokenpara": tokenpara
};
} else {
requestParams = {
"id": userInfo.token,
"Barcode":this.flowScanCode,
};
}
this.$request.post({
data: {
action: 'ScanProcessCode',
params: requestParams,
}
}).then(res => {
let data = res;
uni.setStorageSync('newAddProcessCheckInfo',data);
uni.setStorageSync('flowScanCode',this.flowScanCode);
this.isFlowCode = 1;
if(this.isFlowCode == 1){
this.showGrayLayer = false;
this.showCreatOrderWindow = false;
uni.navigateTo({
url:'O3RP04Detail'
})
}
}).catch(err => {
uni.hideLoading();
if (err.state == 400) {
this.ScanProcessCode(count);
if (count > 4) {
errorUtil.handle(err);
return;
}
} else {
errorUtil.handle(err);
}
this.isFlowCode = 2;
});
},
ScanResourceCode(count){
let _self = this;
if (count) {
count = count + 1;
if (count > 4) {
return
}
} else {
count = 1;
}
let requestParams;
let userInfo = uni.getStorageSync('userInfo')
let tokenpara = uni.getStorageSync('tokenpara');
if (count > 1) {
requestParams = {
"id": userInfo.token,
"Barcode":this.sourceScanCode,
"tokenpara": tokenpara
};
} else {
requestParams = {
"id": userInfo.token,
"Barcode":this.sourceScanCode,
};
}
this.$request.post({
data: {
action: 'ScanResourceCode',
params: requestParams,
}
}).then(res => {
let data = res;
uni.setStorageSync('newAddResourceInfo',data);
this.isSourceCode = 1;
}).catch(err => {
uni.hideLoading();
if (err.state == 400) {
this.ScanResourceCode(count);
if (count > 4) {
errorUtil.handle(err);
return;
}
} else {
errorUtil.handle(err);
}
this.isSourceCode = 2;
});
},
//list item点击
itemClick(item) {
let currProcessCheckInfo = item;
this.isNewCreat = false;
uni.setStorageSync('currProcessCheckInfo',currProcessCheckInfo);
uni.setStorageSync('isNewCreat',this.isNewCreat)
uni.navigateTo({
url: './O3RP04Detail'
})
},
delItem:function(index){
if(this.spanSelected == 0){
this.checkList.splice(index,1);
}
if(this.spanSelected == 1){
this.unCheckList.splice(index,1);
}
this.leftStyle = 0;
uni.showToast({
title:"删除成功",
icon:'none'
})
this.$forceUpdate();
},
// 开始移动时
touchS($event,index) {
// startX记录开始移动的位置
console.log($event);
console.log(index);
this.currIndex = index;
if($event.touches.length === 1) {
this.startX = $event.touches[0].clientX;
}
// hiddenFlag为true则是从右向左,为false则是从左向右
if(this.leftStyle === 0) {
this.hiddenFlag = true;
} else {
this.hiddenFlag = false;
}
},
touchM($event,index) {
if($event.touches.length === 1) {
//手指移动时水平方向位置
const moveX = $event.touches[0].clientX;
this.moveFunc(moveX);
}
},
touchE($event,index) {
const { leftStyle } = this;
const { delBtnWidth } = this;
// 如果停止滑动的距离大于二分之一则直接弹出删除按钮,不然则left为0
if(-leftStyle > delBtnWidth/2) {
this.leftStyle = -delBtnWidth;
} else {
this.leftStyle = 0;
}
},
moveFunc(moveX) {
// 原始位置向左,leftStyle为小于0;原始位置向右,leftStyle为大于0
// disX为相对最初位置的左右距离
// 大于0为向右,小于0为向左
const disX = moveX - this.startX;
const delBtnWidth = this.delBtnWidth;
let offsetNum = 0;
if(-disX >= delBtnWidth && this.leftStyle === -delBtnWidth) {
return;
}
console.log(disX, this.hiddenFlag);
// this.hiddenFlag为true则是从左到右,则应该将container向左移动
// this.hiddenFlag为false则是从右向左,则应该将container向右移动
if(this.hiddenFlag) {
// 此时container为最右边,则应该将container向左移动
// disX大于0为相对原始位置的向右移动,则直接将offsetNum置为0
// 否则为向左移动,offsetNum为disX相反的值,判断是否超过设置的最大位置
if(disX == 0 || disX > 0) {
offsetNum = 0;
} else {
offsetNum = disX;
if (disX <= -delBtnWidth) {
//控制手指移动距离最大值为删除按钮的宽度
offsetNum = -delBtnWidth;
}
}
} else {
// 此时container为最左边,应该向右移动
// disX小于0为相对原始位置的向左移动,则直接将offsetNum置为-this.delBtnWidth
// 否则为相对原始位置的向右移动,此时应该将最大位置与向右位置的差值为此刻位置,判断是否为大于0
if(disX < 0) {
offsetNum = -this.delBtnWidth;
} else {
offsetNum = -this.delBtnWidth + disX;
if(offsetNum > 0) {
offsetNum = 0;
}
}
}
this.leftStyle = offsetNum;
},
}
}
</script>
<style>
page{background-color: #F7F7F7;}
.content{}
.list-card-img-left {
height: 80rpx;
width: 80rpx;
flex-shrink: 0;
margin: 0 0rpx 0 90rpx;
}
.list-card-img-right {
height: 28rpx;
width: 28rpx;
flex-shrink: 0;
margin-right: 64rpx;
}
</style>