Commit a454aed8f2f803d011a3f632b86bb633c6ba0ff1

Authored by 史婷婷
1 parent 100ac083

feat: 撤销单-编辑

@@ -108,5 +108,6 @@ export default { @@ -108,5 +108,6 @@ export default {
108 } 108 }
109 .file-name { 109 .file-name {
110 font-size: 28rpx; color: rgba(0,0,0,0.9); 110 font-size: 28rpx; color: rgba(0,0,0,0.9);
  111 + line-height: 40rpx;
111 } 112 }
112 </style> 113 </style>
@@ -58,27 +58,27 @@ @@ -58,27 +58,27 @@
58 <view class="view-total"> 58 <view class="view-total">
59 <view class="head">合计</view> 59 <view class="head">合计</view>
60 <view class="row"> 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 </view> 65 </view>
63 </view> 66 </view>
64 <button class="btn submit" type="primary" @click="onSubmit">提交</button> 67 <button class="btn submit" type="primary" @click="onSubmit">提交</button>
65 </view> 68 </view>
66 - <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value"  
67 - @confirm="onSheetConfirm" />  
68 </view> 69 </view>
69 </template> 70 </template>
70 71
71 <script> 72 <script>
72 import { getDetailApi, updateApi } from '@/api/revoke_list.js' 73 import { getDetailApi, updateApi } from '@/api/revoke_list.js'
73 import Product from './product.vue' 74 import Product from './product.vue'
74 -import SingleSelectSheet from '@/components/single-select/index.vue'  
75 import FileUpload from '@/components/file-upload/index.vue' 75 import FileUpload from '@/components/file-upload/index.vue'
76 import { getDicName } from '@/utils/dic.js' 76 import { getDicName } from '@/utils/dic.js'
77 import { getDicByCodes } from '@/utils/dic' 77 import { getDicByCodes } from '@/utils/dic'
78 78
79 export default { 79 export default {
80 name: 'RevokeListModify', 80 name: 'RevokeListModify',
81 - components: { Product, SingleSelectSheet, FileUpload }, 81 + components: { Product, FileUpload },
82 data() { 82 data() {
83 return { 83 return {
84 id: '', 84 id: '',
@@ -101,7 +101,6 @@ export default { @@ -101,7 +101,6 @@ export default {
101 }, 101 },
102 initPurchaseOrderLineList: [], 102 initPurchaseOrderLineList: [],
103 dicOptions: { SUPPLIER: [], APPLICABLE_STANDARD: [] }, 103 dicOptions: { SUPPLIER: [], APPLICABLE_STANDARD: [] },
104 - sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },  
105 confirmationVoucherFile: { id: '', name: '' }, 104 confirmationVoucherFile: { id: '', name: '' },
106 } 105 }
107 }, 106 },
@@ -127,12 +126,14 @@ export default { @@ -127,12 +126,14 @@ export default {
127 next.id = m.id || m.code || id; 126 next.id = m.id || m.code || id;
128 next.purchaseOrderId = m.orderId || ''; 127 next.purchaseOrderId = m.orderId || '';
129 next.purchaseOrderLineList = Array.isArray(m.afterChangeSpecList) ? m.afterChangeSpecList.map(x => ({ ...x })) : [] 128 next.purchaseOrderLineList = Array.isArray(m.afterChangeSpecList) ? m.afterChangeSpecList.map(x => ({ ...x })) : []
  129 + delete next.status
130 this.form = next; 130 this.form = next;
131 this.initPurchaseOrderLineList = next.purchaseOrderRevokeLineList || []; 131 this.initPurchaseOrderLineList = next.purchaseOrderRevokeLineList || [];
132 this.confirmationVoucherFile = { 132 this.confirmationVoucherFile = {
133 id: m.confirmationVoucherFileId || '', 133 id: m.confirmationVoucherFileId || '',
134 name: m.confirmationVoucherFileName || '', 134 name: m.confirmationVoucherFileName || '',
135 } 135 }
  136 +
136 this.refreshStandardName() 137 this.refreshStandardName()
137 } catch (e) { 138 } catch (e) {
138 uni.showToast({ title: '加载失败', icon: 'none' }) 139 uni.showToast({ title: '加载失败', icon: 'none' })
@@ -142,22 +143,6 @@ export default { @@ -142,22 +143,6 @@ export default {
142 const est = (this.dicOptions.APPLICABLE_STANDARD || []).find(o => String(o.code) === String(this.form.executionStandard)) 143 const est = (this.dicOptions.APPLICABLE_STANDARD || []).find(o => String(o.code) === String(this.form.executionStandard))
143 this.form.executionStandardName = est ? (est.name || '') : (this.form.executionStandardName || '') 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 getDicName: getDicName, 146 getDicName: getDicName,
162 validateLineListRequired() { 147 validateLineListRequired() {
163 const list = Array.isArray(this.form.purchaseOrderLineList) ? this.form.purchaseOrderLineList : [] 148 const list = Array.isArray(this.form.purchaseOrderLineList) ? this.form.purchaseOrderLineList : []
@@ -166,12 +151,7 @@ export default { @@ -166,12 +151,7 @@ export default {
166 return false 151 return false
167 } 152 }
168 const fields = [ 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 for (let i = 0; i < list.length; i++) { 156 for (let i = 0; i < list.length; i++) {
177 const it = list[i] || {} 157 const it = list[i] || {}
@@ -182,19 +162,28 @@ export default { @@ -182,19 +162,28 @@ export default {
182 return false 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 return true 173 return true
187 }, 174 },
188 async onSubmit() { 175 async onSubmit() {
189 if (!this.validateLineListRequired()) return 176 if (!this.validateLineListRequired()) return
190 const payload = { ...this.form } 177 const payload = { ...this.form }
191 - payload.orderSpecList = payload.purchaseOrderLineList || []; 178 + payload.purchaseOrderRevokeLineList = payload.purchaseOrderLineList || [];
192 delete payload.purchaseOrderLineList 179 delete payload.purchaseOrderLineList
  180 + payload.confirmationVoucherFileName = this.confirmationVoucherFile.name || '';
  181 + payload.confirmationVoucherFileId = this.confirmationVoucherFile.id || '';
193 console.log('onSubmit__payload', payload) 182 console.log('onSubmit__payload', payload)
194 try { 183 try {
195 await updateApi(payload) 184 await updateApi(payload)
196 uni.showToast({ title: '保存成功', icon: 'success' }) 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 } catch (e) { 187 } catch (e) {
199 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' }) 188 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' })
200 } 189 }
@@ -203,10 +192,10 @@ export default { @@ -203,10 +192,10 @@ export default {
203 const list = Array.isArray(data) ? data : [] 192 const list = Array.isArray(data) ? data : []
204 this.form.purchaseOrderLineList = list 193 this.form.purchaseOrderLineList = list
205 const sum = list.reduce((acc, it) => { 194 const sum = list.reduce((acc, it) => {
206 - const v = Number(it && it.quantity) 195 + const v = Number(it && it.revokeQuantity)
207 return acc + (isNaN(v) ? 0 : v) 196 return acc + (isNaN(v) ? 0 : v)
208 }, 0) 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,7 +210,7 @@ export default {
221 210
222 .scroll { 211 .scroll {
223 flex: 1; 212 flex: 1;
224 - padding: 6rpx 0 310rpx; 213 + padding: 6rpx 0 350rpx;
225 } 214 }
226 215
227 216