|
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+<template>
|
|
|
2
|
+ <div class="excel-import-simple">
|
|
|
3
|
+ <el-card class="import-card">
|
|
|
4
|
+ <template #header>
|
|
|
5
|
+ <div class="card-header">
|
|
|
6
|
+ <span class="title">库存调整</span>
|
|
|
7
|
+ </div>
|
|
|
8
|
+ </template>
|
|
|
9
|
+
|
|
|
10
|
+ <!-- 表单部分 -->
|
|
|
11
|
+ <div class="stock-form">
|
|
|
12
|
+ <el-row :gutter="20">
|
|
|
13
|
+ <el-col :span="12">
|
|
|
14
|
+ <div class="form-item">
|
|
|
15
|
+ <label class="form-label">合同号</label>
|
|
|
16
|
+ <el-input
|
|
|
17
|
+ v-model="formData.contractNo"
|
|
|
18
|
+ placeholder="请输入合同号"
|
|
|
19
|
+ clearable
|
|
|
20
|
+ class="form-input"
|
|
|
21
|
+ />
|
|
|
22
|
+ </div>
|
|
|
23
|
+ </el-col>
|
|
|
24
|
+
|
|
|
25
|
+ <el-col :span="12">
|
|
|
26
|
+ <div class="form-item">
|
|
|
27
|
+ <label class="form-label">出入库类型</label>
|
|
|
28
|
+ <el-select
|
|
|
29
|
+ v-model="formData.storageType"
|
|
|
30
|
+ placeholder="请选择出入库类型"
|
|
|
31
|
+ clearable
|
|
|
32
|
+ class="form-input"
|
|
|
33
|
+ >
|
|
|
34
|
+ <el-option label="入库" value="in" />
|
|
|
35
|
+ <el-option label="出库" value="out" />
|
|
|
36
|
+ </el-select>
|
|
|
37
|
+ </div>
|
|
|
38
|
+ </el-col>
|
|
|
39
|
+ </el-row>
|
|
|
40
|
+
|
|
|
41
|
+ <el-row :gutter="20">
|
|
|
42
|
+ <el-col :span="12">
|
|
|
43
|
+ <div class="form-item">
|
|
|
44
|
+ <label class="form-label">物料编码</label>
|
|
|
45
|
+ <el-input
|
|
|
46
|
+ v-model="formData.materialCode"
|
|
|
47
|
+ placeholder="请输入物料编码"
|
|
|
48
|
+ clearable
|
|
|
49
|
+ class="form-input"
|
|
|
50
|
+ />
|
|
|
51
|
+ </div>
|
|
|
52
|
+ </el-col>
|
|
|
53
|
+
|
|
|
54
|
+ <el-col :span="12">
|
|
|
55
|
+ <div class="form-item">
|
|
|
56
|
+ <label class="form-label">单位</label>
|
|
|
57
|
+ <el-input
|
|
|
58
|
+ v-model="formData.unit"
|
|
|
59
|
+ placeholder="请输入单位(如:吨、件、千克等)"
|
|
|
60
|
+ clearable
|
|
|
61
|
+ class="form-input"
|
|
|
62
|
+ />
|
|
|
63
|
+ </div>
|
|
|
64
|
+ </el-col>
|
|
|
65
|
+ </el-row>
|
|
|
66
|
+
|
|
|
67
|
+ <el-row :gutter="20">
|
|
|
68
|
+ <el-col :span="12">
|
|
|
69
|
+ <div class="form-item">
|
|
|
70
|
+ <label class="form-label">数量</label>
|
|
|
71
|
+ <el-input-number
|
|
|
72
|
+ v-model="formData.quantity"
|
|
|
73
|
+ :min="0"
|
|
|
74
|
+ :precision="6"
|
|
|
75
|
+ :step="0.000001"
|
|
|
76
|
+ :controls="false"
|
|
|
77
|
+ placeholder="请输入数量"
|
|
|
78
|
+ class="form-input"
|
|
|
79
|
+ @change="handleQuantityChange"
|
|
|
80
|
+ />
|
|
|
81
|
+ </div>
|
|
|
82
|
+ </el-col>
|
|
|
83
|
+
|
|
|
84
|
+ <el-col :span="12">
|
|
|
85
|
+ <div class="form-item">
|
|
|
86
|
+ <label class="form-label">我方信息</label>
|
|
|
87
|
+ <el-select
|
|
|
88
|
+ v-model="formData.ourInfo"
|
|
|
89
|
+ placeholder="请选择我方信息"
|
|
|
90
|
+ clearable
|
|
|
91
|
+ filterable
|
|
|
92
|
+ class="form-input"
|
|
|
93
|
+ >
|
|
|
94
|
+ <el-option
|
|
|
95
|
+ v-for="item in ourInfoOptions"
|
|
|
96
|
+ :key="item.value"
|
|
|
97
|
+ :label="item.label"
|
|
|
98
|
+ :value="item.value"
|
|
|
99
|
+ />
|
|
|
100
|
+ </el-select>
|
|
|
101
|
+ </div>
|
|
|
102
|
+ </el-col>
|
|
|
103
|
+ </el-row>
|
|
|
104
|
+
|
|
|
105
|
+ <el-row :gutter="20">
|
|
|
106
|
+ <el-col :span="12">
|
|
|
107
|
+ <div class="form-item">
|
|
|
108
|
+ <label class="form-label">仓库名称</label>
|
|
|
109
|
+ <el-input
|
|
|
110
|
+ v-model="formData.warehouse"
|
|
|
111
|
+ placeholder="请输入仓库名称"
|
|
|
112
|
+ clearable
|
|
|
113
|
+ class="form-input"
|
|
|
114
|
+ />
|
|
|
115
|
+ </div>
|
|
|
116
|
+ </el-col>
|
|
|
117
|
+
|
|
|
118
|
+ <el-col :span="12">
|
|
|
119
|
+ <div class="form-item">
|
|
|
120
|
+ <label class="form-label">采购批次号</label>
|
|
|
121
|
+ <el-input
|
|
|
122
|
+ v-model="formData.purchaseBatchNo"
|
|
|
123
|
+ placeholder="请输入关联采购的批次号"
|
|
|
124
|
+ clearable
|
|
|
125
|
+ class="form-input"
|
|
|
126
|
+ />
|
|
|
127
|
+ </div>
|
|
|
128
|
+ </el-col>
|
|
|
129
|
+ </el-row>
|
|
|
130
|
+ </div>
|
|
|
131
|
+
|
|
|
132
|
+ <!-- 导入按钮 -->
|
|
|
133
|
+ <div class="action-buttons">
|
|
|
134
|
+ <el-button
|
|
|
135
|
+ type="primary"
|
|
|
136
|
+ :loading="loading"
|
|
|
137
|
+ @click="handleSubmit"
|
|
|
138
|
+ >
|
|
|
139
|
+ {{ loading ? '提交中...' : '提交表单' }}
|
|
|
140
|
+ </el-button>
|
|
|
141
|
+ <el-button @click="handleReset">重置</el-button>
|
|
|
142
|
+ </div>
|
|
|
143
|
+ </el-card>
|
|
|
144
|
+ </div>
|
|
|
145
|
+</template>
|
|
|
146
|
+
|
|
|
147
|
+<script setup>
|
|
|
148
|
+import { ref, reactive } from 'vue'
|
|
|
149
|
+import { ElMessage } from 'element-plus'
|
|
|
150
|
+import axios from 'axios'
|
|
|
151
|
+
|
|
|
152
|
+// 表单数据
|
|
|
153
|
+const formData = reactive({
|
|
|
154
|
+ contractNo: '',
|
|
|
155
|
+ storageType: '',
|
|
|
156
|
+ materialCode: '',
|
|
|
157
|
+ unit: '',
|
|
|
158
|
+ quantity: 0,
|
|
|
159
|
+ ourInfo: '',
|
|
|
160
|
+ warehouse: '',
|
|
|
161
|
+ purchaseBatchNo: ''
|
|
|
162
|
+})
|
|
|
163
|
+
|
|
|
164
|
+// 使用提供的数据作为我方信息下拉选项
|
|
|
165
|
+const ourInfoOptions = ref([
|
|
|
166
|
+ { label: '山钢国贸(青岛)物流有限公司', value: 'YFWL-山钢国贸(青岛)物流有限公司' },
|
|
|
167
|
+ { label: '山东钢铁集团国际贸易有限公司', value: 'SGGM-山东钢铁集团国际贸易有限公司' },
|
|
|
168
|
+ { label: '山东钢铁集团日照国际贸易有限公司', value: 'RZGM-山东钢铁集团日照国际贸易有限公司' },
|
|
|
169
|
+ { label: '齐鲁钢铁有限公司', value: 'QILU-齐鲁钢铁有限公司' },
|
|
|
170
|
+ { label: '山东莱钢国际贸易有限公司', value: 'LSI-山东莱钢国际贸易有限公司' },
|
|
|
171
|
+ { label: '济钢集团国际贸易有限责任公司', value: 'JGGM-济钢集团国际贸易有限责任公司' },
|
|
|
172
|
+ { label: '埃尔顿发展有限公司', value: 'ELD-埃尔顿发展有限公司' }
|
|
|
173
|
+])
|
|
|
174
|
+
|
|
|
175
|
+const loading = ref(false)
|
|
|
176
|
+
|
|
|
177
|
+// 处理数量变化
|
|
|
178
|
+const handleQuantityChange = (value) => {
|
|
|
179
|
+ if (value === null || value === undefined) {
|
|
|
180
|
+ formData.quantity = 0
|
|
|
181
|
+ }
|
|
|
182
|
+}
|
|
|
183
|
+
|
|
|
184
|
+// 提交表单
|
|
|
185
|
+const handleSubmit = async () => {
|
|
|
186
|
+ try {
|
|
|
187
|
+ loading.value = true
|
|
|
188
|
+
|
|
|
189
|
+ // 准备请求数据 - 注意字段名可能需要根据后端要求调整
|
|
|
190
|
+ const requestData = {
|
|
|
191
|
+ contractNo: formData.contractNo,
|
|
|
192
|
+ storageType: formData.storageType,
|
|
|
193
|
+ materialCode: formData.materialCode,
|
|
|
194
|
+ unit: formData.unit,
|
|
|
195
|
+ quantity: formData.quantity,
|
|
|
196
|
+ ourInfo: formData.ourInfo,
|
|
|
197
|
+ warehouse: formData.warehouse,
|
|
|
198
|
+ purchaseBatchNo: formData.purchaseBatchNo
|
|
|
199
|
+ }
|
|
|
200
|
+
|
|
|
201
|
+ console.log('提交的数据:', JSON.stringify(requestData, null, 2))
|
|
|
202
|
+
|
|
|
203
|
+ // 调用后端API - 使用您提供的库存调整接口
|
|
|
204
|
+ const response = await axios.post(
|
|
|
205
|
+ 'http://localhost:8080/api/KCqichu/import',
|
|
|
206
|
+ requestData,
|
|
|
207
|
+ {
|
|
|
208
|
+ headers: {
|
|
|
209
|
+ 'Content-Type': 'application/json'
|
|
|
210
|
+ },
|
|
|
211
|
+ timeout: 30000,
|
|
|
212
|
+ withCredentials: false
|
|
|
213
|
+ }
|
|
|
214
|
+ )
|
|
|
215
|
+
|
|
|
216
|
+ console.log('API响应成功:', response.status)
|
|
|
217
|
+ console.log('响应数据:', response.data)
|
|
|
218
|
+
|
|
|
219
|
+ // 处理响应数据
|
|
|
220
|
+ if (response.status === 200) {
|
|
|
221
|
+ const resultData = response.data
|
|
|
222
|
+
|
|
|
223
|
+ // 根据后端返回的结构判断
|
|
|
224
|
+ if (resultData.code === 200 || resultData.success === true) {
|
|
|
225
|
+ ElMessage.success(resultData.message || '库存调整提交成功!')
|
|
|
226
|
+
|
|
|
227
|
+ // 可选:提交成功后重置表单
|
|
|
228
|
+ handleReset()
|
|
|
229
|
+ } else {
|
|
|
230
|
+ ElMessage.error(resultData.message || '提交失败')
|
|
|
231
|
+
|
|
|
232
|
+ // 如果有错误详情,可以在这里处理
|
|
|
233
|
+ if (resultData.errors && resultData.errors.length > 0) {
|
|
|
234
|
+ console.error('错误详情:', resultData.errors)
|
|
|
235
|
+ }
|
|
|
236
|
+ }
|
|
|
237
|
+ }
|
|
|
238
|
+
|
|
|
239
|
+ } catch (error) {
|
|
|
240
|
+ console.error('提交失败:', error)
|
|
|
241
|
+ console.error('错误配置:', error.config)
|
|
|
242
|
+
|
|
|
243
|
+ let errorMessage = '网络请求失败'
|
|
|
244
|
+
|
|
|
245
|
+ if (error.response) {
|
|
|
246
|
+ // 服务器返回了错误状态码
|
|
|
247
|
+ const status = error.response.status
|
|
|
248
|
+ const errorData = error.response.data
|
|
|
249
|
+
|
|
|
250
|
+ switch (status) {
|
|
|
251
|
+ case 400:
|
|
|
252
|
+ errorMessage = errorData.message || '请求参数错误'
|
|
|
253
|
+ break
|
|
|
254
|
+ case 401:
|
|
|
255
|
+ errorMessage = '未授权,请登录'
|
|
|
256
|
+ break
|
|
|
257
|
+ case 403:
|
|
|
258
|
+ errorMessage = '权限不足'
|
|
|
259
|
+ break
|
|
|
260
|
+ case 404:
|
|
|
261
|
+ errorMessage = '接口不存在'
|
|
|
262
|
+ break
|
|
|
263
|
+ case 500:
|
|
|
264
|
+ errorMessage = '服务器内部错误'
|
|
|
265
|
+ break
|
|
|
266
|
+ default:
|
|
|
267
|
+ errorMessage = errorData.message || `请求失败 (${status})`
|
|
|
268
|
+ }
|
|
|
269
|
+ } else if (error.code === 'ERR_NETWORK') {
|
|
|
270
|
+ errorMessage = '网络连接失败,请检查后端服务是否启动'
|
|
|
271
|
+ } else if (error.code === 'ECONNABORTED') {
|
|
|
272
|
+ errorMessage = '请求超时,请稍后重试'
|
|
|
273
|
+ }
|
|
|
274
|
+
|
|
|
275
|
+ ElMessage.error(errorMessage)
|
|
|
276
|
+
|
|
|
277
|
+ } finally {
|
|
|
278
|
+ loading.value = false
|
|
|
279
|
+ }
|
|
|
280
|
+}
|
|
|
281
|
+
|
|
|
282
|
+// 重置表单
|
|
|
283
|
+const handleReset = () => {
|
|
|
284
|
+ Object.assign(formData, {
|
|
|
285
|
+ contractNo: '',
|
|
|
286
|
+ storageType: '',
|
|
|
287
|
+ materialCode: '',
|
|
|
288
|
+ unit: '',
|
|
|
289
|
+ quantity: 0,
|
|
|
290
|
+ ourInfo: '',
|
|
|
291
|
+ warehouse: '',
|
|
|
292
|
+ purchaseBatchNo: ''
|
|
|
293
|
+ })
|
|
|
294
|
+}
|
|
|
295
|
+</script>
|
|
|
296
|
+
|
|
|
297
|
+<style scoped>
|
|
|
298
|
+.excel-import-simple {
|
|
|
299
|
+ padding: 20px;
|
|
|
300
|
+ max-width: 900px;
|
|
|
301
|
+ margin: 0 auto;
|
|
|
302
|
+}
|
|
|
303
|
+
|
|
|
304
|
+.import-card {
|
|
|
305
|
+ min-height: 500px;
|
|
|
306
|
+}
|
|
|
307
|
+
|
|
|
308
|
+.card-header {
|
|
|
309
|
+ display: flex;
|
|
|
310
|
+ justify-content: space-between;
|
|
|
311
|
+ align-items: center;
|
|
|
312
|
+}
|
|
|
313
|
+
|
|
|
314
|
+.title {
|
|
|
315
|
+ font-size: 18px;
|
|
|
316
|
+ font-weight: bold;
|
|
|
317
|
+}
|
|
|
318
|
+
|
|
|
319
|
+/* 表单样式 */
|
|
|
320
|
+.stock-form {
|
|
|
321
|
+ margin: 20px 0;
|
|
|
322
|
+ padding: 20px;
|
|
|
323
|
+ background: #f8f9fa;
|
|
|
324
|
+ border-radius: 8px;
|
|
|
325
|
+ border: 1px solid #e9ecef;
|
|
|
326
|
+}
|
|
|
327
|
+
|
|
|
328
|
+.form-item {
|
|
|
329
|
+ margin-bottom: 20px;
|
|
|
330
|
+}
|
|
|
331
|
+
|
|
|
332
|
+.form-label {
|
|
|
333
|
+ display: block;
|
|
|
334
|
+ margin-bottom: 8px;
|
|
|
335
|
+ font-size: 14px;
|
|
|
336
|
+ font-weight: 500;
|
|
|
337
|
+ color: #606266;
|
|
|
338
|
+}
|
|
|
339
|
+
|
|
|
340
|
+.form-input {
|
|
|
341
|
+ width: 100%;
|
|
|
342
|
+}
|
|
|
343
|
+
|
|
|
344
|
+/* 调整 el-input-number 样式以支持更好的输入 */
|
|
|
345
|
+:deep(.el-input-number) {
|
|
|
346
|
+ width: 100%;
|
|
|
347
|
+}
|
|
|
348
|
+
|
|
|
349
|
+:deep(.el-input-number .el-input__wrapper) {
|
|
|
350
|
+ padding-right: 0;
|
|
|
351
|
+}
|
|
|
352
|
+
|
|
|
353
|
+/* 隐藏数字输入框的控件按钮 */
|
|
|
354
|
+:deep(.el-input-number.is-controls-right .el-input__wrapper) {
|
|
|
355
|
+ padding-right: 15px;
|
|
|
356
|
+}
|
|
|
357
|
+
|
|
|
358
|
+/* 调整 el-select 选项样式,使长文本正常显示 */
|
|
|
359
|
+:deep(.el-select-dropdown__item) {
|
|
|
360
|
+ white-space: normal;
|
|
|
361
|
+ word-break: break-all;
|
|
|
362
|
+ line-height: 1.5;
|
|
|
363
|
+ padding: 8px 20px;
|
|
|
364
|
+}
|
|
|
365
|
+
|
|
|
366
|
+/* 调整按钮样式 */
|
|
|
367
|
+.action-buttons {
|
|
|
368
|
+ text-align: center;
|
|
|
369
|
+ margin: 30px 0 20px;
|
|
|
370
|
+ padding-top: 20px;
|
|
|
371
|
+ border-top: 1px solid #eee;
|
|
|
372
|
+}
|
|
|
373
|
+
|
|
|
374
|
+/* 响应式调整 */
|
|
|
375
|
+@media (max-width: 768px) {
|
|
|
376
|
+ .el-col {
|
|
|
377
|
+ width: 100%;
|
|
|
378
|
+ margin-bottom: 10px;
|
|
|
379
|
+ }
|
|
|
380
|
+
|
|
|
381
|
+ .stock-form {
|
|
|
382
|
+ padding: 15px;
|
|
|
383
|
+ }
|
|
|
384
|
+}
|
|
|
385
|
+
|
|
|
386
|
+/* 保持原有样式不变 */
|
|
|
387
|
+.upload-area {
|
|
|
388
|
+ margin: 20px 0;
|
|
|
389
|
+}
|
|
|
390
|
+
|
|
|
391
|
+.result-area {
|
|
|
392
|
+ margin-top: 20px;
|
|
|
393
|
+}
|
|
|
394
|
+
|
|
|
395
|
+.success-result,
|
|
|
396
|
+.error-result {
|
|
|
397
|
+ margin-bottom: 20px;
|
|
|
398
|
+}
|
|
|
399
|
+
|
|
|
400
|
+.statistics {
|
|
|
401
|
+ margin-top: 15px;
|
|
|
402
|
+ padding: 15px;
|
|
|
403
|
+ background: #f0f9ff;
|
|
|
404
|
+ border-radius: 4px;
|
|
|
405
|
+ border: 1px solid #e1f3ff;
|
|
|
406
|
+}
|
|
|
407
|
+
|
|
|
408
|
+.error-list {
|
|
|
409
|
+ margin-top: 15px;
|
|
|
410
|
+ padding: 15px;
|
|
|
411
|
+ background: #fef0f0;
|
|
|
412
|
+ border-radius: 4px;
|
|
|
413
|
+ border: 1px solid #fde2e2;
|
|
|
414
|
+}
|
|
|
415
|
+
|
|
|
416
|
+.error-header {
|
|
|
417
|
+ display: flex;
|
|
|
418
|
+ justify-content: space-between;
|
|
|
419
|
+ align-items: center;
|
|
|
420
|
+ margin-bottom: 10px;
|
|
|
421
|
+}
|
|
|
422
|
+
|
|
|
423
|
+.error-header h4 {
|
|
|
424
|
+ margin: 0;
|
|
|
425
|
+ color: #f56c6c;
|
|
|
426
|
+ font-size: 14px;
|
|
|
427
|
+ display: flex;
|
|
|
428
|
+ align-items: center;
|
|
|
429
|
+ gap: 8px;
|
|
|
430
|
+}
|
|
|
431
|
+
|
|
|
432
|
+.error-scroll {
|
|
|
433
|
+ max-height: 300px;
|
|
|
434
|
+ overflow-y: auto;
|
|
|
435
|
+}
|
|
|
436
|
+
|
|
|
437
|
+.error-item {
|
|
|
438
|
+ display: flex;
|
|
|
439
|
+ align-items: flex-start;
|
|
|
440
|
+ padding: 8px 0;
|
|
|
441
|
+ border-bottom: 1px solid #fde2e2;
|
|
|
442
|
+ line-height: 1.4;
|
|
|
443
|
+}
|
|
|
444
|
+
|
|
|
445
|
+.error-item:last-child {
|
|
|
446
|
+ border-bottom: none;
|
|
|
447
|
+}
|
|
|
448
|
+
|
|
|
449
|
+.error-index {
|
|
|
450
|
+ color: #909399;
|
|
|
451
|
+ font-size: 12px;
|
|
|
452
|
+ margin-right: 8px;
|
|
|
453
|
+ flex-shrink: 0;
|
|
|
454
|
+ min-width: 20px;
|
|
|
455
|
+}
|
|
|
456
|
+
|
|
|
457
|
+.error-content {
|
|
|
458
|
+ font-size: 13px;
|
|
|
459
|
+ color: #f56c6c;
|
|
|
460
|
+ word-break: break-all;
|
|
|
461
|
+}
|
|
|
462
|
+
|
|
|
463
|
+.import-tips {
|
|
|
464
|
+ margin-top: 20px;
|
|
|
465
|
+}
|
|
|
466
|
+
|
|
|
467
|
+.tips-content {
|
|
|
468
|
+ font-size: 13px;
|
|
|
469
|
+ line-height: 1.6;
|
|
|
470
|
+}
|
|
|
471
|
+
|
|
|
472
|
+.tips-content p {
|
|
|
473
|
+ margin: 5px 0;
|
|
|
474
|
+}
|
|
|
475
|
+
|
|
|
476
|
+.tips-content ul {
|
|
|
477
|
+ margin: 5px 0;
|
|
|
478
|
+ padding-left: 20px;
|
|
|
479
|
+}
|
|
|
480
|
+
|
|
|
481
|
+.tips-content li {
|
|
|
482
|
+ margin: 2px 0;
|
|
|
483
|
+}
|
|
|
484
|
+</style>
|