|
@@ -43,7 +43,7 @@
|
|
|
v-loading="detailLoading"
|
|
v-loading="detailLoading"
|
|
|
require-asterisk-position="right"
|
|
require-asterisk-position="right"
|
|
|
>
|
|
>
|
|
|
- <el-form-item label="选择分类" prop="categoryId" required>
|
|
|
|
|
|
|
+ <el-form-item label="选择分类" prop="categoryId">
|
|
|
<el-select v-model="form.categoryId" placeholder="请选择分类" clearable>
|
|
<el-select v-model="form.categoryId" placeholder="请选择分类" clearable>
|
|
|
<el-option v-for="item in categoryOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
<el-option v-for="item in categoryOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
</el-select>
|
|
</el-select>
|
|
@@ -55,7 +55,7 @@
|
|
|
<el-button type="primary" link @click="addTableRow"> 添加 </el-button>
|
|
<el-button type="primary" link @click="addTableRow"> 添加 </el-button>
|
|
|
</div>
|
|
</div>
|
|
|
<template v-for="(row, index) in form.tableRows" :key="index">
|
|
<template v-for="(row, index) in form.tableRows" :key="index">
|
|
|
- <el-form-item label="桌号" :prop="'tableRows.' + index + '.tableNo'" :rules="tableNoFieldRules" required>
|
|
|
|
|
|
|
+ <el-form-item label="桌号" :prop="'tableRows.' + index + '.tableNo'" :rules="tableNoFieldRules">
|
|
|
<el-input
|
|
<el-input
|
|
|
:model-value="row.tableNo"
|
|
:model-value="row.tableNo"
|
|
|
placeholder="如 A01"
|
|
placeholder="如 A01"
|
|
@@ -63,7 +63,7 @@
|
|
|
@update:model-value="(val: string) => onTableNumberInput(row, val)"
|
|
@update:model-value="(val: string) => onTableNumberInput(row, val)"
|
|
|
/>
|
|
/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="座位数" :prop="'tableRows.' + index + '.seatCount'" :rules="seatCountFieldRulesRow" required>
|
|
|
|
|
|
|
+ <el-form-item label="座位数" :prop="'tableRows.' + index + '.seatCount'" :rules="seatCountFieldRulesRow">
|
|
|
<el-input
|
|
<el-input
|
|
|
:model-value="row.seatCount"
|
|
:model-value="row.seatCount"
|
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
@@ -81,7 +81,7 @@
|
|
|
|
|
|
|
|
<!-- 编辑:单条 -->
|
|
<!-- 编辑:单条 -->
|
|
|
<template v-else>
|
|
<template v-else>
|
|
|
- <el-form-item label="桌号" prop="tableNo" required>
|
|
|
|
|
|
|
+ <el-form-item label="桌号" prop="tableNo">
|
|
|
<el-input
|
|
<el-input
|
|
|
:model-value="form.tableNo"
|
|
:model-value="form.tableNo"
|
|
|
placeholder="如 A01"
|
|
placeholder="如 A01"
|
|
@@ -90,7 +90,7 @@
|
|
|
@update:model-value="onTableNumberInputEdit"
|
|
@update:model-value="onTableNumberInputEdit"
|
|
|
/>
|
|
/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
- <el-form-item label="座位数" prop="seatCount" required>
|
|
|
|
|
|
|
+ <el-form-item label="座位数" prop="seatCount">
|
|
|
<el-input
|
|
<el-input
|
|
|
:model-value="seatCountEditDisplay"
|
|
:model-value="seatCountEditDisplay"
|
|
|
placeholder="请输入"
|
|
placeholder="请输入"
|
|
@@ -281,12 +281,14 @@ const form = reactive<{
|
|
|
/** 与 group_merchant/pages/scheduledService/addTableNumber.vue 一致 */
|
|
/** 与 group_merchant/pages/scheduledService/addTableNumber.vue 一致 */
|
|
|
const TABLE_NUMBER_REG = /^[A-Z][0-9]{2}$/;
|
|
const TABLE_NUMBER_REG = /^[A-Z][0-9]{2}$/;
|
|
|
|
|
|
|
|
|
|
+/** 勿在 el-form-item 上写 required:会注入无 message 的必填规则,嵌套 prop 会报英文「tableRows.0.xxx is required」 */
|
|
|
const tableNoFieldRules: FormItemRule[] = [
|
|
const tableNoFieldRules: FormItemRule[] = [
|
|
|
|
|
+ { required: true, message: "请输入桌号", trigger: ["blur", "change"] },
|
|
|
{
|
|
{
|
|
|
validator: (_rule, value, callback) => {
|
|
validator: (_rule, value, callback) => {
|
|
|
const num = String(value ?? "").trim();
|
|
const num = String(value ?? "").trim();
|
|
|
if (!num) {
|
|
if (!num) {
|
|
|
- callback(new Error("请输入桌号"));
|
|
|
|
|
|
|
+ callback();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
if (!TABLE_NUMBER_REG.test(num)) {
|
|
if (!TABLE_NUMBER_REG.test(num)) {
|
|
@@ -300,11 +302,12 @@ const tableNoFieldRules: FormItemRule[] = [
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
const seatCountFieldRulesRow: FormItemRule[] = [
|
|
const seatCountFieldRulesRow: FormItemRule[] = [
|
|
|
|
|
+ { required: true, message: "请输入座位数", trigger: ["blur", "change"] },
|
|
|
{
|
|
{
|
|
|
validator: (_rule, value, callback) => {
|
|
validator: (_rule, value, callback) => {
|
|
|
const seat = String(value ?? "").trim();
|
|
const seat = String(value ?? "").trim();
|
|
|
if (!seat) {
|
|
if (!seat) {
|
|
|
- callback(new Error("请输入座位数"));
|
|
|
|
|
|
|
+ callback();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
const n = parseInt(seat, 10);
|
|
const n = parseInt(seat, 10);
|
|
@@ -391,7 +394,7 @@ function onSeatCountInputEdit(val: string) {
|
|
|
/** 新建只校验分类 + 各行(行规则在 el-form-item 上);编辑校验分类 + 单条桌号/座位数 */
|
|
/** 新建只校验分类 + 各行(行规则在 el-form-item 上);编辑校验分类 + 单条桌号/座位数 */
|
|
|
const formRules = computed<FormRules>(() => {
|
|
const formRules = computed<FormRules>(() => {
|
|
|
const base: FormRules = {
|
|
const base: FormRules = {
|
|
|
- categoryId: [{ required: true, message: "请选择位置", trigger: "change" }]
|
|
|
|
|
|
|
+ categoryId: [{ required: true, message: "请选择分类", trigger: "change" }]
|
|
|
};
|
|
};
|
|
|
if (editId.value != null) {
|
|
if (editId.value != null) {
|
|
|
base.tableNo = tableNoFieldRules;
|
|
base.tableNo = tableNoFieldRules;
|