134 lines
2.8 KiB
Vue
134 lines
2.8 KiB
Vue
<template>
|
|
<u-popup v-model="show" mode="center" border-radius="16" width="85%" :closeable="true" @close="onClose">
|
|
<view class="modal">
|
|
<view class="modal-title">修改售价</view>
|
|
<view v-if="drugName" class="modal-drug">{{ drugName }}</view>
|
|
<view v-if="suggestPrice" class="modal-hint">建议售价 {{ suggestPrice }}</view>
|
|
<input
|
|
class="modal-input"
|
|
type="digit"
|
|
v-model="priceInput"
|
|
placeholder="请输入新售价"
|
|
/>
|
|
<view class="modal-actions">
|
|
<button class="btn cancel" @click="onClose">取消</button>
|
|
<button class="btn confirm" :loading="submitting" @click="onConfirm">确定</button>
|
|
</view>
|
|
</view>
|
|
</u-popup>
|
|
</template>
|
|
|
|
<script>
|
|
import businessMixin from '@/subPackages/sub_business_shared/common/businessMixin.js'
|
|
|
|
export default {
|
|
mixins: [businessMixin],
|
|
name: 'PriceEditModal',
|
|
props: {
|
|
visible: { type: Boolean, default: false },
|
|
item: { type: Object, default: null },
|
|
},
|
|
data() {
|
|
return {
|
|
show: false,
|
|
priceInput: '',
|
|
submitting: false,
|
|
}
|
|
},
|
|
computed: {
|
|
drugName() {
|
|
const drug = (this.item && this.item.drug) || {}
|
|
return drug.drug_name || ''
|
|
},
|
|
suggestPrice() {
|
|
if (!this.item) return ''
|
|
const drug = this.item.drug || {}
|
|
const storeDrug = drug.drug_store_drug || {}
|
|
const p = storeDrug.price != null ? storeDrug.price : drug.price
|
|
if (p == null || p === '') return ''
|
|
return '¥' + Number(p).toFixed(2)
|
|
},
|
|
},
|
|
watch: {
|
|
visible: {
|
|
immediate: true,
|
|
handler(v) {
|
|
this.show = v
|
|
if (v && this.item) {
|
|
const raw = this.item.price
|
|
this.priceInput = raw != null && raw !== '' ? String(raw) : ''
|
|
}
|
|
},
|
|
},
|
|
show(v) {
|
|
if (!v) this.$emit('close')
|
|
},
|
|
},
|
|
methods: {
|
|
onClose() {
|
|
this.show = false
|
|
this.$emit('close')
|
|
},
|
|
onConfirm() {
|
|
const price = parseFloat(String(this.priceInput).trim())
|
|
if (!price || price <= 0 || Number.isNaN(price)) {
|
|
uni.showToast({ title: '请输入有效售价', icon: 'none' })
|
|
return
|
|
}
|
|
const rounded = Math.round(price * 100) / 100
|
|
this.$emit('confirm', rounded)
|
|
},
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.modal {
|
|
padding: 40rpx 32rpx 32rpx;
|
|
}
|
|
.modal-title {
|
|
font-size: 32rpx;
|
|
font-weight: 600;
|
|
color: #333;
|
|
text-align: center;
|
|
}
|
|
.modal-drug {
|
|
font-size: 26rpx;
|
|
color: #666;
|
|
margin-top: 16rpx;
|
|
text-align: center;
|
|
}
|
|
.modal-hint {
|
|
font-size: 24rpx;
|
|
color: #999;
|
|
margin-top: 8rpx;
|
|
text-align: center;
|
|
}
|
|
.modal-input {
|
|
margin-top: 32rpx;
|
|
padding: 20rpx 24rpx;
|
|
background: #f5f5f5;
|
|
border-radius: 12rpx;
|
|
font-size: 28rpx;
|
|
}
|
|
.modal-actions {
|
|
display: flex;
|
|
gap: 24rpx;
|
|
margin-top: 40rpx;
|
|
}
|
|
.btn {
|
|
flex: 1;
|
|
font-size: 28rpx;
|
|
border-radius: 44rpx;
|
|
margin: 0;
|
|
}
|
|
.btn.cancel {
|
|
background: #f5f5f5;
|
|
color: #666;
|
|
}
|
|
.btn.confirm {
|
|
background: #6acdbb;
|
|
color: #fff;
|
|
}
|
|
</style>
|