食材采购修改和样式优化
This commit is contained in:
1 parent
bee9fefa1d
commit
8b7617bb44
9 files changed
+166
-223
No files matched your search
@@ -58,7 +58,7 @@
|
|||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
display: block;
|
display: block;
|
||||||
content: ' ';
|
content: " ";
|
||||||
border-color: transparent;
|
border-color: transparent;
|
||||||
border-style: solid solid outset;
|
border-style: solid solid outset;
|
||||||
border-width: 8px 8px 8px 0;
|
border-width: 8px 8px 8px 0;
|
||||||
@@ -78,14 +78,14 @@
|
|||||||
padding: 15px;
|
padding: 15px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
font-family: Segoe UI, Lucida Grande, Helvetica, Arial, Microsoft YaHei, FreeSans, Arimo, Droid Sans, wenquanyi micro hei, Hiragino Sans GB,
|
font-family: Noto Sans SC, Segoe UI, Lucida Grande, Helvetica, Arial, Microsoft YaHei, FreeSans, Arimo, Droid Sans, wenquanyi micro hei,
|
||||||
Hiragino Sans GB W3, FontAwesome, sans-serif;
|
Hiragino Sans GB, Hiragino Sans GB W3, FontAwesome, sans-serif;
|
||||||
color: #333;
|
color: #333;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
}
|
}
|
||||||
blockquote {
|
blockquote {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-family: Georgia, Times New Roman, Times, Kai, Kaiti SC, KaiTi, BiauKai, FontAwesome, serif;
|
font-family: Noto Sans SC, Georgia, Times New Roman, Times, Kai, Kaiti SC, KaiTi, BiauKai, FontAwesome, serif;
|
||||||
padding: 1px 0 1px 15px;
|
padding: 1px 0 1px 15px;
|
||||||
border-left: 4px solid #ddd;
|
border-left: 4px solid #ddd;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@ body,
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
|
font-family: Noto Sans SC, Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-webkit-tap-highlight-color: transparent;
|
-webkit-tap-highlight-color: transparent;
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
.login-title {
|
.login-title {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
font-family: PingFang SC, Arial, Hiragino Sans GB, Microsoft YaHei, sans-serif;
|
font-family: Noto Sans SC, PingFang SC, Arial, Hiragino Sans GB, Microsoft YaHei, sans-serif;
|
||||||
margin-bottom: 32px;
|
margin-bottom: 32px;
|
||||||
}
|
}
|
||||||
.login-box {
|
.login-box {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
@sort-change="sortChangeHandle"
|
@sort-change="sortChangeHandle"
|
||||||
>
|
>
|
||||||
<el-table-column type="selection" width="40" align="center" />
|
<el-table-column type="selection" width="40" align="center" />
|
||||||
<el-table-column type="index" label="#" width="40" />
|
<el-table-column type="index" label="#" width="50" />
|
||||||
<el-table-column prop="id" label="用户id" show-overflow-tooltip />
|
<el-table-column prop="id" label="用户id" show-overflow-tooltip />
|
||||||
<el-table-column prop="mobilePhone" label="手机号" show-overflow-tooltip />
|
<el-table-column prop="mobilePhone" label="手机号" show-overflow-tooltip />
|
||||||
<el-table-column prop="deviceFingerprint" label="MD5" show-overflow-tooltip />
|
<el-table-column prop="deviceFingerprint" label="MD5" show-overflow-tooltip />
|
||||||
|
|||||||
@@ -1,39 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-loading="loading" class="w-full h-full">
|
<el-dialog :title="baseForm.id ? '食材采购-编辑' : '食材采购-新增'" v-model="dialogVisible" fullscreen>
|
||||||
<div class="layout-padding-auto layout-padding-view" style="overflow: scroll">
|
<div v-loading="loading">
|
||||||
<el-form ref="baseFormRef" :model="baseForm" :rules="dataRules" label-width="100px">
|
<el-form class="flex flex-wrap" ref="baseFormRef" :model="baseForm" :rules="dataRules" label-width="100px">
|
||||||
<div class="flex flex-wrap">
|
<el-form-item label="单据编号" prop="inventoryCode">
|
||||||
<el-form-item label="单据编号" prop="inventoryCode">
|
<el-input v-model.trim="baseForm.inventoryCode" readonly style="width: 200px" />
|
||||||
<el-input v-model.trim="baseForm.inventoryCode" readonly style="width: 200px" />
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="单据日期" prop="inventoryDate">
|
||||||
<el-form-item label="单据日期" prop="inventoryDate">
|
<el-input v-model.trim="baseForm.inventoryDate" readonly style="width: 200px" />
|
||||||
<el-input v-model.trim="baseForm.inventoryDate" readonly style="width: 200px" />
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="经办人" prop="handlerUserId">
|
||||||
<el-form-item label="经办人" prop="handlerUserId">
|
<SelectHandlerUser v-model.trim="baseForm.handlerUserId" placeholder="请选择经办人" style="width: 200px" />
|
||||||
<SelectHandlerUser v-model.trim="baseForm.handlerUserId" placeholder="请选择经办人" style="width: 200px" />
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="货商" prop="supplierId">
|
||||||
<el-form-item label="货商" prop="supplierId">
|
<SelectCanteenSupplier v-model="baseForm.supplierId" style="width: 200px" />
|
||||||
<SelectCanteenSupplier v-model="baseForm.supplierId" style="width: 200px" />
|
</el-form-item>
|
||||||
</el-form-item>
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-form-item label="备注" prop="remark">
|
<el-input v-model.trim="baseForm.remark" placeholder="请输入备注" style="width: 200px" />
|
||||||
<el-input v-model.trim="baseForm.remark" placeholder="请输入备注" style="width: 200px" />
|
</el-form-item>
|
||||||
</el-form-item>
|
|
||||||
</div>
|
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-row class="my-3">
|
<el-row class="my-3">
|
||||||
<el-button type="primary" plain @click="clickSelectDialog">食材选择</el-button>
|
<el-button type="primary" plain @click="selectDialogRef.openDialog()">食材选择</el-button>
|
||||||
<el-button @click="removeSelectedRows" :disabled="state.selectedRowIds.length <= 0">删除选中</el-button>
|
<el-button @click="removeSelectedRows" :disabled="state.selectedRowIds.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>
|
||||||
|
|
||||||
<!-- 对话框选择 -->
|
<!-- 对话框选择 -->
|
||||||
<select-dialog
|
<select-dialog ref="selectDialogRef" :selectedRows="state.itemTableForm" @getSelectedRows="getSelectedRows" />
|
||||||
ref="selectDialogRef"
|
|
||||||
v-model="state.selectDialogVisible"
|
|
||||||
:selectedRows="state.itemTableForm"
|
|
||||||
@getSelectedRows="getSelectedRows"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<vxe-table
|
<vxe-table
|
||||||
ref="itemTableFormRef"
|
ref="itemTableFormRef"
|
||||||
@@ -65,62 +58,39 @@
|
|||||||
<vxe-column type="checkbox" width="40" fixed="left" />
|
<vxe-column type="checkbox" width="40" fixed="left" />
|
||||||
<vxe-column type="seq" width="50" fixed="left" />
|
<vxe-column type="seq" width="50" fixed="left" />
|
||||||
<vxe-column field="name" title="库存食材">
|
<vxe-column field="name" title="库存食材">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">{{ row.name || row.erpMaterialId }}</template>
|
||||||
{{ row.name || row.erpMaterialId }}
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
<vxe-column field="quantity" title="数量" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row }"><el-input v-model="row.quantity" /></template>
|
||||||
<el-input v-model="row.quantity" />
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="unitPrice" title="原进价">
|
<vxe-column field="unitPrice" title="原进价">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">{{ row.unitPrice || 0 }}</template>
|
||||||
{{ row.unitPrice || 0 }}
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="realPrice" title="实际进价" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
<vxe-column field="realPrice" title="实际进价" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">{{ row.realPrice }}</template>
|
||||||
{{ row.realPrice }}
|
<template #edit="{ row }"><el-input v-model="row.realPrice" /></template>
|
||||||
</template>
|
|
||||||
<template #edit="{ row }">
|
|
||||||
<el-input v-model="row.realPrice" />
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
|
||||||
<vxe-column field="totalNumber" title="总数" :edit-render="{ autoFocus: 'input', placeholder: '请输入' }">
|
|
||||||
<template #edit="{ row }">
|
|
||||||
<el-input v-model="row.totalNumber" />
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
<vxe-column field="totalAmount" title="累计总金额">
|
<vxe-column field="totalAmount" title="累计总金额">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">{{ (Number(row.quantity || 0) * Number(row.realPrice || 0)).toFixed(2) }}</template>
|
||||||
{{ (Number(row.quantity || 0) * Number(row.realPrice || 0)).toFixed(2) }}
|
|
||||||
</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: '请输入' }">
|
||||||
<template #edit="{ row }">
|
<template #edit="{ row }"><el-input v-model="row.remark" /></template>
|
||||||
<el-input v-model="row.remark" />
|
|
||||||
</template>
|
|
||||||
</vxe-column>
|
</vxe-column>
|
||||||
</vxe-table>
|
</vxe-table>
|
||||||
|
|
||||||
<el-row class="my-3">
|
|
||||||
<el-tooltip effect="dark" content="返回列表页面" placement="top">
|
|
||||||
<el-button type="primary" plain @click="emit('close')">返回</el-button>
|
|
||||||
</el-tooltip>
|
|
||||||
<el-tooltip v-if="!baseForm.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>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="dialogVisible = false" :disabled="loading">取消</el-button>
|
||||||
|
<el-tooltip v-if="!baseForm.id" effect="dark" content="保存并清空数据" placement="top">
|
||||||
|
<el-button type="primary" plain @click="onContinueAdd" :disabled="loading">继续添加</el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-button type="primary" @click="onSave" :disabled="loading">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from "vue"
|
import { ref, reactive } from "vue"
|
||||||
import { getObj, addObj, putObj } from "/@/api/canteen/canteenInventoryRecords"
|
import { getObj, addObj, putObj } from "/@/api/canteen/canteenInventoryRecords"
|
||||||
import { getCanteenSequence } from "/@/api/canteen/common"
|
import { getCanteenSequence } from "/@/api/canteen/common"
|
||||||
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
import { VxeTableEvents, VxeTablePropTypes, type VxeTableInstance } from "vxe-table"
|
||||||
@@ -130,21 +100,15 @@ import { useMessage } from "/@/hooks/message"
|
|||||||
|
|
||||||
const SelectDialog = defineAsyncComponent(() => import("./select-dialog.vue"))
|
const SelectDialog = defineAsyncComponent(() => import("./select-dialog.vue"))
|
||||||
|
|
||||||
const props = withDefaults(
|
const emit = defineEmits(["refresh"])
|
||||||
defineProps<{
|
|
||||||
formId?: string | undefined
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
formId: undefined,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
const emit = defineEmits(["close"])
|
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const dialogVisible = ref<boolean>(false)
|
||||||
|
|
||||||
const baseFormRef = ref() // 基本表单ref
|
const baseFormRef = ref() // 基本表单ref
|
||||||
const selectDialogRef = ref() // 对话框选择ref
|
const selectDialogRef = ref() // 对话框选择ref
|
||||||
const itemTableFormRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
const itemTableFormRef = ref<VxeTableInstance<any>>() // 可编辑表格ref
|
||||||
|
|
||||||
const baseForm = reactive<any>({
|
const baseForm = reactive<any>({
|
||||||
id: "",
|
id: "",
|
||||||
inventoryCode: "",
|
inventoryCode: "",
|
||||||
@@ -157,7 +121,6 @@ const baseForm = reactive<any>({
|
|||||||
totalAmount: 0,
|
totalAmount: 0,
|
||||||
})
|
})
|
||||||
const state = reactive<any>({
|
const state = reactive<any>({
|
||||||
selectDialogVisible: false, // 对话框选择开关
|
|
||||||
itemTableForm: [], // 可编辑表格数据
|
itemTableForm: [], // 可编辑表格数据
|
||||||
selectedRowIds: [], // 可编辑表格已选行的id
|
selectedRowIds: [], // 可编辑表格已选行的id
|
||||||
})
|
})
|
||||||
@@ -177,19 +140,14 @@ const validRules = ref<VxeTablePropTypes.EditRules<any>>({
|
|||||||
totalNumber: [{ required: true, type: "number", min: 1, message: "必填" }],
|
totalNumber: [{ required: true, type: "number", min: 1, message: "必填" }],
|
||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
const openDialog = async (id: string) => {
|
||||||
() => props.formId,
|
dialogVisible.value = true
|
||||||
async (val) => {
|
baseForm.id = ""
|
||||||
await getInitData()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
// 初始化数据
|
|
||||||
const getInitData = async () => {
|
|
||||||
baseForm.id = undefined
|
|
||||||
clearData()
|
clearData()
|
||||||
const id = props.formId
|
|
||||||
if (id) {
|
if (id) {
|
||||||
|
baseForm.id = id
|
||||||
loading.value = true
|
loading.value = true
|
||||||
// 获取清单数据
|
// 获取清单数据
|
||||||
const [res] = await Promise.allSettled([getObj(id)])
|
const [res] = await Promise.allSettled([getObj(id)])
|
||||||
@@ -199,9 +157,9 @@ const getInitData = async () => {
|
|||||||
Object.assign(baseForm, res.data, { items: "" })
|
Object.assign(baseForm, res.data, { items: "" })
|
||||||
state.itemTableForm = res.data.items.map((item: any) => ({
|
state.itemTableForm = res.data.items.map((item: any) => ({
|
||||||
...item,
|
...item,
|
||||||
|
unitPrice: displayPrice(item.unitPrice, ""),
|
||||||
realPrice: displayPrice(item.realPrice, ""),
|
realPrice: displayPrice(item.realPrice, ""),
|
||||||
totalAmount: displayPrice(item.totalAmount, ""),
|
totalAmount: displayPrice(item.totalAmount, ""),
|
||||||
unitPrice: displayPrice(item.unitPrice, ""),
|
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -214,8 +172,16 @@ const getInitData = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 点击食材选择
|
// 清空填写的数据 返回 true
|
||||||
const clickSelectDialog = () => selectDialogRef.value.openDialog()
|
const clearData = () => {
|
||||||
|
for (const key in baseForm) {
|
||||||
|
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
|
||||||
|
baseForm[key] = ""
|
||||||
|
}
|
||||||
|
state.itemTableForm = []
|
||||||
|
state.selectedRowIds = []
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
// 获取被选择的食材行
|
// 获取被选择的食材行
|
||||||
const getSelectedRows = (selectionRows: any) => {
|
const getSelectedRows = (selectionRows: any) => {
|
||||||
@@ -228,7 +194,6 @@ const getSelectedRows = (selectionRows: any) => {
|
|||||||
|
|
||||||
state.itemTableForm = [...state.itemTableForm, ...addedItems]
|
state.itemTableForm = [...state.itemTableForm, ...addedItems]
|
||||||
|
|
||||||
state.selectDialogVisible = false
|
|
||||||
console.log("state.itemTableForm", state.itemTableForm)
|
console.log("state.itemTableForm", state.itemTableForm)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,38 +219,8 @@ const removeSelectedRows = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 整理数据
|
|
||||||
const tableFormItems = () => {
|
|
||||||
return state.itemTableForm.map((item: any) => {
|
|
||||||
return {
|
|
||||||
id: item.isNew ? undefined : item.id,
|
|
||||||
erpMaterialId: item.erpMaterialId,
|
|
||||||
quantity: item.quantity,
|
|
||||||
unitPrice: storePrice(item.unitPrice),
|
|
||||||
realPrice: item.realPrice ? storePrice(item.realPrice) : 0,
|
|
||||||
totalAmount: storePrice((Number(item.quantity || 0) * Number(item.realPrice || 0)).toFixed(2)),
|
|
||||||
stock: item.stock,
|
|
||||||
remark: item.remark,
|
|
||||||
totalNumber: item.totalNumber,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 点击继续添加
|
|
||||||
const onContinueAdd = async () => {
|
|
||||||
;(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 点击保存
|
|
||||||
const onSave = async () => {
|
|
||||||
;(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData() && emit("close")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验基本数据表单 成功返回 true 失败返回 undefined
|
// 校验基本数据表单 成功返回 true 失败返回 undefined
|
||||||
const baseFormValidate = async () => {
|
const baseFormValidate = async () => await baseFormRef.value.validate().catch(() => {})
|
||||||
const valid = await baseFormRef.value.validate().catch(() => {})
|
|
||||||
return valid
|
|
||||||
}
|
|
||||||
|
|
||||||
// 校验可编辑表格 成功返回 true 失败返回 false
|
// 校验可编辑表格 成功返回 true 失败返回 false
|
||||||
const itemTableFormValidate = async () => {
|
const itemTableFormValidate = async () => {
|
||||||
@@ -298,16 +233,24 @@ const itemTableFormValidate = async () => {
|
|||||||
const $table = itemTableFormRef.value
|
const $table = itemTableFormRef.value
|
||||||
if ($table) {
|
if ($table) {
|
||||||
const errMap = await $table.validate(true)
|
const errMap = await $table.validate(true)
|
||||||
if (errMap) {
|
if (errMap) return false
|
||||||
console.log("全量校验失败!")
|
return true
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
console.log("全量校验成功!")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 整理数据
|
||||||
|
const tableFormItems = () =>
|
||||||
|
state.itemTableForm.map((item: any) => ({
|
||||||
|
id: item.isNew ? undefined : item.id,
|
||||||
|
erpMaterialId: item.erpMaterialId,
|
||||||
|
quantity: item.quantity,
|
||||||
|
unitPrice: storePrice(item.unitPrice),
|
||||||
|
realPrice: item.realPrice ? storePrice(item.realPrice) : 0,
|
||||||
|
totalAmount: storePrice((Number(item.quantity || 0) * Number(item.realPrice || 0)).toFixed(2)),
|
||||||
|
stock: item.stock,
|
||||||
|
remark: item.remark,
|
||||||
|
}))
|
||||||
|
|
||||||
// 提交数据 成功返回 true 失败返回 false
|
// 提交数据 成功返回 true 失败返回 false
|
||||||
const submitData = async () => {
|
const submitData = async () => {
|
||||||
const canteenInventoryRecordsItemDTOS = tableFormItems()
|
const canteenInventoryRecordsItemDTOS = tableFormItems()
|
||||||
@@ -336,18 +279,20 @@ const submitData = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 清空填写的数据 返回 true
|
// 点击继续添加
|
||||||
const clearData = () => {
|
const onContinueAdd = async () => {
|
||||||
for (const key in baseForm) {
|
;(await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData() && emit("refresh")
|
||||||
if (key === "id" || key === "inventoryCode" || key === "inventoryDate" || key === "inventoryType" || key === "orderType") continue
|
|
||||||
baseForm[key] = ""
|
|
||||||
}
|
|
||||||
state.itemTableForm = []
|
|
||||||
state.selectedRowIds = []
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
// 点击保存
|
||||||
getInitData()
|
const onSave = async () => {
|
||||||
|
if ((await baseFormValidate()) && (await itemTableFormValidate()) && (await submitData()) && clearData()) {
|
||||||
|
dialogVisible.value = false
|
||||||
|
emit("refresh")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
openDialog,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="layout-padding">
|
<div class="layout-padding">
|
||||||
<div v-show="!formState.showForm" class="layout-padding-auto layout-padding-view">
|
<div class="layout-padding-auto layout-padding-view">
|
||||||
<el-row v-show="showSearch">
|
<el-row v-show="showSearch">
|
||||||
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
|
||||||
<el-form-item label="单据编号" prop="inventoryCode">
|
<el-form-item label="单据编号" prop="inventoryCode">
|
||||||
@@ -23,7 +23,13 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<div class="mb8" style="width: 100%">
|
<div class="mb8" style="width: 100%">
|
||||||
<el-button icon="folder-add" type="primary" class="ml10" @click="create" v-auth="'canteen_canteenInventoryRecords_add'">
|
<el-button
|
||||||
|
icon="folder-add"
|
||||||
|
type="primary"
|
||||||
|
class="ml10"
|
||||||
|
@click="formDialogRef.openDialog()"
|
||||||
|
v-auth="'canteen_canteenInventoryRecords_add'"
|
||||||
|
>
|
||||||
新 增
|
新 增
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@@ -77,7 +83,13 @@
|
|||||||
<!-- <el-table-column prop="checkReason" label="审核原因" show-overflow-tooltip /> -->
|
<!-- <el-table-column prop="checkReason" label="审核原因" show-overflow-tooltip /> -->
|
||||||
<el-table-column label="操作" width="150">
|
<el-table-column label="操作" width="150">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button icon="edit-pen" text type="primary" v-auth="'canteen_canteenInventoryRecords_edit'" @click="edit(scope.row)">
|
<el-button
|
||||||
|
icon="edit-pen"
|
||||||
|
text
|
||||||
|
type="primary"
|
||||||
|
v-auth="'canteen_canteenInventoryRecords_edit'"
|
||||||
|
@click="formDialogRef.openDialog(scope.row.id)"
|
||||||
|
>
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
@@ -95,7 +107,7 @@
|
|||||||
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
<pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" v-bind="state.pagination" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ct-form v-show="formState.showForm" :formId="formState.formId" @close="formClose" />
|
<ct-form ref="formDialogRef" @refresh="getDataList()" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -111,11 +123,7 @@ const queryRef = ref()
|
|||||||
const showSearch = ref(true)
|
const showSearch = ref(true)
|
||||||
const selectObjs = ref([]) as any
|
const selectObjs = ref([]) as any
|
||||||
const multiple = ref(true)
|
const multiple = ref(true)
|
||||||
const formState = reactive<{ formId: string | undefined; showForm: boolean }>({
|
const formDialogRef = ref()
|
||||||
formId: undefined,
|
|
||||||
showForm: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
const state: BasicTableProps = reactive<BasicTableProps>({
|
const state: BasicTableProps = reactive<BasicTableProps>({
|
||||||
queryForm: {
|
queryForm: {
|
||||||
inventoryType: "1",
|
inventoryType: "1",
|
||||||
@@ -145,19 +153,6 @@ const selectionChangHandle = (objs: { id: string }[]) => {
|
|||||||
multiple.value = !objs.length
|
multiple.value = !objs.length
|
||||||
}
|
}
|
||||||
|
|
||||||
// 新增
|
|
||||||
const create = () => {
|
|
||||||
formState.formId = undefined
|
|
||||||
formState.showForm = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// 点击编辑
|
|
||||||
const edit = (row: any) => {
|
|
||||||
if (!row.id) return useMessage().warning("清单id不存在")
|
|
||||||
formState.formId = row.id
|
|
||||||
formState.showForm = true
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除操作
|
// 删除操作
|
||||||
const handleDelete = async (ids: string[]) => {
|
const handleDelete = async (ids: string[]) => {
|
||||||
try {
|
try {
|
||||||
@@ -174,11 +169,4 @@ const handleDelete = async (ids: string[]) => {
|
|||||||
useMessage().error(err.msg)
|
useMessage().error(err.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 表单关闭
|
|
||||||
const formClose = () => {
|
|
||||||
formState.showForm = false
|
|
||||||
formState.formId = undefined
|
|
||||||
getDataList()
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
@@ -46,7 +46,6 @@
|
|||||||
import { ref } from "vue"
|
import { ref } from "vue"
|
||||||
import { fetchErpMaterialPageList } from "/@/api/canteen/canteenErpMaterial"
|
import { fetchErpMaterialPageList } from "/@/api/canteen/canteenErpMaterial"
|
||||||
|
|
||||||
const dialogVisible = defineModel()
|
|
||||||
const emit = defineEmits(["getSelectedRows"])
|
const emit = defineEmits(["getSelectedRows"])
|
||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
@@ -60,6 +59,7 @@ const props = withDefaults(
|
|||||||
const queryRef = ref()
|
const queryRef = ref()
|
||||||
const tableRef = ref() // 对话框多选表格ref
|
const tableRef = ref() // 对话框多选表格ref
|
||||||
const loading = ref(false) // 对话框多选表格loading
|
const loading = ref(false) // 对话框多选表格loading
|
||||||
|
const dialogVisible = ref(false)
|
||||||
const queryForm = reactive<any>({
|
const queryForm = reactive<any>({
|
||||||
name: "",
|
name: "",
|
||||||
})
|
})
|
||||||
@@ -130,6 +130,7 @@ const dialogConfirm = () => {
|
|||||||
...currentSelectedRows,
|
...currentSelectedRows,
|
||||||
...props.selectedRows.filter((row) => !dataList.value.some((item) => item.erpMaterialId === row.erpMaterialId)),
|
...props.selectedRows.filter((row) => !dataList.value.some((item) => item.erpMaterialId === row.erpMaterialId)),
|
||||||
]
|
]
|
||||||
|
dialogVisible.value = false
|
||||||
emit("getSelectedRows", allSelectedRows)
|
emit("getSelectedRows", allSelectedRows)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ body {
|
|||||||
background: var(--color-background);
|
background: var(--color-background);
|
||||||
transition: color 0.5s, background-color 0.5s;
|
transition: color 0.5s, background-color 0.5s;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
font-family: Noto Sans SC, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans",
|
||||||
sans-serif;
|
"Droid Sans", "Helvetica Neue", sans-serif;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
text-rendering: optimizeLegibility;
|
text-rendering: optimizeLegibility;
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<span class="dialog-footer">
|
<span class="dialog-footer">
|
||||||
<el-button @click="visible = false">{{ $t('common.cancelButtonText') }}</el-button>
|
<el-button @click="visible = false">{{ $t("common.cancelButtonText") }}</el-button>
|
||||||
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t('common.confirmButtonText') }}</el-button>
|
<el-button @click="onSubmit" type="primary" :disabled="loading">{{ $t("common.confirmButtonText") }}</el-button>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
@@ -32,86 +32,95 @@
|
|||||||
|
|
||||||
<script lang="ts" name="GenTemplateDialog" setup>
|
<script lang="ts" name="GenTemplateDialog" setup>
|
||||||
// 定义子组件向父组件传值/事件
|
// 定义子组件向父组件传值/事件
|
||||||
import { useMessage } from '/@/hooks/message';
|
import { useMessage } from "/@/hooks/message"
|
||||||
import { addObj, getObj, putObj } from '/@/api/gen/template';
|
import { addObj, getObj, putObj } from "/@/api/gen/template"
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from "vue-i18n"
|
||||||
import {rule} from "/@/utils/validate";
|
import { rule } from "/@/utils/validate"
|
||||||
|
|
||||||
const CodeEditor = defineAsyncComponent(() => import('/@/components/CodeEditor/index.vue'));
|
const CodeEditor = defineAsyncComponent(() => import("/@/components/CodeEditor/index.vue"))
|
||||||
const emit = defineEmits(['refresh']);
|
const emit = defineEmits(["refresh"])
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n()
|
||||||
|
|
||||||
// 定义变量内容
|
// 定义变量内容
|
||||||
const dataFormRef = ref();
|
const dataFormRef = ref()
|
||||||
const visible = ref(false);
|
const visible = ref(false)
|
||||||
const loading = ref(false);
|
const loading = ref(false)
|
||||||
|
|
||||||
// 定义字典
|
// 定义字典
|
||||||
|
|
||||||
// 提交表单数据
|
// 提交表单数据
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: '',
|
id: "",
|
||||||
templateName: '',
|
templateName: "",
|
||||||
generatorPath: '',
|
generatorPath: "",
|
||||||
templateDesc: '',
|
templateDesc: "",
|
||||||
templateCode: '',
|
templateCode: "",
|
||||||
});
|
})
|
||||||
|
|
||||||
// 定义校验规则
|
// 定义校验规则
|
||||||
const dataRules = ref({
|
const dataRules = ref({
|
||||||
templateName: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板名称不能为空', trigger: 'blur' }],
|
templateName: [
|
||||||
generatorPath: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板路径不能为空', trigger: 'blur' }],
|
{ validator: rule.overLength, trigger: "blur" },
|
||||||
templateDesc: [{ validator: rule.overLength, trigger: 'blur' },{ required: true, message: '模板描述不能为空', trigger: 'blur' }],
|
{ required: true, message: "模板名称不能为空", trigger: "blur" },
|
||||||
});
|
],
|
||||||
|
generatorPath: [
|
||||||
|
{ validator: rule.overLength, trigger: "blur" },
|
||||||
|
{ required: true, message: "模板路径不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
templateDesc: [
|
||||||
|
{ validator: rule.overLength, trigger: "blur" },
|
||||||
|
{ required: true, message: "模板描述不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
// 打开弹窗
|
// 打开弹窗
|
||||||
const openDialog = (id: string) => {
|
const openDialog = (id: string) => {
|
||||||
visible.value = true;
|
visible.value = true
|
||||||
form.id = '';
|
form.id = ""
|
||||||
|
|
||||||
// 重置表单数据
|
// 重置表单数据
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
dataFormRef.value?.resetFields();
|
dataFormRef.value?.resetFields()
|
||||||
});
|
})
|
||||||
// 获取genTemplate信息
|
// 获取genTemplate信息
|
||||||
if (id) {
|
if (id) {
|
||||||
form.id = id;
|
form.id = id
|
||||||
getgenTemplateData(id);
|
getgenTemplateData(id)
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
// 提交
|
// 提交
|
||||||
const onSubmit = async () => {
|
const onSubmit = async () => {
|
||||||
const valid = await dataFormRef.value.validate().catch(() => {});
|
const valid = await dataFormRef.value.validate().catch(() => {})
|
||||||
if (!valid) return false;
|
if (!valid) return false
|
||||||
|
|
||||||
// 校验模板是否为空
|
// 校验模板是否为空
|
||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true;
|
loading.value = true
|
||||||
form.id ? await putObj(form) : await addObj(form);
|
form.id ? await putObj(form) : await addObj(form)
|
||||||
useMessage().success(t(form.id ? 'common.editSuccessText' : 'common.addSuccessText'));
|
useMessage().success(t(form.id ? "common.editSuccessText" : "common.addSuccessText"))
|
||||||
visible.value = false;
|
visible.value = false
|
||||||
emit('refresh');
|
emit("refresh")
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
useMessage().error(err.msg);
|
useMessage().error(err.msg)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false;
|
loading.value = false
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
// 初始化表单数据
|
// 初始化表单数据
|
||||||
const getgenTemplateData = (id: string) => {
|
const getgenTemplateData = (id: string) => {
|
||||||
// 获取数据
|
// 获取数据
|
||||||
getObj(id).then((res: any) => {
|
getObj(id).then((res: any) => {
|
||||||
Object.assign(form, res.data);
|
Object.assign(form, res.data)
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
// 暴露变量
|
// 暴露变量
|
||||||
defineExpose({
|
defineExpose({
|
||||||
openDialog,
|
openDialog,
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
Reference in new issue
Block a user