This commit is contained in:
2025-09-27 22:57:59 +08:00
parent 8a458ff0a4
commit ed26244cdb
12585 changed files with 1914308 additions and 3474 deletions

View File

@@ -6,7 +6,6 @@
<view class="row"><text class="label">手机</text><text v-if="!editing" class="value">{{ d.mobile || '—' }}</text><input v-else class="value-input" v-model="form.mobile" placeholder="可选" /></view>
<view class="row"><text class="label">电话</text><text v-if="!editing" class="value">{{ d.phone || '—' }}</text><input v-else class="value-input" v-model="form.phone" placeholder="可选(座机)" /></view>
<view class="row"><text class="label">地址</text><text v-if="!editing" class="value">{{ d.address || '—' }}</text><input v-else class="value-input" v-model="form.address" placeholder="可选" /></view>
<view class="row"><text class="label">等级</text><text v-if="!editing" class="value">{{ d.level || '—' }}</text><input v-else class="value-input" v-model="form.level" placeholder="可选,如 VIP/A/B" /></view>
<view class="row"><text class="label">售价档位</text>
<text v-if="!editing" class="value">{{ d.priceLevel }}</text>
<picker v-else :range="priceLabels" :value="priceIdx" @change="onPriceChange"><view class="value">{{ priceLabels[priceIdx] }}</view></picker>
@@ -26,7 +25,7 @@
<script>
import { get, put } from '../../common/http.js'
export default {
data(){ return { id: null, d: {}, editing: false, form: { name:'', contactName:'', mobile:'', phone:'', address:'', level:'', priceLevel:'零售价', arOpening:0, remark:'' }, priceLevels:['零售价','批发价','大单报价'], priceLabels:['零售价','批发价','大单报价'], priceIdx:0 } },
data(){ return { id: null, d: {}, editing: false, form: { name:'', contactName:'', mobile:'', phone:'', address:'', priceLevel:'零售价', arOpening:0, remark:'' }, priceLevels:['零售价','批发价','大单报价'], priceLabels:['零售价','批发价','大单报价'], priceIdx:0 } },
onLoad(q){ if (q && q.id) { this.id = Number(q.id); this.fetch() } },
methods: {
async fetch(){
@@ -35,7 +34,7 @@ export default {
// 初始化表单
this.form = {
name: this.d.name || '', contactName: this.d.contactName || '', mobile: this.d.mobile || '', phone: this.d.phone || '',
address: this.d.address || '', level: this.d.level || '', priceLevel: this.d.priceLevel || 'retail', arOpening: Number(this.d.arOpening||0), remark: this.d.remark || ''
address: this.d.address || '', priceLevel: this.d.priceLevel || 'retail', arOpening: Number(this.d.arOpening||0), remark: this.d.remark || ''
}
const idx = this.priceLevels.indexOf(this.form.priceLevel); this.priceIdx = idx >= 0 ? idx : 0
} catch(e){ uni.showToast({ title:'加载失败', icon:'none' }) }

View File

@@ -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 {