优化预约款式录入表单
This commit is contained in:
@@ -483,6 +483,7 @@ Page({
|
||||
createCustomerRecord: false,
|
||||
remark: ''
|
||||
},
|
||||
unifiedStyleDescription: '',
|
||||
customerOptions: [],
|
||||
customerDirectory: [],
|
||||
customerSheetVisible: false,
|
||||
@@ -501,6 +502,7 @@ Page({
|
||||
artistError: '',
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: '',
|
||||
manualProductTitleLength: 0,
|
||||
selectedArtist: {},
|
||||
productModalVisible: false,
|
||||
manualProductSheetVisible: false,
|
||||
@@ -552,6 +554,8 @@ Page({
|
||||
appointmentDate,
|
||||
artistId: options.artistId || baseForm.artistId || ''
|
||||
},
|
||||
manualProductTitleLength: String(baseForm.manualProductTitle || '').length,
|
||||
unifiedStyleDescription: String(baseForm.remark || baseForm.manualProductDescription || ''),
|
||||
draftSavedAtText: draftForm ? '已恢复本机草稿' : '',
|
||||
appointmentDayLabel: dateLabels.day,
|
||||
appointmentDateBadge: dateLabels.badge,
|
||||
@@ -584,7 +588,11 @@ Page({
|
||||
const selectedProduct = this.data.filteredProducts.find(item => String(item.id) === String(this.data.form.productId)) || {}
|
||||
const selectedProductPatch = {
|
||||
selectedProduct,
|
||||
selectedProductPriceText: selectedProduct.priceText || ''
|
||||
selectedProductPriceText: selectedProduct.priceText || '',
|
||||
unifiedStyleDescription: this.data.unifiedStyleDescription || this.data.form.remark || this.data.form.manualProductDescription || '',
|
||||
manualProductTitleLength: this.data.form.manualProductTitle
|
||||
? String(this.data.form.manualProductTitle).length
|
||||
: String(selectedProduct.title || '').length
|
||||
}
|
||||
if (selectedProduct.id && (this.data.form.amount === '' || this.data.form.amount === undefined)) {
|
||||
selectedProductPatch['form.amount'] = selectedProduct.price === undefined || selectedProduct.price === null ? '' : String(selectedProduct.price)
|
||||
@@ -685,16 +693,32 @@ Page({
|
||||
},
|
||||
|
||||
onStyleTitleInput(event) {
|
||||
const patch = { 'form.manualProductTitle': event.detail.value }
|
||||
const patch = {
|
||||
'form.manualProductTitle': event.detail.value,
|
||||
manualProductTitleLength: String(event.detail.value || '').length
|
||||
}
|
||||
if (this.data.form.productId) {
|
||||
patch['form.productId'] = ''
|
||||
patch.selectedProduct = {}
|
||||
patch.selectedProductPriceText = ''
|
||||
patch['form.manualProductDescription'] = this.data.unifiedStyleDescription || ''
|
||||
Object.assign(patch, buildManualProductImagePatch([]))
|
||||
}
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
onUnifiedStyleDescriptionInput(event) {
|
||||
const description = event.detail.value || ''
|
||||
const patch = {
|
||||
unifiedStyleDescription: description,
|
||||
'form.remark': description
|
||||
}
|
||||
if (!this.data.form.productId) {
|
||||
patch['form.manualProductDescription'] = description
|
||||
}
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
onCustomerInput(event) {
|
||||
const field = event.currentTarget.dataset.field
|
||||
const patch = {
|
||||
@@ -891,10 +915,33 @@ Page({
|
||||
this.setData({
|
||||
productModalVisible: false,
|
||||
manualProductSheetVisible: true,
|
||||
manualProductMoreVisible: false
|
||||
manualProductMoreVisible: false,
|
||||
unifiedStyleDescription: this.data.form.remark || this.data.form.manualProductDescription || this.data.unifiedStyleDescription || '',
|
||||
manualProductTitleLength: this.data.form.productId
|
||||
? String(this.data.selectedProduct.title || '').length
|
||||
: String(this.data.form.manualProductTitle || '').length
|
||||
})
|
||||
},
|
||||
|
||||
openManualProductFromLibrary() {
|
||||
const patch = {
|
||||
'form.productId': '',
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: '',
|
||||
unifiedStyleDescription: this.data.form.remark || this.data.form.manualProductDescription || this.data.unifiedStyleDescription || '',
|
||||
manualProductTitleLength: String(this.data.form.manualProductTitle || '').length,
|
||||
productModalVisible: false,
|
||||
manualProductSheetVisible: true,
|
||||
manualProductMoreVisible: false
|
||||
}
|
||||
if (this.data.form.productId) {
|
||||
patch['form.manualProductTitle'] = ''
|
||||
patch['form.manualProductDescription'] = this.data.unifiedStyleDescription || ''
|
||||
patch.manualProductTitleLength = 0
|
||||
}
|
||||
this.setData(patch)
|
||||
},
|
||||
|
||||
closeManualProduct() {
|
||||
this.setData({ manualProductSheetVisible: false })
|
||||
},
|
||||
@@ -904,23 +951,34 @@ Page({
|
||||
},
|
||||
|
||||
confirmManualProduct() {
|
||||
const hasTitle = Boolean(String(this.data.form.manualProductTitle || '').trim())
|
||||
const hasImage = (this.data.form.manualProductImages || []).length > 0 || Boolean(String(this.data.form.manualProductImageFileIds || '').trim())
|
||||
const hasFallbackName = Boolean(String(this.data.form.customerName || '').trim())
|
||||
if (this.data.form.productId && !hasTitle && !hasImage) {
|
||||
this.closeManualProduct()
|
||||
if (!this.data.form.productId) {
|
||||
const hasTitle = Boolean(String(this.data.form.manualProductTitle || '').trim())
|
||||
const hasImage = (this.data.form.manualProductImages || []).length > 0 || Boolean(String(this.data.form.manualProductImageFileIds || '').trim())
|
||||
const hasFallbackName = Boolean(String(this.data.form.customerName || '').trim())
|
||||
if (!hasTitle && !hasImage && !hasFallbackName) {
|
||||
wx.showToast({ title: '请填写款式名称或添加图片', icon: 'none' })
|
||||
return
|
||||
}
|
||||
}
|
||||
const amountText = String(this.data.form.amount === undefined || this.data.form.amount === null ? '' : this.data.form.amount).trim()
|
||||
const amount = Number(amountText)
|
||||
if (!amountText || !Number.isFinite(amount) || amount < 0) {
|
||||
wx.showToast({ title: '请输入不小于0的预约金额', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!hasTitle && !hasImage && !hasFallbackName) {
|
||||
wx.showToast({ title: '请填写款式名称或添加图片', icon: 'none' })
|
||||
if (!normalizeDuration(this.data.form.durationMinutes)) {
|
||||
wx.showToast({ title: '请输入大于0分钟的预计时长', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
'form.productId': '',
|
||||
selectedProduct: {},
|
||||
selectedProductPriceText: '',
|
||||
manualProductSheetVisible: false
|
||||
})
|
||||
if (this.data.form.productId) {
|
||||
this.setData({ manualProductSheetVisible: false })
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
return
|
||||
}
|
||||
this.setData({ 'form.productId': '', selectedProduct: {}, selectedProductPriceText: '', manualProductSheetVisible: false })
|
||||
this.refreshAvailableTimes()
|
||||
this.checkAvailability()
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
@@ -940,6 +998,8 @@ Page({
|
||||
this.setData({
|
||||
selectedProduct,
|
||||
selectedProductPriceText: selectedProduct.priceText || '',
|
||||
unifiedStyleDescription: this.data.form.remark || '',
|
||||
manualProductTitleLength: String(selectedProduct.title || '').length,
|
||||
'form.productId': selectedProduct.id,
|
||||
'form.manualProductTitle': '',
|
||||
'form.manualProductPrice': '',
|
||||
|
||||
Reference in New Issue
Block a user