食堂原料管理
This commit is contained in:
1 parent
7f1cfdb0e7
commit
5bd138c276
8 files changed
+169
-146
No files matched your search
@@ -1,49 +1,48 @@
|
|||||||
import request from "/@/utils/request"
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
export function fetchList(query?: Object) {
|
export function fetchList(query?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial/page',
|
url: "/canteen/canteenErpMaterial/page",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function fetchErpMaterialPageList(query?: Object) {
|
export function fetchErpMaterialPageList(query?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial/erpMaterialPage',
|
url: "/canteen/canteenErpMaterial/erpMaterialPage",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addObj(obj?: Object) {
|
export function addObj(obj?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial',
|
url: "/canteen/canteenErpMaterial",
|
||||||
method: 'post',
|
method: "post",
|
||||||
data: obj
|
data: obj,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getObj(id?: string) {
|
export function getObj(id?: string) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial/' + id,
|
url: "/canteen/canteenErpMaterial/" + id,
|
||||||
method: 'get'
|
method: "get",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function delObjs(ids?: Object) {
|
export function delObjs(ids?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial',
|
url: "/canteen/canteenErpMaterial",
|
||||||
method: 'delete',
|
method: "delete",
|
||||||
data: ids
|
data: ids,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function putObj(obj?: Object) {
|
export function putObj(obj?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial',
|
url: "/canteen/canteenErpMaterial",
|
||||||
method: 'put',
|
method: "put",
|
||||||
data: obj
|
data: obj,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,41 +1,48 @@
|
|||||||
import request from "/@/utils/request"
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
export function fetchList(query?: Object) {
|
export function fetchList(query?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenSupplier/page',
|
url: "/canteen/canteenSupplier/page",
|
||||||
method: 'get',
|
method: "get",
|
||||||
params: query
|
params: query,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function addObj(obj?: Object) {
|
export function addObj(obj?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenSupplier',
|
url: "/canteen/canteenSupplier",
|
||||||
method: 'post',
|
method: "post",
|
||||||
data: obj
|
data: obj,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getObj(id?: string) {
|
export function getObj(id?: string) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenSupplier/' + id,
|
url: "/canteen/canteenSupplier/" + id,
|
||||||
method: 'get'
|
method: "get",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function delObjs(ids?: Object) {
|
export function delObjs(ids?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenSupplier',
|
url: "/canteen/canteenSupplier",
|
||||||
method: 'delete',
|
method: "delete",
|
||||||
data: ids
|
data: ids,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function putObj(obj?: Object) {
|
export function putObj(obj?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenSupplier',
|
url: "/canteen/canteenSupplier",
|
||||||
method: 'put',
|
method: "put",
|
||||||
data: obj
|
data: obj,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function canteenSupplierSelect(params?: Object) {
|
||||||
|
return request({
|
||||||
|
url: "/canteen/canteenSupplier/selectSimpleAll",
|
||||||
|
method: "get",
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
|
// 获取食堂业务流水编号
|
||||||
|
export function getCanteenSequence(params?: { type: string | number }) {
|
||||||
|
return request({
|
||||||
|
url: "/canteen/common/getSequence",
|
||||||
|
method: "get",
|
||||||
|
params,
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<template>
|
||||||
|
<el-select
|
||||||
|
style="width: 100%"
|
||||||
|
v-model="state.selectId"
|
||||||
|
:placeholder="props.placeholder"
|
||||||
|
clearable
|
||||||
|
remote-show-suffix
|
||||||
|
filterable
|
||||||
|
remote
|
||||||
|
:remote-method="remoteSearch"
|
||||||
|
:loading="state.loading"
|
||||||
|
@visible-change="(e: boolean) => e && getOptions()"
|
||||||
|
>
|
||||||
|
<el-option v-for="v in state.options" :key="v.supplierId" :label="v.supplierName" :value="v.supplierId" />
|
||||||
|
</el-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="SelectSupplier">
|
||||||
|
import { reactive } from "vue"
|
||||||
|
import { canteenSupplierSelect } from "/@/api/canteen/canteenSupplier"
|
||||||
|
|
||||||
|
const selectId = defineModel()
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{ placeholder?: string }>(), {
|
||||||
|
placeholder: "请选择",
|
||||||
|
})
|
||||||
|
|
||||||
|
const queryForm = reactive<any>({
|
||||||
|
name: "",
|
||||||
|
supplierId: "",
|
||||||
|
})
|
||||||
|
|
||||||
|
const state = reactive<any>({
|
||||||
|
loading: true,
|
||||||
|
selectId: selectId,
|
||||||
|
options: [],
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
selectId,
|
||||||
|
(newVal, oldValue) => {
|
||||||
|
if (newVal == oldValue) return
|
||||||
|
state.selectId = newVal
|
||||||
|
queryForm.supplierId = newVal
|
||||||
|
getOptions()
|
||||||
|
},
|
||||||
|
{ immediate: true },
|
||||||
|
)
|
||||||
|
|
||||||
|
async function getOptions() {
|
||||||
|
try {
|
||||||
|
state.loading = true
|
||||||
|
const { data } = await canteenSupplierSelect(queryForm)
|
||||||
|
state.options = data ? data : []
|
||||||
|
} finally {
|
||||||
|
setTimeout(() => (state.loading = false), 500)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remoteSearch(params: string) {
|
||||||
|
if (params != queryForm.name) {
|
||||||
|
queryForm.name = params
|
||||||
|
getOptions()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -34,6 +34,7 @@ import SelectHardGroup from "/@/components/Select/selectHardGroup.vue"
|
|||||||
import SelectRole from "/@/components/Select/SelectRole.vue"
|
import SelectRole from "/@/components/Select/SelectRole.vue"
|
||||||
import SelectCabinet from "/@/components/Select/SelectCabinet.vue"
|
import SelectCabinet from "/@/components/Select/SelectCabinet.vue"
|
||||||
import SelectMchCatory from "/@/components/Select/SelectMchCatory.vue"
|
import SelectMchCatory from "/@/components/Select/SelectMchCatory.vue"
|
||||||
|
import SelectCanteenSupplier from "/@/components/Select/SelectCanteenSupplier.vue"
|
||||||
|
|
||||||
// 第三方组件
|
// 第三方组件
|
||||||
import ElementPlus from "element-plus"
|
import ElementPlus from "element-plus"
|
||||||
@@ -89,6 +90,7 @@ export default {
|
|||||||
app.component("SelectMchRule", SelectMchRule)
|
app.component("SelectMchRule", SelectMchRule)
|
||||||
app.component("SelectRole", SelectRole)
|
app.component("SelectRole", SelectRole)
|
||||||
app.component("SelectCabinet", SelectCabinet)
|
app.component("SelectCabinet", SelectCabinet)
|
||||||
|
app.component("SelectCanteenSupplier", SelectCanteenSupplier)
|
||||||
|
|
||||||
// 导入全部的elmenet-plus的图标
|
// 导入全部的elmenet-plus的图标
|
||||||
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<select-mch v-model="baseDataForm.merchantId" :apiParams="{ types: '1' }" style="width: 200px" :disabled="disabled" />
|
<select-mch v-model="baseDataForm.merchantId" :apiParams="{ types: '1' }" style="width: 200px" :disabled="disabled" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="货商" prop="supplierId">
|
<el-form-item label="货商" prop="supplierId">
|
||||||
<select-supplier v-model="baseDataForm.supplierId" style="width: 200px" :disabled="disabled" />
|
<SelectCanteenSupplier v-model="baseDataForm.supplierId" style="width: 200px" :disabled="disabled" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input v-model.trim="baseDataForm.remark" placeholder="请输入备注" style="width: 200px" :disabled="disabled" />
|
<el-input v-model.trim="baseDataForm.remark" placeholder="请输入备注" style="width: 200px" :disabled="disabled" />
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
<el-row class="my-3">
|
<el-row class="my-3">
|
||||||
<el-button type="primary" plain @click="handleClickSpuSelect">商品选择</el-button>
|
<el-button type="primary" plain @click="handleClickSpuSelect">商品选择</el-button>
|
||||||
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowserpMaterialIds.length <= 0">删除选中</el-button>
|
<el-button @click="removeSelectRowEvent" :disabled="state.selectedRowsErpMaterialIds.length <= 0">删除选中</el-button>
|
||||||
<el-button type="danger" plain @click="clearData">清空数据</el-button>
|
<el-button type="danger" plain @click="clearData">清空数据</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="totalAmount" title="累计总金额">
|
<vxe-column field="totalAmount" title="累计总金额">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
{{ (Number(row.quantity) * Number(row.realPrice || 0)).toFixed(2) }}
|
{{ (Number(row.quantity || 0) * Number(row.realPrice || 0)).toFixed(2) }}
|
||||||
</template>
|
</template>
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="remark" title="备注" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
<vxe-column field="remark" title="备注" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
@@ -129,7 +129,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, computed, onMounted } from "vue"
|
import { ref, reactive, computed, onMounted } from "vue"
|
||||||
import { getObj, addObj, putObj } from "/@/api/canteen/canteenInventoryRecords"
|
import { getObj, addObj, putObj } from "/@/api/canteen/canteenInventoryRecords"
|
||||||
import { getPlanCode, getErpSpuSimpleAll } from "/@/api/supermarketerp/common"
|
import { getCanteenSequence } from "/@/api/canteen/common"
|
||||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||||
import { formatDate } from "/@/utils/formatTime"
|
import { formatDate } from "/@/utils/formatTime"
|
||||||
import { displayPrice, storePrice } from "/@/utils/formatMoney"
|
import { displayPrice, storePrice } from "/@/utils/formatMoney"
|
||||||
@@ -169,7 +169,7 @@ const baseDataForm = reactive<any>({
|
|||||||
const state = reactive<{
|
const state = reactive<{
|
||||||
editableTableData: any[]
|
editableTableData: any[]
|
||||||
erpSpuItemsMemo: any[]
|
erpSpuItemsMemo: any[]
|
||||||
selectedRowserpMaterialIds: string[]
|
selectedRowsErpMaterialIds: string[]
|
||||||
erpSpuSimpleAll: any
|
erpSpuSimpleAll: any
|
||||||
linkCodeVisible: boolean
|
linkCodeVisible: boolean
|
||||||
erpSpuSelectDialogVisible: boolean
|
erpSpuSelectDialogVisible: boolean
|
||||||
@@ -177,7 +177,7 @@ const state = reactive<{
|
|||||||
}>({
|
}>({
|
||||||
editableTableData: [], // 可编辑表格数据
|
editableTableData: [], // 可编辑表格数据
|
||||||
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
erpSpuItemsMemo: [], // 请求到的可编辑表格商品数据的缓存
|
||||||
selectedRowserpMaterialIds: [], // 可编辑表格已选行的erpMaterialId
|
selectedRowsErpMaterialIds: [], // 可编辑表格已选行的erpMaterialId
|
||||||
erpSpuSimpleAll: [], // 简要商品列表
|
erpSpuSimpleAll: [], // 简要商品列表
|
||||||
|
|
||||||
linkCodeVisible: false, // 关联采购申请单对话框开关
|
linkCodeVisible: false, // 关联采购申请单对话框开关
|
||||||
@@ -213,36 +213,22 @@ const getInitData = async () => {
|
|||||||
|
|
||||||
if (cgPlanData && cgPlanData.code === 0) {
|
if (cgPlanData && cgPlanData.code === 0) {
|
||||||
Object.assign(baseDataForm, cgPlanData.data)
|
Object.assign(baseDataForm, cgPlanData.data)
|
||||||
state.editableTableData = cgPlanData.data.items.map((item: any) => {
|
|
||||||
const unitObj = item.erpUnitVos.find((unit: any) => unit.id === item.unitId)
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
unitObj: { ...unitObj, realPrice: displayPrice(item?.realPrice, "") || 0 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
state.erpSpuItemsMemo = cgPlanData.data.items.map((item: any) => {
|
|
||||||
const unitObj = item.erpUnitVos.find((unit: any) => unit.id === item.unitId)
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
unitObj: { ...unitObj, realPrice: displayPrice(item?.realPrice, "") || 0 },
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
// 获取采购入库编号
|
// 获取采购入库编号
|
||||||
const [planCode] = await Promise.allSettled([getPlanCode({ type: 3 })])
|
const [planCode] = await Promise.allSettled([getCanteenSequence({ type: 1 })])
|
||||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||||
.finally(() => (loading.value = false))
|
.finally(() => (loading.value = false))
|
||||||
planCode && planCode.code === 0 && (baseDataForm.inventoryCode = planCode.data)
|
planCode && planCode.code === 0 && (baseDataForm.inventoryCode = planCode.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
loading.value = true
|
// loading.value = true
|
||||||
// 获取简要商品列表
|
// 获取简要商品列表
|
||||||
const [erpSpuSimpleAll] = await Promise.allSettled([getErpSpuSimpleAll()])
|
// const [erpSpuSimpleAll] = await Promise.allSettled([getErpSpuSimpleAll()])
|
||||||
.then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
// .then((results) => results.map((result) => (result.status === "fulfilled" ? result.value : null)))
|
||||||
.finally(() => (loading.value = false))
|
// .finally(() => (loading.value = false))
|
||||||
erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
// erpSpuSimpleAll && erpSpuSimpleAll.code === 0 && (state.erpSpuSimpleAll = erpSpuSimpleAll.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击关联采购申请编号
|
// 点击关联采购申请编号
|
||||||
@@ -285,7 +271,7 @@ const selectChangeEvent: VxeTableEvents.CheckboxChange<any> = ({ checked }) => {
|
|||||||
if ($table) {
|
if ($table) {
|
||||||
const records = $table.getCheckboxRecords()
|
const records = $table.getCheckboxRecords()
|
||||||
console.log(checked ? "勾选事件" : "取消事件", records)
|
console.log(checked ? "勾选事件" : "取消事件", records)
|
||||||
state.selectedRowserpMaterialIds = records.map((item) => item.erpMaterialId)
|
state.selectedRowsErpMaterialIds = records.map((item) => item.erpMaterialId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,7 +290,7 @@ const getSelectedSpuRows = (selectionRows: any) => {
|
|||||||
.map((addItem: any) => {
|
.map((addItem: any) => {
|
||||||
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpMaterialId === addItem.erpMaterialId)
|
const index = state.erpSpuItemsMemo.findIndex((item: any) => item.erpMaterialId === addItem.erpMaterialId)
|
||||||
if (index !== -1) return state.erpSpuItemsMemo[index]
|
if (index !== -1) return state.erpSpuItemsMemo[index]
|
||||||
return { ...addItem, isNew: true }
|
return { ...addItem, price: displayPrice(addItem.price, ""), isNew: true }
|
||||||
})
|
})
|
||||||
// 仅添加新勾选的项
|
// 仅添加新勾选的项
|
||||||
state.editableTableData = [...state.editableTableData, ...addedItems]
|
state.editableTableData = [...state.editableTableData, ...addedItems]
|
||||||
@@ -373,7 +359,7 @@ const clearData = () => {
|
|||||||
}
|
}
|
||||||
state.editableTableData = []
|
state.editableTableData = []
|
||||||
state.erpSpuItemsMemo = []
|
state.erpSpuItemsMemo = []
|
||||||
state.selectedRowserpMaterialIds = []
|
state.selectedRowsErpMaterialIds = []
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@
|
|||||||
v-auth="'canteen_canteenInventoryRecords_del'"
|
v-auth="'canteen_canteenInventoryRecords_del'"
|
||||||
@click="handleDelete(selectObjs)"
|
@click="handleDelete(selectObjs)"
|
||||||
>
|
>
|
||||||
删除
|
删 除
|
||||||
</el-button>
|
</el-button>
|
||||||
<right-toolbar
|
<right-toolbar
|
||||||
v-model:showSearch="showSearch"
|
v-model:showSearch="showSearch"
|
||||||
|
|||||||
@@ -1,21 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 商品选择对话框 -->
|
<el-dialog v-model="dialogVisible" title="选择商品" width="80%" :close-on-click-modal="false" draggable @close="dialogVisible = false">
|
||||||
<el-dialog
|
|
||||||
v-model="erpSpuSelectDialogVisible"
|
|
||||||
title="选择商品"
|
|
||||||
width="80%"
|
|
||||||
:close-on-click-modal="false"
|
|
||||||
draggable
|
|
||||||
@close="erpSpuSelectDialogVisible = false"
|
|
||||||
>
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-form :model="queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataListAndSelect">
|
<el-form :model="queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataListAndSelect">
|
||||||
<el-form-item label="商品名称" prop="name">
|
<el-form-item label="商品名称" prop="name">
|
||||||
<el-input placeholder="请输入商品名称" v-model="queryForm.name" />
|
<el-input placeholder="请输入商品名称" v-model="queryForm.name" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="商品分类" prop="categoryId">
|
|
||||||
<select-ctcg v-model="queryForm.categoryId" style="width: 200px" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button icon="search" type="primary" @click="getDataListAndSelect">查询</el-button>
|
<el-button icon="search" type="primary" @click="getDataListAndSelect">查询</el-button>
|
||||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
@@ -25,7 +14,7 @@
|
|||||||
<el-table
|
<el-table
|
||||||
ref="spuMultipleTableRef"
|
ref="spuMultipleTableRef"
|
||||||
:data="spuDataList"
|
:data="spuDataList"
|
||||||
v-loading="spuListLoading"
|
v-loading="loading"
|
||||||
:row-key="(row:any) => row.id"
|
:row-key="(row:any) => row.id"
|
||||||
:reserve-selection="true"
|
:reserve-selection="true"
|
||||||
@row-click="rowClick"
|
@row-click="rowClick"
|
||||||
@@ -34,23 +23,8 @@
|
|||||||
<el-table-column type="selection" width="40" fixed="left" align="center" />
|
<el-table-column type="selection" width="40" fixed="left" align="center" />
|
||||||
<el-table-column type="index" label="#" width="50" fixed="left" align="center" />
|
<el-table-column type="index" label="#" width="50" fixed="left" align="center" />
|
||||||
<el-table-column prop="name" label="商品名称" min-width="150px" align="center" show-overflow-tooltip />
|
<el-table-column prop="name" label="商品名称" min-width="150px" align="center" show-overflow-tooltip />
|
||||||
<el-table-column prop="picUrl" label="封面图" align="center" show-overflow-tooltip>
|
<el-table-column prop="unit" label="单位" min-width="100px" 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="80px" align="center" show-overflow-tooltip />
|
<el-table-column prop="stock" label="库存" min-width="80px" align="center" show-overflow-tooltip />
|
||||||
<el-table-column prop="categoryId" label="分类" min-width="100px" align="center" show-overflow-tooltip>
|
|
||||||
<template #default="scope">
|
|
||||||
{{ foodCategory?.find((item: any) => item.id === scope.row.categoryId)?.name }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<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>
|
|
||||||
<template #default="scope">
|
|
||||||
<dict-tag :options="status" :value="scope.row.status" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
</el-table>
|
||||||
<pagination
|
<pagination
|
||||||
@size-change="sizeChangeHandle"
|
@size-change="sizeChangeHandle"
|
||||||
@@ -61,19 +35,18 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<el-button @click="erpSpuSelectDialogVisible = false">取消</el-button>
|
<el-button @click="dialogVisible = false">取消</el-button>
|
||||||
<el-button type="primary" @click="handleSelectDialogConfirm" :disabled="spuListLoading">确认</el-button>
|
<el-button type="primary" @click="dialogConfirm" :disabled="loading">确认</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue"
|
import { ref } from "vue"
|
||||||
import { fetchList } from "/@/api/canteen/canteenSpu"
|
import { fetchErpMaterialPageList } from "/@/api/canteen/canteenErpMaterial"
|
||||||
import { getSupermarketCategory, getSupermarketBrand } from "/@/api/supermarketerp/supermarketSpu"
|
|
||||||
import { useDict } from "/@/hooks/dict"
|
import { useDict } from "/@/hooks/dict"
|
||||||
|
|
||||||
const erpSpuSelectDialogVisible = defineModel()
|
const dialogVisible = defineModel()
|
||||||
const emit = defineEmits(["getSelectedSpuRows"])
|
const emit = defineEmits(["getSelectedSpuRows"])
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -87,11 +60,9 @@ const props = withDefaults(
|
|||||||
const { status } = useDict("status")
|
const { status } = useDict("status")
|
||||||
const queryRef = ref()
|
const queryRef = ref()
|
||||||
const spuMultipleTableRef = ref() // 对话框多选表格ref
|
const spuMultipleTableRef = ref() // 对话框多选表格ref
|
||||||
const spuListLoading = ref(false) // 对话框多选表格loading
|
const loading = ref(false) // 对话框多选表格loading
|
||||||
const queryForm = reactive<any>({
|
const queryForm = reactive<any>({
|
||||||
productCode: "",
|
name: "",
|
||||||
barcode: "",
|
|
||||||
productName: "",
|
|
||||||
})
|
})
|
||||||
const total = ref<number>(0)
|
const total = ref<number>(0)
|
||||||
const spuDataList = ref<any[]>([]) // 对话框多选表格数据
|
const spuDataList = ref<any[]>([]) // 对话框多选表格数据
|
||||||
@@ -99,15 +70,15 @@ const foodCategory = ref<any>([]) // 菜品分类
|
|||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openDialog = async () => {
|
const openDialog = async () => {
|
||||||
erpSpuSelectDialogVisible.value = true
|
dialogVisible.value = true
|
||||||
getDataListAndSelect()
|
getDataListAndSelect()
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取商品数据并且勾选
|
// 获取商品数据并且勾选
|
||||||
const getDataListAndSelect = async () => {
|
const getDataListAndSelect = async () => {
|
||||||
spuListLoading.value = true
|
loading.value = true
|
||||||
try {
|
try {
|
||||||
const { code, data } = await fetchList(queryForm).finally(() => (spuListLoading.value = false))
|
const { code, data } = await fetchErpMaterialPageList(queryForm).finally(() => (loading.value = false))
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
spuDataList.value = data.records.map((item: any) => ({ ...item, erpMaterialId: item.id }))
|
spuDataList.value = data.records.map((item: any) => ({ ...item, erpMaterialId: item.id }))
|
||||||
total.value = data.total
|
total.value = data.total
|
||||||
@@ -132,9 +103,9 @@ const getDataListAndSelect = async () => {
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
spuDataList.value = []
|
spuDataList.value = []
|
||||||
spuListLoading.value = false
|
loading.value = false
|
||||||
} finally {
|
} finally {
|
||||||
spuListLoading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,12 +126,11 @@ const resetQuery = () => {
|
|||||||
|
|
||||||
// 点击商品列表表格行
|
// 点击商品列表表格行
|
||||||
const rowClick = (row: any) => {
|
const rowClick = (row: any) => {
|
||||||
console.log("clicked-row", row)
|
|
||||||
spuMultipleTableRef.value.toggleRowSelection(row)
|
spuMultipleTableRef.value.toggleRowSelection(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 商品选择对话框确认
|
// 商品选择对话框确认
|
||||||
const handleSelectDialogConfirm = () => {
|
const dialogConfirm = () => {
|
||||||
const $table = spuMultipleTableRef.value
|
const $table = spuMultipleTableRef.value
|
||||||
if ($table) {
|
if ($table) {
|
||||||
// 获取所有选中的行,包括其他页面的选择
|
// 获取所有选中的行,包括其他页面的选择
|
||||||
@@ -177,23 +147,6 @@ const handleSelectDialogConfirm = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
// 获取商品分类
|
|
||||||
// try {
|
|
||||||
// const res = await getSupermarketCategory()
|
|
||||||
// supermarketCategory.value = res.data
|
|
||||||
// } catch (error) {
|
|
||||||
// supermarketCategory.value = []
|
|
||||||
// }
|
|
||||||
// // 获取商品品牌
|
|
||||||
// try {
|
|
||||||
// const res = await getSupermarketBrand()
|
|
||||||
// supermarketBrand.value = res.data
|
|
||||||
// } catch (error) {
|
|
||||||
// supermarketBrand.value = []
|
|
||||||
// }
|
|
||||||
})
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog,
|
openDialog,
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in new issue
Block a user