e5777926
wuxw
优化工作办理
|
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
|
<template>
<div class="edit-purchase-apply-container">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>{{ $t('editPurchaseApply.title') }}</span>
<div class="header-tools">
<el-button type="primary" size="small" @click="goBack">
<i class="el-icon-close"></i>
{{ $t('editPurchaseApply.back') }}
</el-button>
</div>
</div>
<el-row :gutter="20">
<el-col :span="24">
<el-card>
<el-form label-width="120px">
<el-form-item :label="$t('editPurchaseApply.contactPerson')">
<el-input v-model="editPurchaseApplyInfo.endUserName"
:placeholder="$t('editPurchaseApply.contactPersonPlaceholder')" clearable>
</el-input>
</el-form-item>
<el-form-item :label="$t('editPurchaseApply.contactPhone')">
<el-input v-model="editPurchaseApplyInfo.endUserTel"
:placeholder="$t('editPurchaseApply.contactPhonePlaceholder')" clearable>
</el-input>
</el-form-item>
<el-form-item :label="$t('editPurchaseApply.applyDescription')">
<el-input type="textarea" v-model="editPurchaseApplyInfo.description"
:placeholder="$t('editPurchaseApply.applyDescriptionPlaceholder')" :rows="3">
</el-input>
</el-form-item>
</el-form>
</el-card>
</el-col>
</el-row>
<el-row :gutter="20" style="margin-top: 20px;">
<el-col :span="24">
<el-card>
<div slot="header" class="clearfix">
<span>{{ $t('editPurchaseApply.purchaseItems') }}</span>
<div class="header-tools">
<el-button type="primary" size="small" @click="openSelectResourceStoreDialog">
<i class="el-icon-search"></i>
{{ $t('editPurchaseApply.select') }}
</el-button>
</div>
</div>
<el-table :data="editPurchaseApplyInfo.resourceStores" border style="width: 100%">
<el-table-column prop="type" :label="$t('editPurchaseApply.itemType')" align="center">
<template slot-scope="scope">
{{ scope.row.parentRstName || '-' }} > {{ scope.row.rstName || '-' }}
</template>
</el-table-column>
<el-table-column prop="name" :label="$t('editPurchaseApply.itemName')" align="center">
<template slot-scope="scope">
{{ scope.row.resName }}({{ scope.row.resCode }})
</template>
</el-table-column>
<el-table-column prop="spec" :label="$t('editPurchaseApply.itemSpec')" align="center">
<template slot-scope="scope">
{{ scope.row.rssName || '-' }}
</template>
</el-table-column>
<el-table-column prop="price" :label="$t('editPurchaseApply.price')" align="center">
<template slot-scope="scope">
<el-select v-model="scope.row.timesId" @change="changeTimesId($event, scope.$index)"
style="width: 100%">
<el-option :value="''" :label="$t('editPurchaseApply.selectPrice')">
</el-option>
<el-option v-for="time in scope.row.times" :key="time.timesId" :value="time.timesId"
:label="time.price">
</el-option>
</el-select>
</template>
</el-table-column>
<el-table-column prop="stock" :label="$t('editPurchaseApply.itemStock')" align="center">
<template slot-scope="scope">
{{ getTimesStock(scope.row) }}{{ scope.row.unitCodeName }}
</template>
</el-table-column>
<el-table-column prop="quantity" :label="$t('editPurchaseApply.applyQuantity')" align="center">
<template slot-scope="scope">
<el-input-number v-model="scope.row.quantity"
:placeholder="$t('editPurchaseApply.applyQuantityPlaceholder')" :min="1" controls-position="right"
style="width: 120px">
</el-input-number>
{{ scope.row.unitCodeName }}
</template>
</el-table-column>
<el-table-column prop="remark" :label="$t('editPurchaseApply.remark')" align="center">
<template slot-scope="scope">
<el-input v-model="scope.row.remark" :placeholder="$t('editPurchaseApply.remarkPlaceholder')"
clearable>
</el-input>
</template>
</el-table-column>
<el-table-column :label="$t('editPurchaseApply.operation')" align="center" width="120">
<template slot-scope="scope">
<el-button type="danger" size="mini" @click="removeSelectResourceStoreItem(scope.row.resId)">
{{ $t('editPurchaseApply.remove') }}
</el-button>
</template>
</el-table-column>
</el-table>
</el-card>
</el-col>
</el-row>
<el-row style="margin-top: 20px;">
<el-col :span="24" style="text-align: right;">
<el-button type="primary" @click="editApplyPurchaseSummit">
<i class="el-icon-check"></i>
{{ $t('editPurchaseApply.submit') }}
</el-button>
</el-col>
</el-row>
<choose-resource-store2 ref="chooseResourceStoreDialog" @setSelectResourceStores="handleSelectResourceStores">
</choose-resource-store2>
</el-card>
</div>
</template>
<script>
import { getCommunityId } from '@/api/community/communityApi'
import { listPurchaseApplys, updatePurchaseApply } from '@/api/resource/editPurchaseApplyApi'
import ChooseResourceStore2 from '@/components/resource/chooseResourceStore2'
export default {
name: 'EditPurchaseApplyList',
components: {
ChooseResourceStore2
},
data() {
return {
editPurchaseApplyInfo: {
applyOrderId: '',
resourceStores: [],
description: '',
endUserName: '',
endUserTel: '',
resOrderType: '10000',
communityId: getCommunityId()
}
}
},
created() {
this.editPurchaseApplyInfo.applyOrderId = this.$route.query.applyOrderId
this.editPurchaseApplyInfo.resOrderType = this.$route.query.resOrderType || '10000'
this.listPurchaseApply()
},
methods: {
async listPurchaseApply() {
try {
const params = {
page: 1,
row: 1,
applyOrderId: this.editPurchaseApplyInfo.applyOrderId,
resOrderType: this.editPurchaseApplyInfo.resOrderType
}
const { data } = await listPurchaseApplys(params)
if (data && data.length > 0) {
const purchaseApply = data[0]
Object.assign(this.editPurchaseApplyInfo, purchaseApply)
this.editPurchaseApplyInfo.resourceStores = purchaseApply.purchaseApplyDetailVo || []
}
} catch (error) {
console.error('获取采购申请详情失败:', error)
}
},
openSelectResourceStoreDialog() {
this.$refs.chooseResourceStoreDialog.open({
shId: this.editPurchaseApplyInfo.shId
})
},
handleSelectResourceStores(resourceStores) {
const oldList = this.editPurchaseApplyInfo.resourceStores
// 过滤重复选择的商品
const newItems = resourceStores.filter(newItem => {
return !oldList.some(oldItem => oldItem.resId === newItem.resId && (!newItem.times || newItem.times.length < 2))
})
this.editPurchaseApplyInfo.resourceStores = [...newItems, ...oldList]
},
async editApplyPurchaseSummit() {
if (!this.editPurchaseApplyInfo.resourceStores || this.editPurchaseApplyInfo.resourceStores.length === 0) {
this.$message.warning(this.$t('editPurchaseApply.noItemsSelected'))
return
}
try {
await updatePurchaseApply(this.editPurchaseApplyInfo)
this.$message.success(this.$t('editPurchaseApply.updateSuccess'))
this.goBack()
} catch (error) {
console.error('提交采购申请失败:', error)
this.$message.error(error.message || this.$t('editPurchaseApply.updateFailed'))
}
},
removeSelectResourceStoreItem(resId) {
this.editPurchaseApplyInfo.resourceStores = this.editPurchaseApplyInfo.resourceStores.filter(
item => item.resId !== resId
)
},
changeTimesId(timesId, index) {
const times = this.editPurchaseApplyInfo.resourceStores[index].times
const selectedTime = times.find(time => time.timesId === timesId)
if (selectedTime) {
this.editPurchaseApplyInfo.resourceStores[index].selectedStock = selectedTime.stock
}
},
getTimesStock(resourceStore) {
if (!resourceStore.timesId) return '-'
if (!resourceStore.times) return 0
const selectedTime = resourceStore.times.find(time => time.timesId === resourceStore.timesId)
return selectedTime ? selectedTime.stock : 0
},
goBack() {
this.$router.go(-1)
}
}
}
</script>
<style lang="scss" scoped>
.edit-purchase-apply-container {
padding: 20px;
.box-card {
margin-bottom: 20px;
}
.header-tools {
float: right;
}
.el-form-item {
margin-bottom: 20px;
}
.el-select {
width: 100%;
}
}
</style>
|