<template>
|
<el-dialog :title="titleMap[mode]" v-model="visible" :width="570" destroy-on-close @closed="$emit('closed')">
|
<div v-if="isShow">历史反馈</div>
|
<el-row v-if="isShow" class="history-feedback">
|
<el-col :span="24"><span>开始反馈时间</span><span>{{latestData.feedbackTime}}</span></el-col>
|
<el-col :span="24"><span>状态</span><span>{{latestData.wcsDesc}}</span></el-col>
|
<el-col :span="24"><span>描述</span><span>{{latestData.feedbackDesc}}</span></el-col>
|
<el-col :span="24"><span>状态持续时间</span><span>{{latestData.diffTime}}</span></el-col>
|
</el-row>
|
<div v-if="isShow" class="modal-title">最新反馈</div>
|
<el-form :model="addDictForm" :rules="addDictRules" :disabled="mode=='show'" ref="dialogForm" label-width="120px" label-position="center">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="状态时间">
|
<el-date-picker v-model="addDictForm.date" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" align="right" value-format="YYYY-MM-DD HH:mm:ss" @change="dateChange">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="状态" prop="wcs">
|
<el-select v-model="addDictForm.wcs" style="width: 100%">
|
<el-option v-for="item in feedBackStatusList" :key="item.code" :label="item.name" :value="item.code"/>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="描述">
|
<el-input v-model="addDictForm.description" placeholder="描述" clearable></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<el-button @click="visible=false" >取 消</el-button>
|
<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="dictSubmit">提交反馈</el-button>
|
</template>
|
</el-dialog>
|
</template>
|
|
<script>
|
export default {
|
emits: ['success', 'closed'],
|
props: ['workstationId'],
|
data() {
|
return {
|
feedBackStatusList: [],
|
latestData: {
|
latestData: "",
|
wcsDesc: "",
|
feedbackDesc: "",
|
diffTime: ""
|
},
|
isShow: false,
|
value1: true,
|
mode: "add",
|
titleMap: {
|
add: '状态反馈',
|
edit: '状态反馈',
|
show: '状态反馈'
|
},
|
visible: false,
|
isSaveing: false,
|
//表单数据
|
addDictForm: {
|
description: "",
|
date: [],
|
endTime: "",
|
startTime: "",
|
wcs: ""
|
},
|
//验证规则
|
addDictRules: {
|
wcs:[{required: true, message: '请选择状态', trigger: 'change'}]
|
}
|
}
|
},
|
mounted() {
|
|
},
|
methods: {
|
sumTime(startTime,endTime) {
|
// 将字符串转换为Date对象
|
var startDate = new Date(startTime);
|
var endDate = new Date(endTime);
|
|
// 计算时间差(毫秒)
|
var timeDiff = endDate - startDate;
|
|
// 将时间差转换为天数、小时数、分钟数和秒数
|
var diffDays = Math.floor(timeDiff / (1000 * 60 * 60 * 24)); // 天
|
timeDiff %= 1000 * 60 * 60 * 24; // 剩余毫秒数
|
var diffHours = Math.floor(timeDiff / (1000 * 60 * 60)); // 小时
|
timeDiff %= 1000 * 60 * 60; // 剩余毫秒数
|
var diffMinutes = Math.floor(timeDiff / (1000 * 60)); // 分钟
|
timeDiff %= 1000 * 60; // 剩余毫秒数
|
var diffSeconds = Math.floor(timeDiff / 1000); // 秒
|
var d = diffDays == 0?"":diffDays + "天";
|
return d + diffHours + "小时 " + diffMinutes + "分钟 " + diffSeconds + "秒"
|
},
|
dateChange(val) {
|
this.addDictForm.startTime = val[0];
|
this.addDictForm.endTime = val[1];
|
},
|
//显示
|
open(mode='add'){
|
this.mode = mode;
|
this.visible = true;
|
return this
|
},
|
getfeedBackStatusList() {
|
this.$HTTP.get("/api/blade-cps/global_wcs/wcs-achievements").then(res=> {
|
if(res.code == 200) {
|
res.data.forEach(item=> {
|
if(item.type == "4") {
|
this.feedBackStatusList.push(item);
|
}
|
})
|
}
|
})
|
},
|
//表单提交方法
|
dictSubmit(){
|
var obj = Object.assign({},this.addDictForm);
|
obj.workstationIds = [this.workstationId];
|
var that = this;
|
this.$refs.dialogForm.validate(async (valid) => {
|
if (valid) {
|
this.isSaveing = true;
|
this.$HTTP.post("/api/blade-cps/workstation-wcs-feedback/overwrite-feedback-check",obj).then(res=> {
|
that.isSaveing = false;
|
if(res.code == 200) {
|
if(res.data) {
|
that.$confirm(`反馈的时间与已有反馈重叠,是否覆盖`, '', {
|
type: 'warning'
|
}).then(() => {
|
that.$HTTP.post("/api/blade-cps/workstation-wcs-feedback/start-feedback-by-no-immediate",obj).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.$emit('success', this.addDictForm, this.mode);
|
that.visible = false;
|
}
|
})
|
}).catch(() => {})
|
}else {
|
that.$HTTP.post("/api/blade-cps/workstation-wcs-feedback/start-feedback-by-no-immediate",obj).then(res=> {
|
if(res.code == 200) {
|
that.$message.success("操作成功");
|
that.$emit('success', this.addDictForm, this.mode);
|
that.visible = false;
|
}
|
})
|
}
|
}else {
|
this.$alert(res.message, "提示", {type: 'error'});
|
}
|
})
|
}else{
|
return false;
|
}
|
})
|
},
|
//表单注入数据
|
setData(lastLevelId){
|
this.getfeedBackStatusList(); //获取状态list
|
this.$HTTP.get(`/api/blade-cps/workstation-wcs-feedback/latest?workstationId=${lastLevelId}`).then(res=> {
|
if(res.code == 200) {
|
if(res.data == null) {
|
this.isShow = false;
|
}else {
|
res.data.diffTime = this.sumTime(res.data.startTime,res.data.endTime);
|
this.latestData = res.data;
|
this.isShow = true;
|
}
|
}
|
})
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.history-feedback {
|
background: #f5f5f5;
|
padding: 12px 0;
|
padding-bottom: 24px;
|
margin: 16px 0 24px 0;
|
}
|
.history-feedback .el-col.el-col-24 {
|
margin: 24px 0 0px 40px;
|
font-size: 14px;
|
}
|
.history-feedback .el-col.el-col-24 span:nth-child(1) {
|
display: inline-block;
|
min-width: 100px;
|
}
|
.modal-title {
|
margin-bottom: 20px;
|
}
|
</style>
|