2
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<view class="page">
|
||||
<view class="field"><text class="label">客户名称</text><input class="value" v-model="form.name" placeholder="必填" /></view>
|
||||
<view class="field"><text class="label">客户等级</text><input class="value" v-model="form.level" placeholder="可选,如 VIP/A/B" /></view>
|
||||
<view class="field">
|
||||
<text class="label">售价档位</text>
|
||||
<picker :range="priceLabels" :value="priceIdx" @change="onPriceChange">
|
||||
@@ -20,20 +19,39 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { post, put } from '../../common/http.js'
|
||||
import { get, post, put } from '../../common/http.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
id: null,
|
||||
form: { name:'', level:'', priceLevel:'retail', contactName:'', mobile:'', phone:'', address:'', arOpening:0, remark:'' },
|
||||
form: { name:'', priceLevel:'retail', contactName:'', mobile:'', phone:'', address:'', arOpening:0, remark:'' },
|
||||
priceLevels: ['零售价','批发价','大单报价'],
|
||||
priceLabels: ['零售价','批发价','大单报价'],
|
||||
priceIdx: 0
|
||||
}
|
||||
},
|
||||
onLoad(query) { if (query && query.id) { this.id = Number(query.id) } },
|
||||
onLoad(query) { if (query && query.id) { this.id = Number(query.id); this.load() } },
|
||||
methods: {
|
||||
onPriceChange(e){ this.priceIdx = Number(e.detail.value); this.form.priceLevel = this.priceLevels[this.priceIdx] },
|
||||
async load() {
|
||||
if (!this.id) return
|
||||
try {
|
||||
const d = await get(`/api/customers/${this.id}`)
|
||||
this.form = {
|
||||
name: d?.name || '',
|
||||
priceLevel: d?.priceLevel || '零售价',
|
||||
contactName: d?.contactName || '',
|
||||
mobile: d?.mobile || '',
|
||||
phone: d?.phone || '',
|
||||
address: d?.address || '',
|
||||
arOpening: Number(d?.arOpening || 0),
|
||||
remark: d?.remark || ''
|
||||
}
|
||||
// 同步 priceIdx
|
||||
const idx = this.priceLevels.indexOf(this.form.priceLevel || '零售价')
|
||||
this.priceIdx = idx >= 0 ? idx : 0
|
||||
} catch(e) { uni.showToast({ title: e?.message || '加载失败', icon: 'none' }) }
|
||||
},
|
||||
async save() {
|
||||
if (!this.form.name) return uni.showToast({ title:'请填写客户名称', icon:'none' })
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user