|
@@ -5,29 +5,41 @@
|
|
|
|
|
|
<script>
|
|
|
import {gantt} from 'dhtmlx-gantt';
|
|
|
-import {getDeviceList,getJhList} from '@/api/api'
|
|
|
+import {getDeviceList, getJhList, getManagerList, getCgqList} from '@/api/api'
|
|
|
export default {
|
|
|
name: 'gantt',
|
|
|
- props: {
|
|
|
- tasks: {
|
|
|
- type: Object,
|
|
|
- default () {
|
|
|
- return {data: [], links: [], collections:{}}
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
+ // props: {
|
|
|
+ // tasks: {
|
|
|
+ // type: Object,
|
|
|
+ // default () {
|
|
|
+ // return {data: [], links: [], collections:{}}
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // },
|
|
|
data () {
|
|
|
return {
|
|
|
- queryParam:{
|
|
|
- weituoId: undefined
|
|
|
- }
|
|
|
+ tasks: {
|
|
|
+ data: [
|
|
|
+ ],
|
|
|
+ collections: {
|
|
|
+ staff:[],
|
|
|
+ manager:[],
|
|
|
+ chuanganqi:[],
|
|
|
+ },
|
|
|
+ queryParam:{
|
|
|
+ weituoNo: undefined
|
|
|
+ }
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
this.getDevicelist();
|
|
|
+ this.getCgqlist();
|
|
|
+ this.getManagerList();
|
|
|
console.log(1112,this.tasks)
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 获取设备下拉列表
|
|
|
getDevicelist(){
|
|
|
getDeviceList().then((res) => {
|
|
|
this.tasks.collections.staff = res.map(response =>{
|
|
@@ -36,14 +48,43 @@ export default {
|
|
|
label: response.deviceName
|
|
|
}
|
|
|
})
|
|
|
- console.log('this.tasks.collections.staff:',this.tasks.collections.staff)
|
|
|
- this.tasks.collections.staff2.push(
|
|
|
- { id: 2, label: '999' },
|
|
|
- { id: 3, label: '777' }
|
|
|
- )
|
|
|
+ // console.log('this.tasks.collections.staff:',this.tasks.collections.staff)
|
|
|
+ // this.tasks.collections.manager.push(
|
|
|
+ // { id: 2, label: '999' },
|
|
|
+ // { id: 3, label: '777' }
|
|
|
+ // )
|
|
|
+ this.initData()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取项目经理下拉列表
|
|
|
+ getManagerList(){
|
|
|
+ var query ={
|
|
|
+ position: "项目经理"
|
|
|
+ }
|
|
|
+ getManagerList(query).then((res) => {
|
|
|
+ console.log(17,res)
|
|
|
+ this.tasks.collections.manager = res.map(response =>{
|
|
|
+ return {
|
|
|
+ value: response.id,
|
|
|
+ label: response.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.initData()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 获取传感器下拉列表
|
|
|
+ getCgqlist(){
|
|
|
+ getCgqList().then((res) => {
|
|
|
+ this.tasks.collections.chuanganqi = res.map(response =>{
|
|
|
+ return {
|
|
|
+ value: response.id,
|
|
|
+ label: response.xuliehao
|
|
|
+ }
|
|
|
+ })
|
|
|
this.initData()
|
|
|
})
|
|
|
},
|
|
|
+ // 通过委托编号查询检测项目
|
|
|
getinit(queryParam){
|
|
|
console.log(22,queryParam)
|
|
|
getJhList(queryParam).then((res) => {
|
|
@@ -55,15 +96,39 @@ export default {
|
|
|
start_date:res.jihuaStartDate,
|
|
|
duration:res.lastTime,
|
|
|
sampleName:res.sampleName,
|
|
|
- testItems:res.testItems
|
|
|
-
|
|
|
+ testItems:res.testItems,
|
|
|
+ taskProgress: res.status
|
|
|
}
|
|
|
})
|
|
|
gantt.init(this.$refs.gantt);
|
|
|
- gantt.parse(this.$props.tasks);
|
|
|
+ // gantt.parse(this.$props.tasks);
|
|
|
+ gantt.parse(this.tasks);
|
|
|
console.log(33,this.tasks)
|
|
|
})
|
|
|
},
|
|
|
+ // 提交
|
|
|
+ searchReset() {
|
|
|
+ console.log(this.tasks)
|
|
|
+ },
|
|
|
+ // // 今日线
|
|
|
+ // createTodayLine() {
|
|
|
+ // var dateToStr = gantt.date.date_to_str("%Y年%M%d日");
|
|
|
+ // var markerId = gantt.addMarker({
|
|
|
+ // id: 'markerLine',
|
|
|
+ // start_date: new Date(),
|
|
|
+ // css: "today",
|
|
|
+ // text: "今日",
|
|
|
+ // title: dateToStr(new Date())
|
|
|
+ // });
|
|
|
+ // gantt.updateMarker(markerId);
|
|
|
+ // },
|
|
|
+ // //定位到今日线
|
|
|
+ // changeToday() {
|
|
|
+ // this.$nextTick(() => {
|
|
|
+ // let ganTT = document.getElementsByClassName('gantt_marker today')
|
|
|
+ // gantt.scrollTo(ganTT[0].offsetLeft-300, null);
|
|
|
+ // })
|
|
|
+ // },
|
|
|
initData(){
|
|
|
// 启用动态加载
|
|
|
gantt.config.branch_loading = true
|
|
@@ -89,6 +154,26 @@ export default {
|
|
|
},
|
|
|
{ view: "scrollbar", scroll: "x", id: "scrollHor", height: 20 }
|
|
|
],
|
|
|
+ // rows: [
|
|
|
+ // {
|
|
|
+ // cols: [
|
|
|
+ // {
|
|
|
+ // width:400,
|
|
|
+ // min_width: 300,
|
|
|
+ // rows:[
|
|
|
+ // {view: "grid", scrollX: "gridScroll", scrollable: true, scrollY: "scrollVer"},
|
|
|
+ // {view: "scrollbar", id: "gridScroll", group:"horizontal"} ]
|
|
|
+ // },
|
|
|
+ // {resizer: true, width: 1},
|
|
|
+ // {
|
|
|
+ // rows:[
|
|
|
+ // {view: "timeline", scrollX: "scrollHor", scrollY: "scrollVer"},
|
|
|
+ // {view: "scrollbar", id: "scrollHor", group:"horizontal"} ]
|
|
|
+ // },
|
|
|
+ // {view: "scrollbar", id: "scrollVer"}
|
|
|
+ // ]
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
// cols: [
|
|
|
// {
|
|
|
// width:400,
|
|
@@ -108,6 +193,11 @@ export default {
|
|
|
};
|
|
|
// 重置布局
|
|
|
gantt.resetLayout();
|
|
|
+ // var state = gantt.getState();
|
|
|
+
|
|
|
+ // console.log(55,state.min_date);
|
|
|
+
|
|
|
+ // console.log(66,state.max_date);
|
|
|
gantt.config.start_on_monday = true;
|
|
|
gantt.config.work_time = true;
|
|
|
gantt.config.fit_tasks = true; //自动调整图表坐标轴区间用于适配task的长度
|
|
@@ -142,11 +232,12 @@ export default {
|
|
|
taskProjectType_1: "普通任务",
|
|
|
section_head: "项目经理:",
|
|
|
section_device: "试验设备:",
|
|
|
+ section_sensor: "传感器:",
|
|
|
section_priority: '优先级:',
|
|
|
taskProgress: '任务状态',
|
|
|
- taskProgress_0: "未开始",
|
|
|
- taskProgress_1: "进行中",
|
|
|
- taskProgress_2: "已完成",
|
|
|
+ taskProgress_0: "未确认",
|
|
|
+ taskProgress_1: "已确认",
|
|
|
+ taskProgress_2: "完成",
|
|
|
taskProgress_3: "已延期",
|
|
|
taskProgress_4: "搁置中",
|
|
|
section_template: 'Details',
|
|
@@ -212,32 +303,58 @@ export default {
|
|
|
gantt.config.columns = [
|
|
|
// { name: "text", min_width:100,max_width:200, label:"任务", align: "left",resize: true, tree: true },
|
|
|
{ name: "testItems", label: "检测项目", width: 130, resize: true, align: "left",resize: true, tree: true },
|
|
|
- { name: "sampleName", label: "样品名称", width: 130, resize: true, align: "center" },
|
|
|
- { name: "start_date", label: "开始时间", width: 130, resize: true, align: "center" },
|
|
|
- { name: "end_date", label: "结束时间", width: 130, resize: true, align: "center" },
|
|
|
+ { name: "sampleName", label: "样品名称", width: 90, resize: true, align: "center" },
|
|
|
+ { name: "start_date", label: "开始时间", width: 100, resize: true, align: "center" },
|
|
|
+ { name: "end_date", label: "结束时间", width: 100, resize: true, align: "center" },
|
|
|
+ // { name: "taskProgress", label: "状态", width: 130, resize: true, align: "center", options: [
|
|
|
+ // { key: "0", label: gantt.locale.labels.taskProgress_0 },
|
|
|
+ // { key: "1", label: gantt.locale.labels.taskProgress_1 },
|
|
|
+ // { key: "2", label: gantt.locale.labels.taskProgress_2 },
|
|
|
+ // ],
|
|
|
+ // template:function(obj){
|
|
|
+ // let re = '';
|
|
|
+ // switch (obj.taskProgress) {
|
|
|
+ // case "0":
|
|
|
+ // re = `<div class='taskProgress color_bg_1' >未开始</div>`
|
|
|
+ // break;
|
|
|
+ // case "1":
|
|
|
+ // re = `<div class='taskProgress color_bg_2' >进行中</div>`
|
|
|
+ // break;
|
|
|
+ // case "2":
|
|
|
+ // re = `<div class='taskProgress color_bg_3' >已完成</div>`
|
|
|
+ // break;
|
|
|
+ // }
|
|
|
+ // return re}
|
|
|
+ // },
|
|
|
{ name: "add", label:"", width: 30 }
|
|
|
];
|
|
|
- //弹出层
|
|
|
+ //弹出层(灯箱)
|
|
|
gantt.config.lightbox.sections = [
|
|
|
- { name: "text", height: 30, map_to: "text", type: "textarea", focus: true, width: "*" },
|
|
|
+ // { name: "text", height: 30, map_to: "text", type: "textarea", focus: true, width: "*" },
|
|
|
{
|
|
|
name: "time", height: 40, map_to: "auto", type: "duration",
|
|
|
time_format: ["%Y", "%m", "%d"],
|
|
|
+
|
|
|
},
|
|
|
- { name: "head", height: 30, map_to: "head_id", type: "select", options:gantt.serverList("staff2") },
|
|
|
+ { name: "head", height: 30, map_to: "head_id", type: "select", options:gantt.serverList("manager") },
|
|
|
{
|
|
|
name: "device", height: 30, map_to: "device_id", type: "select", options: gantt.serverList('staff',[]),
|
|
|
},
|
|
|
- { name: "description", height: 70, map_to: "description", type: "textarea" },
|
|
|
+ {
|
|
|
+ name: "sensor", height: 30, map_to: "sensor_id", type: "select", options: gantt.serverList('chuanganqi',[]),
|
|
|
+ },
|
|
|
+ // { name: "description", height: 70, map_to: "description", type: "textarea" },
|
|
|
// {
|
|
|
// name: "priority", height: 40, map_to: "priority", type: "radio", options: gantt.serverList("priority")
|
|
|
// },
|
|
|
|
|
|
];
|
|
|
+
|
|
|
|
|
|
|
|
|
gantt.init(this.$refs.gantt);
|
|
|
- gantt.parse(this.$props.tasks);
|
|
|
+ // gantt.parse(this.$props.tasks);
|
|
|
+ gantt.parse(this.tasks);
|
|
|
}
|
|
|
}
|
|
|
}
|