新增手动和自动数据

v1.3.0
于肖磊 2025-03-14 15:51:32 +08:00
parent 1476ba18b9
commit 5e20a07b1f
3 changed files with 360 additions and 0 deletions

20
src/api/realstore.ts Normal file
View File

@ -0,0 +1,20 @@
import api_request from '@/utils/api-request';
class BlogAPI {
/** 博客自动数据 */
static getAutoList(data: any) {
return api_request({
url: `?s=plugins/index/pluginsname/realstore/pluginscontrol/diyrealstore/pluginsaction/autorealstorelist.html`,
method: 'post',
data,
});
}
}
export default BlogAPI;
// 分类树结构
export interface Tree {
/** 主键 */
id: string;
}

View File

@ -0,0 +1,170 @@
<template>
<!-- 商品分类 -->
<div class="container">
<div class="flex-row jc-e gap-20 mb-20">
<el-select v-model="category_ids" class="search-w" placeholder="请选择组合搭配类型" filterable clearable @change="handle_search">
<el-option v-for="item in article_category_list" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-input v-model="search_value" placeholder="请输入搜索内容" class="search-w" @change="handle_search">
<template #suffix>
<icon name="search" size="16" color="9" class="c-pointer" @click="handle_search"></icon>
</template>
</el-input>
</div>
<div class="content">
<el-table v-loading="loading" :data="tableData" class="w" :header-cell-style="{ background: '#f7f7f7' }" row-key="id" height="438" fixed @row-click="row_click" @select="handle_select" @select-all="handle_select">
<el-table-column v-if="multiple" type="selection" width="60" />
<el-table-column v-else label="#" width="60" type="">
<template #default="scope">
<el-radio v-model="template_selection" :label="scope.$index + ''">&nbsp;</el-radio>
</template>
</el-table-column>
<el-table-column prop="id" label="ID" width="80" type="" />
<el-table-column prop="logo" label="logo">
<template #default="scope">
<div class="flex-row align-c gap-10">
<image-empty v-if="scope.row.logo" v-model="scope.row.logo" class="img"></image-empty>
<!-- <div class="flex-1">{{ scope.row.title }}</div> -->
</div>
</template>
</el-table-column>
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="category_name" label="分类"></el-table-column>
<template #empty>
<no-data></no-data>
</template>
</el-table>
<div class="mt-10 flex-row jc-e">
<el-pagination :current-page="page" background :page-size="page_size" :pager-count="5" layout="prev, pager, next" :total="data_total" @current-change="get_list" />
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import UrlValueAPI from '@/api/url-value';
import { commonStore } from '@/store';
import { get_data_list } from '@/utils';
const common_store = commonStore();
const props = defineProps({
//
reset: {
type: Boolean,
default: () => false,
},
multiple: {
type: Boolean,
default: () => false,
},
//
selectIsUrl: {
type: Boolean,
default: false,
},
});
watch(
() => props.reset,
(val) => {
if (val) {
init();
}
}
);
onMounted(() => {
init();
});
const modelValue = defineModel({ type: Object, default: {} });
const tableData = ref<pageLinkList[]>([]);
const search_value = ref('');
const loading = ref(false);
const init = () => {
template_selection.value = '';
category_ids.value = '';
search_value.value = '';
article_category_list.value = get_data_list(common_store.common.plugins, 'realstore.category_list');
get_list(1);
};
const handle_search = () => {
get_list(1);
};
const category_ids = ref('');
interface articleCategory {
name: string;
id: string;
}
const article_category_list = ref<articleCategory[]>([]);
const template_selection = ref('');
//#region -----------------------------------------------start
//
const page = ref(1);
//
const page_size = ref(30);
//
const data_total = ref(0);
//
const get_list = (new_page: number) => {
let new_data = {
page: new_page,
keywords: search_value.value,
category_ids: category_ids.value,
page_size: page_size.value,
};
loading.value = true;
UrlValueAPI.getRealstoreList(new_data).then((res: any) => {
tableData.value = res.data?.data_list || [];
data_total.value = res.data?.data_total || 1;
page.value = res.data?.page || new_page;
setTimeout(() => {
loading.value = false;
}, 500);
});
};
//#region -----------------------------------------------end
const row_click = (row: any) => {
if (!props.multiple) {
const new_table_data = JSON.parse(JSON.stringify(tableData.value));
template_selection.value = new_table_data.findIndex((item: pageLinkList) => item.id == row.id).toString();
if (props.selectIsUrl) {
const page = 'pages/plugins/shop/detail/detail?id=' + row.id;
const new_row = {
id: row.id,
name: row.name || row.title || page,
page: page,
};
modelValue.value = [new_row];
} else {
modelValue.value = [row];
}
}
};
const handle_select = (selection: any) => {
if (props.selectIsUrl) {
// selection
const new_selection = selection.map((item: any) => {
const page = 'pages/plugins/shop/detail/detail?id=' + item.id;
return {
id: item.id,
name: item.name || item.title || page,
page: page,
};
});
modelValue.value = new_selection;
} else {
modelValue.value = selection;
}
};
</script>
<style lang="scss" scoped>
.container {
.search-w {
width: 22.5rem;
}
.content {
:deep(.el-table__inner-wrapper:before) {
background-color: transparent;
}
.img {
width: 3.6rem;
}
}
}
</style>

View File

@ -0,0 +1,170 @@
<template>
<!-- 商品分类 -->
<div class="container">
<div class="flex-row jc-e gap-20 mb-20">
<el-select v-model="category_ids" class="search-w" placeholder="请选择组合搭配类型" filterable clearable @change="handle_search">
<el-option v-for="item in article_category_list" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
<el-input v-model="search_value" placeholder="请输入搜索内容" class="search-w" @change="handle_search">
<template #suffix>
<icon name="search" size="16" color="9" class="c-pointer" @click="handle_search"></icon>
</template>
</el-input>
</div>
<div class="content">
<el-table v-loading="loading" :data="tableData" class="w" :header-cell-style="{ background: '#f7f7f7' }" row-key="id" height="438" fixed @row-click="row_click" @select="handle_select" @select-all="handle_select">
<el-table-column v-if="multiple" type="selection" width="60" />
<el-table-column v-else label="#" width="60" type="">
<template #default="scope">
<el-radio v-model="template_selection" :label="scope.$index + ''">&nbsp;</el-radio>
</template>
</el-table-column>
<el-table-column prop="id" label="ID" width="80" type="" />
<el-table-column prop="logo" label="logo">
<template #default="scope">
<div class="flex-row align-c gap-10">
<image-empty v-if="scope.row.logo" v-model="scope.row.logo" class="img"></image-empty>
<!-- <div class="flex-1">{{ scope.row.title }}</div> -->
</div>
</template>
</el-table-column>
<el-table-column prop="name" label="名称"></el-table-column>
<el-table-column prop="category_name" label="分类"></el-table-column>
<template #empty>
<no-data></no-data>
</template>
</el-table>
<div class="mt-10 flex-row jc-e">
<el-pagination :current-page="page" background :page-size="page_size" :pager-count="5" layout="prev, pager, next" :total="data_total" @current-change="get_list" />
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import UrlValueAPI from '@/api/url-value';
import { commonStore } from '@/store';
import { get_data_list } from '@/utils';
const common_store = commonStore();
const props = defineProps({
//
reset: {
type: Boolean,
default: () => false,
},
multiple: {
type: Boolean,
default: () => false,
},
//
selectIsUrl: {
type: Boolean,
default: false,
},
});
watch(
() => props.reset,
(val) => {
if (val) {
init();
}
}
);
onMounted(() => {
init();
});
const modelValue = defineModel({ type: Object, default: {} });
const tableData = ref<pageLinkList[]>([]);
const search_value = ref('');
const loading = ref(false);
const init = () => {
template_selection.value = '';
category_ids.value = '';
search_value.value = '';
article_category_list.value = get_data_list(common_store.common.plugins, 'shop.category_list');
get_list(1);
};
const handle_search = () => {
get_list(1);
};
const category_ids = ref('');
interface articleCategory {
name: string;
id: string;
}
const article_category_list = ref<articleCategory[]>([]);
const template_selection = ref('');
//#region -----------------------------------------------start
//
const page = ref(1);
//
const page_size = ref(30);
//
const data_total = ref(0);
//
const get_list = (new_page: number) => {
let new_data = {
page: new_page,
keywords: search_value.value,
category_ids: category_ids.value,
page_size: page_size.value,
};
loading.value = true;
UrlValueAPI.getShopList(new_data).then((res: any) => {
tableData.value = res.data?.data_list || [];
data_total.value = res.data?.data_total || 1;
page.value = res.data?.page || new_page;
setTimeout(() => {
loading.value = false;
}, 500);
});
};
//#region -----------------------------------------------end
const row_click = (row: any) => {
if (!props.multiple) {
const new_table_data = JSON.parse(JSON.stringify(tableData.value));
template_selection.value = new_table_data.findIndex((item: pageLinkList) => item.id == row.id).toString();
if (props.selectIsUrl) {
const page = 'pages/plugins/shop/detail/detail?id=' + row.id;
const new_row = {
id: row.id,
name: row.name || row.title || page,
page: page,
};
modelValue.value = [new_row];
} else {
modelValue.value = [row];
}
}
};
const handle_select = (selection: any) => {
if (props.selectIsUrl) {
// selection
const new_selection = selection.map((item: any) => {
const page = 'pages/plugins/shop/detail/detail?id=' + item.id;
return {
id: item.id,
name: item.name || item.title || page,
page: page,
};
});
modelValue.value = new_selection;
} else {
modelValue.value = selection;
}
};
</script>
<style lang="scss" scoped>
.container {
.search-w {
width: 22.5rem;
}
.content {
:deep(.el-table__inner-wrapper:before) {
background-color: transparent;
}
.img {
width: 3.6rem;
}
}
}
</style>