charles
2024-04-26 8a4d220f73dcee2ab848596eb4e48a56b94c7a99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
<script setup lang="ts">
import { ref, onMounted, watch, nextTick } from 'vue'
import { ElMessage } from 'element-plus'
import TaskTabs from '@/views/dashboard/components/TaskTabs.vue'
import CurrentDateTime from '@/views/dashboard/components/CurrentDateTime.vue'
import {
  getQualityProcedureApi,
  getProjectApi,
  getProductApi,
  getWorkerApi,
  updateQualityProcedureApi,
  qualityCountApi,
  IQualityCountParams
} from '@/api'
import BigButton from '@/views/dashboard/components/BigButton.vue'
import EditInspection from '@/views/newDashboard/components/EditInspection.vue'
defineOptions({
  name: 'NewDashboardView'
})
const taskTabsList: Array<any> = [
  { label: '待质检', value: 1 },
  { label: '已质检', value: 3 }
]
const activeTaskTab = ref(1)
const projectList = ref([])
const productList = ref([])
const projectIdArray = ref([])
const productIdArray = ref([])
const workerList = ref([])
const pageData = ref({ page: 1, pageSize: 1000 })
const modalObj = ref({ modalValue: false })
const qualityList = ref([])
const lookQuality = ref({})
const oldLookQuality = ref({})
const DEFAULT_QUALITY_COUNT = { wait: '--', over: '--', scrapped: '--', pass: '--' }
const qualityCountObj = ref({ ...DEFAULT_QUALITY_COUNT })
const tableHeaderColor = ({ rowIndex }: any) => {
  if (rowIndex === 0) {
    return 'header-row-class' // 这个类名需要你自己定义
  }
}
const checkProduct = (quality: any) => {
  lookQuality.value = { ...quality }
  oldLookQuality.value = { ...quality }
  modalObj.value.modalValue = true
}
const editInspection = (quality: any) => {
  updateQualityProcedureApi(quality).then(({ code, data }: any) => {
    if (code == 200) {
      ElMessage.success(data)
      queryQualityProcedure()
      queryQualityCount()
      modalObj.value.modalValue = false
    } else {
      ElMessage.error(data)
    }
  })
}
//1.查询项目列表
const queryProject = () => {
  getProjectApi(pageData.value).then(({ code, data }: any) => {
    if (code == 200) {
      projectList.value = data
      if (Array.isArray(data) && data.length > 0) {
        projectIdArray.value[0] = data[0].id
        queryProduct()
      }
    }
  })
}
//2.根据项目编号查询产品列表
const queryProduct = () => {
  if (projectIdArray.value && projectIdArray.value.length > 0) {
    getProductApi({ projectId: projectIdArray.value[0], ...pageData.value }).then(({ code, data }) => {
      if (code == 200) {
        productList.value = data
        if (Array.isArray(data) && data.length > 0) {
          productIdArray.value[0] = data[0].id
          queryQualityProcedure()
          queryQualityCount()
        }
      }
    })
  } else {
    productList.value = []
    productIdArray.value = []
  }
}
//3.查询工序质检列表
const queryQualityProcedure = () => {
  const params: any = { status: activeTaskTab.value, projectId: '', productId: '', ...pageData.value, keyword: '' }
  if (Array.isArray(projectIdArray.value) && projectIdArray.value.length > 0) {
    params.projectId = projectIdArray.value[0] + ''
  } else {
    qualityList.value = []
    return
  }
  if (Array.isArray(productIdArray.value) && productIdArray.value.length > 0) {
    params.productId = productIdArray.value[0] + ''
  } else {
    qualityList.value = []
    return
  }
  getQualityProcedureApi(params).then(({ code, data }: any) => {
    if (code == 200) {
      qualityList.value = data
    }
  })
}
//4. 条件变化更新工序质检列表数据
watch(
  [() => activeTaskTab.value, () => productIdArray.value, () => projectIdArray.value],
  () => {
    queryQualityProcedure()
    queryQualityCount()
  },
  { immediate: false }
)
//5. 查询所有加工人员列表
const queryWorker = () => {
  getWorkerApi(pageData.value).then(({ code, data }: any) => {
    if (code == 200) {
      workerList.value = data
    }
  })
}
//6.查询质检数据统计
const queryQualityCount = () => {
  const params: IQualityCountParams = { productId: '', projectId: '' }
  if (Array.isArray(projectIdArray.value) && projectIdArray.value.length > 0) {
    params.projectId = projectIdArray.value[0] + ''
  } else {
    qualityCountObj.value = { ...DEFAULT_QUALITY_COUNT }
    return
  }
  if (Array.isArray(productIdArray.value) && productIdArray.value.length > 0) {
    params.productId = productIdArray.value[0] + ''
  } else {
    qualityCountObj.value = { ...DEFAULT_QUALITY_COUNT }
    return
  }
  qualityCountApi(params).then(({ code, data }) => {
    if (code == 200) {
      for (let fieldName in data) {
        if (isNaN(parseInt(data[fieldName]))) {
          data[fieldName] = '--'
        }
      }
      qualityCountObj.value = data
    }
  })
}
//6.初始化页面数据
const initPage = () => {
  queryProject()
  queryWorker()
}
onMounted(() => {
  initPage()
})
</script>
<template>
  <EditInspection
    :worker-list="workerList"
    :look-quality="lookQuality"
    :modal-obj="modalObj"
    :old-look-quality="oldLookQuality"
    @edit-inspection="editInspection"
  ></EditInspection>
  <div class="container">
    <div class="head">
      <div class="left"></div>
      <div class="title">质检工作台</div>
      <div class="right"><CurrentDateTime></CurrentDateTime></div>
    </div>
    <div class="statistic">
      <div class="item">
        <div class="img bg1"><img src="@/assets/images/u820.png" /></div>
        <div class="text">
          <div>待检测</div>
          <div>{{ qualityCountObj.wait }}</div>
        </div>
      </div>
      <div class="item">
        <div class="img bg2"><img src="@/assets/images/u820.png" /></div>
        <div class="text">
          <div>完成数</div>
          <div>{{ qualityCountObj.over }}</div>
        </div>
      </div>
      <div class="item">
        <div class="img bg3"><img src="@/assets/images/u820.png" /></div>
        <div class="text">
          <div>合格率</div>
          <div class="success-number">
            {{ qualityCountObj.pass }}
            <span v-show="!isNaN(parseInt(qualityCountObj.pass))">%</span>
          </div>
        </div>
      </div>
      <div class="item">
        <div class="img bg4"><img src="@/assets/images/u820.png" /></div>
        <div class="text">
          <div>报废率</div>
          <div class="fail-number">
            {{ qualityCountObj.scrapped }}<span v-show="!isNaN(parseInt(qualityCountObj.scrapped))">%</span>
          </div>
        </div>
      </div>
    </div>
    <div class="table-filter">
      <div class="left">
        <TaskTabs v-model="activeTaskTab" style="margin-top: 20px" :list="taskTabsList"></TaskTabs>
      </div>
      <div class="right">
        <el-select
          v-model="projectIdArray"
          :teleported="false"
          size="large"
          :multiple-limit="1"
          multiple
          placeholder="项目"
          @change="queryProduct"
        >
          <el-option v-for="item in projectList" :key="item.id" :label="item.projectName" :value="item.id" multiple>
            <div class="item-option">
              <div>{{ item.id }}</div>
              <div>{{ item.projectName }}</div>
            </div>
          </el-option>
        </el-select>
        <el-select
          v-model="productIdArray"
          :teleported="false"
          size="large"
          :multiple-limit="1"
          multiple
          placeholder="产品"
        >
          <el-option v-for="item in productList" :key="item.id" :label="item.name" :value="item.id" multiple>
            <div class="item-option">
              <div>{{ item.id }}</div>
              <div>{{ item.name }}</div>
            </div>
          </el-option>
        </el-select>
      </div>
    </div>
    <div class="table">
      <!--<el-empty v-if="qualityList.length == 0" description="暂无数据" />-->
      <el-table
        :data="qualityList"
        :header-cell-class-name="tableHeaderColor"
        row-class-name="row-bg"
        style="width: 100%; background: transparent"
        border
      >
        <el-table-column fixed prop="procedureName" style="background: gray" align="center" label="产品工序" />
        <el-table-column prop="workOrderId" align="center" label="工单编号" />
        <el-table-column prop="productName" align="center" label="产品名称" />
        <el-table-column prop="drawingNumber" align="center" label="产品图号" />
        <el-table-column prop="amount" align="center" label="计划数" />
        <el-table-column prop="transferAmount" align="center" label="转入数" />
        <el-table-column prop="scrappedAmount" align="center" label="报废数" />
        <el-table-column prop="passAmount" align="center" label="合格数" />
        <el-table-column prop="workerName" align="center" label="加工人员" />
        <el-table-column prop="inspectionPeople" align="center" label="质检员" />
        <!--<el-table-column prop="procedureId" align="center" label="工序号" />-->
        <el-table-column fixed="right" align="center" label="操作" width="120px">
          <template #default="scope">
            <BigButton bg-color="#00ff00" @click="checkProduct(scope.row)">质检</BigButton>
          </template>
        </el-table-column>
        <template #empty>
          <el-empty description="暂无数据"></el-empty>
        </template>
      </el-table>
    </div>
  </div>
</template>
 
<style scoped lang="scss">
.container {
  .head {
    background-image: url('/header-bg.png');
    background-position-x: center;
    background-repeat: no-repeat;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    .left {
      width: 25%;
    }
    .title {
      width: 50%;
      font-family: 'Arial Negreta', 'Arial Normal', 'Arial';
      font-weight: 700;
      font-style: normal;
      font-size: 36px;
      color: #ffffff;
      text-align: center;
    }
    .right {
      line-height: 60px;
      background-image: url('@/assets/images/u883.png');
      background-position-x: 0px;
      background-position-y: 10px;
      background-repeat: no-repeat;
      background-size: 40px;
      width: 25%;
      padding-left: 60px;
    }
    .left,
    .title,
    .right {
      margin-top: 12px;
    }
  }
  .statistic {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    .item {
      border-width: 0px;
      width: 24%;
      height: 144px;
      background-color: rgba(22, 72, 173, 0.737254901960784);
      border: none;
      border-radius: 8px;
      -moz-box-shadow: none;
      -webkit-box-shadow: none;
      box-shadow: none;
      .img {
        text-align: center;
        display: inline-block;
        margin: 0px 30px;
        position: relative;
        top: -5px;
        width: 98px;
        height: 98px;
        img {
          width: 50%;
          position: relative;
          top: 23px;
        }
      }
      .bg1 {
        background: url('@/assets/images/u819.png') no-repeat;
        background-size: cover;
      }
      .bg2 {
        background: url('@/assets/images/u837.png') no-repeat;
        background-size: cover;
      }
      .bg3 {
        background: url('@/assets/images/u825.png') no-repeat;
        background-size: cover;
      }
      .bg4 {
        background: url('@/assets/images/u831.png') no-repeat;
        background-size: cover;
      }
      .text {
        display: inline-block;
        position: relative;
        top: 25px;
        font-size: 25px;
      }
      .success-number {
        color: #00ff00;
      }
      .fail-number {
        color: #ff0000;
      }
    }
  }
  .table-filter {
    display: flex;
    justify-content: space-between;
    .left {
      width: 30%;
      margin-left: 10px;
    }
    .right {
      width: 40%;
      display: flex;
      justify-content: space-around;
      margin-top: 2.5vh;
      margin-right: -10px;
      .el-select {
        width: 256px;
        :deep(.el-select__wrapper) {
          background-color: transparent !important;
        }
      }
      .el-select-dropdown__item {
        color: white;
      }
      .el-select-dropdown__item.is-hovering {
        color: #fff;
        background: transparent !important;
        /*background: linear-gradient(*/
        /*to right,*/
        /*rgba(147, 250, 255, 0),*/
        /*rgba(147, 250, 255, 0.4),*/
        /*rgba(147, 250, 255, 0)*/
        /*);*/
      }
      :deep(.el-select__popper) {
        width: 100%;
        border: 1px solid #1ca898;
        background: deepskyblue;
      }
      .item-option {
        width: 100%;
        display: flex;
        flex: 1;
        > div {
          min-width: 50%;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
          text-align: center;
        }
      }
      :deep(.el-select__selection .el-tag) {
        background: transparent;
        font-size: 16px;
        color: white;
      }
      :deep(.el-icon) {
        display: none;
      }
    }
  }
  .table {
    margin: 20px 10px;
  }
}
:deep(.row-bg) {
  background-color: transparent;
  color: white;
  &:hover {
    color: #181818;
  }
}
:deep(.header-row-class) {
  background-color: #007fff !important;
  font-size: 20px;
  color: white;
}
</style>