spring
5 天以前 76d8eff2cfc1a428a948fe6f57f0ff93b2e3a444
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
<script setup lang="ts">
import {computed, onMounted, reactive, ref} from "vue";
import dayjs from "dayjs";
import {userListNoPageByTenantId} from "@/api/system/user.js";
import {ElMessage} from "element-plus";
import {addProductMain} from "@/api/productionManagement/workOrder.js";
 
defineOptions({
  name: "CopperPrintingForm"
});
 
const props = defineProps({
  isShow: {
    type: Boolean,
    required: true
  },
  isEdit: {
    type: Boolean,
    default: false
  },
  detailData: {
    type: Object,
    default: () => ({}),
  },
  row: {
    type: Object,
    default: () => ({}),
  }
});
 
const emits = defineEmits(["update:isShow", "refreshData"]);
 
const visible = computed({
  get: () => props.isShow,
  set: (value: boolean) => emits("update:isShow", value),
});
 
const formData = reactive({
  productProcessRouteItemId: undefined,
  workOrderId: undefined,
  planQuantity: undefined,
  reportWork: undefined,
  productMainId: undefined,
  quantity: undefined, // 烧铜产出激
  userId: undefined, // 作业员
  userName: undefined, // 作业员
  otherData: {
    dryingTemperature: '', // 烘干温度
    startTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), // 开始时间
    endTime: dayjs().format('YYYY-MM-DD HH:mm:ss'), // 结束时间
    userId: undefined, // 作业员
    userName: undefined, // 作业员
    underlyingCopperPaste: undefined, // 底层铜浆
    underlyingCopperPastePrintingQuantity: undefined, // 底层铜浆印刷次数
    underlyingCopperPasteMachineNumber: undefined, // 底层铜浆机台号
    underlyingCopperPasteSilkScreenFamilyNumber: undefined, // 底层铜浆丝网族号
    underlyingCopperPasteNumberOfEyes: undefined, // 底层铜浆目数
    underlyingCopperPasteUserId: undefined, // 底层铜浆作业员
    underlyingCopperPasteUserName: undefined, // 底层铜浆作业员
    underlyingCopperPasteDryingTemperature: undefined, // 底层铜浆烘干温度
    surfaceCopperPaste: undefined, // 表层铜浆
    surfaceCopperPastePrintingQuantity: undefined, // 表层铜浆印刷次数
    surfaceCopperPasteMachineNumber: undefined, // 表层铜浆机台号
    surfaceCopperPasteSilkScreenFamilyNumber: undefined, // 表层铜浆丝网族号
    surfaceCopperPasteNumberOfEyes: undefined, // 表层铜浆目数
    surfaceCopperPasteUserId: undefined, // 表层铜浆作业员
    surfaceCopperPasteUserName: undefined, // 表层铜浆作业员
    surfaceCopperPasteDryingTemperature: undefined, // 表层铜浆烘干温度,
    steelBurningDate: undefined, // 烧钢日期
    copperFiringTime: undefined, // 烧铜进炉时间
    steelFiringTime: undefined, // 烧钢出炉时间
    weight: undefined, // 重量(kg/pos)
    copperSmeltingTemperatureProfile: undefined, // 烧铜温度曲线
    remark: undefined, // 备注
  }
})
 
const userOptions = ref([]);
const getUserList = () => {
  userListNoPageByTenantId()
      .then(res => {
        if (res.code === 200) {
          userOptions.value = res.data || [];
        }
      })
      .catch(err => {
        console.error("获取用户列表失败", err);
      });
};
// 用户选择变化时更新 userName
const handleUserChange = (userId: any, reportType: string) => {
  if (userId) {
    const selectedUser = userOptions.value.find(user => user.userId === userId);
 
    switch (reportType) {
      case 'userId':
        formData.otherData.userName = selectedUser.userName;
        break;
      case 'underlyingCopperPasteUserId':
        formData.otherData.underlyingCopperPasteUserName = selectedUser.userName;
        break;
      case 'surfaceCopperPasteUserId':
        formData.otherData.surfaceCopperPasteUserName = selectedUser.userName;
        break;
    }
  } else {
    switch (reportType) {
      case 'userId':
        formData.otherData.userName = "";
        break;
      case 'underlyingCopperPasteUserId':
        formData.otherData.underlyingCopperPasteUserName = "";
        break;
      case 'surfaceCopperPasteUserId':
        formData.otherData.surfaceCopperPasteUserName = "";
        break;
    }
  }
};
const handleReport = () => {
  if (!formData.otherData.userId && !formData.otherData.surfaceCopperPasteUserId && !formData.otherData.underlyingCopperPasteUserId) {
    ElMessage.error('请选择作业员')
    return;
  }
  if (!formData.quantity || formData.quantity <= 0) {
    ElMessage.error('请输入生产数量')
    return;
  }
  formData.userId = formData.otherData.surfaceCopperPasteUserId || formData.otherData.underlyingCopperPasteUserId;
 
  const otherData = JSON.stringify(formData.otherData);
  const submitData = {
    ...formData,
    otherData: otherData
  };
 
  addProductMain(submitData).then(res => {
    if (res.code === 200) {
      ElMessage({
        message: '报工成功',
        type: 'success',
      })
      emits("refreshData")
      visible.value = false;
    } else {
      ElMessage.error('报工失败')
    }
  });
};
 
const initData = () => {
  if (!props.isEdit) {
    formData.otherData = JSON.parse(props.detailData.otherData || '{}');
    formData.quantity = props.detailData.quantity;
  } else {
    const row = props.row;
    formData.planQuantity = row.planQuantity
    formData.productProcessRouteItemId = row.productProcessRouteItemId
    formData.workOrderId = row.id
    formData.reportWork = row.reportWork
    formData.productMainId = row.productMainId
  }
}
 
const displayValue = (value: any) => {
  return value === undefined || value === null || value === "" ? "-" : value;
};
 
onMounted(() => {
  getUserList();
  initData()
})
</script>
 
<template>
  <el-dialog v-model="visible"
             title="印铜报工"
             width="90%">
    <el-form :model="formData">
      <table class="report-table">
        <tbody>
        <tr>
          <td class="tip" colspan="4">瓷片清洗后放置时间超过72H,重新烘片后才能印刷并填写本栏</td>
          <td class="label" colspan="3">烘干温度</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.dryingTemperature" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.dryingTemperature) }}</span>
          </td>
          <td class="label">开始时间</td>
          <td colspan="2">
            <el-date-picker
                v-if="props.isEdit"
                v-model="formData.otherData.startTime"
                type="datetime"
                value-format="YYYY-MM-DD HH:mm:ss"
                format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择"
                style="width: 100%"
            />
            <span v-else class="view-value">{{ displayValue(formData.otherData.startTime) }}</span>
          </td>
          <td class="label"  colspan="3">结束时间</td>
          <td colspan="2">
            <el-date-picker
                v-if="props.isEdit"
                v-model="formData.otherData.endTime"
                type="datetime"
                value-format="YYYY-MM-DD HH:mm:ss"
                format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择"
                style="width: 100%"
            />
            <span v-else class="view-value">{{ displayValue(formData.otherData.endTime) }}</span>
          </td>
          <td class="label" colspan="2">作业员</td>
          <td  colspan="2">
            <el-select v-model="formData.otherData.userId"
                       v-if="props.isEdit"
                       style="width: 100%"
                       placeholder="请选择作业员"
                       clearable
                       filterable
                       @change="handleUserChange($event, 'userId')">
              <el-option v-for="user in userOptions"
                         :key="user.userId"
                         :label="user.userName"
                         :value="user.userId"/>
            </el-select>
            <span v-else class="view-value">{{ displayValue(formData.otherData.userName || formData.otherData.userId) }}</span>
          </td>
        </tr>
        <tr>
          <td class="label" colspan="2">底层铜浆</td>
          <td>
            <el-input v-if="props.isEdit" v-model="formData.otherData.underlyingCopperPaste" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPaste) }}</span>
          </td>
          <td class="label">印刷次数</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.underlyingCopperPastePrintingQuantity" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPastePrintingQuantity) }}</span>
          </td>
          <td class="label">机台号</td>
          <td>
            <el-input v-if="props.isEdit" v-model="formData.otherData.underlyingCopperPasteMachineNumber" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPasteMachineNumber) }}</span>
          </td>
          <td class="label">丝网族号</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.underlyingCopperPasteSilkScreenFamilyNumber" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPasteSilkScreenFamilyNumber) }}</span>
          </td>
          <td class="label">目数</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.underlyingCopperPasteNumberOfEyes" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPasteNumberOfEyes) }}</span>
          </td>
          <td class="label">作业员</td>
          <td colspan="2">
            <el-select v-model="formData.otherData.underlyingCopperPasteUserId"
                       v-if="props.isEdit"
                       style="width: 100%"
                       placeholder="请选择作业员"
                       clearable
                       filterable
                       @change="handleUserChange($event, 'underlyingCopperPasteUserId')">
              <el-option v-for="user in userOptions"
                         :key="user.userId"
                         :label="user.userName"
                         :value="user.userId"/>
            </el-select>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPasteUserName || formData.otherData.underlyingCopperPasteUserId) }}</span>
          </td>
          <td class="label" colspan="2">烘干温度</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.underlyingCopperPasteDryingTemperature" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.underlyingCopperPasteDryingTemperature) }}</span>
          </td>
        </tr>
        <tr>
          <td class="label" colspan="2">表层铜浆</td>
          <td>
            <el-input v-if="props.isEdit" v-model="formData.otherData.surfaceCopperPaste" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPaste) }}</span>
          </td>
          <td class="label">印刷次数</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.surfaceCopperPastePrintingQuantity" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPastePrintingQuantity) }}</span>
          </td>
          <td class="label">机台号</td>
          <td>
            <el-input v-if="props.isEdit" v-model="formData.otherData.surfaceCopperPasteMachineNumber" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPasteMachineNumber) }}</span>
          </td>
          <td class="label">丝网族号</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.surfaceCopperPasteSilkScreenFamilyNumber" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPasteSilkScreenFamilyNumber) }}</span>
          </td>
          <td class="label">目数</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.surfaceCopperPasteNumberOfEyes" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPasteNumberOfEyes) }}</span>
          </td>
          <td class="label">作业员</td>
          <td colspan="2">
            <el-select v-model="formData.otherData.surfaceCopperPasteUserId"
                       v-if="props.isEdit"
                       style="width: 100%"
                       placeholder="请选择作业员"
                       clearable
                       filterable
                       @change="handleUserChange($event, 'surfaceCopperPasteUserId')">
              <el-option v-for="user in userOptions"
                         :key="user.userId"
                         :label="user.userName"
                         :value="user.userId"/>
            </el-select>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPasteUserName || formData.otherData.surfaceCopperPasteUserId) }}</span>
          </td>
          <td class="label" colspan="2">烘干温度</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.surfaceCopperPasteDryingTemperature" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.surfaceCopperPasteDryingTemperature) }}</span>
          </td>
        </tr>
        <tr>
          <td class="label" colspan="2">烧钢日期</td>
          <td colspan="2">
            <el-date-picker
                v-if="props.isEdit"
                v-model="formData.otherData.steelBurningDate"
                type="date"
                value-format="YYYY-MM-DD"
                format="YYYY-MM-DD"
                placeholder="请选择"
                style="width: 100%"
            />
            <span v-else class="view-value">{{ displayValue(formData.otherData.steelBurningDate) }}</span>
          </td>
          <td class="label" colspan="3">烧铜进炉时间</td>
          <td colspan="2">
            <el-date-picker
                v-if="props.isEdit"
                v-model="formData.otherData.copperFiringTime"
                type="datetime"
                value-format="YYYY-MM-DD HH:mm:ss"
                format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择"
                style="width: 100%"
            />
            <span v-else class="view-value">{{ displayValue(formData.otherData.copperFiringTime) }}</span>
          </td>
          <td class="label">烧钢出炉时间</td>
          <td colspan="2">
            <el-date-picker
                v-if="props.isEdit"
                v-model="formData.otherData.steelFiringTime"
                type="datetime"
                value-format="YYYY-MM-DD HH:mm:ss"
                format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择"
                style="width: 100%"
            />
            <span v-else class="view-value">{{ displayValue(formData.otherData.steelFiringTime) }}</span>
          </td>
          <td class="label" colspan="3">烧铜产出激</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.quantity" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.quantity) }}</span>
          </td>
          <td class="label" colspan="2">重量(kg/pos)</td>
          <td colspan="2">
            <el-input v-if="props.isEdit" v-model="formData.otherData.weight" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.weight) }}</span>
          </td>
        </tr>
        <tr>
          <td class="label" colspan="2">烧铜温度曲线</td>
          <td colspan="7">
            <el-input
                v-if="props.isEdit"
                v-model="formData.otherData.copperSmeltingTemperatureProfile"
                type="textarea"
                :rows="3"
                placeholder="请输入"
            />
            <span v-else class="view-value">{{ displayValue(formData.otherData.copperSmeltingTemperatureProfile) }}</span>
          </td>
          <td class="label">备注</td>
          <td colspan="11">
            <el-input v-if="props.isEdit" v-model="formData.otherData.remark" type="textarea" :rows="3" placeholder="请输入"/>
            <span v-else class="view-value">{{ displayValue(formData.otherData.remark) }}</span>
          </td>
        </tr>
        </tbody>
      </table>
    </el-form>
    <template #footer>
        <span class="dialog-footer">
          <el-button v-if="props.isEdit" type="primary"
                     @click="handleReport">确定</el-button>
          <el-button @click="visible = false">{{ props.isEdit ? "取消" : "关闭" }}</el-button>
        </span>
    </template>
  </el-dialog>
</template>
 
<style scoped>
.report-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
}
 
.report-table td {
  border: 1px solid #dcdfe6;
  padding: 6px;
  vertical-align: middle;
}
 
.report-table .label {
  width: 90px;
  background: #f5f7fa;
  text-align: center;
  font-weight: 500;
}
 
.report-table .tip {
  text-align: center;
  font-weight: 500;
  line-height: 1.4;
  background: #fafafa;
}
 
.view-value {
  display: inline-block;
  min-height: 32px;
  line-height: 32px;
}
</style>