Commit 6fc8c1d226b353cbbd4887779c736192af920b5a

Authored by gesilong
2 parents 03ffa657 e8727abc

Merge branch 'cjerp-contract-1.0' into test_cjerp

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