Merge branch 'dev-sws'
commit
298a21a1f8
|
|
@ -1,23 +0,0 @@
|
|||
/**
|
||||
* 登录请求参数
|
||||
*/
|
||||
export interface LoginData {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
username: string;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
password: string;
|
||||
|
||||
/**
|
||||
* 验证码缓存key
|
||||
*/
|
||||
// verifyCodeKey?: string;
|
||||
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
// verifyCode?: string;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
import request from '@/utils/request';
|
||||
|
||||
class UrlValueAPI {
|
||||
/** 链接初始化接口 */
|
||||
static getInit() {
|
||||
return request({
|
||||
url: `diyapi/linkinit`,
|
||||
method: 'post',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export default UrlValueAPI;
|
||||
|
||||
// 分类树结构
|
||||
export interface Tree {
|
||||
/** 主键 */
|
||||
id: string;
|
||||
/** 父级id */
|
||||
pid: string;
|
||||
/** 名称 */
|
||||
name: string;
|
||||
/** 路径 */
|
||||
path: string;
|
||||
/** 是否开启 */
|
||||
is_enable: Number;
|
||||
/** 排序 */
|
||||
sort: number;
|
||||
/** 下级 */
|
||||
items?: Tree[];
|
||||
/** 图标 */
|
||||
icon?: string;
|
||||
}
|
||||
|
|
@ -249,8 +249,7 @@ watch(
|
|||
() => dialog_visible.value,
|
||||
(val) => {
|
||||
if (val) {
|
||||
type_data_list.value = upload_store.category;
|
||||
type_data.value = [all_tree, ...upload_store.category];
|
||||
get_tree();
|
||||
get_attachment_list();
|
||||
}
|
||||
}
|
||||
|
|
@ -304,13 +303,22 @@ const all_tree = {
|
|||
const type_data_list = ref<Tree[]>([]);
|
||||
// 查询分类列表
|
||||
const get_tree = () => {
|
||||
UploadAPI.getTree().then((res) => {
|
||||
// 将all_tree和res.data.category_list全部插入到type_data.value,all_tree放在数组最前面
|
||||
type_data.value = [all_tree, ...res.data.category_list];
|
||||
type_data_list.value = res.data.category_list;
|
||||
upload_store.set_category(type_data_list.value);
|
||||
if (!upload_store.is_upload_api) {
|
||||
upload_store.set_is_upload_api(true);
|
||||
});
|
||||
UploadAPI.getTree()
|
||||
.then((res) => {
|
||||
// 将all_tree和res.data.category_list全部插入到type_data.value,all_tree放在数组最前面
|
||||
type_data.value = [all_tree, ...res.data.category_list];
|
||||
type_data_list.value = res.data.category_list;
|
||||
upload_store.set_category(type_data_list.value);
|
||||
})
|
||||
.catch(() => {
|
||||
upload_store.set_is_upload_api(false);
|
||||
});
|
||||
} else {
|
||||
type_data_list.value = upload_store.category;
|
||||
type_data.value = [all_tree, ...upload_store.category];
|
||||
}
|
||||
};
|
||||
|
||||
// 分类弹窗表单数据
|
||||
|
|
@ -588,11 +596,7 @@ const close_upload_model = (data: any) => {
|
|||
onMounted(() => {
|
||||
// 监听点击事件
|
||||
document.addEventListener('click', video_show);
|
||||
if (!upload_store.is_upload_api) {
|
||||
get_tree();
|
||||
} else {
|
||||
type_data.value = upload_store.category;
|
||||
}
|
||||
get_tree();
|
||||
});
|
||||
onUnmounted(() => {
|
||||
// 移除监听事件
|
||||
|
|
|
|||
|
|
@ -1,230 +0,0 @@
|
|||
<!-- 上传组件 -->
|
||||
<template>
|
||||
<el-dialog v-model="dialogVisible" class="radius-lg" width="1168" append-to-body @close="close_event">
|
||||
<template #header>
|
||||
<div class="title center re">
|
||||
<div class="tc size-16 fw">选择链接</div>
|
||||
</div>
|
||||
</template>
|
||||
<div class="url-value-content pa-20 flex-row">
|
||||
<div class="left-content">
|
||||
<el-menu :default-active="link_select" class="w br-none" @select="handle_select">
|
||||
<el-menu-item v-for="item in base_data" :key="item.type" :index="item.type" :disabled="!(custom_link_type.length == 0 || custom_link_type.includes(item.type))">
|
||||
<span>{{ item.name }}</span>
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
</div>
|
||||
<div class="right-content flex-1">
|
||||
<template v-if="link_select == 'shop'">
|
||||
<link-list v-model="link_value" :reset="reset_compontent"></link-list>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'goods-category'">
|
||||
<link-goods-category v-model="link_value" :reset="reset_compontent"></link-goods-category>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'goods-search'">
|
||||
<link-goods-search :reset="reset_compontent" :status="component_status" @update:link="goods_category_link" @type="goods_category_type_change" @required="required_tips"></link-goods-search>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'goods'">
|
||||
<link-goods v-model="link_value" :reset="reset_compontent"></link-goods>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'articles'">
|
||||
<link-articles v-model="link_value" :reset="reset_compontent"></link-articles>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'diy'">
|
||||
<link-table v-model="link_value" :reset="reset_compontent"></link-table>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'design'">
|
||||
<link-table v-model="link_value" :reset="reset_compontent"></link-table>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'custom-view'">
|
||||
<link-table v-model="link_value" :reset="reset_compontent"></link-table>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'custom'">
|
||||
<link-custom :reset="reset_compontent" :status="component_status" @update:link="custom_link" @required="required_tips"></link-custom>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'plugins'">
|
||||
<link-list v-model="link_value" :reset="reset_compontent"></link-list>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span class="dialog-footer">
|
||||
<el-button class="plr-28 ptb-10" @click="close_event">取消</el-button>
|
||||
<el-button class="plr-28 ptb-10" type="primary" @click="confirm_event">确定</el-button>
|
||||
</span>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<div class="flex-row align-c gap-10 br-d radius-sm plr-11 url-value-input" @click="dialogVisible = true">
|
||||
<div class="flex-1 flex-width size-12 text-line-1">
|
||||
<text v-if="!is_obj_empty(modelValue)">{{ modelValue.name }}</text>
|
||||
<text v-else class="cr-9">{{ placeholder }}</text>
|
||||
</div>
|
||||
<div class="value-input-icon">
|
||||
<template v-if="is_obj_empty(modelValue)">
|
||||
<icon name="arrow-right" size="12" color="9"></icon>
|
||||
</template>
|
||||
<template v-else>
|
||||
<div @click.stop="clear_model_value">
|
||||
<icon name="close-o" size="12" color="c"></icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { MenuItemClicked } from 'element-plus/es/components/menu/src/types';
|
||||
import { is_obj_empty } from '@/utils';
|
||||
import { PropType } from 'vue';
|
||||
|
||||
const app = getCurrentInstance();
|
||||
/**
|
||||
* @description: 页面链接
|
||||
* @param modelValue{Object} 默认值
|
||||
* @param dialogVisible {Boolean} 弹窗显示
|
||||
* @param type{String} 链接类型为空数组则表示无限制,全部可用,传过来则表示传的值可用
|
||||
* @param placeholder{String} 提示文字
|
||||
* @return {*} update:modelValue
|
||||
*/
|
||||
const props = defineProps({
|
||||
type: {
|
||||
type: Array as PropType<string[]>,
|
||||
default: () => [],
|
||||
},
|
||||
placeholder: {
|
||||
type: String,
|
||||
default: '请选择链接',
|
||||
},
|
||||
});
|
||||
const modelValue = defineModel({ type: Object, default: {} });
|
||||
const dialogVisible = defineModel('visibleDialog', { type: Boolean, default: false });
|
||||
const link_value = ref({});
|
||||
const reset_compontent = ref(false);
|
||||
const custom_link_type = ref(props.type);
|
||||
const base_data = reactive([
|
||||
{
|
||||
name: '商城页面',
|
||||
type: 'shop',
|
||||
data: [{ name: '基础链接', data: [{ name: '', page: '' }] }],
|
||||
},
|
||||
{
|
||||
name: '商品分类',
|
||||
type: 'goods-category',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '商品搜索',
|
||||
type: 'goods-search',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '商品页面',
|
||||
type: 'goods',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '文章页面',
|
||||
type: 'articles',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: 'DIY页面',
|
||||
type: 'diy',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '页面设计',
|
||||
type: 'design',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '自定义页面',
|
||||
type: 'custom-view',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '自定义链接',
|
||||
type: 'custom',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '插件',
|
||||
type: 'plugins',
|
||||
data: [{ name: '多商户', data: [{ name: '1', page: '2' }] }],
|
||||
},
|
||||
]);
|
||||
// 弹窗显示
|
||||
|
||||
//#region 链接回调 -----------------------------------------------start
|
||||
// 菜单选中回调
|
||||
const link_select = ref(props.type.length == 0 ? 'shop' : props.type[0]);
|
||||
const handle_select = (index: string, indexPath: string[], item: MenuItemClicked, routeResult: any) => {
|
||||
// console.log(index, indexPath, item, routeResult);
|
||||
link_select.value = index;
|
||||
};
|
||||
//#endregion 链接回调 -----------------------------------------------end
|
||||
|
||||
//@region 子组件回调 -----------------------------------------------start
|
||||
const component_status = ref(false);
|
||||
// 商品分类选中回调
|
||||
const goods_category_type = ref(0);
|
||||
const goods_category_type_change = (type: number) => {
|
||||
goods_category_type.value = type;
|
||||
};
|
||||
const goods_category_link = (data: object, type: number) => {
|
||||
if (type == 2) {
|
||||
modelValue.value = data;
|
||||
close_event();
|
||||
} else {
|
||||
link_value.value = data;
|
||||
}
|
||||
};
|
||||
// 自定义地址回调
|
||||
const custom_link = (data: object) => {
|
||||
modelValue.value = data;
|
||||
close_event();
|
||||
};
|
||||
// 错误回调
|
||||
const required_tips = () => {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '必填项不能为空',
|
||||
});
|
||||
};
|
||||
//#endregion 子组件回调 -----------------------------------------------end
|
||||
|
||||
//#region 链接确认回调 -----------------------------------------------start
|
||||
// 取消回调
|
||||
const close_event = () => {
|
||||
link_select.value = props.type.length == 0 ? 'shop' : props.type[0];
|
||||
dialogVisible.value = false;
|
||||
link_value.value = {};
|
||||
reset_compontent.value = !reset_compontent.value;
|
||||
};
|
||||
// 确认回调
|
||||
const confirm_event = () => {
|
||||
// 判断是否是自定义页面和商品查询
|
||||
if (link_select.value == 'custom' || (link_select.value == 'goods-search' && goods_category_type.value == 2)) {
|
||||
component_status.value = !component_status.value;
|
||||
} else {
|
||||
if (is_obj_empty(link_value.value)) {
|
||||
ElMessage({
|
||||
type: 'warning',
|
||||
message: '请先选择链接',
|
||||
});
|
||||
} else {
|
||||
modelValue.value = link_value.value;
|
||||
close_event();
|
||||
}
|
||||
}
|
||||
};
|
||||
//#endregion 链接确认回调 -----------------------------------------------end
|
||||
|
||||
//#endregion 链接清空-------------------------------------------------start
|
||||
const clear_model_value = () => {
|
||||
modelValue.value = {};
|
||||
};
|
||||
//#endregion 链接清空-------------------------------------------------end
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import 'index.scss';
|
||||
</style>
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { is_obj_empty } from '@/utils';
|
||||
|
||||
const app = getCurrentInstance();
|
||||
/**
|
||||
* @description: 页面链接
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
<div class="search">
|
||||
<el-input v-model="search_value" placeholder="请输入搜索内容" class="" @change="handle_search">
|
||||
<template #suffix>
|
||||
<icon name="search" size="16" color="9"></icon>
|
||||
<icon name="search" size="16" color="9" class="c-pointer" @click="handle_search"></icon>
|
||||
</template>
|
||||
</el-input>
|
||||
</div>
|
||||
|
|
@ -13,10 +13,10 @@
|
|||
<div class="content">
|
||||
<el-scrollbar height="480px">
|
||||
<div class="flex-col gap-30">
|
||||
<div v-for="item in base_data" :key="item.id">
|
||||
<div v-for="item in new_base_data" :key="item.type">
|
||||
<div class="fw mb-15">{{ item.name }}</div>
|
||||
<div class="flex-row flex-wrap gap-15">
|
||||
<div v-for="child in item.data" :key="child.id" class="item" :class="menu_active == item.id + '-' + child.id ? 'active' : ''" @click="menu_link_event(child, item.id)">{{ child.name }}</div>
|
||||
<div v-for="(child, index) in item.data" :key="index" class="item" :class="menu_active == item.page ? 'active' : ''" @click="menu_link_event(child)">{{ child.name }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -25,6 +25,8 @@
|
|||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { urlValueStore, urlValue } from '@/store';
|
||||
const url_value_store = urlValueStore();
|
||||
const props = defineProps({
|
||||
// 重置
|
||||
reset: {
|
||||
|
|
@ -40,67 +42,44 @@ watch(
|
|||
);
|
||||
const modelValue = defineModel({ type: Object, default: {} });
|
||||
const search_value = ref('');
|
||||
const base_data = ref<linkData[]>([
|
||||
{
|
||||
id: 0,
|
||||
name: '基础链接',
|
||||
data: [
|
||||
{ id: 0, name: '首页', link: '首页' },
|
||||
{ id: 1, name: '商城分类', link: '商城分类' },
|
||||
{ id: 2, name: '购物车', link: '购物车' },
|
||||
{ id: 3, name: '分类商品列表', link: '分类商品列表' },
|
||||
{ id: 4, name: '退款列表', link: '退款列表' },
|
||||
{ id: 5, name: '我的订单', link: '我的订单' },
|
||||
{ id: 6, name: '文章列表', link: '文章列表' },
|
||||
{ id: 7, name: '供应商入驻', link: '供应商入驻' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: '个人中心',
|
||||
data: [
|
||||
{ id: 0, name: '付费会员', link: '付费会员' },
|
||||
{ id: 1, name: '收银页面', link: '收银页面' },
|
||||
{ id: 2, name: '我的订单', link: '我的订单' },
|
||||
{ id: 3, name: '我的收藏', link: '我的收藏' },
|
||||
{ id: 4, name: '我的地址', link: '我的地址' },
|
||||
{ id: 5, name: '我的优惠券', link: '我的优惠券' },
|
||||
{ id: 6, name: '我的消息', link: '我的消息' },
|
||||
{ id: 7, name: '我的资料', link: '我的资料' },
|
||||
{ id: 8, name: '我的积分', link: '我的积分' },
|
||||
{ id: 9, name: '我的余额', link: '我的余额' },
|
||||
{ id: 10, name: '我的红包', link: '我的红包' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: '分销',
|
||||
data: [
|
||||
{ id: 0, name: '分销中心', link: '分销中心' },
|
||||
{ id: 1, name: '分销订单', link: '分销订单' },
|
||||
{ id: 2, name: '分销商品', link: '分销商品' },
|
||||
{ id: 3, name: '分销提现', link: '分销提现' },
|
||||
{ id: 4, name: '分销佣金', link: '分销佣金' },
|
||||
{ id: 5, name: '分销设置', link: '分销设置' },
|
||||
{ id: 6, name: '分销关系', link: '分销关系' },
|
||||
{ id: 7, name: '分销商列表', link: '分销商列表' },
|
||||
{ id: 8, name: '分销商等级', link: '分销商等级' },
|
||||
{ id: 9, name: '分销商统计', link: '分销商统计' },
|
||||
{ id: 10, name: '分销商提现', link: '分销商提现' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
const base_data = computed(() => {
|
||||
// 过滤url_value_store.url_value.page_link_list中的type为shop的data的数据,只保留data数组
|
||||
return url_value_store.url_value.page_link_list.filter((item: any) => {
|
||||
if (item.type == 'shop') {
|
||||
return item.data;
|
||||
}
|
||||
});
|
||||
});
|
||||
const new_base_data = computed(() => {
|
||||
// 过滤url_value_store.url_value.page_link_list中的type为shop的data的数据,只保留data数组
|
||||
return base_data.value[0].data;
|
||||
});
|
||||
const handle_search = () => {
|
||||
console.log(search_value.value);
|
||||
// 根据关键词过滤new_base_data数据
|
||||
new_base_data.value.filter((item: any) => {
|
||||
if (item.data) {
|
||||
return item.data.filter((item: any) => {
|
||||
if (item.name.includes(search_value.value)) {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return item.filter((item: any) => {
|
||||
if (item.name.includes(search_value.value)) {
|
||||
return item;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
const menu_active = ref('');
|
||||
const emit = defineEmits(['update:link']);
|
||||
const menu_link_event = (item: linkData, parent_id: number | undefined) => {
|
||||
if (`${parent_id}-${item.id}` == menu_active.value) {
|
||||
const menu_link_event = (item: any) => {
|
||||
if (item.page == menu_active.value) {
|
||||
menu_active.value = '';
|
||||
modelValue.value = {};
|
||||
} else {
|
||||
menu_active.value = `${parent_id}-${item.id}`;
|
||||
menu_active.value = item.page;
|
||||
modelValue.value = item;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
</el-menu>
|
||||
</div>
|
||||
<div class="right-content flex-1">
|
||||
<template v-if="link_select == 'shop'">
|
||||
<template v-if="link_select == 'shop' || link_select == 'plugins'">
|
||||
<link-list v-model="link_value" :reset="reset_compontent"></link-list>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'goods-category'">
|
||||
|
|
@ -29,21 +29,12 @@
|
|||
<template v-else-if="link_select == 'articles'">
|
||||
<link-articles v-model="link_value" :reset="reset_compontent"></link-articles>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'diy'">
|
||||
<link-table v-model="link_value" :reset="reset_compontent"></link-table>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'design'">
|
||||
<link-table v-model="link_value" :reset="reset_compontent"></link-table>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'custom-view'">
|
||||
<template v-else-if="link_select == 'diy' || link_select == 'design' || link_select == 'custom-view'">
|
||||
<link-table v-model="link_value" :reset="reset_compontent"></link-table>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'custom'">
|
||||
<link-custom :reset="reset_compontent" :status="component_status" @update:link="custom_link" @required="required_tips"></link-custom>
|
||||
</template>
|
||||
<template v-else-if="link_select == 'plugins'">
|
||||
<link-list v-model="link_value" :reset="reset_compontent"></link-list>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
|
|
@ -59,14 +50,15 @@
|
|||
import { MenuItemClicked } from 'element-plus/es/components/menu/src/types';
|
||||
import { is_obj_empty } from '@/utils';
|
||||
import { PropType } from 'vue';
|
||||
|
||||
import UrlValueAPI from '@/api/url-value';
|
||||
import { urlValueStore, urlValue } from '@/store';
|
||||
const url_value_store = urlValueStore();
|
||||
const app = getCurrentInstance();
|
||||
/**
|
||||
* @description: 页面链接
|
||||
* @param modelValue{Object} 默认值
|
||||
* @param dialogVisible {Boolean} 弹窗显示
|
||||
* @param type{String} 链接类型为空数组则表示无限制,全部可用,传过来则表示传的值可用
|
||||
* @param placeholder{String} 提示文字
|
||||
* @return {*} update:modelValue
|
||||
*/
|
||||
const props = defineProps({
|
||||
|
|
@ -76,69 +68,58 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
const modelValue = defineModel({ type: Object, default: {} });
|
||||
const dialogVisible = defineModel('visibleDialog', { type: Boolean, default: false });
|
||||
const dialogVisible = defineModel('dialogVisible', { type: Boolean, default: false });
|
||||
const link_value = ref({});
|
||||
const reset_compontent = ref(false);
|
||||
const custom_link_type = ref(props.type);
|
||||
const base_data = reactive([
|
||||
{
|
||||
name: '商城页面',
|
||||
type: 'shop',
|
||||
data: [{ name: '基础链接', data: [{ name: '', page: '' }] }],
|
||||
},
|
||||
{
|
||||
name: '商品分类',
|
||||
type: 'goods-category',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '商品搜索',
|
||||
type: 'goods-search',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '商品页面',
|
||||
type: 'goods',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '文章页面',
|
||||
type: 'articles',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: 'DIY页面',
|
||||
type: 'diy',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '页面设计',
|
||||
type: 'design',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '自定义页面',
|
||||
type: 'custom-view',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '自定义链接',
|
||||
type: 'custom',
|
||||
data: null,
|
||||
},
|
||||
{
|
||||
name: '插件',
|
||||
type: 'plugins',
|
||||
data: [{ name: '多商户', data: [{ name: '1', page: '2' }] }],
|
||||
},
|
||||
]);
|
||||
// 弹窗显示
|
||||
const base_data = ref<any[]>([]);
|
||||
const init_data = ref({});
|
||||
watch(
|
||||
() => dialogVisible.value,
|
||||
(val) => {
|
||||
if (val) {
|
||||
}
|
||||
}
|
||||
);
|
||||
watch(
|
||||
() => dialogVisible.value,
|
||||
(val) => {
|
||||
if (val) {
|
||||
init();
|
||||
}
|
||||
}
|
||||
);
|
||||
onMounted(() => {
|
||||
init();
|
||||
});
|
||||
const init = () => {
|
||||
if (!url_value_store.is_url_value_api) {
|
||||
url_value_store.set_is_url_value_api(true);
|
||||
UrlValueAPI.getInit()
|
||||
.then((res: any) => {
|
||||
init_data.value = res.data;
|
||||
base_data.value = res.data.page_link_list;
|
||||
if (res.data.page_link_list.length > 0) {
|
||||
link_select.value = res.data.page_link_list[0].type;
|
||||
}
|
||||
url_value_store.set_url_value(res.data);
|
||||
})
|
||||
.catch(() => {
|
||||
url_value_store.set_is_url_value_api(false);
|
||||
});
|
||||
} else {
|
||||
init_data.value = url_value_store.url_value;
|
||||
base_data.value = url_value_store.url_value.page_link_list;
|
||||
if (url_value_store.url_value.page_link_list.length > 0) {
|
||||
link_select.value = url_value_store.url_value.page_link_list[0].type;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//#region 链接回调 -----------------------------------------------start
|
||||
// 菜单选中回调
|
||||
const link_select = ref(props.type.length == 0 ? 'shop' : props.type[0]);
|
||||
const link_select = ref('');
|
||||
const handle_select = (index: string, indexPath: string[], item: MenuItemClicked, routeResult: any) => {
|
||||
// console.log(index, indexPath, item, routeResult);
|
||||
link_select.value = index;
|
||||
};
|
||||
//#endregion 链接回调 -----------------------------------------------end
|
||||
|
|
|
|||
|
|
@ -1,25 +1,44 @@
|
|||
import { ref, computed } from 'vue';
|
||||
import { defineStore } from 'pinia';
|
||||
|
||||
export const urlValueStore = defineStore('urlValue', () => {
|
||||
// 链接是否需要调接口判断
|
||||
const is_urlValue_api = ref(false);
|
||||
const is_url_value_api = ref(false);
|
||||
// 链接数据
|
||||
const category = ref<any[]>([]);
|
||||
const url_value = ref<urlValue>({
|
||||
goods_category: [],
|
||||
brand_list: [],
|
||||
article_category_list: [],
|
||||
page_link_list: [],
|
||||
});
|
||||
// 存储链接数据
|
||||
const set_category = (data: any[]) => {
|
||||
category.value = data;
|
||||
is_urlValue_api.value = true;
|
||||
const set_url_value = (data: urlValue) => {
|
||||
url_value.value = data;
|
||||
is_url_value_api.value = true;
|
||||
};
|
||||
// 如果为false 则转为true
|
||||
const set_is_urlValue_api = (bool: boolean) => {
|
||||
is_urlValue_api.value = bool;
|
||||
const set_is_url_value_api = (bool: boolean) => {
|
||||
is_url_value_api.value = bool;
|
||||
};
|
||||
|
||||
return {
|
||||
category,
|
||||
is_urlValue_api,
|
||||
set_category,
|
||||
set_is_urlValue_api,
|
||||
url_value,
|
||||
is_url_value_api,
|
||||
set_url_value,
|
||||
set_is_url_value_api,
|
||||
};
|
||||
});
|
||||
|
||||
interface pageLinkList {
|
||||
name: string;
|
||||
type: string;
|
||||
data: pageLinkList[];
|
||||
page?: string;
|
||||
}
|
||||
|
||||
// 分类树结构
|
||||
export interface urlValue {
|
||||
goods_category: any[];
|
||||
brand_list: any[];
|
||||
article_category_list: any[];
|
||||
page_link_list: pageLinkList[];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue