Commit e8727abc34de3db64fc7a8340df6d8f95d32ec1e

Authored by gesilong
1 parent 538b01b3

commit: 锁价联调

@@ -200,6 +200,7 @@ @@ -200,6 +200,7 @@
200 import { getContractApi, priceLock } from '@/api/contract' 200 import { getContractApi, priceLock } from '@/api/contract'
201 import { formatCurrencyToChinese } from '@/utils/common' 201 import { formatCurrencyToChinese } from '@/utils/common'
202 import SingleSelectSheet from '@/components/single-select/index.vue' 202 import SingleSelectSheet from '@/components/single-select/index.vue'
  203 +import { getDicByCodes } from '@/utils/dic'
203 204
204 export default { 205 export default {
205 name: 'ContractUnplanLock', 206 name: 'ContractUnplanLock',
@@ -214,12 +215,7 @@ export default { @@ -214,12 +215,7 @@ export default {
214 changeReasonName: '', 215 changeReasonName: '',
215 }, 216 },
216 sheet: { visible: false, title: '请选择', options: [], value: '', field: '' }, 217 sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
217 - changeReasonOptions: [  
218 - { label: '客户要求', value: '客户要求' },  
219 - { label: '订单调整', value: '订单调整' },  
220 - { label: '生产计划调整', value: '生产计划调整' },  
221 - { label: '其他', value: '其他' }  
222 - ] 218 + changeReasonOptions: []
223 } 219 }
224 }, 220 },
225 computed: { 221 computed: {
@@ -263,9 +259,27 @@ export default { @@ -263,9 +259,27 @@ export default {
263 onLoad(options) { 259 onLoad(options) {
264 const id = options && options.id ? options.id : '' 260 const id = options && options.id ? options.id : ''
265 this.id = id 261 this.id = id
  262 + this.loadChangeReasonOptions()
266 this.loadDetail() 263 this.loadDetail()
267 }, 264 },
268 methods: { 265 methods: {
  266 + async loadChangeReasonOptions() {
  267 + try {
  268 + const results = await getDicByCodes(['CHANGE_REASON'])
  269 + const list = results && results.CHANGE_REASON && results.CHANGE_REASON.data ? results.CHANGE_REASON.data : []
  270 + this.changeReasonOptions = (list || []).map(it => ({
  271 + label: it.name != null ? String(it.name) : '',
  272 + value: it.code != null ? String(it.code) : ''
  273 + })).filter(it => it.label && it.value)
  274 + const current = this.form && this.form.changeReason ? String(this.form.changeReason) : ''
  275 + if (current) {
  276 + const match = (this.changeReasonOptions || []).find(o => String(o.value) === String(current))
  277 + this.form.changeReasonName = match ? match.label : (this.form.changeReasonName || '')
  278 + }
  279 + } catch (e) {
  280 + this.changeReasonOptions = []
  281 + }
  282 + },
269 normalizeDate(val) { 283 normalizeDate(val) {
270 if (!val) return '' 284 if (!val) return ''
271 const s = String(val) 285 const s = String(val)
@@ -291,6 +305,7 @@ export default { @@ -291,6 +305,7 @@ export default {
291 try { 305 try {
292 const res = await getContractApi(this.id) 306 const res = await getContractApi(this.id)
293 const data = res && res.data ? res.data : {} 307 const data = res && res.data ? res.data : {}
  308 + this.form.changeReason = data.changeReason || this.form.changeReason || ''
294 const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : [] 309 const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : []
295 const init = lines.map(v => ({ 310 const init = lines.map(v => ({
296 locked: true, 311 locked: true,
@@ -321,6 +336,10 @@ export default { @@ -321,6 +336,10 @@ export default {
321 })) 336 }))
322 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) 337 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
323 this.recalculateAll() 338 this.recalculateAll()
  339 + if (this.form.changeReason) {
  340 + const match = (this.changeReasonOptions || []).find(o => String(o.value) === String(this.form.changeReason))
  341 + this.form.changeReasonName = match ? match.label : (this.form.changeReasonName || '')
  342 + }
324 } catch (e) { 343 } catch (e) {
325 this.items = [] 344 this.items = []
326 } 345 }
@@ -187,6 +187,7 @@ @@ -187,6 +187,7 @@
187 import { getContractApi, priceLock } from '@/api/contract' 187 import { getContractApi, priceLock } from '@/api/contract'
188 import { formatCurrencyToChinese } from '@/utils/common' 188 import { formatCurrencyToChinese } from '@/utils/common'
189 import SingleSelectSheet from '@/components/single-select/index.vue' 189 import SingleSelectSheet from '@/components/single-select/index.vue'
  190 +import { getDicByCodes } from '@/utils/dic'
190 191
191 export default { 192 export default {
192 name: 'ContractUnplanLock', 193 name: 'ContractUnplanLock',
@@ -201,12 +202,7 @@ export default { @@ -201,12 +202,7 @@ export default {
201 changeReasonName: '', 202 changeReasonName: '',
202 }, 203 },
203 sheet: { visible: false, title: '请选择', options: [], value: '', field: '' }, 204 sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
204 - changeReasonOptions: [  
205 - { label: '客户要求', value: '客户要求' },  
206 - { label: '订单调整', value: '订单调整' },  
207 - { label: '生产计划调整', value: '生产计划调整' },  
208 - { label: '其他', value: '其他' }  
209 - ] 205 + changeReasonOptions: []
210 } 206 }
211 }, 207 },
212 computed: { 208 computed: {
@@ -250,9 +246,27 @@ export default { @@ -250,9 +246,27 @@ export default {
250 onLoad(options) { 246 onLoad(options) {
251 const id = options && options.id ? options.id : '' 247 const id = options && options.id ? options.id : ''
252 this.id = id 248 this.id = id
  249 + this.loadChangeReasonOptions()
253 this.loadDetail() 250 this.loadDetail()
254 }, 251 },
255 methods: { 252 methods: {
  253 + async loadChangeReasonOptions() {
  254 + try {
  255 + const results = await getDicByCodes(['CHANGE_REASON'])
  256 + const list = results && results.CHANGE_REASON && results.CHANGE_REASON.data ? results.CHANGE_REASON.data : []
  257 + this.changeReasonOptions = (list || []).map(it => ({
  258 + label: it.name != null ? String(it.name) : '',
  259 + value: it.code != null ? String(it.code) : ''
  260 + })).filter(it => it.label && it.value)
  261 + const current = this.form && this.form.changeReason ? String(this.form.changeReason) : ''
  262 + if (current) {
  263 + const match = (this.changeReasonOptions || []).find(o => String(o.value) === String(current))
  264 + this.form.changeReasonName = match ? match.label : (this.form.changeReasonName || '')
  265 + }
  266 + } catch (e) {
  267 + this.changeReasonOptions = []
  268 + }
  269 + },
256 normalizeDate(val) { 270 normalizeDate(val) {
257 if (!val) return '' 271 if (!val) return ''
258 const s = String(val) 272 const s = String(val)
@@ -278,6 +292,7 @@ export default { @@ -278,6 +292,7 @@ export default {
278 try { 292 try {
279 const res = await getContractApi(this.id) 293 const res = await getContractApi(this.id)
280 const data = res && res.data ? res.data : {} 294 const data = res && res.data ? res.data : {}
  295 + this.form.changeReason = data.changeReason || this.form.changeReason || ''
281 const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : [] 296 const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : []
282 const init = lines.map(v => ({ 297 const init = lines.map(v => ({
283 locked: true, 298 locked: true,
@@ -308,6 +323,10 @@ export default { @@ -308,6 +323,10 @@ export default {
308 })) 323 }))
309 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) 324 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
310 this.recalculateAll() 325 this.recalculateAll()
  326 + if (this.form.changeReason) {
  327 + const match = (this.changeReasonOptions || []).find(o => String(o.value) === String(this.form.changeReason))
  328 + this.form.changeReasonName = match ? match.label : (this.form.changeReasonName || '')
  329 + }
311 } catch (e) { 330 } catch (e) {
312 this.items = [] 331 this.items = []
313 } 332 }