Merge branch 'dev-sws' into dev-yxl

v1.0.0
于肖磊 2024-08-21 13:41:16 +08:00
commit 283d5cd788
13 changed files with 217 additions and 125 deletions

35
src/api/article.ts Normal file
View File

@ -0,0 +1,35 @@
import request from '@/utils/request';
class ArticleAPI {
/** 链接初始化接口 */
static getInit() {
return request({
url: `diyapi/linkinit`,
method: 'post',
});
}
/** 文章指定数据 */
static getAppointList(data: any) {
return request({
url: `diyapi/articleappointdata`,
method: 'post',
data,
});
}
/** 文章自动数据 */
static getAutoList(data: any) {
return request({
url: `diyapi/articleautodata`,
method: 'post',
data,
});
}
}
export default ArticleAPI;
// 分类树结构
export interface Tree {
/** 主键 */
id: string;
}

View File

@ -357,7 +357,7 @@ const add_event = () => {
//#region -----------------------------------------------start
const hot_dialog_visible = ref(false);
interface formData {
link: linkData;
link: pageLinkList;
name: string;
}
const form = ref<formData>({

View File

@ -62,7 +62,7 @@
</template>
<script lang="ts" setup>
import type { FormInstance, FormRules } from 'element-plus';
import { urlValueStore, urlValue, pageLinkList } from '@/store';
import { urlValueStore } from '@/store';
const url_value_store = urlValueStore();
const props = defineProps({
status: {
@ -188,7 +188,7 @@ const on_submit = () => {
if (!ruleFormRef.value) return;
ruleFormRef.value.validate((valid: boolean) => {
if (valid) {
let new_value: linkData = {
let new_value: pageLinkList = {
name: form.key,
link: form.key,
};

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'">
@ -22,16 +22,14 @@
<drag :data="form.article_list" :space-col="20" @remove="article_list_remove" @on-sort="article_list_sort">
<template #default="{ row }">
<upload v-model="row.new_url" :limit="1" size="40" styles="2"></upload>
<el-image :src="row.url" fit="contain" class="img">
<el-image :src="row.link.cover" fit="contain" class="img">
<template #error>
<div class="bg-f5 flex-row jc-c align-c radius h w">
<icon name="error-img" size="16" color="9"></icon>
</div>
</template>
</el-image>
<div class="flex-1 flex-width">
<url-value v-model="row.link"></url-value>
</div>
<div class="flex-1 flex-width text-line-2 size-12 self-s">{{ row.link.title }}</div>
</template>
</drag>
<el-button class="mtb-20 w" @click="add">+</el-button>
@ -39,8 +37,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 +69,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 +91,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 +110,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: any) => {
const { article_category_list } = res.data;
base_list.article_category_list = article_category_list;
article_store.set_article(article_category_list);
})
.catch((err: any) => {
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 +138,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,11 +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,
@ -117,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' },
@ -140,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: any) => {
const { article_category_list } = res.data;
base_list.article_category_list = article_category_list;
article_store.set_article(article_category_list);
})
.catch((err: any) => {
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;
@ -152,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({
@ -175,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

@ -72,12 +72,8 @@
<script setup lang="ts">
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;
};
import { shopStore } from '@/store';
const shop_store = shopStore();
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

@ -96,12 +96,8 @@
<script setup lang="ts">
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;
};
import { shopStore } from '@/store';
const shop_store = shopStore();
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'],
},

24
src/store/article.ts Normal file
View File

@ -0,0 +1,24 @@
import { ref, computed } from 'vue';
import { defineStore } from 'pinia';
export const articleStore = defineStore('article', () => {
// 文章是否需要调接口判断
const is_article_api = ref(false);
// 文章数据
const article = ref<select_1[]>([]);
// 存储文章数据
const set_article = (data: select_1[]) => {
article.value = data;
is_article_api.value = true;
};
// 如果为false 则转为true
const set_is_article_api = (bool: boolean) => {
is_article_api.value = bool;
};
return {
article,
is_article_api,
set_article,
set_is_article_api,
};
});

View File

@ -1,19 +1,15 @@
import { ref } from 'vue';
import { defineStore } from 'pinia';
export const ShopStore = defineStore('shop', () => {
interface product_list {
id: number;
name: string;
};
export const shopStore = defineStore('shop', () => {
// 上传是否需要调接口判断
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

@ -28,27 +28,3 @@ export const urlValueStore = defineStore('urlValue', () => {
set_is_url_value_api,
};
});
export interface pageLinkList {
id?: string;
name: string;
type?: string;
page?: string;
data?: pageLinkList[];
items?: pageLinkList[];
icon?: string;
link?: string;
lng?: number;
lat?: number;
hasChildren?: boolean;
children?: pageLinkList[];
}
// 分类树结构
export interface urlValue {
goods_category: any[];
brand_list: any[];
brand_category: any[];
article_category_list: any[];
page_link_list: pageLinkList[];
}

33
src/types/global.d.ts vendored
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;
@ -53,7 +57,7 @@ declare global {
box_shadow_spread: number;
};
// 图片/视频/文件的数据类型
export interface uploadList {
type uploadList = {
id?: number;
url: string;
original?: string;
@ -62,7 +66,7 @@ declare global {
size?: number;
type?: string;
error?: boolean;
}
};
/**
*
*/
@ -100,20 +104,31 @@ declare global {
box_shadow_spread: number;
background_img_url: uploadList[];
};
/**
*
*/
type linkData = {
id?: number;
type pageLinkList = {
id?: string;
name?: string;
link?: String;
data?: Data[];
type?: string;
page?: string;
data?: pageLinkList[];
items?: pageLinkList[];
icon?: string;
link?: string;
lng?: number;
lat?: number;
hasChildren?: boolean;
children?: linkData[];
children?: pageLinkList[];
};
// 分类树结构
type urlValue = {
goods_category: any[];
brand_list: any[];
brand_category: any[];
article_category_list: any[];
page_link_list: pageLinkList[];
};
/**
@ -135,7 +150,7 @@ declare global {
drag_start: rectCoords;
drag_end: rectCoords;
name: string;
link: linkData;
link: pageLinkList;
};
}
export {};