✨ ERP:初始化采购订单 50%
This commit is contained in:
parent
eae2ea0a82
commit
600892b112
64
src/api/erp/purchase/order/index.ts
Normal file
64
src/api/erp/purchase/order/index.ts
Normal file
@ -0,0 +1,64 @@
|
||||
import request from '@/config/axios'
|
||||
|
||||
// ERP 采购订单 VO
|
||||
export interface PurchaseOrderVO {
|
||||
id: number // 订单工单编号
|
||||
no: string // 采购订单号
|
||||
customerId: number // 客户编号
|
||||
orderTime: Date // 订单时间
|
||||
totalCount: number // 合计数量
|
||||
totalPrice: number // 合计金额,单位:元
|
||||
status: number // 状态
|
||||
remark: string // 备注
|
||||
outCount: number // 采购出库数量
|
||||
returnCount: number // 采购退货数量
|
||||
}
|
||||
|
||||
// ERP 采购订单 API
|
||||
export const PurchaseOrderApi = {
|
||||
// 查询采购订单分页
|
||||
getPurchaseOrderPage: async (params: any) => {
|
||||
return await request.get({ url: `/erp/purchase-order/page`, params })
|
||||
},
|
||||
|
||||
// 查询采购订单详情
|
||||
getPurchaseOrder: async (id: number) => {
|
||||
return await request.get({ url: `/erp/purchase-order/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增采购订单
|
||||
createPurchaseOrder: async (data: PurchaseOrderVO) => {
|
||||
return await request.post({ url: `/erp/purchase-order/create`, data })
|
||||
},
|
||||
|
||||
// 修改采购订单
|
||||
updatePurchaseOrder: async (data: PurchaseOrderVO) => {
|
||||
return await request.put({ url: `/erp/purchase-order/update`, data })
|
||||
},
|
||||
|
||||
// 更新采购订单的状态
|
||||
updatePurchaseOrderStatus: async (id: number, status: number) => {
|
||||
return await request.put({
|
||||
url: `/erp/purchase-order/update-status`,
|
||||
params: {
|
||||
id,
|
||||
status
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 删除采购订单
|
||||
deletePurchaseOrder: async (ids: number[]) => {
|
||||
return await request.delete({
|
||||
url: `/erp/purchase-order/delete`,
|
||||
params: {
|
||||
ids: ids.join(',')
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
// 导出采购订单 Excel
|
||||
exportPurchaseOrder: async (params: any) => {
|
||||
return await request.download({ url: `/erp/purchase-order/export-excel`, params })
|
||||
}
|
||||
}
|
289
src/views/erp/purchase/order/SaleOrderForm.vue
Normal file
289
src/views/erp/purchase/order/SaleOrderForm.vue
Normal file
@ -0,0 +1,289 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1080">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
:disabled="disabled"
|
||||
>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="订单单号" prop="no">
|
||||
<el-input disabled v-model="formData.no" placeholder="保存时自动生成" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="订单时间" prop="orderTime">
|
||||
<el-date-picker
|
||||
v-model="formData.orderTime"
|
||||
type="date"
|
||||
value-format="x"
|
||||
placeholder="选择订单时间"
|
||||
class="!w-1/1"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="客户" prop="customerId">
|
||||
<el-select
|
||||
v-model="formData.customerId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择客户"
|
||||
class="!w-1/1"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in customerList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="销售人员" prop="saleUserId">
|
||||
<el-select
|
||||
v-model="formData.saleUserId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择销售人员"
|
||||
class="!w-1/1"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in userList"
|
||||
:key="item.id"
|
||||
:label="item.nickname"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="16">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="formData.remark"
|
||||
:rows="1"
|
||||
placeholder="请输入备注"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="附件" prop="fileUrl">
|
||||
<UploadFile :is-show-tip="false" v-model="formData.fileUrl" :limit="1" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<!-- 子表的表单 -->
|
||||
<ContentWrap>
|
||||
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
|
||||
<el-tab-pane label="订单产品清单" name="item">
|
||||
<SaleOrderItemForm ref="itemFormRef" :items="formData.items" :disabled="disabled" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</ContentWrap>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="8">
|
||||
<el-form-item label="优惠率(%)" prop="discountPercent">
|
||||
<el-input-number
|
||||
v-model="formData.discountPercent"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入优惠率"
|
||||
class="!w-1/1"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="收款优惠" prop="discountPrice">
|
||||
<el-input
|
||||
disabled
|
||||
v-model="formData.discountPrice"
|
||||
:formatter="erpPriceInputFormatter"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="优惠后金额">
|
||||
<el-input disabled v-model="formData.totalPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="结算账户" prop="accountId">
|
||||
<el-select
|
||||
v-model="formData.accountId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择结算账户"
|
||||
class="!w-1/1"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in accountList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="收取订金" prop="depositPrice">
|
||||
<el-input-number
|
||||
v-model="formData.depositPrice"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
placeholder="请输入收取订金"
|
||||
class="!w-1/1"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading" v-if="!disabled">
|
||||
确 定
|
||||
</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
|
||||
import SaleOrderItemForm from './components/SaleOrderItemForm.vue'
|
||||
import { CustomerApi, CustomerVO } from '@/api/erp/sale/customer'
|
||||
import { AccountApi, AccountVO } from '@/api/erp/finance/account'
|
||||
import { erpPriceInputFormatter, erpPriceMultiply } from '@/utils'
|
||||
import * as UserApi from '@/api/system/user'
|
||||
|
||||
/** ERP 销售订单表单 */
|
||||
defineOptions({ name: 'SaleOrderForm' })
|
||||
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改;detail - 详情
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
customerId: undefined,
|
||||
accountId: undefined,
|
||||
saleUserId: undefined,
|
||||
orderTime: undefined,
|
||||
remark: undefined,
|
||||
fileUrl: '',
|
||||
discountPercent: 0,
|
||||
discountPrice: 0,
|
||||
totalPrice: 0,
|
||||
depositPrice: 0,
|
||||
items: [],
|
||||
no: undefined // 订单单号,后端返回
|
||||
})
|
||||
const formRules = reactive({
|
||||
customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
|
||||
orderTime: [{ required: true, message: '订单时间不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const disabled = computed(() => formType.value === 'detail')
|
||||
const formRef = ref() // 表单 Ref
|
||||
const customerList = ref<CustomerVO[]>([]) // 客户列表
|
||||
const accountList = ref<AccountVO[]>([]) // 账户列表
|
||||
const userList = ref<UserApi.UserVO[]>([]) // 用户列表
|
||||
|
||||
/** 子表的表单 */
|
||||
const subTabsName = ref('item')
|
||||
const itemFormRef = ref()
|
||||
|
||||
/** 计算 discountPrice、totalPrice 价格 */
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
if (!val) {
|
||||
return
|
||||
}
|
||||
const totalPrice = val.items.reduce((prev, curr) => prev + curr.totalPrice, 0)
|
||||
const discountPrice =
|
||||
val.discountPercent != null ? erpPriceMultiply(totalPrice, val.discountPercent / 100.0) : 0
|
||||
formData.value.discountPrice = discountPrice
|
||||
formData.value.totalPrice = totalPrice - discountPrice
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = t('action.' + type)
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await SaleOrderApi.getSaleOrder(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
// 加载客户列表
|
||||
customerList.value = await CustomerApi.getCustomerSimpleList()
|
||||
// 加载用户列表
|
||||
userList.value = await UserApi.getSimpleUserList()
|
||||
// 加载账户列表
|
||||
accountList.value = await AccountApi.getAccountSimpleList()
|
||||
const defaultAccount = accountList.value.find((item) => item.defaultStatus)
|
||||
if (defaultAccount) {
|
||||
formData.value.accountId = defaultAccount.id
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
await formRef.value.validate()
|
||||
await itemFormRef.value.validate()
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as SaleOrderVO
|
||||
if (formType.value === 'create') {
|
||||
await SaleOrderApi.createSaleOrder(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await SaleOrderApi.updateSaleOrder(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
customerId: undefined,
|
||||
accountId: undefined,
|
||||
saleUserId: undefined,
|
||||
orderTime: undefined,
|
||||
remark: undefined,
|
||||
fileUrl: undefined,
|
||||
discountPercent: 0,
|
||||
discountPrice: 0,
|
||||
totalPrice: 0,
|
||||
depositPrice: 0,
|
||||
items: []
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
271
src/views/erp/purchase/order/components/SaleOrderItemForm.vue
Normal file
271
src/views/erp/purchase/order/components/SaleOrderItemForm.vue
Normal file
@ -0,0 +1,271 @@
|
||||
<template>
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
v-loading="formLoading"
|
||||
label-width="0px"
|
||||
:inline-message="true"
|
||||
:disabled="disabled"
|
||||
>
|
||||
<el-table :data="formData" show-summary :summary-method="getSummaries" class="-mt-10px">
|
||||
<el-table-column label="序号" type="index" align="center" width="60" />
|
||||
<el-table-column label="产品名称" min-width="180">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
|
||||
<el-select
|
||||
v-model="row.productId"
|
||||
clearable
|
||||
filterable
|
||||
@change="onChangeProduct($event, row)"
|
||||
placeholder="请选择产品"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存" min-width="100">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.stockCount" :formatter="erpCountInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="条码" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productBarCode" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" min-width="80">
|
||||
<template #default="{ row }">
|
||||
<el-form-item class="mb-0px!">
|
||||
<el-input disabled v-model="row.productUnitName" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" prop="count" fixed="right" min-width="140">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
|
||||
<el-input-number
|
||||
v-model="row.count"
|
||||
controls-position="right"
|
||||
:min="0.001"
|
||||
:precision="3"
|
||||
class="!w-100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="产品单价" fixed="right" min-width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.productPrice`" class="mb-0px!">
|
||||
<el-input-number
|
||||
v-model="row.productPrice"
|
||||
controls-position="right"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
class="!w-100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="金额" prop="totalProductPrice" fixed="right" min-width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.totalProductPrice`" class="mb-0px!">
|
||||
<el-input
|
||||
disabled
|
||||
v-model="row.totalProductPrice"
|
||||
:formatter="erpPriceInputFormatter"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税率(%)" fixed="right" min-width="115">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.taxPercent`" class="mb-0px!">
|
||||
<el-input-number
|
||||
v-model="row.taxPercent"
|
||||
controls-position="right"
|
||||
:min="0.01"
|
||||
:precision="2"
|
||||
class="!w-100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税额" prop="taxPrice" fixed="right" min-width="120">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
|
||||
<el-form-item :prop="`${$index}.taxPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.taxPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="税额合计" prop="totalPrice" fixed="right" min-width="100">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
|
||||
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" min-width="150">
|
||||
<template #default="{ row, $index }">
|
||||
<el-form-item :prop="`${$index}.remark`" class="mb-0px!">
|
||||
<el-input v-model="row.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" fixed="right" label="操作" width="60">
|
||||
<template #default="{ $index }">
|
||||
<el-button @click="handleDelete($index)" link>—</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-form>
|
||||
<el-row justify="center" class="mt-3" v-if="!disabled">
|
||||
<el-button @click="handleAdd" round>+ 添加入库产品</el-button>
|
||||
</el-row>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
||||
import { StockApi } from '@/api/erp/stock/stock'
|
||||
import {
|
||||
erpCountInputFormatter,
|
||||
erpPriceInputFormatter,
|
||||
erpPriceMultiply,
|
||||
getSumValue
|
||||
} from '@/utils'
|
||||
|
||||
const props = defineProps<{
|
||||
items: undefined
|
||||
disabled: false
|
||||
}>()
|
||||
const formLoading = ref(false) // 表单的加载中
|
||||
const formData = ref([])
|
||||
const formRules = reactive({
|
||||
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
|
||||
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref([]) // 表单 Ref
|
||||
const productList = ref<ProductVO[]>([]) // 产品列表
|
||||
|
||||
/** 初始化设置入库项 */
|
||||
watch(
|
||||
() => props.items,
|
||||
async (val) => {
|
||||
formData.value = val
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
/** 监听合同产品变化,计算合同产品总价 */
|
||||
watch(
|
||||
() => formData.value,
|
||||
(val) => {
|
||||
if (!val || val.length === 0) {
|
||||
return
|
||||
}
|
||||
// 循环处理
|
||||
val.forEach((item) => {
|
||||
item.totalProductPrice = erpPriceMultiply(item.productPrice, item.count)
|
||||
item.taxPrice = erpPriceMultiply(item.totalProductPrice, item.taxPercent / 100.0)
|
||||
if (item.totalProductPrice != null) {
|
||||
item.totalPrice = item.totalProductPrice + (item.taxPrice || 0)
|
||||
} else {
|
||||
item.totalPrice = undefined
|
||||
}
|
||||
})
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
/** 合计 */
|
||||
const getSummaries = (param: SummaryMethodProps) => {
|
||||
const { columns, data } = param
|
||||
const sums: string[] = []
|
||||
columns.forEach((column, index: number) => {
|
||||
if (index === 0) {
|
||||
sums[index] = '合计'
|
||||
return
|
||||
}
|
||||
if (['count', 'totalProductPrice', 'taxPrice', 'totalPrice'].includes(column.property)) {
|
||||
const sum = getSumValue(data.map((item) => Number(item[column.property])))
|
||||
sums[index] =
|
||||
column.property === 'count' ? erpCountInputFormatter(sum) : erpPriceInputFormatter(sum)
|
||||
} else {
|
||||
sums[index] = ''
|
||||
}
|
||||
})
|
||||
|
||||
return sums
|
||||
}
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
const row = {
|
||||
id: undefined,
|
||||
productId: undefined,
|
||||
productUnitName: undefined, // 产品单位
|
||||
productBarCode: undefined, // 产品条码
|
||||
productPrice: undefined,
|
||||
stockCount: undefined,
|
||||
count: 1,
|
||||
totalProductPrice: undefined,
|
||||
taxPercent: undefined,
|
||||
taxPrice: undefined,
|
||||
totalPrice: undefined,
|
||||
remark: undefined
|
||||
}
|
||||
formData.value.push(row)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = (index: number) => {
|
||||
formData.value.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 处理产品变更 */
|
||||
const onChangeProduct = (productId, row) => {
|
||||
const product = productList.value.find((item) => item.id === productId)
|
||||
if (product) {
|
||||
row.productUnitName = product.unitName
|
||||
row.productBarCode = product.barCode
|
||||
row.productPrice = product.salePrice
|
||||
}
|
||||
// 加载库存
|
||||
setStockCount(row)
|
||||
}
|
||||
|
||||
/** 加载库存 */
|
||||
const setStockCount = async (row: any) => {
|
||||
if (!row.productId) {
|
||||
return
|
||||
}
|
||||
const count = await StockApi.getStockCount(row.productId)
|
||||
row.stockCount = count || 0
|
||||
}
|
||||
|
||||
/** 表单校验 */
|
||||
const validate = () => {
|
||||
return formRef.value.validate()
|
||||
}
|
||||
defineExpose({ validate })
|
||||
|
||||
/** 初始化 */
|
||||
onMounted(async () => {
|
||||
productList.value = await ProductApi.getProductSimpleList()
|
||||
// 默认添加一个
|
||||
if (formData.value.length === 0) {
|
||||
handleAdd()
|
||||
}
|
||||
})
|
||||
</script>
|
@ -0,0 +1,206 @@
|
||||
<!-- 可入库的订单列表 -->
|
||||
<template>
|
||||
<Dialog
|
||||
title="选择销售订单(仅展示可入库)"
|
||||
v-model="dialogVisible"
|
||||
:appendToBody="true"
|
||||
:scroll="true"
|
||||
width="1080"
|
||||
>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="订单单号" prop="no">
|
||||
<el-input
|
||||
v-model="queryParams.no"
|
||||
placeholder="请输入订单单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-160px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品" prop="productId">
|
||||
<el-select
|
||||
v-model="queryParams.productId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择产品"
|
||||
class="!w-160px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单时间" prop="orderTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.orderTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-160px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
|
||||
<el-table-column align="center" width="65">
|
||||
<template #default="scope">
|
||||
<el-radio
|
||||
:label="scope.row.id"
|
||||
v-model="currentRowValue"
|
||||
@change="handleCurrentChange(scope.row)"
|
||||
>
|
||||
|
||||
</el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column min-width="180" label="订单单号" align="center" prop="no" />
|
||||
<el-table-column label="客户" align="center" prop="customerName" />
|
||||
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
|
||||
<el-table-column
|
||||
label="订单时间"
|
||||
align="center"
|
||||
prop="orderTime"
|
||||
:formatter="dateFormatter2"
|
||||
width="120px"
|
||||
/>
|
||||
<el-table-column label="创建人" align="center" prop="creatorName" />
|
||||
<el-table-column
|
||||
label="总数量"
|
||||
align="center"
|
||||
prop="totalCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="入库数量"
|
||||
align="center"
|
||||
prop="outCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="金额合计"
|
||||
align="center"
|
||||
prop="totalProductPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="含税金额"
|
||||
align="center"
|
||||
prop="totalPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
<template #footer>
|
||||
<el-button :disabled="!currentRow" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ElTable } from 'element-plus'
|
||||
import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
|
||||
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
||||
|
||||
defineOptions({ name: 'ErpSaleOrderOutEnableList' })
|
||||
|
||||
const list = ref<SaleOrderVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined,
|
||||
productId: undefined,
|
||||
orderTime: [],
|
||||
outEnable: true
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const productList = ref<ProductVO[]>([]) // 产品列表
|
||||
|
||||
/** 选中行 */
|
||||
const currentRowValue = ref(undefined) // 选中行的 value
|
||||
const currentRow = ref(undefined) // 选中行
|
||||
const handleCurrentChange = (row) => {
|
||||
currentRow.value = row
|
||||
}
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async () => {
|
||||
dialogVisible.value = true
|
||||
await nextTick() // 等待,避免 queryFormRef 为空
|
||||
// 加载可入库的订单列表
|
||||
await resetQuery()
|
||||
// 加载产品列表
|
||||
productList.value = await ProductApi.getProductSimpleList()
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交选择 */
|
||||
const emits = defineEmits<{
|
||||
(e: 'success', value: SaleOrderVO): void
|
||||
}>()
|
||||
const submitForm = () => {
|
||||
try {
|
||||
emits('success', currentRow.value)
|
||||
} finally {
|
||||
// 关闭弹窗
|
||||
dialogVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await SaleOrderApi.getSaleOrderPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
currentRowValue.value = undefined
|
||||
currentRow.value = undefined
|
||||
getList()
|
||||
}
|
||||
</script>
|
@ -0,0 +1,212 @@
|
||||
<!-- 可退货的订单列表 -->
|
||||
<template>
|
||||
<Dialog
|
||||
title="选择销售订单(仅展示可退货)"
|
||||
v-model="dialogVisible"
|
||||
:appendToBody="true"
|
||||
:scroll="true"
|
||||
width="1080"
|
||||
>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="订单单号" prop="no">
|
||||
<el-input
|
||||
v-model="queryParams.no"
|
||||
placeholder="请输入订单单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-160px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品" prop="productId">
|
||||
<el-select
|
||||
v-model="queryParams.productId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择产品"
|
||||
class="!w-160px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单时间" prop="orderTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.orderTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-160px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
|
||||
<el-table-column align="center" width="65">
|
||||
<template #default="scope">
|
||||
<el-radio
|
||||
:label="scope.row.id"
|
||||
v-model="currentRowValue"
|
||||
@change="handleCurrentChange(scope.row)"
|
||||
>
|
||||
|
||||
</el-radio>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column min-width="180" label="订单单号" align="center" prop="no" />
|
||||
<el-table-column label="客户" align="center" prop="customerName" />
|
||||
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
|
||||
<el-table-column
|
||||
label="订单时间"
|
||||
align="center"
|
||||
prop="orderTime"
|
||||
:formatter="dateFormatter2"
|
||||
width="120px"
|
||||
/>
|
||||
<el-table-column label="创建人" align="center" prop="creatorName" />
|
||||
<el-table-column
|
||||
label="总数量"
|
||||
align="center"
|
||||
prop="totalCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="入库数量"
|
||||
align="center"
|
||||
prop="outCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="退货数量"
|
||||
align="center"
|
||||
prop="returnCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="金额合计"
|
||||
align="center"
|
||||
prop="totalProductPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="含税金额"
|
||||
align="center"
|
||||
prop="totalPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
v-model:limit="queryParams.pageSize"
|
||||
v-model:page="queryParams.pageNo"
|
||||
:total="total"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
<template #footer>
|
||||
<el-button :disabled="!currentRow" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ElTable } from 'element-plus'
|
||||
import { SaleOrderApi, SaleOrderVO } from '@/api/erp/sale/order'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
|
||||
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
||||
|
||||
defineOptions({ name: 'SaleOrderReturnEnableList' })
|
||||
|
||||
const list = ref<SaleOrderVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined,
|
||||
productId: undefined,
|
||||
orderTime: [],
|
||||
returnEnable: true
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const productList = ref<ProductVO[]>([]) // 产品列表
|
||||
|
||||
/** 选中行 */
|
||||
const currentRowValue = ref(undefined) // 选中行的 value
|
||||
const currentRow = ref(undefined) // 选中行
|
||||
const handleCurrentChange = (row) => {
|
||||
currentRow.value = row
|
||||
}
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async () => {
|
||||
dialogVisible.value = true
|
||||
await nextTick() // 等待,避免 queryFormRef 为空
|
||||
// 加载可退货的订单列表
|
||||
await resetQuery()
|
||||
// 加载产品列表
|
||||
productList.value = await ProductApi.getProductSimpleList()
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交选择 */
|
||||
const emits = defineEmits<{
|
||||
(e: 'success', value: SaleOrderVO): void
|
||||
}>()
|
||||
const submitForm = () => {
|
||||
try {
|
||||
emits('success', currentRow.value)
|
||||
} finally {
|
||||
// 关闭弹窗
|
||||
dialogVisible.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 加载列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await SaleOrderApi.getSaleOrderPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
currentRowValue.value = undefined
|
||||
currentRow.value = undefined
|
||||
getList()
|
||||
}
|
||||
</script>
|
405
src/views/erp/purchase/order/index.vue
Normal file
405
src/views/erp/purchase/order/index.vue
Normal file
@ -0,0 +1,405 @@
|
||||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="订单单号" prop="no">
|
||||
<el-input
|
||||
v-model="queryParams.no"
|
||||
placeholder="请输入订单单号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="产品" prop="productId">
|
||||
<el-select
|
||||
v-model="queryParams.productId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择产品"
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in productList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="订单时间" prop="orderTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.orderTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="供应商" prop="supplierId">
|
||||
<el-select
|
||||
v-model="queryParams.supplierId"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择供供应商"
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in supplierList"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建人" prop="creator">
|
||||
<el-select
|
||||
v-model="queryParams.creator"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择创建人"
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in userList"
|
||||
:key="item.id"
|
||||
:label="item.nickname"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.ERP_AUDIT_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input
|
||||
v-model="queryParams.remark"
|
||||
placeholder="请输入备注"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="入库数量" prop="outStatus">
|
||||
<el-select
|
||||
v-model="queryParams.outStatus"
|
||||
placeholder="请选择入库数量"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="未入库" value="0" />
|
||||
<el-option label="部分入库" value="1" />
|
||||
<el-option label="全部入库" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="退货数量" prop="returnStatus">
|
||||
<el-select
|
||||
v-model="queryParams.returnStatus"
|
||||
placeholder="请选择退货数量"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="未退货" value="0" />
|
||||
<el-option label="部分退货" value="1" />
|
||||
<el-option label="全部退货" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['erp:purchase-order:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['erp:purchase-order:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
@click="handleDelete(selectionList.map((item) => item.id))"
|
||||
v-hasPermi="['erp:purchase-order:delete']"
|
||||
:disabled="selectionList.length === 0"
|
||||
>
|
||||
<Icon icon="ep:delete" class="mr-5px" /> 删除
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column width="30" label="选择" type="selection" />
|
||||
<el-table-column min-width="180" label="订单单号" align="center" prop="no" />
|
||||
<el-table-column label="产品信息" align="center" prop="productNames" min-width="200" />
|
||||
<el-table-column label="供应商" align="center" prop="supplierName" />
|
||||
<el-table-column
|
||||
label="订单时间"
|
||||
align="center"
|
||||
prop="orderTime"
|
||||
:formatter="dateFormatter2"
|
||||
width="120px"
|
||||
/>
|
||||
<el-table-column label="创建人" align="center" prop="creatorName" />
|
||||
<el-table-column
|
||||
label="总数量"
|
||||
align="center"
|
||||
prop="totalCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="入库数量"
|
||||
align="center"
|
||||
prop="outCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="退货数量"
|
||||
align="center"
|
||||
prop="returnCount"
|
||||
:formatter="erpCountTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="金额合计"
|
||||
align="center"
|
||||
prop="totalProductPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="含税金额"
|
||||
align="center"
|
||||
prop="totalPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="收取订金"
|
||||
align="center"
|
||||
prop="depositPrice"
|
||||
:formatter="erpPriceTableColumnFormatter"
|
||||
/>
|
||||
<el-table-column label="状态" align="center" fixed="right" width="90" prop="status">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.ERP_AUDIT_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" fixed="right" width="220">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
@click="openForm('detail', scope.row.id)"
|
||||
v-hasPermi="['erp:purchase-order:query']"
|
||||
>
|
||||
详情
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['erp:purchase-order:update']"
|
||||
:disabled="scope.row.status === 20"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="handleUpdateStatus(scope.row.id, 20)"
|
||||
v-hasPermi="['erp:purchase-order:update-status']"
|
||||
v-if="scope.row.status === 10"
|
||||
>
|
||||
审批
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleUpdateStatus(scope.row.id, 10)"
|
||||
v-hasPermi="['erp:purchase-order:update-status']"
|
||||
v-else
|
||||
>
|
||||
反审批
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete([scope.row.id])"
|
||||
v-hasPermi="['erp:purchase-order:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<!-- <PurchaseOrderForm ref="formRef" @success="getList" />-->
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import { dateFormatter2 } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { PurchaseOrderApi, PurchaseOrderVO } from '@/api/erp/purchase/order'
|
||||
// import PurchaseOrderForm from './PurchaseOrderForm.vue'
|
||||
import { ProductApi, ProductVO } from '@/api/erp/product/product'
|
||||
import { UserVO } from '@/api/system/user'
|
||||
import * as UserApi from '@/api/system/user'
|
||||
import { erpCountTableColumnFormatter, erpPriceTableColumnFormatter } from '@/utils'
|
||||
import { SupplierApi, SupplierVO } from '@/api/erp/purchase/supplier'
|
||||
|
||||
/** ERP 销售订单列表 */
|
||||
defineOptions({ name: 'ErpPurchaseOrder' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const list = ref<PurchaseOrderVO[]>([]) // 列表的数据
|
||||
const total = ref(0) // 列表的总页数
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
no: undefined,
|
||||
supplierId: undefined,
|
||||
productId: undefined,
|
||||
orderTime: [],
|
||||
status: undefined,
|
||||
remark: undefined,
|
||||
creator: undefined,
|
||||
outStatus: undefined,
|
||||
returnStatus: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
const productList = ref<ProductVO[]>([]) // 产品列表
|
||||
const supplierList = ref<SupplierVO[]>([]) // 供应商列表
|
||||
const userList = ref<UserVO[]>([]) // 用户列表
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await PurchaseOrderApi.getPurchaseOrderPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (ids: number[]) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await PurchaseOrderApi.deletePurchaseOrder(ids)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
selectionList.value = selectionList.value.filter((item) => !ids.includes(item.id))
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 审批/反审批操作 */
|
||||
const handleUpdateStatus = async (id: number, status: number) => {
|
||||
try {
|
||||
// 审批的二次确认
|
||||
await message.confirm(`确定${status === 20 ? '审批' : '反审批'}该订单吗?`)
|
||||
// 发起审批
|
||||
await PurchaseOrderApi.updatePurchaseOrderStatus(id, status)
|
||||
message.success(`${status === 20 ? '审批' : '反审批'}成功`)
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
// 导出的二次确认
|
||||
await message.exportConfirm()
|
||||
// 发起导出
|
||||
exportLoading.value = true
|
||||
const data = await PurchaseOrderApi.exportPurchaseOrder(queryParams)
|
||||
download.excel(data, '销售订单.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 选中操作 */
|
||||
const selectionList = ref<PurchaseOrderVO[]>([])
|
||||
const handleSelectionChange = (rows: PurchaseOrderVO[]) => {
|
||||
selectionList.value = rows
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(async () => {
|
||||
await getList()
|
||||
// 加载产品、仓库列表、供应商
|
||||
productList.value = await ProductApi.getProductSimpleList()
|
||||
supplierList.value = await SupplierApi.getSupplierSimpleList()
|
||||
userList.value = await UserApi.getSimpleUserList()
|
||||
})
|
||||
// TODO 芋艿:可优化功能:列表界面,支持导入
|
||||
// TODO 芋艿:可优化功能:详情界面,支持打印
|
||||
</script>
|
@ -95,21 +95,21 @@
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="入库数量" prop="inStatus">
|
||||
<el-form-item label="出库数量" prop="outStatus">
|
||||
<el-select
|
||||
v-model="queryParams.inStatus"
|
||||
placeholder="请选择入库数量"
|
||||
v-model="queryParams.outStatus"
|
||||
placeholder="请选择出库数量"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option label="未入库" value="0" />
|
||||
<el-option label="部分入库" value="1" />
|
||||
<el-option label="全部入库" value="2" />
|
||||
<el-option label="未出库" value="0" />
|
||||
<el-option label="部分出库" value="1" />
|
||||
<el-option label="全部出库" value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="退货数量" prop="inStatus">
|
||||
<el-form-item label="退货数量" prop="returnStatus">
|
||||
<el-select
|
||||
v-model="queryParams.inStatus"
|
||||
v-model="queryParams.returnStatus"
|
||||
placeholder="请选择退货数量"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
@ -305,7 +305,8 @@ const queryParams = reactive({
|
||||
status: undefined,
|
||||
remark: undefined,
|
||||
creator: undefined,
|
||||
inStatus: undefined
|
||||
outStatus: undefined,
|
||||
returnStatus: undefined
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const exportLoading = ref(false) // 导出的加载中
|
||||
|
Loading…
Reference in New Issue
Block a user