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 () { mounted: function () {
let that = this;
gantt.clearAll();// gantt.clearAll();//
gantt.i18n.setLocale('cn'); // gantt.i18n.setLocale('cn'); //
gantt.config.date_format = "%Y-%m-%d"; gantt.config.date_format = "%Y-%m-%d";
@ -36,6 +37,13 @@ export default {
gantt.config.autosize = true;// gantt.config.autosize = true;//
gantt.plugins({ tooltip: true }); gantt.plugins({ tooltip: true });
gantt.config.bar_height = 20; //task 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.start_date = new Date(2023, 9, 1);
// gantt.config.end_date = new Date(2023, 9, 10); // gantt.config.end_date = new Date(2023, 9, 10);
// //
@ -63,6 +71,44 @@ export default {
'<br/>完工时间:' + gantt.templates.tooltip_date_format(start); '<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.autosize = true;
// gantt.config.open_split_tasks = 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-drawer title="检定记录" v-model="visibleRecord" :size="1000" destroy-on-close @closed="visibleRecord = false">
<el-container v-loading="loading"> <el-container v-loading="loading">
<el-button type="primary" icon="el-icon-plus" @click="record_create" v-auth="'equipment'" <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"> <el-main style="padding: 0 20px 20px 20px">
<scTable ref="drawer_table" :apiObj="apiObj2" row-key="id" stripe :params="query2"> <scTable ref="drawer_table" :apiObj="apiObj2" row-key="id" stripe :params="query2">
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
@ -107,6 +109,20 @@
</template> </template>
</el-table-column> </el-table-column>
</scTable> </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-main>
</el-container> </el-container>
</el-drawer> </el-drawer>
@ -215,6 +231,7 @@ export default {
item: {}, item: {},
visible: false, visible: false,
visibleRecord: false, visibleRecord: false,
excelName:''
}; };
}, },
mounted() { mounted() {
@ -257,6 +274,7 @@ export default {
this.item = row; this.item = row;
this.form.equipment = row.id; this.form.equipment = row.id;
this.query2.equipment = row.id; this.query2.equipment = row.id;
this.excelName = row.name;
this.$nextTick(() => { this.$nextTick(() => {
this.visibleRecord = true; this.visibleRecord = true;
}) })
@ -308,6 +326,11 @@ export default {
resetQuery() { resetQuery() {
this.query = {}; this.query = {};
}, },
exportExcel() {
this.exportLoading = true;
this.$XLSX('#myTable', this.excelName)
this.exportLoading = false;
},
}, },
}; };
</script> </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 type="primary" @click="table_check(scope.row)" v-if="mioObj.state==20&&mioObj.type=='do_in'">
检验 检验
</el-link> </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 type="danger" @click="table_del(scope.row)" v-if="mioObj.state == 10">
删除 删除
</el-link> </el-link>

View File

@ -86,7 +86,7 @@
</div> </div>
</el-header> </el-header>
<el-main class="nopadding"> <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> </GanttComponent>
</el-main> </el-main>
</el-container> </el-container>
@ -142,16 +142,60 @@ export default {
}, },
methods: { methods: {
initDept() { 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) { if (res.length == 1) {
this.currentDept = res[0] that.currentDept = res[0]
this.paramsUtask.belong_dept = this.currentDept.id that.paramsUtask.belong_dept = that.currentDept.id
this.apiUtask = this.$API.pm.utask.list that.apiUtask = that.$API.pm.utask.list
that.getGantt();
} else { } 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() { utaskDepuse() {
let that = this; let that = this;
if (that.selectedIds.length > 0) { if (that.selectedIds.length > 0) {
@ -261,49 +305,58 @@ export default {
objItem.material_name = row.material_.name; objItem.material_name = row.material_.name;
objItem.material_specification = row.material_.specification; objItem.material_specification = row.material_.specification;
objItem.material_model = row.material_.model; objItem.material_model = row.material_.model;
objItem.progress = 1; objItem.progress = row.count_real / row.count;;
objItem.count_ok = row.count_ok; objItem.count_ok = row.count_ok;
objItem.count_real = row.count_real; objItem.count_real = row.count_real;
objItem.count_notok = row.count_notok; objItem.count_notok = row.count_notok;
objItem.state = row.state; objItem.state = row.state;
objItem.start_date = row.start_date; objItem.start_date = start_date;
objItem.mgroup_name = row.mgroup_name; objItem.mgroup_name = row.mgroup_name;
objItem.open = true; 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) data.push(objItem)
this.$API.pm.mtask.list.req({ utask: row.id, page: 0, ordering: 'start_date,mgroup__process__sort' }).then(res => { that.start_date = start_date
res.forEach(item => { that.end_date = end_date;
let obj = {}; that.tasks.data = data;
obj.id = item.id; console.log('objItemduration',objItem.duration)
obj.type = 'task'; gantt.parse(that.tasks);
obj.parent = row.id; //
obj.number = item.number; gantt.refreshData();
obj.text = item.mgroup_name; // this.$API.pm.mtask.list.req({ utask: row.id, page: 0, ordering: 'start_date,mgroup__process__sort' }).then(res => {
obj.state = item.state; // res.forEach(item => {
obj.start = item.start_date; // let obj = {};
obj.start_date = item.start_date; // obj.id = item.id;
obj.duration = 1; // obj.type = 'task';
obj.progress = item.count_real / item.count; // obj.parent = row.id;
obj.count = item.count; // obj.number = item.number;
obj.count_ok = item.count_ok; // obj.text = item.mgroup_name;
obj.count_real = item.count_real; // obj.state = item.state;
obj.count_notok = item.count_notok; // obj.start = item.start_date;
obj.state = item.state; // obj.start_date = item.start_date;
obj.utask = item.utask; // obj.duration = 1;
obj.mgroup_name = item.mgroup_name; // obj.progress = item.count_real / item.count;
// obj.material_name = item.material_out_.name; // obj.count = item.count;
// obj.material_specification = item.material_out_.specification; // obj.count_ok = item.count_ok;
data.push(obj) // obj.count_real = item.count_real;
}) // obj.count_notok = item.count_notok;
// console.log(that.tasks.data) // obj.state = item.state;
// console.log('tasks:',that.tasks) // obj.utask = item.utask;
// :gantt // obj.mgroup_name = item.mgroup_name;
that.start_date = start_date // data.push(obj)
that.end_date = end_date // })
that.tasks.data = data // // :gantt
gantt.parse(that.tasks); // that.start_date = start_date
// // that.end_date = end_date
gantt.refreshData(); // that.tasks.data = data
}) // gantt.parse(that.tasks);
// //
// gantt.refreshData();
// })
}, },
handleSaveSuccess(data, mode) { handleSaveSuccess(data, mode) {
this.$refs.table.refresh(); this.$refs.table.refresh();

View File

@ -3,6 +3,7 @@
<el-header> <el-header>
<div class="left-panel"> <div class="left-panel">
<el-button type="primary" icon="el-icon-plus" @click="add">新增</el-button> <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>
<div class="right-panel"> <div class="right-panel">
<el-date-picker v-model="query.date" type="date" value-format="YYYY-MM-DD" /> <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 type="primary" @click="table_edit(scope.row)">编辑
</el-link> </el-link>
<el-divider direction="vertical"></el-divider> <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> </el-link>
</template> </template>
</el-table-column> </el-table-column>
</scTable> </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> </el-main>
<check-dialog v-if="dialog.check" ref="checkDialog" @success="handleCheckSuccess" @closed="dialog.check = false"> <check-dialog v-if="dialog.check" ref="checkDialog" @success="handleCheckSuccess" @closed="dialog.check = false">
</check-dialog> </check-dialog>
@ -85,6 +135,7 @@ export default {
dialog: { dialog: {
check: false check: false
}, },
excelName:'首件确认',
// apiObj: this.$API.qm.list, // apiObj: this.$API.qm.list,
apiObj: this.$API.qm.ftest.list, apiObj: this.$API.qm.ftest.list,
query: { query: {
@ -123,6 +174,11 @@ export default {
resetQuery() { resetQuery() {
this.query = {}; this.query = {};
}, },
exportExcel() {
this.exportLoading = true;
this.$XLSX('#myTable', this.excelName)
this.exportLoading = false;
},
}, },
}; };
</script> </script>