<template>
|
<view class="content">
|
<view class="list" v-for="(item,index) in listData" :key="index">
|
<uni-card :title="'工单号:'+item.HICMOBillNo" :extra="'日期:'+item.计划日期" style="margin: 10px;" @tap="edit(item)">
|
<view class="card-detail">
|
<view class="detail" v-if="item.HMaterName" style="width: 100%;">
|
<text>产品名称:</text>{{item.HMaterName}}
|
</view>
|
<view class="detail" v-if="item.HModel" style="width: 100%;">
|
<text>产品型号:</text>{{item.HModel}}
|
</view>
|
<view class="detail">
|
<text>计划数量:</text>{{item.HDatePlanQty?item.HDatePlanQty:0}}
|
</view>
|
<view class="detail">
|
<text>汇报总数:</text>{{item.HDateFinishQty?item.HDateFinishQty:0}}
|
</view>
|
<view class="detail" v-if="item.HICMOStatus">
|
<text>当前状态:</text>{{item.HICMOStatus}}
|
</view>
|
<view class="detail" v-if="item.领料状态">
|
<text>领料状态:</text>{{item.领料状态}}
|
</view>
|
<view class="detail" style="width: 100%;display: flex;align-items: center;">
|
<text>生产进度:</text>
|
<zui-progress-bar :value="item.percent" :width="210" type="follow-left"/>
|
</view>
|
</view>
|
</uni-card>
|
</view>
|
<uni-popup ref="popup" background-color="#fff">
|
<view class="popup-content">
|
<view class="tit">异常类型</view>
|
<view class="item" v-for="(item,index) in popList" :key="index" @tap="toAbnm(item)">{{item}}</view>
|
</view>
|
</uni-popup>
|
<view class="over" v-if="listData.length == 0">暂无数据</view>
|
<view class="over" v-if="listData.length != 0">已到底</view>
|
</view>
|
</template>
|
|
<script>
|
import { getUserInfo } from "@/utils/auth.js";
|
export default {
|
data() {
|
return {
|
userInfo:getUserInfo(),
|
serverUrl: uni.getStorageSync('serverUrl')||'http://47.96.97.237/API',
|
HSourceID:'',
|
HSourceName:'',
|
number:1,
|
listData:[],
|
chooseIt:'',
|
popList:['人员原因', '设备原因', '材料原因', '工艺原因', '模具原因', '测试原因', '环境原因'],
|
// 定义操作映射配置
|
actionConfig: {
|
'开工': {
|
apiUrl: '/Sc_MESBeginWorkBill/FastBeginWorkBill',
|
type: '开工',
|
handler: 'handleBegin',
|
checkStatus: true, // 需要检查状态
|
denyMsg: '单据状态不满足开工条件!' // 固定错误提示
|
},
|
'完工': {
|
apiUrl: '/Sc_MESEndWorkBill/FastEndWorkBill',
|
type: '完工',
|
handler: 'handleEnd',
|
checkStatus: true,
|
denyMsg: '单据状态不满足完工条件!' // 固定错误提示
|
},
|
'停工': {
|
apiUrl: '/Sc_MESStopWorkBill/FastStopWorkBill',
|
type: '停工',
|
handler: 'handleStop',
|
checkStatus: true,
|
denyMsg: '单据状态不满足停工条件!' // 固定错误提示
|
},
|
'异常反馈': {
|
apiUrl: '',
|
type: '异常反馈',
|
handler: 'handleAbnormal',
|
checkStatus: true,
|
denyMsg: '单据状态不满足异常反馈条件!' // 固定错误提示
|
}
|
}
|
}
|
},
|
onLoad(e) {
|
console.log(e)
|
uni.showLoading({
|
title:'加载中...'
|
})
|
this.HSourceName=e.HSourceName
|
this.HSourceID=e.HSourceID
|
this.getList(e.HSourceID)
|
},
|
onPullDownRefresh: function() {
|
this.getList(this.HSourceID)
|
setTimeout(()=>{
|
uni.stopPullDownRefresh();
|
}, 1000);
|
},
|
methods: {
|
getList(e){
|
uni.request({
|
url: this.serverUrl + '/ReportPlatForm/SearchGetWorkBillList',
|
data: { "HSourceID": e },
|
success: (res) => {
|
if(res.data.count == 1){
|
console.log(res.data.data.h_p_JIT_GetWorkBillListInfoBySource)
|
this.listData = res.data.data.h_p_JIT_GetWorkBillListInfoBySource
|
for(var i=0;i<this.listData.length;i++){
|
this.listData[i].percent = (this.listData[i].HDateFinishQty / this.listData[i].HDatePlanQty).toFixed(4)
|
}
|
setTimeout(()=>{
|
uni.hideLoading()
|
}, 1000);
|
}else{
|
setTimeout(()=>{
|
uni.hideLoading()
|
}, 1000);
|
uni.showToast({
|
title:'获取列表出错!',
|
icon:'none'
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
setTimeout(()=>{
|
uni.hideLoading()
|
}, 1000);
|
uni.showToast({
|
title:'获取列表接口请求失败',
|
icon:'none'
|
})
|
},
|
});
|
},
|
toAbnm(item){
|
console.log(item,this.chooseIt)
|
this.$refs.popup.close()
|
uni.navigateTo({
|
url:'./OA_ErrMsgBackBill?HICMOBillNo=' + this.chooseIt.HICMOBillNo
|
+'&HSourceName=' + this.HSourceName
|
+'&HSourceBillNo=' + this.chooseIt.HSourceBillNo
|
+'&HType=' + item
|
+'&OperationType=4&linterid=&HSouceBillType='
|
})
|
},
|
edit(item){
|
console.log(item)
|
this.chooseIt = item
|
|
// 使用对象映射配置生成可用的操作列表
|
const availableActions = Object.keys(this.actionConfig)
|
|
uni.showActionSheet({
|
itemList: availableActions,
|
success: (res)=> {
|
const actionKey = availableActions[res.tapIndex]
|
const actionConfig = this.actionConfig[actionKey]
|
|
// 调用对应的处理方法
|
this[actionConfig.handler](item, actionConfig)
|
},
|
fail: function (res) {
|
console.log(res.errMsg);
|
}
|
});
|
},
|
// 开工处理
|
handleBegin(item, config) {
|
const upData = this.createUpData(item)
|
this.checkAndExecuteWorkStatus(
|
item,
|
config,
|
config.apiUrl,
|
upData
|
)
|
},
|
// 完工处理
|
handleEnd(item, config) {
|
const upData = this.createUpData(item)
|
this.checkAndExecuteWorkStatus(
|
item,
|
config,
|
config.apiUrl,
|
upData
|
)
|
},
|
// 停工处理
|
handleStop(item, config) {
|
const upData = this.createUpData(item)
|
this.checkAndExecuteWorkStatus(
|
item,
|
config,
|
config.apiUrl,
|
upData
|
)
|
},
|
// 异常反馈处理
|
handleAbnormal(item, config) {
|
const sWhere = {
|
"HSourceID": this.HSourceID,
|
"HICMOBillNo": item.HICMOBillNo,
|
"HInterID": item.HSourceInterID,
|
"type": config.type
|
}
|
|
uni.request({
|
url: this.serverUrl + '/Sc_MESBeginWorkBill/GetMESBeginWorkBillStaus',
|
type: "GET",
|
data: { "sWhere": JSON.stringify(sWhere) },
|
dataType: "json",
|
async: false,
|
success: (res) => {
|
console.log('异常反馈状态检查:', res.data)
|
// 根据第二个页面的逻辑:如果count>0,表示不允许操作
|
if (res.data.count > 0) {
|
// 不允许操作,显示错误提示
|
const status = item.HICMOStatus || '未知状态'
|
uni.showToast({
|
title: `工单【${item.HICMOBillNo}】当前状态为【${status}】,${config.denyMsg}`,
|
icon:'none',
|
duration: 3000
|
})
|
}
|
else {
|
// count<=0,表示允许操作
|
this.$refs.popup.open('center')
|
}
|
},
|
fail: (res) => {
|
console.log(res)
|
uni.hideLoading()
|
uni.showToast({
|
title:'接口请求失败',
|
icon:'none'
|
})
|
},
|
})
|
},
|
// 创建通用的请求数据
|
createUpData(item) {
|
return {
|
HBillType: item.HBillType,
|
HSourceInterID: item.HSourceInterID,
|
HSourceEntryID: item.HSourceEntryID,
|
HSourceBillNo: item.HSourceBillNo,
|
HSourceBillType: item.HSourceBillType,
|
user: uni.getStorageSync('HUserName')
|
}
|
},
|
// 通用的检查和执行方法
|
checkAndExecuteWorkStatus(item, config, apiUrl, upData) {
|
const sWhere = {
|
"HSourceID": this.HSourceID,
|
"HICMOBillNo": item.HICMOBillNo,
|
"HInterID": item.HSourceInterID,
|
"type": config.type
|
}
|
|
console.log('状态检查参数:', JSON.stringify(sWhere))
|
|
uni.request({
|
url: this.serverUrl + '/Sc_MESBeginWorkBill/GetMESBeginWorkBillStaus',
|
type: "GET",
|
data: { "sWhere": JSON.stringify(sWhere) },
|
dataType: "json",
|
async: false,
|
success: (res) => {
|
console.log('状态检查结果:', res.data)
|
// 根据第二个页面的逻辑:如果data.count>0,表示不允许操作
|
if (res.data.count > 0) {
|
// 不允许操作,显示错误提示
|
const status = item.HICMOStatus || '未知状态'
|
const operationMap = {
|
'开工': '开工',
|
'完工': '完工',
|
'停工': '停工',
|
'异常反馈': '异常反馈'
|
}
|
const operationName = operationMap[config.type] || config.type
|
|
// 根据操作类型给出不同的建议
|
let suggestion = ''
|
switch(config.type) {
|
case '开工':
|
suggestion = '开工操作需要工单状态为"待生产"或"挂起"状态,请检查当前状态是否符合要求'
|
break
|
case '完工':
|
suggestion = '完工操作需要工单处于"生产中"状态,请检查当前状态是否符合要求'
|
break
|
case '停工':
|
suggestion = '停工操作需要工单处于"生产中"状态,请检查当前状态是否符合要求'
|
break
|
case '异常反馈':
|
suggestion = '异常反馈需要工单处于"生产中"或"开工"状态,请检查当前状态是否符合要求'
|
break
|
default:
|
suggestion = '请检查工单状态是否符合操作要求'
|
}
|
|
uni.showToast({
|
title: `工单【${item.HICMOBillNo}】当前状态为【${status}】,无法进行【${operationName}】操作。\n${suggestion}`,
|
icon:'none',
|
duration: 4000
|
})
|
}
|
else {
|
// data.count<=0,表示允许操作
|
this.showConfirmDialog(config.type, item, apiUrl, upData)
|
}
|
},
|
fail: (res) => {
|
console.log(res)
|
uni.hideLoading()
|
uni.showToast({
|
title:'状态检查接口请求失败',
|
icon:'none'
|
})
|
},
|
})
|
},
|
// 显示确认对话框
|
showConfirmDialog(actionType, item, apiUrl, upData) {
|
// 获取当前工单状态显示在确认框中
|
const status = item.HICMOStatus || '未知状态'
|
|
uni.showModal({
|
title: actionType + '确认',
|
content: `设备:${this.HSourceName}\n工单:${item.HICMOBillNo}\n产品:${item.HMaterName}\n当前状态:${status}\n\n确定要执行【${actionType}】操作吗?`,
|
success: (res) => {
|
if (res.confirm) {
|
console.log('用户点击确定')
|
this.executeWork(apiUrl, upData, item, actionType)
|
} else if (res.cancel) {
|
console.log('用户点击取消')
|
}
|
}
|
})
|
},
|
// 执行工作操作
|
executeWork(apiUrl, upData, item, actionType) {
|
uni.showLoading({
|
title:`正在${actionType}...`
|
})
|
|
console.log('执行操作参数:', upData)
|
|
uni.request({
|
url: this.serverUrl + apiUrl,
|
data: upData,
|
success: (res) => {
|
console.log('执行操作结果:', res)
|
if(res.data.count == 1){
|
// 操作成功后刷新列表
|
this.getList(this.HSourceID)
|
uni.showToast({
|
title:`${actionType}成功!`,
|
icon:'success'
|
})
|
}else{
|
uni.hideLoading()
|
// 显示更详细的操作失败提示
|
let errorMsg = res.data.Message || `${actionType}失败`
|
uni.showToast({
|
title: `${actionType}失败:${errorMsg}`,
|
icon:'none',
|
duration: 3000
|
})
|
}
|
},
|
fail: (res) => {
|
console.log(res)
|
uni.hideLoading()
|
uni.showToast({
|
title:`${actionType}接口请求失败,请检查网络`,
|
icon:'none'
|
})
|
},
|
})
|
},
|
changeTab(e){
|
this.number = e
|
if(e==1){
|
this.listData = this.listData1
|
}else{
|
this.listData = this.listData2
|
}
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
.list{
|
width: 100%;
|
.card-detail{
|
width: 100%;
|
display: flex;
|
flex-wrap: wrap;
|
justify-content: space-between;
|
line-height: 120%;
|
.detail{
|
width: 46%;
|
font-size: 26rpx;
|
margin-bottom: 12rpx;
|
color: #555;
|
margin-right: 20rpx;
|
text{
|
color: #999;
|
font-size: 26rpx;
|
}
|
}
|
}
|
.more{
|
color: #888;
|
font-size: 24rpx;
|
display: flex;
|
border-top: 1px solid #eee;
|
padding-top: 20rpx;
|
.part{
|
width: 50%;
|
text-align: center;
|
}
|
}
|
}
|
|
.popup-content{
|
width: 500rpx;
|
border-radius: 20rpx;
|
text-align: center;
|
padding-bottom: 20rpx;
|
.tit{
|
height: 120rpx;
|
line-height: 120rpx;
|
font-size: 34rpx;
|
color: #222;
|
font-weight: bold;
|
}
|
.item{
|
height: 88rpx;
|
line-height: 88rpx;
|
border-top: 1px solid #eee;
|
font-size: 32rpx;
|
color: #444;
|
}
|
}
|
</style>
|