李红攀:V2.0.001小程序的采摘管理
This commit is contained in:
13
src/api/erp/box/index.ts
Normal file
13
src/api/erp/box/index.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { http } from '@/http/http'
|
||||||
|
|
||||||
|
/** 框管理记录 */
|
||||||
|
export interface Box {
|
||||||
|
id?: number
|
||||||
|
boxNumber: string
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取框管理分页列表(用于提取框编号) */
|
||||||
|
export function getBoxPage(params?: Record<string, any>) {
|
||||||
|
return http.get<{ list: Box[], total: number }>('/erp/box/page', { pageNo: 1, pageSize: 100, ...params })
|
||||||
|
}
|
||||||
13
src/api/erp/farming/index.ts
Normal file
13
src/api/erp/farming/index.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { http } from '@/http/http'
|
||||||
|
|
||||||
|
/** 田间管理记录 */
|
||||||
|
export interface FarmingManagement {
|
||||||
|
id?: number
|
||||||
|
code: string
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取田间管理分页列表(用于提取田间编号) */
|
||||||
|
export function getFarmingManagementPage(params?: Record<string, any>) {
|
||||||
|
return http.get<{ list: FarmingManagement[], total: number }>('/erp/farming-management/page', { pageNo: 1, pageSize: 100, ...params })
|
||||||
|
}
|
||||||
85
src/api/erp/pick-broccoli/index.ts
Normal file
85
src/api/erp/pick-broccoli/index.ts
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import type { PageParam, PageResult } from '@/http/types'
|
||||||
|
import { http } from '@/http/http'
|
||||||
|
|
||||||
|
/** 西兰花采摘记录信息 */
|
||||||
|
export interface PickBroccoli {
|
||||||
|
id?: number
|
||||||
|
pickCode?: string
|
||||||
|
userId?: number
|
||||||
|
userName?: string
|
||||||
|
fieldCode?: string
|
||||||
|
fieldName?: string
|
||||||
|
basketCode?: string
|
||||||
|
basketWeight?: number
|
||||||
|
licensePlate?: string
|
||||||
|
pickTime?: string
|
||||||
|
loadTime?: string
|
||||||
|
loaderId?: number
|
||||||
|
loaderName?: string
|
||||||
|
status?: number
|
||||||
|
unloadTime?: string
|
||||||
|
unloaderId?: number
|
||||||
|
unloaderName?: string
|
||||||
|
warehouseId?: string
|
||||||
|
warehouseName?: string
|
||||||
|
unloadBatch?: string
|
||||||
|
productId?: number
|
||||||
|
productName?: string
|
||||||
|
remark?: string
|
||||||
|
createTime?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取采摘记录分页列表 */
|
||||||
|
export function getPickBroccoliPage(params: PageParam) {
|
||||||
|
return http.get<PageResult<PickBroccoli>>('/erp/pick-broccoli/page', params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取采摘记录详情 */
|
||||||
|
export function getPickBroccoli(id: number) {
|
||||||
|
return http.get<PickBroccoli>(`/erp/pick-broccoli/get?id=${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建采摘记录 */
|
||||||
|
export function createPickBroccoli(data: PickBroccoli) {
|
||||||
|
return http.post<number>('/erp/pick-broccoli/create', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新采摘记录 */
|
||||||
|
export function updatePickBroccoli(data: PickBroccoli) {
|
||||||
|
return http.put<boolean>('/erp/pick-broccoli/update', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除采摘记录 */
|
||||||
|
export function deletePickBroccoli(id: number) {
|
||||||
|
return http.delete<boolean>(`/erp/pick-broccoli/delete?id=${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新采摘记录状态 */
|
||||||
|
export function updatePickBroccoliStatus(id: number, status: number) {
|
||||||
|
return http.put<boolean>(`/erp/pick-broccoli/update-status?id=${id}&status=${status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 装车操作 */
|
||||||
|
export function loadTruck(id: number, licensePlate: string, loaderId: number, loaderName: string) {
|
||||||
|
return http.put<boolean>(`/erp/pick-broccoli/load-truck?id=${id}&licensePlate=${licensePlate}&loaderId=${loaderId}&loaderName=${loaderName}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 卸车入库操作 */
|
||||||
|
export function unloadTruck(licensePlate: string, unloaderId: number, unloaderName: string, warehouseId: string, warehouseName: string) {
|
||||||
|
return http.put<boolean>(`/erp/pick-broccoli/unload-truck?licensePlate=${licensePlate}&unloaderId=${unloaderId}&unloaderName=${unloaderName}&warehouseId=${warehouseId}&warehouseName=${warehouseName}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取已装车车辆列表 */
|
||||||
|
export function getLoadedTrucks() {
|
||||||
|
return http.get<any[]>('/erp/pick-broccoli/list-loaded-trucks')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 卸车预览 */
|
||||||
|
export function getUnloadPreview(licensePlate: string) {
|
||||||
|
return http.get<any>(`/erp/pick-broccoli/unload-preview?licensePlate=${licensePlate}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 生成采摘编号 */
|
||||||
|
export function generatePickCode() {
|
||||||
|
return http.get<{ code: string }>('/erp/pick-broccoli/generate-code')
|
||||||
|
}
|
||||||
22
src/api/erp/product/index.ts
Normal file
22
src/api/erp/product/index.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { http } from '@/http/http'
|
||||||
|
|
||||||
|
/** 产品精简信息 */
|
||||||
|
export interface ProductSimple {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
barCode?: string
|
||||||
|
unitId?: number
|
||||||
|
unitName?: string
|
||||||
|
standard?: string
|
||||||
|
purchasePrice?: number
|
||||||
|
salePrice?: number
|
||||||
|
minPrice?: number
|
||||||
|
supplierId?: number
|
||||||
|
supplierName?: string
|
||||||
|
weight?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取产品精简列表 */
|
||||||
|
export function getProductSimpleList() {
|
||||||
|
return http.get<ProductSimple[]>('/erp/product/simple-list')
|
||||||
|
}
|
||||||
90
src/api/erp/purchase-order/index.ts
Normal file
90
src/api/erp/purchase-order/index.ts
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
import type { PageParam, PageResult } from '@/http/types'
|
||||||
|
import { http } from '@/http/http'
|
||||||
|
|
||||||
|
/** 采购订单项 */
|
||||||
|
export interface PurchaseOrderItem {
|
||||||
|
id?: number
|
||||||
|
productId: number
|
||||||
|
productUnitId: number
|
||||||
|
productPrice?: number
|
||||||
|
count: number
|
||||||
|
taxPercent?: number
|
||||||
|
taxPrice?: number
|
||||||
|
remark?: string
|
||||||
|
inCount?: number
|
||||||
|
returnCount?: number
|
||||||
|
supplierId?: number
|
||||||
|
supplierName?: string
|
||||||
|
productName?: string
|
||||||
|
productBarCode?: string
|
||||||
|
productUnitName?: string
|
||||||
|
stockCount?: number
|
||||||
|
productSpec?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 采购订单信息 */
|
||||||
|
export interface PurchaseOrder {
|
||||||
|
id?: number
|
||||||
|
no?: string
|
||||||
|
status?: number
|
||||||
|
supplierId?: number
|
||||||
|
supplierName?: string
|
||||||
|
accountId?: number
|
||||||
|
orderTime?: string
|
||||||
|
totalCount?: number
|
||||||
|
totalPrice?: number
|
||||||
|
totalProductPrice?: number
|
||||||
|
totalTaxPrice?: number
|
||||||
|
discountPercent?: number
|
||||||
|
discountPrice?: number
|
||||||
|
depositPrice?: number
|
||||||
|
fileUrl?: string
|
||||||
|
remark?: string
|
||||||
|
creator?: string
|
||||||
|
creatorName?: string
|
||||||
|
createTime?: string
|
||||||
|
items?: PurchaseOrderItem[]
|
||||||
|
productNames?: string
|
||||||
|
inCount?: number
|
||||||
|
returnCount?: number
|
||||||
|
auditorId?: number
|
||||||
|
auditorName?: string
|
||||||
|
purchaseRequisitionId?: number
|
||||||
|
purchaseRequisitionNo?: string
|
||||||
|
invoiceType?: number
|
||||||
|
invoiceTypeName?: string
|
||||||
|
freightPayer?: number
|
||||||
|
freightPayerName?: string
|
||||||
|
settlementMethod?: number
|
||||||
|
settlementMethodName?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取采购订单分页列表 */
|
||||||
|
export function getPurchaseOrderPage(params: PageParam) {
|
||||||
|
return http.get<PageResult<PurchaseOrder>>('/erp/purchase-order/page', params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取采购订单详情 */
|
||||||
|
export function getPurchaseOrder(id: number) {
|
||||||
|
return http.get<PurchaseOrder>(`/erp/purchase-order/get?id=${id}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 创建采购订单 */
|
||||||
|
export function createPurchaseOrder(data: PurchaseOrder) {
|
||||||
|
return http.post<number>('/erp/purchase-order/create', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新采购订单 */
|
||||||
|
export function updatePurchaseOrder(data: PurchaseOrder) {
|
||||||
|
return http.put<boolean>('/erp/purchase-order/update', data)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 更新采购订单状态 */
|
||||||
|
export function updatePurchaseOrderStatus(id: number, status: number) {
|
||||||
|
return http.put<boolean>(`/erp/purchase-order/update-status?id=${id}&status=${status}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除采购订单 */
|
||||||
|
export function deletePurchaseOrder(ids: number[]) {
|
||||||
|
return http.delete<boolean>(`/erp/purchase-order/delete?ids=${ids.join(',')}`)
|
||||||
|
}
|
||||||
12
src/api/erp/supplier/index.ts
Normal file
12
src/api/erp/supplier/index.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import { http } from '@/http/http'
|
||||||
|
|
||||||
|
/** 供应商精简信息 */
|
||||||
|
export interface SupplierSimple {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取供应商精简列表 */
|
||||||
|
export function getSupplierSimpleList() {
|
||||||
|
return http.get<SupplierSimple[]>('/erp/supplier/simple-list')
|
||||||
|
}
|
||||||
126
src/pages-erp/pick-broccoli/components/search-form.vue
Normal file
126
src/pages-erp/pick-broccoli/components/search-form.vue
Normal file
@@ -0,0 +1,126 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 搜索框入口 -->
|
||||||
|
<view @click="visible = true">
|
||||||
|
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 搜索弹窗 -->
|
||||||
|
<wd-popup v-model="visible" position="top" @close="visible = false">
|
||||||
|
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||||
|
<view class="yd-search-form-item">
|
||||||
|
<view class="yd-search-form-label">
|
||||||
|
采摘编号
|
||||||
|
</view>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.pickCode"
|
||||||
|
placeholder="请输入采摘编号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="yd-search-form-item">
|
||||||
|
<view class="yd-search-form-label">
|
||||||
|
采摘人员
|
||||||
|
</view>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.userName"
|
||||||
|
placeholder="请输入采摘人员姓名"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="yd-search-form-item">
|
||||||
|
<view class="yd-search-form-label">
|
||||||
|
状态
|
||||||
|
</view>
|
||||||
|
<wd-radio-group v-model="formData.status" shape="button">
|
||||||
|
<wd-radio :value="-1">
|
||||||
|
全部
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="1">
|
||||||
|
已采摘
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="2">
|
||||||
|
已装框
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="3">
|
||||||
|
已装车
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="4">
|
||||||
|
已入库
|
||||||
|
</wd-radio>
|
||||||
|
</wd-radio-group>
|
||||||
|
</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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, reactive, ref } from 'vue'
|
||||||
|
import { getNavbarHeight } from '@/utils'
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
search: [data: Record<string, any>]
|
||||||
|
reset: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const visible = ref(false)
|
||||||
|
const formData = reactive({
|
||||||
|
pickCode: undefined as string | undefined,
|
||||||
|
userName: undefined as string | undefined,
|
||||||
|
status: -1,
|
||||||
|
})
|
||||||
|
|
||||||
|
const statusMap: Record<number, string> = {
|
||||||
|
1: '已采摘',
|
||||||
|
2: '已装框',
|
||||||
|
3: '已装车',
|
||||||
|
4: '已入库',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索条件 placeholder 拼接 */
|
||||||
|
const placeholder = computed(() => {
|
||||||
|
const conditions: string[] = []
|
||||||
|
if (formData.pickCode) {
|
||||||
|
conditions.push(`编号:${formData.pickCode}`)
|
||||||
|
}
|
||||||
|
if (formData.userName) {
|
||||||
|
conditions.push(`人员:${formData.userName}`)
|
||||||
|
}
|
||||||
|
if (formData.status !== -1) {
|
||||||
|
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||||
|
}
|
||||||
|
return conditions.length > 0 ? conditions.join(' | ') : '搜索采摘记录'
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 搜索 */
|
||||||
|
function handleSearch() {
|
||||||
|
visible.value = false
|
||||||
|
const params: Record<string, any> = {}
|
||||||
|
if (formData.pickCode) {
|
||||||
|
params.pickCode = formData.pickCode
|
||||||
|
}
|
||||||
|
if (formData.userName) {
|
||||||
|
params.userName = formData.userName
|
||||||
|
}
|
||||||
|
if (formData.status !== -1) {
|
||||||
|
params.status = formData.status
|
||||||
|
}
|
||||||
|
emit('search', params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置 */
|
||||||
|
function handleReset() {
|
||||||
|
formData.pickCode = undefined
|
||||||
|
formData.userName = undefined
|
||||||
|
formData.status = -1
|
||||||
|
visible.value = false
|
||||||
|
emit('reset')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
237
src/pages-erp/pick-broccoli/detail/index.vue
Normal file
237
src/pages-erp/pick-broccoli/detail/index.vue
Normal file
@@ -0,0 +1,237 @@
|
|||||||
|
<template>
|
||||||
|
<view class="yd-page-container">
|
||||||
|
<!-- 顶部导航栏 -->
|
||||||
|
<wd-navbar
|
||||||
|
title="采摘记录详情"
|
||||||
|
left-arrow placeholder safe-area-inset-top fixed
|
||||||
|
@click-left="handleBack"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 详情内容 -->
|
||||||
|
<view v-if="formData">
|
||||||
|
<!-- 基本信息 -->
|
||||||
|
<wd-cell-group title="基本信息" border>
|
||||||
|
<wd-cell title="采摘编号" :value="formData.pickCode" />
|
||||||
|
<wd-cell title="状态">
|
||||||
|
<view
|
||||||
|
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||||
|
:class="getStatusClass(formData.status)"
|
||||||
|
>
|
||||||
|
{{ getStatusText(formData.status) }}
|
||||||
|
</view>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="关联产品" :value="formData.productName || '-'" />
|
||||||
|
<wd-cell title="采摘人员" :value="formData.userName || '-'" />
|
||||||
|
<wd-cell title="田间编号" :value="formData.fieldCode || '-'" />
|
||||||
|
<wd-cell title="采摘时间" :value="formatDate(formData.pickTime)" />
|
||||||
|
<wd-cell title="创建时间" :value="formatDate(formData.createTime)" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 采摘信息 -->
|
||||||
|
<wd-cell-group title="采摘信息" border>
|
||||||
|
<wd-cell title="框编号" :value="formData.basketCode || '-'" />
|
||||||
|
<wd-cell title="每筐重量" :value="formData.basketWeight ? `${formData.basketWeight} kg` : '-'" />
|
||||||
|
<wd-cell title="车牌号" :value="formData.licensePlate || '-'" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 装车信息 (status >= 3) -->
|
||||||
|
<wd-cell-group v-if="(formData.status ?? 0) >= 3" title="装车信息" border>
|
||||||
|
<wd-cell title="装车人员" :value="formData.loaderName || '-'" />
|
||||||
|
<wd-cell title="装车时间" :value="formatDate(formData.loadTime)" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 卸车入库信息 (status === 4) -->
|
||||||
|
<wd-cell-group v-if="formData.status === 4" title="卸车入库信息" border>
|
||||||
|
<wd-cell title="卸车人员" :value="formData.unloaderName || '-'" />
|
||||||
|
<wd-cell title="卸车时间" :value="formatDate(formData.unloadTime)" />
|
||||||
|
<wd-cell title="入库仓库" :value="formData.warehouseName || '-'" />
|
||||||
|
<wd-cell title="卸车批次号" :value="formData.unloadBatch || '-'" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 备注 -->
|
||||||
|
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||||
|
<wd-cell :value="formData.remark" />
|
||||||
|
</wd-cell-group>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 底部操作按钮 -->
|
||||||
|
<view class="yd-detail-footer">
|
||||||
|
<view class="yd-detail-footer-actions">
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && (formData?.status ?? 0) < 3"
|
||||||
|
class="flex-1" type="primary" @click="handleEdit"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && formData?.status === 1"
|
||||||
|
class="flex-1" type="success" @click="handleStatusUpdate(2, '装框')"
|
||||||
|
>
|
||||||
|
装框
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && formData?.status === 2"
|
||||||
|
class="flex-1" type="warning" @click="handleLoadTruck"
|
||||||
|
>
|
||||||
|
装车
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:delete']) && (formData?.status ?? 0) < 3"
|
||||||
|
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</wd-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
import { deletePickBroccoli, getPickBroccoli, loadTruck, updatePickBroccoliStatus } from '@/api/erp/pick-broccoli'
|
||||||
|
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 formData = ref<PickBroccoli>()
|
||||||
|
const deleting = ref(false)
|
||||||
|
|
||||||
|
/** 格式化日期 */
|
||||||
|
function formatDate(date?: string) {
|
||||||
|
if (!date) return '-'
|
||||||
|
return new Date(date).toLocaleString('zh-CN')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态文本 */
|
||||||
|
function getStatusText(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 1: return '已采摘'
|
||||||
|
case 2: return '已装框'
|
||||||
|
case 3: return '已装车'
|
||||||
|
case 4: return '已卸车入库'
|
||||||
|
default: return '未知'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态样式 */
|
||||||
|
function getStatusClass(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 1: return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||||
|
case 2: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||||
|
case 3: return 'bg-[#f9f0ff] text-[#722ed1]'
|
||||||
|
case 4: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||||
|
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回上一页 */
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackPlus('/pages-erp/pick-broccoli/index')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载详情 */
|
||||||
|
async function getDetail() {
|
||||||
|
if (!props.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
toast.loading('加载中...')
|
||||||
|
formData.value = await getPickBroccoli(props.id)
|
||||||
|
} finally {
|
||||||
|
toast.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑 */
|
||||||
|
function handleEdit() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-erp/pick-broccoli/form/index?id=${props.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 状态更新(装框) */
|
||||||
|
function handleStatusUpdate(status: number, text: string) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `确认将该记录状态更新为"${text}完成"吗?`,
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) return
|
||||||
|
try {
|
||||||
|
await updatePickBroccoliStatus(props.id, status)
|
||||||
|
toast.success(`${text}操作成功`)
|
||||||
|
getDetail()
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 装车操作 */
|
||||||
|
function handleLoadTruck() {
|
||||||
|
uni.showModal({
|
||||||
|
title: '装车',
|
||||||
|
content: '请输入车牌号',
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '车牌号',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm || !res.content) return
|
||||||
|
try {
|
||||||
|
await loadTruck(props.id, res.content, 0, '')
|
||||||
|
toast.success('装车操作成功')
|
||||||
|
getDetail()
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
function handleDelete() {
|
||||||
|
if (!props.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该采摘记录吗?',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
deleting.value = true
|
||||||
|
try {
|
||||||
|
await deletePickBroccoli(props.id)
|
||||||
|
toast.success('删除成功')
|
||||||
|
setTimeout(() => {
|
||||||
|
handleBack()
|
||||||
|
}, 500)
|
||||||
|
} finally {
|
||||||
|
deleting.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
|
getDetail()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
354
src/pages-erp/pick-broccoli/form/index.vue
Normal file
354
src/pages-erp/pick-broccoli/form/index.vue
Normal file
@@ -0,0 +1,354 @@
|
|||||||
|
<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.pickCode"
|
||||||
|
label="采摘编号"
|
||||||
|
label-width="180rpx"
|
||||||
|
prop="pickCode"
|
||||||
|
placeholder="自动生成"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
readonly
|
||||||
|
>
|
||||||
|
<template v-if="!props.id" #suffix>
|
||||||
|
<wd-button size="small" type="primary" @click="handleGenerateCode">
|
||||||
|
生成
|
||||||
|
</wd-button>
|
||||||
|
</template>
|
||||||
|
</wd-input>
|
||||||
|
<wd-cell title="采摘人员" title-width="180rpx" prop="userName" center>
|
||||||
|
<wd-picker
|
||||||
|
v-model="formData.userId"
|
||||||
|
:columns="userColumns"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择采摘人员"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
@confirm="onUserConfirm"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="关联产品" title-width="180rpx" prop="productName" center>
|
||||||
|
<wd-picker
|
||||||
|
v-model="formData.productId"
|
||||||
|
:columns="productColumns"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择产品"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
@confirm="onProductConfirm"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="田间编号" title-width="180rpx" prop="fieldCode" center>
|
||||||
|
<wd-picker
|
||||||
|
v-model="formData.fieldCode"
|
||||||
|
:columns="fieldColumns"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择田间编号"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 采摘信息 -->
|
||||||
|
<wd-cell-group title="采摘信息" border>
|
||||||
|
<wd-cell title="框编号" title-width="180rpx" prop="basketCode" center>
|
||||||
|
<wd-picker
|
||||||
|
v-model="formData.basketCode"
|
||||||
|
:columns="basketColumns"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择框编号"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.basketWeight"
|
||||||
|
label="每筐重量(kg)"
|
||||||
|
label-width="180rpx"
|
||||||
|
type="number"
|
||||||
|
placeholder="请输入每筐重量"
|
||||||
|
clearable
|
||||||
|
:disabled="isLoaded"
|
||||||
|
/>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.licensePlate"
|
||||||
|
label="车牌号"
|
||||||
|
label-width="180rpx"
|
||||||
|
clearable
|
||||||
|
placeholder="请输入车牌号"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
/>
|
||||||
|
<wd-cell title="采摘时间" title-width="180rpx" prop="pickTime" center>
|
||||||
|
<wd-datetime-picker
|
||||||
|
v-model="formData.pickTime"
|
||||||
|
type="datetime"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择采摘时间"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 状态信息(编辑时) -->
|
||||||
|
<wd-cell-group v-if="formData.id" title="状态信息" border>
|
||||||
|
<wd-cell title="当前状态" :value="getStatusText(formData.status)" />
|
||||||
|
<wd-cell v-if="formData.loadTime" title="装车时间" :value="formatDate(formData.loadTime)" />
|
||||||
|
<wd-cell v-if="formData.loaderName" title="装车人" :value="formData.loaderName" />
|
||||||
|
<wd-cell v-if="formData.unloadTime" title="卸车时间" :value="formatDate(formData.unloadTime)" />
|
||||||
|
<wd-cell v-if="formData.unloaderName" title="卸车人员" :value="formData.unloaderName" />
|
||||||
|
<wd-cell v-if="formData.warehouseName" title="仓库名称" :value="formData.warehouseName" />
|
||||||
|
<wd-cell v-if="formData.unloadBatch" title="卸车批次号" :value="formData.unloadBatch" />
|
||||||
|
</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
|
||||||
|
:disabled="isLoaded"
|
||||||
|
/>
|
||||||
|
</wd-cell-group>
|
||||||
|
</wd-form>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 底部保存按钮 -->
|
||||||
|
<view class="yd-detail-footer">
|
||||||
|
<wd-button
|
||||||
|
type="primary"
|
||||||
|
block
|
||||||
|
:loading="formLoading"
|
||||||
|
:disabled="isLoaded"
|
||||||
|
@click="handleSubmit"
|
||||||
|
>
|
||||||
|
保存
|
||||||
|
</wd-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||||
|
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||||
|
import type { User } from '@/api/system/user'
|
||||||
|
import type { ProductSimple } from '@/api/erp/product'
|
||||||
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
import { createPickBroccoli, generatePickCode, getPickBroccoli, updatePickBroccoli } from '@/api/erp/pick-broccoli'
|
||||||
|
import { getSimpleUserList } from '@/api/system/user'
|
||||||
|
import { getProductSimpleList } from '@/api/erp/product'
|
||||||
|
import { getFarmingManagementPage } from '@/api/erp/farming'
|
||||||
|
import { getBoxPage } from '@/api/erp/box'
|
||||||
|
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<PickBroccoli>({
|
||||||
|
id: undefined,
|
||||||
|
pickCode: '',
|
||||||
|
userId: undefined,
|
||||||
|
userName: '',
|
||||||
|
productId: undefined,
|
||||||
|
productName: '',
|
||||||
|
fieldCode: '',
|
||||||
|
basketCode: '',
|
||||||
|
basketWeight: undefined,
|
||||||
|
licensePlate: '',
|
||||||
|
pickTime: undefined,
|
||||||
|
status: 1,
|
||||||
|
remark: '',
|
||||||
|
})
|
||||||
|
const formRules = {
|
||||||
|
pickCode: [{ required: true, message: '采摘编号不能为空' }],
|
||||||
|
userName: [{ required: true, message: '采摘人员不能为空' }],
|
||||||
|
productName: [{ required: true, message: '关联产品不能为空' }],
|
||||||
|
fieldCode: [{ required: true, message: '田间编号不能为空' }],
|
||||||
|
basketCode: [{ required: true, message: '框编号不能为空' }],
|
||||||
|
pickTime: [{ required: true, message: '采摘时间不能为空' }],
|
||||||
|
}
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
const userList = ref<User[]>([])
|
||||||
|
const productList = ref<ProductSimple[]>([])
|
||||||
|
const fieldList = ref<string[]>([])
|
||||||
|
const basketList = ref<string[]>([])
|
||||||
|
|
||||||
|
/** 采摘人员下拉列 */
|
||||||
|
const userColumns = computed(() => [
|
||||||
|
userList.value.map(u => ({ value: u.id, label: u.nickname })),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 产品下拉列 */
|
||||||
|
const productColumns = computed(() => [
|
||||||
|
productList.value.map(p => ({ value: p.id, label: p.name })),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 田间编号下拉列 */
|
||||||
|
const fieldColumns = computed(() => [
|
||||||
|
fieldList.value.map(code => ({ value: code, label: code })),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 框编号下拉列 */
|
||||||
|
const basketColumns = computed(() => [
|
||||||
|
basketList.value.map(code => ({ value: code, label: code })),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 采摘人员选择回调 */
|
||||||
|
function onUserConfirm({ value }: any) {
|
||||||
|
const userId = value?.[0]
|
||||||
|
formData.value.userId = userId
|
||||||
|
const user = userList.value.find(u => u.id === userId)
|
||||||
|
if (user) {
|
||||||
|
formData.value.userName = user.nickname
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 产品选择回调 */
|
||||||
|
function onProductConfirm({ value }: any) {
|
||||||
|
const productId = value?.[0]
|
||||||
|
formData.value.productId = productId
|
||||||
|
const product = productList.value.find(p => p.id === productId)
|
||||||
|
if (product) {
|
||||||
|
formData.value.productName = product.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载下拉列表数据 */
|
||||||
|
async function loadDropdownData() {
|
||||||
|
try {
|
||||||
|
const [users, products, farmingResult, boxResult] = await Promise.all([
|
||||||
|
getSimpleUserList(),
|
||||||
|
getProductSimpleList(),
|
||||||
|
getFarmingManagementPage(),
|
||||||
|
getBoxPage(),
|
||||||
|
])
|
||||||
|
userList.value = users || []
|
||||||
|
productList.value = products || []
|
||||||
|
// 提取田间编号
|
||||||
|
const farmingList = farmingResult?.list || []
|
||||||
|
fieldList.value = [...new Set(farmingList.filter(f => f.code?.trim()).map(f => f.code))]
|
||||||
|
// 提取框编号
|
||||||
|
const boxList = boxResult?.list || []
|
||||||
|
basketList.value = boxList.filter(b => b.boxNumber?.trim()).map(b => b.boxNumber)
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 已装车状态时禁用所有字段 */
|
||||||
|
const isLoaded = computed(() => (formData.value.status ?? 0) >= 3)
|
||||||
|
|
||||||
|
/** 格式化日期 */
|
||||||
|
function formatDate(date?: string) {
|
||||||
|
if (!date) return '-'
|
||||||
|
return new Date(date).toLocaleString('zh-CN')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态文本 */
|
||||||
|
function getStatusText(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 1: return '已采摘'
|
||||||
|
case 2: return '已装框'
|
||||||
|
case 3: return '已装车'
|
||||||
|
case 4: return '已卸车入库'
|
||||||
|
default: return '未知'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回上一页 */
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackPlus('/pages-erp/pick-broccoli/index')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 生成采摘编号 */
|
||||||
|
async function handleGenerateCode() {
|
||||||
|
try {
|
||||||
|
const data = await generatePickCode()
|
||||||
|
if (data && data.code) {
|
||||||
|
formData.value.pickCode = data.code
|
||||||
|
} else {
|
||||||
|
// 前端生成备用编号
|
||||||
|
const d = new Date()
|
||||||
|
const y = d.getFullYear()
|
||||||
|
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(d.getDate()).padStart(2, '0')
|
||||||
|
const rnd = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||||
|
formData.value.pickCode = `CJXL${y}${m}${day}${rnd}`
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// 前端生成备用编号
|
||||||
|
const d = new Date()
|
||||||
|
const y = d.getFullYear()
|
||||||
|
const m = String(d.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(d.getDate()).padStart(2, '0')
|
||||||
|
const rnd = Math.floor(Math.random() * 1000000).toString().padStart(6, '0')
|
||||||
|
formData.value.pickCode = `CJXL${y}${m}${day}${rnd}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载详情 */
|
||||||
|
async function getDetail() {
|
||||||
|
if (!props.id) {
|
||||||
|
// 新增时自动生成编号
|
||||||
|
await handleGenerateCode()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formData.value = await getPickBroccoli(props.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
async function handleSubmit() {
|
||||||
|
const { valid } = await formRef.value!.validate()
|
||||||
|
if (!valid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
if (props.id) {
|
||||||
|
await updatePickBroccoli(formData.value)
|
||||||
|
toast.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await createPickBroccoli(formData.value)
|
||||||
|
toast.success('新增成功')
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
handleBack()
|
||||||
|
}, 500)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadDropdownData()
|
||||||
|
getDetail()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
331
src/pages-erp/pick-broccoli/index.vue
Normal file
331
src/pages-erp/pick-broccoli/index.vue
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
<template>
|
||||||
|
<view class="yd-page-container">
|
||||||
|
<!-- 顶部导航栏 -->
|
||||||
|
<wd-navbar
|
||||||
|
title="采摘管理"
|
||||||
|
left-arrow placeholder safe-area-inset-top fixed
|
||||||
|
@click-left="handleBack"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 搜索组件 -->
|
||||||
|
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||||
|
|
||||||
|
<!-- 采摘记录列表 -->
|
||||||
|
<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="handleCardClick(item)"
|
||||||
|
>
|
||||||
|
<view class="p-24rpx">
|
||||||
|
<!-- 头部:采摘编号 + 状态 -->
|
||||||
|
<view class="mb-16rpx flex items-center justify-between">
|
||||||
|
<view class="text-30rpx text-[#333] font-semibold">
|
||||||
|
{{ item.pickCode }}
|
||||||
|
</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.productName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 采摘人员 -->
|
||||||
|
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">采摘人员</text>
|
||||||
|
<text>{{ item.userName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 田间编号 -->
|
||||||
|
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">田间编号</text>
|
||||||
|
<text>{{ item.fieldCode || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 框编号 -->
|
||||||
|
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">框编号</text>
|
||||||
|
<text>{{ item.basketCode || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 重量 -->
|
||||||
|
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">重量</text>
|
||||||
|
<text class="font-semibold">{{ item.basketWeight || 0 }} kg</text>
|
||||||
|
</view>
|
||||||
|
<!-- 车牌号 -->
|
||||||
|
<view class="mb-8rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">车牌号</text>
|
||||||
|
<text>{{ item.licensePlate || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 采摘时间 -->
|
||||||
|
<view class="flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">采摘时间</text>
|
||||||
|
<text>{{ formatDate(item.pickTime) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && (item.status ?? 0) < 3"
|
||||||
|
size="small" type="primary" plain @click="handleEdit(item)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:query'])"
|
||||||
|
size="small" plain @click="handleDetail(item)"
|
||||||
|
>
|
||||||
|
详情
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && item.status === 1"
|
||||||
|
size="small" type="success" plain @click="handleStatusUpdate(item, 2, '装框')"
|
||||||
|
>
|
||||||
|
装框
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:update']) && item.status === 2"
|
||||||
|
size="small" type="warning" plain @click="handleLoadTruck(item)"
|
||||||
|
>
|
||||||
|
装车
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:pick-broccoli:delete']) && (item.status ?? 0) < 3"
|
||||||
|
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:pick-broccoli:create'])"
|
||||||
|
position="right-bottom"
|
||||||
|
type="primary"
|
||||||
|
:expandable="false"
|
||||||
|
@click="handleAdd"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PickBroccoli } from '@/api/erp/pick-broccoli'
|
||||||
|
import type { LoadMoreState } from '@/http/types'
|
||||||
|
import { onReachBottom } from '@dcloudio/uni-app'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
import { deletePickBroccoli, getPickBroccoliPage, loadTruck, updatePickBroccoliStatus } from '@/api/erp/pick-broccoli'
|
||||||
|
import { useAccess } from '@/hooks/useAccess'
|
||||||
|
import { navigateBackPlus } from '@/utils'
|
||||||
|
import SearchForm from './components/search-form.vue'
|
||||||
|
|
||||||
|
definePage({
|
||||||
|
style: {
|
||||||
|
navigationBarTitleText: '',
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const { hasAccessByCodes } = useAccess()
|
||||||
|
const toast = useToast()
|
||||||
|
const total = ref(0)
|
||||||
|
const list = ref<PickBroccoli[]>([])
|
||||||
|
const loadMoreState = ref<LoadMoreState>('loading')
|
||||||
|
const queryParams = ref<Record<string, any>>({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 格式化日期 */
|
||||||
|
function formatDate(date?: string) {
|
||||||
|
if (!date) return '-'
|
||||||
|
return new Date(date).toLocaleString('zh-CN')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态文本 */
|
||||||
|
function getStatusText(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 1: return '已采摘'
|
||||||
|
case 2: return '已装框'
|
||||||
|
case 3: return '已装车'
|
||||||
|
case 4: return '已入库'
|
||||||
|
default: return '未知'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态样式 */
|
||||||
|
function getStatusClass(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 1: return 'bg-[#e6f7ff] text-[#1890ff]'
|
||||||
|
case 2: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||||
|
case 3: return 'bg-[#f9f0ff] text-[#722ed1]'
|
||||||
|
case 4: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||||
|
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回上一页 */
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackPlus()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询采摘记录列表 */
|
||||||
|
async function getList() {
|
||||||
|
loadMoreState.value = 'loading'
|
||||||
|
try {
|
||||||
|
const params = { ...queryParams.value }
|
||||||
|
const data = await getPickBroccoliPage(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 handleQuery(data?: Record<string, any>) {
|
||||||
|
queryParams.value = {
|
||||||
|
...data,
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: queryParams.value.pageSize,
|
||||||
|
}
|
||||||
|
list.value = []
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function handleReset() {
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载更多 */
|
||||||
|
function loadMore() {
|
||||||
|
if (loadMoreState.value === 'finished') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
queryParams.value.pageNo++
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 刷新列表 */
|
||||||
|
function refreshList() {
|
||||||
|
list.value = []
|
||||||
|
queryParams.value.pageNo = 1
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 卡片点击 — 打开详情 */
|
||||||
|
function handleCardClick(item: PickBroccoli) {
|
||||||
|
handleDetail(item)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增采摘记录 */
|
||||||
|
function handleAdd() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages-erp/pick-broccoli/form/index',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看详情 */
|
||||||
|
function handleDetail(item: PickBroccoli) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-erp/pick-broccoli/detail/index?id=${item.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑 */
|
||||||
|
function handleEdit(item: PickBroccoli) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-erp/pick-broccoli/form/index?id=${item.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 状态更新(装框) */
|
||||||
|
function handleStatusUpdate(item: PickBroccoli, status: number, text: string) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `确认将该记录状态更新为"${text}完成"吗?`,
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) return
|
||||||
|
try {
|
||||||
|
await updatePickBroccoliStatus(item.id!, status)
|
||||||
|
toast.success(`${text}操作成功`)
|
||||||
|
refreshList()
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 装车操作 — 简易输入车牌号 + 装车人 */
|
||||||
|
function handleLoadTruck(item: PickBroccoli) {
|
||||||
|
// 小程序端用简化方式:直接输入车牌号
|
||||||
|
uni.showModal({
|
||||||
|
title: '装车',
|
||||||
|
content: '请输入车牌号',
|
||||||
|
editable: true,
|
||||||
|
placeholderText: '车牌号',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm || !res.content) return
|
||||||
|
try {
|
||||||
|
// 使用当前用户作为装车人(简化处理)
|
||||||
|
await loadTruck(item.id!, res.content, 0, '')
|
||||||
|
toast.success('装车操作成功')
|
||||||
|
refreshList()
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除 */
|
||||||
|
function handleDelete(id: number) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该采摘记录吗?',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) return
|
||||||
|
try {
|
||||||
|
await deletePickBroccoli(id)
|
||||||
|
toast.success('删除成功')
|
||||||
|
refreshList()
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 触底加载更多 */
|
||||||
|
onReachBottom(() => {
|
||||||
|
loadMore()
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
104
src/pages-erp/purchase-order/components/search-form.vue
Normal file
104
src/pages-erp/purchase-order/components/search-form.vue
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 搜索框入口 -->
|
||||||
|
<view @click="visible = true">
|
||||||
|
<wd-search :placeholder="placeholder" hide-cancel disabled />
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 搜索弹窗 -->
|
||||||
|
<wd-popup v-model="visible" position="top" @close="visible = false">
|
||||||
|
<view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
|
||||||
|
<view class="yd-search-form-item">
|
||||||
|
<view class="yd-search-form-label">
|
||||||
|
采购单编号
|
||||||
|
</view>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.no"
|
||||||
|
placeholder="请输入采购单编号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="yd-search-form-item">
|
||||||
|
<view class="yd-search-form-label">
|
||||||
|
采购状态
|
||||||
|
</view>
|
||||||
|
<wd-radio-group v-model="formData.status" shape="button">
|
||||||
|
<wd-radio :value="-1">
|
||||||
|
全部
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="10">
|
||||||
|
未审批
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="20">
|
||||||
|
已审批
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="30">
|
||||||
|
已驳回
|
||||||
|
</wd-radio>
|
||||||
|
</wd-radio-group>
|
||||||
|
</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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { computed, reactive, ref } from 'vue'
|
||||||
|
import { getNavbarHeight } from '@/utils'
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
search: [data: Record<string, any>]
|
||||||
|
reset: []
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const visible = ref(false)
|
||||||
|
const formData = reactive({
|
||||||
|
no: undefined as string | undefined,
|
||||||
|
status: -1,
|
||||||
|
})
|
||||||
|
|
||||||
|
const statusMap: Record<number, string> = {
|
||||||
|
10: '未审批',
|
||||||
|
20: '已审批',
|
||||||
|
30: '已驳回',
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索条件 placeholder 拼接 */
|
||||||
|
const placeholder = computed(() => {
|
||||||
|
const conditions: string[] = []
|
||||||
|
if (formData.no) {
|
||||||
|
conditions.push(`编号:${formData.no}`)
|
||||||
|
}
|
||||||
|
if (formData.status !== -1) {
|
||||||
|
conditions.push(`状态:${statusMap[formData.status] || formData.status}`)
|
||||||
|
}
|
||||||
|
return conditions.length > 0 ? conditions.join(' | ') : '搜索采购订单'
|
||||||
|
})
|
||||||
|
|
||||||
|
/** 搜索 */
|
||||||
|
function handleSearch() {
|
||||||
|
visible.value = false
|
||||||
|
const params: Record<string, any> = {}
|
||||||
|
if (formData.no) {
|
||||||
|
params.no = formData.no
|
||||||
|
}
|
||||||
|
if (formData.status !== -1) {
|
||||||
|
params.status = formData.status
|
||||||
|
}
|
||||||
|
emit('search', params)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置 */
|
||||||
|
function handleReset() {
|
||||||
|
formData.no = undefined
|
||||||
|
formData.status = -1
|
||||||
|
visible.value = false
|
||||||
|
emit('reset')
|
||||||
|
}
|
||||||
|
</script>
|
||||||
297
src/pages-erp/purchase-order/detail/index.vue
Normal file
297
src/pages-erp/purchase-order/detail/index.vue
Normal file
@@ -0,0 +1,297 @@
|
|||||||
|
<template>
|
||||||
|
<view class="yd-page-container">
|
||||||
|
<!-- 顶部导航栏 -->
|
||||||
|
<wd-navbar
|
||||||
|
title="采购订单详情"
|
||||||
|
left-arrow placeholder safe-area-inset-top fixed
|
||||||
|
@click-left="handleBack"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 详情内容 -->
|
||||||
|
<view v-if="formData">
|
||||||
|
<!-- 基本信息 -->
|
||||||
|
<wd-cell-group title="基本信息" border>
|
||||||
|
<wd-cell title="采购单编号" :value="formData.no" />
|
||||||
|
<wd-cell title="采购状态">
|
||||||
|
<view
|
||||||
|
class="rounded-8rpx px-16rpx py-4rpx text-24rpx"
|
||||||
|
:class="getStatusClass(formData.status)"
|
||||||
|
>
|
||||||
|
{{ getStatusText(formData.status) }}
|
||||||
|
</view>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="供应商" :value="formData.supplierName || '-'" />
|
||||||
|
<wd-cell title="下单时间" :value="formatDateTime(formData.orderTime)" />
|
||||||
|
<wd-cell title="创建人" :value="formData.creatorName || '-'" />
|
||||||
|
<wd-cell title="审核人" :value="formData.auditorName || '-'" />
|
||||||
|
<wd-cell title="创建时间" :value="formatDateTime(formData.createTime)" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 合同信息 -->
|
||||||
|
<wd-cell-group title="合同信息" border>
|
||||||
|
<wd-cell title="发票类别" :value="formData.invoiceTypeName || '-'" />
|
||||||
|
<wd-cell title="运费承担方" :value="formData.freightPayerName || '-'" />
|
||||||
|
<wd-cell title="结算方式" :value="formData.settlementMethodName || '-'" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 金额信息 -->
|
||||||
|
<wd-cell-group title="金额信息" border>
|
||||||
|
<wd-cell title="合计数量" :value="String(formData.totalCount || 0)" />
|
||||||
|
<wd-cell title="合计产品价格" :value="`¥${formData.totalProductPrice || 0}`" />
|
||||||
|
<wd-cell title="合计税额" :value="`¥${formData.totalTaxPrice || 0}`" />
|
||||||
|
<wd-cell title="优惠率" :value="`${formData.discountPercent || 0}%`" />
|
||||||
|
<wd-cell title="优惠金额" :value="`¥${formData.discountPrice || 0}`" />
|
||||||
|
<wd-cell title="定金金额" :value="`¥${formData.depositPrice || 0}`" />
|
||||||
|
<wd-cell title="最终合计价格">
|
||||||
|
<text class="text-[#f5222d] font-semibold">¥{{ formData.totalPrice || 0 }}</text>
|
||||||
|
</wd-cell>
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 入库/退货信息 -->
|
||||||
|
<wd-cell-group title="入库/退货" border>
|
||||||
|
<wd-cell title="入库数量" :value="String(formData.inCount || 0)" />
|
||||||
|
<wd-cell title="退货数量" :value="String(formData.returnCount || 0)" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 请购单信息 -->
|
||||||
|
<wd-cell-group v-if="formData.purchaseRequisitionNo" title="关联请购单" border>
|
||||||
|
<wd-cell title="请购单编号" :value="formData.purchaseRequisitionNo" />
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<!-- 订单明细 -->
|
||||||
|
<view class="mx-24rpx mt-24rpx">
|
||||||
|
<view class="mb-16rpx text-32rpx text-[#333] font-semibold">
|
||||||
|
订单明细({{ formData.items?.length || 0 }}项)
|
||||||
|
</view>
|
||||||
|
<view v-if="formData.items && formData.items.length > 0">
|
||||||
|
<view
|
||||||
|
v-for="(item, index) in formData.items"
|
||||||
|
:key="item.id || index"
|
||||||
|
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||||
|
>
|
||||||
|
<!-- 产品头部 -->
|
||||||
|
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-16rpx">
|
||||||
|
<view class="flex items-center">
|
||||||
|
<text class="text-28rpx text-[#333] font-semibold">{{ item.productName || '-' }}</text>
|
||||||
|
<text v-if="item.productBarCode" class="ml-12rpx text-22rpx text-[#999]">{{ item.productBarCode }}</text>
|
||||||
|
</view>
|
||||||
|
<text v-if="item.supplierName" class="text-24rpx text-[#1890ff]">{{ item.supplierName }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="p-24rpx">
|
||||||
|
<!-- 产品规格 -->
|
||||||
|
<view v-if="item.productSpec" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||||
|
<text class="mr-8rpx text-[#999]">规格:</text>
|
||||||
|
<text>{{ item.productSpec }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 单价 / 数量 / 单位 -->
|
||||||
|
<view class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||||
|
<view class="mr-24rpx flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">单价:</text>
|
||||||
|
<text class="text-[#f5222d]">¥{{ item.productPrice || 0 }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="mr-24rpx flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">数量:</text>
|
||||||
|
<text class="font-semibold">{{ item.count || 0 }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">单位:</text>
|
||||||
|
<text>{{ item.productUnitName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 税率 / 税额 -->
|
||||||
|
<view v-if="item.taxPercent" class="mb-12rpx flex items-center text-26rpx text-[#666]">
|
||||||
|
<view class="mr-24rpx flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">税率:</text>
|
||||||
|
<text>{{ item.taxPercent }}%</text>
|
||||||
|
</view>
|
||||||
|
<view class="flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">税额:</text>
|
||||||
|
<text>¥{{ item.taxPrice || 0 }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 入库 / 退货 / 库存 -->
|
||||||
|
<view class="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<view class="flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">入库:</text>
|
||||||
|
<text>{{ item.inCount || 0 }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">退货:</text>
|
||||||
|
<text>{{ item.returnCount || 0 }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="flex items-center">
|
||||||
|
<text class="mr-8rpx text-[#999]">库存:</text>
|
||||||
|
<text>{{ item.stockCount || 0 }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 备注 -->
|
||||||
|
<view v-if="item.remark" class="text-24rpx text-[#999]">
|
||||||
|
备注:{{ item.remark }}
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-else class="py-60rpx text-center text-28rpx text-[#999]">
|
||||||
|
暂无订单明细
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 备注 -->
|
||||||
|
<wd-cell-group v-if="formData.remark" title="备注" border>
|
||||||
|
<wd-cell :value="formData.remark" />
|
||||||
|
</wd-cell-group>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 底部操作按钮 -->
|
||||||
|
<view class="yd-detail-footer">
|
||||||
|
<view class="yd-detail-footer-actions">
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:update']) && formData?.status === 10"
|
||||||
|
class="flex-1" type="warning" @click="handleEdit"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && formData?.status === 10"
|
||||||
|
class="flex-1" type="success" @click="handleApprove"
|
||||||
|
>
|
||||||
|
审批
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:delete']) && formData?.status !== 20"
|
||||||
|
class="flex-1" type="error" :loading="deleting" @click="handleDelete"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</wd-button>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
import { deletePurchaseOrder, getPurchaseOrder, updatePurchaseOrderStatus } from '@/api/erp/purchase-order'
|
||||||
|
import { useAccess } from '@/hooks/useAccess'
|
||||||
|
import { navigateBackPlus } from '@/utils'
|
||||||
|
import { formatDateTime } from '@/utils/date'
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
id?: number | any
|
||||||
|
}>()
|
||||||
|
|
||||||
|
definePage({
|
||||||
|
style: {
|
||||||
|
navigationBarTitleText: '',
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const { hasAccessByCodes } = useAccess()
|
||||||
|
const toast = useToast()
|
||||||
|
const formData = ref<PurchaseOrder>()
|
||||||
|
const deleting = ref(false)
|
||||||
|
|
||||||
|
/** 获取状态文本 */
|
||||||
|
function getStatusText(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 10: return '未审批'
|
||||||
|
case 20: return '已审批'
|
||||||
|
case 30: return '已驳回'
|
||||||
|
default: return '未知'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态样式 */
|
||||||
|
function getStatusClass(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 10: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||||
|
case 20: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||||
|
case 30: return 'bg-[#fff1f0] text-[#f5222d]'
|
||||||
|
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回上一页 */
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackPlus('/pages-erp/purchase-order/index')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载详情 */
|
||||||
|
async function getDetail() {
|
||||||
|
if (!props.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
toast.loading('加载中...')
|
||||||
|
formData.value = await getPurchaseOrder(props.id)
|
||||||
|
} finally {
|
||||||
|
toast.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑操作 */
|
||||||
|
function handleEdit() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-erp/purchase-order/form/index?id=${props.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 审批操作 */
|
||||||
|
function handleApprove() {
|
||||||
|
if (!props.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要审批通过该采购订单吗?',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await updatePurchaseOrderStatus(props.id, 20)
|
||||||
|
toast.success('审批成功')
|
||||||
|
getDetail()
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除操作 */
|
||||||
|
function handleDelete() {
|
||||||
|
if (!props.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: '确定要删除该采购订单吗?',
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
deleting.value = true
|
||||||
|
try {
|
||||||
|
await deletePurchaseOrder([props.id])
|
||||||
|
toast.success('删除成功')
|
||||||
|
setTimeout(() => {
|
||||||
|
handleBack()
|
||||||
|
}, 500)
|
||||||
|
} finally {
|
||||||
|
deleting.value = false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
|
getDetail()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
412
src/pages-erp/purchase-order/form/index.vue
Normal file
412
src/pages-erp/purchase-order/form/index.vue
Normal file
@@ -0,0 +1,412 @@
|
|||||||
|
<template>
|
||||||
|
<view class="yd-page-container">
|
||||||
|
<!-- 顶部导航栏 -->
|
||||||
|
<wd-navbar
|
||||||
|
:title="getTitle"
|
||||||
|
left-arrow placeholder safe-area-inset-top fixed
|
||||||
|
@click-left="handleBack"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 表单区域 -->
|
||||||
|
<view>
|
||||||
|
<wd-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
|
<wd-cell-group title="基本信息" border>
|
||||||
|
<wd-cell title="供应商" title-width="180rpx" prop="supplierId" center>
|
||||||
|
<wd-picker
|
||||||
|
v-model="formData.supplierId"
|
||||||
|
:columns="supplierColumns"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择供应商"
|
||||||
|
@confirm="onSupplierConfirm"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="采购时间" title-width="180rpx" prop="orderTime" center>
|
||||||
|
<wd-datetime-picker
|
||||||
|
v-model="formData.orderTime"
|
||||||
|
type="datetime"
|
||||||
|
label=""
|
||||||
|
placeholder="请选择采购时间"
|
||||||
|
/>
|
||||||
|
</wd-cell>
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<wd-cell-group title="合同信息" border>
|
||||||
|
<wd-cell title="发票类别" title-width="180rpx" center>
|
||||||
|
<wd-radio-group v-model="formData.invoiceType" shape="button">
|
||||||
|
<wd-radio :value="1">
|
||||||
|
增值税普通发票
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="2">
|
||||||
|
增值税专用发票
|
||||||
|
</wd-radio>
|
||||||
|
</wd-radio-group>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="运费承担方" title-width="180rpx" center>
|
||||||
|
<wd-radio-group v-model="formData.freightPayer" shape="button">
|
||||||
|
<wd-radio :value="1">
|
||||||
|
卖方承担
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="2">
|
||||||
|
买方承担
|
||||||
|
</wd-radio>
|
||||||
|
</wd-radio-group>
|
||||||
|
</wd-cell>
|
||||||
|
<wd-cell title="结算方式" title-width="180rpx" center>
|
||||||
|
<wd-radio-group v-model="formData.settlementMethod" shape="button">
|
||||||
|
<wd-radio :value="1">
|
||||||
|
款到发货
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="2">
|
||||||
|
货到票到付款
|
||||||
|
</wd-radio>
|
||||||
|
<wd-radio :value="3">
|
||||||
|
预付部分货到付清
|
||||||
|
</wd-radio>
|
||||||
|
</wd-radio-group>
|
||||||
|
</wd-cell>
|
||||||
|
</wd-cell-group>
|
||||||
|
|
||||||
|
<wd-cell-group title="其他信息" border>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.discountPercent"
|
||||||
|
label="优惠率(%)"
|
||||||
|
label-width="180rpx"
|
||||||
|
type="number"
|
||||||
|
placeholder="请输入优惠率"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
<wd-input
|
||||||
|
v-model="formData.depositPrice"
|
||||||
|
label="定金金额"
|
||||||
|
label-width="180rpx"
|
||||||
|
type="number"
|
||||||
|
placeholder="请输入定金金额"
|
||||||
|
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="mx-24rpx mt-24rpx pb-180rpx">
|
||||||
|
<view class="mb-16rpx flex items-center justify-between">
|
||||||
|
<view class="text-32rpx text-[#333] font-semibold">
|
||||||
|
订单明细({{ formData.items?.length || 0 }}项)
|
||||||
|
</view>
|
||||||
|
<wd-button size="small" type="primary" @click="handleAddItem">
|
||||||
|
+ 添加产品
|
||||||
|
</wd-button>
|
||||||
|
</view>
|
||||||
|
<view
|
||||||
|
v-for="(item, index) in formData.items"
|
||||||
|
:key="index"
|
||||||
|
class="mb-16rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
|
||||||
|
>
|
||||||
|
<view class="flex items-center justify-between bg-[#f8f8f8] px-24rpx py-12rpx">
|
||||||
|
<text class="text-28rpx text-[#333] font-semibold">产品 #{{ index + 1 }} {{ item.productName || '' }}</text>
|
||||||
|
<wd-button size="small" type="error" plain @click="handleRemoveItem(index)">
|
||||||
|
删除
|
||||||
|
</wd-button>
|
||||||
|
</view>
|
||||||
|
<view class="p-24rpx">
|
||||||
|
<view class="mb-16rpx">
|
||||||
|
<text class="mb-8rpx block text-24rpx text-[#999]">选择产品</text>
|
||||||
|
<wd-picker
|
||||||
|
v-model="item.productId"
|
||||||
|
:columns="productColumns"
|
||||||
|
placeholder="请选择产品"
|
||||||
|
@confirm="(e: any) => onProductConfirm(e, index)"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<!-- 自动填充的产品信息(只读) -->
|
||||||
|
<view v-if="item.productId" class="mb-16rpx rounded-8rpx bg-[#f9f9f9] p-16rpx">
|
||||||
|
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||||
|
<text class="text-[#999]">规格</text>
|
||||||
|
<text class="text-[#333]">{{ item.productSpec || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||||
|
<text class="text-[#999]">单位</text>
|
||||||
|
<text class="text-[#333]">{{ item.productUnitName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="mb-8rpx flex justify-between text-24rpx">
|
||||||
|
<text class="text-[#999]">条码</text>
|
||||||
|
<text class="text-[#333]">{{ item.productBarCode || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<view class="flex justify-between text-24rpx">
|
||||||
|
<text class="text-[#999]">供应商</text>
|
||||||
|
<text class="text-[#333]">{{ item.supplierName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="mb-16rpx flex gap-16rpx">
|
||||||
|
<view class="flex-1">
|
||||||
|
<text class="mb-8rpx block text-24rpx text-[#999]">数量</text>
|
||||||
|
<wd-input
|
||||||
|
v-model="item.count"
|
||||||
|
type="number"
|
||||||
|
placeholder="数量"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="flex-1">
|
||||||
|
<text class="mb-8rpx block text-24rpx text-[#999]">单价(元)</text>
|
||||||
|
<wd-input
|
||||||
|
v-model="item.productPrice"
|
||||||
|
type="number"
|
||||||
|
placeholder="单价"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="mb-16rpx flex gap-16rpx">
|
||||||
|
<view class="flex-1">
|
||||||
|
<text class="mb-8rpx block text-24rpx text-[#999]">税率(%)</text>
|
||||||
|
<wd-input
|
||||||
|
v-model="item.taxPercent"
|
||||||
|
type="number"
|
||||||
|
placeholder="税率"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<view class="flex-1">
|
||||||
|
<text class="mb-8rpx block text-24rpx text-[#999]">金额</text>
|
||||||
|
<text class="block pt-16rpx text-28rpx text-[#333]">{{ calcTotalPrice(item) }}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view>
|
||||||
|
<text class="mb-8rpx block text-24rpx text-[#999]">备注</text>
|
||||||
|
<wd-input
|
||||||
|
v-model="item.remark"
|
||||||
|
placeholder="请输入备注"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view v-if="!formData.items?.length" class="py-60rpx text-center text-28rpx text-[#999]">
|
||||||
|
暂无产品,请点击“添加产品”按钮
|
||||||
|
</view>
|
||||||
|
</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 { PurchaseOrder, PurchaseOrderItem } from '@/api/erp/purchase-order'
|
||||||
|
import type { ProductSimple } from '@/api/erp/product'
|
||||||
|
import type { SupplierSimple } from '@/api/erp/supplier'
|
||||||
|
import { computed, onMounted, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
import { createPurchaseOrder, getPurchaseOrder, updatePurchaseOrder } from '@/api/erp/purchase-order'
|
||||||
|
import { getProductSimpleList } from '@/api/erp/product'
|
||||||
|
import { getSupplierSimpleList } from '@/api/erp/supplier'
|
||||||
|
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<PurchaseOrder>({
|
||||||
|
id: undefined,
|
||||||
|
supplierId: undefined,
|
||||||
|
orderTime: undefined,
|
||||||
|
discountPercent: undefined,
|
||||||
|
depositPrice: undefined,
|
||||||
|
invoiceType: undefined,
|
||||||
|
freightPayer: undefined,
|
||||||
|
settlementMethod: undefined,
|
||||||
|
remark: '',
|
||||||
|
items: [],
|
||||||
|
})
|
||||||
|
const formRules = {
|
||||||
|
supplierId: [{ required: true, message: '供应商不能为空' }],
|
||||||
|
orderTime: [{ required: true, message: '采购时间不能为空' }],
|
||||||
|
}
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
const supplierList = ref<SupplierSimple[]>([])
|
||||||
|
const productList = ref<ProductSimple[]>([])
|
||||||
|
|
||||||
|
/** 供应商下拉列 */
|
||||||
|
const supplierColumns = computed(() => [
|
||||||
|
supplierList.value.map(s => ({ value: s.id, label: s.name })),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 产品下拉列 */
|
||||||
|
const productColumns = computed(() => [
|
||||||
|
productList.value.map(p => ({ value: p.id, label: p.name })),
|
||||||
|
])
|
||||||
|
|
||||||
|
/** 供应商选择回调 */
|
||||||
|
function onSupplierConfirm({ value }: any) {
|
||||||
|
formData.value.supplierId = value?.[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 产品选择回调:自动填充规格/单位/条码/单价/供应商 */
|
||||||
|
function onProductConfirm({ value }: any, index: number) {
|
||||||
|
const productId = value?.[0]
|
||||||
|
if (formData.value.items && formData.value.items[index]) {
|
||||||
|
const item = formData.value.items[index]
|
||||||
|
item.productId = productId
|
||||||
|
const product = productList.value.find(p => p.id === productId)
|
||||||
|
if (product) {
|
||||||
|
item.productName = product.name
|
||||||
|
item.productSpec = product.standard || ''
|
||||||
|
item.productUnitName = product.unitName || ''
|
||||||
|
item.productUnitId = product.unitId as any
|
||||||
|
item.productBarCode = product.barCode || ''
|
||||||
|
item.productPrice = product.purchasePrice
|
||||||
|
item.supplierId = product.supplierId
|
||||||
|
item.supplierName = product.supplierName || ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 计算行项金额 */
|
||||||
|
function calcTotalPrice(item: PurchaseOrderItem) {
|
||||||
|
if (item.productPrice && item.count) {
|
||||||
|
const total = Number(item.productPrice) * Number(item.count)
|
||||||
|
return `¥${total.toFixed(2)}`
|
||||||
|
}
|
||||||
|
return '-'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载下拉列表数据 */
|
||||||
|
async function loadDropdownData() {
|
||||||
|
try {
|
||||||
|
const [suppliers, products] = await Promise.all([
|
||||||
|
getSupplierSimpleList(),
|
||||||
|
getProductSimpleList(),
|
||||||
|
])
|
||||||
|
supplierList.value = suppliers || []
|
||||||
|
productList.value = products || []
|
||||||
|
} catch {
|
||||||
|
// error handled by http
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回上一页 */
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackPlus('/pages-erp/purchase-order/index')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 添加订单明细行 */
|
||||||
|
function handleAddItem() {
|
||||||
|
if (!formData.value.items) {
|
||||||
|
formData.value.items = []
|
||||||
|
}
|
||||||
|
formData.value.items.push({
|
||||||
|
productId: undefined as any,
|
||||||
|
productName: undefined as any,
|
||||||
|
productUnitId: undefined as any,
|
||||||
|
productUnitName: undefined as any,
|
||||||
|
productPrice: undefined,
|
||||||
|
productSpec: undefined as any,
|
||||||
|
productBarCode: undefined as any,
|
||||||
|
count: 1 as any,
|
||||||
|
taxPercent: undefined,
|
||||||
|
supplierId: undefined,
|
||||||
|
supplierName: undefined as any,
|
||||||
|
remark: '',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 删除订单明细行 */
|
||||||
|
function handleRemoveItem(index: number) {
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定要删除第 ${index + 1} 项产品吗?`,
|
||||||
|
success: (res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
formData.value.items?.splice(index, 1)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载详情 */
|
||||||
|
async function getDetail() {
|
||||||
|
if (!props.id) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formData.value = await getPurchaseOrder(props.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
async function handleSubmit() {
|
||||||
|
const { valid } = await formRef.value!.validate()
|
||||||
|
if (!valid) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 校验订单明细
|
||||||
|
if (!formData.value.items || formData.value.items.length === 0) {
|
||||||
|
toast.warning('请至少添加一项产品明细')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for (let i = 0; i < formData.value.items.length; i++) {
|
||||||
|
const item = formData.value.items[i]
|
||||||
|
if (!item.productId) {
|
||||||
|
toast.warning(`第 ${i + 1} 项产品ID不能为空`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (!item.count) {
|
||||||
|
toast.warning(`第 ${i + 1} 项产品数量不能为空`)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
if (props.id) {
|
||||||
|
await updatePurchaseOrder(formData.value)
|
||||||
|
toast.success('修改成功')
|
||||||
|
} else {
|
||||||
|
await createPurchaseOrder(formData.value)
|
||||||
|
toast.success('新增成功')
|
||||||
|
}
|
||||||
|
setTimeout(() => {
|
||||||
|
handleBack()
|
||||||
|
}, 500)
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 */
|
||||||
|
onMounted(async () => {
|
||||||
|
await loadDropdownData()
|
||||||
|
getDetail()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
</style>
|
||||||
344
src/pages-erp/purchase-order/index.vue
Normal file
344
src/pages-erp/purchase-order/index.vue
Normal file
@@ -0,0 +1,344 @@
|
|||||||
|
<template>
|
||||||
|
<view class="yd-page-container">
|
||||||
|
<!-- 顶部导航栏 -->
|
||||||
|
<wd-navbar
|
||||||
|
title="采购订单"
|
||||||
|
left-arrow placeholder safe-area-inset-top fixed
|
||||||
|
@click-left="handleBack"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 搜索组件 -->
|
||||||
|
<SearchForm @search="handleQuery" @reset="handleReset" />
|
||||||
|
|
||||||
|
<!-- 状态快速筛选 -->
|
||||||
|
<view class="flex items-center overflow-hidden rounded-12rpx bg-white mx-24rpx mb-16rpx shadow-sm">
|
||||||
|
<view
|
||||||
|
v-for="tab in statusTabs"
|
||||||
|
:key="tab.value"
|
||||||
|
class="flex-1 py-20rpx text-center text-26rpx relative"
|
||||||
|
:class="activeStatus === tab.value ? 'text-[#1890ff] font-semibold' : 'text-[#666]'"
|
||||||
|
@click="handleQuickFilter(tab.value)"
|
||||||
|
>
|
||||||
|
{{ tab.label }}
|
||||||
|
<view
|
||||||
|
v-if="activeStatus === tab.value"
|
||||||
|
class="absolute bottom-0 left-1/4 w-1/2 h-4rpx rounded-2rpx bg-[#1890ff]"
|
||||||
|
/>
|
||||||
|
</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"
|
||||||
|
@click="handleCardClick(item)"
|
||||||
|
>
|
||||||
|
<view class="p-24rpx">
|
||||||
|
<!-- 头部:单号 + 状态 -->
|
||||||
|
<view class="mb-16rpx flex items-center justify-between">
|
||||||
|
<view class="text-30rpx 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.supplierName || '-' }}</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="mb-12rpx flex items-center justify-between text-26rpx text-[#666]">
|
||||||
|
<text class="text-[#999]">创建人</text>
|
||||||
|
<text>{{ item.creatorName || '-' }}</text>
|
||||||
|
</view>
|
||||||
|
<!-- 数量金额区域 -->
|
||||||
|
<view class="flex items-center justify-around mt-12rpx pt-16rpx border-t border-[#f0f0f0]">
|
||||||
|
<view class="text-center">
|
||||||
|
<view class="text-30rpx text-[#333] font-semibold">{{ item.totalCount || 0 }}</view>
|
||||||
|
<view class="text-22rpx text-[#999] mt-4rpx">总数量</view>
|
||||||
|
</view>
|
||||||
|
<view class="text-center">
|
||||||
|
<view class="text-30rpx text-[#52c41a] font-semibold">{{ item.inCount || 0 }}</view>
|
||||||
|
<view class="text-22rpx text-[#999] mt-4rpx">已入库</view>
|
||||||
|
</view>
|
||||||
|
<view class="text-center">
|
||||||
|
<view class="text-30rpx text-[#e6a23c] font-semibold">¥{{ item.totalPrice || 0 }}</view>
|
||||||
|
<view class="text-22rpx text-[#999] mt-4rpx">含税金额</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<!-- 操作按钮 -->
|
||||||
|
<view class="flex flex-wrap gap-12rpx px-24rpx pb-20rpx" @click.stop>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:query'])"
|
||||||
|
size="small" plain @click="handleDetail(item)"
|
||||||
|
>
|
||||||
|
详情
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:update']) && item.status !== 20"
|
||||||
|
size="small" type="primary" plain @click="handleEdit(item)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && item.status === 10"
|
||||||
|
size="small" type="success" plain @click="handleUpdateStatus(item.id!, 20)"
|
||||||
|
>
|
||||||
|
审批
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:update-status']) && item.status === 20"
|
||||||
|
size="small" type="error" plain @click="handleUpdateStatus(item.id!, 10)"
|
||||||
|
>
|
||||||
|
反审批
|
||||||
|
</wd-button>
|
||||||
|
<wd-button
|
||||||
|
v-if="hasAccessByCodes(['erp:purchase-order:delete']) && item.status !== 20"
|
||||||
|
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:purchase-order:create'])"
|
||||||
|
position="right-bottom"
|
||||||
|
type="primary"
|
||||||
|
:expandable="false"
|
||||||
|
@click="handleAdd"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import type { PurchaseOrder } from '@/api/erp/purchase-order'
|
||||||
|
import type { LoadMoreState } from '@/http/types'
|
||||||
|
import { onReachBottom } from '@dcloudio/uni-app'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
|
import { useToast } from 'wot-design-uni'
|
||||||
|
import { deletePurchaseOrder, getPurchaseOrderPage, updatePurchaseOrderStatus } from '@/api/erp/purchase-order'
|
||||||
|
import { useAccess } from '@/hooks/useAccess'
|
||||||
|
import { navigateBackPlus } from '@/utils'
|
||||||
|
import SearchForm from './components/search-form.vue'
|
||||||
|
|
||||||
|
definePage({
|
||||||
|
style: {
|
||||||
|
navigationBarTitleText: '',
|
||||||
|
navigationStyle: 'custom',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const { hasAccessByCodes } = useAccess()
|
||||||
|
const toast = useToast()
|
||||||
|
const total = ref(0)
|
||||||
|
const list = ref<PurchaseOrder[]>([])
|
||||||
|
const loadMoreState = ref<LoadMoreState>('loading')
|
||||||
|
const activeStatus = ref<number | undefined>(undefined)
|
||||||
|
const queryParams = ref<Record<string, any>>({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
})
|
||||||
|
|
||||||
|
const statusTabs = [
|
||||||
|
{ label: '全部', value: undefined },
|
||||||
|
{ label: '待审核', value: 10 },
|
||||||
|
{ label: '已审核', value: 20 },
|
||||||
|
]
|
||||||
|
|
||||||
|
/** 格式化日期 */
|
||||||
|
function formatDate(date?: string) {
|
||||||
|
if (!date) return '-'
|
||||||
|
return new Date(date).toLocaleDateString('zh-CN')
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态文本 */
|
||||||
|
function getStatusText(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 10: return '未审批'
|
||||||
|
case 20: return '已审批'
|
||||||
|
case 30: return '已驳回'
|
||||||
|
default: return '未知'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 获取状态样式 */
|
||||||
|
function getStatusClass(status?: number) {
|
||||||
|
switch (status) {
|
||||||
|
case 10: return 'bg-[#fff7e6] text-[#fa8c16]'
|
||||||
|
case 20: return 'bg-[#f6ffed] text-[#52c41a]'
|
||||||
|
case 30: return 'bg-[#fff1f0] text-[#f5222d]'
|
||||||
|
default: return 'bg-[#f5f5f5] text-[#999]'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 返回上一页 */
|
||||||
|
function handleBack() {
|
||||||
|
navigateBackPlus()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查询采购订单列表 */
|
||||||
|
async function getList() {
|
||||||
|
loadMoreState.value = 'loading'
|
||||||
|
try {
|
||||||
|
const params = { ...queryParams.value }
|
||||||
|
const data = await getPurchaseOrderPage(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 handleQuickFilter(status?: number) {
|
||||||
|
activeStatus.value = status
|
||||||
|
queryParams.value.status = status
|
||||||
|
queryParams.value.pageNo = 1
|
||||||
|
list.value = []
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery(data?: Record<string, any>) {
|
||||||
|
queryParams.value = {
|
||||||
|
...data,
|
||||||
|
status: activeStatus.value,
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: queryParams.value.pageSize,
|
||||||
|
}
|
||||||
|
list.value = []
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function handleReset() {
|
||||||
|
activeStatus.value = undefined
|
||||||
|
handleQuery()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 加载更多 */
|
||||||
|
function loadMore() {
|
||||||
|
if (loadMoreState.value === 'finished') {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
queryParams.value.pageNo++
|
||||||
|
getList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 卡片点击 — 已审核打开详情,未审核打开编辑 */
|
||||||
|
function handleCardClick(item: PurchaseOrder) {
|
||||||
|
if (item.status === 20) {
|
||||||
|
handleDetail(item)
|
||||||
|
} else if (item.status === 10) {
|
||||||
|
handleEdit(item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 新增采购订单 */
|
||||||
|
function handleAdd() {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: '/pages-erp/purchase-order/form/index',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 查看详情 */
|
||||||
|
function handleDetail(item: PurchaseOrder) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-erp/purchase-order/detail/index?id=${item.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 编辑 */
|
||||||
|
function handleEdit(item: PurchaseOrder) {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages-erp/purchase-order/form/index?id=${item.id}`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 审批/反审批 */
|
||||||
|
function handleUpdateStatus(id: number, status: number) {
|
||||||
|
const text = status === 20 ? '审批' : '反审批'
|
||||||
|
uni.showModal({
|
||||||
|
title: '提示',
|
||||||
|
content: `确定${text}该订单吗?`,
|
||||||
|
success: async (res) => {
|
||||||
|
if (!res.confirm) return
|
||||||
|
try {
|
||||||
|
await updatePurchaseOrderStatus(id, status)
|
||||||
|
toast.success(`${text}成功`)
|
||||||
|
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 deletePurchaseOrder([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>
|
||||||
@@ -26,6 +26,28 @@ export interface MenuGroup {
|
|||||||
|
|
||||||
/** 菜单分组原始数据 */
|
/** 菜单分组原始数据 */
|
||||||
const menuGroupsData: MenuGroup[] = [
|
const menuGroupsData: MenuGroup[] = [
|
||||||
|
{
|
||||||
|
key: 'purchase',
|
||||||
|
name: '采购管理',
|
||||||
|
menus: [
|
||||||
|
{
|
||||||
|
key: 'purchaseOrder',
|
||||||
|
name: '采购订单',
|
||||||
|
icon: 'order',
|
||||||
|
url: '/pages-erp/purchase-order/index',
|
||||||
|
iconColor: '#1890ff',
|
||||||
|
permission: 'erp:purchase-order:query',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'pickBroccoli',
|
||||||
|
name: '采摘管理',
|
||||||
|
icon: 'goods',
|
||||||
|
url: '/pages-erp/pick-broccoli/index',
|
||||||
|
iconColor: '#52c41a',
|
||||||
|
permission: 'erp:pick-broccoli:query',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
key: 'system',
|
key: 'system',
|
||||||
name: '系统管理',
|
name: '系统管理',
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
'src/pages-system', // “系统管理”模块
|
'src/pages-system', // “系统管理”模块
|
||||||
'src/pages-infra', // “基础设施”模块
|
'src/pages-infra', // “基础设施”模块
|
||||||
'src/pages-bpm', // “工作流程”模块
|
'src/pages-bpm', // “工作流程”模块
|
||||||
|
'src/pages-erp', // “采购管理”模块
|
||||||
],
|
],
|
||||||
dts: 'src/types/uni-pages.d.ts',
|
dts: 'src/types/uni-pages.d.ts',
|
||||||
}),
|
}),
|
||||||
|
|||||||
Reference in New Issue
Block a user