对齐历史补录款式弹窗

This commit is contained in:
2026-10-21 00:55:51 +08:00
parent 8d3f092084
commit 9925c7f83b
6 changed files with 258 additions and 20 deletions
+14 -9
View File
@@ -5,7 +5,7 @@ const customersApi = require('../../api/customers')
const dateUtil = require('../../utils/date')
Page({
data: { form: { serviceDate: dateUtil.formatDate(new Date()), manualProductTitle: '', amount: '', customerName: '', phone: '', serviceTime: '', status: 4, remark: '', artistId: '', productId: '', customerUserId: '' }, manualProductDraft: { title: '', price: '' }, manualMoreExpanded: false, productSelectorMode: 'list', artists: [], artistOptions: [], allProductOptions: [], productOptions: [], customerOptions: [], allCustomerOptions: [], productSelectorVisible: false, artistSelectorVisible: false, customerSelectorVisible: false, loadingProducts: false, loadingArtists: false, loadingCustomers: false, productKeyword: '', artistKeyword: '', customerKeyword: '', productError: '', artistError: '', customerError: '', selectedArtistName: '', selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: '', submitting: false },
data: { form: { serviceDate: dateUtil.formatDate(new Date()), manualProductTitle: '', amount: '', customerName: '', phone: '', serviceTime: '', status: 4, remark: '', artistId: '', productId: '', customerUserId: '' }, manualProductDraft: { title: '', price: '' }, artists: [], artistOptions: [], allProductOptions: [], productOptions: [], customerOptions: [], allCustomerOptions: [], productSelectorVisible: false, manualProductSheetVisible: false, artistSelectorVisible: false, customerSelectorVisible: false, loadingProducts: false, loadingArtists: false, loadingCustomers: false, productKeyword: '', artistKeyword: '', customerKeyword: '', productError: '', artistError: '', customerError: '', selectedArtistName: '', selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: '', submitting: false },
onLoad(options = {}) {
const serviceDate = options.serviceDate || this.data.form.serviceDate
const artistId = options.artistId || ''
@@ -43,12 +43,17 @@ Page({
this.setData({ allProductOptions: options, productOptions: options.filter(item => !keyword || `${item.title} ${item.artistText} ${item.tagList.join(' ')}`.toLowerCase().includes(keyword)) })
},
async loadCustomers() { this.setData({ loadingCustomers: true }); try { const result = await customersApi.list({ page: 1, size: 30 }); const list = result.list || result || []; const options = list.map(item => ({ id: item.id, title: item.nickname || item.name || item.account, subtitle: item.phone || item.contactPhone || '' })); this.setData({ allCustomerOptions: options, customerOptions: options, customerError: '' }) } catch (error) { this.setData({ customerError: error.message || '客户加载失败' }) } finally { this.setData({ loadingCustomers: false }) } },
openProductSelector() { this.setData({ productSelectorVisible: true, productSelectorMode: 'list' }) },
closeProductSelector() { this.setData({ productSelectorVisible: false, productSelectorMode: 'list' }) },
openManualProduct() { this.setData({ productSelectorMode: 'manual', manualMoreExpanded: false }) },
backToProductList() { this.setData({ productSelectorMode: 'list' }) },
onManualProductInput(e) { this.setData({ [`manualProductDraft.${e.detail.field}`]: e.detail.value }) },
toggleManualProductMore() { this.setData({ manualMoreExpanded: !this.data.manualMoreExpanded }) },
openProductSelector() { this.setData({ manualProductSheetVisible: true }) },
openProductLibrary() { this.setData({ manualProductSheetVisible: false, productSelectorVisible: true }) },
closeProductSelector() { this.setData({ productSelectorVisible: false }) },
closeManualProduct() { this.setData({ manualProductSheetVisible: false }) },
openManualProduct() { this.setData({ productSelectorVisible: false, manualProductSheetVisible: true }) },
onManualProductInput(e) {
const field = e.currentTarget && e.currentTarget.dataset.field || e.detail.field
this.setData({ [`manualProductDraft.${field}`]: e.detail.value })
},
stopTap() {},
stopTouchMove() {},
openArtistSelector() { this.setData({ artistSelectorVisible: true }) },
closeArtistSelector() { this.setData({ artistSelectorVisible: false }) },
openCustomerSelector() { this.setData({ customerSelectorVisible: true }) },
@@ -56,7 +61,7 @@ Page({
searchProducts(e) { const keyword = String(e.detail.value || '').trim().toLowerCase(); this.setData({ productKeyword: keyword, productOptions: this.data.allProductOptions.filter(item => !keyword || `${item.title} ${item.artistText} ${item.tagList.join(' ')}`.toLowerCase().includes(keyword)) }) },
searchArtists(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ artistKeyword: keyword, artistOptions: this.data.artists.map(item => ({ id: item.id, title: item.name, subtitle: item.phone || '' })).filter(item => !keyword || item.title.toLowerCase().includes(keyword)) }) },
searchCustomers(e) { const keyword = String(e.detail.value || '').toLowerCase(); this.setData({ customerKeyword: keyword, customerOptions: this.data.allCustomerOptions.filter(item => !keyword || String(item.title).toLowerCase().includes(keyword) || String(item.subtitle).includes(keyword)) }) },
selectProduct(e) { const item = e.detail.item; this.setData({ 'form.productId': item.id, selectedProduct: item, selectedProductTitle: item.title, selectedProductPriceText: item.priceText || (item.price == null ? '价格待定' : `¥${item.price}`), 'form.manualProductTitle': '', manualProductDraft: { title: '', price: '' }, 'form.amount': item.price == null ? this.data.form.amount : String(item.price), productSelectorVisible: false, productSelectorMode: 'list' }) },
selectProduct(e) { const item = e.detail.item; this.setData({ 'form.productId': item.id, selectedProduct: item, selectedProductTitle: item.title, selectedProductPriceText: item.priceText || (item.price == null ? '价格待定' : `¥${item.price}`), 'form.manualProductTitle': '', manualProductDraft: { title: '', price: '' }, 'form.amount': item.price == null ? this.data.form.amount : String(item.price), productSelectorVisible: false, manualProductSheetVisible: false }) },
selectArtist(e) { const item = e.detail.item; this.setData({ 'form.artistId': item.id, selectedArtistName: item.title, artistSelectorVisible: false }) },
selectCustomer(e) { const item = e.detail.item; this.setData({ 'form.customerUserId': item.id, 'form.customerName': item.title, 'form.phone': item.subtitle, customerSelectorVisible: false }) },
useWalkIn() { this.setData({ 'form.customerUserId': '', 'form.customerName': '', 'form.phone': '', customerSelectorVisible: false }) },
@@ -69,7 +74,7 @@ Page({
wx.showToast({ title: '请填写作品名称和价格', icon: 'none' })
return
}
this.setData({ 'form.productId': '', 'form.manualProductTitle': title, selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: `¥${price}`, 'form.amount': String(price), productSelectorVisible: false, productSelectorMode: 'list' })
this.setData({ 'form.productId': '', 'form.manualProductTitle': title, selectedProduct: {}, selectedProductTitle: '', selectedProductPriceText: `¥${price}`, 'form.amount': String(price), productSelectorVisible: false, manualProductSheetVisible: false })
},
onInput(e) { this.setData({ [`form.${e.currentTarget.dataset.field}`]: e.detail.value }) },
onDateChange(e) { this.setData({ 'form.serviceDate': e.detail.value }) },