Commit c153bb814e8174db1d63bb1b56ebbf892d6a9815

Authored by 史婷婷
1 parent d3541766

feat: 撤销单-新增-完成

... ... @@ -9,11 +9,6 @@
9 9 <view class="item-title"><text class="required">*</text><text>订单编号</text></view>
10 10 </template>
11 11 </uni-list-item>
12   - <uni-list-item title="供货单位">
13   - <template v-slot:footer>
14   - <view class="readonly-text">{{ getDicName('SUPPLIER', form.supplyUnit, dicOptions.SUPPLIER) }}</view>
15   - </template>
16   - </uni-list-item>
17 12 <uni-list-item title="订货单位">
18 13 <template v-slot:footer>
19 14 <view class="readonly-text">{{ form.orderingUnitName }}</view>
... ... @@ -24,20 +19,14 @@
24 19 <view class="readonly-text">{{ form.orderDate }}</view>
25 20 </template>
26 21 </uni-list-item>
27   - <uni-list-item title="生产厂">
  22 + <uni-list-item title="申请撤单日期">
28 23 <template v-slot:footer>
29   - <view class="readonly-text">{{ form.workshopName }}</view>
  24 + <view class="readonly-text">{{ form.documentPreparationDate }}</view>
30 25 </template>
31 26 </uni-list-item>
32   - <uni-list-item title="结算方式或期限">
  27 + <uni-list-item title="所属办">
33 28 <template v-slot:footer>
34   - <view class="readonly-text">{{ form.settlementTerms }}</view>
35   - </template>
36   - </uni-list-item>
37   -
38   - <uni-list-item title="交货方式">
39   - <template v-slot:footer>
40   - <uni-easyinput v-model="form.deliveryMethod" placeholder="请输入交货方式" :inputBorder="false" />
  29 + <view class="readonly-text">{{ form.deptName }}</view>
41 30 </template>
42 31 </uni-list-item>
43 32 </view>
... ... @@ -48,90 +37,24 @@
48 37 </view>
49 38
50 39 <view class="section">
51   - <uni-list-item title="价格表编号">
52   - <template v-slot:footer>
53   - <uni-easyinput v-model="form.priceListNo" placeholder="请输入价格表编号" :inputBorder="false" />
54   - </template>
55   - </uni-list-item>
56   - <uni-list-item title="开票情况">
  40 + <uni-list-item title="撤销原因">
57 41 <template v-slot:footer>
58   - <uni-easyinput v-model="form.invoicingStatus" placeholder="请输入开票情况" :inputBorder="false" />
  42 + <uni-easyinput type="textarea" v-model="form.revokeReason" placeholder="请输入撤销原因"
  43 + :inputBorder="false" />
59 44 </template>
60 45 </uni-list-item>
61   - <uni-list-item class="amount-item">
62   - <template v-slot:body>
63   - <view class="item-title"><text>运费</text></view>
64   - </template>
65   - <template v-slot:footer>
66   - <view class="amount-row">
67   - <uni-easyinput type="number" v-model="form.shippingCost" placeholder="0.00" :inputBorder="false" />
68   - <text class="unit">元</text>
69   - </view>
70   - </template>
71   - </uni-list-item>
72   - <uni-list-item class="amount-item">
73   - <template v-slot:body>
74   - <view class="item-title"><text>包装费</text></view>
75   - </template>
  46 + </view>
  47 +
  48 + <view class="section">
  49 + <uni-list-item title="撤销确认凭证">
76 50 <template v-slot:footer>
77   - <view class="amount-row">
78   - <uni-easyinput type="number" v-model="form.packagingFee" placeholder="0.00" :inputBorder="false" />
79   - <text class="unit">元</text>
80   - </view>
81   - </template>
82   - </uni-list-item>
83   - <uni-list-item class="select-item" :class="form.executionStandardName ? 'is-filled' : 'is-empty'" clickable
84   - @click="openSheet('executionStandard')" :rightText="form.executionStandardName || '请选择'" showArrow>
85   - <template v-slot:body>
86   - <view class="item-title"><text>执行标准</text></view>
  51 + <FileUpload v-model="confirmationVoucherFile" />
  52 + <view v-if="confirmationVoucherFile && confirmationVoucherFile.name" class="upload-show">{{ confirmationVoucherFile.name
  53 + }}</view>
87 54 </template>
88 55 </uni-list-item>
89 56 </view>
90 57
91   -
92   - <view class="title-header">
93   - <image class="title-header_icon" src="/static/images/title.png" />
94   - <span>具体质量要求</span>
95   - </view>
96   -
97   - <uni-list-item title="件重条头">
98   - <template v-slot:footer>
99   - <uni-easyinput type="textarea" v-model="form.pieceWeightHeader" placeholder="请输入件重条头"
100   - :inputBorder="false" />
101   - </template>
102   - </uni-list-item>
103   - <uni-list-item title="表面">
104   - <template v-slot:footer>
105   - <uni-easyinput type="textarea" v-model="form.surface" placeholder="请输入表面" :inputBorder="false" />
106   - </template>
107   - </uni-list-item>
108   - <uni-list-item title="公差">
109   - <template v-slot:footer>
110   - <uni-easyinput type="textarea" v-model="form.tolerance" placeholder="请输入公差" :inputBorder="false" />
111   - </template>
112   - </uni-list-item>
113   - <uni-list-item title="性能">
114   - <template v-slot:footer>
115   - <uni-easyinput type="textarea" v-model="form.performance" placeholder="请输入性能" :inputBorder="false" />
116   - </template>
117   - </uni-list-item>
118   - <uni-list-item title="成分">
119   - <template v-slot:footer>
120   - <uni-easyinput type="textarea" v-model="form.element" placeholder="请输入成分" :inputBorder="false" />
121   - </template>
122   - </uni-list-item>
123   - <uni-list-item title="包装">
124   - <template v-slot:footer>
125   - <uni-easyinput type="textarea" v-model="form.packaging" placeholder="请输入包装" :inputBorder="false" />
126   - </template>
127   - </uni-list-item>
128   - <uni-list-item title="备注">
129   - <template v-slot:footer>
130   - <uni-easyinput type="textarea" v-model="form.remarks" placeholder="请输入备注" :inputBorder="false" />
131   - </template>
132   - </uni-list-item>
133   -
134   -
135 58 </uni-list>
136 59 </scroll-view>
137 60
... ... @@ -139,7 +62,10 @@
139 62 <view class="view-total">
140 63 <view class="head">合计</view>
141 64 <view class="row">
142   - <text class="label">总数量</text><text class="value">{{ form.afterTotalQuantity }}</text>
  65 + <text class="label">原数量</text><text class="value">{{ form.totalQuantity || '-' }}</text>
  66 + </view>
  67 + <view class="row">
  68 + <text class="label">撤销数量</text><text class="value">{{ form.totalRevokeQuantity || '-' }}</text>
143 69 </view>
144 70 </view>
145 71 <button class="btn submit" type="primary" @click="onSubmit">提交</button>
... ... @@ -148,55 +74,47 @@
148 74 @confirm="onSheetConfirm" />
149 75 <RelateSelectSheet :visible.sync="relate.visible" :title="relate.title" :source="relate.source"
150 76 :display-fields="relate.display" :multiple="relate.multiple" :row-key="relate.rowKey"
151   - :selectedKeys.sync="relate.selectedKeys" :source-extra="{ queryType: 'CHANGE' }" @confirm="onRelateConfirm" />
  77 + :selectedKeys.sync="relate.selectedKeys" :source-extra="{ queryType: 'REVOKE' }" @confirm="onRelateConfirm" />
152 78 </view>
153 79 </template>
154 80
155 81 <script>
156   -import { createApi, loadOrderApi } from '@/api/revoke_list.js'
  82 +import { createApi } from '@/api/revoke_list.js'
  83 +import { loadOrderApi } from '@/api/change_list.js'
157 84 import Product from './product.vue'
158 85 import SingleSelectSheet from '@/components/single-select/index.vue'
159 86 import RelateSelectSheet from '@/components/relate-select/index.vue'
160 87 import { getDicName } from '@/utils/dic.js'
161 88 import { getDicByCodes } from '@/utils/dic'
  89 +import FileUpload from '@/components/file-upload/index.vue'
162 90
163 91 export default {
164 92 name: 'RevokeListAdd',
165   - components: { Product, SingleSelectSheet, RelateSelectSheet },
  93 + components: { Product, SingleSelectSheet, RelateSelectSheet, FileUpload },
166 94 data() {
167 95 return {
168 96 form: {
  97 + purchaseOrderId: '',
  98 + id: '',
  99 + // 订单基础信息
169 100 orderNo: '',
170   - orderId: '',
171   - supplyUnit: '',
172 101 orderingUnit: '',
173 102 orderDate: '',
174   - workshopId: '',
175   - settlementTerms: '',
176   - deliveryMethod: '',
177   - priceListNo: '',
178   - invoicingStatus: '',
179   - shippingCost: '',
180   - packagingFee: '',
181   - executionStandard: '',
182   - executionStandardRemarks: '',
183   - totalQuantity: '',
184   - afterTotalQuantity: '',
185   - pieceWeightHeader: '',
186   - surface: '',
187   - tolerance: '',
188   - performance: '',
189   - element: '',
190   - packaging: '',
191   - remarks: '',
192 103 // 默认当前日期 格式为 yyyy-MM-dd
193   - orderDate: new Date().toISOString().substring(0, 10),
194   -
  104 + documentPreparationDate: new Date().toISOString().substring(0, 10),
  105 + deptName: '',
  106 + totalQuantity: '',
  107 + totalRevokeQuantity: '',
  108 + revokeReason: '',
  109 + // 文件上传
  110 + confirmationVoucherFileName: '',
  111 + confirmationVoucherFileId: '',
195 112 },
196 113 initPurchaseOrderLineList: [],
197 114 dicOptions: { SUPPLIER: [], APPLICABLE_STANDARD: [] },
198 115 sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
199   - relate: { visible: false, title: '选择', source: '', display: [], multiple: false, rowKey: 'id', selectedKeys: [], fieldKey: '' }
  116 + relate: { visible: false, title: '选择', source: '', display: [], multiple: false, rowKey: 'id', selectedKeys: [], fieldKey: '' },
  117 + confirmationVoucherFile: { id: '', name: '' },
200 118 }
201 119 },
202 120 onLoad() {
... ... @@ -277,6 +195,8 @@ export default {
277 195 this.$nextTick(() => { this.relate.visible = true })
278 196 },
279 197 async onRelateConfirm({ items }) {
  198 + console.log('onRelateConfirm_items', items)
  199 + console.log('onRelateConfirm_this.relate', this.relate)
280 200 const _fieldKey = this.relate.fieldKey
281 201 const first = (items && items.length > 0) ? items[0] : null
282 202 if (_fieldKey === 'orderNo') {
... ... @@ -288,16 +208,12 @@ export default {
288 208 const item = Array.isArray(data) ? (data[0] || {}) : (data || {})
289 209 const next = { ...this.form, ...item }
290 210 next.orderNo = next.orderNo || ((first && (first.orderNo || first.code)) || '');
291   - next.orderId = next.id || '';
  211 + next.purchaseOrderId = next.id || '';
292 212 delete next.id
293 213 this.form = next
294   - const lines = Array.isArray(item.purchaseOrderLineList) ? item.purchaseOrderLineList.map(x => ({ ...x, purchaseOrderId: x.id, id: '' })) : []
295   - this.initPurchaseOrderLineList = lines
296   - const sum = lines.reduce((acc, it) => {
297   - const v = Number(it && it.quantity)
298   - return acc + (isNaN(v) ? 0 : v)
299   - }, 0)
300   - this.form.afterTotalQuantity = sum
  214 + const lines = Array.isArray(item.purchaseOrderLineList) ? item.purchaseOrderLineList.map(x => ({ ...x, purchaseOrderLineId: x.id, id: '' })) : []
  215 + this.initPurchaseOrderLineList = lines;
  216 + this.form.totalRevokeQuantity = 0;
301 217 this.refreshStandardName()
302 218 } catch (e) {
303 219 this.form.orderNo = (first && (first.orderNo || first.code)) || ''
... ... @@ -328,12 +244,7 @@ export default {
328 244 return false
329 245 }
330 246 const fields = [
331   - { key: 'industry', label: '行业' },
332   - { key: 'quality', label: '品质' },
333   - { key: 'brand', label: '牌号' },
334   - { key: 'quantity', label: '数量' },
335   - { key: 'salesPrice', label: '销售价格' },
336   - { key: 'deliveryDate', label: '发货日期' },
  247 + { key: 'revokeQuantity', label: '撤销数量kg' },
337 248 ]
338 249 for (let i = 0; i < list.length; i++) {
339 250 const it = list[i] || {}
... ... @@ -344,6 +255,13 @@ export default {
344 255 return false
345 256 }
346 257 }
  258 + // 撤销数量kg不能大于原数量
  259 + const originalQuantity = Number(it && it.quantity)
  260 + const revokeQuantity = Number(it && it.revokeQuantity)
  261 + if (revokeQuantity > originalQuantity) {
  262 + uni.showToast({ title: `产品第${i + 1}条:撤销数量kg不能大于原数量!`, icon: 'none' })
  263 + return false
  264 + }
347 265 }
348 266 return true
349 267 },
... ... @@ -351,25 +269,27 @@ export default {
351 269 if (!this.validateRequired()) return
352 270 if (!this.validateLineListRequired()) return
353 271 const payload = { ...this.form }
354   - payload.orderSpecList = payload.purchaseOrderLineList || [];
  272 + payload.purchaseOrderRevokeLineList = payload.purchaseOrderLineList || [];
355 273 delete payload.purchaseOrderLineList;
356   - console.log('onSubmit__payload', payload)
  274 + payload.confirmationVoucherFileName = this.confirmationVoucherFile.name || '';
  275 + payload.confirmationVoucherFileId = this.confirmationVoucherFile.id || '';
357 276 try {
358 277 await createApi(payload)
359 278 uni.showToast({ title: '保存成功', icon: 'success' })
360   - setTimeout(() => { uni.redirectTo({ url: '/pages/order_list/index' }) }, 300)
  279 + setTimeout(() => { uni.redirectTo({ url: '/pages/revoke_list/index' }) }, 300)
361 280 } catch (e) {
362 281 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' })
363 282 }
364 283 },
365 284 purchaseOrderLineListChange(data) {
  285 + console.log('purchaseOrderLineListChange_data', data)
366 286 const list = Array.isArray(data) ? data : []
367 287 this.form.purchaseOrderLineList = list
368 288 const sum = list.reduce((acc, it) => {
369   - const v = Number(it && it.quantity)
  289 + const v = Number(it && it.revokeQuantity)
370 290 return acc + (isNaN(v) ? 0 : v)
371 291 }, 0)
372   - this.form.afterTotalQuantity = sum
  292 + this.form.totalRevokeQuantity = sum
373 293 },
374 294 }
375 295 }
... ... @@ -384,7 +304,7 @@ export default {
384 304
385 305 .scroll {
386 306 flex: 1;
387   - padding: 6rpx 0 310rpx;
  307 + padding: 6rpx 0 350rpx;
388 308 }
389 309
390 310
... ...
... ... @@ -160,7 +160,9 @@ export default {
160 160 })
161 161 },
162 162 filterStatus(status) {
163   - return this.statusOptions.filter(item => item.value === status)[0].text || '';
  163 + const list = Array.isArray(this.statusOptions) ? this.statusOptions : []
  164 + const m = list.find(it => String(it.value) === String(status))
  165 + return m ? (m.text || '') : ''
164 166 },
165 167 onAdd() {
166 168 uni.navigateTo({
... ...
... ... @@ -47,22 +47,20 @@
47 47 </view>
48 48 <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view>
49 49 <view class="row" :class="{ 'noneStyle': !item.showSalesPrice }"><text
50   - class="label">数量kg</text><text class="value">{{ item.quantity }}</text>
  50 + class="label">数量kg</text><text class="value">{{ item.quantity }}</text>
51 51 </view>
52   - <view class="row" :class="{ 'noneStyle': item.showSalesPrice }" v-if="item.showSalesPrice"><text
53   - class="label">销售价格</text><text class="value">{{
  52 + <view class="row" :class="{ 'noneStyle': item.showSalesPrice }"><text class="label">销售价格</text><text
  53 + class="value">{{
54 54 item.salesPrice }}</text></view>
55 55
  56 + <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text>
  57 + </view>
56 58 <uni-list class="edit-list">
57   - <uni-list-item title="发货日期">
  59 + <uni-list-item title="撤销数量kg">
58 60 <template v-slot:footer>
59   - <uni-datetime-picker type="date" v-model="item.deliveryDate" />
60   - </template>
61   - </uni-list-item>
62   - <uni-list-item title="考核超协">
63   - <template v-slot:footer>
64   - <uni-easyinput v-model="item.assessmentExceedsAgreement" placeholder="请输入考核超协"
65   - :inputBorder="false" />
  61 + <uni-easyinput type="digit" v-model="item.revokeQuantity" placeholder="请输入撤销数量kg"
  62 + :inputBorder="false" @input="onRevokeQuantityInput($event, item, idx)"
  63 + @blur="onRevokeQuantityBlur(item, idx)" />
66 64 </template>
67 65 </uni-list-item>
68 66 </uni-list>
... ... @@ -109,11 +107,11 @@
109 107 </view>
110 108 <view class="row"><text class="label">状态</text><text class="value">{{ item.status }}</text></view>
111 109 <view class="row"><text class="label">原数量kg</text><text class="value">{{ item.quantity }}</text></view>
112   - <view class="row"><text class="label">销售价格</text><text class="value">{{item.salesPrice }}</text></view>
  110 + <view class="row"><text class="label">销售价格</text><text class="value">{{ item.salesPrice }}</text></view>
113 111 <view class="row"><text class="label">发货日期</text><text class="value">{{ item.deliveryDate }}</text>
114 112 </view>
115 113 <view class="row"><text class="label">撤销数量kg</text><text class="value">{{ item.revokeQuantity
116   - }}</text></view>
  114 + }}</text></view>
117 115 </view>
118 116 <view class="view-total">
119 117 <view class="head">合计</view>
... ... @@ -137,7 +135,6 @@ export default {
137 135 mode: { type: String, default: 'add' },
138 136 list: { type: Array, default: () => [] },
139 137 max: { type: Number, default: 8 },
140   - options: { type: Array, default: () => [] },
141 138 totalQuantity: { type: Number, default: 0 },
142 139 totalRevokeQuantity: { type: Number, default: 0 }
143 140 },
... ... @@ -148,13 +145,6 @@ export default {
148 145 }
149 146 },
150 147 computed: {
151   - selectOptions() {
152   - const list = Array.isArray(this.options) ? this.options : []
153   - return list.map(o => ({
154   - label: o.label != null ? o.label : (o.text != null ? o.text : (o.name != null ? o.name : '')),
155   - value: o.value != null ? o.value : (o.code != null ? o.code : (o.id != null ? o.id : o.productId))
156   - }))
157   - }
158 148 },
159 149 watch: {
160 150 items: {
... ... @@ -164,19 +154,13 @@ export default {
164 154 list: {
165 155 handler(v) {
166 156 const arr = Array.isArray(v) ? v : []
167   - const opts = this.selectOptions
168 157 this.items = arr.map(x => {
169 158 const it = { ...this.defaultItem(), ...x, collapsed: true }
170   - const m = opts.find(o => String(o.value) === String(it.sex))
171   - it.sexName = m ? (m.label || '') : it.sexName
172 159 return it
173 160 })
174 161 },
175 162 deep: true
176 163 },
177   - options: {
178   - handler() { this.refreshSexNames() }
179   - }
180 164 },
181 165 created() {
182 166 const init = Array.isArray(this.list) && this.list.length > 0 ? this.list.map(v => ({ ...this.defaultItem(), ...v, collapsed: false })) : [{ ...this.defaultItem(), collapsed: false }]
... ... @@ -184,20 +168,7 @@ export default {
184 168 },
185 169 methods: {
186 170 defaultItem() {
187   - return { personId: uuid(), name: '', sex: '', sexName: '', nativePlace: '', age: '', position: '', mobile: '', phone: '', email: '', address: '', collapsed: false }
188   - },
189   - getSexName(item) {
190   - const opts = this.selectOptions
191   - const v = item && item.sex
192   - const m = opts.find(o => String(o.value) === String(v))
193   - return m ? (m.label || '') : ((item && item.sexName) || '')
194   - },
195   - refreshSexNames() {
196   - const opts = this.selectOptions
197   - this.items = (this.items || []).map(it => {
198   - const m = opts.find(o => String(o.value) === String(it.sex))
199   - return { ...it, sexName: m ? (m.label || '') : it.sexName }
200   - })
  171 + return { collapsed: false }
201 172 },
202 173 toggleItem(idx) {
203 174 const it = this.items[idx]
... ... @@ -211,6 +182,27 @@ export default {
211 182 this.$emit('update:value', out)
212 183 this.$emit('change', out)
213 184 },
  185 + onRevokeQuantityInput(val, item, idx) {
  186 + let v = String(val != null ? val : (item && item.revokeQuantity) || '')
  187 + v = v.replace(/[^0-9.]/g, '')
  188 + v = v.replace(/(\..*)\./g, '$1')
  189 + if (v.startsWith('.')) v = '0' + v
  190 + if (v === '') { item.revokeQuantity = ''; return }
  191 + const num = Number(v)
  192 + if (isNaN(num) || num < 0) {
  193 + item.revokeQuantity = '0'
  194 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  195 + } else {
  196 + item.revokeQuantity = v
  197 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  198 + }
  199 + },
  200 + onRevokeQuantityBlur(item, idx) {
  201 + const v = String((item && item.revokeQuantity) || '')
  202 + const num = Number(v)
  203 + if (isNaN(num) || num < 0) { item.revokeQuantity = '0'; if (typeof idx === 'number') this.$set(this.items, idx, { ...item }); return }
  204 + if (typeof idx === 'number') this.$set(this.items, idx, { ...item })
  205 + },
214 206 toggleViewCollapse() {
215 207 this.collapsedView = !this.collapsedView
216 208 }
... ... @@ -275,6 +267,10 @@ export default {
275 267 ::v-deep .uni-list {
276 268 background: transparent;
277 269
  270 + .uni-list--border-top {
  271 + background-color: transparent !important;
  272 + }
  273 +
278 274 &-item {
279 275 &__extra-text {
280 276 font-size: 32rpx;
... ... @@ -309,10 +305,16 @@ export default {
309 305 font-size: 32rpx;
310 306 }
311 307
  308 + &-textarea {
  309 + margin: 4rpx !important;
  310 + }
  311 +
312 312 .content-clear-icon {
313 313 font-size: 44rpx !important;
314 314 }
  315 +
315 316 }
  317 +
316 318 }
317 319
318 320 .amount-row {
... ... @@ -399,6 +401,8 @@ export default {
399 401 font-weight: 600;
400 402 }
401 403 }
  404 +
  405 +
402 406 }
403 407
404 408 /* 只读 easyinput 根据内容自适应高度 */
... ...
... ... @@ -563,7 +563,7 @@ $uni-border-1: #dcdfe6 !default;
563 563 flex: 1;
564 564 line-height: 1.5;
565 565 font-size: 14px;
566   - margin: 6px;
  566 + margin: 2px;
567 567 margin-left: 0;
568 568 height: 80px;
569 569 min-height: 80px;
... ...