Commit 6fc8c1d226b353cbbd4887779c736192af920b5a

Authored by gesilong
2 parents 03ffa657 e8727abc

Merge branch 'cjerp-contract-1.0' into test_cjerp

... ... @@ -76,7 +76,7 @@
76 76 </uni-list-item>
77 77 <uni-list-item title="物料编码">
78 78 <template v-slot:footer>
79   - <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" :clearable="false" disabled />
  79 + <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" :clearable="false" />
80 80 </template>
81 81 </uni-list-item>
82 82 <uni-list-item title="状态">
... ... @@ -136,6 +136,26 @@
136 136 </uni-list-item>
137 137
138 138 </uni-list>
  139 +
  140 + </view>
  141 + <view style="margin-top: 20rpx;">
  142 + <uni-list>
  143 + <uni-list-item
  144 + class="select-item"
  145 + :class="form.changeReason ? 'is-filled' : 'is-empty'"
  146 + clickable
  147 + @click="openSheet('changeReason')"
  148 + :rightText="form.changeReasonName || '请选择'"
  149 + showArrow
  150 + >
  151 + <template v-slot:body>
  152 + <view class="item-title">
  153 + <text v-if="isChangeReasonRequired" class="required">*</text>
  154 + <text>变更原因</text>
  155 + </view>
  156 + </template>
  157 + </uni-list-item>
  158 + </uni-list>
139 159 </view>
140 160 <view class="footer">
141 161 <div class="total">
... ... @@ -172,21 +192,30 @@
172 192 </view>
173 193 </scroll-view>
174 194
175   -
  195 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onSheetConfirm" />
176 196 </view>
177 197 </template>
178 198
179 199 <script>
180 200 import { getContractApi, priceLock } from '@/api/contract'
181 201 import { formatCurrencyToChinese } from '@/utils/common'
  202 +import SingleSelectSheet from '@/components/single-select/index.vue'
  203 +import { getDicByCodes } from '@/utils/dic'
182 204
183 205 export default {
184 206 name: 'ContractUnplanLock',
  207 + components: { SingleSelectSheet },
185 208 data() {
186 209 return {
187 210 id: '',
188 211 items: [],
189 212 planQty: 30,
  213 + form: {
  214 + changeReason: '',
  215 + changeReasonName: '',
  216 + },
  217 + sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
  218 + changeReasonOptions: []
190 219 }
191 220 },
192 221 computed: {
... ... @@ -222,14 +251,35 @@ export default {
222 251 totalQtyDisplay() {
223 252 const qty = this.round(this.items.reduce((p, c) => p + this.toNumber(c.quantity), 0), 3)
224 253 return `${qty}t/${this.planQty}t`
  254 + },
  255 + isChangeReasonRequired() {
  256 + return this.items.some(it => it && it.locked && this.normalizeDate(it.deliveryDate) !== this.normalizeDate(it.originalDeliveryDate))
225 257 }
226 258 },
227 259 onLoad(options) {
228 260 const id = options && options.id ? options.id : ''
229 261 this.id = id
  262 + this.loadChangeReasonOptions()
230 263 this.loadDetail()
231 264 },
232 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 + },
233 283 normalizeDate(val) {
234 284 if (!val) return ''
235 285 const s = String(val)
... ... @@ -255,6 +305,7 @@ export default {
255 305 try {
256 306 const res = await getContractApi(this.id)
257 307 const data = res && res.data ? res.data : {}
  308 + this.form.changeReason = data.changeReason || this.form.changeReason || ''
258 309 const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : []
259 310 const init = lines.map(v => ({
260 311 locked: true,
... ... @@ -280,10 +331,15 @@ export default {
280 331 // amountExcludingTax: v.amountExcludingTax || 0,
281 332 totalAmount: v.totalAmount || 0,
282 333 deliveryDate: this.normalizeDate(v.deliveryDate),
  334 + originalDeliveryDate: this.normalizeDate(v.deliveryDate),
283 335 specDisplay: ''
284 336 }))
285 337 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
286 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 + }
287 343 } catch (e) {
288 344 this.items = []
289 345 }
... ... @@ -359,6 +415,23 @@ export default {
359 415 // amountExcludingTax: 0
360 416 }))
361 417 },
  418 + openSheet(field) {
  419 + if (field === 'changeReason') {
  420 + const options = this.changeReasonOptions || []
  421 + const current = this.form.changeReason
  422 + const match = options.find(o => String(o.value) === String(current))
  423 + this.sheet = { ...this.sheet, visible: true, title: '变更原因', options, field, value: match ? match.value : '' }
  424 + }
  425 + },
  426 + onSheetConfirm(e) {
  427 + const field = this.sheet.field
  428 + if (field === 'changeReason') {
  429 + const val = e && e.value != null ? e.value : ''
  430 + const label = e && e.label != null ? e.label : ''
  431 + this.form.changeReason = val
  432 + this.form.changeReasonName = label
  433 + }
  434 + },
362 435 async onSubmit() {
363 436 const selected = this.items.filter(it => it.locked).map(it => {
364 437 const raw = { ...(it.raw || {}) }
... ... @@ -371,6 +444,7 @@ export default {
371 444 raw.unitPrice = price
372 445 raw.totalAmount = total
373 446 raw.deliveryDate = it.deliveryDate
  447 + raw.materialCode = it.materialCode
374 448 // raw.amountExcludingTax = excl
375 449 return raw
376 450 })
... ... @@ -391,6 +465,10 @@ export default {
391 465 uni.showToast({ title: '发货日期不得早于今日', icon: 'none' })
392 466 return
393 467 }
  468 + if (this.isChangeReasonRequired && !this.form.changeReason) {
  469 + uni.showToast({ title: '发货日期已变更,请选择变更原因', icon: 'none' })
  470 + return
  471 + }
394 472 this.selectedItems = selected
395 473 const payload = {
396 474 id: this.id,
... ... @@ -399,6 +477,7 @@ export default {
399 477 totalAmountIncludingTax: this.totalAmountIncludingTax,
400 478 totalQuantity: this.totalQuantity,
401 479 type: 'INTL_INVENTORY_AGMT',
  480 + changeReason: this.form.changeReason,
402 481 contractDistributorLineList: selected
403 482 }
404 483
... ... @@ -676,7 +755,9 @@ export default {
676 755 padding: 24rpx;
677 756 margin: 0 32rpx 20rpx;
678 757 }
679   -
  758 +::v-deep .uni-list--border-top {
  759 + display: none;
  760 +}
680 761 .row {
681 762 display: flex;
682 763 margin-bottom: 16rpx;
... ...
... ... @@ -205,6 +205,14 @@
205 205 ¥{{ (totalAmountIncludingTax || 0).toFixed(2) }}
206 206 </div>
207 207 </div>
  208 + <div class="total-item">
  209 + <div class="total-item-text">
  210 + 剩余锁规数量
  211 + </div>
  212 + <div class="total-item-price text-red">
  213 + {{ (remainingQuantity || 0).toFixed(2) }}
  214 + </div>
  215 + </div>
208 216 </div>
209 217 <button class="btn submit" type="primary" @click="onSubmit">提交</button>
210 218 </view>
... ... @@ -228,6 +236,7 @@ export default {
228 236 id: '',
229 237 items: [],
230 238 planQty: 30,
  239 + remainingQuantity: 0,
231 240 sheet: { visible: false, title: '请选择', options: [], idx: -1, value: '', mode: '' },
232 241 options: [],
233 242 qualityForm: {
... ... @@ -325,6 +334,7 @@ export default {
325 334 try {
326 335 const res = await getContractApi(this.id)
327 336 const data = res && res.data ? res.data : {}
  337 + this.remainingQuantity = this.toNumber(data.remainingQuantity)
328 338 this.qualityForm = {
329 339 pieceWeightHead: data.pieceWeightHead || '',
330 340 surface: data.surface || '',
... ...
... ... @@ -71,7 +71,7 @@
71 71 </uni-list-item>
72 72 <uni-list-item title="物料编码">
73 73 <template v-slot:footer>
74   - <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" :clearable="false" disabled />
  74 + <uni-easyinput v-model="item.materialCode" placeholder="请输入物料编码" :clearable="false" />
75 75 </template>
76 76 </uni-list-item>
77 77 <uni-list-item title="状态">
... ... @@ -122,7 +122,26 @@
122 122 <uni-easyinput v-model="item.brand" placeholder="请输入牌号" :clearable="false" disabled />
123 123 </template>
124 124 </uni-list-item>
125   -
  125 + </uni-list>
  126 +
  127 + </view>
  128 + <view style="margin-top: 20rpx;">
  129 + <uni-list>
  130 + <uni-list-item
  131 + class="select-item"
  132 + :class="form.changeReason ? 'is-filled' : 'is-empty'"
  133 + clickable
  134 + @click="openSheet('changeReason')"
  135 + :rightText="form.changeReasonName || '请选择'"
  136 + showArrow
  137 + >
  138 + <template v-slot:body>
  139 + <view class="item-title">
  140 + <text v-if="isChangeReasonRequired" class="required">*</text>
  141 + <text>变更原因</text>
  142 + </view>
  143 + </template>
  144 + </uni-list-item>
126 145 </uni-list>
127 146 </view>
128 147 <view class="footer">
... ... @@ -160,20 +179,30 @@
160 179 </view>
161 180 </scroll-view>
162 181
  182 + <SingleSelectSheet :visible.sync="sheet.visible" :title="sheet.title" :options="sheet.options" v-model="sheet.value" @confirm="onSheetConfirm" />
163 183 </view>
164 184 </template>
165 185
166 186 <script>
167 187 import { getContractApi, priceLock } from '@/api/contract'
168 188 import { formatCurrencyToChinese } from '@/utils/common'
  189 +import SingleSelectSheet from '@/components/single-select/index.vue'
  190 +import { getDicByCodes } from '@/utils/dic'
169 191
170 192 export default {
171 193 name: 'ContractUnplanLock',
  194 + components: { SingleSelectSheet },
172 195 data() {
173 196 return {
174 197 id: '',
175 198 items: [],
176 199 planQty: 30,
  200 + form: {
  201 + changeReason: '',
  202 + changeReasonName: '',
  203 + },
  204 + sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
  205 + changeReasonOptions: []
177 206 }
178 207 },
179 208 computed: {
... ... @@ -209,14 +238,35 @@ export default {
209 238 totalQtyDisplay() {
210 239 const qty = this.round(this.items.reduce((p, c) => p + this.toNumber(c.quantity), 0), 3)
211 240 return `${qty}t/${this.planQty}t`
  241 + },
  242 + isChangeReasonRequired() {
  243 + return this.items.some(it => it && it.locked && this.normalizeDate(it.deliveryDate) !== this.normalizeDate(it.originalDeliveryDate))
212 244 }
213 245 },
214 246 onLoad(options) {
215 247 const id = options && options.id ? options.id : ''
216 248 this.id = id
  249 + this.loadChangeReasonOptions()
217 250 this.loadDetail()
218 251 },
219 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 + },
220 270 normalizeDate(val) {
221 271 if (!val) return ''
222 272 const s = String(val)
... ... @@ -242,6 +292,7 @@ export default {
242 292 try {
243 293 const res = await getContractApi(this.id)
244 294 const data = res && res.data ? res.data : {}
  295 + this.form.changeReason = data.changeReason || this.form.changeReason || ''
245 296 const lines = Array.isArray(data.contractDistributorLineList) ? data.contractDistributorLineList : []
246 297 const init = lines.map(v => ({
247 298 locked: true,
... ... @@ -267,10 +318,15 @@ export default {
267 318 amountExcludingTax: v.amountExcludingTax || 0,
268 319 totalAmount: v.totalAmount || 0,
269 320 deliveryDate: this.normalizeDate(v.deliveryDate),
  321 + originalDeliveryDate: this.normalizeDate(v.deliveryDate),
270 322 specDisplay: ''
271 323 }))
272 324 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
273 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 + }
274 330 } catch (e) {
275 331 this.items = []
276 332 }
... ... @@ -346,6 +402,23 @@ export default {
346 402 amountExcludingTax: 0
347 403 }))
348 404 },
  405 + openSheet(field) {
  406 + if (field === 'changeReason') {
  407 + const options = this.changeReasonOptions || []
  408 + const current = this.form.changeReason
  409 + const match = options.find(o => String(o.value) === String(current))
  410 + this.sheet = { ...this.sheet, visible: true, title: '变更原因', options, field, value: match ? match.value : '' }
  411 + }
  412 + },
  413 + onSheetConfirm(e) {
  414 + const field = this.sheet.field
  415 + if (field === 'changeReason') {
  416 + const val = e && e.value != null ? e.value : ''
  417 + const label = e && e.label != null ? e.label : ''
  418 + this.form.changeReason = val
  419 + this.form.changeReasonName = label
  420 + }
  421 + },
349 422 async onSubmit() {
350 423 const selected = this.items.filter(it => it.locked).map(it => {
351 424 const raw = { ...(it.raw || {}) }
... ... @@ -359,6 +432,7 @@ export default {
359 432 raw.totalAmount = total
360 433 raw.amountExcludingTax = excl
361 434 raw.deliveryDate = it.deliveryDate
  435 + raw.materialCode = it.materialCode
362 436 return raw
363 437 })
364 438 if (!selected.length) {
... ... @@ -378,6 +452,10 @@ export default {
378 452 uni.showToast({ title: '发货日期不得早于今日', icon: 'none' })
379 453 return
380 454 }
  455 + if (this.isChangeReasonRequired && !this.form.changeReason) {
  456 + uni.showToast({ title: '发货日期已变更,请选择变更原因', icon: 'none' })
  457 + return
  458 + }
381 459 this.selectedItems = selected
382 460 const payload = {
383 461 id: this.id,
... ... @@ -386,6 +464,7 @@ export default {
386 464 totalAmountIncludingTax: this.totalAmountIncludingTax,
387 465 totalQuantity: this.totalQuantity,
388 466 type:'DIST_STOCK_CONTRACT',
  467 + changeReason: this.form.changeReason,
389 468 contractDistributorLineList: selected
390 469 }
391 470
... ... @@ -599,7 +678,9 @@ export default {
599 678 // ::v-deep .uni-list-item__extra-text {
600 679 // font-size: 32rpx;
601 680 // }
602   -
  681 +::v-deep .uni-list--border-top {
  682 + display: none;
  683 +}
603 684 ::v-deep .uni-easyinput {
604 685 width: 100%;
605 686 }
... ...
... ... @@ -205,6 +205,14 @@
205 205 ¥{{ (totalAmountIncludingTax || 0).toFixed(2) }}
206 206 </div>
207 207 </div>
  208 + <div class="total-item">
  209 + <div class="total-item-text">
  210 + 剩余锁规数量
  211 + </div>
  212 + <div class="total-item-price text-red">
  213 + {{ (remainingQuantity || 0).toFixed(2) }}
  214 + </div>
  215 + </div>
208 216 </div>
209 217 <button class="btn submit" type="primary" @click="onSubmit">提交</button>
210 218 </view>
... ... @@ -228,6 +236,7 @@ export default {
228 236 id: '',
229 237 items: [],
230 238 planQty: 30,
  239 + remainingQuantity: 0,
231 240 sheet: { visible: false, title: '请选择', options: [], idx: -1, value: '', mode: '' },
232 241 options: [],
233 242 qualityForm: {
... ... @@ -341,6 +350,7 @@ export default {
341 350 try {
342 351 const res = await getContractApi(this.id)
343 352 const data = res && res.data ? res.data : {}
  353 + this.remainingQuantity = this.toNumber(data.remainingQuantity)
344 354 this.qualityForm = {
345 355 pieceWeightHead: data.pieceWeightHead || '',
346 356 surface: data.surface || '',
... ...
... ... @@ -57,7 +57,8 @@
57 57 </uni-list-item>
58 58 <uni-list-item title="职务">
59 59 <template v-slot:footer>
60   - <uni-easyinput v-model="item.position" :inputBorder="false" placeholder="请输入职务" />
  60 + <uni-easyinput v-model="item.position" :disabled="idx === 0" :inputBorder="false"
  61 + placeholder="请输入职务" />
61 62 </template>
62 63 </uni-list-item>
63 64 <uni-list-item title="手机">
... ... @@ -128,6 +129,7 @@
128 129 <script>
129 130 import SingleSelectSheet from '@/components/single-select/index.vue'
130 131 import { uuid } from '@/utils/uuid.js'
  132 +const LEGAL_POSITION = '法定代表人'
131 133 export default {
132 134 name: 'CorePersonnel',
133 135 props: {
... ... @@ -168,6 +170,7 @@ export default {
168 170 it.sexName = m ? (m.label || '') : it.sexName
169 171 return it
170 172 })
  173 + this.enforceFirstPosition()
171 174 },
172 175 deep: true
173 176 },
... ... @@ -178,8 +181,17 @@ export default {
178 181 created() {
179 182 const init = Array.isArray(this.list) && this.list.length > 0 ? this.list.map(v => ({ ...this.defaultItem(), ...v, collapsed: false })) : [{ ...this.defaultItem(), collapsed: false }]
180 183 this.items = init
  184 + this.enforceFirstPosition()
181 185 },
182 186 methods: {
  187 + enforceFirstPosition() {
  188 + if (this.mode === 'history') return
  189 + if (!Array.isArray(this.items) || this.items.length === 0) return
  190 + const first = this.items[0]
  191 + if (!first) return
  192 + if (first.position === LEGAL_POSITION) return
  193 + this.$set(this.items, 0, { ...first, position: LEGAL_POSITION })
  194 + },
183 195 defaultItem() {
184 196 return { personId: uuid(), name: '', sex: '', sexName: '', nativePlace: '', age: '', position: '', mobile: '', phone: '', email: '', address: '', collapsed: false }
185 197 },
... ... @@ -216,6 +228,7 @@ export default {
216 228 const obj = this.defaultItem()
217 229 obj.collapsed = true
218 230 this.items.push(obj)
  231 + this.enforceFirstPosition()
219 232 this.emitChange()
220 233 },
221 234 onRemove(id) {
... ... @@ -230,6 +243,7 @@ export default {
230 243 const i = this.items.findIndex(it => String(it.personId) === String(id))
231 244 if (i >= 0) {
232 245 this.items.splice(i, 1)
  246 + this.enforceFirstPosition()
233 247 this.emitChange()
234 248 }
235 249 }
... ... @@ -333,7 +347,9 @@ export default {
333 347
334 348 ::v-deep .uni-list {
335 349 background: transparent;
336   -
  350 + .uni-input-input:disabled {
  351 + color: rgb(51, 51, 51) !important;
  352 + }
337 353 &-item {
338 354 &__container {
339 355 padding: 32rpx;
... ...