Commit b90075415c0eec596407207ef3cd91748d4d3031

Authored by 史婷婷
1 parent ed3f4659

feat: 规格变更单新增&编辑 + 订货单编辑-增加产品字段校验

@@ -321,8 +321,35 @@ export default { @@ -321,8 +321,35 @@ export default {
321 } 321 }
322 return true 322 return true
323 }, 323 },
  324 + validateLineListRequired() {
  325 + const list = Array.isArray(this.form.purchaseOrderLineList) ? this.form.purchaseOrderLineList : []
  326 + if (list.length === 0) {
  327 + uni.showToast({ title: '请先添加产品', icon: 'none' })
  328 + return false
  329 + }
  330 + 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: '发货日期' },
  337 + ]
  338 + for (let i = 0; i < list.length; i++) {
  339 + const it = list[i] || {}
  340 + for (const f of fields) {
  341 + const v = it && it[f.key]
  342 + if (v === undefined || v === null || String(v).trim() === '') {
  343 + uni.showToast({ title: `产品第${i + 1}条:${f.label}不能为空!`, icon: 'none' })
  344 + return false
  345 + }
  346 + }
  347 + }
  348 + return true
  349 + },
324 async onSubmit() { 350 async onSubmit() {
325 if (!this.validateRequired()) return 351 if (!this.validateRequired()) return
  352 + if (!this.validateLineListRequired()) return
326 const payload = { ...this.form } 353 const payload = { ...this.form }
327 payload.orderSpecList = payload.purchaseOrderLineList || []; 354 payload.orderSpecList = payload.purchaseOrderLineList || [];
328 delete payload.purchaseOrderLineList; 355 delete payload.purchaseOrderLineList;
@@ -242,16 +242,42 @@ export default { @@ -242,16 +242,42 @@ export default {
242 this.sheet.visible = false 242 this.sheet.visible = false
243 }, 243 },
244 getDicName: getDicName, 244 getDicName: getDicName,
  245 + validateLineListRequired() {
  246 + const list = Array.isArray(this.form.purchaseOrderLineList) ? this.form.purchaseOrderLineList : []
  247 + if (list.length === 0) {
  248 + uni.showToast({ title: '请先添加产品', icon: 'none' })
  249 + return false
  250 + }
  251 + const fields = [
  252 + { key: 'industry', label: '行业' },
  253 + { key: 'quality', label: '品质' },
  254 + { key: 'brand', label: '牌号' },
  255 + { key: 'quantity', label: '数量' },
  256 + { key: 'salesPrice', label: '销售价格' },
  257 + { key: 'deliveryDate', label: '发货日期' },
  258 + ]
  259 + for (let i = 0; i < list.length; i++) {
  260 + const it = list[i] || {}
  261 + for (const f of fields) {
  262 + const v = it && it[f.key]
  263 + if (v === undefined || v === null || String(v).trim() === '') {
  264 + uni.showToast({ title: `产品第${i + 1}条:${f.label}不能为空!`, icon: 'none' })
  265 + return false
  266 + }
  267 + }
  268 + }
  269 + return true
  270 + },
245 async onSubmit() { 271 async onSubmit() {
  272 + if (!this.validateLineListRequired()) return
246 const payload = { ...this.form } 273 const payload = { ...this.form }
247 payload.orderSpecList = payload.purchaseOrderLineList || []; 274 payload.orderSpecList = payload.purchaseOrderLineList || [];
248 delete payload.purchaseOrderLineList 275 delete payload.purchaseOrderLineList
249 console.log('onSubmit__payload', payload) 276 console.log('onSubmit__payload', payload)
250 - return  
251 try { 277 try {
252 await updateApi(payload) 278 await updateApi(payload)
253 uni.showToast({ title: '保存成功', icon: 'success' }) 279 uni.showToast({ title: '保存成功', icon: 'success' })
254 - setTimeout(() => { uni.redirectTo({ url: '/pages/order_list/index' }) }, 300) 280 + setTimeout(() => { uni.redirectTo({ url: '/pages/change_list/index' }) }, 300)
255 } catch (e) { 281 } catch (e) {
256 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' }) 282 uni.showToast({ title: (e && e.msg) || '保存失败', icon: 'none' })
257 } 283 }
@@ -252,7 +252,7 @@ export default { @@ -252,7 +252,7 @@ export default {
252 const it = list[i] || {} 252 const it = list[i] || {}
253 const v = it && it.deliveryDate 253 const v = it && it.deliveryDate
254 if (v === undefined || v === null || String(v).trim() === '') { 254 if (v === undefined || v === null || String(v).trim() === '') {
255 - uni.showToast({ title: `第${i + 1}条:发货日期不能为空`, icon: 'none' }) 255 + uni.showToast({ title: `产品第${i + 1}条:发货日期不能为空`, icon: 'none' })
256 return false 256 return false
257 } 257 }
258 } 258 }