Commit 538b01b32363c43dddae292f13e0afc996f5205d

Authored by gesilong
1 parent e3fbd569

commit:PC端对应的优化

... ... @@ -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,34 @@
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'
182 203
183 204 export default {
184 205 name: 'ContractUnplanLock',
  206 + components: { SingleSelectSheet },
185 207 data() {
186 208 return {
187 209 id: '',
188 210 items: [],
189 211 planQty: 30,
  212 + form: {
  213 + changeReason: '',
  214 + changeReasonName: '',
  215 + },
  216 + sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
  217 + changeReasonOptions: [
  218 + { label: '客户要求', value: '客户要求' },
  219 + { label: '订单调整', value: '订单调整' },
  220 + { label: '生产计划调整', value: '生产计划调整' },
  221 + { label: '其他', value: '其他' }
  222 + ]
190 223 }
191 224 },
192 225 computed: {
... ... @@ -222,6 +255,9 @@ export default {
222 255 totalQtyDisplay() {
223 256 const qty = this.round(this.items.reduce((p, c) => p + this.toNumber(c.quantity), 0), 3)
224 257 return `${qty}t/${this.planQty}t`
  258 + },
  259 + isChangeReasonRequired() {
  260 + return this.items.some(it => it && it.locked && this.normalizeDate(it.deliveryDate) !== this.normalizeDate(it.originalDeliveryDate))
225 261 }
226 262 },
227 263 onLoad(options) {
... ... @@ -280,6 +316,7 @@ export default {
280 316 // amountExcludingTax: v.amountExcludingTax || 0,
281 317 totalAmount: v.totalAmount || 0,
282 318 deliveryDate: this.normalizeDate(v.deliveryDate),
  319 + originalDeliveryDate: this.normalizeDate(v.deliveryDate),
283 320 specDisplay: ''
284 321 }))
285 322 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
... ... @@ -359,6 +396,23 @@ export default {
359 396 // amountExcludingTax: 0
360 397 }))
361 398 },
  399 + openSheet(field) {
  400 + if (field === 'changeReason') {
  401 + const options = this.changeReasonOptions || []
  402 + const current = this.form.changeReason
  403 + const match = options.find(o => String(o.value) === String(current))
  404 + this.sheet = { ...this.sheet, visible: true, title: '变更原因', options, field, value: match ? match.value : '' }
  405 + }
  406 + },
  407 + onSheetConfirm(e) {
  408 + const field = this.sheet.field
  409 + if (field === 'changeReason') {
  410 + const val = e && e.value != null ? e.value : ''
  411 + const label = e && e.label != null ? e.label : ''
  412 + this.form.changeReason = val
  413 + this.form.changeReasonName = label
  414 + }
  415 + },
362 416 async onSubmit() {
363 417 const selected = this.items.filter(it => it.locked).map(it => {
364 418 const raw = { ...(it.raw || {}) }
... ... @@ -371,6 +425,7 @@ export default {
371 425 raw.unitPrice = price
372 426 raw.totalAmount = total
373 427 raw.deliveryDate = it.deliveryDate
  428 + raw.materialCode = it.materialCode
374 429 // raw.amountExcludingTax = excl
375 430 return raw
376 431 })
... ... @@ -391,6 +446,10 @@ export default {
391 446 uni.showToast({ title: '发货日期不得早于今日', icon: 'none' })
392 447 return
393 448 }
  449 + if (this.isChangeReasonRequired && !this.form.changeReason) {
  450 + uni.showToast({ title: '发货日期已变更,请选择变更原因', icon: 'none' })
  451 + return
  452 + }
394 453 this.selectedItems = selected
395 454 const payload = {
396 455 id: this.id,
... ... @@ -399,6 +458,7 @@ export default {
399 458 totalAmountIncludingTax: this.totalAmountIncludingTax,
400 459 totalQuantity: this.totalQuantity,
401 460 type: 'INTL_INVENTORY_AGMT',
  461 + changeReason: this.form.changeReason,
402 462 contractDistributorLineList: selected
403 463 }
404 464
... ... @@ -676,7 +736,9 @@ export default {
676 736 padding: 24rpx;
677 737 margin: 0 32rpx 20rpx;
678 738 }
679   -
  739 +::v-deep .uni-list--border-top {
  740 + display: none;
  741 +}
680 742 .row {
681 743 display: flex;
682 744 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,34 @@
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'
169 190
170 191 export default {
171 192 name: 'ContractUnplanLock',
  193 + components: { SingleSelectSheet },
172 194 data() {
173 195 return {
174 196 id: '',
175 197 items: [],
176 198 planQty: 30,
  199 + form: {
  200 + changeReason: '',
  201 + changeReasonName: '',
  202 + },
  203 + sheet: { visible: false, title: '请选择', options: [], value: '', field: '' },
  204 + changeReasonOptions: [
  205 + { label: '客户要求', value: '客户要求' },
  206 + { label: '订单调整', value: '订单调整' },
  207 + { label: '生产计划调整', value: '生产计划调整' },
  208 + { label: '其他', value: '其他' }
  209 + ]
177 210 }
178 211 },
179 212 computed: {
... ... @@ -209,6 +242,9 @@ export default {
209 242 totalQtyDisplay() {
210 243 const qty = this.round(this.items.reduce((p, c) => p + this.toNumber(c.quantity), 0), 3)
211 244 return `${qty}t/${this.planQty}t`
  245 + },
  246 + isChangeReasonRequired() {
  247 + return this.items.some(it => it && it.locked && this.normalizeDate(it.deliveryDate) !== this.normalizeDate(it.originalDeliveryDate))
212 248 }
213 249 },
214 250 onLoad(options) {
... ... @@ -267,6 +303,7 @@ export default {
267 303 amountExcludingTax: v.amountExcludingTax || 0,
268 304 totalAmount: v.totalAmount || 0,
269 305 deliveryDate: this.normalizeDate(v.deliveryDate),
  306 + originalDeliveryDate: this.normalizeDate(v.deliveryDate),
270 307 specDisplay: ''
271 308 }))
272 309 this.items = init.map(it => ({ ...it, specDisplay: this.specOf(it) }))
... ... @@ -346,6 +383,23 @@ export default {
346 383 amountExcludingTax: 0
347 384 }))
348 385 },
  386 + openSheet(field) {
  387 + if (field === 'changeReason') {
  388 + const options = this.changeReasonOptions || []
  389 + const current = this.form.changeReason
  390 + const match = options.find(o => String(o.value) === String(current))
  391 + this.sheet = { ...this.sheet, visible: true, title: '变更原因', options, field, value: match ? match.value : '' }
  392 + }
  393 + },
  394 + onSheetConfirm(e) {
  395 + const field = this.sheet.field
  396 + if (field === 'changeReason') {
  397 + const val = e && e.value != null ? e.value : ''
  398 + const label = e && e.label != null ? e.label : ''
  399 + this.form.changeReason = val
  400 + this.form.changeReasonName = label
  401 + }
  402 + },
349 403 async onSubmit() {
350 404 const selected = this.items.filter(it => it.locked).map(it => {
351 405 const raw = { ...(it.raw || {}) }
... ... @@ -359,6 +413,7 @@ export default {
359 413 raw.totalAmount = total
360 414 raw.amountExcludingTax = excl
361 415 raw.deliveryDate = it.deliveryDate
  416 + raw.materialCode = it.materialCode
362 417 return raw
363 418 })
364 419 if (!selected.length) {
... ... @@ -378,6 +433,10 @@ export default {
378 433 uni.showToast({ title: '发货日期不得早于今日', icon: 'none' })
379 434 return
380 435 }
  436 + if (this.isChangeReasonRequired && !this.form.changeReason) {
  437 + uni.showToast({ title: '发货日期已变更,请选择变更原因', icon: 'none' })
  438 + return
  439 + }
381 440 this.selectedItems = selected
382 441 const payload = {
383 442 id: this.id,
... ... @@ -386,6 +445,7 @@ export default {
386 445 totalAmountIncludingTax: this.totalAmountIncludingTax,
387 446 totalQuantity: this.totalQuantity,
388 447 type:'DIST_STOCK_CONTRACT',
  448 + changeReason: this.form.changeReason,
389 449 contractDistributorLineList: selected
390 450 }
391 451
... ... @@ -599,7 +659,9 @@ export default {
599 659 // ::v-deep .uni-list-item__extra-text {
600 660 // font-size: 32rpx;
601 661 // }
602   -
  662 +::v-deep .uni-list--border-top {
  663 + display: none;
  664 +}
603 665 ::v-deep .uni-easyinput {
604 666 width: 100%;
605 667 }
... ...
... ... @@ -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;
... ...