李红攀:V2.6.969,客户管理、销售订单

This commit is contained in:
2026-06-18 17:51:39 +08:00
parent 4c09ffdf00
commit d0ce2f2b55
9 changed files with 1992 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
import type { PageParam, PageResult } from '@/http/types'
import { http } from '@/http/http'
/** 账户信息 */
export interface Account {
id?: number
name?: string
}
/** 获取账户精简列表 */
export function getAccountSimpleList() {
return http.get<Account[]>('/erp/account/simple-list')
}

View File

@@ -0,0 +1,96 @@
import type { PageParam, PageResult } from '@/http/types'
import { http } from '@/http/http'
/** 客户信息 */
export interface Customer {
id?: number
name?: string
contact?: string
mobile?: string
telephone?: string
email?: string
fax?: string
remark?: string
status?: number
sort?: number
taxNo?: string
taxPercent?: number
bankName?: string
bankAccount?: string
bankAddress?: string
tags?: string
companyType?: number
businessScale?: string
annualPurchaseVolume?: number
annualPurchaseAmount?: number
annualOrderNums?: number
annualOrderAmounts?: number
annualReceivedAmounts?: number
totalUnreceivedAmounts?: number
preferredProducts?: string
preferredPackaging?: string
qualityCertRequirements?: string
deliveryCyclePrefer?: string
paymentTerms?: string
lastDeliveryTime?: number
deliveryAddress?: string
businessLicenseNo?: string
licenseValidity?: number
riskLevel?: number
logisticsPartner?: string
requiresColdChain?: boolean
serviceRegion?: string
relationshipLevel?: number
leadSourceType?: number
leadSourceDetail?: string
leadScore?: number
potentialLevel?: number
expectedAnnualVolume?: number
expectedAnnualAmount?: number
purchaseCycle?: string
}
/** 客户精简信息 */
export interface CustomerSimple {
id: number
name: string
}
/** 获取客户分页列表 */
export function getCustomerPage(params: PageParam & {
name?: string
mobile?: string
telephone?: string
}) {
return http.get<PageResult<Customer>>('/erp/customer/page', params)
}
/** 获取客户详情 */
export function getCustomer(id: number) {
return http.get<Customer>(`/erp/customer/get?id=${id}`)
}
/** 创建客户 */
export function createCustomer(data: Customer) {
return http.post<number>('/erp/customer/create', data)
}
/** 更新客户 */
export function updateCustomer(data: Customer) {
return http.put<boolean>('/erp/customer/update', data)
}
/** 删除客户 */
export function deleteCustomer(id: number) {
return http.delete<boolean>(`/erp/customer/delete?id=${id}`)
}
/** 获取客户精简列表 */
export function getCustomerSimpleList() {
return http.get<CustomerSimple[]>('/erp/customer/simple-list')
}
/** 导出客户 */
export function exportCustomer(params: PageParam) {
return http.get<string>('/erp/customer/export', params)
}

View File

@@ -0,0 +1,92 @@
import type { PageParam, PageResult } from '@/http/types'
import { http } from '@/http/http'
/** 销售订单项 */
export interface SaleOrderItem {
id?: number
productId?: number
productName?: string
productNo?: string
count?: number
totalCount?: number
unitPrice?: number
productPrice?: number
taxPrice?: number
totalPrice?: number
taxPercent?: number
taxAmount?: number
remark?: string
}
/** 销售订单信息 */
export interface SaleOrder {
id?: number
no?: string
customerId?: number
customerName?: string
orderTime?: number | string
totalCount?: number
totalProductPrice?: number
discountPercent?: number
discountPrice?: number
totalPrice?: number
depositPrice?: number
accountId?: number
status?: number
remark?: string
fileUrl?: string
items?: SaleOrderItem[]
saleUserId?: number
saleUserName?: string
paymentCondition?: number
paymentMethod?: number
outCount?: number
returnCount?: number
productNames?: string
creatorName?: string
hasApprovalRecords?: boolean
}
/** 获取销售订单分页列表 */
export function getSaleOrderPage(params: PageParam & {
no?: string
customerId?: number
productId?: number
orderTime?: string[]
status?: number
creator?: number
outStatus?: string
returnStatus?: string
}) {
return http.get<PageResult<SaleOrder>>('/erp/sale-order/page', params)
}
/** 获取销售订单详情 */
export function getSaleOrder(id: number) {
return http.get<SaleOrder>(`/erp/sale-order/get?id=${id}`)
}
/** 创建销售订单 */
export function createSaleOrder(data: SaleOrder) {
return http.post<number>('/erp/sale-order/create', data)
}
/** 更新销售订单 */
export function updateSaleOrder(data: SaleOrder) {
return http.put<boolean>('/erp/sale-order/update', data)
}
/** 更新销售订单状态 */
export function updateSaleOrderStatus(id: number, status: number) {
return http.put<boolean>('/erp/sale-order/update-status', undefined, { id, status })
}
/** 删除销售订单 */
export function deleteSaleOrder(ids: number[]) {
return http.delete<boolean>(`/erp/sale-order/delete?ids=${ids.join(',')}`)
}
/** 导出销售订单 */
export function exportSaleOrder(params: PageParam) {
return http.get<string>('/erp/sale-order/export-excel', params)
}

View File

@@ -0,0 +1,372 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
:title="getTitle"
left-arrow placeholder safe-area-inset-top fixed
@click-left="handleBack"
/>
<!-- 表单区域 -->
<view class="pb-180rpx">
<wd-form ref="formRef" :model="formData" :rules="formRules">
<!-- 基础信息 -->
<wd-cell-group title="基础信息" border>
<wd-input
v-model="formData.name"
label="名称"
label-width="180rpx"
placeholder="请输入客户名称"
prop="name"
clearable
/>
<wd-input
v-model="formData.contact"
label="联系人"
label-width="180rpx"
placeholder="请输入联系人"
clearable
/>
<wd-input
v-model="formData.mobile"
label="手机号码"
label-width="180rpx"
placeholder="请输入手机号码"
type="number"
clearable
/>
<wd-input
v-model="formData.telephone"
label="联系电话"
label-width="180rpx"
placeholder="请输入联系电话"
clearable
/>
<wd-input
v-model="formData.email"
label="电子邮箱"
label-width="180rpx"
placeholder="请输入电子邮箱"
clearable
/>
<wd-cell title="企业类型" title-width="180rpx" center>
<wd-picker
v-model="formData.companyType"
:columns="companyTypeColumns"
label=""
placeholder="请选择企业类型"
@confirm="onCompanyTypeConfirm"
/>
</wd-cell>
<wd-input
v-model="formData.businessScale"
label="企业规模"
label-width="180rpx"
placeholder="请输入企业规模"
clearable
/>
<wd-cell title="客户来源" title-width="180rpx" center>
<wd-picker
v-model="formData.leadSourceType"
:columns="leadSourceTypeColumns"
label=""
placeholder="请选择来源类型"
@confirm="onLeadSourceTypeConfirm"
/>
</wd-cell>
</wd-cell-group>
<!-- 财务信息 -->
<wd-cell-group title="财务信息" border>
<wd-input
v-model="formData.taxNo"
label="纳税人识别号"
label-width="180rpx"
placeholder="请输入纳税人识别号"
clearable
/>
<wd-input
v-model="formData.bankName"
label="开户行"
label-width="180rpx"
placeholder="请输入开户行"
clearable
/>
<wd-input
v-model="formData.bankAccount"
label="开户账号"
label-width="180rpx"
placeholder="请输入开户账号"
clearable
/>
<wd-input
v-model="formData.bankAddress"
label="开户地址"
label-width="180rpx"
placeholder="请输入开户地址"
clearable
/>
</wd-cell-group>
<!-- 偏好信息 -->
<wd-cell-group title="偏好信息" border>
<wd-input
v-model="formData.preferredProducts"
label="偏好产品"
label-width="180rpx"
placeholder="请输入偏好产品或品类"
clearable
/>
<wd-input
v-model="formData.preferredPackaging"
label="偏好包装"
label-width="180rpx"
placeholder="请输入偏好包装形式"
clearable
/>
<wd-input
v-model="formData.deliveryCyclePrefer"
label="偏好交期"
label-width="180rpx"
placeholder="请输入偏好交期/周期"
clearable
/>
</wd-cell-group>
<!-- 统计信息 -->
<wd-cell-group title="统计信息" border>
<wd-input
:model-value="formatInteger(formData.annualOrderNums)"
label="年度订单数"
label-width="180rpx"
placeholder="系统自动生成"
disabled
/>
<wd-input
:model-value="formatAmount(formData.annualOrderAmounts)"
label="年度订单额"
label-width="180rpx"
placeholder="系统自动生成"
disabled
/>
<wd-input
:model-value="formatAmount(formData.annualReceivedAmounts)"
label="年度已收款"
label-width="180rpx"
placeholder="系统自动生成"
disabled
/>
<wd-input
:model-value="formatAmount(formData.totalUnreceivedAmounts)"
label="累计未收款"
label-width="180rpx"
placeholder="系统自动生成"
disabled
/>
</wd-cell-group>
<!-- 其他信息 -->
<wd-cell-group title="其他信息" border>
<wd-cell title="开启状态" title-width="180rpx" center>
<wd-switch v-model="statusEnabled" />
</wd-cell>
<wd-input
v-model="formData.sort"
label="排序"
label-width="180rpx"
placeholder="请输入排序"
type="number"
clearable
/>
<wd-textarea
v-model="formData.remark"
label="备注"
label-width="180rpx"
placeholder="请输入备注"
:maxlength="200"
show-word-limit
clearable
/>
</wd-cell-group>
</wd-form>
</view>
<!-- 底部保存按钮 -->
<view class="yd-detail-footer">
<wd-button
type="primary"
block
:loading="formLoading"
@click="handleSubmit"
>
保存
</wd-button>
</view>
</view>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
import type { Customer } from '@/api/erp/customer'
import { computed, onMounted, ref, watch } from 'vue'
import { useToast } from 'wot-design-uni'
import { createCustomer, getCustomer, updateCustomer } from '@/api/erp/customer'
import { navigateBackPlus } from '@/utils'
const props = defineProps<{
id?: number | any
}>()
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
const toast = useToast()
const getTitle = computed(() => props.id ? '编辑客户' : '新增客户')
const formLoading = ref(false)
const formData = ref<Customer>({
id: undefined,
name: undefined,
contact: undefined,
mobile: undefined,
telephone: undefined,
email: undefined,
remark: undefined,
status: 0,
sort: 0,
taxNo: undefined,
taxPercent: undefined,
bankName: undefined,
bankAccount: undefined,
bankAddress: undefined,
companyType: undefined,
businessScale: undefined,
leadSourceType: undefined,
preferredProducts: undefined,
preferredPackaging: undefined,
deliveryCyclePrefer: undefined,
annualOrderNums: undefined,
annualOrderAmounts: undefined,
annualReceivedAmounts: undefined,
totalUnreceivedAmounts: undefined,
})
const formRules = {
name: [{ required: true, message: '客户名称不能为空' }],
}
const formRef = ref<FormInstance>()
// 状态开关
const statusEnabled = ref(true)
watch(statusEnabled, (val) => {
formData.value.status = val ? 0 : 1
})
watch(() => formData.value.status, (val) => {
statusEnabled.value = val === 0
})
/** 企业类型选项 */
const companyTypeOptions = [
{ value: 1, label: '餐饮' },
{ value: 2, label: '食品批发' },
{ value: 3, label: '制造' },
{ value: 4, label: '超市' },
{ value: 5, label: '其他' },
]
const companyTypeColumns = computed(() => [
companyTypeOptions.map(v => ({ value: v.value, label: v.label })),
])
function onCompanyTypeConfirm({ value }: any) {
formData.value.companyType = value?.[0]
}
/** 客户来源选项 */
const leadSourceTypeOptions = [
{ value: 1, label: '展会' },
{ value: 2, label: '地推' },
{ value: 3, label: '转介绍' },
{ value: 4, label: '官网' },
{ value: 5, label: '平台' },
{ value: 6, label: '电销' },
{ value: 7, label: '老客户' },
{ value: 99, label: '其他' },
]
const leadSourceTypeColumns = computed(() => [
leadSourceTypeOptions.map(v => ({ value: v.value, label: v.label })),
])
function onLeadSourceTypeConfirm({ value }: any) {
formData.value.leadSourceType = value?.[0]
}
/** 格式化整数 */
const formatInteger = (value?: string | number) => {
if (value === undefined || value === null || value === '') {
return ''
}
const num = Number(value)
if (Number.isNaN(num)) {
return String(value)
}
return String(Math.trunc(num))
}
/** 格式化金额 */
const formatAmount = (value?: string | number) => {
if (value === undefined || value === null || value === '') {
return ''
}
const num = Number(value)
if (Number.isNaN(num)) {
return String(value)
}
return num.toFixed(2)
}
/** 返回上一页 */
function handleBack() {
navigateBackPlus('/pages-erp/customer/index')
}
/** 加载详情 */
async function getDetail() {
if (!props.id) return
try {
toast.loading('加载中...')
formData.value = await getCustomer(props.id)
} finally {
toast.close()
}
}
/** 提交表单 */
async function handleSubmit() {
const { valid } = await formRef.value!.validate()
if (!valid) return
formLoading.value = true
try {
if (props.id) {
await updateCustomer(formData.value)
toast.success('修改成功')
} else {
await createCustomer(formData.value)
toast.success('新增成功')
}
setTimeout(() => {
handleBack()
}, 500)
} finally {
formLoading.value = false
}
}
/** 初始化 */
onMounted(() => {
getDetail()
})
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,260 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
title="客户管理"
left-arrow placeholder safe-area-inset-top fixed
@click-left="handleBack"
/>
<!-- 搜索组件 -->
<view @click="openSearchForm">
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
</view>
<!-- 客户列表 -->
<view class="px-24rpx">
<view
v-for="item in list"
:key="item.id"
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
@click="handleEdit(item)"
>
<view class="p-24rpx">
<!-- 头部名称 + 状态 -->
<view class="mb-16rpx flex items-center justify-between">
<view class="text-30rpx text-[#333] font-semibold">
{{ item.name || '-' }}
</view>
<view
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
:class="item.status === 0 ? 'bg-[#f6ffed] text-[#52c41a]' : 'bg-[#fff1f0] text-[#f5222d]'"
>
{{ item.status === 0 ? '正常' : '停用' }}
</view>
</view>
<!-- 联系人 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">联系人</text>
<text>{{ item.contact || '-' }}</text>
</view>
<!-- 手机号码 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">手机号码</text>
<text>{{ item.mobile || '-' }}</text>
</view>
<!-- 联系电话 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">联系电话</text>
<text>{{ item.telephone || '-' }}</text>
</view>
<!-- 备注 -->
<view class="flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">备注</text>
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.remark || '无备注' }}</text>
</view>
</view>
<!-- 操作按钮 -->
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
<wd-button
v-if="hasAccessByCodes(['erp:customer:update']) && item.name !== '-'"
size="small" type="primary" plain @click="handleEdit(item)"
>
编辑
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:customer:delete']) && item.name !== '-'"
size="small" type="error" plain @click="handleDelete(item.id!)"
>
删除
</wd-button>
</view>
</view>
<!-- 加载更多 -->
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
<wd-status-tip image="content" tip="暂无客户数据" />
</view>
<wd-loadmore
v-if="list.length > 0"
:state="loadMoreState"
@reload="loadMore"
/>
</view>
<!-- 新增按钮 -->
<wd-fab
v-if="hasAccessByCodes(['erp:customer:create'])"
position="right-bottom"
type="primary"
:expandable="false"
@click="handleAdd"
/>
<!-- 搜索弹窗 -->
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
<view class="yd-search-form-container">
<view class="yd-search-form-item">
<view class="yd-search-form-label">客户名称</view>
<wd-input v-model="searchForm.name" placeholder="请输入客户名称" clearable />
</view>
<view class="yd-search-form-item">
<view class="yd-search-form-label">手机号码</view>
<wd-input v-model="searchForm.mobile" placeholder="请输入手机号码" clearable />
</view>
<view class="yd-search-form-item">
<view class="yd-search-form-label">联系电话</view>
<wd-input v-model="searchForm.telephone" placeholder="请输入联系电话" clearable />
</view>
<view class="yd-search-form-actions">
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
</view>
</view>
</wd-popup>
</view>
</template>
<script lang="ts" setup>
import type { Customer } from '@/api/erp/customer'
import type { LoadMoreState } from '@/http/types'
import { onReachBottom } from '@dcloudio/uni-app'
import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { deleteCustomer, getCustomerPage } from '@/api/erp/customer'
import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
const { hasAccessByCodes } = useAccess()
const toast = useToast()
const total = ref(0)
const list = ref<Customer[]>([])
const loadMoreState = ref<LoadMoreState>('loading')
const queryParams = ref<Record<string, any>>({
pageNo: 1,
pageSize: 10,
})
// 搜索相关
const searchVisible = ref(false)
const searchForm = reactive({
name: undefined as string | undefined,
mobile: undefined as string | undefined,
telephone: undefined as string | undefined,
})
/** 打开搜索表单 */
function openSearchForm() {
searchVisible.value = true
}
/** 搜索条件 placeholder */
const searchPlaceholder = computed(() => {
const conditions: string[] = []
if (searchForm.name) conditions.push(`名称:${searchForm.name}`)
if (searchForm.mobile) conditions.push(`手机:${searchForm.mobile}`)
if (searchForm.telephone) conditions.push(`电话:${searchForm.telephone}`)
return conditions.length > 0 ? conditions.join(' | ') : '搜索客户'
})
/** 返回上一页 */
function handleBack() {
navigateBackPlus()
}
/** 查询客户列表 */
async function getList() {
loadMoreState.value = 'loading'
try {
const params = { ...queryParams.value }
const data = await getCustomerPage(params)
list.value = [...list.value, ...data.list]
total.value = data.total
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
} catch {
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
loadMoreState.value = 'error'
}
}
/** 搜索 */
function handleSearch() {
searchVisible.value = false
queryParams.value = {
...searchForm,
pageNo: 1,
pageSize: queryParams.value.pageSize,
}
list.value = []
getList()
}
/** 重置 */
function handleReset() {
searchForm.name = undefined
searchForm.mobile = undefined
searchForm.telephone = undefined
searchVisible.value = false
queryParams.value = { pageNo: 1, pageSize: 10 }
list.value = []
getList()
}
/** 加载更多 */
function loadMore() {
if (loadMoreState.value === 'finished') return
queryParams.value.pageNo++
getList()
}
/** 新增客户 */
function handleAdd() {
uni.navigateTo({ url: '/pages-erp/customer/form/index' })
}
/** 编辑 */
function handleEdit(item: Customer) {
if (item.name === '-') return
uni.navigateTo({ url: `/pages-erp/customer/form/index?id=${item.id}` })
}
/** 删除 */
function handleDelete(id: number) {
uni.showModal({
title: '提示',
content: '确定要删除该客户吗?',
success: async (res) => {
if (!res.confirm) return
try {
await deleteCustomer(id)
toast.success('删除成功')
list.value = []
queryParams.value.pageNo = 1
getList()
} catch {
// error handled by http
}
},
})
}
/** 触底加载更多 */
onReachBottom(() => {
loadMore()
})
/** 初始化 */
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
</style>

View File

@@ -0,0 +1,311 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
title="订单详情"
left-arrow placeholder safe-area-inset-top fixed
@click-left="handleBack"
/>
<view class="p-24rpx" :class="{ 'opacity-60': loading }">
<!-- 基本信息 -->
<view class="bg-white rounded-12rpx p-24rpx mb-24rpx">
<view class="text-32rpx font-semibold mb-24rpx text-[#333]">基本信息</view>
<view class="info-row">
<text class="info-label">订单单号</text>
<text class="info-value">{{ detail.no || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">客户</text>
<text class="info-value">{{ detail.customerName || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">订单时间</text>
<text class="info-value">{{ formatDate(detail.orderTime) || '-' }}</text>
</view>
<view class="info-row">
<text class="info-label">状态</text>
<view :class="getStatusClass(detail.status)">
{{ getStatusText(detail.status) }}
</view>
</view>
</view>
<!-- 付款信息 -->
<view class="bg-white rounded-12rpx p-24rpx mb-24rpx" v-if="detail.depositPrice || detail.paymentCondition">
<view class="text-32rpx font-semibold mb-24rpx text-[#333]">付款信息</view>
<view class="info-row" v-if="detail.paymentCondition">
<text class="info-label">付款条件</text>
<text class="info-value">{{ getPaymentConditionText(detail.paymentCondition) }}</text>
</view>
<view class="info-row" v-if="detail.paymentMethod">
<text class="info-label">付款方式</text>
<text class="info-value">{{ getPaymentMethodText(detail.paymentMethod) }}</text>
</view>
<view class="info-row" v-if="detail.depositPrice">
<text class="info-label">收取订金</text>
<text class="info-value text-[#409eff]">¥{{ formatPrice(detail.depositPrice) }}</text>
</view>
</view>
<!-- 产品清单 -->
<view class="bg-white rounded-12rpx p-24rpx mb-24rpx">
<view class="text-32rpx font-semibold mb-24rpx text-[#333]">产品清单</view>
<view
v-for="(item, index) in detail.items"
:key="index"
class="product-item"
>
<view class="flex justify-between items-center mb-8rpx">
<text class="text-28rpx font-medium">{{ item.productName }}</text>
</view>
<view class="flex justify-between text-24rpx text-[#999]">
<text>单价: ¥{{ formatPrice(item.unitPrice) }}</text>
<text>数量: {{ item.count }}</text>
<text class="text-[#409eff]">小计: ¥{{ formatPrice(item.totalPrice) }}</text>
</view>
</view>
<view v-if="!detail.items || detail.items.length === 0" class="text-center text-26rpx text-[#999] py-20rpx">
暂无产品
</view>
</view>
<!-- 金额汇总 -->
<view class="bg-white rounded-12rpx p-24rpx mb-24rpx">
<view class="text-32rpx font-semibold mb-24rpx text-[#333]">金额汇总</view>
<view class="info-row">
<text class="info-label">总数量</text>
<text class="info-value">{{ formatCount(detail.totalCount) }}</text>
</view>
<view class="info-row">
<text class="info-label">产品金额</text>
<text class="info-value">¥{{ formatPrice(detail.totalProductPrice) }}</text>
</view>
<view class="info-row" v-if="detail.discountPercent">
<text class="info-label">优惠率</text>
<text class="info-value">{{ detail.discountPercent }}%</text>
</view>
<view class="info-row" v-if="detail.discountPrice">
<text class="info-label">优惠金额</text>
<text class="info-value">-¥{{ formatPrice(detail.discountPrice) }}</text>
</view>
<view class="info-row total-row">
<text class="info-label">含税金额</text>
<text class="info-value text-[#409eff] text-36rpx">¥{{ formatPrice(detail.totalPrice) }}</text>
</view>
</view>
<!-- 其他信息 -->
<view class="bg-white rounded-12rpx p-24rpx mb-24rpx" v-if="detail.remark">
<view class="text-32rpx font-semibold mb-24rpx text-[#333]">备注</view>
<view class="text-26rpx text-[#666]">{{ detail.remark }}</view>
</view>
</view>
<!-- 底部操作按钮 -->
<view class="yd-detail-footer" v-if="detail.status === 10 && !detail.hasApprovalRecords">
<wd-button
v-if="hasAccessByCodes(['erp:sale-order:update'])"
type="primary" plain
@click="handleEdit"
>
编辑
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-order:update-status'])"
type="success"
@click="handleApprove"
>
审批
</wd-button>
</view>
</view>
</template>
<script lang="ts" setup>
import type { SaleOrder } from '@/api/erp/sale-order'
import { onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { getSaleOrder, updateSaleOrderStatus } from '@/api/erp/sale-order'
import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils'
const props = defineProps<{
id?: number | any
}>()
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
const { hasAccessByCodes } = useAccess()
const toast = useToast()
const loading = ref(false)
const detail = ref<Partial<SaleOrder>>({})
/** 返回上一页 */
function handleBack() {
navigateBackPlus('/pages-erp/sale-order/index')
}
/** 格式化日期 */
function formatDate(date: any) {
if (!date) return ''
const d = new Date(date)
const year = d.getFullYear()
const month = String(d.getMonth() + 1).padStart(2, '0')
const day = String(d.getDate()).padStart(2, '0')
return `${year}-${month}-${day}`
}
/** 格式化数量 */
function formatCount(count?: number) {
if (count === undefined || count === null) return '0'
return String(Math.trunc(count))
}
/** 格式化价格 */
function formatPrice(price?: number) {
if (price === undefined || price === null) return '0.00'
return Number(price).toFixed(2)
}
/** 获取状态样式 */
function getStatusClass(status?: number) {
switch (status) {
case 10:
return 'status-tag bg-[#fffbe6] text-[#faad14]'
case 20:
return 'status-tag bg-[#f6ffed] text-[#52c41a]'
default:
return 'status-tag bg-[#f5f5f5] text-[#999]'
}
}
/** 获取状态文本 */
function getStatusText(status?: number) {
switch (status) {
case 10:
return '未审核'
case 20:
return '已审核'
default:
return '-'
}
}
/** 获取付款条件文本 */
function getPaymentConditionText(condition?: number) {
const map: Record<number, string> = {
1: '款到发货',
2: '货到付款',
3: '月结',
}
return map[condition || 0] || '-'
}
/** 获取付款方式文本 */
function getPaymentMethodText(method?: number) {
const map: Record<number, string> = {
1: '现金',
2: '银行转账',
3: '微信支付',
4: '支付宝',
}
return map[method || 0] || '-'
}
/** 编辑 */
function handleEdit() {
uni.navigateTo({ url: `/pages-erp/sale-order/form/index?id=${props.id}` })
}
/** 审批 */
function handleApprove() {
uni.showModal({
title: '提示',
content: '确定审批该订单吗?',
success: async (res) => {
if (!res.confirm) return
try {
await updateSaleOrderStatus(props.id, 20)
toast.success('审批成功')
getDetail()
} catch {
// error handled by http
}
},
})
}
/** 加载详情 */
async function getDetail() {
if (!props.id) return
loading.value = true
try {
detail.value = await getSaleOrder(props.id)
} catch (e) {
toast.error('加载失败')
} finally {
loading.value = false
}
}
/** 初始化 */
onMounted(() => {
getDetail()
})
</script>
<style lang="scss" scoped>
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16rpx 0;
border-bottom: 1rpx solid #f5f5f5;
&:last-child {
border-bottom: none;
}
.info-label {
color: #999;
font-size: 28rpx;
flex-shrink: 0;
}
.info-value {
color: #333;
font-size: 28rpx;
text-align: right;
}
}
.total-row {
margin-top: 16rpx;
padding-top: 16rpx;
border-top: 2rpx solid #eee;
border-bottom: none;
}
.status-tag {
padding: 4rpx 16rpx;
border-radius: 8rpx;
font-size: 24rpx;
}
.product-item {
padding: 16rpx;
background: #fafafa;
border-radius: 8rpx;
margin-bottom: 12rpx;
&:last-child {
margin-bottom: 0;
}
}
</style>

View File

@@ -0,0 +1,423 @@
<template>
<view class="yd-page-container">
<wd-navbar
:title="getTitle"
left-arrow
placeholder
safe-area-inset-top
fixed
@click-left="handleBack"
/>
<view class="pb-180rpx">
<wd-form ref="formRef" :model="formData" :rules="formRules">
<wd-cell-group title="基本信息" border>
<wd-picker
v-model="formData.customerId"
label="客户"
label-width="180rpx"
prop="customerId"
:columns="customerColumns"
placeholder="请选择"
/>
<wd-datetime-picker
v-model="formData.orderTime"
type="date"
label="订单时间"
label-width="180rpx"
placeholder="请选择"
/>
<wd-picker
v-model="formData.saleUserId"
label="销售人员"
label-width="180rpx"
:columns="userColumns"
placeholder="请选择"
/>
</wd-cell-group>
<wd-cell-group title="付款信息" border>
<wd-picker
v-model="formData.paymentCondition"
label="付款条件"
label-width="180rpx"
:columns="paymentConditionColumns"
placeholder="请选择"
/>
<wd-picker
v-model="formData.paymentMethod"
label="付款方式"
label-width="180rpx"
:columns="paymentMethodColumns"
placeholder="请选择"
/>
<wd-picker
v-model="formData.accountId"
label="结算账户"
label-width="180rpx"
:columns="accountColumns"
placeholder="请选择"
/>
<wd-input
v-model="formData.depositPrice"
label="收取订金"
label-width="180rpx"
placeholder="请输入订金"
type="number"
clearable
/>
</wd-cell-group>
<wd-cell-group title="订单产品" border>
<view class="p-24rpx">
<view
v-for="(item, index) in formData.items"
:key="index"
class="mb-16rpx rounded-8rpx bg-gray-50 p-24rpx"
>
<view class="mb-12rpx flex items-center justify-between">
<text class="text-28rpx font-semibold">{{ item.productName || `产品${index + 1}` }}</text>
<wd-button size="small" type="error" plain @click="removeItem(index)">删除</wd-button>
</view>
<view class="mb-12rpx flex items-center">
<text class="w-140rpx text-24rpx text-gray-500">数量</text>
<wd-input
v-model="item.count"
type="number"
placeholder="数量"
clearable
@change="calculateTotal"
/>
</view>
<view class="mb-12rpx flex items-center">
<text class="w-140rpx text-24rpx text-gray-500">单价</text>
<wd-input
v-model="item.unitPrice"
type="number"
placeholder="单价"
clearable
@change="calculateTotal"
/>
</view>
<view class="flex items-center">
<text class="w-140rpx text-24rpx text-gray-500">小计</text>
<text class="text-28rpx text-[#409eff]">{{ formatPrice(calculateItemTotal(item)) }}</text>
</view>
</view>
<wd-button type="primary" plain block @click="showProductPicker = true">添加产品</wd-button>
</view>
</wd-cell-group>
<wd-cell-group title="优惠信息" border>
<wd-input
v-model="formData.discountPercent"
label="优惠率(%)"
label-width="180rpx"
placeholder="请输入优惠率"
type="number"
clearable
@change="calculateTotal"
/>
<wd-input
:model-value="formatPrice(formData.discountPrice || 0)"
label="收款优惠"
label-width="180rpx"
placeholder="自动计算"
disabled
/>
<wd-input
:model-value="formatPrice(formData.totalPrice || 0)"
label="优惠后金额"
label-width="180rpx"
placeholder="自动计算"
disabled
/>
</wd-cell-group>
<wd-cell-group title="其他信息" border>
<wd-textarea
v-model="formData.remark"
label="备注"
label-width="180rpx"
placeholder="请输入备注"
:maxlength="200"
show-word-limit
clearable
/>
</wd-cell-group>
</wd-form>
</view>
<view class="yd-detail-footer">
<wd-button type="primary" block :loading="formLoading" @click="handleSubmit">
保存
</wd-button>
</view>
<wd-popup v-model="showProductPicker" position="bottom" custom-style="height: 60%">
<view class="p-24rpx">
<view class="mb-24rpx flex items-center justify-between">
<text class="text-32rpx font-semibold">选择产品</text>
<wd-button size="small" @click="showProductPicker = false">关闭</wd-button>
</view>
<scroll-view scroll-y class="product-picker-list">
<view
v-for="product in productList"
:key="product.id"
class="product-picker-item"
:class="{ 'is-active': selectedProductId === product.id }"
@click="selectedProductId = product.id"
>
<view class="product-picker-item__main">
<text class="product-picker-item__name">{{ product.name }}</text>
<text class="product-picker-item__price">¥{{ formatPrice(product.salePrice) }}</text>
</view>
</view>
</scroll-view>
<wd-button type="primary" block class="mt-24rpx" @click="addProduct">确定添加</wd-button>
</view>
</wd-popup>
</view>
</template>
<script lang="ts" setup>
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
import type { SaleOrder, SaleOrderItem } from '@/api/erp/sale-order'
import { computed, onMounted, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { createSaleOrder, getSaleOrder, updateSaleOrder } from '@/api/erp/sale-order'
import { getProductSimpleList } from '@/api/erp/product'
import { getCustomerSimpleList } from '@/api/erp/customer'
import { getSimpleUserList } from '@/api/system/user'
import { getAccountSimpleList } from '@/api/erp/account'
import { navigateBackPlus } from '@/utils'
const props = defineProps<{
id?: number | any
}>()
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
const toast = useToast()
const getTitle = computed(() => (props.id ? '编辑订单' : '新增订单'))
const formLoading = ref(false)
const formRef = ref<FormInstance>()
const customerList = ref<any[]>([])
const userList = ref<any[]>([])
const productList = ref<any[]>([])
const accountList = ref<any[]>([])
const showProductPicker = ref(false)
const selectedProductId = ref<number>()
const formData = ref<SaleOrder>({
id: undefined,
customerId: undefined,
orderTime: Date.now(),
saleUserId: undefined,
paymentCondition: undefined,
paymentMethod: undefined,
accountId: undefined,
depositPrice: undefined,
discountPercent: undefined,
discountPrice: 0,
totalPrice: 0,
remark: undefined,
items: [],
})
const formRules = {
customerId: [{ required: true, message: '请选择客户' }],
}
const customerColumns = computed(() => customerList.value.map(v => ({ label: v.name, value: v.id })))
const userColumns = computed(() => userList.value.map(v => ({ label: v.nickname, value: v.id })))
const accountColumns = computed(() => accountList.value.map(v => ({ label: v.name, value: v.id })))
const paymentConditionOptions = [
{ label: '款到发货', value: 1 },
{ label: '货到付款', value: 2 },
{ label: '月结', value: 3 },
]
const paymentConditionColumns = computed(() => paymentConditionOptions.map(v => ({ label: v.label, value: v.value })))
const paymentMethodOptions = [
{ label: '现金', value: 1 },
{ label: '银行转账', value: 2 },
{ label: '微信支付', value: 3 },
{ label: '支付宝', value: 4 },
]
const paymentMethodColumns = computed(() => paymentMethodOptions.map(v => ({ label: v.label, value: v.value })))
function formatPrice(price?: number) {
if (price === undefined || price === null) return '0.00'
return Number(price).toFixed(2)
}
function calculateItemTotal(item: SaleOrderItem) {
const count = Number(item.count) || 0
const unitPrice = Number(item.unitPrice) || 0
return count * unitPrice
}
function calculateTotal() {
if (!formData.value.items || formData.value.items.length === 0) {
formData.value.totalPrice = 0
formData.value.discountPrice = 0
return
}
const total = formData.value.items.reduce((sum, item) => sum + calculateItemTotal(item), 0)
const discountPercent = Number(formData.value.discountPercent) || 0
formData.value.discountPrice = total * (discountPercent / 100)
formData.value.totalPrice = total - formData.value.discountPrice
}
function addProduct() {
const product = productList.value.find(p => p.id === selectedProductId.value)
if (!product) {
toast.warning('请选择产品')
return
}
const newItem: SaleOrderItem = {
productId: product.id,
productName: product.name,
count: 1,
unitPrice: product.salePrice || 0,
totalPrice: product.salePrice || 0,
}
formData.value.items = [...(formData.value.items || []), newItem]
selectedProductId.value = undefined
showProductPicker.value = false
calculateTotal()
}
function removeItem(index: number) {
formData.value.items?.splice(index, 1)
calculateTotal()
}
function handleBack() {
navigateBackPlus('/pages-erp/sale-order/index')
}
async function getDetail() {
if (!props.id) return
try {
toast.loading('加载中...')
formData.value = await getSaleOrder(props.id)
calculateTotal()
} finally {
toast.close()
}
}
async function loadOptions() {
const [customersResult, usersResult, productsResult, accountsResult] = await Promise.allSettled([
getCustomerSimpleList(),
getSimpleUserList(),
getProductSimpleList(),
getAccountSimpleList(),
])
customerList.value = customersResult.status === 'fulfilled' ? (customersResult.value || []) : []
userList.value = usersResult.status === 'fulfilled' ? (usersResult.value || []) : []
productList.value = productsResult.status === 'fulfilled' ? (productsResult.value || []) : []
accountList.value = accountsResult.status === 'fulfilled' ? (accountsResult.value || []) : []
if ([customersResult, usersResult, productsResult, accountsResult].some(result => result.status === 'rejected')) {
console.error('加载选项失败', {
customersResult,
usersResult,
productsResult,
accountsResult,
})
}
}
async function handleSubmit() {
const { valid } = await formRef.value!.validate()
if (!valid) return
if (!formData.value.items || formData.value.items.length === 0) {
toast.warning('请添加订单产品')
return
}
formLoading.value = true
try {
const submitData = { ...formData.value }
if (submitData.orderTime) {
submitData.orderTime = new Date(submitData.orderTime).getTime()
}
submitData.items = (submitData.items || []).map(item => ({
...item,
totalPrice: calculateItemTotal(item),
}))
if (props.id) {
await updateSaleOrder(submitData)
toast.success('修改成功')
} else {
await createSaleOrder(submitData)
toast.success('新增成功')
}
setTimeout(() => {
handleBack()
}, 500)
} finally {
formLoading.value = false
}
}
onMounted(async () => {
await loadOptions()
await getDetail()
})
</script>
<style lang="scss" scoped>
.product-picker-list {
max-height: 720rpx;
}
.product-picker-item {
padding: 24rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.product-picker-item.is-active {
background: #f0f7ff;
}
.product-picker-item__main {
display: flex;
align-items: center;
justify-content: space-between;
gap: 24rpx;
}
.product-picker-item__name {
flex: 1;
font-size: 28rpx;
color: #333;
}
.product-picker-item__price {
flex-shrink: 0;
font-size: 24rpx;
color: #999;
}
</style>

View File

@@ -0,0 +1,403 @@
<template>
<view class="yd-page-container">
<!-- 顶部导航栏 -->
<wd-navbar
title="销售订单"
left-arrow placeholder safe-area-inset-top fixed
@click-left="handleBack"
/>
<!-- 搜索组件 -->
<view @click="openSearchForm">
<wd-search :placeholder="searchPlaceholder" hide-cancel disabled />
</view>
<!-- 分类标签 -->
<view class="status-tabs">
<view
:class="['status-tabs__item', { 'is-active': queryParams.status === undefined }]"
@click="onStatusTabChange(undefined)"
>
全部
</view>
<view
:class="['status-tabs__item', { 'is-active': queryParams.status === 10 }]"
@click="onStatusTabChange(10)"
>
未审核
</view>
<view
:class="['status-tabs__item', { 'is-active': queryParams.status === 20 }]"
@click="onStatusTabChange(20)"
>
已审核
</view>
</view>
<!-- 订单列表 -->
<view class="px-24rpx">
<view
v-for="item in list"
:key="item.id"
class="mb-20rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
>
<view class="p-24rpx" @click="handleDetail(item)">
<!-- 头部单号 + 状态 -->
<view class="mb-16rpx flex items-center justify-between">
<view class="text-28rpx text-[#333] font-semibold">
{{ item.no || '-' }}
</view>
<view
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
:class="getStatusClass(item.status)"
>
{{ getStatusText(item.status) }}
</view>
</view>
<!-- 客户 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">客户</text>
<text>{{ item.customerName || '-' }}</text>
</view>
<!-- 产品 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">产品</text>
<text class="ml-16rpx line-clamp-1 text-right" style="max-width: 400rpx;">{{ item.productNames || '-' }}</text>
</view>
<!-- 订单时间 -->
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
<text class="text-[#999]">订单时间</text>
<text>{{ formatDate(item.orderTime) || '-' }}</text>
</view>
<!-- 数量统计 -->
<view class="flex justify-around pt-16rpx border-t border-[#f0f0f0]">
<view class="text-center">
<view class="text-28rpx font-semibold text-[#333]">{{ formatCount(item.totalCount) }}</view>
<view class="text-22rpx text-[#999]">总数量</view>
</view>
<view class="text-center">
<view class="text-28rpx font-semibold text-[#333]">{{ formatCount(item.outCount) }}</view>
<view class="text-22rpx text-[#999]">出库数</view>
</view>
<view class="text-center">
<view class="text-28rpx font-semibold text-[#409eff]">¥{{ formatPrice(item.totalPrice) }}</view>
<view class="text-22rpx text-[#999]">含税金额</view>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
<wd-button
size="small" plain @click="handleDetail(item)"
>
详情
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-order:update']) && item.status === 10 && !item.hasApprovalRecords"
size="small" type="primary" plain @click="handleEdit(item)"
>
编辑
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-order:update-status']) && item.status === 10"
size="small" type="success" plain @click="handleApprove(item.id)"
>
审批
</wd-button>
<wd-button
v-if="hasAccessByCodes(['erp:sale-order:delete']) && !item.hasApprovalRecords"
size="small" type="error" plain @click="handleDelete(item.id)"
>
删除
</wd-button>
</view>
</view>
<!-- 加载更多 -->
<view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
<wd-status-tip image="content" tip="暂无订单数据" />
</view>
<wd-loadmore
v-if="list.length > 0"
:state="loadMoreState"
@reload="loadMore"
/>
</view>
<!-- 新增按钮 -->
<wd-fab
v-if="hasAccessByCodes(['erp:sale-order:create'])"
position="right-bottom"
type="primary"
:expandable="false"
@click="handleAdd"
/>
<!-- 搜索弹窗 -->
<wd-popup v-model="searchVisible" position="top" @close="searchVisible = false">
<view class="yd-search-form-container">
<view class="yd-search-form-item">
<view class="yd-search-form-label">订单单号</view>
<wd-input v-model="searchForm.no" placeholder="请输入订单单号" clearable />
</view>
<view class="yd-search-form-actions">
<wd-button class="flex-1" plain @click="handleReset">重置</wd-button>
<wd-button class="flex-1" type="primary" @click="handleSearch">搜索</wd-button>
</view>
</view>
</wd-popup>
</view>
</template>
<script lang="ts" setup>
import type { SaleOrder } from '@/api/erp/sale-order'
import type { LoadMoreState } from '@/http/types'
import { onReachBottom } from '@dcloudio/uni-app'
import { computed, onMounted, reactive, ref } from 'vue'
import { useToast } from 'wot-design-uni'
import { deleteSaleOrder, getSaleOrderPage, updateSaleOrderStatus } from '@/api/erp/sale-order'
import { useAccess } from '@/hooks/useAccess'
import { navigateBackPlus } from '@/utils'
definePage({
style: {
navigationBarTitleText: '',
navigationStyle: 'custom',
},
})
/** 打开搜索表单 */
function openSearchForm() {
searchVisible.value = true
}
const { hasAccessByCodes } = useAccess()
const toast = useToast()
const total = ref(0)
const list = ref<SaleOrder[]>([])
const loadMoreState = ref<LoadMoreState>('loading')
const queryParams = ref<Record<string, any>>({
pageNo: 1,
pageSize: 10,
status: undefined as number | undefined,
})
// 搜索相关
const searchVisible = ref(false)
const searchForm = reactive({
no: undefined as string | undefined,
})
/** 搜索条件 placeholder */
const searchPlaceholder = computed(() => {
const conditions: string[] = []
if (searchForm.no) conditions.push(`单号:${searchForm.no}`)
return conditions.length > 0 ? conditions.join(' | ') : '搜索订单'
})
/** 返回上一页 */
function handleBack() {
navigateBackPlus()
}
/** 状态切换 */
function onStatusTabChange(status: number | undefined) {
queryParams.value.status = status
queryParams.value.pageNo = 1
list.value = []
getList()
}
/** 格式化日期 */
function formatDate(date?: string) {
if (!date) return '-'
return new Date(date).toLocaleDateString('zh-CN')
}
/** 格式化数量 */
function formatCount(count?: number) {
if (count === undefined || count === null) return '0'
return String(Math.trunc(count))
}
/** 格式化价格 */
function formatPrice(price?: number) {
if (price === undefined || price === null) return '0.00'
return Number(price).toFixed(2)
}
/** 获取状态样式 */
function getStatusClass(status?: number) {
switch (status) {
case 10:
return 'bg-[#fffbe6] text-[#faad14]'
case 20:
return 'bg-[#f6ffed] text-[#52c41a]'
default:
return 'bg-[#f5f5f5] text-[#999]'
}
}
/** 获取状态文本 */
function getStatusText(status?: number) {
switch (status) {
case 10:
return '未审核'
case 20:
return '已审核'
default:
return '-'
}
}
/** 查询订单列表 */
async function getList() {
loadMoreState.value = 'loading'
try {
const params = { ...queryParams.value }
const data = await getSaleOrderPage(params)
list.value = [...list.value, ...data.list]
total.value = data.total
loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
} catch {
queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
loadMoreState.value = 'error'
}
}
/** 搜索 */
function handleSearch() {
searchVisible.value = false
queryParams.value = {
...queryParams.value,
...searchForm,
pageNo: 1,
pageSize: queryParams.value.pageSize,
}
list.value = []
getList()
}
/** 重置 */
function handleReset() {
searchForm.no = undefined
searchVisible.value = false
queryParams.value = { pageNo: 1, pageSize: 10, status: queryParams.value.status }
list.value = []
getList()
}
/** 加载更多 */
function loadMore() {
if (loadMoreState.value === 'finished') return
queryParams.value.pageNo++
getList()
}
/** 新增订单 */
function handleAdd() {
uni.navigateTo({ url: '/pages-erp/sale-order/form/index' })
}
/** 编辑订单 */
function handleEdit(item: SaleOrder) {
uni.navigateTo({ url: `/pages-erp/sale-order/form/index?id=${item.id}` })
}
/** 查看详情 */
function handleDetail(item: SaleOrder) {
uni.navigateTo({ url: `/pages-erp/sale-order/detail/index?id=${item.id}` })
}
/** 审批 */
function handleApprove(id: number) {
uni.showModal({
title: '提示',
content: '确定审批该订单吗?',
success: async (res) => {
if (!res.confirm) return
try {
await updateSaleOrderStatus(id, 20)
toast.success('审批成功')
list.value = []
queryParams.value.pageNo = 1
getList()
} catch {
// error handled by http
}
},
})
}
/** 删除 */
function handleDelete(id: number) {
uni.showModal({
title: '提示',
content: '确定要删除该订单吗?',
success: async (res) => {
if (!res.confirm) return
try {
await deleteSaleOrder([id])
toast.success('删除成功')
list.value = []
queryParams.value.pageNo = 1
getList()
} catch {
// error handled by http
}
},
})
}
/** 触底加载更多 */
onReachBottom(() => {
loadMore()
})
/** 初始化 */
onMounted(() => {
getList()
})
</script>
<style lang="scss" scoped>
.status-tabs {
display: flex;
margin: 0 24rpx 16rpx;
background: #fff;
border-radius: 8rpx;
overflow: hidden;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.04);
&__item {
flex: 1;
text-align: center;
padding: 20rpx 0;
font-size: 28rpx;
color: #606266;
cursor: pointer;
transition: all 0.2s;
position: relative;
&.is-active {
color: #018d71;
font-weight: 600;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 25%;
width: 50%;
height: 4rpx;
background: #018d71;
border-radius: 2rpx;
}
}
&:not(:last-child) {
border-right: 1rpx solid #f0f0f0;
}
}
}
</style>

View File

@@ -88,6 +88,28 @@ const menuGroupsData: MenuGroup[] = [
},
],
},
{
key: 'sale',
name: '销售管理',
menus: [
{
key: 'customer',
name: '客户管理',
icon: 'user',
url: '/pages-erp/customer/index',
iconColor: '#1890ff',
permission: 'erp:customer:query',
},
{
key: 'saleOrder',
name: '销售订单',
icon: 'order',
url: '/pages-erp/sale-order/index',
iconColor: '#1890ff',
permission: 'erp:sale-order:query',
}
],
},
{
key: 'agri',
name: '农业溯源',