Commit bbe19b010698b6a88e30a5c3f5878c6fc8c29879

Authored by 史婷婷
1 parent 25781bcb

feat: 经销标准合同-编辑-使用地区级联选择组件 并处理提交数据(区id)

@@ -63,9 +63,11 @@ @@ -63,9 +63,11 @@
63 <uni-easyinput v-model="form.transportMode" placeholder="请输入运输方式" :inputBorder="false" /> 63 <uni-easyinput v-model="form.transportMode" placeholder="请输入运输方式" :inputBorder="false" />
64 </template> 64 </template>
65 </uni-list-item> 65 </uni-list-item>
66 - <uni-list-item title="目的地">  
67 - <template v-slot:footer>  
68 - <uni-easyinput v-model="form.destinationId" placeholder="请输入目的地" :inputBorder="false" /> 66 + <uni-list-item class="select-item" :class="(Array.isArray(form.destinationId) && form.destinationId.length) ? 'is-filled' : 'is-empty'" clickable
  67 + @click="openCitySelector" :rightText="form.destinationLabel || '请选择'" showArrow>
  68 + <template v-slot:body>
  69 + <view class="item-title"><text>目的地</text></view>
  70 + <CitySelector ref="citySelectorRef" v-model="form.destinationId" @change="onCityChange" />
69 </template> 71 </template>
70 </uni-list-item> 72 </uni-list-item>
71 73
@@ -193,13 +195,14 @@ @@ -193,13 +195,14 @@
193 import SingleSelectSheet from '@/components/single-select/index.vue' 195 import SingleSelectSheet from '@/components/single-select/index.vue'
194 import RelateSelectSheet from '@/components/relate-select/index.vue' 196 import RelateSelectSheet from '@/components/relate-select/index.vue'
195 import ProductRel from './productRel.vue' 197 import ProductRel from './productRel.vue'
  198 +import CitySelector from '@/components/city-selector/index.vue'
196 import { getContractApi } from '@/api/contract' 199 import { getContractApi } from '@/api/contract'
197 import { getDicByCodes } from '@/utils/dic' 200 import { getDicByCodes } from '@/utils/dic'
198 import { formatCurrencyToChinese } from '@/utils/common' 201 import { formatCurrencyToChinese } from '@/utils/common'
199 202
200 export default { 203 export default {
201 name: 'ModifyContractRetail', 204 name: 'ModifyContractRetail',
202 - components: { SingleSelectSheet, RelateSelectSheet, ProductRel }, 205 + components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector },
203 data() { 206 data() {
204 return { 207 return {
205 id: '', 208 id: '',
@@ -227,7 +230,8 @@ export default { @@ -227,7 +230,8 @@ export default {
227 packagingRequirements: '', 230 packagingRequirements: '',
228 paymentTerms: '', 231 paymentTerms: '',
229 transportMode: '', 232 transportMode: '',
230 - destinationId: '', 233 + destinationId: [],
  234 + destinationLabel: '',
231 specialInstructions: '', 235 specialInstructions: '',
232 remarks: '', 236 remarks: '',
233 pieceWeightHead: '', 237 pieceWeightHead: '',
@@ -257,6 +261,11 @@ export default { @@ -257,6 +261,11 @@ export default {
257 this.loadSuppliers() 261 this.loadSuppliers()
258 this.loadExtraOptions() 262 this.loadExtraOptions()
259 this.loadDetail() 263 this.loadDetail()
  264 + this.$nextTick(() => {
  265 + if (Array.isArray(this.form.destinationId) && this.form.destinationId.length) {
  266 + this.initDestinationLabel()
  267 + }
  268 + })
260 }, 269 },
261 methods: { 270 methods: {
262 async loadDetail() { 271 async loadDetail() {
@@ -292,7 +301,8 @@ export default { @@ -292,7 +301,8 @@ export default {
292 packagingRequirements: m.packagingRequirements || '', 301 packagingRequirements: m.packagingRequirements || '',
293 paymentTerms: m.paymentTerms || '', 302 paymentTerms: m.paymentTerms || '',
294 transportMode: m.transportMode || '', 303 transportMode: m.transportMode || '',
295 - destinationId: m.destinationId || '', 304 + destinationId: (m.provinceId && m.cityId && m.districtId) ? [m.provinceId, m.cityId, m.districtId] : (Array.isArray(m.destinationId) ? m.destinationId : []),
  305 + destinationLabel: (m.provinceName && m.cityName && m.districtName) ? `${m.provinceName} / ${m.cityName} / ${m.districtName}` : (m.destinationLabel || ''),
296 specialInstructions: m.specialInstructions || '', 306 specialInstructions: m.specialInstructions || '',
297 remarks: m.remarks || '', 307 remarks: m.remarks || '',
298 pieceWeightHead: m.pieceWeightHead || '', 308 pieceWeightHead: m.pieceWeightHead || '',
@@ -307,6 +317,20 @@ export default { @@ -307,6 +317,20 @@ export default {
307 this.onProductsChange(lines) 317 this.onProductsChange(lines)
308 } catch (e) { } 318 } catch (e) { }
309 }, 319 },
  320 + async initDestinationLabel() {
  321 + const comp = this.$refs.citySelectorRef
  322 + if (comp && typeof comp.getLabel === 'function') {
  323 + const label = await comp.getLabel()
  324 + this.form.destinationLabel = label || ''
  325 + }
  326 + },
  327 + openCitySelector() {
  328 + this.$refs.citySelectorRef && this.$refs.citySelectorRef.open()
  329 + },
  330 + onCityChange(payload) {
  331 + const label = payload && payload.label != null ? payload.label : ''
  332 + this.form.destinationLabel = label
  333 + },
310 onProductsChange(products) { 334 onProductsChange(products) {
311 const list = Array.isArray(products) ? products : [] 335 const list = Array.isArray(products) ? products : []
312 const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0) 336 const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0)
@@ -388,6 +412,15 @@ export default { @@ -388,6 +412,15 @@ export default {
388 } 412 }
389 }, 413 },
390 async onSubmit() { 414 async onSubmit() {
  415 +
  416 + const { destinationLabel, destinationId, ...formForSubmit } = this.form;
  417 + // 区id
  418 + const destination = destinationId && destinationId.length > 0 ? destinationId[destinationId.length - 1] : '';
  419 + const payload = {
  420 + ...formForSubmit,
  421 + destination,
  422 + }
  423 + console.log('onSubmit__payload', payload)
391 uni.showToast({ title: '暂未接入保存接口', icon: 'none' }) 424 uni.showToast({ title: '暂未接入保存接口', icon: 'none' })
392 } 425 }
393 } 426 }