Commit 15542ca9e4139c421bc24c8633b42959f7fcf8a5

Authored by gesilong
1 parent ba727ac7

commit:修复bug

@@ -244,7 +244,7 @@ export default { @@ -244,7 +244,7 @@ export default {
244 }, 244 },
245 list: { 245 list: {
246 handler(v) { 246 handler(v) {
247 - if (this._emitSuppressed) return 247 + // 始终以最新 props 重建 items,仅抑制 emit,避免跳过初始化导致子组件停留在旧数据
248 this._emitSuppressed = true 248 this._emitSuppressed = true
249 this._initialized = false 249 this._initialized = false
250 this.initItems() 250 this.initItems()
@@ -291,7 +291,10 @@ export default { @@ -291,7 +291,10 @@ export default {
291 return Object.assign({}, self.defaultItem(), x, { 291 return Object.assign({}, self.defaultItem(), x, {
292 _key: key, 292 _key: key,
293 itemId: x && x.itemId ? x.itemId : key, 293 itemId: x && x.itemId ? x.itemId : key,
294 - collapsed: old ? old.collapsed : true 294 + collapsed: old ? old.collapsed : true,
  295 + // 兼容服务端返回的 factoryId/factoryName/factoryName2 字段
  296 + workshopId: (x && x.workshopId != null && x.workshopId !== '') ? x.workshopId : ((x && x.factoryId != null) ? x.factoryId : ''),
  297 + workshopName: (x && x.workshopName != null && String(x.workshopName).trim() !== '') ? x.workshopName : ((x && (x.factoryName || x.factoryName2)) ? (x.factoryName || x.factoryName2) : '')
295 }) 298 })
296 }) 299 })
297 }, 300 },
@@ -474,10 +477,9 @@ export default { @@ -474,10 +477,9 @@ export default {
474 this.$set(it, 'workshopName', label) 477 this.$set(it, 'workshopName', label)
475 } 478 }
476 }, 479 },
477 - emitChange() {  
478 - if (!this._initialized) return  
479 - if (this._emitSuppressed) return  
480 - var list = (this.items || []).map(function (it) { 480 + getTableData() {
  481 + var self = this
  482 + return (this.items || []).map(function (it) {
481 var c = Object.assign({}, it) 483 var c = Object.assign({}, it)
482 var key = c._key 484 var key = c._key
483 delete c._key 485 delete c._key
@@ -485,10 +487,14 @@ export default { @@ -485,10 +487,14 @@ export default {
485 delete c._selected 487 delete c._selected
486 delete c.fixedLossRate 488 delete c.fixedLossRate
487 if (!c.itemId) c.itemId = key 489 if (!c.itemId) c.itemId = key
488 - if (!this.isAnyBuyout) c.estimatedLoss = null 490 + if (!self.isAnyBuyout) c.estimatedLoss = null
489 return c 491 return c
490 }) 492 })
491 - this.$emit('change', list) 493 + },
  494 + emitChange() {
  495 + if (!this._initialized) return
  496 + if (this._emitSuppressed) return
  497 + this.$emit('change', this.getTableData())
492 }, 498 },
493 safeText(v) { 499 safeText(v) {
494 var s = v == null ? '' : String(v) 500 var s = v == null ? '' : String(v)
@@ -311,7 +311,7 @@ export default { @@ -311,7 +311,7 @@ export default {
311 }, 311 },
312 computed: { 312 computed: {
313 isAnyBuyout() { 313 isAnyBuyout() {
314 - return this.form.commodityBuyout || this.form.qualityBuyout || this.form.quantityBuyout 314 + return this.detail.commodityBuyout || this.detail.qualityBuyout || this.detail.quantityBuyout
315 }, 315 },
316 companyNameDisplay() { 316 companyNameDisplay() {
317 var d = this.detail || {} 317 var d = this.detail || {}
@@ -395,7 +395,7 @@ export default { @@ -395,7 +395,7 @@ export default {
395 }, 395 },
396 methods: { 396 methods: {
397 handleInvoiceNameChange(name) { 397 handleInvoiceNameChange(name) {
398 - this.form.invoiceProductName = name 398 + this.detail.invoiceProductName = name
399 }, 399 },
400 toNumber(v) { 400 toNumber(v) {
401 if (v == null || v === '') return 0 401 if (v == null || v === '') return 0
@@ -470,18 +470,19 @@ export default { @@ -470,18 +470,19 @@ export default {
470 if (!this.id) return 470 if (!this.id) return
471 try { 471 try {
472 var res = await procurementPlanDetailApi({ id: this.id }) 472 var res = await procurementPlanDetailApi({ id: this.id })
473 - var d = (res && res.data) ? res.data : {} 473 + console.log(res,'6666')
  474 +
  475 + this.detail = (res && res.data) ? res.data : {}
474 var self = this 476 var self = this
475 this.materialConditionConfigs.forEach(function (mc) { 477 this.materialConditionConfigs.forEach(function (mc) {
476 - var v = d[mc.field] 478 + var v = self.detail[mc.field]
477 if (typeof v === 'string' && v) { 479 if (typeof v === 'string' && v) {
478 - d[mc.field] = v.split(',').filter(Boolean) 480 + self.detail[mc.field] = v.split(',').filter(Boolean)
479 } else if (!Array.isArray(v)) { 481 } else if (!Array.isArray(v)) {
480 - d[mc.field] = [] 482 + self.detail[mc.field] = []
481 } 483 }
482 }) 484 })
483 - this.detail = d  
484 - this.lineList = Array.isArray(d.procurementPlanLineList) ? d.procurementPlanLineList.slice() : [] 485 + this.lineList = Array.isArray(this.detail.procurementPlanLineList) ? this.detail.procurementPlanLineList.slice() : []
485 this.buildAttachmentList() 486 this.buildAttachmentList()
486 this.fillLineNames() 487 this.fillLineNames()
487 await this.fillPriceByDetailPriceId() 488 await this.fillPriceByDetailPriceId()
@@ -524,7 +525,7 @@ export default { @@ -524,7 +525,7 @@ export default {
524 this.lineList = this.lineList.map(function (row) { 525 this.lineList = this.lineList.map(function (row) {
525 var r = Object.assign({}, row) 526 var r = Object.assign({}, row)
526 var pid = r.productId != null ? String(r.productId) : '' 527 var pid = r.productId != null ? String(r.productId) : ''
527 - var wid = r.workshopId != null ? String(r.workshopId) : '' 528 + var wid = (r.workshopId != null && r.workshopId !== '') ? String(r.workshopId) : (r.factoryId != null ? String(r.factoryId) : '')
528 if ((r.productName == null || String(r.productName).trim() === '') && pid) { 529 if ((r.productName == null || String(r.productName).trim() === '') && pid) {
529 var p = pOpts.find(function (o) { 530 var p = pOpts.find(function (o) {
530 var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : '')) 531 var id = o.id != null ? String(o.id) : (o.productId != null ? String(o.productId) : (o.value != null ? String(o.value) : ''))
@@ -534,7 +535,17 @@ export default { @@ -534,7 +535,17 @@ export default {
534 r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : '')) 535 r.productName = p.name != null ? p.name : (p.productName != null ? p.productName : (p.label != null ? p.label : ''))
535 } 536 }
536 } 537 }
537 - if ((r.workshopName == null || String(r.workshopName).trim() === '') && wid) { 538 + var wName = ''
  539 + if (r.workshopName != null && String(r.workshopName).trim() !== '') {
  540 + wName = r.workshopName
  541 + } else if (r.factoryName != null && String(r.factoryName).trim() !== '') {
  542 + wName = r.factoryName
  543 + } else if (r.factoryName2 != null && String(r.factoryName2).trim() !== '') {
  544 + wName = r.factoryName2
  545 + }
  546 + if (wName) {
  547 + r.workshopName = wName
  548 + } else if (wid) {
538 var w = wOpts.find(function (o) { 549 var w = wOpts.find(function (o) {
539 var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : '')) 550 var id = o.id != null ? String(o.id) : (o.workshopId != null ? String(o.workshopId) : (o.value != null ? String(o.value) : ''))
540 return id === wid 551 return id === wid
@@ -671,7 +682,9 @@ export default { @@ -671,7 +682,9 @@ export default {
671 buildPayload() { 682 buildPayload() {
672 var self = this 683 var self = this
673 var d = this.detail || {} 684 var d = this.detail || {}
674 - var lines = Array.isArray(this.lineList) ? this.lineList.slice() : [] 685 + // 与桌面端 select-factory 一致:保存时直接取子组件最新明细数据,避免 emit 同步链路丢数据
  686 + var pr = this.$refs.productRel
  687 + var lines = (pr && typeof pr.getTableData === 'function') ? pr.getTableData() : (Array.isArray(this.lineList) ? this.lineList.slice() : [])
675 var lineList = lines.map(function (row, i) { 688 var lineList = lines.map(function (row, i) {
676 var r = row || {} 689 var r = row || {}
677 var itemId = r.itemId || (r._key != null ? r._key : (r.id ? String(r.id) : ('line-' + Date.now() + '-' + i))) 690 var itemId = r.itemId || (r._key != null ? r._key : (r.id ? String(r.id) : ('line-' + Date.now() + '-' + i)))
@@ -689,7 +702,7 @@ export default { @@ -689,7 +702,7 @@ export default {
689 coordinationRange: self.toNumber(r.coordinationRange), 702 coordinationRange: self.toNumber(r.coordinationRange),
690 estimatedLoss: self.toNumber(r.estimatedLoss), 703 estimatedLoss: self.toNumber(r.estimatedLoss),
691 applicationAttrition: self.toNumber(r.applicationAttrition), 704 applicationAttrition: self.toNumber(r.applicationAttrition),
692 - workshopId: self.pickId(r.workshopId) 705 + workshopId: self.pickId(r.workshopId || r.factoryId)
693 } 706 }
694 }) 707 })
695 var mcFields = this.materialConditionConfigs.map(function (mc) { return mc.field }) 708 var mcFields = this.materialConditionConfigs.map(function (mc) { return mc.field })