1.文章接口联调

sws 2024-08-21
v1.0.0
sws 2024-08-21 10:40:10 +08:00
parent cff877f15f
commit 7c009a421b
9 changed files with 131 additions and 90 deletions

View File

@ -14,7 +14,7 @@
<div class="mb-12">文章设置</div>
<el-form-item label="读取方式">
<el-radio-group v-model="form.article_check">
<el-radio v-for="item in base_list.article_list" :key="item.value" :value="item.value">{{ item.name }}</el-radio>
<el-radio v-for="item in base_list.get_data_method_list" :key="item.value" :value="item.value">{{ item.name }}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="form.article_check === '0'">
@ -39,8 +39,8 @@
</template>
<template v-else>
<el-form-item label="文章分类">
<el-select v-model="form.article_type" multiple collapse-tags placeholder="请选择文章分类">
<el-option v-for="item in base_list.article_type_list" :key="item.value" :label="item.name" :value="item.value" />
<el-select v-model="form.article_category" multiple collapse-tags placeholder="请选择文章分类">
<el-option v-for="item in base_list.article_category_list" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="显示数量">
@ -71,10 +71,14 @@
</card-container>
</div>
</el-form>
<url-value-dialog v-model:dialog-visible="url_value_dialog_visible" :type="['article']" multiple @update:model-value="url_value_dialog_call_back"></url-value-dialog>
</div>
</template>
<script setup lang="ts">
import { get_math } from '@/utils';
import ArticleAPI from '@/api/article';
import { articleStore } from '@/store/article';
const article_store = articleStore();
const props = defineProps({
value: {
type: Object,
@ -89,15 +93,11 @@ const base_list = reactive({
{ name: '大图展示', value: '2' },
{ name: '左右滑动展示', value: '3' },
],
article_list: [
get_data_method_list: [
{ name: '选择文章', value: '0' },
{ name: '筛选文章', value: '1' },
],
article_type_list: [
{ name: '样式一', value: '0' },
{ name: '样式二', value: '1' },
{ name: '样式三', value: '2' },
],
article_category_list: [] as select_1[],
sort_list: [
{ name: '综合', value: '0' },
{ name: '时间', value: '1' },
@ -112,6 +112,26 @@ const base_list = reactive({
{ name: '浏览量', value: '1' },
],
});
onMounted(() => {
init();
});
const init = () => {
//
if (!article_store.is_article_api) {
article_store.set_is_article_api(true);
ArticleAPI.getInit()
.then((res) => {
const { article_category_list } = res.data;
base_list.article_category_list = article_category_list;
article_store.set_article(article_category_list);
})
.catch((err) => {
article_store.set_is_article_api(false);
});
} else {
base_list.article_category_list = article_store.article;
}
};
const article_list_remove = (index: number) => {
form.article_list.splice(index, 1);
@ -120,11 +140,18 @@ const article_list_sort = (item: any) => {
form.article_list = item;
};
const add = () => {
form.article_list.push({
id: get_math(),
src: '',
new_url: [],
href: {},
url_value_dialog_visible.value = true;
};
//
const url_value_dialog_visible = ref(false);
const url_value_dialog_call_back = (item: any[]) => {
item.forEach((child: any) => {
form.article_list.push({
id: get_math(),
src: '',
new_url: [],
link: child,
});
});
};
</script>

View File

@ -32,7 +32,7 @@
</el-form-item>
<el-form-item label="读取方式">
<el-radio-group v-model="row.article_check">
<el-radio v-for="item in base_list.article_list" :key="item.value + get_math()" :value="item.value">{{ item.name }}</el-radio>
<el-radio v-for="item in base_list.get_data_method_list" :key="item.value + get_math()" :value="item.value">{{ item.name }}</el-radio>
</el-radio-group>
</el-form-item>
<template v-if="row.article_check === '0'">
@ -55,8 +55,8 @@
</template>
<template v-else>
<el-form-item label="文章分类">
<el-select v-model="row.article_type" multiple collapse-tags placeholder="请选择文章分类">
<el-option v-for="item in base_list.article_type_list" :key="item.value" :label="item.name" :value="item.value" />
<el-select v-model="row.article_category" multiple collapse-tags placeholder="请选择文章分类">
<el-option v-for="item in base_list.article_category_list" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="显示数量">
@ -92,13 +92,14 @@
</el-form-item>
</card-container>
</el-form>
<url-value-dialog v-model:dialog-visible="urlValueDialogVisible" :type="['article']" multiple @update:model-value="url_value_dialog_call_back"></url-value-dialog>
<url-value-dialog v-model:dialog-visible="url_value_dialog_visible" :type="['article']" multiple @update:model-value="url_value_dialog_call_back"></url-value-dialog>
</div>
</template>
<script setup lang="ts">
import { get_math } from '@/utils';
import ArticleAPI from '@/api/article';
import { articleStore } from '@/store/article';
const article_store = articleStore();
const props = defineProps({
value: {
type: Object,
@ -119,15 +120,11 @@ const base_list = reactive({
{ name: '大图展示', value: '2' },
{ name: '左右滑动展示', value: '3' },
],
article_list: [
get_data_method_list: [
{ name: '选择文章', value: '0' },
{ name: '筛选文章', value: '1' },
],
article_type_list: [
{ name: '样式一', value: '0' },
{ name: '样式二', value: '1' },
{ name: '样式三', value: '2' },
],
article_category_list: [] as select_1[],
sort_list: [
{ name: '综合', value: '0' },
{ name: '时间', value: '1' },
@ -142,8 +139,29 @@ const base_list = reactive({
{ name: '浏览量', value: '1' },
],
});
onMounted(() => {
init();
});
const init = () => {
//
if (!article_store.is_article_api) {
article_store.set_is_article_api(true);
ArticleAPI.getInit()
.then((res) => {
const { article_category_list } = res.data;
base_list.article_category_list = article_category_list;
article_store.set_article(article_category_list);
})
.catch((err) => {
article_store.set_is_article_api(false);
});
} else {
base_list.article_category_list = article_store.article;
}
};
//
const urlValueDialogVisible = ref(false);
const url_value_dialog_visible = ref(false);
const active_index = ref(0);
const tabs_list_click = (item: any, index: number) => {
active_index.value = index;
@ -154,7 +172,7 @@ const tabs_list_remove = (index: number) => {
};
const tabs_list_sort = (item: any) => {
//
form.tabs_list = item.value;
form.tabs_list = item;
};
const tabs_add = () => {
form.tabs_list.push({
@ -177,12 +195,12 @@ const article_list_remove = (index: number) => {
form.tabs_list[active_index.value].article_list.splice(index, 1);
};
const article_list_sort = (item: any) => {
// emit('update:value', item);
form.tabs_list[active_index.value].article_list = item;
};
const article_index = ref(0);
const article_add = (index: number) => {
urlValueDialogVisible.value = true;
url_value_dialog_visible.value = true;
article_index.value = index;
};
const url_value_dialog_call_back = (item: any[]) => {

View File

@ -74,10 +74,6 @@ import { get_math } from '@/utils';
import ShopAPI from '@/api/shop';
import { shopStore } from '@/store';
const shop_store = shopStore();
interface shop_list {
id: number;
name: string;
};
const props = defineProps({
value: {
@ -104,8 +100,8 @@ const base_list = reactive({
{ name: '指定商品', value: '0' },
{ name: '筛选商品', value: '1' },
],
product_category_list: [] as shop_list[],
product_brand_list: [] as shop_list[],
product_category_list: [] as select_1[],
product_brand_list: [] as select_1[],
sort_list: [
{ name: '综合', value: '0' },
{ name: '销量', value: '1' },
@ -116,26 +112,30 @@ const base_list = reactive({
sort_rules_list: [
{ name: '降序(desc)', value: '0' },
{ name: '升序(asc)', value: '1' },
]
],
});
const init = () => {
ShopAPI.getShop().then((res) => {
const { goods_category, brand_list } = res.data;
base_list.product_category_list = goods_category;
base_list.product_brand_list = brand_list;
shop_store.set_category_brand(goods_category, brand_list);
});
};
onBeforeMount(() => {
if (!shop_store.is_shop_api) {
shop_store.set_is_shop_api(true);
init();
ShopAPI.getShop()
.then((res) => {
const { goods_category, brand_list } = res.data;
base_list.product_category_list = goods_category;
base_list.product_brand_list = brand_list;
shop_store.set_category_brand(goods_category, brand_list);
})
.catch((err) => {
shop_store.set_is_shop_api(false);
});
} else {
base_list.product_category_list = shop_store.category_list;
base_list.product_brand_list = shop_store.brand_list;
}
};
onBeforeMount(() => {
init();
});
const product_list_remove = (index: number) => {
@ -152,8 +152,8 @@ const add = () => {
//
const product_list_sort = (new_list: any) => {
form.value.product_list = new_list;
}
const change_style = (val: any):void => {
};
const change_style = (val: any): void => {
form.value.product_style = val;
if (['3', '4', '5'].includes(val) && ['0', '1'].includes(form.value.shop_type)) {
form.value.shop_type = '2';
@ -170,7 +170,8 @@ const change_style = (val: any):void => {
}
}
}
.card, .card.mb-8 {
.card,
.card.mb-8 {
.el-form-item:last-child {
margin-bottom: 0;
}

View File

@ -98,10 +98,6 @@ import { get_math } from '@/utils';
import ShopAPI from '@/api/shop';
import { shopStore } from '@/store';
const shop_store = shopStore();
interface shop_list {
id: number;
name: string;
};
const props = defineProps({
value: {
@ -136,8 +132,8 @@ const base_list = reactive({
{ name: '指定商品', value: '0' },
{ name: '选择商品', value: '1' },
],
product_category_list: [] as shop_list[],
product_brand_list: [] as shop_list[],
product_category_list: [] as select_1[],
product_brand_list: [] as select_1[],
sort_list: [
{ name: '综合', value: '0' },
{ name: '销量', value: '1' },
@ -156,23 +152,27 @@ const base_list = reactive({
});
//
const init = () => {
ShopAPI.getShop().then((res) => {
const { goods_category, brand_list } = res.data;
base_list.product_category_list = goods_category;
base_list.product_brand_list = brand_list;
shop_store.set_category_brand(goods_category, brand_list);
});
};
onBeforeMount(() => {
//
if (!shop_store.is_shop_api) {
shop_store.set_is_shop_api(true);
init();
ShopAPI.getShop()
.then((res) => {
const { goods_category, brand_list } = res.data;
base_list.product_category_list = goods_category;
base_list.product_brand_list = brand_list;
shop_store.set_category_brand(goods_category, brand_list);
})
.catch((err) => {
shop_store.set_is_shop_api(false);
});
} else {
base_list.product_category_list = shop_store.category_list;
base_list.product_brand_list = shop_store.brand_list;
}
};
onBeforeMount(() => {
init();
});
const active_index = ref(0);

View File

@ -10,7 +10,7 @@ interface DefaultArticleList {
content: {
article_style: string;
article_check: string;
article_type: string[];
article_category: string[];
article_list: ArticleList[];
number: number;
sort: string;
@ -41,7 +41,7 @@ const defaultArticleList: DefaultArticleList = {
article_style: '1',
article_check: '0',
article_list: [],
article_type: [],
article_category: [],
number: 4,
sort: '0',
sort_rules: '0',

View File

@ -10,7 +10,7 @@ interface articleTabsList {
title: string;
desc: string;
article_check: string;
article_type: string[];
article_category: string[];
number: number;
sort: string;
sort_rules: string;
@ -58,12 +58,12 @@ const defaultArticleTabs: DefaultArticleTabs = {
tabs_top_up: true,
article_style: '0',
tabs_list: [
{ id: '1', title: '热门推荐', desc: '简介', article_check: '0', article_type: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '2', title: '测试一', desc: '简介', article_check: '0', article_type: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '3', title: '测试二', desc: '简介', article_check: '0', article_type: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '4', title: '测试三', desc: '简介', article_check: '0', article_type: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '5', title: '测试四', desc: '简介', article_check: '0', article_type: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '6', title: '测试五', desc: '简介', article_check: '0', article_type: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '1', title: '热门推荐', desc: '简介', article_check: '0', article_category: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '2', title: '测试一', desc: '简介', article_check: '0', article_category: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '3', title: '测试二', desc: '简介', article_check: '0', article_category: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '4', title: '测试三', desc: '简介', article_check: '0', article_category: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '5', title: '测试四', desc: '简介', article_check: '0', article_category: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
{ id: '6', title: '测试五', desc: '简介', article_check: '0', article_category: [], number: 4, sort: '0', sort_rules: '0', is_img_show: true, article_list: [] },
],
is_show: ['0', '1'],
},

View File

@ -1,12 +1,12 @@
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const articleStore = defineStore('article', () => {
// 链接是否需要调接口判断
// 文章是否需要调接口判断
const is_article_api = ref(false);
// 链接数据
const article = ref<article_list[]>([]);
// 存储链接数据
const set_article = (data: article_list[]) => {
// 文章数据
const article = ref<select_1[]>([]);
// 存储文章数据
const set_article = (data: select_1[]) => {
article.value = data;
is_article_api.value = true;
};
@ -22,8 +22,3 @@ export const articleStore = defineStore('article', () => {
set_is_article_api,
};
});
interface article_list {
id: number;
name: string;
url?: string;
}

View File

@ -2,18 +2,14 @@ import { ref } from 'vue';
import { defineStore } from 'pinia';
export const shopStore = defineStore('shop', () => {
interface product_list {
id: number;
name: string;
};
// 上传是否需要调接口判断
const is_shop_api = ref(false);
// 上传分类列表
const category_list = ref<product_list[]>([]);
const category_list = ref<select_1[]>([]);
// 上传品牌列表
const brand_list = ref<product_list[]>([]);
const brand_list = ref<select_1[]>([]);
// 存储上传分类列表
const set_category_brand = (category: product_list[], brand: product_list[]) => {
const set_category_brand = (category: select_1[], brand: select_1[]) => {
category_list.value = category;
brand_list.value = brand;
is_shop_api.value = true;

View File

@ -3,6 +3,10 @@ declare global {
interface arrayIndex {
[key: string]: any;
}
interface select_1 {
id: string | number;
name: string;
}
// 可视化数据
interface commonComponentData {
src: string;