fix:gantt去掉累加,随上表数据变化变化

This commit is contained in:
shijing 2024-03-25 15:50:48 +08:00
parent 89d70548b9
commit 70df6c3837
3 changed files with 1553 additions and 1202 deletions

View File

@ -4,10 +4,20 @@
<el-container>
<el-header>
<div class="'left-panel'">
<el-button type="primary" icon="el-icon-plus" @click="utaskCreate"
v-auth="'utask.create'">新增任务</el-button>
<el-button type="primary" @click="utaskDepuse" v-loading="isLoading"
v-auth="'utask.assgin'">任务分解并下达</el-button>
<el-button
type="primary"
icon="el-icon-plus"
@click="utaskCreate"
v-auth="'utask.create'"
>新增任务</el-button
>
<el-button
type="primary"
@click="utaskDepuse"
v-loading="isLoading"
v-auth="'utask.assgin'"
>任务分解并下达</el-button
>
</div>
<div class="'right-panel'">
<el-date-picker
@ -19,16 +29,38 @@
value-format="YYYY-MM-DD"
style="vertical-align: middle; margin-right: 6px"
/>
<el-button type="primary" @click="utaskSearch" v-loading="isLoading">搜索</el-button>
<el-button
type="primary"
@click="utaskSearch"
v-loading="isLoading"
>搜索</el-button
>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="tables" :apiObj="apiUtask" row-key="id" stripe :params="paramsUtask" @row-click="rowclick"
@selection-change="handleSelectionChange" @dataChange="updateCount">
<scTable
ref="tables"
:apiObj="apiUtask"
row-key="id"
stripe
:params="paramsUtask"
@row-click="rowclick"
@selection-change="handleSelectionChange"
@dataChange="updateCount"
>
<el-table-column type="selection" width="40" />
<el-table-column type="index" width="40" />
<el-table-column label="任务编号" prop="number" width="120"> </el-table-column>
<el-table-column label="产品名称" prop="material_" show-overflow-tooltip>
<el-table-column
label="任务编号"
prop="number"
width="120"
>
</el-table-column>
<el-table-column
label="产品名称"
prop="material_"
show-overflow-tooltip
>
<template #default="scope">
{{ scope.row.material_.name }}
</template>
@ -45,10 +77,16 @@
</el-table-column>
<el-table-column label="任务状态" prop="state">
<template #default="scope">
<el-tag v-if="scope.row.state == 40" type="success">
<el-tag
v-if="scope.row.state == 40"
type="success"
>
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else-if="scope.row.state == 34" type="danger">
<el-tag
v-else-if="scope.row.state == 34"
type="danger"
>
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else>
@ -58,44 +96,98 @@
</el-table-column>
<el-table-column label="任务类型" prop="type">
<template #default="scope">
<el-link v-if="scope.row.type == 'mass'" type="primary">量产</el-link>
<el-link
v-if="scope.row.type == 'mass'"
type="primary"
>量产</el-link
>
<el-link v-else type="success">中试</el-link>
</template>
</el-table-column>
<el-table-column label="任务量" prop="count"> </el-table-column>
<el-table-column label="计划量" prop="count"> </el-table-column>
<el-table-column label="任务量" prop="count">
</el-table-column>
<el-table-column label="计划量" prop="count">
</el-table-column>
<el-table-column label="日均产量" prop="count_day">
</el-table-column>
<el-table-column label="计划开工时间" prop="start_date" width="120">
<el-table-column
label="计划开工时间"
prop="start_date"
width="120"
>
</el-table-column>
<el-table-column label="计划完工时间" prop="end_date" width="120">
<el-table-column
label="计划完工时间"
prop="end_date"
width="120"
>
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
<el-table-column label="合格数" prop="count_ok"> </el-table-column>
<el-table-column label="完成率" prop="count">
<template #default="scope">
<span v-if="scope.row.count != 0&&scope.row.count_ok!= 0">{{ Math.round((scope.row.count_ok / scope.row.count) * 100) }}%</span>
<span
v-if="
scope.row.count != 0 &&
scope.row.count_ok != 0
"
>{{
Math.round(
(scope.row.count_ok /
scope.row.count) *
100
)
}}%</span
>
<span v-else>0</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="150">
<template #default="scope">
<el-button link type="primary" @click.stop="table_show(scope.row)">
<el-button
link
type="primary"
@click.stop="table_show(scope.row)"
>
查看
</el-button>
<el-button link type="primary" @click.stop="table_edit(scope.row)"
v-if="scope.row.state == 10" v-auth="'utask.update'">
<el-button
link
type="primary"
@click.stop="table_edit(scope.row)"
v-if="scope.row.state == 10"
v-auth="'utask.update'"
>
编辑
</el-button>
<el-popconfirm title="确定删除吗?" @confirm.stop="table_del(scope.row)"
v-if="scope.row.state == 10 || scope.row.state == 14" v-auth="'utask.delete'">
<el-popconfirm
title="确定删除吗?"
@confirm.stop="table_del(scope.row)"
v-if="
scope.row.state == 10 ||
scope.row.state == 14
"
v-auth="'utask.delete'"
>
<template #reference>
<el-button link type="danger">删除</el-button>
<el-button link type="danger"
>删除</el-button
>
</template>
</el-popconfirm>
<el-popconfirm title="确定终止该任务吗?" @confirm.stop="table_stop(scope.row)"
v-if="scope.row.state==30" v-auth="'utask.stop'">
<el-popconfirm
title="确定终止该任务吗?"
@confirm.stop="table_stop(scope.row)"
v-if="scope.row.state == 30"
v-auth="'utask.stop'"
>
<template #reference>
<el-button link type="danger" v-if="scope.row.state==30">终止</el-button>
<el-button
link
type="danger"
v-if="scope.row.state == 30"
>终止</el-button
>
</template>
</el-popconfirm>
</template>
@ -105,29 +197,44 @@
</el-container>
</el-header>
<el-main class="nopadding">
<GanttComponent class="left-container" v-if="ganntVisit" :tasks="tasks" :start_date="start_date">
<GanttComponent
class="left-container"
v-if="ganntVisit"
:tasks="tasks"
:start_date="start_date"
>
</GanttComponent>
</el-main>
</el-container>
<showDrawer ref="showDrawer" v-if="visibleDrawer" :utaskId="utaskId" @closed="visibleDrawer = false">
<showDrawer
ref="showDrawer"
v-if="visibleDrawer"
:utaskId="utaskId"
@closed="visibleDrawer = false"
>
</showDrawer>
<save-dialog v-if="dialog.save" ref="saveDialog" :activeDept="currentDept.id" @success="handleSaveSuccess"
@closed="dialog.save = false"></save-dialog>
<save-dialog
v-if="dialog.save"
ref="saveDialog"
:activeDept="currentDept.id"
@success="handleSaveSuccess"
@closed="dialog.save = false"
></save-dialog>
</template>
<script>
import saveDialog from "./utask_form.vue";
import showDrawer from "./mtask_drawer.vue"
import GanttComponent from '@/components/GanttComponent.vue';
import showDrawer from "./mtask_drawer.vue";
import GanttComponent from "@/components/GanttComponent.vue";
export default {
name: 'utask_dept10',
name: "utask_dept10",
components: {
saveDialog,
showDrawer,
GanttComponent
GanttComponent,
},
data() {
return {
utaskId: '',
utaskId: "",
visibleDrawer: false,
isLoading: false,
selectedIds: [],
@ -135,9 +242,9 @@ export default {
save: false,
},
tasks: {
data: []
data: [],
},
dateValue:'',
dateValue: "",
apiUtask: null,
apiObj: null,
ganntVisit: true,
@ -151,48 +258,53 @@ export default {
14: "已分解",
20: "已下达",
30: "生产中",
34:'终止',
34: "终止",
40: "已提交",
},
start_date:''
}
start_date: "",
};
},
mounted() {
this.initDept()
this.initDept();
},
methods: {
initDept() {
let that = this;
that.$API.system.dept.list.req({ page: 0, name: '10车间' }).then(res => {
that.$API.system.dept.list
.req({ page: 0, name: "10车间" })
.then((res) => {
if (res.length == 1) {
that.currentDept = res[0]
that.paramsUtask.belong_dept = that.currentDept.id
that.currentDept = res[0];
that.paramsUtask.belong_dept = that.currentDept.id;
that.apiUtask = that.$API.pm.utask.list;
that.getGantt();
} else {
that.$message.error("未找到车间");
}
})
});
},
updateCount(res, tableData) {
let that = this;
this.count = res.count;
let data = [];
console.log('tableData', tableData)
that.ganntVisit = false;
that.tasks.data = [];
console.log("tableData", tableData);
if (tableData.length > 0) {
tableData.forEach(item=>{
tableData.forEach((item) => {
let start_date = item.start_date;
let end_date = item.end_date;
let objItem = {};
objItem.id = item.id;
objItem.type = 'utask';
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_specification =
item.material_.specification;
objItem.material_model = item.material_.model;
objItem.progress = item.count_real / item.count;;
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;
@ -204,38 +316,40 @@ export default {
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 timeDiff = Math.abs(
secondDate.getTime() - firstDate.getTime()
);
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff + 1;
data.push(objItem)
data.push(objItem);
that.start_date = start_date;
console.log('objItemduration',objItem.duration)
})
});
}
that.ganntVisit = true;
that.tasks.data = data;
that.ganntVisit = true;
gantt.parse(that.tasks);
//
gantt.refreshData();
},
getGantt() {
let that = this;
that.$API.pm.utask.list.req(that.paramsUtask).then(res=>{
that.$API.pm.utask.list.req(that.paramsUtask).then((res) => {
let list = res.results;
let data = [];
list.forEach(item=>{
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.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_specification =
item.material_.specification;
objItem.material_model = item.material_.model;
objItem.progress = item.count_real / item.count;;
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;
@ -247,19 +361,21 @@ export default {
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 timeDiff = Math.abs(
secondDate.getTime() - firstDate.getTime()
);
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff + 1;
data.push(objItem)
data.push(objItem);
that.start_date = start_date;
console.log('objItemduration',objItem.duration)
})
console.log("objItemduration", objItem.duration);
});
that.tasks.data = data;
gantt.parse(that.tasks);
//
gantt.refreshData();
})
});
},
utaskDepuse() {
let that = this;
@ -318,7 +434,9 @@ export default {
});
},
table_stop(row) {
this.$API.pm.utask.stop.req(row.id).then((res) => {
this.$API.pm.utask.stop
.req(row.id)
.then((res) => {
this.$message.success("操作成功");
this.$refs.table.refresh();
return res;
@ -391,13 +509,13 @@ export default {
this.paramsUtask.start_date__gte = start_date;
this.paramsUtask.end_date__lte = end_date;
} else {
this.paramsUtask.start_date__gte = '';
this.paramsUtask.end_date__lte = '';
this.paramsUtask.start_date__gte = "";
this.paramsUtask.end_date__lte = "";
}
this.$refs.tables.refresh();
},
}
}
},
};
</script>
<style scoped>
.countBlock {

View File

@ -4,12 +4,27 @@
<el-container>
<el-header>
<div class="'left-panel'">
<el-button type="primary" icon="el-icon-plus" @click="utaskCreate"
v-auth="'utask.create'">新增任务</el-button>
<el-button type="primary" @click="utaskDepuse" v-loading="isLoading"
v-auth="'utask.schedule'">任务分解</el-button>
<el-button type="primary" @click="utaskAssgin" v-loading="isLoading"
v-auth="'utask.assgin'">任务下达</el-button>
<el-button
type="primary"
icon="el-icon-plus"
@click="utaskCreate"
v-auth="'utask.create'"
>新增任务</el-button
>
<el-button
type="primary"
@click="utaskDepuse"
v-loading="isLoading"
v-auth="'utask.schedule'"
>任务分解</el-button
>
<el-button
type="primary"
@click="utaskAssgin"
v-loading="isLoading"
v-auth="'utask.assgin'"
>任务下达</el-button
>
</div>
<div class="'right-panel'">
<el-date-picker
@ -21,16 +36,38 @@
value-format="YYYY-MM-DD"
style="vertical-align: middle; margin-right: 6px"
/>
<el-button type="primary" @click="utaskSearch" v-loading="isLoading">搜索</el-button>
<el-button
type="primary"
@click="utaskSearch"
v-loading="isLoading"
>搜索</el-button
>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="tables" :apiObj="apiUtask" row-key="id" stripe :params="paramsUtask" @row-click="rowclick"
@selection-change="handleSelectionChange" @dataChange="updateCount">
<scTable
ref="tables"
:apiObj="apiUtask"
row-key="id"
stripe
:params="paramsUtask"
@row-click="rowclick"
@selection-change="handleSelectionChange"
@dataChange="updateCount"
>
<el-table-column type="selection" width="40" />
<el-table-column type="index" width="40" />
<el-table-column label="任务编号" prop="number" width="120"> </el-table-column>
<el-table-column label="产品名称" prop="material_" show-overflow-tooltip>
<el-table-column
label="任务编号"
prop="number"
width="120"
>
</el-table-column>
<el-table-column
label="产品名称"
prop="material_"
show-overflow-tooltip
>
<template #default="scope">
{{ scope.row.material_.name }}
</template>
@ -47,10 +84,16 @@
</el-table-column>
<el-table-column label="任务状态" prop="state">
<template #default="scope">
<el-tag v-if="scope.row.state == 40" type="success">
<el-tag
v-if="scope.row.state == 40"
type="success"
>
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else-if="scope.row.state == 34" type="danger">
<el-tag
v-else-if="scope.row.state == 34"
type="danger"
>
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else>
@ -60,44 +103,95 @@
</el-table-column>
<el-table-column label="任务类型" prop="type">
<template #default="scope">
<el-link v-if="scope.row.type == 'mass'" type="primary">量产</el-link>
<el-link
v-if="scope.row.type == 'mass'"
type="primary"
>量产</el-link
>
<el-link v-else type="success">中试</el-link>
</template>
</el-table-column>
<el-table-column label="任务量" prop="count"> </el-table-column>
<el-table-column label="计划量" prop="count"> </el-table-column>
<el-table-column label="任务量" prop="count">
</el-table-column>
<el-table-column label="计划量" prop="count">
</el-table-column>
<el-table-column label="日均产量" prop="count_day">
</el-table-column>
<el-table-column label="计划开工时间" prop="start_date" width="120">
<el-table-column
label="计划开工时间"
prop="start_date"
width="120"
>
</el-table-column>
<el-table-column label="计划完工时间" prop="end_date" width="120">
<el-table-column
label="计划完工时间"
prop="end_date"
width="120"
>
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
<el-table-column label="合格数" prop="count_ok"> </el-table-column>
<el-table-column label="完成率" prop="count">
<template #default="scope">
<span v-if="scope.row.count != 0&&scope.row.count_ok!= 0">{{ Math.round((scope.row.count_ok / scope.row.count) * 100) }}%</span>
<span
v-if="
scope.row.count != 0 &&
scope.row.count_ok != 0
"
>{{
Math.round(
(scope.row.count_ok /
scope.row.count) *
100
)
}}%</span
>
<span v-else>0</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="150">
<template #default="scope">
<el-button link type="primary" @click.stop="table_show(scope.row)">
<el-button
link
type="primary"
@click.stop="table_show(scope.row)"
>
查看
</el-button>
<el-button link type="primary" @click.stop="table_edit(scope.row)"
v-if="scope.row.state==10" v-auth="'utask.update'">
<el-button
link
type="primary"
@click.stop="table_edit(scope.row)"
v-if="scope.row.state == 10"
v-auth="'utask.update'"
>
编辑
</el-button>
<el-popconfirm title="确定删除吗?" @confirm.stop="table_del(scope.row)"
v-if="scope.row.state==10||scope.row.state==14" v-auth="'utask.delete'">
<el-popconfirm
title="确定删除吗?"
@confirm.stop="table_del(scope.row)"
v-if="
scope.row.state == 10 ||
scope.row.state == 14
"
v-auth="'utask.delete'"
>
<template #reference>
<el-button link type="danger">删除</el-button>
<el-button link type="danger"
>删除</el-button
>
</template>
</el-popconfirm>
<el-popconfirm title="确定终止该任务吗?" @confirm.stop="table_stop(scope.row)"
v-if="scope.row.state==30" v-auth="'utask.stop'">
<el-popconfirm
title="确定终止该任务吗?"
@confirm.stop="table_stop(scope.row)"
v-if="scope.row.state == 30"
v-auth="'utask.stop'"
>
<template #reference>
<el-button link type="danger">终止</el-button>
<el-button link type="danger"
>终止</el-button
>
</template>
</el-popconfirm>
</template>
@ -114,31 +208,46 @@
</div>
</el-header>
<el-main class="nopadding">
<GanttComponent class="left-container" v-if="ganntVisit" :tasks="tasks" :start_date="start_date">
<GanttComponent
class="left-container"
v-if="ganntVisit"
:tasks="tasks"
:start_date="start_date"
>
</GanttComponent>
</el-main>
</el-container>
</el-main>
</el-container>
<save-dialog v-if="dialog.save" ref="saveDialog" :activeDept="currentDept.id" @success="handleSaveSuccess"
@closed="dialog.save = false"></save-dialog>
<showDrawer ref="showDrawer" v-if="visibleDrawer" :utaskId="utaskId" @closed="visibleDrawer = false">
<save-dialog
v-if="dialog.save"
ref="saveDialog"
:activeDept="currentDept.id"
@success="handleSaveSuccess"
@closed="dialog.save = false"
></save-dialog>
<showDrawer
ref="showDrawer"
v-if="visibleDrawer"
:utaskId="utaskId"
@closed="visibleDrawer = false"
>
</showDrawer>
</template>
<script>
import GanttComponent from '@/components/GanttComponent.vue';
import GanttComponent from "@/components/GanttComponent.vue";
import saveDialog from "./utask_form_2.vue";
import showDrawer from "./mtask_drawer.vue"
import showDrawer from "./mtask_drawer.vue";
export default {
name: 'utask_dept6',
name: "utask_dept6",
components: {
saveDialog,
showDrawer,
GanttComponent
GanttComponent,
},
data() {
return {
utaskId: '',
utaskId: "",
visibleDrawer: false,
isLoading: false,
selectedIds: [],
@ -146,11 +255,11 @@ export default {
save: false,
},
query: {
start_date:'',
end_date:'',
start_date: "",
end_date: "",
},
ganntVisit: true,
dateValue:'',
dateValue: "",
apiUtask: null,
currentDept: { id: 0 },
paramsUtask: {},
@ -160,52 +269,57 @@ export default {
14: "已分解",
20: "已下达",
30: "生产中",
34:'终止',
34: "终止",
40: "已提交",
},
tasks: {
data: []
data: [],
},
end_date: '',
start_date: '',
}
end_date: "",
start_date: "",
};
},
mounted() {
this.initDept()
this.initDept();
},
methods: {
initDept() {
let that = this;
that.$API.system.dept.list.req({ page: 0, name: '6车间' }).then(res => {
that.$API.system.dept.list
.req({ page: 0, name: "6车间" })
.then((res) => {
if (res.length == 1) {
that.currentDept = res[0]
that.paramsUtask.belong_dept = that.currentDept.id
that.apiUtask = that.$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 {
that.$message.error("未找到车间");
}
})
});
},
updateCount(res, tableData) {
let that = this;
this.count = res.count;
let data = [];
console.log('tableData', tableData)
that.ganntVisit = false;
that.tasks.data = [];
console.log("tableData", tableData);
if (tableData.length > 0) {
tableData.forEach(item=>{
tableData.forEach((item) => {
let start_date = item.start_date;
let end_date = item.end_date;
let objItem = {};
objItem.id = item.id;
objItem.type = 'utask';
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_specification =
item.material_.specification;
objItem.material_model = item.material_.model;
objItem.progress = item.count_real / item.count;;
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;
@ -217,38 +331,40 @@ export default {
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 timeDiff = Math.abs(
secondDate.getTime() - firstDate.getTime()
);
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff + 1;
data.push(objItem)
data.push(objItem);
that.start_date = start_date;
console.log('objItemduration',objItem.duration)
})
});
}
that.ganntVisit = true;
that.tasks.data = data;
that.ganntVisit = true;
gantt.parse(that.tasks);
//
gantt.refreshData();
},
getGantt() {
let that = this;
that.$API.pm.utask.list.req(that.paramsUtask).then(res=>{
that.$API.pm.utask.list.req(that.paramsUtask).then((res) => {
let list = res.results;
let data = [];
list.forEach(item=>{
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.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_specification =
item.material_.specification;
objItem.material_model = item.material_.model;
objItem.progress = item.count_real / item.count;;
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;
@ -260,19 +376,21 @@ export default {
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 timeDiff = Math.abs(
secondDate.getTime() - firstDate.getTime()
);
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff + 1;
data.push(objItem)
data.push(objItem);
that.start_date = start_date;
console.log('objItemduration',objItem.duration)
})
console.log("objItemduration", objItem.duration);
});
that.tasks.data = data;
gantt.parse(that.tasks);
//
gantt.refreshData();
})
});
},
utaskDepuse() {
let that = this;
@ -343,7 +461,9 @@ export default {
});
},
table_stop(row) {
this.$API.pm.utask.stop.req(row.id).then((res) => {
this.$API.pm.utask.stop
.req(row.id)
.then((res) => {
this.$message.success("操作成功");
this.$refs.table.refresh();
return res;
@ -386,14 +506,14 @@ export default {
let end_date = row.end_date;
let objItem = {};
objItem.id = row.id;
objItem.type = 'utask';
objItem.type = "utask";
objItem.number = row.number;
objItem.count = row.count;
objItem.text = row.number;
objItem.material_name = row.material_.name;
objItem.material_specification = row.material_.specification;
objItem.material_model = row.material_.model;
objItem.progress = row.count_real / row.count;;
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;
@ -407,11 +527,11 @@ export default {
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
data.push(objItem);
that.start_date = start_date;
that.end_date = end_date;
that.tasks.data = data;
console.log('objItemduration',objItem.duration)
console.log("objItemduration", objItem.duration);
gantt.parse(that.tasks);
//
gantt.refreshData();
@ -457,13 +577,13 @@ export default {
this.paramsUtask.start_date__gte = start_date;
this.paramsUtask.end_date__lte = end_date;
} else {
this.paramsUtask.start_date__gte = '';
this.paramsUtask.end_date__lte = '';
this.paramsUtask.start_date__gte = "";
this.paramsUtask.end_date__lte = "";
}
this.$refs.tables.refresh();
},
}
}
},
};
</script>
<style scoped>
.countBlock {

View File

@ -4,10 +4,20 @@
<el-container>
<el-header>
<div class="'left-panel'">
<el-button type="primary" icon="el-icon-plus" @click="utaskCreate"
v-auth="'utask.create'">新增任务</el-button>
<el-button type="primary" @click="utaskDepuse" v-loading="isLoading"
v-auth="'utask.assgin'">任务分解并下达</el-button>
<el-button
type="primary"
icon="el-icon-plus"
@click="utaskCreate"
v-auth="'utask.create'"
>新增任务</el-button
>
<el-button
type="primary"
@click="utaskDepuse"
v-loading="isLoading"
v-auth="'utask.assgin'"
>任务分解并下达</el-button
>
</div>
<div class="'right-panel'">
<el-date-picker
@ -19,16 +29,39 @@
value-format="YYYY-MM-DD"
style="vertical-align: middle; margin-right: 6px"
/>
<el-button type="primary" @click="utaskSearch" v-loading="isLoading">搜索</el-button>
<el-button
type="primary"
@click="utaskSearch"
v-loading="isLoading"
>搜索</el-button
>
</div>
</el-header>
<el-main class="nopadding">
<scTable ref="tables" :apiObj="apiUtask" row-key="id" stripe :params="paramsUtask" :query="queryUtask" @row-click="rowclick"
@selection-change="handleSelectionChange" @dataChange="updateCount">
<scTable
ref="tables"
:apiObj="apiUtask"
row-key="id"
stripe
:params="paramsUtask"
:query="queryUtask"
@row-click="rowclick"
@selection-change="handleSelectionChange"
@dataChange="updateCount"
>
<el-table-column type="selection" width="40" />
<el-table-column type="index" width="40" />
<el-table-column label="任务编号" prop="number" width="120"> </el-table-column>
<el-table-column label="产品名称" prop="material_" show-overflow-tooltip>
<el-table-column
label="任务编号"
prop="number"
width="120"
>
</el-table-column>
<el-table-column
label="产品名称"
prop="material_"
show-overflow-tooltip
>
<template #default="scope">
{{ scope.row.material_.name }}
</template>
@ -45,10 +78,16 @@
</el-table-column>
<el-table-column label="任务状态" prop="state">
<template #default="scope">
<el-tag v-if="scope.row.state == 40" type="success">
<el-tag
v-if="scope.row.state == 40"
type="success"
>
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else-if="scope.row.state == 34" type="danger">
<el-tag
v-else-if="scope.row.state == 34"
type="danger"
>
{{ state_[scope.row.state] }}
</el-tag>
<el-tag v-else>
@ -58,44 +97,95 @@
</el-table-column>
<el-table-column label="任务类型" prop="type">
<template #default="scope">
<el-link v-if="scope.row.type == 'mass'" type="primary">量产</el-link>
<el-link
v-if="scope.row.type == 'mass'"
type="primary"
>量产</el-link
>
<el-link v-else type="success">中试</el-link>
</template>
</el-table-column>
<el-table-column label="任务量" prop="count"> </el-table-column>
<el-table-column label="计划量" prop="count"> </el-table-column>
<el-table-column label="任务量" prop="count">
</el-table-column>
<el-table-column label="计划量" prop="count">
</el-table-column>
<el-table-column label="日均产量" prop="count_day">
</el-table-column>
<el-table-column label="计划开工时间" prop="start_date" width="120">
<el-table-column
label="计划开工时间"
prop="start_date"
width="120"
>
</el-table-column>
<el-table-column label="计划完工时间" prop="end_date" width="120">
<el-table-column
label="计划完工时间"
prop="end_date"
width="120"
>
</el-table-column>
<el-table-column label="合格数" prop="count_ok">
</el-table-column>
<el-table-column label="合格数" prop="count_ok"> </el-table-column>
<el-table-column label="完成率">
<template #default="scope">
<span v-if="scope.row.count != 0&&scope.row.count_ok != 0">{{ Math.round(scope.row.count_ok / scope.row.count*100) }}%</span>
<span
v-if="
scope.row.count != 0 &&
scope.row.count_ok != 0
"
>{{
Math.round(
(scope.row.count_ok /
scope.row.count) *
100
)
}}%</span
>
<span v-else>0</span>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="150">
<template #default="scope">
<el-button link type="primary" @click.stop="table_show(scope.row)">
<el-button
link
type="primary"
@click.stop="table_show(scope.row)"
>
查看
</el-button>
<el-button link type="primary" @click.stop="table_edit(scope.row)"
v-if="scope.row.state == 10" v-auth="'utask.update'">
<el-button
link
type="primary"
@click.stop="table_edit(scope.row)"
v-if="scope.row.state == 10"
v-auth="'utask.update'"
>
编辑
</el-button>
<el-popconfirm title="确定删除吗?" @confirm.stop="table_del(scope.row)"
v-if="scope.row.state == 10 || scope.row.state == 14" v-auth="'utask.delete'">
<el-popconfirm
title="确定删除吗?"
@confirm.stop="table_del(scope.row)"
v-if="
scope.row.state == 10 ||
scope.row.state == 14
"
v-auth="'utask.delete'"
>
<template #reference>
<el-button link type="danger">删除</el-button>
<el-button link type="danger"
>删除</el-button
>
</template>
</el-popconfirm>
<el-popconfirm title="确定终止该任务吗?" @confirm.stop="table_stop(scope.row)"
v-if="scope.row.state==30" v-auth="'utask.stop'">
<el-popconfirm
title="确定终止该任务吗?"
@confirm.stop="table_stop(scope.row)"
v-if="scope.row.state == 30"
v-auth="'utask.stop'"
>
<template #reference>
<el-button link type="danger">终止</el-button>
<el-button link type="danger"
>终止</el-button
>
</template>
</el-popconfirm>
</template>
@ -140,29 +230,44 @@
</scTable>
</el-main>
</el-container> -->
<GanttComponent class="left-container" :tasks="tasks" v-if="ganntVisit" :start_date="start_date">
<GanttComponent
class="left-container"
:tasks="tasks"
v-if="ganntVisit"
:start_date="start_date"
>
</GanttComponent>
</el-main>
</el-container>
<showDrawer ref="showDrawer" v-if="visibleDrawer" :utaskId="utaskId" @closed="visibleDrawer = false">
<showDrawer
ref="showDrawer"
v-if="visibleDrawer"
:utaskId="utaskId"
@closed="visibleDrawer = false"
>
</showDrawer>
<save-dialog v-if="dialog.save" ref="saveDialog" :activeDept="currentDept.id" @success="handleSaveSuccess"
@closed="dialog.save = false"></save-dialog>
<save-dialog
v-if="dialog.save"
ref="saveDialog"
:activeDept="currentDept.id"
@success="handleSaveSuccess"
@closed="dialog.save = false"
></save-dialog>
</template>
<script>
import saveDialog from "./utask_form.vue";
import showDrawer from "./mtask_drawer.vue";
import GanttComponent from '@/components/GanttComponent.vue';
import GanttComponent from "@/components/GanttComponent.vue";
export default {
name: 'utask_dept7',
name: "utask_dept7",
components: {
saveDialog,
showDrawer,
GanttComponent
GanttComponent,
},
data() {
return {
utaskId: '',
utaskId: "",
visibleDrawer: false,
isLoading: false,
selectedIds: [],
@ -170,7 +275,7 @@ export default {
save: false,
},
tasks: {
data: []
data: [],
},
ganntVisit: true,
dateValue: [],
@ -186,12 +291,12 @@ export default {
14: "已分解",
20: "已下达",
30: "生产中",
34:'终止',
34: "终止",
40: "已提交",
},
start_date: '',
newDate:''
}
start_date: "",
newDate: "",
};
},
mounted() {
this.initDept();
@ -199,7 +304,9 @@ export default {
methods: {
initDept() {
let that = this;
that.$API.system.dept.list.req({ page: 0, name: '7车间' }).then(res => {
that.$API.system.dept.list
.req({ page: 0, name: "7车间" })
.then((res) => {
if (res.length == 1) {
that.currentDept = res[0];
that.paramsUtask.belong_dept = that.currentDept.id;
@ -209,27 +316,30 @@ export default {
} else {
that.$message.error("未找到车间");
}
})
});
},
updateCount(res, tableData) {
let that = this;
this.count = res.count;
let data = [];
console.log('tableData', tableData)
that.ganntVisit = false;
that.tasks.data = [];
console.log("tableData", tableData);
if (tableData.length > 0) {
tableData.forEach(item=>{
tableData.forEach((item) => {
let start_date = item.start_date;
let end_date = item.end_date;
let objItem = {};
objItem.id = item.id;
objItem.type = 'utask';
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_specification =
item.material_.specification;
objItem.material_model = item.material_.model;
objItem.progress = item.count_real / item.count;;
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;
@ -241,16 +351,17 @@ export default {
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 timeDiff = Math.abs(
secondDate.getTime() - firstDate.getTime()
);
let daysDiff = Math.ceil(timeDiff / oneDay);
objItem.duration = daysDiff + 1;
data.push(objItem)
data.push(objItem);
that.start_date = start_date;
console.log('objItemduration',objItem.duration)
})
});
}
that.ganntVisit = true;
that.tasks.data = data;
that.ganntVisit = true;
gantt.parse(that.tasks);
//
gantt.refreshData();
@ -312,7 +423,9 @@ export default {
});
},
table_stop(row) {
this.$API.pm.utask.stop.req(row.id).then((res) => {
this.$API.pm.utask.stop
.req(row.id)
.then((res) => {
this.$message.success("操作成功");
this.$refs.table.refresh();
return res;
@ -352,7 +465,7 @@ export default {
this.$refs.table.refresh();
},
utaskSearch() {
console.log('this.dateValue',this.dateValue);
console.log("this.dateValue", this.dateValue);
this.ganntVisit = false;
if (this.dateValue && this.dateValue.length > 0) {
let start_date = this.dateValue[0];
@ -360,13 +473,13 @@ export default {
this.paramsUtask.start_date__gte = start_date;
this.paramsUtask.end_date__lte = end_date;
} else {
this.paramsUtask.start_date__gte = '';
this.paramsUtask.end_date__lte = '';
this.paramsUtask.start_date__gte = "";
this.paramsUtask.end_date__lte = "";
}
this.$refs.tables.refresh();
},
}
}
},
};
</script>
<style scoped>
.countBlock {