Merge branch 'master' of http://gitea.zianxin.com/zianxin-tec/biz-pc-cloud
This commit is contained in:
commit
dc7b51d461
31 files changed
+401
-1271
No files matched your search
@@ -29,3 +29,12 @@ export function getErpSpuSimpleAll() {
|
||||
method: "get",
|
||||
})
|
||||
}
|
||||
|
||||
// 获取出入库订单列表
|
||||
export function getCgInventoryPage(params?: Object) {
|
||||
return request({
|
||||
url: "/smErpInventoryRecords/inventory/page",
|
||||
method: "get",
|
||||
params,
|
||||
})
|
||||
}
|
||||
@@ -38,11 +38,3 @@ export function putObj(obj?: Object) {
|
||||
data: obj,
|
||||
})
|
||||
}
|
||||
|
||||
export function getCgInventoryPage(params?: Object) {
|
||||
return request({
|
||||
url: "/smErpInventoryRecords/inventory/page",
|
||||
method: "get",
|
||||
params,
|
||||
})
|
||||
}
|
||||
File renamed without changes.
@@ -1,9 +0,0 @@
|
||||
import request from "/@/utils/request"
|
||||
|
||||
export function getCgInventoryPage(params?: Object) {
|
||||
return request({
|
||||
url: "/smErpInventoryRecords/inventory/page",
|
||||
method: "get",
|
||||
params,
|
||||
})
|
||||
}
|
||||
@@ -45,7 +45,7 @@
|
||||
:data="state.treeDataList"
|
||||
:expand-on-click-node="false"
|
||||
node-key="id"
|
||||
highlight-current
|
||||
:highlight-current="nodeClickable ? true : false"
|
||||
default-expand-all
|
||||
show-checkbox
|
||||
@node-click="handleNodeClick"
|
||||
@@ -63,7 +63,7 @@
|
||||
@change="handleSwitchChange"
|
||||
:inactive-text="switchInactiveText"
|
||||
:active-text="switchActiveText"
|
||||
:disabled="state.checkedTreeNodes.length > 0"
|
||||
:disabled="nodeClickable && state.checkedTreeNodes.length > 0"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,6 +101,7 @@ const props = withDefaults(
|
||||
showExpand?: boolean // 折叠控制
|
||||
query?: (searchName?: string) => Promise<any> // 查询函数
|
||||
props?: object
|
||||
nodeClickable?: boolean
|
||||
switchInactiveText?: string | undefined
|
||||
switchActiveText?: string | undefined
|
||||
defaultTreeWidth?: number | string
|
||||
@@ -116,6 +117,7 @@ const props = withDefaults(
|
||||
value: "id",
|
||||
}
|
||||
},
|
||||
nodeClickable: true,
|
||||
switchInactiveText: "当前级",
|
||||
switchActiveText: "当前级及子级",
|
||||
defaultTreeWidth: 20,
|
||||
@@ -177,6 +179,7 @@ const handleSearchInputChange = () => {
|
||||
|
||||
// 点击树形结构节点
|
||||
const handleNodeClick = (nodeData: any) => {
|
||||
if (!props.nodeClickable) return
|
||||
state.curClickedNode = nodeData
|
||||
emit("getSelectNode", state.curClickedNode, state.checkedTreeNodes, state.switch)
|
||||
}
|
||||
@@ -186,7 +189,7 @@ const handleCheck = (data: any, checkStatus: any) => {
|
||||
const { checkedNodes } = checkStatus
|
||||
console.log("checkedNodes", checkedNodes)
|
||||
state.checkedTreeNodes = checkedNodes
|
||||
if (state.checkedTreeNodes.length > 0) {
|
||||
if (props.nodeClickable && state.checkedTreeNodes.length > 0) {
|
||||
state.switch = false
|
||||
}
|
||||
emit("getSelectNode", state.curClickedNode, state.checkedTreeNodes, state.switch)
|
||||
@@ -204,16 +207,6 @@ const toggleRowExpansionAll = (status: boolean) => {
|
||||
}
|
||||
}
|
||||
|
||||
// 勾选树节点时关闭switch
|
||||
watch(
|
||||
() => state.checkedTreeNodes,
|
||||
(val) => {
|
||||
if (state.checkedTreeNodes.length > 0) {
|
||||
state.switch = false
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
// 重置数据
|
||||
const resetData = () => {
|
||||
state.searchName = ""
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-row v-show="showSearch">
|
||||
@@ -237,7 +238,7 @@ const resetQuery = () => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: boolean) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -208,7 +209,7 @@ const resetQuery = () => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -206,7 +207,7 @@ const handleDelete = async (ids: string[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -160,7 +161,7 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -148,7 +149,7 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
+35
-26
@@ -1,14 +1,14 @@
|
||||
<template>
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<el-dialog v-model="linkCgCodeDialogVisible" title="选择采购单" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<!-- 关联订单对话框 -->
|
||||
<el-dialog v-model="linkCodeDialogVisible" :title="title" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<vxe-table
|
||||
v-show="step === 0"
|
||||
ref="linkCgPlanTableRef"
|
||||
ref="linkCodeTableRef"
|
||||
border
|
||||
v-loading="linkCodeLoading"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:radio-config="{ labelField: '', trigger: 'row' }"
|
||||
:data="cgddPage"
|
||||
:data="linkCodeTableData"
|
||||
@radio-change="radioChangeEvent"
|
||||
>
|
||||
<vxe-column type="radio" width="60" align="center"></vxe-column>
|
||||
@@ -28,7 +28,7 @@
|
||||
/> -->
|
||||
<vxe-table
|
||||
v-show="step === 1"
|
||||
ref="linkCgPlanSpuTableRef"
|
||||
ref="linkCodeUnitTableRef"
|
||||
border
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:checkbox-config="{ trigger: 'row' }"
|
||||
@@ -45,7 +45,7 @@
|
||||
</vxe-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="linkCgCodeDialogVisible = false">取消</el-button>
|
||||
<el-button @click="linkCodeDialogVisible = false">取消</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="step--">上一步</el-button>
|
||||
<el-button v-show="step === 0" type="primary" @click="step++" :disabled="currRadioRowItems.length <= 0">下一步</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="getSelectedRowData" :disabled="linkCodeLoading">确认</el-button>
|
||||
@@ -55,31 +55,40 @@
|
||||
|
||||
<script setup lang="ts" name="linkCgCodeDialog">
|
||||
import { ref } from "vue"
|
||||
import { getCgddPage } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { VxeTableEvents } from "vxe-table"
|
||||
|
||||
const linkCgCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedCgPlan"])
|
||||
const linkCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedLinkCode"])
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
title?: string
|
||||
getTableData?: (params?: object) => Promise<any>
|
||||
}>(),
|
||||
{
|
||||
title: "",
|
||||
getTableData: () => Promise.resolve([]),
|
||||
},
|
||||
)
|
||||
|
||||
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
|
||||
const linkCgPlanTableRef = ref() // 关联补货单对话框表格1ref
|
||||
const linkCgPlanSpuTableRef = ref() // 关联补货单对话框表格2ref
|
||||
const cgddPage = ref([]) // 采购申请列表数据
|
||||
const linkCodeLoading = ref(false)
|
||||
const linkCodeTableRef = ref() // 关联订单表格ref
|
||||
const linkCodeUnitTableRef = ref() // 关联订单的包装单位表格ref
|
||||
const linkCodeTableData = ref([]) // 关联订单列表数据
|
||||
const currRadioRowItems = ref([]) // 当前单选的表格行的items
|
||||
const step = ref(0) // 选择步骤
|
||||
const step = ref(0)
|
||||
|
||||
// 打开关联补货单对话框
|
||||
const openLinkCodeDialog = async () => {
|
||||
linkCgCodeDialogVisible.value = true
|
||||
linkCodeDialogVisible.value = true
|
||||
step.value = 0
|
||||
linkCodeLoading.value = true
|
||||
try {
|
||||
const res = await getCgddPage().finally(() => (linkCodeLoading.value = false))
|
||||
const res = await props.getTableData().finally(() => (linkCodeLoading.value = false))
|
||||
if (res.code === 0) {
|
||||
cgddPage.value = res.data.records
|
||||
linkCodeTableData.value = res.data.records
|
||||
}
|
||||
} catch (error) {
|
||||
cgddPage.value = []
|
||||
linkCodeTableData.value = []
|
||||
linkCodeLoading.value = false
|
||||
}
|
||||
}
|
||||
@@ -89,23 +98,23 @@ const radioChangeEvent: VxeTableEvents.RadioChange<any> = ({ row }) => (currRadi
|
||||
|
||||
// 获取选择的关联补货单对话框表格行数据
|
||||
const getSelectedRowData = () => {
|
||||
const $table = linkCgPlanTableRef.value
|
||||
const $SpuTable = linkCgPlanSpuTableRef.value
|
||||
if ($table && $SpuTable) {
|
||||
const $table = linkCodeTableRef.value
|
||||
const $unitTable = linkCodeUnitTableRef.value
|
||||
if ($table && $unitTable) {
|
||||
const currRadioRow = $table.getRadioRecord()
|
||||
console.log("currRadioRow", currRadioRow)
|
||||
const currSpuRows = $SpuTable.getCheckboxRecords()
|
||||
console.log("currSpuRows", currSpuRows)
|
||||
const currUnitRows = $unitTable.getCheckboxRecords()
|
||||
console.log("currUnitRows", currUnitRows)
|
||||
|
||||
emit("getSelectedCgPlan", { ...currRadioRow, items: currSpuRows })
|
||||
emit("getSelectedLinkCode", { ...currRadioRow, items: currUnitRows })
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框关闭
|
||||
const onClose = () => {
|
||||
linkCgCodeDialogVisible.value = false
|
||||
linkCodeDialogVisible.value = false
|
||||
currRadioRowItems.value = []
|
||||
cgddPage.value = []
|
||||
linkCodeTableData.value = []
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
@@ -1,114 +0,0 @@
|
||||
<template>
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<el-dialog v-model="linkCgCodeDialogVisible" title="选择采购单" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<vxe-table
|
||||
v-show="step === 0"
|
||||
ref="linkCgPlanTableRef"
|
||||
border
|
||||
v-loading="linkCodeLoading"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:radio-config="{ labelField: '', trigger: 'row' }"
|
||||
:data="cgddPage"
|
||||
@radio-change="radioChangeEvent"
|
||||
>
|
||||
<vxe-column type="radio" width="60" align="center"></vxe-column>
|
||||
<vxe-column field="id" title="id" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planCode" title="编号" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planDate" title="单据日期" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="handlerUserId" title="经办人" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="checkStatus" title="审批状态" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
<!-- <pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-model:current-page="foodQueryForm.current"
|
||||
v-model:page-size="foodQueryForm.size"
|
||||
:total="total"
|
||||
/> -->
|
||||
<vxe-table
|
||||
v-show="step === 1"
|
||||
ref="linkCgPlanSpuTableRef"
|
||||
border
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:checkbox-config="{ trigger: 'row' }"
|
||||
:data="currRadioRowItems"
|
||||
>
|
||||
<vxe-column type="checkbox" width="60" align="center"></vxe-column>
|
||||
<vxe-column field="erpSpuId" title="erpSpuId" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="unit" title="包装单位" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="quantity" title="数量" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="purchasePrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="unitPrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="linkCgCodeDialogVisible = false">取消</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="step--">上一步</el-button>
|
||||
<el-button v-show="step === 0" type="primary" @click="step++" :disabled="currRadioRowItems.length <= 0">下一步</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="getSelectedRowData" :disabled="linkCodeLoading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="linkCgCodeDialog">
|
||||
import { ref } from "vue"
|
||||
import { VxeTableEvents } from "vxe-table"
|
||||
import { getCgInventoryPage } from "/@/api/supermarketerp/smErpCgBack"
|
||||
|
||||
const linkCgCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedCgPlan"])
|
||||
|
||||
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
|
||||
const linkCgPlanTableRef = ref() // 关联补货单对话框表格1ref
|
||||
const linkCgPlanSpuTableRef = ref() // 关联补货单对话框表格2ref
|
||||
const cgddPage = ref([]) // 采购申请列表数据
|
||||
const currRadioRowItems = ref([]) // 当前单选的表格行的items
|
||||
const step = ref(0) // 选择步骤
|
||||
|
||||
// 打开关联补货单对话框
|
||||
const openLinkCodeDialog = async () => {
|
||||
linkCgCodeDialogVisible.value = true
|
||||
step.value = 0
|
||||
linkCodeLoading.value = true
|
||||
try {
|
||||
const res = await getCgInventoryPage({ inventoryType: "3" }).finally(() => (linkCodeLoading.value = false))
|
||||
if (res.code === 0) {
|
||||
cgddPage.value = res.data.records
|
||||
}
|
||||
} catch (error) {
|
||||
cgddPage.value = []
|
||||
linkCodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 单选时
|
||||
const radioChangeEvent: VxeTableEvents.RadioChange<any> = ({ row }) => (currRadioRowItems.value = row.items)
|
||||
|
||||
// 获取选择的关联补货单对话框表格行数据
|
||||
const getSelectedRowData = () => {
|
||||
const $table = linkCgPlanTableRef.value
|
||||
const $SpuTable = linkCgPlanSpuTableRef.value
|
||||
if ($table && $SpuTable) {
|
||||
const currRadioRow = $table.getRadioRecord()
|
||||
console.log("currRadioRow", currRadioRow)
|
||||
const currSpuRows = $SpuTable.getCheckboxRecords()
|
||||
console.log("currSpuRows", currSpuRows)
|
||||
|
||||
emit("getSelectedCgPlan", { ...currRadioRow, items: currSpuRows })
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框关闭
|
||||
const onClose = () => {
|
||||
linkCgCodeDialogVisible.value = false
|
||||
currRadioRowItems.value = []
|
||||
cgddPage.value = []
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openLinkCodeDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -112,10 +112,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemSmErpInventoryRecords">
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from "vue-router"
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { fetchList, delObjs } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -149,11 +149,7 @@ const resetQuery = () => {
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile(
|
||||
"/supermarket/smErpInventoryRecords/export",
|
||||
Object.assign(state.queryForm, { ids: selectObjs }),
|
||||
"smErpInventoryRecords.xlsx",
|
||||
)
|
||||
downBlobFile("/supermarket/smErpInventoryRecords/export", Object.assign(state.queryForm, { ids: selectObjs }), "smErpCgInventory.xlsx")
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
|
||||
@@ -171,8 +171,14 @@
|
||||
@getSelectedSpuRows="getSelectedSpuRows"
|
||||
/>
|
||||
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<linkCgCodeDialog ref="linkCgCodeDialogRef" v-model="state.linkCgCodeDialogVisible" @getSelectedCgPlan="getSelectedCgPlan" />
|
||||
<linkCodeDialog
|
||||
ref="linkCgPlanDialogRef"
|
||||
v-model="state.linkCgPlanDialogVisible"
|
||||
title="关联采购订单"
|
||||
:getTableData="getCgInventoryPage"
|
||||
@getSelectedLinkCode="getSelectedLinkCode"
|
||||
/>
|
||||
<!-- {inventoryType: "3"} -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -188,14 +194,15 @@ import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import { Search } from "@element-plus/icons-vue"
|
||||
import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
|
||||
import linkCgCodeDialog from "/@/views/supermarketerp/smErpCgBack/components/linkCgCodeDialog.vue"
|
||||
import linkCodeDialog from "../components/linkCodeDialog.vue"
|
||||
import { getCgInventoryPage } from "/@/api/supermarketerp/common"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
||||
const linkCgCodeDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const linkCgPlanDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||
@@ -222,7 +229,7 @@ const state = reactive<{
|
||||
erpSpuSimpleAll: any
|
||||
linkCodeVisible: boolean
|
||||
erpSpuSelectDialogVisible: boolean
|
||||
linkCgCodeDialogVisible: boolean
|
||||
linkCgPlanDialogVisible: boolean
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
@@ -232,7 +239,7 @@ const state = reactive<{
|
||||
|
||||
linkCodeVisible: false, // 关联采购申请单对话框开关
|
||||
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
linkCgCodeDialogVisible: false, // 关联采购申请单对话框开关
|
||||
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
|
||||
})
|
||||
|
||||
// 基本信息表单校验规则
|
||||
@@ -279,16 +286,16 @@ const getInitData = async () => {
|
||||
}
|
||||
|
||||
// 点击关联采购申请编号
|
||||
const handleClickLinkCode = () => linkCgCodeDialogRef.value.openLinkCodeDialog()
|
||||
const handleClickLinkCode = () => linkCgPlanDialogRef.value.openLinkCodeDialog()
|
||||
|
||||
// 获取选择的采购申请
|
||||
const getSelectedCgPlan = (selectionRows: any) => {
|
||||
const getSelectedLinkCode = (selectionRows: any) => {
|
||||
console.log("被选择的关联数据", selectionRows)
|
||||
|
||||
baseDataForm.linkCode = selectionRows.planCode
|
||||
state.editableTableData = selectionRows.items
|
||||
state.erpSpuItemsMemo = selectionRows.items
|
||||
state.linkCgCodeDialogVisible = false
|
||||
state.linkCgPlanDialogVisible = false
|
||||
}
|
||||
|
||||
// 顶部表格行新增
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
<template>
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<el-dialog v-model="linkCgCodeDialogVisible" title="选择采购单" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<vxe-table
|
||||
v-show="step === 0"
|
||||
ref="linkCgPlanTableRef"
|
||||
border
|
||||
v-loading="linkCodeLoading"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:radio-config="{ labelField: '', trigger: 'row' }"
|
||||
:data="cgsqPage"
|
||||
@radio-change="radioChangeEvent"
|
||||
>
|
||||
<vxe-column type="radio" width="60" align="center"></vxe-column>
|
||||
<!-- <vxe-column field="id" title="id" align="center" width="200"></vxe-column>-->
|
||||
|
||||
<vxe-column field="planCode" title="编号" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planDate" title="单据日期" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="productName" title="商品名称" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="handlerUserId" title="经办人" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="checkStatus" title="审批状态" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
<!-- <pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-model:current-page="foodQueryForm.current"
|
||||
v-model:page-size="foodQueryForm.size"
|
||||
:total="total"
|
||||
/> -->
|
||||
<vxe-table
|
||||
v-show="step === 1"
|
||||
ref="linkCgPlanSpuTableRef"
|
||||
border
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:checkbox-config="{ trigger: 'row' }"
|
||||
:data="currRadioRowItems"
|
||||
>
|
||||
<vxe-column type="checkbox" width="60" align="center"></vxe-column>
|
||||
<!-- <vxe-column field="erpSpuId" title="erpSpuId" align="center" width="200"></vxe-column>-->
|
||||
<vxe-column field="unit" title="包装单位" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="quantity" title="数量" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="purchasePrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="unitPrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="linkCgCodeDialogVisible = false">取消</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="step--">上一步</el-button>
|
||||
<el-button v-show="step === 0" type="primary" @click="step++" :disabled="currRadioRowItems.length <= 0">下一步</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="getSelectedRowData" :disabled="linkCodeLoading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="linkCgCodeDialog">
|
||||
import { ref } from "vue"
|
||||
import { getCgsqPage } from "/@/api/supermarketerp/smErpCgDd"
|
||||
import { VxeTableEvents } from "vxe-table"
|
||||
|
||||
const linkCgCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedCgPlan"])
|
||||
|
||||
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
|
||||
const linkCgPlanTableRef = ref() // 关联补货单对话框表格1ref
|
||||
const linkCgPlanSpuTableRef = ref() // 关联补货单对话框表格2ref
|
||||
const cgsqPage = ref([]) // 采购申请列表数据
|
||||
const currRadioRowItems = ref([]) // 当前单选的表格行的items
|
||||
const step = ref(0) // 选择步骤
|
||||
|
||||
// 打开关联补货单对话框
|
||||
const openLinkCodeDialog = async () => {
|
||||
linkCgCodeDialogVisible.value = true
|
||||
step.value = 0
|
||||
linkCodeLoading.value = true
|
||||
try {
|
||||
const res = await getCgsqPage().finally(() => (linkCodeLoading.value = false))
|
||||
if (res.code === 0) {
|
||||
cgsqPage.value = res.data.records
|
||||
}
|
||||
} catch (error) {
|
||||
cgsqPage.value = []
|
||||
linkCodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 单选时
|
||||
const radioChangeEvent: VxeTableEvents.RadioChange<any> = ({ row }) => (currRadioRowItems.value = row.items)
|
||||
|
||||
// 获取选择的关联补货单对话框表格行数据
|
||||
const getSelectedRowData = () => {
|
||||
const $table = linkCgPlanTableRef.value
|
||||
const $SpuTable = linkCgPlanSpuTableRef.value
|
||||
if ($table && $SpuTable) {
|
||||
const currRadioRow = $table.getRadioRecord()
|
||||
console.log("currRadioRow", currRadioRow)
|
||||
const currSpuRows = $SpuTable.getCheckboxRecords()
|
||||
console.log("currSpuRows", currSpuRows)
|
||||
|
||||
emit("getSelectedCgPlan", { ...currRadioRow, items: currSpuRows })
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框关闭
|
||||
const onClose = () => {
|
||||
linkCgCodeDialogVisible.value = false
|
||||
currRadioRowItems.value = []
|
||||
cgsqPage.value = []
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openLinkCodeDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -176,13 +176,18 @@
|
||||
@getSelectedSpuRows="getSelectedSpuRows"
|
||||
/>
|
||||
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<linkCgCodeDialog ref="linkCgCodeDialogRef" v-model="state.linkCgCodeDialogVisible" @getSelectedCgPlan="getSelectedCgPlan" />
|
||||
<linkCodeDialog
|
||||
ref="linkCgPlanDialogRef"
|
||||
v-model="state.linkCgPlanDialogVisible"
|
||||
title="关联补货申请"
|
||||
:getTableData="getCgsqPage"
|
||||
@getSelectedLinkCode="getSelectedLinkCode"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="cgPlanOption">
|
||||
<script setup lang="ts" name="smErpCgDd">
|
||||
import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
@@ -193,7 +198,8 @@ import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import { Search } from "@element-plus/icons-vue"
|
||||
import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
|
||||
import linkCgCodeDialog from "/@/views/supermarketerp/smErpCgDd/components/linkCgCodeDialog.vue"
|
||||
import linkCodeDialog from "../components/linkCodeDialog.vue"
|
||||
import { getCgsqPage } from "/@/api/supermarketerp/smErpCgDd"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -201,7 +207,7 @@ const router = useRouter()
|
||||
const route = useRoute()
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
||||
const linkCgCodeDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const linkCgPlanDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||
@@ -230,7 +236,7 @@ const state = reactive<{
|
||||
erpSpuSimpleAll: any
|
||||
linkCodeVisible: boolean
|
||||
erpSpuSelectDialogVisible: boolean
|
||||
linkCgCodeDialogVisible: boolean
|
||||
linkCgPlanDialogVisible: boolean
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
@@ -239,7 +245,7 @@ const state = reactive<{
|
||||
erpSpuSimpleAll: [], // 简要商品列表
|
||||
linkCodeVisible: false, // 关联采购申请单对话框开关
|
||||
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
linkCgCodeDialogVisible: false, // 关联采购申请单对话框开关
|
||||
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
|
||||
})
|
||||
|
||||
// 基本信息表单校验规则
|
||||
@@ -286,16 +292,16 @@ const getInitData = async () => {
|
||||
}
|
||||
|
||||
// 点击关联采购申请编号
|
||||
const handleClickLinkCode = () => linkCgCodeDialogRef.value.openLinkCodeDialog()
|
||||
const handleClickLinkCode = () => linkCgPlanDialogRef.value.openLinkCodeDialog()
|
||||
|
||||
// 获取选择的采购申请
|
||||
const getSelectedCgPlan = (selectionRows: any) => {
|
||||
const getSelectedLinkCode = (selectionRows: any) => {
|
||||
console.log("被选择的关联数据", selectionRows)
|
||||
|
||||
baseDataForm.linkCode = selectionRows.planCode
|
||||
state.editableTableData = selectionRows.items
|
||||
state.erpSpuItemsMemo = selectionRows.items
|
||||
state.linkCgCodeDialogVisible = false
|
||||
state.linkCgPlanDialogVisible = false
|
||||
}
|
||||
|
||||
// 顶部表格行新增
|
||||
|
||||
+5
-9
@@ -112,10 +112,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemSmErpInventoryRecords">
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from "vue-router"
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { fetchList, delObjs } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -149,11 +149,7 @@ const resetQuery = () => {
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile(
|
||||
"/supermarket/smErpInventoryRecords/export",
|
||||
Object.assign(state.queryForm, { ids: selectObjs }),
|
||||
"smErpInventoryRecords.xlsx",
|
||||
)
|
||||
downBlobFile("/supermarket/smErpInventoryRecords/export", Object.assign(state.queryForm, { ids: selectObjs }), "smErpCgInventory.xlsx")
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
@@ -163,10 +159,10 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
}
|
||||
|
||||
// 点击创建出库入库记录表
|
||||
const handleClickCreateInventoryRecord = () => router.push({ path: "/supermarketerp/smErpInventoryRecords/smErpInventoryRecordsOption" })
|
||||
const handleClickCreateInventoryRecord = () => router.push({ path: "/supermarketerp/smErpCgInventory/smErpCgInventoryOption" })
|
||||
// 点击编辑出库入库记录表
|
||||
const handleClickEditInventoryRecord = (id: string) =>
|
||||
router.push({ path: "/supermarketerp/smErpInventoryRecords/smErpInventoryRecordsOption", query: { id } })
|
||||
router.push({ path: "/supermarketerp/smErpCgInventory/smErpCgInventoryOption", query: { id } })
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
+18
-12
@@ -177,24 +177,30 @@
|
||||
@getSelectedSpuRows="getSelectedSpuRows"
|
||||
/>
|
||||
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<linkCgCodeDialog ref="linkCgCodeDialogRef" v-model="state.linkCgCodeDialogVisible" @getSelectedCgPlan="getSelectedCgPlan" />
|
||||
<linkCodeDialog
|
||||
ref="linkCgPlanDialogRef"
|
||||
v-model="state.linkCgPlanDialogVisible"
|
||||
title="关联采购订单"
|
||||
:getTableData="getCgddPage"
|
||||
@getSelectedLinkCode="getSelectedLinkCode"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="cgPlanOption">
|
||||
<script setup lang="ts" name="smErpCgInventory">
|
||||
import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpCgInventory"
|
||||
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import { Search } from "@element-plus/icons-vue"
|
||||
import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
|
||||
import linkCgCodeDialog from "/@/views/supermarketerp/smErpInventoryRecords/components/linkCgCodeDialog.vue"
|
||||
import linkCodeDialog from "../components/linkCodeDialog.vue"
|
||||
import { getCgddPage } from "/@/api/supermarketerp/smErpCgInventory"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -202,7 +208,7 @@ const router = useRouter()
|
||||
const route = useRoute()
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
||||
const linkCgCodeDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const linkCgPlanDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||
@@ -230,7 +236,7 @@ const state = reactive<{
|
||||
erpSpuSimpleAll: any
|
||||
linkCodeVisible: boolean
|
||||
erpSpuSelectDialogVisible: boolean
|
||||
linkCgCodeDialogVisible: boolean
|
||||
linkCgPlanDialogVisible: boolean
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
@@ -240,7 +246,7 @@ const state = reactive<{
|
||||
|
||||
linkCodeVisible: false, // 关联采购申请单对话框开关
|
||||
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
linkCgCodeDialogVisible: false, // 关联采购申请单对话框开关
|
||||
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
|
||||
})
|
||||
|
||||
// 基本信息表单校验规则
|
||||
@@ -287,16 +293,16 @@ const getInitData = async () => {
|
||||
}
|
||||
|
||||
// 点击关联采购申请编号
|
||||
const handleClickLinkCode = () => linkCgCodeDialogRef.value.openLinkCodeDialog()
|
||||
const handleClickLinkCode = () => linkCgPlanDialogRef.value.openLinkCodeDialog()
|
||||
|
||||
// 获取选择的采购申请
|
||||
const getSelectedCgPlan = (selectionRows: any) => {
|
||||
const getSelectedLinkCode = (selectionRows: any) => {
|
||||
console.log("被选择的关联数据", selectionRows)
|
||||
|
||||
baseDataForm.linkCode = selectionRows.code
|
||||
state.editableTableData = selectionRows.items
|
||||
state.erpSpuItemsMemo = selectionRows.items
|
||||
state.linkCgCodeDialogVisible = false
|
||||
state.linkCgPlanDialogVisible = false
|
||||
}
|
||||
|
||||
// 顶部表格行新增
|
||||
@@ -461,7 +467,7 @@ const onSave = async () => {
|
||||
(await editableTableValidate()) &&
|
||||
(await submitData()) &&
|
||||
clearData() &&
|
||||
router.replace({ path: "/supermarketerp/smErpInventoryRecords/index" })
|
||||
router.replace({ path: "/supermarketerp/smErpCgInventory/index" })
|
||||
}
|
||||
|
||||
// 校验基本数据表单 成功返回 true 失败返回 undefined
|
||||
@@ -1,649 +0,0 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div v-loading="loading" class="layout-padding-auto layout-padding-view" style="overflow: scroll">
|
||||
<el-form ref="baseDataFormRef" :model="baseDataForm" :rules="dataRules" label-width="140px">
|
||||
<div class="flex flex-wrap">
|
||||
<el-form-item label="编号" prop="planCode">
|
||||
<el-input v-model="baseDataForm.planCode" readonly style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item label="单据日期" prop="planDate">
|
||||
<el-input v-model="baseDataForm.planDate" readonly style="width: 200px" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="经办人" prop="handlerUserId">
|
||||
<SelectHandlerUser v-model.trim="baseDataForm.handlerUserId" placeholder="请选择经办人" style="width: 200px" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model.trim="baseDataForm.remark" placeholder="请输入备注" maxlength="200" style="width: 200px" />
|
||||
</el-form-item>
|
||||
</div>
|
||||
</el-form>
|
||||
|
||||
<el-row class="my-3">
|
||||
<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-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpSpuIds.length <= 0">删除选中</el-button>
|
||||
<el-button @click="clearData">清空数据</el-button>
|
||||
<el-button @click="handleClickSpuSelect">商品选择</el-button>
|
||||
</el-row>
|
||||
|
||||
<vxe-table
|
||||
ref="editableTableRef"
|
||||
border
|
||||
:loading="loading"
|
||||
show-overflow
|
||||
max-height="400"
|
||||
:edit-config="{
|
||||
trigger: 'click',
|
||||
mode: 'cell',
|
||||
beforeEditMethod({ row, column }:any) {
|
||||
// 禁止编辑
|
||||
if (column.property === '') {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
},
|
||||
}"
|
||||
:column-config="{ resizable: true }"
|
||||
:row-config="{ isHover: true }"
|
||||
:resizable-config="{ dragMode: 'fixed' }"
|
||||
:data="state.editableTableData"
|
||||
:edit-rules="validRules"
|
||||
@checkbox-all="selectChangeEvent"
|
||||
@checkbox-change="selectChangeEvent"
|
||||
size="mini"
|
||||
align="center"
|
||||
>
|
||||
<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>
|
||||
<span v-else>{{ row.erpSpuId && state.erpSpuSimpleAll.find((item: any) => item.id === row.erpSpuId).productName }}</span>
|
||||
</template>
|
||||
</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-select>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<span v-if="row.unitId">{{ row.erpUnitVos?.find((item: any) => item.id == row.unitId)?.unit }}</span>
|
||||
<span v-else style="color: #c0c4cf">请选择</span>
|
||||
</template>
|
||||
</vxe-column>
|
||||
|
||||
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||
<template #edit="{ row }">
|
||||
<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">
|
||||
<el-tooltip effect="dark" content="返回列表页面" placement="top">
|
||||
<el-button type="primary" plain @click="router.back()">取消</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="!baseDataForm.id" effect="dark" content="保存并清空数据" placement="top">
|
||||
<el-button type="primary" plain @click="onContinueAdd">继续添加</el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip effect="dark" content="保存并返回列表页面" placement="top">
|
||||
<el-button type="primary" plain @click="onSave">保存</el-button>
|
||||
</el-tooltip>
|
||||
</el-row>
|
||||
|
||||
<!-- 商品选择对话框 -->
|
||||
<el-dialog
|
||||
v-model="state.spuSelectDialogVisible"
|
||||
title="选择商品"
|
||||
width="70%"
|
||||
:close-on-click-modal="false"
|
||||
draggable
|
||||
@close="state.selectedSpuObjs = []"
|
||||
>
|
||||
<!-- <el-row>
|
||||
<el-form :model="foodQueryForm" ref="queryRef" :inline="true" @keyup.enter="getDataListAndSelect">
|
||||
<el-form-item label="商品名称" prop="name">
|
||||
<el-input placeholder="请输入商品名称" v-model="foodQueryForm.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="商品分类" prop="categoryId">
|
||||
<select-ctcg v-model="foodQueryForm.categoryId" style="width: 200px" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="search" type="primary" @click="getDataListAndSelect">查询</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-row> -->
|
||||
|
||||
<el-table
|
||||
ref="spuMultipleTableRef"
|
||||
:data="state.spuDataList"
|
||||
v-loading="spuListLoading"
|
||||
@select="handleSelect"
|
||||
@select-all="handleSelectAll"
|
||||
@selection-change="selectionChangeHandle"
|
||||
:row-key="(row:any) => row.id"
|
||||
:reserve-selection="true"
|
||||
@row-click="rowClick"
|
||||
:row-style="{ cursor: 'pointer' }"
|
||||
>
|
||||
<el-table-column type="selection" width="40" align="center" fixed="left" />
|
||||
<el-table-column type="index" label="#" width="50" align="center" fixed="left" />
|
||||
<el-table-column prop="productName" label="商品名称" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="barcode" label="自编码/条码" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="productCode" label="货号" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="brandId" label="品牌" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="categoryId" label="分类" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="deptId" label="商户" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="supplierId" label="货商" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="status" label="状态" min-width="100px" align="center" show-overflow-tooltip />
|
||||
<el-table-column prop="picUrl" label="商品封面图" align="center" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
<preview-image @click.stop :src="scope.row.picUrl" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="stock" label="库存" min-width="100px" align="center" show-overflow-tooltip />
|
||||
</el-table>
|
||||
<!-- <pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-model:current-page="foodQueryForm.current"
|
||||
v-model:page-size="foodQueryForm.size"
|
||||
:total="total"
|
||||
/> -->
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="state.spuSelectDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="cgPlanOption">
|
||||
import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpCgPlan"
|
||||
import { getPlanCode, getErpSpuPage, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { storePrice } from "/@/utils/formatMoney"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
|
||||
// 基本表单数据类型
|
||||
interface FormVO {
|
||||
id: string | undefined
|
||||
planCode: string
|
||||
orderNumber: string
|
||||
planDate: string
|
||||
supplierId: string
|
||||
handlerUserId: string
|
||||
remark: string
|
||||
[key: string]: string | undefined
|
||||
}
|
||||
|
||||
// 可编辑表格行数据类型
|
||||
interface RowVO {
|
||||
id?: string
|
||||
erpSpuId: string
|
||||
quantity: number | null
|
||||
unitPrice: number | null
|
||||
totalAmount: number | null
|
||||
remark: string
|
||||
unitId: string
|
||||
}
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const spuListLoading = ref(false) // 对话框商品列表加载
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<RowVO>>() // 可编辑表格ref
|
||||
const spuMultipleTableRef = ref() // 对话框多选表格ref
|
||||
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||
|
||||
// 基本信息表单数据
|
||||
const baseDataForm = reactive<FormVO>({
|
||||
id: undefined,
|
||||
planCode: "",
|
||||
orderNumber: "",
|
||||
planDate: formatDate(new Date(), "YYYY-mm-dd"),
|
||||
supplierId: "",
|
||||
handlerUserId: "",
|
||||
remark: "",
|
||||
})
|
||||
const state = reactive<{
|
||||
editableTableData: RowVO[]
|
||||
erpSpuItemsMemo: RowVO[]
|
||||
selectedRowsErpSpuIds: string[]
|
||||
insertedRowNumber: number
|
||||
erpSpuSimpleAll: any
|
||||
spuSelectDialogVisible: boolean
|
||||
spuDataList: any[]
|
||||
selectedSpuObjs: any[]
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
selectedRowsErpSpuIds: [], // 可编辑表格已选行的ErpSpuId
|
||||
insertedRowNumber: 0, // 可编辑表格插入行的行号
|
||||
erpSpuSimpleAll: [], // 简要商品列表
|
||||
|
||||
spuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
spuDataList: [], // 商品列表
|
||||
selectedSpuObjs: [], // 已选中的商品列表项
|
||||
})
|
||||
|
||||
// 基本信息表单校验规则
|
||||
const dataRules = ref({
|
||||
planCode: [{ required: true, message: "采购计划编号不能为空", trigger: "blur" }],
|
||||
planDate: [{ required: true, message: "采购计划单据日期不能为空", trigger: "blur" }],
|
||||
supplierId: [{ required: true, message: "货商不能为空", trigger: "blur" }],
|
||||
})
|
||||
|
||||
// 可编辑表格校验规则
|
||||
const validRules = ref<VxeTablePropTypes.EditRules<RowVO>>({
|
||||
unitId: [{ required: true, message: "必须选择" }],
|
||||
quantity: [{ required: true, type: "number", min: 1, max: 99, message: "数值范围1~99" }],
|
||||
})
|
||||
|
||||
// 初始化数据
|
||||
const getInitData = async () => {
|
||||
baseDataForm.id = undefined
|
||||
const id = route.query.id as string
|
||||
if (id) {
|
||||
loading.value = true
|
||||
// 获取采购计划数据 & 获取简要商品列表
|
||||
const [cgPlanData, erpSpuSimpleAll] = await Promise.allSettled([getObj(id), getErpSpuSimpleAll()])
|
||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||
.finally(() => (loading.value = false))
|
||||
|
||||
if (cgPlanData && cgPlanData.code === 0) {
|
||||
Object.assign(baseDataForm, {
|
||||
id: cgPlanData.data.id,
|
||||
planCode: cgPlanData.data.planCode,
|
||||
orderNumber: cgPlanData.data.orderNumber,
|
||||
planDate: cgPlanData.data.planDate,
|
||||
supplierId: cgPlanData.data.supplierId,
|
||||
handlerUserId: cgPlanData.data.handlerUserId,
|
||||
remark: cgPlanData.data.remark,
|
||||
})
|
||||
state.editableTableData = cgPlanData.data.items
|
||||
state.erpSpuItemsMemo = cgPlanData.data.items
|
||||
}
|
||||
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
||||
}
|
||||
|
||||
// 获取货商选项 & 获取采购计划编号
|
||||
const [supplierTypeOptions, planCode] = await Promise.allSettled([getSupplierTypeOptions(), getPlanCode({ type: 1 })]).then((results) =>
|
||||
results.map((result) => (result.status === "fulfilled" ? result.value : null)),
|
||||
)
|
||||
supplierTypeOptions && supplierTypeOptions.code === 0 && (supplierTypeDict.value = supplierTypeOptions.data)
|
||||
planCode && planCode.code === 0 && (baseDataForm.planCode = planCode.data)
|
||||
}
|
||||
|
||||
// 可编辑表格行勾选
|
||||
const selectChangeEvent: VxeTableEvents.CheckboxChange<RowVO> = ({ checked }) => {
|
||||
const $table = editableTableRef.value
|
||||
if ($table) {
|
||||
const records = $table.getCheckboxRecords()
|
||||
console.log(checked ? "勾选事件" : "取消事件", records)
|
||||
state.selectedRowsErpSpuIds = records.map((item) => item.erpSpuId)
|
||||
}
|
||||
}
|
||||
|
||||
// 顶部表格行新增
|
||||
const addEvent = () => {
|
||||
const newRow: RowVO = {
|
||||
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: RowVO = {
|
||||
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: RowVO = {
|
||||
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
|
||||
if ($table) {
|
||||
const selectRecords = $table.getCheckboxRecords()
|
||||
if (selectRecords.length > 0) {
|
||||
state.editableTableData = state.editableTableData.filter((item) => !selectRecords.some((row) => row.erpSpuId === item.erpSpuId))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 点击商品选择
|
||||
const handleClickSpuSelect = async () => {
|
||||
state.selectedSpuObjs = [...state.editableTableData]
|
||||
|
||||
state.spuSelectDialogVisible = true
|
||||
spuListLoading.value = true
|
||||
try {
|
||||
const { code, data } = await getErpSpuPage().finally(() => (spuListLoading.value = false))
|
||||
if (code === 0) {
|
||||
state.spuDataList = data.records.map((item: RowVO) => ({ ...item, erpSpuId: item.id }))
|
||||
|
||||
// 勾选已经选择的商品
|
||||
const target = state.spuDataList.filter((row: any) => state.selectedSpuObjs.some((item: any) => row.erpSpuId === item.erpSpuId))
|
||||
target.forEach((row: any) => nextTick(() => spuMultipleTableRef.value!.toggleRowSelection(row)))
|
||||
}
|
||||
} catch (error) {
|
||||
state.spuDataList = []
|
||||
spuListLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 点击商品列表表格行
|
||||
const rowClick = (row: any) => {
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1
|
||||
? // state.selectedSpuObjs.indexOf(row) === -1
|
||||
state.selectedSpuObjs.push(row)
|
||||
: state.selectedSpuObjs.splice(
|
||||
// state.selectedSpuObjs.indexOf(row)
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId),
|
||||
1,
|
||||
)
|
||||
console.log("click-select", state.selectedSpuObjs)
|
||||
spuMultipleTableRef.value.toggleRowSelection(row)
|
||||
}
|
||||
|
||||
// 选中商品列表表格行
|
||||
const handleSelect = (selectedRows: any[], row: any) => {
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1
|
||||
? // state.selectedSpuObjs.indexOf(row) === -1
|
||||
state.selectedSpuObjs.push(row)
|
||||
: state.selectedSpuObjs.splice(
|
||||
// state.selectedSpuObjs.indexOf(row)
|
||||
state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId),
|
||||
1,
|
||||
)
|
||||
console.log("check-select", state.selectedSpuObjs)
|
||||
}
|
||||
|
||||
// 全选和反全选商品列表表格行
|
||||
const handleSelectAll = (selectedRows: any[]) => {
|
||||
if (selectedRows.length > 0) {
|
||||
selectedRows.forEach((row: any) => {
|
||||
if (state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId) === -1) {
|
||||
state.selectedSpuObjs.push(row)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
state.spuDataList.forEach((row: any) => {
|
||||
const index = state.selectedSpuObjs.findIndex((item: any) => item.erpSpuId === row.erpSpuId)
|
||||
if (index !== -1) {
|
||||
state.selectedSpuObjs.splice(index, 1)
|
||||
}
|
||||
})
|
||||
}
|
||||
console.log("checkAll-select", state.selectedSpuObjs)
|
||||
}
|
||||
|
||||
// 商品表格多选
|
||||
const selectionChangeHandle = (rows: any) => {
|
||||
// console.log("onChange-selects", rows)
|
||||
}
|
||||
|
||||
// 商品选择对话框确认
|
||||
const handleSelectDialogConfirm = () => {
|
||||
// 筛选新勾选的项
|
||||
const addedItems = state.selectedSpuObjs
|
||||
.filter((item: any) => !state.editableTableData.some((editableTableItem: RowVO) => editableTableItem.erpSpuId === item.erpSpuId))
|
||||
.map((addItem) => {
|
||||
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpSpuId === addItem.erpSpuId)
|
||||
if (index !== -1) return state.erpSpuItemsMemo[index]
|
||||
return { ...addItem, isNew: true }
|
||||
}) // 为新增的数据项添加isNew标志,若该项原本已经存在,则不添加isNew标志
|
||||
// 仅添加新勾选的项
|
||||
state.editableTableData = [...state.editableTableData, ...addedItems]
|
||||
|
||||
// 筛选取消勾选的项
|
||||
const removedItems = state.editableTableData.filter(
|
||||
(item: any) => !state.selectedSpuObjs.some((selectedItem: any) => selectedItem.erpSpuId === item.erpSpuId),
|
||||
)
|
||||
// 仅移除取消勾选的项
|
||||
state.editableTableData = state.editableTableData.filter(
|
||||
(item: any) => !removedItems.some((removeItem: any) => removeItem.erpSpuId === item.erpSpuId),
|
||||
)
|
||||
// state.editableTableData.push(item)
|
||||
// nextTick(() => {
|
||||
// const $table = editableTableRef.value
|
||||
// if ($table) {
|
||||
// $table.setRow(item)
|
||||
// }
|
||||
// })
|
||||
state.spuSelectDialogVisible = false
|
||||
console.log("state.editableTableData", state.editableTableData)
|
||||
}
|
||||
|
||||
// 整理数据
|
||||
const cgPlanSpuItems = computed(() => {
|
||||
return state.editableTableData.map((item: any) => {
|
||||
const unit = item.erpUnitVos.find((unitItem: any) => unitItem.id === item.unitId)
|
||||
return {
|
||||
id: item.isNew ? undefined : item.id,
|
||||
erpSpuId: item.erpSpuId,
|
||||
quantity: item.quantity,
|
||||
unitPrice: unit.purchasePrice ? storePrice(unit?.purchasePrice) : 0,
|
||||
totalAmount: Number(unit?.purchasePrice || 0) * item.quantity,
|
||||
remark: item.remark,
|
||||
unitId: item.unitId,
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// 点击继续添加
|
||||
const onContinueAdd = async () => {
|
||||
console.log("baseDataForm", baseDataForm)
|
||||
console.log("state.editableTableData", state.editableTableData)
|
||||
;(await baseDataFormValidate()) && checkSelectSpu() && (await editableTableValidate()) && (await submitData()) && clearData()
|
||||
}
|
||||
|
||||
// 点击保存
|
||||
const onSave = async () => {
|
||||
console.log("baseDataForm", baseDataForm)
|
||||
console.log("state.editableTableData", state.editableTableData)
|
||||
;(await baseDataFormValidate()) &&
|
||||
checkSelectSpu() &&
|
||||
(await editableTableValidate()) &&
|
||||
(await submitData()) &&
|
||||
clearData() &&
|
||||
router.replace({ path: "/supermarketerp/smErpCgPlan/index" })
|
||||
}
|
||||
|
||||
// 校验基本数据表单 成功返回 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.selectedRowsErpSpuIds = []
|
||||
state.selectedSpuObjs = []
|
||||
return true
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getInitData()
|
||||
})
|
||||
</script>
|
||||
@@ -1,115 +0,0 @@
|
||||
<template>
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<el-dialog v-model="linkCgCodeDialogVisible" title="选择采购单" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<vxe-table
|
||||
v-show="step === 0"
|
||||
ref="linkCgPlanTableRef"
|
||||
border
|
||||
v-loading="linkCodeLoading"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:radio-config="{ labelField: '', trigger: 'row' }"
|
||||
:data="cgddPage"
|
||||
@radio-change="radioChangeEvent"
|
||||
>
|
||||
<vxe-column type="radio" width="60" align="center"></vxe-column>
|
||||
<!-- <vxe-column field="id" title="id" align="center" width="200"></vxe-column>-->
|
||||
<vxe-column field="productName" title="商品" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="code" title="编号" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="ddDate" title="单据日期" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="handlerUserId" title="经办人" align="center" width="100"></vxe-column>
|
||||
<!-- <vxe-column field="checkStatus" title="审批状态" align="center" width="100"></vxe-column>-->
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
<!-- <pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-model:current-page="foodQueryForm.current"
|
||||
v-model:page-size="foodQueryForm.size"
|
||||
:total="total"
|
||||
/> -->
|
||||
<vxe-table
|
||||
v-show="step === 1"
|
||||
ref="linkCgPlanSpuTableRef"
|
||||
border
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:checkbox-config="{ trigger: 'row' }"
|
||||
:data="currRadioRowItems"
|
||||
>
|
||||
<vxe-column type="checkbox" width="60" align="center"></vxe-column>
|
||||
<!-- <vxe-column field="erpSpuId" title="erpSpuId" align="center" width="200"></vxe-column>-->
|
||||
<vxe-column field="unit" title="包装单位" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="quantity" title="数量" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="purchasePrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="unitPrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="linkCgCodeDialogVisible = false">取消</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="step--">上一步</el-button>
|
||||
<el-button v-show="step === 0" type="primary" @click="step++" :disabled="currRadioRowItems.length <= 0">下一步</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="getSelectedRowData" :disabled="linkCodeLoading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="linkCgCodeDialog">
|
||||
import { ref } from "vue"
|
||||
import { getCgddPage } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { VxeTableEvents } from "vxe-table"
|
||||
|
||||
const linkCgCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedCgPlan"])
|
||||
|
||||
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
|
||||
const linkCgPlanTableRef = ref() // 关联补货单对话框表格1ref
|
||||
const linkCgPlanSpuTableRef = ref() // 关联补货单对话框表格2ref
|
||||
const cgddPage = ref([]) // 采购申请列表数据
|
||||
const currRadioRowItems = ref([]) // 当前单选的表格行的items
|
||||
const step = ref(0) // 选择步骤
|
||||
|
||||
// 打开关联补货单对话框
|
||||
const openLinkCodeDialog = async () => {
|
||||
linkCgCodeDialogVisible.value = true
|
||||
step.value = 0
|
||||
linkCodeLoading.value = true
|
||||
try {
|
||||
const res = await getCgddPage().finally(() => (linkCodeLoading.value = false))
|
||||
if (res.code === 0) {
|
||||
cgddPage.value = res.data.records
|
||||
}
|
||||
} catch (error) {
|
||||
cgddPage.value = []
|
||||
linkCodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 单选时
|
||||
const radioChangeEvent: VxeTableEvents.RadioChange<any> = ({ row }) => (currRadioRowItems.value = row.items)
|
||||
|
||||
// 获取选择的关联补货单对话框表格行数据
|
||||
const getSelectedRowData = () => {
|
||||
const $table = linkCgPlanTableRef.value
|
||||
const $SpuTable = linkCgPlanSpuTableRef.value
|
||||
if ($table && $SpuTable) {
|
||||
const currRadioRow = $table.getRadioRecord()
|
||||
console.log("currRadioRow", currRadioRow)
|
||||
const currSpuRows = $SpuTable.getCheckboxRecords()
|
||||
console.log("currSpuRows", currSpuRows)
|
||||
|
||||
emit("getSelectedCgPlan", { ...currRadioRow, items: currSpuRows })
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框关闭
|
||||
const onClose = () => {
|
||||
linkCgCodeDialogVisible.value = false
|
||||
currRadioRowItems.value = []
|
||||
cgddPage.value = []
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openLinkCodeDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -1,114 +0,0 @@
|
||||
<template>
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<el-dialog v-model="linkCgCodeDialogVisible" title="选择采购单" width="70%" :close-on-click-modal="false" draggable @close="onClose">
|
||||
<vxe-table
|
||||
v-show="step === 0"
|
||||
ref="linkCgPlanTableRef"
|
||||
border
|
||||
v-loading="linkCodeLoading"
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:radio-config="{ labelField: '', trigger: 'row' }"
|
||||
:data="cgddPage"
|
||||
@radio-change="radioChangeEvent"
|
||||
>
|
||||
<vxe-column type="radio" width="60" align="center"></vxe-column>
|
||||
<vxe-column field="id" title="id" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planCode" title="编号" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="planDate" title="单据日期" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="handlerUserId" title="经办人" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="checkStatus" title="审批状态" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
<!-- <pagination
|
||||
@size-change="sizeChangeHandle"
|
||||
@current-change="currentChangeHandle"
|
||||
v-model:current-page="foodQueryForm.current"
|
||||
v-model:page-size="foodQueryForm.size"
|
||||
:total="total"
|
||||
/> -->
|
||||
<vxe-table
|
||||
v-show="step === 1"
|
||||
ref="linkCgPlanSpuTableRef"
|
||||
border
|
||||
:row-config="{ isCurrent: true, isHover: true }"
|
||||
:checkbox-config="{ trigger: 'row' }"
|
||||
:data="currRadioRowItems"
|
||||
>
|
||||
<vxe-column type="checkbox" width="60" align="center"></vxe-column>
|
||||
<vxe-column field="erpSpuId" title="erpSpuId" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="unit" title="包装单位" align="center" width="200"></vxe-column>
|
||||
<vxe-column field="quantity" title="数量" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="purchasePrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="unitPrice" title="进价" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="totalAmount" title="累计总金额" align="center" width="100"></vxe-column>
|
||||
<vxe-column field="remark" title="备注" show-overflow align="center" min-width="100"></vxe-column>
|
||||
</vxe-table>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="linkCgCodeDialogVisible = false">取消</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="step--">上一步</el-button>
|
||||
<el-button v-show="step === 0" type="primary" @click="step++" :disabled="currRadioRowItems.length <= 0">下一步</el-button>
|
||||
<el-button v-show="step === 1" type="primary" @click="getSelectedRowData" :disabled="linkCodeLoading">确认</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="linkCgCodeDialog">
|
||||
import { ref } from "vue"
|
||||
import { VxeTableEvents } from "vxe-table"
|
||||
import { getCgInventoryPage } from "/@/api/supermarketerp/smErpRetailBack"
|
||||
|
||||
const linkCgCodeDialogVisible = defineModel()
|
||||
const emit = defineEmits(["getSelectedCgPlan"])
|
||||
|
||||
const linkCodeLoading = ref(false) // 关联采购申请单对话框加载状态
|
||||
const linkCgPlanTableRef = ref() // 关联补货单对话框表格1ref
|
||||
const linkCgPlanSpuTableRef = ref() // 关联补货单对话框表格2ref
|
||||
const cgddPage = ref([]) // 采购申请列表数据
|
||||
const currRadioRowItems = ref([]) // 当前单选的表格行的items
|
||||
const step = ref(0) // 选择步骤
|
||||
|
||||
// 打开关联补货单对话框
|
||||
const openLinkCodeDialog = async () => {
|
||||
linkCgCodeDialogVisible.value = true
|
||||
step.value = 0
|
||||
linkCodeLoading.value = true
|
||||
try {
|
||||
const res = await getCgInventoryPage({ inventoryType: "5" }).finally(() => (linkCodeLoading.value = false))
|
||||
if (res.code === 0) {
|
||||
cgddPage.value = res.data.records
|
||||
}
|
||||
} catch (error) {
|
||||
cgddPage.value = []
|
||||
linkCodeLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 单选时
|
||||
const radioChangeEvent: VxeTableEvents.RadioChange<any> = ({ row }) => (currRadioRowItems.value = row.items)
|
||||
|
||||
// 获取选择的关联补货单对话框表格行数据
|
||||
const getSelectedRowData = () => {
|
||||
const $table = linkCgPlanTableRef.value
|
||||
const $SpuTable = linkCgPlanSpuTableRef.value
|
||||
if ($table && $SpuTable) {
|
||||
const currRadioRow = $table.getRadioRecord()
|
||||
console.log("currRadioRow", currRadioRow)
|
||||
const currSpuRows = $SpuTable.getCheckboxRecords()
|
||||
console.log("currSpuRows", currSpuRows)
|
||||
|
||||
emit("getSelectedCgPlan", { ...currRadioRow, items: currSpuRows })
|
||||
}
|
||||
}
|
||||
|
||||
// 对话框关闭
|
||||
const onClose = () => {
|
||||
linkCgCodeDialogVisible.value = false
|
||||
currRadioRowItems.value = []
|
||||
cgddPage.value = []
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openLinkCodeDialog,
|
||||
})
|
||||
</script>
|
||||
@@ -112,10 +112,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemSmErpInventoryRecords">
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from "vue-router"
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { fetchList, delObjs } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
|
||||
@@ -202,8 +202,14 @@
|
||||
@getSelectedSpuRows="getSelectedSpuRows"
|
||||
/>
|
||||
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<linkCgCodeDialog ref="linkCgCodeDialogRef" v-model="state.linkCgCodeDialogVisible" @getSelectedCgPlan="getSelectedCgPlan" />
|
||||
<linkCodeDialog
|
||||
ref="linkCgPlanDialogRef"
|
||||
v-model="state.linkCgPlanDialogVisible"
|
||||
title="关联采购订单"
|
||||
:getTableData="getCgInventoryPage"
|
||||
@getSelectedLinkCode="getSelectedLinkCode"
|
||||
/>
|
||||
<!-- { inventoryType: "5" } -->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -212,14 +218,15 @@
|
||||
import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { getObj, addObj, putObj } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import { Search } from "@element-plus/icons-vue"
|
||||
import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
|
||||
import linkCgCodeDialog from "/@/views/supermarketerp/smErpRetailBack/components/linkCgCodeDialog.vue"
|
||||
import linkCodeDialog from "../components/linkCodeDialog.vue"
|
||||
import { getCgInventoryPage } from "/@/api/supermarketerp/common"
|
||||
import { displayPrice, storePrice } from "/@/utils/formatMoney"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -227,7 +234,7 @@ const router = useRouter()
|
||||
const route = useRoute()
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
||||
const linkCgCodeDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const linkCgPlanDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||
@@ -256,7 +263,7 @@ const state = reactive<{
|
||||
erpSpuSimpleAll: any
|
||||
linkCodeVisible: boolean
|
||||
erpSpuSelectDialogVisible: boolean
|
||||
linkCgCodeDialogVisible: boolean
|
||||
linkCgPlanDialogVisible: boolean
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
@@ -266,7 +273,7 @@ const state = reactive<{
|
||||
|
||||
linkCodeVisible: false, // 关联采购申请单对话框开关
|
||||
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
linkCgCodeDialogVisible: false, // 关联采购申请单对话框开关
|
||||
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
|
||||
})
|
||||
// 合计金额表单数据
|
||||
const receiveAmountForm = reactive<{ receiveAmount: number }>({
|
||||
@@ -325,16 +332,16 @@ const getInitData = async () => {
|
||||
}
|
||||
|
||||
// 点击关联采购申请编号
|
||||
const handleClickLinkCode = () => linkCgCodeDialogRef.value.openLinkCodeDialog()
|
||||
const handleClickLinkCode = () => linkCgPlanDialogRef.value.openLinkCodeDialog()
|
||||
|
||||
// 获取选择的采购申请
|
||||
const getSelectedCgPlan = (selectionRows: any) => {
|
||||
const getSelectedLinkCode = (selectionRows: any) => {
|
||||
console.log("被选择的关联数据", selectionRows)
|
||||
|
||||
baseDataForm.linkCode = selectionRows.planCode
|
||||
state.editableTableData = selectionRows.items
|
||||
state.erpSpuItemsMemo = selectionRows.items
|
||||
state.linkCgCodeDialogVisible = false
|
||||
state.linkCgPlanDialogVisible = false
|
||||
}
|
||||
|
||||
// 顶部表格行新增
|
||||
|
||||
@@ -112,10 +112,10 @@
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemSmErpInventoryRecords">
|
||||
<script setup lang="ts">
|
||||
import { useRouter } from "vue-router"
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchList, delObjs } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { fetchList, delObjs } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -149,11 +149,7 @@ const resetQuery = () => {
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
downBlobFile(
|
||||
"/supermarket/smErpInventoryRecords/export",
|
||||
Object.assign(state.queryForm, { ids: selectObjs }),
|
||||
"smErpInventoryRecords.xlsx",
|
||||
)
|
||||
downBlobFile("/supermarket/smErpRetailDelivery/export", Object.assign(state.queryForm, { ids: selectObjs }), "smErpRetailDelivery.xlsx")
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
|
||||
@@ -202,8 +202,13 @@
|
||||
@getSelectedSpuRows="getSelectedSpuRows"
|
||||
/>
|
||||
|
||||
<!-- 关联采购申请单对话框 -->
|
||||
<linkCgCodeDialog ref="linkCgCodeDialogRef" v-model="state.linkCgCodeDialogVisible" @getSelectedCgPlan="getSelectedCgPlan" />
|
||||
<linkCodeDialog
|
||||
ref="linkCgPlanDialogRef"
|
||||
v-model="state.linkCgPlanDialogVisible"
|
||||
title="关联采购订单"
|
||||
:getTableData="getCgddPage"
|
||||
@getSelectedLinkCode="getSelectedLinkCode"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -212,14 +217,15 @@
|
||||
import { ref, reactive, computed, onMounted } from "vue"
|
||||
import { useRouter, useRoute } from "vue-router"
|
||||
import { useMessage } from "/@/hooks/message"
|
||||
import { getObj, addObj, putObj } from "/@/api/supermarketerp/smErpInventoryRecords"
|
||||
import { getObj, addObj, putObj } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||
import { getSupplierTypeOptions } from "/@/api/supermarketerp/smErpSupplier"
|
||||
import { formatDate } from "/@/utils/formatTime"
|
||||
import { Search } from "@element-plus/icons-vue"
|
||||
import erpSpuSelectDialog from "/@/views/supermarketerp/components/erpSpuSelectDialog.vue"
|
||||
import linkCgCodeDialog from "/@/views/supermarketerp/smErpCgDd/components/linkCgCodeDialog.vue"
|
||||
import linkCodeDialog from "../components/linkCodeDialog.vue"
|
||||
import { getCgddPage } from "../../../api/supermarketerp/smErpCgInventory"
|
||||
import { displayPrice, storePrice } from "/@/utils/formatMoney"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
|
||||
@@ -227,7 +233,7 @@ const router = useRouter()
|
||||
const route = useRoute()
|
||||
const loading = ref(false) // 采购计划加载
|
||||
const erpSpuSelectDialogRef = ref() // 商品选择对话框ref
|
||||
const linkCgCodeDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const linkCgPlanDialogRef = ref() // 关联采购申请单对话框ref
|
||||
const baseDataFormRef = ref() // 基本数据表单ref
|
||||
const editableTableRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||
const supplierTypeDict = ref<any[]>([]) // 货商下拉选项
|
||||
@@ -256,7 +262,7 @@ const state = reactive<{
|
||||
erpSpuSimpleAll: any
|
||||
linkCodeVisible: boolean
|
||||
erpSpuSelectDialogVisible: boolean
|
||||
linkCgCodeDialogVisible: boolean
|
||||
linkCgPlanDialogVisible: boolean
|
||||
}>({
|
||||
editableTableData: [], // 可编辑表格数据
|
||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||
@@ -266,7 +272,7 @@ const state = reactive<{
|
||||
|
||||
linkCodeVisible: false, // 关联采购申请单对话框开关
|
||||
erpSpuSelectDialogVisible: false, // 商品选择对话框开关
|
||||
linkCgCodeDialogVisible: false, // 关联采购申请单对话框开关
|
||||
linkCgPlanDialogVisible: false, // 关联采购申请单对话框开关
|
||||
})
|
||||
// 合计金额表单数据
|
||||
const receiveAmountForm = reactive<{ receiveAmount: number }>({
|
||||
@@ -325,16 +331,16 @@ const getInitData = async () => {
|
||||
}
|
||||
|
||||
// 点击关联采购申请编号
|
||||
const handleClickLinkCode = () => linkCgCodeDialogRef.value.openLinkCodeDialog()
|
||||
const handleClickLinkCode = () => linkCgPlanDialogRef.value.openLinkCodeDialog()
|
||||
|
||||
// 获取选择的采购申请
|
||||
const getSelectedCgPlan = (selectionRows: any) => {
|
||||
const getSelectedLinkCode = (selectionRows: any) => {
|
||||
console.log("被选择的关联数据", selectionRows)
|
||||
|
||||
baseDataForm.linkCode = selectionRows.planCode
|
||||
baseDataForm.linkCode = selectionRows.code
|
||||
state.editableTableData = selectionRows.items
|
||||
state.erpSpuItemsMemo = selectionRows.items
|
||||
state.linkCgCodeDialogVisible = false
|
||||
state.linkCgPlanDialogVisible = false
|
||||
}
|
||||
|
||||
// 顶部表格行新增
|
||||
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -213,7 +214,7 @@ const handleDelete = async (ids: string[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -218,7 +219,7 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,214 @@
|
||||
<template>
|
||||
<div class="layout-padding">
|
||||
<div class="layout-padding-auto layout-padding-view">
|
||||
<DraggableDepTree
|
||||
ref="draggableDepTreeRef"
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
<el-row :gutter="24">
|
||||
<el-col :span="4">
|
||||
<el-form-item class="w100" label="用户" prop="userId">
|
||||
<select-user v-model="state.queryForm.userId" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-form-item class="w100" label="饭卡卡号" prop="cardNumber">
|
||||
<el-input v-model="state.queryForm.cardNumber" placeholder="饭卡卡号" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="4">
|
||||
<el-form-item class="w100" label="饭卡类型" prop="walletTypeId">
|
||||
<select-wallet-type v-model="state.queryForm.walletTypeId" placeholder="饭卡类型" clearable />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<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
|
||||
plain
|
||||
:disabled="multiple"
|
||||
icon="Delete"
|
||||
type="primary"
|
||||
v-auth="'wallet_walletManage_del'"
|
||||
@click="handleDelete(selectObjs)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
<right-toolbar
|
||||
v-model:showSearch="showSearch"
|
||||
:export="'wallet_walletManage_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
|
||||
:summary-method="getSummaries"
|
||||
show-summary
|
||||
: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="80" />
|
||||
<el-table-column prop="username" width="100" label="用户" />
|
||||
<el-table-column prop="userAvatar" width="80" label="头像">
|
||||
<template #default="{ row }">
|
||||
<preview-image :src="row.userAvatar" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="userMobile" width="120" label="手机号" />
|
||||
<el-table-column prop="deptName" label="部门" width="200" />
|
||||
<el-table-column prop="walletTypeUniqueCode" width="200" label="饭卡类型">
|
||||
<template #default="{ row }">
|
||||
<div class="flex items-center justify-center">
|
||||
<div class="color-primary">{{ row.walletTypeName }}</div>
|
||||
<div class="flex items-center just ml5">
|
||||
<dict-tag :options="wallet_type" :value="row.walletTypeUniqueCode" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="cardNumber" width="150" label="饭卡卡号" />
|
||||
<el-table-column prop="balance" align="center" width="100" label="余额">
|
||||
<template #default="{ row }">
|
||||
<div class="color-primary">{{ displayPrice(row.balance) }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalExpense" align="center" width="100" label="累计支出">
|
||||
<template #default="{ row }">
|
||||
<div class="color-danger">{{ displayPrice(row.totalExpense) }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="totalRecharge" align="center" width="100" label="累计充值">
|
||||
<template #default="{ row }">
|
||||
<div class="color-success">{{ displayPrice(row.totalRecharge) }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="isFreeze" width="120" label="是否冻结饭卡">
|
||||
<template #default="{ row }">
|
||||
<dict-tag :options="yes_no_type" :value="row.isFreeze" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="false" prop="activeBindStatus" width="120" label="饭卡绑定状态" />
|
||||
<el-table-column prop="createTime" width="200" label="创建时间" />
|
||||
</el-table>
|
||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||
</template>
|
||||
</DraggableDepTree>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name="systemWalletManage">
|
||||
import { BasicTableProps, useTable } from "/@/hooks/table"
|
||||
import { fetchListJoin, delObjs } from "/@/api/wallet/wallet-manage"
|
||||
import { useMessage, useMessageBox } from "/@/hooks/message"
|
||||
import { useDict } from "/@/hooks/dict"
|
||||
import { displayPrice } from "/@/utils/formatMoney"
|
||||
|
||||
const { wallet_type, yes_no_type } = useDict("wallet_type", "yes_no_type")
|
||||
// 定义变量内容
|
||||
const draggableDepTreeRef = ref()
|
||||
// 搜索变量
|
||||
const queryRef = ref()
|
||||
const showSearch = ref(true)
|
||||
// 多选变量
|
||||
const selectObjs = ref([]) as any
|
||||
const multiple = ref(true)
|
||||
|
||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||
queryForm: {},
|
||||
pageList: fetchListJoin,
|
||||
})
|
||||
|
||||
// table hook
|
||||
const { getDataList, currentChangeHandle, sizeChangeHandle, sortChangeHandle, postDownBlobFile, tableStyle } = useTable(state)
|
||||
|
||||
// 清空搜索条件
|
||||
const resetQuery = () => {
|
||||
// 清空搜索条件
|
||||
queryRef.value?.resetFields()
|
||||
// 清空多选
|
||||
selectObjs.value = []
|
||||
state.queryForm.deptId = ""
|
||||
state.queryForm.deptIds = []
|
||||
draggableDepTreeRef.value.resetData()
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 导出excel
|
||||
const exportExcel = () => {
|
||||
postDownBlobFile(
|
||||
"/wallet/wallet-manage/export",
|
||||
Object.assign(state.queryForm, { current: state.pagination?.current, size: state.pagination?.size }),
|
||||
"walletManage.xlsx",
|
||||
)
|
||||
}
|
||||
|
||||
const getSummaries = (param: any) => {
|
||||
const { columns, data } = param
|
||||
const totalColumns = ["balance", "totalExpense", "totalRecharge"]
|
||||
const totalRow = Array.from({ length: columns.length })
|
||||
columns.forEach((i: any, index: number) => {
|
||||
if (totalColumns.includes(i.property)) {
|
||||
const total = data
|
||||
.filter((v: any) => v[i.property] != null)
|
||||
.map((v: any) => v[i.property])
|
||||
.reduce((pren: number, next: number) => pren + next, 0)
|
||||
totalRow[index] = displayPrice(total)
|
||||
}
|
||||
})
|
||||
return totalRow
|
||||
}
|
||||
|
||||
// 多选事件
|
||||
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||
selectObjs.value = objs.map(({ id }) => id)
|
||||
multiple.value = !objs.length
|
||||
}
|
||||
|
||||
// 树节点选择时
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
|
||||
// 删除操作
|
||||
const handleDelete = async (ids: string[]) => {
|
||||
try {
|
||||
await useMessageBox().confirm("此操作将永久删除")
|
||||
} catch {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await delObjs(ids)
|
||||
getDataList()
|
||||
useMessage().success("删除成功")
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -216,7 +217,7 @@ const resetQuery = () => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.userDeptId = curClickedNode.id
|
||||
state.queryForm.userDeptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -226,7 +227,7 @@ const handleDelete = async (ids: string[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
@@ -6,9 +6,10 @@
|
||||
placeholder="请输入部门名称"
|
||||
:show-expand="true"
|
||||
@getSelectNode="handleGetSelectNode"
|
||||
switch-inactive-text="当前部门"
|
||||
switch-active-text="当前部门及子部门"
|
||||
switch-inactive-text="包含"
|
||||
switch-active-text="不包含"
|
||||
:defaultTreeWidth="20"
|
||||
:nodeClickable="false"
|
||||
>
|
||||
<template #default>
|
||||
<el-form ref="queryRef" :inline="true" :model="state.queryForm" @keyup.enter="getDataList">
|
||||
@@ -221,7 +222,7 @@ const handleDelete = async (ids: string[]) => {
|
||||
const handleGetSelectNode = (curClickedNode: any, checkedTreeNodes: any, isDeepTree: any) => {
|
||||
state.queryForm.deptId = curClickedNode.id
|
||||
state.queryForm.deptIds = checkedTreeNodes.map((item: any) => item.id)
|
||||
state.queryForm.isDeepDept = isDeepTree
|
||||
state.queryForm.isInclude = !isDeepTree
|
||||
getDataList()
|
||||
}
|
||||
</script>
|
||||
Reference in new issue
Block a user