factory_web/src/views/wpm_bx/mlogs.vue

444 lines
10 KiB
Vue

<template>
<el-container>
<el-header>
<div class="left-panel">
<el-button
type="primary"
icon="el-icon-plus"
@click="table_add"
v-auth="'mlog.create'"
>新增</el-button
>
<el-button
type="primary"
icon="el-icon-plus"
@click="table_rework"
v-auth="'mlog.create'"
>返工</el-button
>
</div>
<div class="right-panel">
<el-input
style="margin-right: 5px"
v-model="query.search"
placeholder="名称"
clearable
></el-input>
<el-button
type="primary"
icon="el-icon-search"
@click="handleQuery"
></el-button>
<el-checkbox
v-model="showHidden"
label="已提交"
@change="hiddenChange"
/>
</div>
</el-header>
<el-main>
<scTable
ref="table"
:apiObj="apiObj"
row-key="id"
:params="params"
:query="params"
@row-click="table_detail"
>
<el-table-column
label="#"
type="index"
width="50"
fixed
></el-table-column>
<el-table-column
label="工艺路线"
prop="material_out_name"
min-width="130"
fixed
>
<template #default="scope">
<span v-if="scope.row.material_out_name!==null">{{scope.row.material_out_name}}</span>
<span v-else>返工</span>
</template>
</el-table-column>
<el-table-column
label="预计工时"
prop="hour_work"
width="80"
></el-table-column>
<el-table-column
label="生产设备"
prop="equipment_name"
min-width="150"
></el-table-column>
<el-table-column label="进度" prop="belong_dept_name" v-if="mgroup_name=='黑化'||mgroup_name=='退火'">
<template #default="scope">
<el-progress id="progressbwlq" :percentage="customMethod(scope.row,1)" :stroke-width="20" :color="customMethod(scope.row,2)" :text-inside="true"><span>{{customMethod(scope.row,3)}}</span></el-progress>
</template>
</el-table-column>
<el-table-column
label="部门/工段"
prop="belong_dept_name"
>
<template #default="scope">
{{scope.row.belong_dept_name}}/{{scope.row.mgroup_name}}
</template>
</el-table-column>
<el-table-column
label="处理人"
prop="handle_user_name"
width="80"
></el-table-column>
<el-table-column label="保温剩余时间" v-if="mgroup_name=='黑化'||mgroup_name=='退火'">
<template #default="scope">
{{ getRemaTime(scope.row) }}
</template>
</el-table-column>
<el-table-column
label="开始时间"
prop="work_start_time"
></el-table-column>
<el-table-column
label="结束时间"
prop="work_end_time"
></el-table-column>
<!-- <el-table-column label="是否提交">
<template #default="scope">
<el-tag v-if="scope.row.submit_time == null" type="warning">未提交</el-tag>
<el-tag v-else type="success">已提交</el-tag>
</template>
</el-table-column> -->
<el-table-column
label="提交时间"
prop="submit_time"
></el-table-column>
<el-table-column
label="操作"
fixed="right"
align="center"
width="220"
>
<template #default="scope">
<el-button
type="success"
v-if="route_code=='ladansi'||route_code=='yicifusi'||route_code=='ercifusi'||route_code=='zlybcl'"
@click.stop="table_monitor(scope.row)"
>监测</el-button
>
<el-button
@click="table_detail(scope.row)"
type="primary"
>详情</el-button
>
<el-button
v-auth="'mlog.delete'"
type="danger"
v-if="scope.row.submit_time == null"
@click.stop="table_del(scope.row, scope.$index)"
>删除</el-button
>
<el-button
v-else
type="danger"
@click.stop="mlogRevert(scope.row)"
>撤回</el-button
>
</template>
</el-table-column>
</scTable>
</el-main>
<save-dialog
v-if="dialog.save"
ref="saveDialog"
:process="processId"
:mgroup="mgroupId"
:dept="deptId"
:mgroupName = "mgroupName"
:mgroupMtype="mgroupMtype"
@success="handleSaveSuccess"
@closed="dialog.save = false"
>
</save-dialog>
<detail-drawer
v-if="dialog.detail"
ref="detailDialog"
:mlogId="mlogId"
:process="processId"
:mtask="mtask"
:dept = "deptId"
@closed="detailClose"
>
</detail-drawer>
<monitor-drawer
v-if="dialog.monitor"
ref="monitorDialog"
:endTime="endTime"
:startTime="startTime"
:equipmentId="equipmentId"
></monitor-drawer>
</el-container>
</template>
<script>
import saveDialog from "./mlog_form.vue";
import detailDrawer from "./mlog_detail.vue";
import monitorDrawer from "./monitor_detail.vue";
export default {
props: {
mgroupName: {
type: String,
default: "",
},
mgroupId:{
type: String,
default: "",
}
},
name: "mlog",
components: {
saveDialog,
detailDrawer,
monitorDrawer
},
data() {
return {
apiObj: null,
params: { mgroup: "" ,submit_time__isnull:true,
query: " { id,equipment, material_out_name, equipment_name, reminder_interval_list ,mstate_json,belong_dept_name, mgroup_name,handle_user_name,work_start_time,work_end_time,submit_time}"
},
query: {submit_time__isnull:true},
dialog: {
save: false,
detail: false,
monitor:false,
},
tableData: [],
selection: [],
mtask: "",
mlogId: "",
deptId: null,
processId: "",
route_code: "",
equipmentId: "",
processCate: "",
mgroupMtype: "",
showHidden:false,
};
},
watch: {
mgroupName: {
handler: function (newval,odlval) {
let that = this;
that.params.mgroup = "";
that.apiObj = null;
that.getMgroupInfo();
},
},
},
mounted() {
let that = this;
that.route_code = this.$route.path.split("/")[2];
that.params.mgroup =that.mgroupId;
that.apiObj = that.$API.wpm.mlog.list;
this.getMgroupInfo();
},
methods: {
getMgroupInfo(){
let that = this;
that.$API.mtm.mgroup.item.req(that.mgroupId).then((res) => {
if (res.length < 1) {
that.$message.error("获取工段错误");
return;
}
that.deptId = res.belong_dept;
that.processId = res.process;
that.mgroupMtype = res.mtype;
that.processCate = res.process_cate;
that.params.mgroup = res.id;
that.apiObj = that.$API.wpm.mlog.list;
});
},
getRemaTime(row){
if(row.work_start_time !== null){
let times = 0;
let nowTime = new Date().getTime();
let startTiem = new Date(row.work_start_time).getTime();
let remaTime = nowTime - startTiem;
let temp = Math.floor(remaTime/1000*60);
if(remaTime>0&&row.reminder_interval_list[0]){
if(temp<row.reminder_interval_list[0]){
times = row.reminder_interval_list[0]-temp;
}else{
return '/';
}
return times
}else{
return '/';
}
}
},
detailClose() {
this.dialog.detail = false;
this.$refs.table.refresh();
},
table_monitor(row){
let that= this;
if(row.equipment!==null){
that.equipmentId = row.equipment;
that.endTime = row.work_end_time;
that.startTime = row.work_start_time;
that.dialog.monitor = true;
this.$nextTick(() => {
this.$refs.monitorDialog.open("add");
});
}else{
that.$message.error("该日志未关联设备,请选择设备后重新查看");
}
},
//添加日志
table_add() {
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add");
});
},
table_rework(){
this.dialog.save = true;
this.$nextTick(() => {
this.$refs.saveDialog.open("add","rework");
});
},
//编辑日志
table_edit(row) {
this.dialog.save = true;
this.$nextTick(() => {
if(row.is_fix){
this.$refs.saveDialog.open("edit","rework").setData(row);
}else{
this.$refs.saveDialog.open("edit").setData(row);
}
});
},
//日志详情
table_detail(row) {
this.mlogId = row.id;
this.dialog.detail = true;
this.$nextTick(() => {
this.$refs.detailDialog.open();
});
},
//日志删除
table_del(row) {
this.$confirm(`确定删除吗?`, "提示", {
type: "warning",
}).then(() => {
var id = row.id;
this.$API.wpm.mlog.delete.req(id).then((res) => {
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
this.$refs.table.refresh();
this.$message.success("删除成功");
}
});
});
},
//日志撤回
mlogRevert(row) {
this.$confirm(`确定撤回该日志吗?`, "提示", {
type: "warning",
}).then(() => {
var id = row.id;
this.$API.wpm.mlog.revert.req(id).then((res) => {
if (res.err_msg) {
this.$message.error(res.err_msg);
} else {
this.$refs.table.refresh();
this.$message.success("撤回成功");
}
});
});
},
customMethod(row,index){
let color = '',context = '';
let percent = 0;
if(row.reminder_interval_list.length>0){
let data = new Date();
//当前时间
let currentTime = data.getTime();
//开始时间
let startTime = new Date(row.work_start_time).getTime();
//结束时间
let endTime = new Date(row.work_end_time).getTime();
//已开始工作的时长
let times = (currentTime-startTime)/1000/60;
//总时长
let sum = row.reminder_interval_list[0]+row.reminder_interval_list[1];
if(endTime!==0&&(currentTime>endTime)){
percent = 100;
color = row.mstate_json[1].color;
context = '已完成';
}else{
if(times>0){
percent = Math.round((times/sum)*100);
}else{
percent = 0;
}
if(times>0){
if(times>row.reminder_interval_list[0]){//冷却中
color = row.mstate_json[1].color;
context = row.mstate_json[1].name;
}else if(times>row.reminder_interval_list[1]){//已完成
color = row.mstate_json[1].color;
context = '已完成';
}else{//保温中
color = row.mstate_json[0].color;
context = row.mstate_json[0].name;
}
}else{
color = "#ffffff";
}
}
if(index==1){
return percent
}else if(index==2){
return color
}else{
return context
}
}
},
hiddenChange(val) {
if (val) {
this.query.submit_time__isnull = false;
} else {
this.query.submit_time__isnull = true;
}
this.$refs.table.queryData(this.query);
},
//表格选择后回调事件
selectionChange(selection) {
this.selection = selection;
},
//搜索
handleQuery() {
this.$refs.table.queryData(this.query);
},
//本地更新数据
//新增岗位后更新数据
handleSaveSuccess(data, mode) {
this.dialog.save = true;
this.$refs.table.refresh();
},
},
};
</script>
<style scoped>
</style>