Commit a454aed8f2f803d011a3f632b86bb633c6ba0ff1

Authored by 史婷婷
1 parent 100ac083

feat: 撤销单-编辑

... ... @@ -108,5 +108,6 @@ export default {
108 108 }
109 109 .file-name {
110 110 font-size: 28rpx; color: rgba(0,0,0,0.9);
  111 + line-height: 40rpx;
111 112 }
112 113 </style>
... ...
... ... @@ -58,27 +58,27 @@
58 58 <view class="view-total">
59 59 <view class="head">合计</view>
60 60 <view class="row">
61   - <text class="label">总数量</text><text class="value">{{ form.afterTotalQuantity }}</text>
  61 + <text class="label">原数量</text><text class="value">{{ form.totalQuantity || '-' }}</text>
  62 + </view>
  63 + <view class="row">
  64 + <text class="label">撤销数量</text><text class="value">{{ form.totalRevokeQuantity || '-' }}</text>
62 65 </view>
63 66 </view>
64 67 <button class="btn submit" type="primary" @click="onSubmit">提交</button>
65 68 </view>
66   - <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value"
67   - @confirm="onSheetConfirm" />
68 69 </view>
69 70 </template>
70 71
71 72 <script>
72 73 import { getDetailApi, updateApi } from '@/api/revoke_list.js'
73 74 import Product from './product.vue'
74   -import SingleSelectSheet from '@/components/single-select/index.vue'
75 75 import FileUpload from '@/components/file-upload/index.vue'
76 76 import { getDicName } from '@/utils/dic.js'
77 77 import { getDicByCodes } from '@/utils/dic'
78 78
79 79 export default {
80 80 name: 'RevokeListModify',
81   - components: { Product, SingleSelectSheet, FileUpload },
  81 + components: { Product, FileUpload },
82 82 data() {
83 83 return {
84 84 id: '',
... ... @@ -101,7 +101,6 @@ export default {
101 101 },
102 102 initPurchaseOrderLineList: [],
103 103 dicOptions: { SUPPLIER: [], APPLICABLE_STANDARD: [] },
104   - sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
105 104 confirmationVoucherFile: { id: '', name: '' },
106 105 }
107 106 },
... ... @@ -127,12 +126,14 @@ export default {
127 126 next.id = m.id || m.code || id;
128 127 next.purchaseOrderId = m.orderId || '';
129 128 next.purchaseOrderLineList = Array.isArray(m.afterChangeSpecList) ? m.afterChangeSpecList.map(x => ({ ...x })) : []
  129 + delete next.status
130 130 this.form = next;
131 131 this.initPurchaseOrderLineList = next.purchaseOrderRevokeLineList || [];
132 132 this.confirmationVoucherFile = {
133 133 id: m.confirmationVoucherFileId || '',
134 134 name: m.confirmationVoucherFileName || '',
135 135 }
  136 +
136 137 this.refreshStandardName()
137 138 } catch (e) {
138 139 uni.showToast({ title: '加载失败', icon: 'none' })
... ... @@ -142,22 +143,6 @@ export default {
142 143 const est = (this.dicOptions.APPLICABLE_STANDARD || []).find(o => String(o.code) === String(this.form.executionStandard))
143 144 this.form.executionStandardName = est ? (est.name || '') : (this.form.executionStandardName || '')
144 145 },
145   - openSheet(field) {
146   - if (field === 'executionStandard') {
147   - const options = (this.dicOptions.APPLICABLE_STANDARD || []).map(it => ({ label: it.name || '', value: it.code || '' }))
148   - const current = this.form.executionStandard
149   - const match = options.find(o => String(o.value) === String(current))
150   - this.sheet = { ...this.sheet, visible: true, title: '执行标准', options, field, value: match ? match.value : '' }
151   - }
152   - },
153   - onSheetConfirm({ value, label }) {
154   - const field = this.sheet.field
155   - if (field === 'executionStandard') {
156   - this.form.executionStandard = value || ''
157   - this.form.executionStandardName = label || ''
158   - }
159   - this.sheet.visible = false
160   - },
161 146 getDicName: getDicName,
162 147 validateLineListRequired() {
163 148 const list = Array.isArray(this.form.purchaseOrderLineList) ? this.form.purchaseOrderLineList : []
... ... @@ -166,12 +151,7 @@ export default {
166 151 return false
167 152 }
168 153 const fields = [
169   - { key: 'industry', label: '行业' },
170   - { key: 'quality', label: '品质' },
171   - { key: 'brand', label: '牌号' },
172   - { key: 'quantity', label: '数量' },
173   - { key: 'salesPrice', label: '销售价格' },
174   - { key: 'deliveryDate', label: '发货日期' },
  154 + { key: 'revokeQuantity', label: '撤销数量kg' },
175 155 ]
176 156 for (let i = 0; i < list.length; i++) {
177 157 const it = list[i] || {}
... ... @@ -182,19 +162,28 @@ export default {
182 162 return false
183 163 }
184 164 }
  165 + // 撤销数量kg不能大于原数量
  166 + const originalQuantity = Number(it && it.quantity)
  167 + const revokeQuantity = Number(it && it.revokeQuantity)
  168 + if (revokeQuantity > originalQuantity) {
  169 + uni.showToast({ title: `产品第${i + 1}条:撤销数量kg不能大于原数量!`, icon: 'none' })
  170 + return false
  171 + }
185 172 }
186 173 return true
187 174 },
188 175 async onSubmit() {
189 176 if (!this.validateLineListRequired()) return
190 177 const payload = { ...this.form }
191   - payload.orderSpecList = payload.purchaseOrderLineList || [];
  178 + payload.purchaseOrderRevokeLineList = payload.purchaseOrderLineList || [];
192 179 delete payload.purchaseOrderLineList
  180 + payload.confirmationVoucherFileName = this.confirmationVoucherFile.name || '';
  181 + payload.confirmationVoucherFileId = this.confirmationVoucherFile.id || '';
193 182 console.log('onSubmit__payload', payload)
194 183 try {
195 184 await updateApi(payload)
196 185 uni.showToast({ title: '保存成功', icon: 'success' })
197   - setTimeout(() => { uni.redirectTo({ url: '/pages/change_list/index' }) }, 300)
  186 + setTimeout(() => { uni.redirectTo({ url: '/pages/revoke_list/index' }) }, 300)
198 187 } catch (e) {
199 188 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' })
200 189 }
... ... @@ -203,10 +192,10 @@ export default {
203 192 const list = Array.isArray(data) ? data : []
204 193 this.form.purchaseOrderLineList = list
205 194 const sum = list.reduce((acc, it) => {
206   - const v = Number(it && it.quantity)
  195 + const v = Number(it && it.revokeQuantity)
207 196 return acc + (isNaN(v) ? 0 : v)
208 197 }, 0)
209   - this.form.afterTotalQuantity = sum
  198 + this.form.totalRevokeQuantity = sum
210 199 },
211 200 }
212 201 }
... ... @@ -221,7 +210,7 @@ export default {
221 210
222 211 .scroll {
223 212 flex: 1;
224   - padding: 6rpx 0 310rpx;
  213 + padding: 6rpx 0 350rpx;
225 214 }
226 215
227 216
... ...