Showing
2 changed files
with
50 additions
and
12 deletions
| ... | ... | @@ -200,6 +200,7 @@ |
| 200 | 200 | import { getContractApi, priceLock } from '@/api/contract' |
| 201 | 201 | import { formatCurrencyToChinese } from '@/utils/common' |
| 202 | 202 | import SingleSelectSheet from '@/components/single-select/index.vue' |
| 203 | +import { getDicByCodes } from '@/utils/dic' | |
| 203 | 204 | |
| 204 | 205 | export default { |
| 205 | 206 | name: 'ContractUnplanLock', |
| ... | ... | @@ -214,12 +215,7 @@ export default { |
| 214 | 215 | changeReasonName: '', |
| 215 | 216 | }, |
| 216 | 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 | 221 | computed: { |
| ... | ... | @@ -263,9 +259,27 @@ export default { |
| 263 | 259 | onLoad(options) { |
| 264 | 260 | const id = options && options.id ? options.id : '' |
| 265 | 261 | this.id = id |
| 262 | + this.loadChangeReasonOptions() | |
| 266 | 263 | this.loadDetail() |
| 267 | 264 | }, |
| 268 | 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 | 283 | normalizeDate(val) { |
| 270 | 284 | if (!val) return '' |
| 271 | 285 | const s = String(val) |
| ... | ... | @@ -291,6 +305,7 @@ export default { |
| 291 | 305 | try { |
| 292 | 306 | const res = await getContractApi(this.id) |
| 293 | 307 | const data = res && res.data ? res.data : {} |
| 308 | + this.form.changeReason = data.changeReason || this.form.changeReason || '' | |
| 294 | 309 | const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : [] |
| 295 | 310 | const init = lines.map(v => ({ |
| 296 | 311 | locked: true, |
| ... | ... | @@ -321,6 +336,10 @@ export default { |
| 321 | 336 | })) |
| 322 | 337 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) |
| 323 | 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 | 343 | } catch (e) { |
| 325 | 344 | this.items = [] |
| 326 | 345 | } | ... | ... |
| ... | ... | @@ -187,6 +187,7 @@ |
| 187 | 187 | import { getContractApi, priceLock } from '@/api/contract' |
| 188 | 188 | import { formatCurrencyToChinese } from '@/utils/common' |
| 189 | 189 | import SingleSelectSheet from '@/components/single-select/index.vue' |
| 190 | +import { getDicByCodes } from '@/utils/dic' | |
| 190 | 191 | |
| 191 | 192 | export default { |
| 192 | 193 | name: 'ContractUnplanLock', |
| ... | ... | @@ -201,12 +202,7 @@ export default { |
| 201 | 202 | changeReasonName: '', |
| 202 | 203 | }, |
| 203 | 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 | 208 | computed: { |
| ... | ... | @@ -250,9 +246,27 @@ export default { |
| 250 | 246 | onLoad(options) { |
| 251 | 247 | const id = options && options.id ? options.id : '' |
| 252 | 248 | this.id = id |
| 249 | + this.loadChangeReasonOptions() | |
| 253 | 250 | this.loadDetail() |
| 254 | 251 | }, |
| 255 | 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 | 270 | normalizeDate(val) { |
| 257 | 271 | if (!val) return '' |
| 258 | 272 | const s = String(val) |
| ... | ... | @@ -278,6 +292,7 @@ export default { |
| 278 | 292 | try { |
| 279 | 293 | const res = await getContractApi(this.id) |
| 280 | 294 | const data = res && res.data ? res.data : {} |
| 295 | + this.form.changeReason = data.changeReason || this.form.changeReason || '' | |
| 281 | 296 | const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : [] |
| 282 | 297 | const init = lines.map(v => ({ |
| 283 | 298 | locked: true, |
| ... | ... | @@ -308,6 +323,10 @@ export default { |
| 308 | 323 | })) |
| 309 | 324 | this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) })) |
| 310 | 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 | 330 | } catch (e) { |
| 312 | 331 | this.items = [] |
| 313 | 332 | } | ... | ... |