sql数据流,amdin业务逻辑接入

This commit is contained in:
comlibmb
2026-02-09 23:14:23 +08:00
parent 8a11a43b6c
commit bf394eb65d
3 changed files with 261 additions and 107 deletions

View File

@@ -66,13 +66,13 @@
<text class="page-val">15条/页 ▼</text>
</view>
<view class="page-btns">
<text class="p-btn disabled"><</text>
<text class="p-btn active">1</text>
<text class="p-btn">></text>
<text :class="['p-btn', page <= 1 ? 'disabled' : '']" @click="prevPage"><</text>
<text class="p-btn active">{{ page }}</text>
<text :class="['p-btn', page >= totalPages ? 'disabled' : '']" @click="nextPage">></text>
</view>
<view class="page-jump">
<text class="jump-txt">前往</text>
<input class="jump-input" placeholder="1" />
<input class="jump-input" placeholder="1" v-model="jumpPage" @confirm="goToJumpPage" />
<text class="jump-txt">页</text>
</view>
</view>
@@ -104,7 +104,8 @@
</template>
<script setup lang="uts">
import { ref } from 'vue'
import { ref, onMounted, computed } from 'vue'
import { fetchCashierOrderPage } from '@/services/orderService.uts'
interface CashierOrder {
orderId: string
@@ -116,23 +117,85 @@ interface CashierOrder {
const orderId = ref('')
const username = ref('')
const total = ref(12)
const orderList = ref<CashierOrder[]>([
{ orderId: 'hy536720518414336000', userInfo: '东流 | 76058', payPrice: 1.00, discountPrice: 0.00, payTime: '2026-01-21 01:35:43' },
{ orderId: 'hy529509398574268416', userInfo: '半个栗子 | 81997', payPrice: 10000.00, discountPrice: 0.00, payTime: '2026-01-01 04:01:18' },
{ orderId: 'hy511477797936431104', userInfo: '莉莉 | 80736', payPrice: 10.00, discountPrice: 0.00, payTime: '2025-11-12 09:50:09' },
{ orderId: 'hy507152261823070208', userInfo: '. . . | 71546', payPrice: 0.10, discountPrice: 0.00, payTime: '2025-10-31 11:22:01' },
{ orderId: 'hy506826113427701760', userInfo: 'A梁 | 80363', payPrice: 0.10, discountPrice: 0.00, payTime: '2025-10-30 13:46:01' },
{ orderId: 'hy504707908026499072', userInfo: '前前前前 | 80225', payPrice: 2252.00, discountPrice: 0.00, payTime: '2025-10-24 17:29:02' },
{ orderId: 'hy494505602832138240', userInfo: '张总说 | 40028', payPrice: 1.00, discountPrice: 0.00, payTime: '2025-09-26 13:48:43' },
{ orderId: 'hy490819329198129152', userInfo: '虚伪 | 79027', payPrice: 10.00, discountPrice: 0.00, payTime: '2025-09-16 09:40:47' }
])
const total = ref(0)
const orderList = ref<CashierOrder[]>([])
const loading = ref(false)
const page = ref(1)
const pageSize = ref(15)
const jumpPage = ref('')
const totalPages = computed((): number => {
if (pageSize.value <= 0) return 1
const pages = Math.ceil(total.value / pageSize.value)
return pages <= 0 ? 1 : pages
})
const loadCashierOrders = async () => {
loading.value = true
try {
const res = await fetchCashierOrderPage(
page.value,
pageSize.value,
orderId.value ? orderId.value : null,
username.value ? username.value : null
)
orderList.value = res.items.map((item: any): CashierOrder => {
return {
orderId: String(item.order_no ?? '--'),
userInfo: `${String(item.customer_name ?? '未知')} | ${String(item.customer_phone ?? '')}`,
payPrice: parseFloat(String(item.total_amount ?? item.pay_amount ?? '0')),
discountPrice: parseFloat(String(item.discount_amount ?? '0')),
payTime: String(item.paid_at ?? '--')
} as CashierOrder
})
total.value = res.total
} catch (e) {
uni.showToast({ title: '收银订单加载失败', icon: 'none' })
} finally {
loading.value = false
}
}
onMounted(() => {
loadCashierOrders()
})
const handleQuery = () => {
page.value = 1
loadCashierOrders()
}
const prevPage = () => {
if (page.value > 1) {
page.value--
loadCashierOrders()
}
}
const nextPage = () => {
if (page.value < totalPages.value) {
page.value++
loadCashierOrders()
}
}
const goToJumpPage = () => {
const targetPage = parseInt(jumpPage.value)
if (!isNaN(targetPage) && targetPage >= 1 && targetPage <= totalPages.value) {
page.value = targetPage
loadCashierOrders()
jumpPage.value = ''
} else {
uni.showToast({ title: '请输入有效的页码', icon: 'none' })
}
}
const showQrModal = ref(false)
const isClosing = ref(false)
const handleQuery = () => { console.log('Querying...') }
const openQrModal = () => {
showQrModal.value = true
isClosing.value = false