Merge branch 'master' of https://codeup.aliyun.com/bsdtec/biz-pc-cloud
This commit is contained in:
commit
f6e7fd4cb3
11 files changed
+1256
No files matched your search
@@ -8,6 +8,14 @@ export function fetchList(query?: Object) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchErpMaterialPageList(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenErpMaterial/erpMaterialPage',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function addObj(obj?: Object) {
|
export function addObj(obj?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenErpMaterial',
|
url: '/canteen/canteenErpMaterial',
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
|
export function fetchList(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplate/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplate',
|
||||||
|
method: 'post',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getObj(id?: string) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplate/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delObjs(ids?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplate',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function putObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplate',
|
||||||
|
method: 'put',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delChildObj(ids?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplate/child',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
|
export function fetchList(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplateDetail/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplateDetail',
|
||||||
|
method: 'post',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getObj(id?: string) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplateDetail/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delObjs(ids?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplateDetail',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function putObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenProductionTemplateDetail',
|
||||||
|
method: 'put',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@@ -8,6 +8,14 @@ export function fetchList(query?: Object) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchSimpleList(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenSpu/getCanteenSpuSimplePage',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function addObj(obj?: Object) {
|
export function addObj(obj?: Object) {
|
||||||
return request({
|
return request({
|
||||||
url: '/canteen/canteenSpu',
|
url: '/canteen/canteenSpu',
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
import request from "/@/utils/request"
|
||||||
|
|
||||||
|
export function fetchList(query?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenSupplier/page',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenSupplier',
|
||||||
|
method: 'post',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getObj(id?: string) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenSupplier/' + id,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delObjs(ids?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenSupplier',
|
||||||
|
method: 'delete',
|
||||||
|
data: ids
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function putObj(obj?: Object) {
|
||||||
|
return request({
|
||||||
|
url: '/canteen/canteenSupplier',
|
||||||
|
method: 'put',
|
||||||
|
data: obj
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,400 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog
|
||||||
|
v-model="visible"
|
||||||
|
:title="form.id ? '编辑生产模板' : '新增生产模板'"
|
||||||
|
width="800px"
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
@close="closeDialog"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="form"
|
||||||
|
:rules="rules"
|
||||||
|
label-width="120px"
|
||||||
|
>
|
||||||
|
<el-form-item label="模板名称" prop="templateName">
|
||||||
|
<el-input v-model="form.templateName" placeholder="请输入模板名称" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="菜品" prop="dishId">
|
||||||
|
<el-button @click="openDishDialog">选择菜品</el-button>
|
||||||
|
<span v-if="selectedDish" class="ml-2">{{ selectedDish.name }}</span>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="基础产量" prop="baseOutput">
|
||||||
|
<el-input-number v-model="form.baseOutput" :min="0" :precision="2" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="食材原料">
|
||||||
|
<div class="mb-4">
|
||||||
|
<el-button type="primary" @click="openMaterialDialog">选择食材</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<el-table :data="form.canteenProductionTemplateDetailList" border>
|
||||||
|
<el-table-column label="食材名称" prop="materialName" />
|
||||||
|
<el-table-column label="基准用量" width="200">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-input-number
|
||||||
|
v-model="row.baseUsage"
|
||||||
|
:min="0"
|
||||||
|
:precision="2"
|
||||||
|
style="width: 120px"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="损耗率" width="200">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div style="display: flex; align-items: center;">
|
||||||
|
<el-input-number
|
||||||
|
v-model="row.lossRate"
|
||||||
|
:min="0"
|
||||||
|
:max="100"
|
||||||
|
:precision="2"
|
||||||
|
style="width: 120px"
|
||||||
|
/>
|
||||||
|
<span style="margin-left: 4px;">%</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="100">
|
||||||
|
<template #default="{ $index }">
|
||||||
|
<el-button type="danger" link @click="removeMaterial($index)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="closeDialog">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="submitForm" :loading="loading">
|
||||||
|
确 定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- 菜品选择弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="dishDialogVisible"
|
||||||
|
title="选择菜品"
|
||||||
|
width="800px"
|
||||||
|
append-to-body
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<div class="h-[500px] flex flex-col">
|
||||||
|
<el-form :inline="true" class="mb-4">
|
||||||
|
<el-form-item>
|
||||||
|
<el-input
|
||||||
|
v-model="dishQuery.name"
|
||||||
|
placeholder="菜品名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="searchDish"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="searchDish">搜索</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<div class="flex-1 overflow-auto">
|
||||||
|
<el-table
|
||||||
|
:data="dishList"
|
||||||
|
border
|
||||||
|
@row-click="selectDish"
|
||||||
|
height="100%"
|
||||||
|
>
|
||||||
|
<el-table-column type="radio" width="55" />
|
||||||
|
<el-table-column prop="name" label="菜品名称" min-width="200"/>
|
||||||
|
<el-table-column label="菜品图片" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-image
|
||||||
|
v-if="row.picUrl"
|
||||||
|
:src="row.picUrl"
|
||||||
|
:preview-src-list="[row.picUrl]"
|
||||||
|
fit="cover"
|
||||||
|
style="width: 60px; height: 60px; border-radius: 6px;"
|
||||||
|
:lazy="true"
|
||||||
|
:preview-teleported="true"
|
||||||
|
>
|
||||||
|
<template #error>
|
||||||
|
<div class="w-[60px] h-[60px] flex items-center justify-center bg-[#f5f7fa] text-[#c0c4cc] text-xs">
|
||||||
|
无图
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template #placeholder>
|
||||||
|
<div class="w-[60px] h-[60px] flex items-center justify-center bg-[#f5f7fa] text-xs">
|
||||||
|
加载中
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-image>
|
||||||
|
<div v-else class="w-[60px] h-[60px] flex items-center justify-center bg-[#f5f7fa] text-[#c0c4cc] text-xs">
|
||||||
|
无图
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4">
|
||||||
|
<pagination
|
||||||
|
v-model:current-page="dishQuery.current"
|
||||||
|
v-model:page-size="dishQuery.size"
|
||||||
|
:total="dishTotal"
|
||||||
|
@size-change="val => { dishQuery.size = val; dishQuery.current = 1; searchDish() }"
|
||||||
|
@current-change="val => { dishQuery.current = val; searchDish() }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 食材选择弹窗 -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="materialDialogVisible"
|
||||||
|
title="选择食材"
|
||||||
|
width="800px"
|
||||||
|
append-to-body
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<div class="h-[500px] flex flex-col">
|
||||||
|
<el-form :inline="true" class="mb-4">
|
||||||
|
<el-form-item>
|
||||||
|
<el-input
|
||||||
|
v-model="materialQuery.name"
|
||||||
|
placeholder="食材名称"
|
||||||
|
clearable
|
||||||
|
@keyup.enter="searchMaterial"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="searchMaterial">搜索</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<div class="flex-1 overflow-auto">
|
||||||
|
<el-table
|
||||||
|
:data="materialList"
|
||||||
|
border
|
||||||
|
@selection-change="handleMaterialSelectionChange"
|
||||||
|
height="100%"
|
||||||
|
>
|
||||||
|
<el-table-column type="selection" width="55" />
|
||||||
|
<el-table-column prop="name" label="食材名称" min-width="200"/>
|
||||||
|
<el-table-column prop="unit" label="单位" width="100" />
|
||||||
|
<el-table-column prop="stock" label="库存数量" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
{{ row.stock || 0 }} {{ row.unit }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-4">
|
||||||
|
<pagination
|
||||||
|
v-model:current-page="materialQuery.current"
|
||||||
|
v-model:page-size="materialQuery.size"
|
||||||
|
:total="materialTotal"
|
||||||
|
@size-change="val => { materialQuery.size = val; materialQuery.current = 1; searchMaterial() }"
|
||||||
|
@current-change="val => { materialQuery.current = val; searchMaterial() }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="materialDialogVisible = false">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="confirmMaterialSelection">
|
||||||
|
确 定
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive } from 'vue'
|
||||||
|
import type { FormInstance } from 'element-plus'
|
||||||
|
import { useMessage } from "/@/hooks/message"
|
||||||
|
import { fetchSimpleList } from "/@/api/canteen/canteenSpu"
|
||||||
|
import { fetchErpMaterialPageList } from "/@/api/canteen/canteenErpMaterial"
|
||||||
|
import { addObj, putObj, getObj } from "/@/api/canteen/canteenProductionTemplate"
|
||||||
|
import Pagination from '/@/components/Pagination/index.vue'
|
||||||
|
|
||||||
|
const visible = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
const selectedDish = ref<any>(null)
|
||||||
|
|
||||||
|
// 菜品选择相关
|
||||||
|
const dishDialogVisible = ref(false)
|
||||||
|
const dishList = ref<any[]>([])
|
||||||
|
const dishTotal = ref(0)
|
||||||
|
const dishQuery = reactive({
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
name: ''
|
||||||
|
})
|
||||||
|
|
||||||
|
// 食材选择相关
|
||||||
|
const materialDialogVisible = ref(false)
|
||||||
|
const materialList = ref<any[]>([])
|
||||||
|
const materialTotal = ref(0)
|
||||||
|
const materialQuery = reactive({
|
||||||
|
current: 1,
|
||||||
|
size: 10,
|
||||||
|
name: ''
|
||||||
|
})
|
||||||
|
const selectedMaterials = ref<any[]>([])
|
||||||
|
|
||||||
|
const form = reactive({
|
||||||
|
id: undefined,
|
||||||
|
templateName: '',
|
||||||
|
dishId: undefined,
|
||||||
|
baseOutput: 0,
|
||||||
|
canteenProductionTemplateDetailList: [] as any[]
|
||||||
|
})
|
||||||
|
|
||||||
|
const rules = {
|
||||||
|
templateName: [{ required: true, message: '请输入模板名称', trigger: 'blur' }],
|
||||||
|
dishId: [{ required: true, message: '请选择菜品', trigger: 'change' }],
|
||||||
|
baseOutput: [{ required: true, message: '请输入基础产量', trigger: 'blur' }]
|
||||||
|
}
|
||||||
|
|
||||||
|
const emit = defineEmits(['refresh'])
|
||||||
|
|
||||||
|
// 搜索菜品
|
||||||
|
const searchDish = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetchSimpleList(dishQuery)
|
||||||
|
dishList.value = res.data.records
|
||||||
|
dishTotal.value = res.data.total
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取菜品列表失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 选择菜品
|
||||||
|
const selectDish = (row: any) => {
|
||||||
|
selectedDish.value = row
|
||||||
|
form.dishId = row.id
|
||||||
|
dishDialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 搜索食材
|
||||||
|
const searchMaterial = async () => {
|
||||||
|
try {
|
||||||
|
const res = await fetchErpMaterialPageList(materialQuery)
|
||||||
|
materialList.value = res.data.records
|
||||||
|
materialTotal.value = res.data.total
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取食材列表失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 食材选择变化
|
||||||
|
const handleMaterialSelectionChange = (selection: any[]) => {
|
||||||
|
selectedMaterials.value = selection
|
||||||
|
}
|
||||||
|
|
||||||
|
// 确认食材选择
|
||||||
|
const confirmMaterialSelection = () => {
|
||||||
|
selectedMaterials.value.forEach(material => {
|
||||||
|
if (!form.canteenProductionTemplateDetailList.find(item => item.materialId === material.id)) {
|
||||||
|
form.canteenProductionTemplateDetailList.push({
|
||||||
|
id: undefined,
|
||||||
|
templateId: form.id,
|
||||||
|
materialId: material.id,
|
||||||
|
materialName: material.name,
|
||||||
|
baseUsage: 0,
|
||||||
|
lossRate: 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
materialDialogVisible.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除食材
|
||||||
|
const removeMaterial = (index: number) => {
|
||||||
|
form.canteenProductionTemplateDetailList.splice(index, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开菜品选择弹窗
|
||||||
|
const openDishDialog = () => {
|
||||||
|
dishDialogVisible.value = true
|
||||||
|
searchDish()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开食材选择弹窗
|
||||||
|
const openMaterialDialog = () => {
|
||||||
|
materialDialogVisible.value = true
|
||||||
|
searchMaterial()
|
||||||
|
}
|
||||||
|
|
||||||
|
const openDialog = async (row?: any) => {
|
||||||
|
visible.value = true
|
||||||
|
if (row && row.id) {
|
||||||
|
try {
|
||||||
|
const res = await getObj(row.id)
|
||||||
|
if (res.code === 0 && res.data) {
|
||||||
|
const data = res.data
|
||||||
|
form.id = data.id
|
||||||
|
form.templateName = data.templateName
|
||||||
|
form.dishId = data.dishId
|
||||||
|
form.baseOutput = data.baseOutput
|
||||||
|
form.canteenProductionTemplateDetailList = Array.isArray(data.canteenProductionTemplateDetailList)
|
||||||
|
? data.canteenProductionTemplateDetailList.map(item => ({ ...item }))
|
||||||
|
: []
|
||||||
|
selectedDish.value = data.dishId && data.dishName ? { id: data.dishId, name: data.dishName } : null
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
useMessage().error('获取详情失败')
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
form.id = undefined
|
||||||
|
form.templateName = ''
|
||||||
|
form.dishId = undefined
|
||||||
|
form.baseOutput = 0
|
||||||
|
form.canteenProductionTemplateDetailList = []
|
||||||
|
selectedDish.value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeDialog = () => {
|
||||||
|
visible.value = false
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
form.id = undefined
|
||||||
|
form.templateName = ''
|
||||||
|
form.dishId = undefined
|
||||||
|
form.baseOutput = 0
|
||||||
|
form.canteenProductionTemplateDetailList = []
|
||||||
|
selectedDish.value = null
|
||||||
|
}
|
||||||
|
|
||||||
|
const submitForm = async () => {
|
||||||
|
if (!formRef.value) return
|
||||||
|
|
||||||
|
await formRef.value.validate(async (valid) => {
|
||||||
|
if (valid) {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
const api = form.id ? putObj : addObj
|
||||||
|
const res = await api(form)
|
||||||
|
if (res.code === 0) {
|
||||||
|
useMessage().success(form.id ? '修改成功' : '新增成功')
|
||||||
|
emit('refresh')
|
||||||
|
closeDialog()
|
||||||
|
} else {
|
||||||
|
useMessage().error(res.msg || (form.id ? '修改失败' : '新增失败'))
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
useMessage().error(error.msg || (form.id ? '修改失败' : '新增失败'))
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openDialog
|
||||||
|
})
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
<template>
|
||||||
|
<div class="layout-padding">
|
||||||
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
|
<el-row v-show="showSearch">
|
||||||
|
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||||
|
<el-form-item label="模版名称" prop="templateName" >
|
||||||
|
<el-input placeholder="请输入模版名称" v-model="state.queryForm.templateName" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button icon="search" type="primary" @click="getDataList">
|
||||||
|
查询
|
||||||
|
</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<div class="mb8" style="width: 100%">
|
||||||
|
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
||||||
|
v-auth="'canteen_canteenProductionTemplate_add'">
|
||||||
|
新 增
|
||||||
|
</el-button>
|
||||||
|
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||||
|
v-auth="'canteen_canteenProductionTemplate_del'" @click="handleDelete(selectObjs)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_canteenProductionTemplate_export'"
|
||||||
|
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
||||||
|
@queryTable="getDataList"></right-toolbar>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="state.dataList" v-loading="state.loading" border
|
||||||
|
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
||||||
|
@selection-change="selectionChangHandle"
|
||||||
|
@sort-change="sortChangeHandle">
|
||||||
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
|
<el-table-column type="index" label="#" width="40" />
|
||||||
|
<el-table-column prop="templateName" label="模版名称" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="dishId" label="菜品id" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="baseOutput" label="基准产出量(碗)" show-overflow-tooltip/>
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenProductionTemplate_edit'"
|
||||||
|
@click="formDialogRef.openDialog(scope.row)">编辑</el-button>
|
||||||
|
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenProductionTemplate_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 编辑、新增 -->
|
||||||
|
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="systemCanteenProductionTemplate">
|
||||||
|
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||||
|
import { fetchList, delObjs } from "/@/api/canteen/canteenProductionTemplate";
|
||||||
|
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
|
||||||
|
// 引入组件
|
||||||
|
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||||
|
// 定义查询字典
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const formDialogRef = ref()
|
||||||
|
// 搜索变量
|
||||||
|
const queryRef = ref()
|
||||||
|
const showSearch = ref(true)
|
||||||
|
// 多选变量
|
||||||
|
const selectObjs = ref([]) as any
|
||||||
|
const multiple = ref(true)
|
||||||
|
|
||||||
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
|
queryForm: {},
|
||||||
|
pageList: fetchList
|
||||||
|
})
|
||||||
|
|
||||||
|
// table hook
|
||||||
|
const {
|
||||||
|
getDataList,
|
||||||
|
currentChangeHandle,
|
||||||
|
sizeChangeHandle,
|
||||||
|
sortChangeHandle,
|
||||||
|
downBlobFile,
|
||||||
|
tableStyle
|
||||||
|
} = useTable(state)
|
||||||
|
|
||||||
|
// 清空搜索条件
|
||||||
|
const resetQuery = () => {
|
||||||
|
// 清空搜索条件
|
||||||
|
queryRef.value?.resetFields()
|
||||||
|
// 清空多选
|
||||||
|
selectObjs.value = []
|
||||||
|
getDataList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出excel
|
||||||
|
const exportExcel = () => {
|
||||||
|
downBlobFile('/canteen/canteenProductionTemplate/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenProductionTemplate.xlsx')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选事件
|
||||||
|
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||||
|
selectObjs.value = objs.map(({ id }) => id);
|
||||||
|
multiple.value = !objs.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
const handleDelete = async (ids: string[]) => {
|
||||||
|
try {
|
||||||
|
await useMessageBox().confirm('此操作将永久删除');
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await delObjs(ids);
|
||||||
|
getDataList();
|
||||||
|
useMessage().success('删除成功');
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,125 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :title="form.id ? '编辑' : '新增'" v-model="visible"
|
||||||
|
:close-on-click-modal="false" draggable>
|
||||||
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||||
|
<el-row :gutter="24">
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="模版id" prop="templateId">
|
||||||
|
<el-input v-model="form.templateId" placeholder="请输入模版id"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="原料id" prop="materialId">
|
||||||
|
<el-input v-model="form.materialId" placeholder="请输入原料id"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="部门id" prop="deptId">
|
||||||
|
<el-input v-model="form.deptId" placeholder="请输入部门id"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="基准用量" prop="baseUsage">
|
||||||
|
<el-input v-model="form.baseUsage" placeholder="请输入基准用量"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="损耗率" prop="lossRate">
|
||||||
|
<el-input v-model="form.lossRate" placeholder="请输入损耗率"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="visible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="CanteenProductionTemplateDetailDialog">
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
import { useMessage } from "/@/hooks/message";
|
||||||
|
import { getObj, addObj, putObj } from '/@/api/canteen/canteenProductionTemplateDetail'
|
||||||
|
import { rule } from '/@/utils/validate';
|
||||||
|
const emit = defineEmits(['refresh']);
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const dataFormRef = ref();
|
||||||
|
const visible = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
// 定义字典
|
||||||
|
|
||||||
|
// 提交表单数据
|
||||||
|
const form = reactive({
|
||||||
|
id:'',
|
||||||
|
templateId: '',
|
||||||
|
materialId: '',
|
||||||
|
deptId: '',
|
||||||
|
baseUsage: '',
|
||||||
|
lossRate: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 定义校验规则
|
||||||
|
const dataRules = ref({
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打开弹窗
|
||||||
|
const openDialog = (id: string) => {
|
||||||
|
visible.value = true
|
||||||
|
form.id = ''
|
||||||
|
|
||||||
|
// 重置表单数据
|
||||||
|
nextTick(() => {
|
||||||
|
dataFormRef.value?.resetFields();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取canteenProductionTemplateDetail信息
|
||||||
|
if (id) {
|
||||||
|
form.id = id
|
||||||
|
getcanteenProductionTemplateDetailData(id)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
const onSubmit = async () => {
|
||||||
|
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||||
|
if (!valid) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
form.id ? await putObj(form) : await addObj(form);
|
||||||
|
useMessage().success(form.id ? '修改成功' : '添加成功');
|
||||||
|
visible.value = false;
|
||||||
|
emit('refresh');
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化表单数据
|
||||||
|
const getcanteenProductionTemplateDetailData = (id: string) => {
|
||||||
|
// 获取数据
|
||||||
|
loading.value = true
|
||||||
|
getObj(id).then((res: any) => {
|
||||||
|
Object.assign(form, res.data)
|
||||||
|
}).finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// 暴露变量
|
||||||
|
defineExpose({
|
||||||
|
openDialog
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
<template>
|
||||||
|
<div class="layout-padding">
|
||||||
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
|
<el-row>
|
||||||
|
<div class="mb8" style="width: 100%">
|
||||||
|
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
||||||
|
v-auth="'canteen_canteenProductionTemplateDetail_add'">
|
||||||
|
新 增
|
||||||
|
</el-button>
|
||||||
|
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||||
|
v-auth="'canteen_canteenProductionTemplateDetail_del'" @click="handleDelete(selectObjs)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_canteenProductionTemplateDetail_export'"
|
||||||
|
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
||||||
|
@queryTable="getDataList"></right-toolbar>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="state.dataList" v-loading="state.loading" border
|
||||||
|
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
||||||
|
@selection-change="selectionChangHandle"
|
||||||
|
@sort-change="sortChangeHandle">
|
||||||
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
|
<el-table-column type="index" label="#" width="40" />
|
||||||
|
<el-table-column prop="templateId" label="模版id" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="materialId" label="原料id" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="deptId" label="部门id" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="baseUsage" label="基准用量" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="lossRate" label="损耗率" show-overflow-tooltip/>
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenProductionTemplateDetail_edit'"
|
||||||
|
@click="formDialogRef.openDialog(scope.row.id)">编辑</el-button>
|
||||||
|
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenProductionTemplateDetail_del'" @click="handleDelete([scope.row.id])">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 编辑、新增 -->
|
||||||
|
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="systemCanteenProductionTemplateDetail">
|
||||||
|
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||||
|
import { fetchList, delObjs } from "/@/api/canteen/canteenProductionTemplateDetail";
|
||||||
|
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
|
||||||
|
// 引入组件
|
||||||
|
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||||
|
// 定义查询字典
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const formDialogRef = ref()
|
||||||
|
// 搜索变量
|
||||||
|
const queryRef = ref()
|
||||||
|
const showSearch = ref(true)
|
||||||
|
// 多选变量
|
||||||
|
const selectObjs = ref([]) as any
|
||||||
|
const multiple = ref(true)
|
||||||
|
|
||||||
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
|
queryForm: {},
|
||||||
|
pageList: fetchList
|
||||||
|
})
|
||||||
|
|
||||||
|
// table hook
|
||||||
|
const {
|
||||||
|
getDataList,
|
||||||
|
currentChangeHandle,
|
||||||
|
sizeChangeHandle,
|
||||||
|
sortChangeHandle,
|
||||||
|
downBlobFile,
|
||||||
|
tableStyle
|
||||||
|
} = useTable(state)
|
||||||
|
|
||||||
|
// 清空搜索条件
|
||||||
|
const resetQuery = () => {
|
||||||
|
// 清空搜索条件
|
||||||
|
queryRef.value?.resetFields()
|
||||||
|
// 清空多选
|
||||||
|
selectObjs.value = []
|
||||||
|
getDataList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出excel
|
||||||
|
const exportExcel = () => {
|
||||||
|
downBlobFile('/canteen/canteenProductionTemplateDetail/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenProductionTemplateDetail.xlsx')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选事件
|
||||||
|
const selectionChangHandle = (objs: { id: string }[]) => {
|
||||||
|
selectObjs.value = objs.map(({ id }) => id);
|
||||||
|
multiple.value = !objs.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
const handleDelete = async (ids: string[]) => {
|
||||||
|
try {
|
||||||
|
await useMessageBox().confirm('此操作将永久删除');
|
||||||
|
} catch {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await delObjs(ids);
|
||||||
|
getDataList();
|
||||||
|
useMessage().success('删除成功');
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,197 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog :title="form.supplierId ? '编辑' : '新增'" v-model="visible"
|
||||||
|
:close-on-click-modal="false" draggable>
|
||||||
|
<el-form ref="dataFormRef" :model="form" :rules="dataRules" formDialogRef label-width="90px" v-loading="loading">
|
||||||
|
<el-row :gutter="24">
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="货商名称" prop="supplierName">
|
||||||
|
<el-input v-model="form.supplierName" placeholder="请输入货商名称"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="货商地址" prop="address">
|
||||||
|
<el-input v-model="form.address" placeholder="请输入货商地址"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="电话号码" prop="phone">
|
||||||
|
<el-input v-model="form.phone" placeholder="请输入电话号码"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="税号" prop="tax">
|
||||||
|
<el-input v-model="form.tax" placeholder="请输入税号"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="联系人" prop="linkName">
|
||||||
|
<el-input v-model="form.linkName" placeholder="请输入联系人"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="开户行账号" prop="openAccount">
|
||||||
|
<el-input v-model="form.openAccount" placeholder="请输入开户行账号"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="邮箱地址" prop="email">
|
||||||
|
<el-input v-model="form.email" placeholder="请输入邮箱地址"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="所属部门ID" prop="deptId">
|
||||||
|
<el-input v-model="form.deptId" placeholder="请输入所属部门ID"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="货商类别" prop="supplierType">
|
||||||
|
<el-input v-model="form.supplierType" placeholder="请输入货商类别"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="货商地区" prop="supplierArea">
|
||||||
|
<el-input v-model="form.supplierArea" placeholder="请输入货商地区"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="修改时间" prop="passwordModifyTime">
|
||||||
|
<el-input v-model="form.passwordModifyTime" placeholder="请输入修改时间"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="开户行" prop="openName">
|
||||||
|
<el-input v-model="form.openName" placeholder="请输入开户行"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="合同号" prop="contractNumber">
|
||||||
|
<el-input v-model="form.contractNumber" placeholder="请输入合同号"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="状态 0使用 1禁用" prop="status">
|
||||||
|
<el-input v-model="form.status" placeholder="请输入状态 0使用 1禁用"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
<el-col :span="12" class="mb20">
|
||||||
|
<el-form-item label="拼音简码" prop="pinyinCod">
|
||||||
|
<el-input v-model="form.pinyinCod" placeholder="请输入拼音简码"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<span class="dialog-footer">
|
||||||
|
<el-button @click="visible = false">取消</el-button>
|
||||||
|
<el-button type="primary" @click="onSubmit" :disabled="loading">确认</el-button>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="CanteenSupplierDialog">
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
import { useMessage } from "/@/hooks/message";
|
||||||
|
import { getObj, addObj, putObj } from '/@/api/canteen/canteenSupplier'
|
||||||
|
import { rule } from '/@/utils/validate';
|
||||||
|
const emit = defineEmits(['refresh']);
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const dataFormRef = ref();
|
||||||
|
const visible = ref(false)
|
||||||
|
const loading = ref(false)
|
||||||
|
// 定义字典
|
||||||
|
|
||||||
|
// 提交表单数据
|
||||||
|
const form = reactive({
|
||||||
|
supplierId:'',
|
||||||
|
supplierName: '',
|
||||||
|
address: '',
|
||||||
|
phone: '',
|
||||||
|
tax: '',
|
||||||
|
linkName: '',
|
||||||
|
openAccount: '',
|
||||||
|
email: '',
|
||||||
|
deptId: '',
|
||||||
|
supplierType: '',
|
||||||
|
supplierArea: '',
|
||||||
|
passwordModifyTime: '',
|
||||||
|
openName: '',
|
||||||
|
contractNumber: '',
|
||||||
|
status: '',
|
||||||
|
pinyinCod: '',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 定义校验规则
|
||||||
|
const dataRules = ref({
|
||||||
|
supplierName: [{required: true, message: '货商名称不能为空', trigger: 'blur'}],
|
||||||
|
phone: [{ validator: rule.mobilePhone, trigger: 'blur' }],
|
||||||
|
})
|
||||||
|
|
||||||
|
// 打开弹窗
|
||||||
|
const openDialog = (id: string) => {
|
||||||
|
visible.value = true
|
||||||
|
form.supplierId = ''
|
||||||
|
|
||||||
|
// 重置表单数据
|
||||||
|
nextTick(() => {
|
||||||
|
dataFormRef.value?.resetFields();
|
||||||
|
});
|
||||||
|
|
||||||
|
// 获取canteenSupplier信息
|
||||||
|
if (id) {
|
||||||
|
form.supplierId = id
|
||||||
|
getcanteenSupplierData(id)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 提交
|
||||||
|
const onSubmit = async () => {
|
||||||
|
const valid = await dataFormRef.value.validate().catch(() => {});
|
||||||
|
if (!valid) return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading.value = true;
|
||||||
|
form.supplierId ? await putObj(form) : await addObj(form);
|
||||||
|
useMessage().success(form.supplierId ? '修改成功' : '添加成功');
|
||||||
|
visible.value = false;
|
||||||
|
emit('refresh');
|
||||||
|
} catch (err: any) {
|
||||||
|
useMessage().error(err.msg);
|
||||||
|
} finally {
|
||||||
|
loading.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// 初始化表单数据
|
||||||
|
const getcanteenSupplierData = (id: string) => {
|
||||||
|
// 获取数据
|
||||||
|
loading.value = true
|
||||||
|
getObj(id).then((res: any) => {
|
||||||
|
Object.assign(form, res.data)
|
||||||
|
}).finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// 暴露变量
|
||||||
|
defineExpose({
|
||||||
|
openDialog
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
<template>
|
||||||
|
<div class="layout-padding">
|
||||||
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
|
<el-row v-show="showSearch">
|
||||||
|
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||||
|
<el-form-item label="货商名称" prop="supplierName" >
|
||||||
|
<el-input placeholder="请输入货商名称" v-model="state.queryForm.supplierName" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="电话号码" prop="phone" >
|
||||||
|
<el-input placeholder="请输入电话号码" v-model="state.queryForm.phone" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button icon="search" type="primary" @click="getDataList">
|
||||||
|
查询
|
||||||
|
</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<div class="mb8" style="width: 100%">
|
||||||
|
<el-button icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()"
|
||||||
|
v-auth="'canteen_canteenSupplier_add'">
|
||||||
|
新 增
|
||||||
|
</el-button>
|
||||||
|
<el-button plain :disabled="multiple" icon="Delete" type="primary"
|
||||||
|
v-auth="'canteen_canteenSupplier_del'" @click="handleDelete(selectObjs)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" :export="'canteen_canteenSupplier_export'"
|
||||||
|
@exportExcel="exportExcel" class="ml10 mr20" style="float: right;"
|
||||||
|
@queryTable="getDataList"></right-toolbar>
|
||||||
|
</div>
|
||||||
|
</el-row>
|
||||||
|
<el-table :data="state.dataList" v-loading="state.loading" border
|
||||||
|
:cell-style="tableStyle.cellStyle" :header-cell-style="tableStyle.headerCellStyle"
|
||||||
|
@selection-change="selectionChangHandle"
|
||||||
|
@sort-change="sortChangeHandle">
|
||||||
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
|
<el-table-column type="index" label="#" width="40" />
|
||||||
|
<el-table-column prop="supplierName" label="货商名称" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="address" label="货商地址" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="phone" label="电话号码" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="tax" label="税号" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="linkName" label="联系人" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="openAccount" label="开户行账号" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="email" label="邮箱地址" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="deptId" label="所属部门ID" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="supplierType" label="货商类别" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="supplierArea" label="货商地区" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="passwordModifyTime" label="修改时间" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="openName" label="开户行" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="contractNumber" label="合同号" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="status" label="状态 0使用 1禁用" show-overflow-tooltip/>
|
||||||
|
<el-table-column prop="pinyinCod" label="拼音简码" show-overflow-tooltip/>
|
||||||
|
<el-table-column label="操作" width="150">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenSupplier_edit'"
|
||||||
|
@click="formDialogRef.openDialog(scope.row.supplierId)">编辑</el-button>
|
||||||
|
<el-button icon="delete" text type="primary" v-auth="'canteen_canteenSupplier_del'" @click="handleDelete([scope.row.supplierId])">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 编辑、新增 -->
|
||||||
|
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts" name="systemCanteenSupplier">
|
||||||
|
import { BasicTableProps, useTable } from "/@/hooks/table";
|
||||||
|
import { fetchList, delObjs } from "/@/api/canteen/canteenSupplier";
|
||||||
|
import { useMessage, useMessageBox } from "/@/hooks/message";
|
||||||
|
import { useDict } from '/@/hooks/dict';
|
||||||
|
|
||||||
|
// 引入组件
|
||||||
|
const FormDialog = defineAsyncComponent(() => import('./form.vue'));
|
||||||
|
// 定义查询字典
|
||||||
|
|
||||||
|
// 定义变量内容
|
||||||
|
const formDialogRef = ref()
|
||||||
|
// 搜索变量
|
||||||
|
const queryRef = ref()
|
||||||
|
const showSearch = ref(true)
|
||||||
|
// 多选变量
|
||||||
|
const selectObjs = ref([]) as any
|
||||||
|
const multiple = ref(true)
|
||||||
|
|
||||||
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
|
queryForm: {},
|
||||||
|
pageList: fetchList
|
||||||
|
})
|
||||||
|
|
||||||
|
// table hook
|
||||||
|
const {
|
||||||
|
getDataList,
|
||||||
|
currentChangeHandle,
|
||||||
|
sizeChangeHandle,
|
||||||
|
sortChangeHandle,
|
||||||
|
downBlobFile,
|
||||||
|
tableStyle
|
||||||
|
} = useTable(state)
|
||||||
|
|
||||||
|
// 清空搜索条件
|
||||||
|
const resetQuery = () => {
|
||||||
|
// 清空搜索条件
|
||||||
|
queryRef.value?.resetFields()
|
||||||
|
// 清空多选
|
||||||
|
selectObjs.value = []
|
||||||
|
getDataList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出excel
|
||||||
|
const exportExcel = () => {
|
||||||
|
downBlobFile('/canteen/canteenSupplier/export', Object.assign(state.queryForm, { ids: selectObjs }), 'canteenSupplier.xlsx')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 多选事件
|
||||||
|
const selectionChangHandle = (objs: { supplierId: string }[]) => {
|
||||||
|
selectObjs.value = objs.map(({ supplierId }) => supplierId);
|
||||||
|
multiple.value = !objs.length;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
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>
|
||||||
Reference in new issue
Block a user