Commit bbe19b010698b6a88e30a5c3f5878c6fc8c29879

Authored by 史婷婷
1 parent 25781bcb

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

... ... @@ -63,9 +63,11 @@
63 63 <uni-easyinput v-model="form.transportMode" placeholder="请输入运输方式" :inputBorder="false" />
64 64 </template>
65 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 71 </template>
70 72 </uni-list-item>
71 73
... ... @@ -193,13 +195,14 @@
193 195 import SingleSelectSheet from '@/components/single-select/index.vue'
194 196 import RelateSelectSheet from '@/components/relate-select/index.vue'
195 197 import ProductRel from './productRel.vue'
  198 +import CitySelector from '@/components/city-selector/index.vue'
196 199 import { getContractApi } from '@/api/contract'
197 200 import { getDicByCodes } from '@/utils/dic'
198 201 import { formatCurrencyToChinese } from '@/utils/common'
199 202
200 203 export default {
201 204 name: 'ModifyContractRetail',
202   - components: { SingleSelectSheet, RelateSelectSheet, ProductRel },
  205 + components: { SingleSelectSheet, RelateSelectSheet, ProductRel, CitySelector },
203 206 data() {
204 207 return {
205 208 id: '',
... ... @@ -227,7 +230,8 @@ export default {
227 230 packagingRequirements: '',
228 231 paymentTerms: '',
229 232 transportMode: '',
230   - destinationId: '',
  233 + destinationId: [],
  234 + destinationLabel: '',
231 235 specialInstructions: '',
232 236 remarks: '',
233 237 pieceWeightHead: '',
... ... @@ -257,6 +261,11 @@ export default {
257 261 this.loadSuppliers()
258 262 this.loadExtraOptions()
259 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 270 methods: {
262 271 async loadDetail() {
... ... @@ -292,7 +301,8 @@ export default {
292 301 packagingRequirements: m.packagingRequirements || '',
293 302 paymentTerms: m.paymentTerms || '',
294 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 306 specialInstructions: m.specialInstructions || '',
297 307 remarks: m.remarks || '',
298 308 pieceWeightHead: m.pieceWeightHead || '',
... ... @@ -307,6 +317,20 @@ export default {
307 317 this.onProductsChange(lines)
308 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 334 onProductsChange(products) {
311 335 const list = Array.isArray(products) ? products : []
312 336 const sumQ = list.reduce((acc, it) => acc + (parseFloat(it.quantity) || 0), 0)
... ... @@ -388,6 +412,15 @@ export default {
388 412 }
389 413 },
390 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 424 uni.showToast({ title: '暂未接入保存接口', icon: 'none' })
392 425 }
393 426 }
... ...