resourceOutManageList.vue
5.3 KB
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
<template>
<div class="resource-out-manage-container">
<el-card class="box-card">
<div slot="header" class="flex justify-between">
<span>{{ $t('resourceOutManage.orderId') }}:{{ resourceOutManageInfo.applyOrderId }}</span>
</div>
<el-row>
<el-col :span="24">
<el-table :data="resourceOutManageInfo.purchaseApplyDetailVo" border style="width: 100%" v-loading="loading">
<el-table-column prop="rstName" :label="$t('resourceOutManage.itemType')" align="center" width="180">
<template slot-scope="scope">
{{ scope.row.rstName || '-' }}
</template>
</el-table-column>
<el-table-column prop="resName" :label="$t('resourceOutManage.itemName')" align="center" width="180" />
<el-table-column prop="specName" :label="$t('resourceOutManage.itemSpec')" align="center" width="180">
<template slot-scope="scope">
{{ scope.row.specName || '-' }}
</template>
</el-table-column>
<el-table-column prop="resCode" :label="$t('resourceOutManage.itemCode')" align="center" width="180" />
<el-table-column prop="stock" :label="$t('resourceOutManage.itemStock')" align="center" width="120" />
<el-table-column prop="quantity" :label="$t('resourceOutManage.applyQuantity')" align="center"
width="120" />
<el-table-column :label="$t('resourceOutManage.issueQuantity')" align="center" width="200">
<template slot-scope="scope">
<el-input v-model.number="scope.row.purchaseQuantity" type="number"
:placeholder="$t('resourceOutManage.issueQuantityPlaceholder')" clearable />
</template>
</el-table-column>
<el-table-column :label="$t('resourceOutManage.remark')" align="center" width="200">
<template slot-scope="scope">
<el-input v-model="scope.row.purchaseRemark" type="text"
:placeholder="$t('resourceOutManage.remarkPlaceholder')" clearable />
</template>
</el-table-column>
</el-table>
</el-col>
</el-row>
<el-row class="footer-row">
<el-col :span="24" class="text-right">
<el-button type="primary" @click="handleSubmit">
{{ $t('resourceOutManage.submit') }}
</el-button>
</el-col>
</el-row>
</el-card>
</div>
</template>
<script>
import { listPurchaseApplys, submitResourceOut } from '@/api/resource/resourceOutManageApi'
export default {
name: 'ResourceOutManageList',
data() {
return {
loading: false,
resourceOutManageInfo: {
purchaseApplyDetailVo: [],
applyOrderId: '',
taskId: '',
resOrderType: ''
}
}
},
created() {
this.resourceOutManageInfo.applyOrderId = this.$route.query.applyOrderId
this.resourceOutManageInfo.resOrderType = this.$route.query.resOrderType
this.resourceOutManageInfo.taskId = this.$route.query.taskId
this.getList()
},
methods: {
async getList() {
try {
this.loading = true
const params = {
page: 1,
row: 10,
applyOrderId: this.resourceOutManageInfo.applyOrderId,
resOrderType: this.resourceOutManageInfo.resOrderType
}
const { data } = await listPurchaseApplys(params)
const purchaseApply = data.purchaseApplys[0]
this.resourceOutManageInfo = {
...this.resourceOutManageInfo,
...purchaseApply
}
this.resourceOutManageInfo.purchaseApplyDetailVo.forEach(item => {
item.purchaseQuantity = ''
item.price = ''
item.purchaseRemark = ''
})
} catch (error) {
console.error('Failed to fetch purchase apply list:', error)
this.$message.error(this.$t('resourceOutManage.fetchError'))
} finally {
this.loading = false
}
},
async handleSubmit() {
try {
// Validate form
let isValid = true
this.resourceOutManageInfo.purchaseApplyDetailVo.forEach(item => {
if (!item.purchaseQuantity || parseFloat(item.purchaseQuantity) <= 0) {
this.$message.error(this.$t('resourceOutManage.quantityRequired'))
isValid = false
return
}
item.purchaseQuantity = parseFloat(item.purchaseQuantity)
if (item.purchaseQuantity > parseFloat(item.stock)) {
this.$message.error(this.$t('resourceOutManage.insufficientStock'))
isValid = false
return
}
})
if (!isValid) return
const response = await submitResourceOut(this.resourceOutManageInfo)
if (response.code === 0) {
this.$message.success(this.$t('resourceOutManage.submitSuccess'))
this.$router.go(-1)
} else {
this.$message.error(response.msg)
}
} catch (error) {
console.error('Failed to submit resource out:', error)
this.$message.error(this.$t('resourceOutManage.submitError'))
}
}
}
}
</script>
<style lang="scss" scoped>
.resource-out-manage-container {
padding: 20px;
.box-card {
margin-bottom: 20px;
}
.footer-row {
margin-top: 20px;
}
.text-right {
text-align: right;
}
}
</style>