Blame view

src/views/scheduler/progressRate.vue 6.48 KB
1
2
3
4
5
<template>
  <div>
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="10">
6
7
8
9
10
11
12
13
14
          <a-col :md="6" :sm="24">
            <a-form-item label="项目名称">
              <a-select show-search
                        placeholder="请输入项目名称"
                        option-filter-prop="children"
                        :filter-option="filterOption"
                        @change="handleChange"
                        v-model="queryParam.projectName">
                <a-select-option v-for="item in projectNameList" :key="item" :value="item">{{ item }}</a-select-option>
15
16
17
18
19
20
21
22
23
24
25
26
27
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <gantt-elastic
      :options="options"
      :tasks="tasks"
      @tasks-changed="tasksUpdate"
      @options-changed="optionsUpdate"
      @dynamic-style-changed="styleUpdate"
28
      :dynamic-style="dynamicStyle"
29
30
31
32
33
34
35
36
37
38
39
40
    >
      <gantt-header slot="header" :options="options"></gantt-header>
    </gantt-elastic>
    <div class="q-mt-md" />
  </div>

</template>

<script>
import GanttElastic from 'gantt-elastic'
import GanttHeader from 'gantt-elastic-header'
import moment from 'moment'
41
import { projectName, queryTask } from '../../api/schedulerApi'
42
import dayjs from 'dayjs'
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

function getDate(hours) {
  const currentDate = new Date()
  const currentYear = currentDate.getFullYear()
  const currentMonth = currentDate.getMonth()
  const currentDay = currentDate.getDate()
  const timeStamp = new Date(
    currentYear,
    currentMonth,
    currentDay,
    0,
    0,
    0
  ).getTime()
  return new Date(timeStamp + hours * 60 * 60 * 1000).getTime()
}

let that
let options = {
  taskMapping: {
    progress: "percent"
  },
  maxRows: 100,
  maxHeight: 500,
  title: {
68
    label: "",
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
    html: false
  },
  row: {
    height: 24
  },
  calendar: {
    hour: {
      display: false
    }
  },
  chart: {
    progress: {
      bar: false
    },
    expander: {
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
      type: 'chart',
      display: true, //*
      displayIfTaskListHidden: true, //*
      offset: 4, //*
      size: 18
    },
    text: {
      offset: 4,
      xPadding: 10,
      display: true
    },
    grid: {
      horizontal: {
        gap: 6
      }
99
100
101
102
103
104
105
106
    }
  },
  taskList: {
    expander: {
      straight: false
    },
    columns: [
      {
DESKTOP-AO0VKC8\mahua authored
107
108
109
110
111
        id: 1,
        label: "ID",
        value: "id",
        width: 50
      },
112
113
114
115
116
117
118
119
120
121
122
123
124
      // {
      //   id: 2,
      //   label: "项目名称",
      //   value: "projectName",
      //   width: 150,
      //   expander: true
      // },
      // {
      //   id: 3,
      //   label: "项目编码",
      //   value: "projectCode",
      //   width: 130
      // },
125
126
127
128
      {
        id: 4,
        label: "生产令号",
        value: "orderNo",
DESKTOP-AO0VKC8\mahua authored
129
        width: 100,
130
        expander: true
131
132
133
134
135
136
137
138
139
140
      },
      {
        id: 5,
        label: "部件号",
        value: "partNo",
        width: 100
      },
      {
        id: 5,
        label: "计划开始时间",
141
        value: task => dayjs(task.completionTime).format("YYYY-MM-DD"),
142
143
144
145
146
        width: 100
      },
      {
        id: 6,
        label: "计划完成时间",
147
        value: task => dayjs(task.actualCompletionTime).format("YYYY-MM-DD"),
148
149
150
151
152
153
        width: 100
      },
      {
        id: 7,
        label: "图号",
        value: "drawingNo",
DESKTOP-AO0VKC8\mahua authored
154
155
        width: 120,
        // expander: true
156
157
158
159
160
161
162
163
164
165
166
167
      },
      {
        id: 8,
        label: "名称",
        value: "name",
        width: 120
      },
      {
        id: 9,
        label: "数量",
        value: "qty",
        width: 60
168
169
170
171
172
173
      },
      {
        id: 10,
        label: "状态",
        value: (task) => task.status==0 ? "生产中" : task.status == 1 ? "按时完成":"超时完成",
        width: 60
174
175
176
177
178
179
180
181
      }
    ]
  },
  locale: {
    name: "zh-cn",
    Now: "Now",
    "X-Scale": "Zoom-X",
    "Y-Scale": "Zoom-Y",
DESKTOP-AO0VKC8\mahua authored
182
    "Task list width": "列头宽度",
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
    "Before/After": "Expand",
    "Display task list": "Task list",
    weekdays:["周日","周一","周二","周三","周四","周五","周六"],
    months:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"],
  },
};

let doingStyle = {
  base: {
    fill: '#BFEFFF',
    stroke: '#BFEFFF'
  }
}
let warnStyle = {
  base: {
    fill: '#FF6A6A',
    stroke: '#FF6A6A'
  }
}
let finishStyle = {
  base: {
    fill: '#C1FFC1',
    stroke: '#C1FFC1'
  }
}
let cancelStyle = {
  base: {
    fill: '#BABABA',
    stroke: '#BABABA'
  }
}

export default {
  name: 'progressRate',
  components: {
    GanttElastic,
    GanttHeader
  },
  mounted() {
    that = this
  },
  data() {
    return {
226
      tasks: [],
227
      options,
228
229
230
231
232
      dynamicStyle: {
        'task-list-header-label': {
          'font-weight': 'bold',
        },
      },
233
      lastId: 16,
234
      projectNameList: {},
DESKTOP-AO0VKC8\mahua authored
235
      queryParam: []
236
237
    }
  },
238
239
  created() {
    this.getProjectNameList()
240
241
  },
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
  methods: {
    moment,
    addTask() {
      this.tasks.push({
        id: this.lastId++,
        label:
          '<a href="https://images.pexels.com/photos/423364/pexels-photo-423364.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" target="_blank" style="color:#0077c0;">Yeaahh! you have added a task bro!</a>',
        projectCode:
          '<a href="https://images.pexels.com/photos/423364/pexels-photo-423364.jpeg?auto=compress&cs=tinysrgb&h=650&w=940" target="_blank" style="color:#0077c0;">Awesome!</a>',
        start: getDate(24 * 3),
        duration: 1 * 24 * 60 * 60 * 1000,
        percent: 50,
        type: 'project'
      })
    },
yuanshuhui authored
257
258
259
260
261
262
    tasksUpdate(tasks,num) {
      if(num == 2) {
        this.tasks = tasks
      } else {
        return
      }
263
    },
yuanshuhui authored
264
265
266
267
268
269
    optionsUpdate(options,num) {
      if(num == 2) {
        this.options = options
      } else {
        return
      }
270
271
272
    },
    styleUpdate(style) {
      this.dynamicStyle = style
273
274
275
    },
    getProjectNameList() {
      projectName().then((res) => {
276
        this.projectNameList = res
277
278
279
      })
    },
    handleChange(value) {
280
      this.getTask(value)
281
282
283
284
285
286
    },
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      );
    },
287
288
289
290
    getTask(projectName) {
      if (projectName == null || projectName === "") {
        return;
      }
yuanshuhui authored
291
      let params = {
292
        "projectName": projectName
yuanshuhui authored
293
      };
294
      queryTask(params).then((res)=> {
295
        console.log(res)
296
297
298
299
        if (res.success) {
          this.tasks = res.result
        }
      })
300
301
302
303
304
305
306
307
    }
  }
}
</script>

<style scoped>

</style>