ZengTao
3 天以前 b8a043314eb644f45e3e110c75c29b19218c2ae8
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
<template>
  <div style="height: 600px;">
    <div style="display: flex; flex-direction: row; align-items: center; margin-top: 20px;margin-left: 20px;">
      {{ $t('Mounting.projecta') }}
       <el-input :placeholder="$t('order.projectnumber')" v-model="engineerId" style="width: 200px;margin-right: 20px;" autocomplete="off" />
      {{ $t('hellow.cardnumbera') }}
       <el-input :placeholder="$t('searchOrder.incardnumber')" v-model="flowCardId" style="width: 200px;margin-right: 20px;" autocomplete="off" />
      {{ $t('searchOrder.glassIDa') }}
       <el-input :placeholder="$t('searchOrder.inglassID')" v-model="glassId" style="width: 200px;margin-right: 20px;" autocomplete="off" />
      <el-button type="primary" style="margin-left: 10px;" 
        :disabled="isQueryBtnDisabled"
        @click="selectReportData()">{{ $t('reportmanage.inquire')}}</el-button>
    </div>
    <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;" >
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
        <el-table height="140" :data="reportData"  ref="upperTableRef"
         @selection-change="handleSelectionChange"
          :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
          <el-table-column prop="selectionKey" type="selection" width="50"/>
          <el-table-column prop="engineerId" align="center" :label="$t('reportmanage.projectnumber')" min-width="100"/>
          <el-table-column prop="flowCardId" align="center" :label="$t('hellow.cardnumber')" min-width="120"/>
          <el-table-column prop="glassType" align="center" :label="$t('large.serialnumber')" min-width="100"/>
          <el-table-column prop="layer" align="center" :label="$t('searchOrder.ceng')" min-width="60"/>
          <el-table-column prop="filmsid" align="center" :label="$t('hellow.coatingtypes')" min-width="100"/>
          <el-table-column prop="thickness" align="center" :label="$t('hellow.thickness')" min-width="100"/>
          <el-table-column prop="width" align="center" :label="$t('hellow.width')" min-width="100"/>
          <el-table-column prop="height" align="center" :label="$t('basicData.height')" min-width="100"/>
          <el-table-column prop="totalQuantity" align="center" :label="$t('searchOrder.allnumber')" min-width="100"/>
          <el-table-column prop="cutting" align="center" :label="$t('large.load')" min-width="100"/>
          <el-table-column prop="edging" align="center" :label="$t('scheduling.edgingCount')" min-width="100"/>
          <el-table-column prop="temping" align="center" :label="$t('scheduling.temperingCount')" min-width="100"/>
        </el-table>
      </div>
    </el-card>
    <div style="display: flex; flex-direction: row; align-items: center; margin-top: 20px;margin-left: 20px;">
      {{ $t('reportmanage.process') }}:
      <el-select v-model="workingProcedureList" :placeholder="$t('reportmanage.cprocess')"
       @change="handleSelectChange" multiple
        style="margin-left: 10px;margin-right: 20px;width: 240px;">
        <el-option :label="$t('reportmanage.incise')" value="切割"></el-option>
        <el-option :label="$t('reportmanage.edging')" value="磨边"></el-option>
        <el-option :label="$t('reportmanage.steel')" value="钢化"></el-option>
      </el-select>
      {{ $t('reportmanage.type') }}:
      <el-select v-model="typeList" :placeholder="$t('reportmanage.ctype')"
       @change="handleSelectChange" multiple
        style="margin-left: 10px;width: 240px;">
        <el-option :label="$t('reportmanage.completed')" value="1"></el-option>
        <el-option :label="$t('reportmanage.broke')" value="8"></el-option>
      </el-select>
    </div>
    <el-card style="flex: 1;margin-left: 10px;margin-top: 20px;" >
      <div style="width: 98%; height: calc(100% - 35px); overflow-y: auto;">
        <el-table height="500" ref="table" :data="tableData"
          :header-cell-style="{ background: '#F2F3F5 ', color: '#1D2129' }">
          <el-table-column prop="workingProcedure" align="center" :label="$t('reportmanage.process')" min-width="100" />
          <el-table-column prop="glassId" align="center" :label="$t('reportmanage.glassID')" min-width="150" />
          <el-table-column prop="formattedDamageTime" align="center" :label="$t('reportmanage.productiontime')" min-width="150" />
          <el-table-column prop="flowCardId" align="center" :label="$t('hellow.cardnumber')" min-width="100"/>
          <el-table-column prop="glassType" align="center" :label="$t('large.serialnumber')" min-width="100"/>
          <el-table-column prop="layer" align="center" :label="$t('searchOrder.ceng')" min-width="100"/>
          <el-table-column prop="filmsid" align="center" :label="$t('hellow.coatingtypes')" min-width="100"/>
          <el-table-column prop="thickness" align="center" :label="$t('hellow.thickness')" min-width="100"/>
          <el-table-column prop="width" align="center" :label="$t('hellow.width')" min-width="100"/>
          <el-table-column prop="height" align="center" :label="$t('basicData.height')" min-width="100"/>
          <el-table-column prop="deviceName" align="center" :label="$t('reportmanage.reportingequipment')" min-width="100" />
          <el-table-column prop="type" align="center" :label="$t('reportmanage.type')" min-width="100">
           <template #default="scope">
            <el-tag :type="gettypeType(scope.row.type)">
              {{ gettypeText(scope.row.type) }}
            </el-tag>
           </template>
          </el-table-column>
           <el-table-column prop="status" align="center" :label="$t('reportmanage.state')" min-width="100">
           <template #default="scope">
            <el-tag :type="getStatusType(scope.row.status)">
              {{ getStatusText(scope.row.status) }}
            </el-tag>
           </template>
          </el-table-column>
        </el-table>
      </div>
    </el-card>
  </div>
</template>
<script lang="ts" setup>
import { Delete, Upload } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { ref, onMounted, onBeforeUnmount, reactive, computed, shallowRef, onUnmounted, watchEffect } from "vue";
import { WebSocketHost, host } from '@/utils/constants'
import { useI18n } from 'vue-i18n'
import { inject } from 'vue';
import request from "@/utils/request"
const globalDate = inject('globalDate');
const { t } = useI18n()
const timeRange = ref([])
const reportData = ref([])
const tableData = ref([])
const selectedRows = ref([])
const engineerId = ref('')
const flowCardId = ref('')
const glassId = ref('')
const workingProcedureList = ref<string[]>(['切割'])
const typeList = ref<string[]>(['1'])
const selectReportData = async () => {
  const response = await request.post("/cacheVerticalGlass/damage/queryFlowCardIdProgress", {
    engineerId: engineerId.value.trim(),
    flowCardId: flowCardId.value.trim(),
    glassId: glassId.value.trim(),
  })
  if (response.code === 200) {
    reportData.value = response.data;
    ElMessage.success(response.message);
  }
};
const isQueryBtnDisabled = computed(() => {
  return !engineerId.value.trim() && !flowCardId.value.trim() && !glassId.value.trim()
})
const handleSelectionChange = (val) => {
  selectedRows.value = val
  // 当选中行数量为0时,清空下方表格数据
  if (val.length === 0) {
    tableData.value = []
    workingProcedureList.value = ['切割'] 
    typeList.value = ['1']
    return
  }
  if (val.length > 0) {
    handleQueryWorkData()
  }
}
const handleSelectChange = () => {
  // 有选中行且下方表格有数据时,才调用接口
  if (selectedRows.value.length > 0 ) {
    handleQueryWorkData()
  }
}
const handleQueryWorkData = async () => {
  if (selectedRows.value.length === 0) {
    ElMessage.warning(t('reportmanage.pleaseSelectRow'))
    return
  }
  if (!workingProcedureList.value || workingProcedureList.value.length === 0) {
    ElMessage.warning(t('reportmanage.cprocess'))
    return
  }
  // 类型下拉选是否为空
  if (!typeList.value || typeList.value.length === 0) {
    ElMessage.warning(t('reportmanage.ctype'))
    return
  }
  const conditionList = selectedRows.value.map(row => ({
    flowCardId: row.flowCardId,
    layer: row.layer,
    glassType: row.glassType
  }))
  const requestParams = {
    conditionList,
    glassId: glassId.value.trim(),
    workingProcedureList: workingProcedureList.value,
    typeList: typeList.value,
  }
  try {
    const response = await request.post("/cacheVerticalGlass/damage/queryProgress", requestParams)
    if (response.code === 200) {
      const formattedData = response.data.map(record => ({
        ...record,
        formattedDamageTime: formatTimestamp(record.damageTime),
      }));
      tableData.value = formattedData;
      ElMessage.success(response.message);
    } else {
      ElMessage.error(response.message)
    }
  } catch (error) {
    ElMessage.error()
  }
};
function gettypeType(type: number) {
  switch (type) {
    case 1:
      return 'success';
    case 8:
      return 'warning';
    default:
      return 'info'
  }
}
function gettypeText(type: number) {
  switch (type) {
    case 1:
      return t('reportmanage.completed');//完工
    case 8:
      return t('reportmanage.broke');//破损
    default:
      return t('sorter.another')
  }
}
function getStatusType(status: number) {
  switch (status) {
    case 1:
      return 'warning';
    case 3:
      return 'success';
    default:
      return 'info'
  }
}
function getStatusText(status: number) {
  switch (status) {
    case 1:
      return t('reportmanage.dreportwork');//未报工
    case 3:
      return t('reportmanage.reportwork');//已报工
    default:
      return t('sorter.another')
  }
}
function formatTimestamp(timestamp) {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1,并补零
  const day = String(date.getDate()).padStart(2, '0'); // 补零
  const hours = String(date.getHours()).padStart(2, '0'); // 补零(如果需要显示时间)
  const minutes = String(date.getMinutes()).padStart(2, '0'); // 补零(如果需要显示时间)
  const seconds = String(date.getSeconds()).padStart(2, '0'); // 补零(如果需要显示时间)
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
// 格式化后端时间并计算一周前的时间
const defaultTime = ref<[Date, Date]>([new Date(), new Date()]);
function parseAndSetTime() {
  const backendTime = new Date(globalDate);
  const oneWeekAgo = new Date(backendTime.getTime() - 7 * 24 * 60 * 60 * 1000); // 减去7天
  oneWeekAgo.setHours(0, 0, 0, 0);
  timeRange.value = [formatTimestamp(oneWeekAgo), formatTimestamp(backendTime)];
  window.localStorage.setItem('startTime', formatTimestamp(oneWeekAgo))
}
onMounted(() => {
  parseAndSetTime();
});
</script>