|
@@ -12,15 +12,54 @@
|
|
|
</template>
|
|
</template>
|
|
|
<!-- 表格操作 -->
|
|
<!-- 表格操作 -->
|
|
|
<template #operation="scope">
|
|
<template #operation="scope">
|
|
|
- <!-- 审批通过和拒绝按钮仅在状态为0时显示 -->
|
|
|
|
|
- <template v-if="scope.row.status === '0'">
|
|
|
|
|
- <el-button link type="primary" @click="changeTypes(scope.row, 'on')"> 上架 </el-button>
|
|
|
|
|
- <el-button link type="primary" @click="changeTypes(scope.row, 'off')"> 下架 </el-button>
|
|
|
|
|
- <el-button link type="primary" @click="changeInventory(scope.row)"> 修改库存 </el-button>
|
|
|
|
|
- </template>
|
|
|
|
|
- <el-button type="primary" link @click="toDetail(scope.row)"> 查看详情 </el-button>
|
|
|
|
|
- <el-button link type="primary" @click="editRow(scope.row)"> 编辑 </el-button>
|
|
|
|
|
- <el-button link type="primary" @click="deleteRow(scope.row)"> 删除 </el-button>
|
|
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="changeTypes(scope.row, 'on')"
|
|
|
|
|
+ v-if="canShowButton(scope.row.status, OPERATION_PERMISSIONS.上架)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 上架
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="changeTypes(scope.row, 'off')"
|
|
|
|
|
+ v-if="canShowButton(scope.row.status, OPERATION_PERMISSIONS.下架)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 下架
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="changeInventory(scope.row)"
|
|
|
|
|
+ v-if="canShowButton(scope.row.status, OPERATION_PERMISSIONS.修改库存)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 修改库存
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ link
|
|
|
|
|
+ @click="toDetail(scope.row)"
|
|
|
|
|
+ v-if="canShowButton(scope.row.status, OPERATION_PERMISSIONS.查看详情)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 查看详情
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="editRow(scope.row)"
|
|
|
|
|
+ v-if="canShowButton(scope.row.status, OPERATION_PERMISSIONS.编辑)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 编辑
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ <el-button
|
|
|
|
|
+ link
|
|
|
|
|
+ type="primary"
|
|
|
|
|
+ @click="deleteRow(scope.row)"
|
|
|
|
|
+ v-if="canShowButton(scope.row.status, OPERATION_PERMISSIONS.删除)"
|
|
|
|
|
+ >
|
|
|
|
|
+ 删除
|
|
|
|
|
+ </el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</ProTable>
|
|
</ProTable>
|
|
|
<el-dialog v-model="dialogFormVisible" title="修改库存" width="500">
|
|
<el-dialog v-model="dialogFormVisible" title="修改库存" width="500">
|
|
@@ -78,12 +117,48 @@ const rules = reactive<FormRules<RuleForm>>({
|
|
|
}
|
|
}
|
|
|
]
|
|
]
|
|
|
});
|
|
});
|
|
|
-const statusEnum = [
|
|
|
|
|
- { value: "-1", label: "待审核" },
|
|
|
|
|
- { value: "-2", label: "审核通过" },
|
|
|
|
|
- { value: "0", label: "审核驳回" }
|
|
|
|
|
|
|
+const allTabOptions = [
|
|
|
|
|
+ { label: "全部", name: "" },
|
|
|
|
|
+ { label: "草稿", name: "0" },
|
|
|
|
|
+ { label: "进行中", name: "5" },
|
|
|
|
|
+ { label: "未开始", name: "2" },
|
|
|
|
|
+ { label: "已下架", name: "6" },
|
|
|
|
|
+ { label: "已售罄", name: "4" },
|
|
|
|
|
+ { label: "已结束", name: "7" }
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
|
|
+// 状态枚举:0草稿 1待审核 2未开始 3审核拒绝 4已售罄 5进行中 6已下架 7已结束
|
|
|
|
|
+const STATUS = {
|
|
|
|
|
+ 草稿: 0,
|
|
|
|
|
+ 待审核: 1,
|
|
|
|
|
+ 未开始: 2,
|
|
|
|
|
+ 审核拒绝: 3,
|
|
|
|
|
+ 已售罄: 4,
|
|
|
|
|
+ 进行中: 5,
|
|
|
|
|
+ 已下架: 6,
|
|
|
|
|
+ 已结束: 7
|
|
|
|
|
+} as const;
|
|
|
|
|
+
|
|
|
|
|
+// 操作按钮权限配置:定义每个操作按钮在哪些状态下显示
|
|
|
|
|
+const OPERATION_PERMISSIONS = {
|
|
|
|
|
+ // 查看详情:待审核、未开始、审核拒绝、进行中、已售罄、已下架
|
|
|
|
|
+ 查看详情: [STATUS.待审核, STATUS.未开始, STATUS.审核拒绝, STATUS.进行中, STATUS.已售罄, STATUS.已下架],
|
|
|
|
|
+ // 上架:未开始、已下架
|
|
|
|
|
+ 上架: [STATUS.未开始, STATUS.已下架],
|
|
|
|
|
+ // 下架:进行中
|
|
|
|
|
+ 下架: [STATUS.进行中],
|
|
|
|
|
+ // 修改库存:未开始、进行中、已售罄
|
|
|
|
|
+ 修改库存: [STATUS.未开始, STATUS.进行中, STATUS.已售罄],
|
|
|
|
|
+ // 编辑:草稿、审核拒绝、已售罄、已下架、已结束
|
|
|
|
|
+ 编辑: [STATUS.草稿, STATUS.审核拒绝, STATUS.已售罄, STATUS.已下架, STATUS.已结束],
|
|
|
|
|
+ // 删除:草稿、未开始、审核拒绝、已售罄、已结束
|
|
|
|
|
+ 删除: [STATUS.草稿, STATUS.未开始, STATUS.审核拒绝, STATUS.已售罄, STATUS.已结束]
|
|
|
|
|
+} as const;
|
|
|
|
|
+
|
|
|
|
|
+// 判断按钮是否显示的工具函数
|
|
|
|
|
+const canShowButton = (status: number, allowedStatuses: readonly number[]) => {
|
|
|
|
|
+ return allowedStatuses.includes(status);
|
|
|
|
|
+};
|
|
|
// ProTable 实例(需要在使用它的地方之前定义)
|
|
// ProTable 实例(需要在使用它的地方之前定义)
|
|
|
const proTable = ref<ProTableInstance>();
|
|
const proTable = ref<ProTableInstance>();
|
|
|
|
|
|
|
@@ -123,17 +198,6 @@ const columns = reactive<ColumnProps<any>[]>([
|
|
|
{ prop: "operation", label: "操作", fixed: "right", width: 330 }
|
|
{ prop: "operation", label: "操作", fixed: "right", width: 330 }
|
|
|
]);
|
|
]);
|
|
|
|
|
|
|
|
-// 在 script setup 中添加
|
|
|
|
|
-const allTabOptions = [
|
|
|
|
|
- { label: "全部", name: "" },
|
|
|
|
|
- { label: "草稿", name: "0" },
|
|
|
|
|
- { label: "进行中", name: "5" },
|
|
|
|
|
- { label: "待审核", name: "1" },
|
|
|
|
|
- { label: "审核拒绝", name: "3" },
|
|
|
|
|
- { label: "已售罄", name: "4" },
|
|
|
|
|
- { label: "已结束", name: "7" }
|
|
|
|
|
-];
|
|
|
|
|
-
|
|
|
|
|
// 获取当前审核状态
|
|
// 获取当前审核状态
|
|
|
const currentAuditStatus = computed(() => {
|
|
const currentAuditStatus = computed(() => {
|
|
|
if (!proTable.value?.searchParam) return "";
|
|
if (!proTable.value?.searchParam) return "";
|