feat: 台桌列表增加绑定桌码功能(暂时隐藏)

This commit is contained in:
2025-03-31 15:57:19 +08:00
parent 274833d548
commit 3af175c506
3 changed files with 107 additions and 3 deletions

View File

@@ -0,0 +1,82 @@
<template>
<el-dialog title="绑定桌码" v-model="dialogVisible" width="30%" @close="reset">
<el-form :model="form" :rules="rules" ref="refForm">
<el-form-item label="桌码" prop="tableCode">
<el-input
autofocus
ref="refTableCode"
v-model="form.tableCode"
placeholder="请输入表码"
></el-input>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup>
import shopTableApi from "@/api/account/table";
const dialogVisible = ref(false);
const form = reactive({
id: "",
tableCode: "",
});
const rules = {
tableCode: [{ required: true, message: "请输入桌码", trigger: "blur" }],
};
const refForm = ref(null);
function reset() {
refForm.value.resetFields();
for (let i in form) {
form[i] = "";
}
}
const refTableCode = ref(null);
function open(item) {
dialogVisible.value = true;
nextTick(() => {
setTimeout(() => {
refTableCode.value.focus();
}, 100);
});
form.tableCode = item.tableCode;
form.id = item.id;
}
const emits = defineEmits(["refresh"]);
function submitForm() {
refForm.value.validate((valid) => {
if (valid) {
shopTableApi
.bindTableCode(form)
.then((res) => {
ElMessage({
type: res ? "success" : "error",
message: res ? "绑定成功" : "绑定失败",
});
if (res) {
close();
emits("refresh");
}
})
.catch((error) => {
console.log(error);
});
}
});
}
function close() {
dialogVisible.value = false;
}
defineExpose({
open,
close,
});
</script>