This commit is contained in:
zjf committed 2025-05-06 10:55:07 +08:00
commit d55c85a040
21 files changed
+820 -699

No files matched your search

+2 -2
View File
@@ -8,14 +8,14 @@ VITE_OPEN = true
ENV = 'development'
# ADMIN 服务地址
# VITE_ADMIN_PROXY_PATH = http://47.96.250.9:8089/api/ # 测试线上
# VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 测试线上
# VITE_ADMIN_PROXY_PATH = http://pjcloud.center.takin.cc/
# VITE_ADMIN_PROXY_PATH = http://localhost:9999/
VITE_ADMIN_PROXY_PATH = http://192.168.101.123:9999/ # 邓-本地
# VITE_ADMIN_PROXY_PATH = http://59.202.170.152:81/api # 正式环境线上
# 图片访问基础地址
# VITE_IMAGE_BASE_PATH = http://47.96.250.9:8089/api # 测试线上
# VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api/ # 测试线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc
# VITE_IMAGE_BASE_PATH = http://localhost:9999
VITE_IMAGE_BASE_PATH = http://192.168.101.123:9999 # 邓-本地
+10 -1
View File
@@ -1,7 +1,16 @@
import request from "/@/utils/request"
// 库存盘点新增
export function stockTakingAdd(data?: object) {
export function addObj(data?: object) {
return request({
url: "/supermarket/smErpInventoryRecords/savePD",
method: "post",
data,
})
}
// 库存盘点修改
export function putObj(data?: object) {
return request({
url: "/supermarket/smErpInventoryRecords/savePD",
method: "post",
+40
View File
@@ -0,0 +1,40 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: "/third/third-key-manage/page",
method: "get",
params: query,
})
}
export function addObj(obj?: Object) {
return request({
url: "/third/third-key-manage",
method: "post",
data: obj,
})
}
export function getObj(id?: string) {
return request({
url: "/third/third-key-manage/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: "/third/third-key-manage",
method: "delete",
data: ids,
})
}
export function putObj(obj?: Object) {
return request({
url: "/third/third-key-manage",
method: "put",
data: obj,
})
}
+40
View File
@@ -0,0 +1,40 @@
import request from "/@/utils/request"
export function fetchList(query?: Object) {
return request({
url: "/third/third-pay-log/page",
method: "get",
params: query,
})
}
export function addObj(obj?: Object) {
return request({
url: "/third/third-pay-log",
method: "post",
data: obj,
})
}
export function getObj(id?: string) {
return request({
url: "/third/third-pay-log/" + id,
method: "get",
})
}
export function delObjs(ids?: Object) {
return request({
url: "/third/third-pay-log",
method: "delete",
data: ids,
})
}
export function putObj(obj?: Object) {
return request({
url: "/third/third-pay-log",
method: "put",
data: obj,
})
}
+59
View File
@@ -0,0 +1,59 @@
import { Ref } from "vue"
import { useMessage } from "./message"
export function useSmProcessFormAction() {
// 校验 成功返回true 失败返回false
const formValidate = async (baseDataFormRef: any, editableTableRef: any, editableTableData: any) => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
if (!valid) return false
if (editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
}
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
}
}
return true
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async (baseDataForm: any, cgPlanSpuItems: Ref<any[]>, loading: Ref<boolean>, putObj: any, addObj: any) => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id ? await putObj(_pa) : await addObj(_pa)
if (res.code == 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
} finally {
loading.value = false
}
}
return {
formValidate,
submitData,
}
}
+2 -2
View File
@@ -131,11 +131,11 @@ const state: BasicTableProps = reactive<BasicTableProps>({
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
// 导出excel
const exportExcel = () => {
downBlobFile("/hard/hard-total/export-payType", Object.assign(state.queryForm), "支付方式交易记录.xlsx")
postDownBlobFile("/hard/hard-total/export-payType", Object.assign(state.queryForm), "支付方式交易记录.xlsx")
}
const getSummaries = (param: any) => {
+2 -2
View File
@@ -132,11 +132,11 @@ const state: BasicTableProps = reactive<BasicTableProps>({
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
// 导出excel
const exportExcel = () => {
downBlobFile("/hard/hard-total/export-sb", Object.assign(state.queryForm), "设备交易记录.xlsx")
postDownBlobFile("/hard/hard-total/export-sb", Object.assign(state.queryForm), "设备交易记录.xlsx")
}
const getSummaries = (param: any) => {
+2 -2
View File
@@ -129,11 +129,11 @@ const state: BasicTableProps = reactive<BasicTableProps>({
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
// 导出excel
const exportExcel = () => {
downBlobFile("/hard/hard-total/export-cs", Object.assign(state.queryForm), "商户交易记录.xlsx")
postDownBlobFile("/hard/hard-total/export-cs", Object.assign(state.queryForm), "商户交易记录.xlsx")
}
const getSummaries = (param: any) => {
+1 -1
View File
@@ -47,7 +47,7 @@
<select-mch v-model="form.parentId" :apiParams="{ types: '2', supType: '10' }" />
</el-form-item>
</el-col>
<el-col v-show="form.types == '2' && form.supType == '20'" :span="24" class="mb20">
<el-col v-show="form.types == '2'" :span="24" class="mb20">
<el-form-item label="分类:" prop="catgoryId">
<select-mch-catory v-model="form.catgoryId" :apiParams="{ bizType: form.types }" />
</el-form-item>
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.inventoryCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -192,7 +192,6 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
import { getPlanCode, getErpSpuSimpleAll, getCgInventoryPage } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
@@ -201,6 +200,7 @@ import { Search } from "@element-plus/icons-vue"
import linkCodeDialog from "/@/views/supermarketerp/components/linkCodeDialog.vue"
import { displayPrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -242,7 +242,6 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
@@ -251,21 +250,12 @@ const state = reactive<{
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 基本信息表单校验规则
const dataRules = ref({
@@ -414,93 +404,33 @@ const cgPlanSpuItems = computed(() => {
})
})
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id
? await putObj(_pa).finally(() => (loading.value = false))
: await addObj(_pa).finally(() => (loading.value = false))
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.code" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -197,7 +197,6 @@
<script setup lang="ts" name="smErpCgDd">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpCgDd"
import { getPlanCode, getErpSpuSimpleAll, getCgsqPage } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
@@ -206,6 +205,7 @@ import { Search } from "@element-plus/icons-vue"
import linkCodeDialog from "/@/views/supermarketerp/components/linkCodeDialog.vue"
import { displayPrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -248,7 +248,6 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
@@ -257,20 +256,11 @@ const state = reactive<{
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 基本信息表单校验规则
const dataRules = ref({
@@ -419,93 +409,33 @@ const cgPlanSpuItems = computed(() => {
})
})
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id
? await putObj(_pa).finally(() => (loading.value = false))
: await addObj(_pa).finally(() => (loading.value = false))
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "code" || key === "id" || key === "dDate") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.inventoryCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -109,20 +109,16 @@
</vxe-column>
<vxe-column field="unitId" title="包装单位" :edit-render="{}">
<template #edit="{ row }">
<el-select v-model="row.unitId" placeholder="请选择包装单位">
<el-option
v-if="row.erpUnitVos?.length > 0"
v-for="item in row.erpUnitVos"
:key="item.id"
:label="item.unit"
:value="item.id"
/>
<el-option v-else :key="row.id" :label="row.unit" :value="row.unitId" />
<el-select v-if="row.erpUnitVos" v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
<el-option v-for="item in row.erpUnitVos" :key="item.id" :label="item.unit" :value="item" />
</el-select>
<el-select v-else v-model="row.unitId" value-key="id" placeholder="请选择包装单位">
<el-option :key="row.id" :label="row.unit" :value="row.unitId" />
</el-select>
</template>
<template #default="{ row }">
<span v-if="row.unitId">{{ row.unit ?? row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
<span v-else style="color: #c0c4cf">请选择</span>
<span v-if="row.erpUnitVos">{{ row.unitId?.unit ?? "请选择" }}</span>
<span v-else>{{ row.unit }}</span>
</template>
</vxe-column>
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
@@ -132,26 +128,25 @@
</vxe-column>
<vxe-column field="unitPrice" title="原进价">
<template #default="{ row }">
{{
row.purchasePrice
? displayPrice(row.purchasePrice)
: displayPrice(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice)
}}
{{ row.erpUnitVos ? displayPrice(row.unitId?.purchasePrice || 0) : displayPrice(row.purchasePrice) }}
</template>
</vxe-column>
<vxe-column field="realPrice" title="实际进价" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #default="{ row }">{{ row.realPrice }}</template>
<template #default="{ row }">
{{ row.erpUnitVos && row.unitId ? row.unitId?.realPrice || 0 : row.realPrice }}
</template>
<template #edit="{ row }">
<el-input v-model="row.realPrice" />
<el-input v-if="row.erpUnitVos && row.unitId" v-model="row.unitId.realPrice" />
<el-input v-else v-model="row.realPrice" />
</template>
</vxe-column>
<vxe-column field="totalAmount" title="累计总金额">
<template #default="{ row }">
<span v-if="row.unitId && row.quantity && row.unit && !row.erpUnitVos">
{{ Number(row.quantity * parseFloat(row.realPrice)).toFixed(2) }}
<span v-if="row.erpUnitVos && row.unitId && row.quantity">
{{ Number(row.quantity * parseFloat(row.unitId.realPrice || 0)).toFixed(2) }}
</span>
<span v-if="row.unitId && row.quantity && row.erpUnitVos">
{{ Number(Number(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.realPrice) * row.quantity).toFixed(2) }}
<span v-else>
{{ Number(Number(row.quantity) * row.realPrice).toFixed(2) }}
</span>
</template>
</vxe-column>
@@ -198,7 +193,6 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
import { getPlanCode, getErpSpuSimpleAll, getCgddPage } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
@@ -207,6 +201,7 @@ import { Search } from "@element-plus/icons-vue"
import linkCodeDialog from "/@/views/supermarketerp/components/linkCodeDialog.vue"
import { displayPrice, storePrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -248,7 +243,6 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
@@ -257,27 +251,18 @@ const state = reactive<{
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 基本信息表单校验规则
const dataRules = ref({
inventoryCode: [{ required: true, message: "出入库记录表编号不能为空", trigger: "blur" }],
inventoryDate: [{ required: true, message: "出入库记录表单据日期不能为空", trigger: "blur" }],
// handlerUserId: [{ required: true, message: "经办人不能为空", trigger: "blur" }],
handlerUserId: [{ required: true, message: "经办人不能为空", trigger: "blur" }],
supplierId: [{ required: true, message: "货商不能为空", trigger: "blur" }],
})
@@ -302,8 +287,8 @@ const getInitData = async () => {
if (cgPlanData && cgPlanData.code === 0) {
Object.assign(baseDataForm, cgPlanData.data)
state.editableTableData = cgPlanData.data.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.realPrice, "") }))
state.erpSpuItemsMemo = cgPlanData.data.items.map((item: any) => ({ ...item, realPrice: displayPrice(item.realPrice, "") }))
state.editableTableData = cgPlanData.data.items
state.erpSpuItemsMemo = cgPlanData.data.items
}
} else {
loading.value = true
@@ -369,7 +354,11 @@ const getSelectedSpuRows = (selectionRows: any) => {
.map((addItem: any) => {
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
if (index !== -1) return state.erpSpuItemsMemo[index]
return { ...addItem, isNew: true }
return {
...addItem,
erpUnitVos: addItem.erpUnitVos.map((item: any) => ({ ...item, realPrice: displayPrice(item.purchasePrice, "") })),
isNew: true,
}
})
// 仅添加新勾选的项
state.editableTableData = [...state.editableTableData, ...addedItems]
@@ -397,16 +386,16 @@ const getSelectedSpuRows = (selectionRows: any) => {
const cgPlanSpuItems = computed(() => {
return state.editableTableData.map((item: any) => {
if (item.erpUnitVos) {
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
const unitObj = item.unitId
return {
id: item.isNew ? undefined : item.id,
erpSpuId: item.erpSpuId,
quantity: item.quantity,
unitPrice: unit.purchasePrice ? Number(unit?.purchasePrice) : 0,
realPrice: unit.realPrice ? storePrice(unit?.realPrice) : 0,
totalAmount: storePrice(Number(unit?.realPrice || 0) * item.quantity),
unitPrice: unitObj.purchasePrice ? Number(unitObj?.purchasePrice) : 0,
realPrice: unitObj.realPrice ? storePrice(unitObj?.realPrice) : 0,
totalAmount: storePrice(Number(unitObj?.realPrice || 0) * item.quantity),
remark: item.remark,
unitId: item.unitId,
unitId: unitObj.unitId,
}
} else {
return {
@@ -423,93 +412,33 @@ const cgPlanSpuItems = computed(() => {
})
})
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id
? await putObj(_pa).finally(() => (loading.value = false))
: await addObj(_pa).finally(() => (loading.value = false))
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.planCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -58,22 +58,6 @@
<el-button type="primary" plain @click="handleClickSpuSelect">商品选择</el-button>
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpSpuIds.length <= 0">删除选中</el-button>
<el-button type="danger" plain @click="clearData">清空数据</el-button>
<!-- <el-button @click="addEvent">新增(顶部)</el-button>
<el-button @click="pushEvent">新增(尾部)</el-button>
<el-button @click="insertEvent">
在第
<el-input-number
@click.stop
v-model="state.insertedRowNumber"
:min="0"
:max="state.editableTableData.length"
:precision="0"
size="small"
controls-position="right"
style="min-width: 50px; margin: 0 5px"
/>
行新增
</el-button> -->
</el-row>
<vxe-table
@@ -106,11 +90,6 @@
>
<vxe-column type="checkbox" width="40" fixed="left" />
<vxe-column type="seq" width="50" fixed="left" />
<!-- <vxe-column field="planId" title="采购" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #edit="{ row }">
<el-input v-model="row.planId" />
</template>
</vxe-column> -->
<vxe-column field="productName" title="库存商品">
<template #default="{ row }">
<span v-if="row.productName">{{ row.productName }}</span>
@@ -139,35 +118,11 @@
<el-input v-model="row.quantity" />
</template>
</vxe-column>
<!-- <vxe-column field="unitPrice" title="进价">
<template #default="{ row }">
{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice }}
</template>
</vxe-column>
<vxe-column field="totalAmount" title="累计总金额">
<template #default="{ row }">
{{
row.unitId && row.quantity
? Number(row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.purchasePrice) * row.quantity
: ""
}}
</template>
</vxe-column> -->
<vxe-column field="remark" title="备注" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
<template #edit="{ row }">
<el-input v-model="row.remark" />
</template>
</vxe-column>
<!-- <vxe-column field="merchantId" title="商户编号" :edit-render="{ autoFocus: 'input', placeholder: '请选择' }">-->
<!-- <template #edit="{ row }">-->
<!-- <select-mch v-model="row.merchantId" />-->
<!-- </template>-->
<!-- </vxe-column>-->
<!-- <vxe-column field="deptId" title="部门id" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">-->
<!-- <template #edit="{ row }">-->
<!-- <el-input v-model="row.deptId" />-->
<!-- </template>-->
<!-- </vxe-column>-->
</vxe-table>
<el-row class="my-3">
@@ -198,12 +153,12 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpCgPlan"
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
import { formatDate } from "/@/utils/formatTime"
import { tablePrint } from "../../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -237,25 +192,15 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
erpSpuSelectDialogVisible: boolean
}>({
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 基本信息表单校验规则
const dataRules = ref({
@@ -299,66 +244,6 @@ const getInitData = async () => {
planCode && planCode.code === 0 && (baseDataForm.planCode = planCode.data)
}
// 顶部表格行新增
const addEvent = () => {
const newRow: any = {
id: "",
erpSpuId: "",
quantity: null,
unitPrice: null,
totalAmount: null,
remark: "",
unitId: "",
}
state.editableTableData.unshift(newRow)
nextTick(() => {
const $table = editableTableRef.value
if ($table) {
$table.setEditRow(newRow)
}
})
}
// 底部表格行新增
const pushEvent = () => {
const newRow: any = {
id: "",
erpSpuId: "",
quantity: null,
unitPrice: null,
totalAmount: null,
remark: "",
unitId: "",
}
state.editableTableData.push(newRow)
nextTick(() => {
const $table = editableTableRef.value
if ($table) {
$table.setEditRow(newRow)
}
})
}
// 在指定行插入
const insertEvent = () => {
const newRow: any = {
id: "",
erpSpuId: "",
quantity: null,
unitPrice: null,
totalAmount: null,
remark: "",
unitId: "",
}
state.editableTableData.splice(state.insertedRowNumber, 0, newRow)
nextTick(() => {
const $table = editableTableRef.value
if ($table) {
$table.setEditRow(newRow)
}
})
}
// 删除选中的行
const removeSelectRowEvent = () => {
const $table = editableTableRef.value
@@ -433,93 +318,33 @@ const cgPlanSpuItems = computed(() => {
})
})
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id
? await putObj(_pa).finally(() => (loading.value = false))
: await addObj(_pa).finally(() => (loading.value = false))
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "planCode" || key === "id" || key === "planDate") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.inventoryCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -224,7 +224,6 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
import { getPlanCode, getErpSpuSimpleAll, getCgInventoryPage } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
@@ -233,6 +232,7 @@ import { Search } from "@element-plus/icons-vue"
import linkCodeDialog from "/@/views/supermarketerp/components/linkCodeDialog.vue"
import { displayPrice, storePrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -275,7 +275,6 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
@@ -284,21 +283,13 @@ const state = reactive<{
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 合计金额表单数据
const receiveAmountForm = reactive<{ receiveAmount: number }>({
receiveAmount: 0,
@@ -462,93 +453,33 @@ const cgPlanSpuItems = computed(() => {
// 计算单据金额
const totalAmount = computed(() => cgPlanSpuItems.value.reduce((pre, cur) => pre + cur.totalAmount, 0))
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id
? await putObj(_pa).finally(() => (loading.value = false))
: await addObj(_pa).finally(() => (loading.value = false))
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.inventoryCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -216,7 +216,6 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
import { getPlanCode, getErpSpuSimpleAll, getCgddPage } from "/@/api/supermarketerp/common"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
@@ -225,6 +224,7 @@ import { Search } from "@element-plus/icons-vue"
import linkCodeDialog from "/@/views/supermarketerp/components/linkCodeDialog.vue"
import { displayPrice, storePrice } from "/@/utils/formatMoney"
import { tablePrint } from "../../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -267,7 +267,6 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
@@ -276,21 +275,13 @@ const state = reactive<{
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 合计金额表单数据
const receiveAmountForm = reactive<{ receiveAmount: number }>({
receiveAmount: 0,
@@ -454,93 +445,33 @@ const cgPlanSpuItems = computed(() => {
// 计算单据金额
const totalAmount = computed(() => cgPlanSpuItems.value.reduce((pre, cur) => pre + cur.totalAmount, 0))
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, cgPlanSpuItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: cgPlanSpuItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id
? await putObj(_pa).finally(() => (loading.value = false))
: await addObj(_pa).finally(() => (loading.value = false))
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
+10 -78
View File
@@ -1,5 +1,5 @@
<template>
<div v-loading="loading" :element-loading-svg="svg" element-loading-svg-view-box="-10, -10, 50, 50" class="w-full h-full">
<div v-loading="loading" class="w-full h-full">
<div v-if="baseDataForm.inventoryCode" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
<div v-if="disabled" ref="baseDataInfoRef">
<div style="margin-bottom: 8px; padding: 8px 16px; color: #606279; display: flex; flex-wrap: wrap">
@@ -203,14 +203,14 @@
<script setup lang="ts">
import { ref, reactive, computed, onMounted } from "vue"
import { useMessage } from "/@/hooks/message"
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
import { getStockTakingDeatil, stockTakingAdd } from "/@/api/supermarketerp/stockTaking"
import { getStockTakingDeatil, addObj, putObj } from "/@/api/supermarketerp/stockTaking"
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
import { formatDate } from "/@/utils/formatTime"
import barCodeEnter from "./barCodeEnter.vue"
import { displayPrice } from "/@/utils/formatMoney"
import { tablePrint } from "../supermarketUtils"
import { useSmProcessFormAction } from "/@/hooks/smProcessFormAction"
const SelectDialog = defineAsyncComponent(() => import("/@/views/supermarketerp/components/erpSpuSelectDialog.vue"))
@@ -247,7 +247,6 @@ const state = reactive<{
editableTableData: any[]
erpSpuItemsMemo: any[]
selectedRowsErpSpuIds: string[]
insertedRowNumber: number
erpSpuSimpleAll: any
linkCodeVisible: boolean
erpSpuSelectDialogVisible: boolean
@@ -256,21 +255,12 @@ const state = reactive<{
editableTableData: [], // 可编辑表格数据
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
insertedRowNumber: 0, // 可编辑表格插入行的行号
erpSpuSimpleAll: [], // 简要商品列表
linkCodeVisible: false, // 关联采购申请单对话框开关
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
})
const svg = `<path class="path" d="
M 30 15
L 28 17
M 25.61 25.61
A 15 15, 0, 0, 1, 15 30
A 15 15, 0, 1, 1, 27.99 7.5
L 15 15
" style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>`
// 基本信息表单校验规则
const dataRules = ref({
@@ -472,91 +462,33 @@ const pdPlanItems = computed(() => {
})
})
const { formValidate, submitData } = useSmProcessFormAction()
// 点击继续添加
const onContinueAdd = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, pdPlanItems, loading, putObj, addObj)) &&
clearData()
}
// 点击保存
const onSave = async () => {
console.log("baseDataForm", baseDataForm)
console.log("state.editableTableData", state.editableTableData)
;(await baseDataFormValidate()) &&
checkSelectSpu() &&
(await editableTableValidate()) &&
(await submitData()) &&
;(await formValidate(baseDataFormRef, editableTableRef, state.editableTableData)) &&
(await submitData(baseDataForm, pdPlanItems, loading, putObj, addObj)) &&
clearData() &&
emit("close")
}
// 校验基本数据表单 成功返回 true 失败返回 undefined
const baseDataFormValidate = async () => {
const valid = await baseDataFormRef.value.validate().catch(() => {})
return valid
}
// 校验是否选择了商品 成功返回 true 失败返回 false
const checkSelectSpu = () => {
if (state.editableTableData.length <= 0) {
useMessage().warning("请选择商品")
return false
} else {
return true
}
}
// 校验可编辑表格 成功返回 true 失败返回 false
const editableTableValidate = async () => {
// 全量校验
const $table = editableTableRef.value
if ($table) {
const errMap = await $table.validate(true)
if (errMap) {
console.log("全量校验失败!")
return false
} else {
console.log("全量校验成功!")
return true
}
}
}
// 提交数据 成功返回 true 失败返回 false
const submitData = async () => {
try {
loading.value = true
const _pa = {
...baseDataForm,
items: pdPlanItems.value,
}
console.log("提交的数据:", _pa)
const res = baseDataForm.id ? await putObj(_pa) : await stockTakingAdd(_pa)
if (res.code === 0) {
useMessage().success(baseDataForm.id ? "修改成功" : "添加成功")
return true
} else {
useMessage().error(res.msg)
return false
}
} catch (err: any) {
useMessage().error(err.msg)
loading.value = false
return false
}
}
// 清空填写的数据 返回 true
const clearData = () => {
for (const key in baseDataForm) {
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
baseDataForm[key] = ""
}
state.insertedRowNumber = 0
state.editableTableData = []
state.erpSpuItemsMemo = []
state.selectedRowsErpSpuIds = []
+143
View File
@@ -0,0 +1,143 @@
<template>
<el-dialog width="40%" :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="120px" v-loading="loading">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item label="第三方名" prop="name">
<el-input v-model="form.name" placeholder="第三方名" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="类型" prop="bizType">
<dict-select v-model="form.bizType" dict-code="third_key_type" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="appKey" prop="appKey">
<el-input v-model="form.appKey" placeholder="请输入appKey" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="appSecret" prop="appSecret">
<el-input v-model="form.appSecret" placeholder="请输入appSecret" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="字段加密key" prop="fieldKey">
<el-input v-model="form.fieldKey" placeholder="请输入字段加密key" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="是否启用" prop="status">
<el-radio-group v-model="form.status">
<el-radio v-for="v in yes_no_type" :key="v.value" :label="v.value" border>
{{ v.label }}
</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" type="textarea" :autosize="{ minRows: 6 }" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="ThirdKeyManageDialog">
import { useDict } from "/@/hooks/dict"
import { useMessage } from "/@/hooks/message"
import * as thirdKeyManageApi from "/@/api/thirdparty/third-key-manage"
import { rule } from "/@/utils/validate"
const emit = defineEmits(["refresh"])
// 定义变量内容
const dataFormRef = ref()
const visible = ref(false)
const loading = ref(false)
// 定义字典
const { third_key_type, yes_no_type } = useDict("third_key_type", "yes_no_type")
// 提交表单数据
const form = reactive({
id: "",
name: "",
bizType: "",
appKey: "",
appSecret: "",
fieldKey: "",
status: "1",
remark: "",
})
// 定义校验规则
const dataRules = ref({
name: [{ required: true, message: "第三方名不能为空", trigger: "blur" }],
bizType: [{ required: true, message: "类型不能为空", trigger: "change" }],
appKey: [{ required: true, message: "appKey不能为空", trigger: "blur" }],
appSecret: [{ required: true, message: "appSecret不能为空", trigger: "blur" }],
fieldKey: [{ required: true, message: "字段加密key不能为空", trigger: "blur" }],
status: [{ required: true, message: "状态不能为空", trigger: "change" }],
})
// 打开弹窗
const openDialog = (id: string) => {
visible.value = true
form.id = ""
// 重置表单数据
nextTick(() => {
dataFormRef.value?.resetFields()
})
// 获取thirdKeyManage信息
if (id) {
form.id = id
getthirdKeyManageData(id)
}
}
// 提交
const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => {})
if (!valid) return false
try {
loading.value = true
form.id ? await thirdKeyManageApi.putObj(form) : await thirdKeyManageApi.addObj(form)
useMessage().success(form.id ? "修改成功" : "添加成功")
visible.value = false
emit("refresh")
} catch (err: any) {
useMessage().error(err.msg)
} finally {
loading.value = false
}
}
// 初始化表单数据
const getthirdKeyManageData = (id: string) => {
// 获取数据
loading.value = true
thirdKeyManageApi
.getObj(id)
.then((res: any) => {
Object.assign(form, res.data)
})
.finally(() => {
loading.value = false
})
}
// 暴露变量
defineExpose({
openDialog,
})
</script>
+154
View File
@@ -0,0 +1,154 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
<el-row>
<el-form-item style="width: 250px" label="第三方名" prop="name">
<el-input v-model="state.queryForm.name" />
</el-form-item>
<el-form-item>
<el-button icon="Search" type="primary" @click="getDataList">
{{ $t("common.queryBtn") }}
</el-button>
<el-button icon="Refresh" @click="resetQuery">{{ $t("common.resetBtn") }}</el-button>
</el-form-item>
</el-row>
</el-form>
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'third_thirdKeyManage_add'">
新 增
</el-button>
<el-button
plain
:disabled="multiple"
icon="Delete"
type="primary"
v-auth="'third_thirdKeyManage_del'"
@click="handleDelete(selectObjs)"
>
删除
</el-button>
<!-- :export="'third_thirdKeyManage_export'" -->
<right-toolbar
v-model:showSearch="showSearch"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="name" label="第三方名" />
<el-table-column prop="bizType" label="类型">
<template #default="{ row }">
<dict-tag :options="third_key_type" :value="row.bizType" />
</template>
</el-table-column>
<el-table-column prop="appKey" label="appKey" show-overflow-tooltip />
<el-table-column prop="appSecret" label="appSecret" show-overflow-tooltip />
<el-table-column prop="fieldKey" label="字段加密key" show-overflow-tooltip />
<el-table-column prop="status" label="是否启用">
<template #default="{ row }">
<dict-tag :options="yes_no_type" :value="row.status" />
</template>
</el-table-column>
<el-table-column prop="remark" label="备注" />
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button
icon="edit-pen"
text
type="primary"
v-auth="'third_thirdKeyManage_edit'"
@click="formDialogRef.openDialog(scope.row.id)"
>编辑</el-button
>
<el-button icon="delete" text type="primary" v-auth="'third_thirdKeyManage_del'" @click="handleDelete([scope.row.id])"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div>
</template>
<script setup lang="ts" name="systemThirdKeyManage">
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as thirdKeyManageApi from "/@/api/thirdparty/third-key-manage"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
// 引入组件
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义查询字典
const { third_key_type, yes_no_type } = useDict("third_key_type", "yes_no_type")
// 定义变量内容
const formDialogRef = ref()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: thirdKeyManageApi.fetchList,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile("/third/thirdKeyManage/export", Object.assign(state.queryForm, { ids: selectObjs }), "thirdKeyManage.xlsx")
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm("此操作将永久删除")
} catch {
return
}
try {
await thirdKeyManageApi.delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg)
}
}
</script>
+139
View File
@@ -0,0 +1,139 @@
<template>
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible" :close-on-click-modal="false" draggable>
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
<el-row :gutter="24">
<el-col :span="24" class="mb20">
<el-form-item label="支付发起方类型id" prop="paySourceType">
<el-input v-model="form.paySourceType" placeholder="请输入支付发起方类型id" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="支付类型" prop="bizType">
<el-input v-model="form.bizType" placeholder="请输入支付类型" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="支付类型id" prop="bizId">
<el-input v-model="form.bizId" placeholder="请输入支付类型id" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="api-url" prop="apiUrl">
<el-input v-model="form.apiUrl" placeholder="请输入api-url" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="res" prop="res">
<el-input v-model="form.res" placeholder="请输入res" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="req" prop="req">
<el-input v-model="form.req" placeholder="请输入req" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="调用错误" prop="error">
<el-input v-model="form.error" placeholder="请输入调用错误" />
</el-form-item>
</el-col>
<el-col :span="24" class="mb20">
<el-form-item label="耗时(毫秒)" prop="timeConsuming">
<el-input v-model="form.timeConsuming" placeholder="请输入耗时(毫秒)" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<span class="dialog-footer">
<el-button @click="visible = false">取消</el-button>
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script setup lang="ts" name="ThirdPayLogDialog">
import { useDict } from "/@/hooks/dict"
import { useMessage } from "/@/hooks/message"
import * as thirdPayLogApi from "/@/api/thirdparty/third-pay-log"
import { rule } from "/@/utils/validate"
const emit = defineEmits(["refresh"])
// 定义变量内容
const dataFormRef = ref()
const visible = ref(false)
const loading = ref(false)
// 定义字典
// 提交表单数据
const form = reactive({
id: "",
paySourceType: "",
bizType: "",
bizId: "",
apiUrl: "",
res: "",
req: "",
error: "",
timeConsuming: "",
})
// 定义校验规则
const dataRules = ref({})
// 打开弹窗
const openDialog = (id: string) => {
visible.value = true
form.id = ""
// 重置表单数据
nextTick(() => {
dataFormRef.value?.resetFields()
})
// 获取thirdPayLog信息
if (id) {
form.id = id
getthirdPayLogData(id)
}
}
// 提交
const onSubmit = async () => {
const valid = await dataFormRef.value.validate().catch(() => {})
if (!valid) return false
try {
loading.value = true
form.id ? await thirdPayLogApi.putObj(form) : await thirdPayLogApi.addObj(form)
useMessage().success(form.id ? "修改成功" : "添加成功")
visible.value = false
emit("refresh")
} catch (err: any) {
useMessage().error(err.msg)
} finally {
loading.value = false
}
}
// 初始化表单数据
const getthirdPayLogData = (id: string) => {
// 获取数据
loading.value = true
thirdPayLogApi
.getObj(id)
.then((res: any) => {
Object.assign(form, res.data)
})
.finally(() => {
loading.value = false
})
}
// 暴露变量
defineExpose({
openDialog,
})
</script>
+129
View File
@@ -0,0 +1,129 @@
<template>
<div class="layout-padding">
<div class="layout-padding-auto layout-padding-view">
<el-row>
<div class="mb8" style="width: 100%">
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'third_thirdPayLog_add'">
新 增
</el-button>
<el-button
plain
:disabled="multiple"
icon="Delete"
type="primary"
v-auth="'third_thirdPayLog_del'"
@click="handleDelete(selectObjs)"
>
删除
</el-button>
<right-toolbar
v-model:showSearch="showSearch"
:export="'third_thirdPayLog_export'"
@exportExcel="exportExcel"
class="ml10 mr20"
style="float: right"
@queryTable="getDataList"
></right-toolbar>
</div>
</el-row>
<el-table
:data="state.dataList"
v-loading="state.loading"
border
:cell-style="tableStyle.cellStyle"
:header-cell-style="tableStyle.headerCellStyle"
@selection-change="selectionChangHandle"
@sort-change="sortChangeHandle"
>
<el-table-column type="selection" width="40" align="center" />
<el-table-column type="index" label="#" width="40" />
<el-table-column prop="paySourceType" label="支付发起方类型id" show-overflow-tooltip />
<el-table-column prop="bizType" label="支付类型" show-overflow-tooltip />
<el-table-column prop="bizId" label="支付类型id" show-overflow-tooltip />
<el-table-column prop="apiUrl" label="api-url" show-overflow-tooltip />
<el-table-column prop="res" label="res" show-overflow-tooltip />
<el-table-column prop="req" label="req" show-overflow-tooltip />
<el-table-column prop="error" label="调用错误" show-overflow-tooltip />
<el-table-column prop="timeConsuming" label="耗时(毫秒)" show-overflow-tooltip />
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button icon="edit-pen" text type="primary" v-auth="'third_thirdPayLog_edit'" @click="formDialogRef.openDialog(scope.row.id)"
>编辑</el-button
>
<el-button icon="delete" text type="primary" v-auth="'third_thirdPayLog_del'" @click="handleDelete([scope.row.id])"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
</div>
<!-- 编辑、新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div>
</template>
<script setup lang="ts" name="systemThirdPayLog">
import { BasicTableProps, useTable } from "/@/hooks/table"
import * as thirdPayLogApi from "/@/api/thirdparty/third-pay-log"
import { useMessage, useMessageBox } from "/@/hooks/message"
import { useDict } from "/@/hooks/dict"
// 引入组件
const FormDialog = defineAsyncComponent(() => import("./form.vue"))
// 定义查询字典
// 定义变量内容
const formDialogRef = ref()
// 搜索变量
const queryRef = ref()
const showSearch = ref(true)
// 多选变量
const selectObjs = ref([]) as any
const multiple = ref(true)
const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {},
pageList: thirdPayLogApi.fetchList,
})
// table hook
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, downBlobFile, tableStyle } = useTable(state)
// 清空搜索条件
const resetQuery = () => {
// 清空搜索条件
queryRef.value?.resetFields()
// 清空多选
selectObjs.value = []
getDataList()
}
// 导出excel
const exportExcel = () => {
downBlobFile("/third/thirdPayLog/export", Object.assign(state.queryForm, { ids: selectObjs }), "thirdPayLog.xlsx")
}
// 多选事件
const selectionChangHandle = (objs: { id: string }[]) => {
selectObjs.value = objs.map(({ id }) => id)
multiple.value = !objs.length
}
// 删除操作
const handleDelete = async (ids: string[]) => {
try {
await useMessageBox().confirm("此操作将永久删除")
} catch {
return
}
try {
await thirdPayLogApi.delObjs(ids)
getDataList()
useMessage().success("删除成功")
} catch (err: any) {
useMessage().error(err.msg)
}
}
</script>
+1 -1
View File
@@ -20,7 +20,7 @@
<el-form-item style="width: 200px" label="充值方式" prop="bizType">
<dict-select v-model="state.queryForm.bizType" dict-code="wallet_biz" />
</el-form-item>
<el-form-item style="width: 200px" label="充值类型" prop="type">
<el-form-item v-if="false" style="width: 200px" label="充值类型" prop="type">
<dict-select v-model="state.queryForm.type" dict-code="wallet_biz_recharge" />
</el-form-item>
<el-form-item style="width: 300px" label="充值时间" prop="createTimeList">