|
@@ -1,11 +1,6 @@
|
|
|
<template>
|
|
<template>
|
|
|
<ele-page flex-table>
|
|
<ele-page flex-table>
|
|
|
- <common-table ref="tableRef" :pageConfig="pageConfig" :columns="columns" :tools="false"
|
|
|
|
|
- :datasource="mockDatasource">
|
|
|
|
|
- <template #toolbar>
|
|
|
|
|
- <el-button type="primary" @click="handleAdd">新建规格</el-button>
|
|
|
|
|
- </template>
|
|
|
|
|
-
|
|
|
|
|
|
|
+ <common-table ref="tableRef" :columns="columns" :tools="false" :datasource="datasource" :pagination="false">
|
|
|
<!-- 序号 -->
|
|
<!-- 序号 -->
|
|
|
<template #index="{ $index }">
|
|
<template #index="{ $index }">
|
|
|
{{ $index + 1 }}
|
|
{{ $index + 1 }}
|
|
@@ -18,8 +13,7 @@
|
|
|
|
|
|
|
|
<!-- 是否启用 -->
|
|
<!-- 是否启用 -->
|
|
|
<template #status="{ row }">
|
|
<template #status="{ row }">
|
|
|
- <el-switch v-model="row.status" :active-value="1" :inactive-value="0"
|
|
|
|
|
- @change="handleStatusChange(row)" />
|
|
|
|
|
|
|
+ <el-switch v-model="row.status" active-value="1" inactive-value="0" @change="handleStatusChange(row)" />
|
|
|
</template>
|
|
</template>
|
|
|
</common-table>
|
|
</common-table>
|
|
|
|
|
|
|
@@ -28,80 +22,66 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, reactive } from 'vue';
|
|
|
|
|
-import CommonTable from '@/components/CommonPage/CommonTable.vue';
|
|
|
|
|
-import SpecEditDialog from './components/spec-edit-dialog.vue';
|
|
|
|
|
-import { ElMessage } from 'element-plus';
|
|
|
|
|
-
|
|
|
|
|
-defineOptions({ name: 'GoodsSpec' });
|
|
|
|
|
-
|
|
|
|
|
-const tableRef = ref(null);
|
|
|
|
|
-const editDialogRef = ref(null);
|
|
|
|
|
-
|
|
|
|
|
-const pageConfig = reactive({
|
|
|
|
|
- pageUrl: '', // Local mock data
|
|
|
|
|
- fileName: '规格列表',
|
|
|
|
|
- cacheKey: 'goods-spec-list',
|
|
|
|
|
- params: {}
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-const columns = ref([
|
|
|
|
|
- { label: '序号', type: 'index', width: 100, align: 'center' },
|
|
|
|
|
- { label: '规格名称', prop: 'name', align: 'center' },
|
|
|
|
|
- { label: '规格值', prop: 'value', align: 'center' },
|
|
|
|
|
- { label: '操作', prop: 'action', slot: 'action', align: 'center' },
|
|
|
|
|
- { label: '是否启用', prop: 'status', slot: 'status', align: 'center' }
|
|
|
|
|
-]);
|
|
|
|
|
-
|
|
|
|
|
-// Mock Data
|
|
|
|
|
-const mockList = ref([
|
|
|
|
|
- { id: 1, name: '一般', value: '1', status: 1 },
|
|
|
|
|
- { id: 2, name: '良好', value: '1.2', status: 1 },
|
|
|
|
|
- { id: 3, name: '次品', value: '0.7', status: 1 },
|
|
|
|
|
- { id: 4, name: '全新', value: '1.2', status: 1 }
|
|
|
|
|
-]);
|
|
|
|
|
-
|
|
|
|
|
-const mockDatasource = ({ page, limit }) => {
|
|
|
|
|
- return new Promise((resolve) => {
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- resolve({
|
|
|
|
|
- code: 0,
|
|
|
|
|
- msg: 'success',
|
|
|
|
|
- count: mockList.value.length,
|
|
|
|
|
- data: mockList.value
|
|
|
|
|
- });
|
|
|
|
|
- }, 300);
|
|
|
|
|
|
|
+ import { ref, reactive } from 'vue';
|
|
|
|
|
+ import CommonTable from '@/components/CommonPage/CommonTable.vue';
|
|
|
|
|
+ import SpecEditDialog from './components/spec-edit-dialog.vue';
|
|
|
|
|
+ import { ElMessage } from 'element-plus';
|
|
|
|
|
+ import request from '@/utils/request';
|
|
|
|
|
+
|
|
|
|
|
+ defineOptions({ name: 'GoodsSpec' });
|
|
|
|
|
+
|
|
|
|
|
+ const tableRef = ref(null);
|
|
|
|
|
+ const editDialogRef = ref(null);
|
|
|
|
|
+
|
|
|
|
|
+ const pageConfig = reactive({
|
|
|
|
|
+ pageUrl: '',
|
|
|
|
|
+ fileName: '规格列表',
|
|
|
|
|
+ cacheKey: 'goods-spec-list',
|
|
|
|
|
+ params: {}
|
|
|
});
|
|
});
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const reload = () => {
|
|
|
|
|
- tableRef.value?.reload();
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const handleAdd = () => {
|
|
|
|
|
- editDialogRef.value?.handleOpen();
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const handleEdit = (row) => {
|
|
|
|
|
- editDialogRef.value?.handleOpen(row);
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const handleSuccess = (data) => {
|
|
|
|
|
- if (data.id) {
|
|
|
|
|
- const index = mockList.value.findIndex(item => item.id === data.id);
|
|
|
|
|
- if (index !== -1) {
|
|
|
|
|
- mockList.value[index] = { ...mockList.value[index], ...data };
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- data.id = Date.now(); // Generate unique ID
|
|
|
|
|
- mockList.value.push(data);
|
|
|
|
|
- }
|
|
|
|
|
- reload();
|
|
|
|
|
-};
|
|
|
|
|
|
|
|
|
|
-const handleStatusChange = (row) => {
|
|
|
|
|
- ElMessage.success(`${row.name} ${row.status === 1 ? '已启用' : '已禁用'}`);
|
|
|
|
|
-};
|
|
|
|
|
|
|
+ const datasource = ({ page, limit, where, orders }) => {
|
|
|
|
|
+ return request.get('/shop/shopbook/getConditionTypeList').then(res => {
|
|
|
|
|
+ return res.data?.data || [];
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const columns = ref([
|
|
|
|
|
+ { label: '序号', type: 'index', width: 100, align: 'center' },
|
|
|
|
|
+ { label: '规格名称', prop: 'conditionName', align: 'center' },
|
|
|
|
|
+ { label: '规格值', prop: 'conditionValue', align: 'center' },
|
|
|
|
|
+ { label: '操作', prop: 'action', slot: 'action', align: 'center' },
|
|
|
|
|
+ { label: '是否启用', prop: 'status', slot: 'status', align: 'center' }
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ const reload = () => {
|
|
|
|
|
+ tableRef.value?.reload();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleAdd = () => {
|
|
|
|
|
+ editDialogRef.value?.handleOpen();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleEdit = (row) => {
|
|
|
|
|
+ editDialogRef.value?.handleOpen(row);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleSuccess = () => {
|
|
|
|
|
+ reload();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleStatusChange = (row) => {
|
|
|
|
|
+ const payload = {
|
|
|
|
|
+ ...row,
|
|
|
|
|
+ status: String(row.status)
|
|
|
|
|
+ };
|
|
|
|
|
+ request.post('/shop/shopbook/updateConditionType', payload).then(() => {
|
|
|
|
|
+ ElMessage.success(`${row.conditionName} ${row.status === '1' ? '已启用' : '已禁用'}`);
|
|
|
|
|
+ }).catch(() => {
|
|
|
|
|
+ // Revert status on error
|
|
|
|
|
+ row.status = row.status === '1' ? '0' : '1';
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped></style>
|
|
<style scoped></style>
|