gantt修改

This commit is contained in:
shijing 2023-12-05 08:49:20 +08:00
parent 5ce7ce250f
commit 1f1d96528a
5 changed files with 224 additions and 46 deletions

View File

@ -28,6 +28,7 @@ export default {
},
},
mounted: function () {
let that = this;
gantt.clearAll();//
gantt.i18n.setLocale('cn'); //
gantt.config.date_format = "%Y-%m-%d";
@ -36,6 +37,13 @@ export default {
gantt.config.autosize = true;//
gantt.plugins({ tooltip: true });
gantt.config.bar_height = 20; //task
gantt.config.duration_unit = "day";//
// gantt.config.work_time = true;
// gantt.setWorkTime({ hours:["20:00-20:00"] });
// gantt.setWorkTime({ day:7, hours:false });
// gantt.setWorkTime({ hours:["0-24"] });
// gantt.config.start_date = new Date(2023, 9, 1);
// gantt.config.end_date = new Date(2023, 9, 10);
//
@ -63,6 +71,44 @@ export default {
'<br/>完工时间:' + gantt.templates.tooltip_date_format(start);
};
});
gantt.attachEvent("onTaskClick", async function(id, e) {
var task = gantt.getTask(id);
console.log(task)
if(task.type=="utask"){
that.$API.pm.mtask.list.req({ utask: id, page: 0, ordering: 'start_date,mgroup__process__sort' }).then(res => {
let data = [];
res.forEach(item => {
let obj = {};
obj.id = item.id;
obj.type = 'task';
obj.parent = id;
obj.number = item.number;
obj.text = item.mgroup_name;
obj.state = item.state;
obj.start = item.start_date;
obj.start_date = item.start_date;
obj.duration = 1;
obj.progress = item.count_real / item.count;
obj.count = item.count;
obj.count_ok = item.count_ok;
obj.count_real = item.count_real;
obj.count_notok = item.count_notok;
obj.state = item.state;
obj.utask = item.utask;
obj.mgroup_name = item.mgroup_name;
data.push(obj)
})
// :gantt
let childTasks = data
gantt.parse({ data: childTasks });
//
gantt.refreshData();
})
}
})
//, 使,
// gantt.config.autosize = true;
// gantt.config.open_split_tasks = true;

View File

@ -84,7 +84,9 @@
<el-drawer title="检定记录" v-model="visibleRecord" :size="1000" destroy-on-close @closed="visibleRecord = false">
<el-container v-loading="loading">
<el-button type="primary" icon="el-icon-plus" @click="record_create" v-auth="'equipment'"
style="position: absolute;z-index: 10;left: 110px;top: 16px;"></el-button>
style="position: absolute;z-index: 10;left: 110px;top: 16px;">新增</el-button>
<el-button type="primary" icon="el-icon-download" @click="exportExcel"
style="position: absolute;z-index: 10;left:200px;top: 16px;">导出</el-button>
<el-main style="padding: 0 20px 20px 20px">
<scTable ref="drawer_table" :apiObj="apiObj2" row-key="id" stripe :params="query2">
<el-table-column type="index" width="50" />
@ -107,6 +109,20 @@
</template>
</el-table-column>
</scTable>
<scTable ref="drawer_table" :apiObj="apiObj2" row-key="id" stripe :params="query2" id="myTable" style="display: none;">
<el-table-column type="index" width="50" />
<el-table-column label="设备名称" prop="equipment_name" show-overflow-tooltip>
</el-table-column>
<el-table-column label="巡检时间" prop="inspect_time">
</el-table-column>
<el-table-column label="巡检结果" prop="result">
<template #default="scope">
<span>{{ results_[scope.row.result] }}</span>
</template>
</el-table-column>
<el-table-column label="巡检人" prop="inspect_user_name">
</el-table-column>
</scTable>
</el-main>
</el-container>
</el-drawer>
@ -215,6 +231,7 @@ export default {
item: {},
visible: false,
visibleRecord: false,
excelName:''
};
},
mounted() {
@ -257,6 +274,7 @@ export default {
this.item = row;
this.form.equipment = row.id;
this.query2.equipment = row.id;
this.excelName = row.name;
this.$nextTick(() => {
this.visibleRecord = true;
})
@ -308,6 +326,11 @@ export default {
resetQuery() {
this.query = {};
},
exportExcel() {
this.exportLoading = true;
this.$XLSX('#myTable', this.excelName)
this.exportLoading = false;
},
},
};
</script>

View File

@ -45,9 +45,9 @@
<el-link type="primary" @click="table_check(scope.row)" v-if="mioObj.state==20&&mioObj.type=='do_in'">
检验
</el-link>
<el-link type="primary" @click="table_Show(scope.row)" v-else>
<!-- <el-link type="primary" @click="table_Show(scope.row)" v-else>
查看
</el-link>
</el-link> -->
<el-link type="danger" @click="table_del(scope.row)" v-if="mioObj.state == 10">
删除
</el-link>

View File

@ -86,7 +86,7 @@
</div>
</el-header>
<el-main class="nopadding">
<GanttComponent class="left-container" :tasks="tasks" :start_date="start_date" :end_date="end_date">
<GanttComponent class="left-container" :tasks="tasks" :start_date="start_date">
</GanttComponent>
</el-main>
</el-container>
@ -142,16 +142,60 @@ export default {
},
methods: {
initDept() {
this.$API.system.dept.list.req({ page: 0, name: '6车间' }).then(res => {
let that = this;
that.$API.system.dept.list.req({ page: 0, name: '6车间' }).then(res => {
if (res.length == 1) {
this.currentDept = res[0]
this.paramsUtask.belong_dept = this.currentDept.id
this.apiUtask = this.$API.pm.utask.list
that.currentDept = res[0]
that.paramsUtask.belong_dept = that.currentDept.id
that.apiUtask = that.$API.pm.utask.list
that.getGantt();
} else {
this.$message.error("未找到车间");
that.$message.error("未找到车间");
}
})
},
getGantt(){
let that = this;
that.$API.pm.utask.list.req(that.paramsUtask).then(res=>{
let list = res.results;
let data = [];
list.forEach(item=>{
let start_date = item.start_date;
let end_date = item.end_date;
let objItem = {};
objItem.id = item.id;
objItem.type = 'utask';
objItem.number = item.number;
objItem.count = item.count;
objItem.text = item.number;
objItem.material_name = item.material_.name;
objItem.material_specification = item.material_.specification;
objItem.material_model = item.material_.model;
objItem.progress = item.count_real / item.count;;
objItem.count_ok = item.count_ok;
objItem.count_real = item.count_real;
objItem.count_notok = item.count_notok;
objItem.state = item.state;
objItem.start_date = start_date;
objItem.mgroup_name = item.mgroup_name;
objItem.open = true;
let oneDay = 24 * 60 * 60 * 1000; //
let firstDate = new Date(start_date);
let secondDate = new Date(end_date);
let timeDiff = Math.abs(secondDate.getTime()-firstDate.getTime());
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff+1;
data.push(objItem)
that.start_date = start_date;
console.log('objItemduration',objItem.duration)
})
that.tasks.data = data;
gantt.parse(that.tasks);
//
gantt.refreshData();
})
},
utaskDepuse() {
let that = this;
if (that.selectedIds.length > 0) {
@ -261,49 +305,58 @@ export default {
objItem.material_name = row.material_.name;
objItem.material_specification = row.material_.specification;
objItem.material_model = row.material_.model;
objItem.progress = 1;
objItem.progress = row.count_real / row.count;;
objItem.count_ok = row.count_ok;
objItem.count_real = row.count_real;
objItem.count_notok = row.count_notok;
objItem.state = row.state;
objItem.start_date = row.start_date;
objItem.start_date = start_date;
objItem.mgroup_name = row.mgroup_name;
objItem.open = true;
let oneDay = 24 * 60 * 60 * 1000; //
let firstDate = new Date(start_date);
let secondDate = new Date(end_date);
let timeDiff = Math.abs(secondDate.getTime()-firstDate.getTime());
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff+1;
data.push(objItem)
this.$API.pm.mtask.list.req({ utask: row.id, page: 0, ordering: 'start_date,mgroup__process__sort' }).then(res => {
res.forEach(item => {
let obj = {};
obj.id = item.id;
obj.type = 'task';
obj.parent = row.id;
obj.number = item.number;
obj.text = item.mgroup_name;
obj.state = item.state;
obj.start = item.start_date;
obj.start_date = item.start_date;
obj.duration = 1;
obj.progress = item.count_real / item.count;
obj.count = item.count;
obj.count_ok = item.count_ok;
obj.count_real = item.count_real;
obj.count_notok = item.count_notok;
obj.state = item.state;
obj.utask = item.utask;
obj.mgroup_name = item.mgroup_name;
// obj.material_name = item.material_out_.name;
// obj.material_specification = item.material_out_.specification;
data.push(obj)
})
// console.log(that.tasks.data)
// console.log('tasks:',that.tasks)
// :gantt
that.start_date = start_date
that.end_date = end_date
that.tasks.data = data
that.end_date = end_date;
that.tasks.data = data;
console.log('objItemduration',objItem.duration)
gantt.parse(that.tasks);
//
gantt.refreshData();
})
// this.$API.pm.mtask.list.req({ utask: row.id, page: 0, ordering: 'start_date,mgroup__process__sort' }).then(res => {
// res.forEach(item => {
// let obj = {};
// obj.id = item.id;
// obj.type = 'task';
// obj.parent = row.id;
// obj.number = item.number;
// obj.text = item.mgroup_name;
// obj.state = item.state;
// obj.start = item.start_date;
// obj.start_date = item.start_date;
// obj.duration = 1;
// obj.progress = item.count_real / item.count;
// obj.count = item.count;
// obj.count_ok = item.count_ok;
// obj.count_real = item.count_real;
// obj.count_notok = item.count_notok;
// obj.state = item.state;
// obj.utask = item.utask;
// obj.mgroup_name = item.mgroup_name;
// data.push(obj)
// })
// // :gantt
// that.start_date = start_date
// that.end_date = end_date
// that.tasks.data = data
// gantt.parse(that.tasks);
// //
// gantt.refreshData();
// })
},
handleSaveSuccess(data, mode) {
this.$refs.table.refresh();

View File

@ -3,6 +3,7 @@
<el-header>
<div class="left-panel">
<el-button type="primary" icon="el-icon-plus" @click="add">新增</el-button>
<el-button type="primary" icon="el-icon-download" @click="exportExcel">导出</el-button>
</div>
<div class="right-panel">
<el-date-picker v-model="query.date" type="date" value-format="YYYY-MM-DD" />
@ -63,11 +64,60 @@
<el-link type="primary" @click="table_edit(scope.row)">编辑
</el-link>
<el-divider direction="vertical"></el-divider>
<el-link type="primary" @click="table_del(scope.row)">删除
<el-link type="danger" @click="table_del(scope.row)">删除
</el-link>
</template>
</el-table-column>
</scTable>
<scTable ref="table" :apiObj="apiObj" row-key="id" stripe :params="query" id="myTable" style="display: none;">
<el-table-column type="index" width="50" />
<el-table-column label="日期" prop="test_date" show-overflow-tooltip>
</el-table-column>
<el-table-column label="工序" prop="number">
</el-table-column>
<el-table-column label="检测内容">
<template #default="scope">
<div v-for="item in scope.row.ftestitems" :key="item.id">
{{ item.testitem_description }}
</div>
</template>
</el-table-column>
<el-table-column label="检测标准" show-overflow-tooltip>
<template #default="scope">
<div v-for="item in scope.row.ftestitems" :key="item.id">
{{ item.testitem_name }}
</div>
</template>
</el-table-column>
<el-table-column label="操作人测量值" prop="production_date">
<template #default="scope">
<div v-for="item in scope.row.ftestitems" :key="item.id">
{{ item.test_val }}
</div>
</template>
</el-table-column>
<el-table-column label="操作人" prop="test_user_name">
</el-table-column>
<el-table-column label="专检人测量值" prop="buy_date">
<template #default="scope">
<div v-for="item in scope.row.ftestitems" :key="item.id">
{{ item.check_val }}
</div>
</template>
</el-table-column>
<el-table-column label="专检人" prop="check_user_name">
</el-table-column>
<el-table-column label="结论">
<template #default="scope">
<span v-if="scope.row.is_ok" type="success">
合格
</span>
<span v-else type="warning">
不合格
</span>
</template>
</el-table-column>
</scTable>
</el-main>
<check-dialog v-if="dialog.check" ref="checkDialog" @success="handleCheckSuccess" @closed="dialog.check = false">
</check-dialog>
@ -85,6 +135,7 @@ export default {
dialog: {
check: false
},
excelName:'首件确认',
// apiObj: this.$API.qm.list,
apiObj: this.$API.qm.ftest.list,
query: {
@ -123,6 +174,11 @@ export default {
resetQuery() {
this.query = {};
},
exportExcel() {
this.exportLoading = true;
this.$XLSX('#myTable', this.excelName)
this.exportLoading = false;
},
},
};
</script>