Form.vue
14.5 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
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
<template>
<transition name="el-zoom-in-center">
<div class="NCC-preview-main order-form">
<div class="NCC-common-page-header">
<el-page-header @back="goBack" :content="dataForm.id?'编辑':'新建'" />
<div class="options">
<el-button type="primary" @click="submit()" :loading="btnLoading">确 定</el-button>
<el-button @click="goBack()">取 消</el-button>
</div>
</div>
<div class="main" v-loading="loading">
<el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="90px">
<el-row>
<el-col :span="18">
<el-col :span="8">
<el-form-item label="订单编码" prop="code">
<el-input v-model="dataForm.code" placeholder="提交后系统自动生成" readonly>
</el-input>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="客户名称" prop="customerName">
<el-autocomplete v-model="dataForm.customerName"
:fetch-suggestions="querySearchAsync" placeholder="请输入客户名称"
@select="handleSelect" style="width:100%" popper-class="sale-order-popper">
<template slot-scope="{ item }">
<div class="sale-order-popper-item">
<span>{{ item.code }}</span>
<span class="name">{{ item.name }}</span>
<span>{{ item.address }}</span>
<span>{{ item.customerName }}</span>
<span>{{ item.contactTel }}</span>
</div>
</template>
</el-autocomplete>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="联系方式" prop="contactTel">
<el-input v-model="dataForm.contactTel" placeholder="联系方式">
</el-input>
</el-form-item>
</el-col>
<el-col :span="16">
<el-form-item label="送货地址" prop="address">
<el-input v-model="dataForm.address" placeholder="送货地址">
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="发货仓库" prop="goodsWarehouse">
<el-select v-model="dataForm.goodsWarehouse" placeholder="发货仓库">
<el-option :key="item" :label="item" :value="item"
v-for="item in storeOptions" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="业务员" prop="business">
<el-input v-model="dataForm.business" placeholder="业务员">
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="收款方式" prop="gatheringType">
<el-select v-model="dataForm.gatheringType" placeholder="选择收款方式">
<el-option :key="item" :label="item" :value="item" v-for="item in options" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="让利金额" prop="partPrice">
<el-input v-model="dataForm.partPrice" placeholder="让利金额">
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="优惠金额" prop="reducedPrice">
<el-input v-model="dataForm.reducedPrice" placeholder="优惠金额">
</el-input>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="折后金额" prop="discountPrice">
<el-input v-model="dataForm.discountPrice" placeholder="折后金额">
</el-input>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注">
<el-input v-model="dataForm.description" placeholder="备注" type="textarea"
:rows="3" />
</el-form-item>
</el-col>
</el-col>
<el-col :span="6">
<el-form-item label="审核人" label-width="120px" prop="auditName">
<el-input v-model="dataForm.auditName" disabled />
</el-form-item>
<el-form-item label="审核时间" label-width="120px" prop="auditDate">
<el-input v-model="dataForm.auditDate" disabled />
</el-form-item>
<el-form-item label="发货通知人" label-width="120px" prop="goodsName">
<el-input v-model="dataForm.goodsName" disabled />
</el-form-item>
<el-form-item label="发货通知时间" label-width="120px" prop="goodsDate">
<el-input v-model="dataForm.goodsDate" disabled />
</el-form-item>
<el-form-item label="收货仓库" label-width="120px" prop="harvestWarehouse">
<el-input v-model="dataForm.harvestWarehouse" disabled />
</el-form-item>
<el-form-item label="代发客户" label-width="120px" prop="issuingName">
<el-input v-model="dataForm.issuingName" disabled />
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-row class="add-btn">
<el-col :span="18">
<el-button type="primary" icon="el-icon-plus" @click="openGoodsBox">选择产品</el-button>
</el-col>
<el-col :span="6">
<el-form label-width="120px">
<el-form-item label="订货类型">
<el-select v-model="orderType" placeholder="选择订货类型" @change="onTypeChange"
clearable>
<el-option label="1" value="1" />
<el-option label="2" value="2" />
<el-option label="3" value="3" />
</el-select>
</el-form-item>
</el-form>
</el-col>
</el-row>
<NCC-table :data="dataForm.productEntryList" size='small'>
<el-table-column label="操作" width="80">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-plus" @click="addItem(scope.$index)">
</el-button>
<el-button size="mini" type="text" class="NCC-table-delBtn" icon="el-icon-minus"
@click="delItem(scope.$index)">
</el-button>
</template>
</el-table-column>
<el-table-column prop="productCode" label="商品编码" width="200">
<template slot-scope="scope">
<el-autocomplete v-model="scope.row.productCode" :fetch-suggestions="goodsSearchAsync"
placeholder="商品编码" @select="goodsSelect($event,scope.row)" style="width:100%"
popper-class="sale-order-popper goods-popper">
<template slot-scope="{ item }">
<div class="sale-order-popper-item">
<span>{{ item.code }}</span>
<span>{{ item.fullName }}</span>
<span>{{ item.productSpecification }}</span>
</div>
</template>
</el-autocomplete>
</template>
</el-table-column>
<el-table-column prop="productName" label="商品名称" />
<el-table-column prop="productSpecification" label="规格型号" width="100" />
<el-table-column prop="type" label="订货类型" width="100" />
<el-table-column prop="qty" label="数量" width="120">
<template slot-scope="scope">
<el-input-number v-model="scope.row.qty" @change="count(scope.row)" :controls="false"
style="width:100% !important">
</el-input-number>
</template>
</el-table-column>
<el-table-column prop="money" label="单价" width="120">
<template slot-scope="scope">
<el-input-number v-model="scope.row.money" @change="count(scope.row)"
:controls="false" style="width:100% !important">
</el-input-number>
</template>
</el-table-column>
<el-table-column prop="amount" label="金额" width="120" />
<el-table-column prop="description" label="备注" width="120">
<template slot-scope="scope">
<el-input v-model="scope.row.description"> </el-input>
</template>
</el-table-column>
</NCC-table>
<div class="order-footer">
<span class="order-footer-item">订单总数:0</span>
<span class="order-footer-item">下单总数:0</span>
<span class="order-footer-item">总金额(元):{{total}}</span>
</div>
</div>
<GoodsBox v-if="goodsBoxVisible" ref="goodsBox" @choice="choice" />
</div>
</transition>
</template>
<script>
import { orderInfo, createOrder, updateOrder, getGoodsSelector, getCustomer, GoodsList } from '@/api/extend/saleOrder'
import GoodsBox from './GoodsBox'
export default {
components: { GoodsBox },
data() {
return {
dataForm: {
id: '',
address: "",
auditDate: '',
auditName: "",
business: "",
code: "",
contactTel: "",
customerId: "",
customerName: '',
description: "",
discountPrice: '',
gatheringType: "",
goodsDate: '',
goodsName: "",
goodsWarehouse: "",
harvestMsg: 0,
harvestWarehouse: "",
issuingName: "",
partPrice: '',
productEntryList: []
},
dataRule: {},
list: [],
loading: true,
total: 0,
options: ['现金', '转帐', '汇票'],
storeOptions: ['仓库1', '仓库2', '仓库3'],
goodsBoxVisible: false,
btnLoading: false,
orderType: ''
}
},
watch: {
'dataForm.productEntryList': {
handler(newVal, oldVal) {
let menoy = 0
for (let i = 0; i < newVal.length; i++) {
const e = newVal[i];
menoy += parseFloat(e.amount)
}
this.total = menoy
},
deep: true
}
},
methods: {
goBack() {
this.$emit('close')
},
init(id) {
this.dataForm.id = id || ''
this.loading = true
this.$nextTick(() => {
if (this.dataForm.id) {
this.$refs['dataForm'].resetFields()
orderInfo(this.dataForm.id).then(res => {
this.dataForm = res.data
this.loading = false
})
} else {
this.loading = false
this.addItem()
}
})
},
addItem(index) {
let item = {
productId: '',
productCode: '',
productName: '',
productSpecification: '',
qty: 1,
money: 0,
amount: 0,
description: '',
type: ''
}
this.dataForm.productEntryList.splice(index + 1, 0, item)
},
delItem(index) {
this.dataForm.productEntryList.splice(index, 1);
},
count(row) {
row.amount = this.ncc.toDecimal(parseFloat(row.money) * parseFloat(row.qty))
},
openGoodsBox() {
this.goodsBoxVisible = true
this.$nextTick(() => {
this.$refs.goodsBox.init()
})
},
onTypeChange(val) {
if (!val) return
for (let i = 0; i < this.dataForm.productEntryList.length; i++) {
this.dataForm.productEntryList[i].type = val
}
},
choice(list) {
for (let i = 0; i < list.length; i++) {
const e = list[i];
let item = {
productId: e.id,
productCode: e.code,
productName: e.fullName,
productSpecification: e.productSpecification,
qty: 1,
money: e.money,
amount: e.money,
description: '',
type: e.type
}
this.dataForm.productEntryList.push(item)
}
},
querySearchAsync(queryString, cb) {
getCustomer(queryString).then(res => {
cb(res.data.list)
})
},
goodsSearchAsync(queryString, cb) {
getGoodsSelector(queryString).then(res => {
cb(res.data.list)
})
},
goodsSelect(item, row) {
row.productId = item.id
row.productCode = item.code
row.productName = item.fullName
row.productSpecification = item.productSpecification
row.money = item.money
row.type = item.type
row.amount = this.ncc.toDecimal(parseFloat(row.money) * parseFloat(row.qty))
},
handleSelect(item) {
this.dataForm.customerName = item.name
this.dataForm.customerId = item.id
this.dataForm.contactTel = item.contactTel
this.dataForm.address = item.address
},
submit() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.btnLoading = true
const formMethod = this.dataForm.id ? updateOrder : createOrder
if (!this.dataForm.id) delete (this.dataForm.id)
formMethod(this.dataForm).then((res) => {
this.$message({
message: res.msg,
type: 'success',
duration: 1500,
onClose: () => {
this.btnLoading = false
this.$emit('close', true)
}
})
}).catch(() => { this.btnLoading = false })
}
})
}
}
}
</script>
<style lang="scss" scoped>
.NCC-common-page-header {
height: 61px;
}
>>> .el-tabs__header {
margin-bottom: 0;
}
>>> .el-select {
width: 100%;
}
.box {
position: relative;
}
.order-form {
height: 100%;
overflow: hidden;
.main {
display: flex;
flex-direction: column;
}
.add-btn {
margin-top: 20px;
margin-bottom: -10px;
}
.order-footer {
margin-top: 10px;
text-align: right;
font-size: 12px;
.order-footer-item {
display: inline-block;
min-width: 150px;
color: #606266;
text-align: left;
}
}
}
</style>
<style lang="scss">
.sale-order-popper {
&.el-autocomplete-suggestion li {
white-space: normal;
overflow: visible;
text-overflow: clip;
}
.sale-order-popper-item {
span {
margin-right: 10px;
}
.name {
color: #1890ff;
}
}
}
.goods-popper {
width: 400px !important;
}
</style>