@@ -107,7 +107,12 @@
< ! - - Add Oil Form ( toggleable ) - - >
< div v-if = "showAddForm && auth.canManage" class="add-oil-form" >
< div class = "form-row " >
< div class = "add-type-tabs " >
< button class = "add-type-tab" : class = "{ active: addType === 'oil' }" @click ="addType = 'oil'" > 新增精油 < / button >
< button class = "add-type-tab" : class = "{ active: addType === 'product' }" @click ="addType = 'product'" > 新增其他产品 < / button >
< / div >
< ! - - 新增精油 - - >
< div v-if = "addType === 'oil'" class="form-row" >
< input v-model = "newOilName" style="flex:1;min-width:120px" placeholder="精油名称" class="form-input-sm" / >
< input v-model = "newOilEnName" style="flex:1;min-width:100px" placeholder="英文名" class="form-input-sm" / >
< input v -model .number = " newBottlePrice " style = "width:100px" type = "number" step = "0.01" min = "0" placeholder = "会员价 ¥" class = "form-input-sm" / >
@@ -124,6 +129,20 @@
< input v -model .number = " newRetailPrice " style = "width:100px" type = "number" step = "0.01" min = "0" placeholder = "零售价 ¥" class = "form-input-sm" / >
< button class = "btn btn-primary btn-sm" @click ="addOil" :disabled = "!newOilName.trim()" > ➕ 添加 < / button >
< / div >
<!-- 新增其他产品 -- >
< div v-else class = "form-row" >
< input v-model = "newOilName" style="flex:1;min-width:120px" placeholder="产品名称" class="form-input-sm" / >
< input v-model = "newOilEnName" style="flex:1;min-width:100px" placeholder="英文名" class="form-input-sm" / >
< input v -model .number = " newBottlePrice " style = "width:100px" type = "number" step = "0.01" min = "0" placeholder = "会员价 ¥" class = "form-input-sm" / >
< input v -model .number = " newProductAmount " style = "width:70px" type = "number" step = "1" min = "1" placeholder = "容量" class = "form-input-sm" / >
< select v-model = "newProductUnit" class="form-input-sm" style="width:60px" >
< option value = "ml" > ml < / option >
< option value = "g" > g < / option >
< option value = "capsule" > 颗 < / option >
< / select >
< input v -model .number = " newRetailPrice " style = "width:100px" type = "number" step = "0.01" min = "0" placeholder = "零售价 ¥" class = "form-input-sm" / >
< button class = "btn btn-primary btn-sm" @click ="addProduct" : disabled = "!newOilName.trim() || !newProductAmount" > ➕ 添加 < / button >
< / div >
< / div >
<!-- Oil Grid -- >
@@ -413,12 +432,15 @@ const activeCardName = ref(null)
const activeCard = ref ( null )
// Add oil form
const addType = ref ( 'oil' )
const newOilName = ref ( '' )
const newOilEnName = ref ( '' )
const newBottlePrice = ref ( null )
const newVolume = ref ( '5' )
const newCustomDrops = ref ( null )
const newRetailPrice = ref ( null )
const newProductAmount = ref ( null )
const newProductUnit = ref ( 'ml' )
// Edit oil
const editingOilName = ref ( null )
@@ -657,6 +679,29 @@ async function addOil() {
}
}
async function addProduct ( ) {
if ( ! newOilName . value . trim ( ) || ! newProductAmount . value ) return
try {
await oils . saveOil (
newOilName . value . trim ( ) ,
newBottlePrice . value || 0 ,
newProductAmount . value ,
newRetailPrice . value || null ,
newOilEnName . value . trim ( ) || null ,
newProductUnit . value
)
ui . showToast ( ` 已添加: ${ newOilName . value } ` )
newOilName . value = ''
newOilEnName . value = ''
newBottlePrice . value = null
newProductAmount . value = null
newProductUnit . value = 'ml'
newRetailPrice . value = null
} catch ( e ) {
ui . showToast ( '添加失败: ' + ( e . message || '' ) )
}
}
function editOil ( name ) {
editingOilName . value = name
editOilDisplayName . value = name
@@ -1065,6 +1110,16 @@ async function saveCardImage(name) {
}
/* ===== Add Oil Form ===== */
. add - type - tabs { display : flex ; gap : 0 ; margin - bottom : 10 px ; }
. add - type - tab {
flex : 1 ; padding : 6 px 0 ; text - align : center ; font - size : 13 px ; cursor : pointer ;
border : 1.5 px solid var ( -- border , # d4cfc7 ) ; background : # fff ; color : var ( -- text - mid , # 6 b6375 ) ;
font - family : inherit ;
}
. add - type - tab : first - child { border - radius : 8 px 0 0 8 px ; }
. add - type - tab : last - child { border - radius : 0 8 px 8 px 0 ; border - left : none ; }
. add - type - tab . active { background : var ( -- sage , # 7 a9e7e ) ; color : # fff ; border - color : var ( -- sage , # 7 a9e7e ) ; }
. add - oil - form {
margin - bottom : 16 px ;
padding : 14 px ;