<template>
|
<div class="page">
|
<div class="top-right">
|
<button class="refresh-btn" @click="refresh">刷新</button>
|
</div>
|
|
<div class="middle-section">
|
<div class="item" style="height:100px;">
|
<h4>说明:先调机,再送检</h4>
|
</div>
|
|
<!-- 调机开始 -->
|
<div class="item">
|
<button :class="canStart ? 'btn-blue' : 'btn-disabled'"
|
:disabled="!canStart"
|
@click="onStartClick">
|
调机开始
|
</button>
|
<input class="txt-inp" v-model="maStartTime" placeholder="点击按钮带出时间" disabled />
|
</div>
|
|
<!-- 送检呼叫 -->
|
<div class="item">
|
<button :class="canShout ? 'btn-blue' : 'btn-disabled'"
|
:disabled="!canShout"
|
@click="onShoutClick">
|
送检呼叫
|
</button>
|
<input class="txt-inp" v-model="maShoutTime" placeholder="点击按钮带出时间" disabled />
|
</div>
|
|
<!-- 调机完成(后端合格自动写) -->
|
<div class="item">
|
<button class="btn-disabled" disabled>调机完成(=检验通过=开工)</button>
|
<input class="txt-inp" v-model="maEndTime" placeholder="首次首检合格后写入" disabled />
|
</div>
|
|
<!-- 首检结果与提示 -->
|
<div class="item" style="flex-direction:column;">
|
<label>当前首检结果: {{ latestFirstResult || '未判定' }}</label>
|
<label v-if="remark" style="color:#00A2E9">{{ remark }}</label>
|
</div>
|
</div>
|
|
<!-- 底部操作 -->
|
<div class="bottom-section">
|
<button :class="hasUnsaved ? 'save-btn':'btn-disabled'"
|
:disabled="!hasUnsaved"
|
@click="save">
|
保存并生效
|
</button>
|
<button class="cancel-btn" @click="cancel">取消</button>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
props: {
|
orderNo: String,
|
orderId: Number,
|
machineNo: String
|
},
|
data() {
|
return {
|
statusForm: {},
|
maStartTime: '',
|
maShoutTime: '',
|
maEndTime: '',
|
remark: '',
|
latestFirstResult: '',
|
origStart: '',
|
origShout: '',
|
origEnd: '',
|
submitting: false
|
};
|
},
|
computed: {
|
canStart() {
|
// 若从未开始可调机;保留原规则(业务若需首检不合格后允许再次调机可再扩展)
|
return !this.maStartTime;
|
},
|
canShout() {
|
// 已有开始 且 (未送检 或 首检不合格允许再次送检)
|
if (!this.maStartTime) return false;
|
if (!this.maShoutTime) return true;
|
return this.latestFirstResult === '不合格';
|
},
|
hasUnsaved() {
|
return (this.maStartTime !== this.origStart ||
|
this.maShoutTime !== this.origShout);
|
}
|
},
|
created() {
|
this.refresh();
|
},
|
methods: {
|
getNow() {
|
const pad = n => (n < 10 ? '0' + n : '' + n);
|
const d = new Date();
|
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
|
},
|
onStartClick() {
|
if (!this.canStart) return;
|
this.maStartTime = this.getNow();
|
},
|
onShoutClick() {
|
if (!this.canShout) return;
|
// 直接覆盖旧送检时间,实现重送检
|
this.maShoutTime = this.getNow();
|
},
|
refresh() {
|
if (!this.orderId) return;
|
this.$post({
|
url: "/MesOrderSta/FindByOrderNo",
|
data: { orderId: this.orderId, orderNo: this.orderNo }
|
}).then(res => {
|
const d = res.data;
|
if (!d) return;
|
const sta = d.tbBillList || {};
|
this.statusForm = sta;
|
this.maStartTime = sta.maStartTime || '';
|
this.maShoutTime = sta.maShoutTime || '';
|
this.maEndTime = sta.maEndTime || '';
|
this.remark = sta.remark || d.remark || '';
|
this.latestFirstResult = sta.latestFirstResult || d.latestFirstResult || '';
|
this.syncOrig();
|
// 若后端不主动清 maShoutTime,通过 canShout 逻辑仍可重送检
|
});
|
},
|
syncOrig() {
|
this.origStart = this.maStartTime;
|
this.origShout = this.maShoutTime;
|
this.origEnd = this.maEndTime;
|
},
|
cancel() {
|
this.maStartTime = this.origStart;
|
this.maShoutTime = this.origShout;
|
this.maEndTime = this.origEnd;
|
},
|
save() {
|
if (!this.statusForm.id) {
|
this.$showMessage("状态ID为空,不能保存");
|
return;
|
}
|
if (!this.hasUnsaved) {
|
this.$showMessage("无变更");
|
return;
|
}
|
if (this.submitting) return;
|
this.submitting = true;
|
this.$post({
|
url: "/MesOrderSta/ChangeMachineTime",
|
data: {
|
id: this.statusForm.id,
|
maStartTime: this.maStartTime || null,
|
maShoutTime: this.maShoutTime || null,
|
maEndTime: null,
|
orderId: this.orderId,
|
orderNo: this.orderNo,
|
machineNo: this.machineNo
|
}
|
}).then(res => {
|
this.submitting = false;
|
if (res.data) {
|
const sta = res.data.tbBillList || {};
|
this.maStartTime = sta.maStartTime || '';
|
this.maShoutTime = sta.maShoutTime || '';
|
this.maEndTime = sta.maEndTime || '';
|
this.remark = sta.remark || res.data.remark || '';
|
this.latestFirstResult = sta.latestFirstResult || res.data.latestFirstResult || '';
|
this.syncOrig();
|
this.$showMessage("保存成功");
|
} else {
|
this.$showMessage("保存失败");
|
}
|
}).catch(() => {
|
this.submitting = false;
|
this.$showMessage("网络异常");
|
});
|
}
|
}
|
};
|
</script>
|
|
<style scoped>
|
.page {
|
padding: 2vh;
|
display: flex;
|
flex-direction: column;
|
height: 100%;
|
box-sizing: border-box;
|
}
|
|
.top-right {
|
position: absolute;
|
top: 10px;
|
right: 50px;
|
}
|
|
.refresh-btn {
|
padding: 10px;
|
background: #00A2E9;
|
color: #fff;
|
border: none;
|
font-size: 1.5vw;
|
border-radius: 5px;
|
}
|
|
.middle-section {
|
display: flex;
|
flex-direction: column;
|
margin-bottom: 4vh;
|
}
|
|
.item {
|
display: flex;
|
flex-direction: row;
|
align-items: flex-start;
|
margin-bottom: 2vh;
|
}
|
|
button {
|
width: 100%;
|
padding: 1.5vh;
|
font-size: 1.5vw;
|
border: none;
|
text-align: center;
|
}
|
|
.btn-blue {
|
background: #00A2E9;
|
color: #fff;
|
}
|
|
.btn-disabled {
|
background: #ccc;
|
color: #fff;
|
}
|
|
.txt-inp {
|
height: 8vh;
|
padding: 1vh;
|
font-size: 1.5vw;
|
width: 100%;
|
box-sizing: border-box;
|
margin-left: 1vw;
|
}
|
|
.bottom-section {
|
display: flex;
|
justify-content: space-between;
|
margin-top: 4vh;
|
}
|
|
.save-btn, .cancel-btn {
|
width: 48%;
|
padding: 1.5vh;
|
background: #00A2E9;
|
color: #fff;
|
font-size: 1.6vw;
|
border: none;
|
}
|
|
.cancel-btn {
|
background: #0077A6;
|
}
|
</style>
|