Blame view

src/views/scheduler/progressRate.vue 7.01 KB
1
2
3
<template>
  <div>
    <div class="table-page-search-wrapper">
hh authored
4
      <!-- <a-form layout="inline">
5
        <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
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
hh authored
19
      </a-form> -->
20
21
    </div>
hh authored
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
        <a-row :gutter="10">
          <a-col :md="6" :sm="8">
                  <a-form-item label="工作令号">
                    <!--  <a-input placeholder="请输入工作令号" v-model="queryParam.workNo"></a-input>-->
                    <j-popup  v-model="queryParam" code="find_projectc" field="field0056" orgFields="field0056" destFields="field0056" :multi="false"/>
                  </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
                <a-button type="primary" @click="handleChange(queryParam)">查询</a-button>
                <a-button style="margin-left: 8px" @click="() => (queryParam = {})">重置</a-button>
          </a-col>
        </a-row>
      </a-form>
    </div>
38
39
40
41
42
43
    <gantt-elastic
      :options="options"
      :tasks="tasks"
      @tasks-changed="tasksUpdate"
      @options-changed="optionsUpdate"
      @dynamic-style-changed="styleUpdate"
44
      :dynamic-style="dynamicStyle"
45
46
47
48
49
50
51
52
53
54
55
56
    >
      <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'
57
import { projectName, queryTask } from '../../api/schedulerApi'
58
import dayjs from 'dayjs'
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

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


export default {
  name: 'progressRate',
  components: {
    GanttElastic,
    GanttHeader
  },
  mounted() {
    that = this
  },
  data() {
    return {
218
      tasks: [],
hh authored
219
      projectName:'',
220
      options,
221
222
223
224
225
      dynamicStyle: {
        'task-list-header-label': {
          'font-weight': 'bold',
        },
      },
226
      lastId: 16,
227
      projectNameList: {},
DESKTOP-AO0VKC8\mahua authored
228
      queryParam: []
229
230
    }
  },
231
232
  created() {
    this.getProjectNameList()
233
234
  },
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
  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
250
251
252
253
254
255
    tasksUpdate(tasks,num) {
      if(num == 2) {
        this.tasks = tasks
      } else {
        return
      }
256
    },
yuanshuhui authored
257
258
259
260
261
262
    optionsUpdate(options,num) {
      if(num == 2) {
        this.options = options
      } else {
        return
      }
263
264
265
    },
    styleUpdate(style) {
      this.dynamicStyle = style
266
267
268
    },
    getProjectNameList() {
      projectName().then((res) => {
269
        this.projectNameList = res
270
271
272
      })
    },
    handleChange(value) {
273
      this.getTask(value)
274
275
276
277
278
279
    },
    filterOption(input, option) {
      return (
        option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
      );
    },
280
281
282
283
    getTask(projectName) {
      if (projectName == null || projectName === "") {
        return;
      }
hh authored
284
      this.tasks = []
yuanshuhui authored
285
      let params = {
286
        "projectName": projectName
yuanshuhui authored
287
      };
288
      queryTask(params).then((res)=> {
289
        console.log(res)
290
291
292
293
        if (res.success) {
          this.tasks = res.result
        }
      })
hh authored
294
    },
295
296
297
298
299
300
301
  }
}
</script>

<style scoped>

</style>