commit
48cb65941e
@ -0,0 +1,91 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from "@/utils/request";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
|
||||||
|
SalesDiscounts: {
|
||||||
|
|
||||||
|
List(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesDiscounts/List",
|
||||||
|
method: "GET",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetItem(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesDiscounts/GetItem",
|
||||||
|
method: "GET",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
Create(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesDiscounts/Create",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
SalesFullDiscounts: {
|
||||||
|
|
||||||
|
List(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesFullDiscounts/List",
|
||||||
|
method: "GET",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetItem(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesFullDiscounts/GetItem",
|
||||||
|
method: "GET",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
Create(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesFullDiscounts/Create",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
SalesFullSetRedution: {
|
||||||
|
|
||||||
|
List(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesFullSetRedution/List",
|
||||||
|
method: "GET",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
GetItem(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesFullSetRedution/GetItem",
|
||||||
|
method: "GET",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
Create(data) {
|
||||||
|
return request({
|
||||||
|
url: "/shop/SalesFullSetRedution/Create",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'mall'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
import {
|
||||||
|
request
|
||||||
|
} from "@/utils/request";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
|
||||||
|
PointsList(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/PointsList",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
PointsSave(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/PointsSave",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
classifyList(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/classifyList",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
ClassifySave(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/ClassifySave",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
list(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/goodsList",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
goodsItem(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/goodsItem",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
goodsEdit(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/goodsEdit",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
goodsDel(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsGoods/goodsDel",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
orderList(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsOrder/orderList",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
orderSend(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsOrder/orderSend",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
GetExpressList(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsOrder/GetExpressList",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
printOrder(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsOrder/printOrder",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
updateNotes(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsOrder/updateNotes",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
confirmCancel(data) {
|
||||||
|
return request({
|
||||||
|
url: "/admin/PointsOrder/confirmCancel",
|
||||||
|
method: "POST",
|
||||||
|
data,
|
||||||
|
type: 'store'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
@ -0,0 +1,143 @@
|
|||||||
|
<template>
|
||||||
|
<view class="content pt-2">
|
||||||
|
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
|
||||||
|
|
||||||
|
<view class="px-2 my-1">
|
||||||
|
<div class="relative flex flex-col rounded-xl bg-white p-4 shadow-sm">
|
||||||
|
|
||||||
|
<div class="mb-2 pointer-events-auto relative inline-flex bg-white font-medium ">
|
||||||
|
<div class="flex items-baseline text-xs px-2">
|
||||||
|
<span class="mr-2 warn-state warn-status-processing bg-emerald-400"></span>
|
||||||
|
基础功能
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<view class="grid grid-cols-3 gap-3">
|
||||||
|
|
||||||
|
<div @click="utils.toUrl('/mall/cat/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
商品分类
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div @click="utils.toUrl('/mall/goods/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
商品管理
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="px-2 my-1">
|
||||||
|
<div class="relative flex flex-col rounded-xl bg-white p-4 shadow-sm">
|
||||||
|
|
||||||
|
<div class="mb-2 pointer-events-auto relative inline-flex bg-white font-medium ">
|
||||||
|
<div class="flex items-baseline text-xs px-2">
|
||||||
|
<span class="mr-2 warn-state warn-status-processing bg-yellow-600"></span>
|
||||||
|
订单管理
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<view class="grid grid-cols-3 gap-3">
|
||||||
|
<div @click="utils.toUrl('/mall/order/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
普通订单
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div @click="utils.toUrl('/mall/pickUp/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
自提订单
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div @click="utils.toUrl('/mall/inpersonPay/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
当面付订单
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="px-2 my-1">
|
||||||
|
<div class="relative flex flex-col rounded-xl bg-white p-4 shadow-sm">
|
||||||
|
|
||||||
|
<div class="mb-2 pointer-events-auto relative inline-flex bg-white font-medium ">
|
||||||
|
<div class="flex items-baseline text-xs px-2">
|
||||||
|
<span class="mr-2 warn-state warn-status-processing bg-stone-800"></span>
|
||||||
|
折扣管理
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<view class="grid grid-cols-3 gap-3">
|
||||||
|
<div @click="utils.toUrl('/mall/discount/discount/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
限时折扣
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div @click="utils.toUrl('/mall/discount/full_discount/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
梯度折扣
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div @click="utils.toUrl('/mall/discount/full_set_redution/index')"
|
||||||
|
class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
满额立减
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="item border-2 border-solid border-gray-100 rounded bg-slate-50 p-2 flex justify-between"
|
||||||
|
style="font-size: 0.75rem;">
|
||||||
|
套餐优惠
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<view class="bg-transparent h-[80px]"></view>
|
||||||
|
|
||||||
|
<view class="fixed left-2 right-2 bottom-4 z-50">
|
||||||
|
<myTabbar tab="function"></myTabbar>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import utils from '@/utils/utils.js';
|
||||||
|
import index from '@/api/store/index.js';
|
||||||
|
import myTabbar from "../components/myTabbar/index.vue";
|
||||||
|
import bar from "../components/bar/bar.vue";
|
||||||
|
import kevyloading from "@/components/kevy-loading/kevy-loading";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Ref<boolean>}
|
||||||
|
* 控制页面加载状态的 Ref
|
||||||
|
*/
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从本地存储中获取用户信息
|
||||||
|
*/
|
||||||
|
const store_info = uni.getStorageSync("store_info");
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.content {}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
<template>
|
||||||
|
<view class="charts-box bg-white content">
|
||||||
|
<view v-show="classifyList.length" class="flex overflow-auto flex-wrap">
|
||||||
|
<div class="grid grid-cols-3 gap-4 p-4 w-full">
|
||||||
|
|
||||||
|
<wd-button @click="utils.toUrl('/store/cat/edit?edit=' + JSON.stringify({}))" style="width: 100%;"
|
||||||
|
class="bg-[#f0f0f0] w-full flex-1" :round="false">
|
||||||
|
新增
|
||||||
|
</wd-button>
|
||||||
|
<wd-button @click="showActions(cat)" style="width: 100%;" v-for="cat of classifyList"
|
||||||
|
class="bg-[#f0f0f0] w-full flex-1" type="info" :round="false">
|
||||||
|
{{ cat.name }}
|
||||||
|
</wd-button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<wd-action-sheet v-model="show" :actions="actions" @close="close" @select="select" />
|
||||||
|
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import utils from '@/utils/utils.js'
|
||||||
|
import pointsGoodsApi from '@/api/store/pointsGoods.js';
|
||||||
|
import kevyloading from "@/components/kevy-loading/kevy-loading";
|
||||||
|
/** @type {Ref<boolean>} */
|
||||||
|
const loading = ref(false);
|
||||||
|
|
||||||
|
import {
|
||||||
|
onShow,
|
||||||
|
} from "@dcloudio/uni-app";
|
||||||
|
|
||||||
|
const model = ref({})
|
||||||
|
const baseForm = ref({})
|
||||||
|
|
||||||
|
const show = ref(false)
|
||||||
|
const actions = ref([
|
||||||
|
{
|
||||||
|
name: '编辑分类'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '新增子项'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
const opt = ref("编辑分类")
|
||||||
|
|
||||||
|
function showActions(row) {
|
||||||
|
show.value = true
|
||||||
|
model.value = row
|
||||||
|
console.log(row);
|
||||||
|
}
|
||||||
|
|
||||||
|
function close() {
|
||||||
|
show.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
function select({ item, index }) {
|
||||||
|
opt.value = item.name
|
||||||
|
|
||||||
|
if (opt.value == '编辑分类') {
|
||||||
|
// message.alert({
|
||||||
|
// title: "编辑分类"
|
||||||
|
// })
|
||||||
|
|
||||||
|
baseForm.value = model.value
|
||||||
|
utils.toUrl('/store/points/catEdit?edit=' + JSON.stringify(baseForm.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt.value == '新增子项') {
|
||||||
|
|
||||||
|
console.log(model.value);
|
||||||
|
|
||||||
|
if (model.value.parentIds.length == 3) {
|
||||||
|
return uni.showToast({
|
||||||
|
title: '三级分类不可新增子级',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
baseForm.value = model.value
|
||||||
|
utils.toUrl('/store/cat/edit?edit=' + JSON.stringify({}) + "&parent=" + JSON.stringify(baseForm.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
// baseForm.value = model.value
|
||||||
|
// utils.toUrl('/store/cat/edit?edit=' + JSON.stringify(baseForm.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
const classifyList = ref([])
|
||||||
|
const getClassify = () => {
|
||||||
|
loading.value = true
|
||||||
|
function flattenCategories(categories, parentIds = []) {
|
||||||
|
let flatCategories = [];
|
||||||
|
|
||||||
|
for (const category of categories) {
|
||||||
|
const categoryWithParents = {
|
||||||
|
...category,
|
||||||
|
parentIds: [...parentIds, category.id],
|
||||||
|
};
|
||||||
|
|
||||||
|
flatCategories.push(categoryWithParents);
|
||||||
|
|
||||||
|
if (category.children && category.children.length > 0) {
|
||||||
|
flatCategories = flatCategories.concat(flattenCategories(category.children, [...parentIds, category.id]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flatCategories;
|
||||||
|
}
|
||||||
|
pointsGoodsApi.classifyList().then(res => {
|
||||||
|
classifyList.value = flattenCategories(res.data)
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
getClassify()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
/* 请根据实际需求修改父元素尺寸,组件自动识别宽高 */
|
||||||
|
.charts-box {
|
||||||
|
width: 100%;
|
||||||
|
height: 300px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,374 @@
|
|||||||
|
<template>
|
||||||
|
<view class="skuEdit">
|
||||||
|
<wd-table rowHeight="100" :data="Pdata.use_sku == 0
|
||||||
|
? skuDefault
|
||||||
|
: skuLibrary
|
||||||
|
" :stripe="false">
|
||||||
|
<wd-table-col prop="name" label="SKU">
|
||||||
|
|
||||||
|
<template #value="scope">
|
||||||
|
<view class="custom-class">
|
||||||
|
<span style="margin-right: 4px" v-for="(item, index) of scope.row
|
||||||
|
.attr_list" :key="index">
|
||||||
|
{{ item.name }}
|
||||||
|
</span>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
</wd-table-col>
|
||||||
|
<wd-table-col prop="school" label="售价">
|
||||||
|
<template #value="scope">
|
||||||
|
<view class="px-2 pb-1 bg-white">
|
||||||
|
<wd-input placeholder="售价" v-model="scope.row.price" type="number" />
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</wd-table-col>
|
||||||
|
<wd-table-col prop="major" label="原价">
|
||||||
|
<template #value="scope">
|
||||||
|
<view class="px-2 pb-1 bg-white">
|
||||||
|
<wd-input placeholder="原价" v-model="scope.row.original_price" type="number">
|
||||||
|
</wd-input>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</wd-table-col>
|
||||||
|
<wd-table-col prop="major" label="库存">
|
||||||
|
<template #value="scope">
|
||||||
|
<view class="px-2 pb-1 bg-white">
|
||||||
|
<wd-input placeholder="库存" v-model="scope.row.stock" type="number">
|
||||||
|
</wd-input>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</wd-table-col>
|
||||||
|
<wd-table-col prop="major" label="产品号">
|
||||||
|
<template #value="scope">
|
||||||
|
<view class="px-2 pb-1 bg-white">
|
||||||
|
<wd-input placeholder="产品号" v-model="scope.row.no">
|
||||||
|
</wd-input>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</wd-table-col>
|
||||||
|
|
||||||
|
<wd-table-col prop="major" label="产品图">
|
||||||
|
<template #value="scope">
|
||||||
|
<view class="overflow-hidden w-full h-full flex items-center justify-center">
|
||||||
|
<view class="px-2 pb-1 bg-white flex items-center justify-center mt-4 overflow-hidden">
|
||||||
|
<yUpload v-model="scope.row.pic_url"></yUpload>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
</wd-table-col>
|
||||||
|
|
||||||
|
</wd-table>
|
||||||
|
|
||||||
|
<view v-show="Pdata.use_sku == 1" class="bg-gray-100 rounded mb-2">
|
||||||
|
<div class="p-2 bg-white w-full">
|
||||||
|
<div class="name mb-2 text-xs">规格设置</div>
|
||||||
|
<view class="flex bg-white px-3 py-1 rounded w-full">
|
||||||
|
<div class="flex-1 mr-4">
|
||||||
|
<wd-input type="text" v-model="addGroupData.name" />
|
||||||
|
</div>
|
||||||
|
<wd-button @click="addSkuGroup">添加规格组</wd-button>
|
||||||
|
</view>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="p-2 bg-white">
|
||||||
|
<div style="display: flex; flex-flow: column; align-items: flex-start;">
|
||||||
|
<div class="name mb-2 text-xs">规格组</div>
|
||||||
|
|
||||||
|
<div class="w-full bg-gray-100 p-2" v-for="(item, index) in skuGroup" :key="index">
|
||||||
|
<div class="flex items-center justify-between w-full bg-white p-2">
|
||||||
|
<div class="mr-3">
|
||||||
|
<wd-tag type="primary" custom-class="space" closable @close="moveGroup(index)">{{
|
||||||
|
item.name }}</wd-tag>
|
||||||
|
</div>
|
||||||
|
<div class="mr-3">
|
||||||
|
<wd-input type="text" v-model="addGouppItemData[index]" />
|
||||||
|
</div>
|
||||||
|
<wd-button type="warning" @click="addGroupItem(index)">添加规格</wd-button>
|
||||||
|
</div>
|
||||||
|
<div type="flex" style="margin: 12px 0;">
|
||||||
|
<div class="name mb-2 text-xs">规格:</div>
|
||||||
|
<view class="flex gap-2 flex-wrap">
|
||||||
|
<wd-tag custom-class="space1" closable round type="warning" class="mx-1"
|
||||||
|
v-for="(value, key) in item.groupItem" :key="key" style="margin-left: 10px"
|
||||||
|
@close="removeGroupItem(index, key)">{{ value.name
|
||||||
|
}}</wd-tag>
|
||||||
|
</view>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import yUpload from "@/components/yUpload/index.vue"
|
||||||
|
import { useToast } from '@/uni_modules/wot-design-uni'
|
||||||
|
const toast = useToast()
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "skuEdit",
|
||||||
|
props: {
|
||||||
|
Pdata: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
components: {
|
||||||
|
yUpload
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// sku规格开始
|
||||||
|
skuDefault: [
|
||||||
|
{
|
||||||
|
attr_list: [{ group_name: "默认", name: "默认" }],
|
||||||
|
price: "", // 售价
|
||||||
|
original_price: "", // 原价
|
||||||
|
stock: "", // 库存
|
||||||
|
pic_url: "", // 图片
|
||||||
|
no: "", // 货号
|
||||||
|
},
|
||||||
|
],
|
||||||
|
skuGroup: [],
|
||||||
|
addGroupData: {
|
||||||
|
name: "",
|
||||||
|
groupItem: [],
|
||||||
|
}, //添加规格组默认数据
|
||||||
|
addGouppItemData: [],
|
||||||
|
skuLibrary: [], // 规格库
|
||||||
|
// 批量设置
|
||||||
|
all_price: "",
|
||||||
|
all_original_price: "",
|
||||||
|
all_stock: "",
|
||||||
|
all_no: "",
|
||||||
|
// sku规格结束
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.skuDefault = this.Pdata.skuDefault.length ? this.Pdata.skuDefault : this.skuDefault
|
||||||
|
this.skuLibrary = this.Pdata.skuLibrary
|
||||||
|
this.skuGroup = this.Pdata.skuGroup
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
successImage($event, index) {
|
||||||
|
console.log($event, index);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理规格数据
|
||||||
|
*/
|
||||||
|
setGoodsAttrItem(attrGroup, attrList, index) {
|
||||||
|
var attrList1 = [];
|
||||||
|
if (index < attrGroup.length) {
|
||||||
|
if (index === 0 || attrList.length === 0) {
|
||||||
|
if (attrGroup[index].groupItem.length > 0) {
|
||||||
|
attrGroup[index].groupItem.forEach((element) => {
|
||||||
|
element.group_name = attrGroup[index].name;
|
||||||
|
attrList1.push([element]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (attrGroup[index].groupItem.length > 0) {
|
||||||
|
attrList.forEach((element) => {
|
||||||
|
attrGroup[index].groupItem.forEach((element1) => {
|
||||||
|
element1.group_name = attrGroup[index].name;
|
||||||
|
attrList1.push(element.concat([element1]));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
attrList1 = attrList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++index;
|
||||||
|
return this.setGoodsAttrItem(attrGroup, attrList1, index);
|
||||||
|
} else {
|
||||||
|
return attrList;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取其他详细数据
|
||||||
|
*/
|
||||||
|
getAttrDataInfo(attr) {
|
||||||
|
var attrList = [];
|
||||||
|
attr.forEach((element) => {
|
||||||
|
var setAttr = {};
|
||||||
|
if (this.skuLibrary) {
|
||||||
|
this.skuLibrary.forEach((element2) => {
|
||||||
|
if (element2.attr_list.length === element.length) {
|
||||||
|
var loading = true;
|
||||||
|
if (
|
||||||
|
loading &&
|
||||||
|
this.compareAttr(element2.attr_list, element)
|
||||||
|
) {
|
||||||
|
setAttr = element2;
|
||||||
|
loading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = {
|
||||||
|
id: setAttr && setAttr.id ? setAttr.id : 0,
|
||||||
|
attr_list: element,
|
||||||
|
price: setAttr && setAttr.price ? setAttr.price : element.reduce((price, i) => price + i.price, 0).toFixed(2),
|
||||||
|
original_price:
|
||||||
|
setAttr && setAttr.original_price
|
||||||
|
? setAttr.original_price
|
||||||
|
: element.reduce((price, i) => price + i.price, 0).toFixed(2),
|
||||||
|
stock: setAttr && setAttr.stock ? setAttr.stock : 0,
|
||||||
|
pic_url: setAttr && setAttr.pic_url ? setAttr.pic_url : "",
|
||||||
|
no: setAttr && setAttr.no ? setAttr.no : "",
|
||||||
|
};
|
||||||
|
for (const key in setAttr) {
|
||||||
|
if (key.indexOf("member") !== -1) {
|
||||||
|
data[key] = setAttr[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
attrList.push(data);
|
||||||
|
});
|
||||||
|
return attrList;
|
||||||
|
},
|
||||||
|
compareAttr(val1, val2) {
|
||||||
|
var compareLen = 0;
|
||||||
|
val1.forEach((element1) => {
|
||||||
|
val2.forEach((element2) => {
|
||||||
|
if (element1.name === element2.name) {
|
||||||
|
compareLen++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return compareLen === val1.length;
|
||||||
|
},
|
||||||
|
// 添加规格组
|
||||||
|
addSkuGroup() {
|
||||||
|
|
||||||
|
if (!this.addGroupData.name) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请填写规格组名称',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加一个一个规格类
|
||||||
|
console.log("添加了一个规格组");
|
||||||
|
this.skuGroup.push(this.addGroupData);
|
||||||
|
console.log("skuGroup发生了变换");
|
||||||
|
// 回复默认数据
|
||||||
|
this.addGroupData = {
|
||||||
|
name: "",
|
||||||
|
groupItem: [],
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除规格组
|
||||||
|
moveGroup(index) {
|
||||||
|
if (this.skuGroup[index].groupItem.length === 0) {
|
||||||
|
console.log("删除的组合没有规格!!!");
|
||||||
|
this.skuGroup.splice(index, 1);
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.skuGroup.splice(index, 1);
|
||||||
|
var attrList = this.setGoodsAttrItem(this.skuGroup, [], 0);
|
||||||
|
this.skuLibrary = this.getAttrDataInfo(attrList);
|
||||||
|
this.calculateCombinationPrice(this.skuLibrary);
|
||||||
|
},
|
||||||
|
// 计算组合价格的方法
|
||||||
|
calculateCombinationPrice(skuLibrary) {
|
||||||
|
console.log(skuLibrary);
|
||||||
|
skuLibrary.forEach((sku) => {
|
||||||
|
// 计算每个 SKU 组合的价格
|
||||||
|
let combinationPrice = 0;
|
||||||
|
|
||||||
|
// 遍历 SKU 的属性列表
|
||||||
|
sku.attr_list.forEach((attr) => {
|
||||||
|
// 累加每个属性项的价格
|
||||||
|
combinationPrice += attr.price;
|
||||||
|
});
|
||||||
|
|
||||||
|
// 将组合价格保存到 SKU 对象中
|
||||||
|
sku.price = combinationPrice.toFixed(2);
|
||||||
|
sku.original_price = combinationPrice.toFixed(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
this.skuLibrary = skuLibrary
|
||||||
|
|
||||||
|
},
|
||||||
|
// 添加规格
|
||||||
|
addGroupItem(index) {
|
||||||
|
const _skuGroup = this.skuGroup
|
||||||
|
|
||||||
|
if (this.skuGroup[index].groupItem.length === 0) {
|
||||||
|
console.log("新的组合出现了!!!");
|
||||||
|
// 计算组合价格
|
||||||
|
setTimeout(() => {
|
||||||
|
// console.log(this.skuGroup);
|
||||||
|
this.calculateCombinationPrice(this.skuLibrary);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log(_skuGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!this.addGouppItemData[index]) {
|
||||||
|
if (!this.addGroupData.name) {
|
||||||
|
uni.showToast({
|
||||||
|
title: '请填写规格名称',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.skuGroup[index].groupItem.push({
|
||||||
|
group_name: this.skuGroup[index].name,
|
||||||
|
name: this.addGouppItemData[index],
|
||||||
|
price: 0
|
||||||
|
});
|
||||||
|
console.log(this.skuGroup);
|
||||||
|
|
||||||
|
// todo 这里还有问题
|
||||||
|
var attrList = this.setGoodsAttrItem(this.skuGroup, [], 0);
|
||||||
|
console.log(attrList);
|
||||||
|
this.skuLibrary = this.getAttrDataInfo(attrList);
|
||||||
|
this.addGouppItemData = [];
|
||||||
|
|
||||||
|
// // 计算组合价格
|
||||||
|
// this.calculateCombinationPrice(this.skuLibrary);
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除规格
|
||||||
|
removeGroupItem(index, key) {
|
||||||
|
this.skuGroup[index].groupItem.splice(key, 1);
|
||||||
|
var attrList = this.setGoodsAttrItem(this.skuGroup, [], 0);
|
||||||
|
this.skuLibrary = this.getAttrDataInfo(attrList);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
:deep(.space) {
|
||||||
|
padding: 6px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.space1) {
|
||||||
|
padding: 6px 10px;
|
||||||
|
background: #f0883a !important;
|
||||||
|
color: white !important;
|
||||||
|
|
||||||
|
.wd-tag__close {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
// #ifdef H5
|
||||||
|
export default {
|
||||||
|
name: 'Keypress',
|
||||||
|
props: {
|
||||||
|
disable: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted () {
|
||||||
|
const keyNames = {
|
||||||
|
esc: ['Esc', 'Escape'],
|
||||||
|
tab: 'Tab',
|
||||||
|
enter: 'Enter',
|
||||||
|
space: [' ', 'Spacebar'],
|
||||||
|
up: ['Up', 'ArrowUp'],
|
||||||
|
left: ['Left', 'ArrowLeft'],
|
||||||
|
right: ['Right', 'ArrowRight'],
|
||||||
|
down: ['Down', 'ArrowDown'],
|
||||||
|
delete: ['Backspace', 'Delete', 'Del']
|
||||||
|
}
|
||||||
|
const listener = ($event) => {
|
||||||
|
if (this.disable) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const keyName = Object.keys(keyNames).find(key => {
|
||||||
|
const keyName = $event.key
|
||||||
|
const value = keyNames[key]
|
||||||
|
return value === keyName || (Array.isArray(value) && value.includes(keyName))
|
||||||
|
})
|
||||||
|
if (keyName) {
|
||||||
|
// 避免和其他按键事件冲突
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$emit(keyName, {})
|
||||||
|
}, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener('keyup', listener)
|
||||||
|
this.$once('hook:beforeDestroy', () => {
|
||||||
|
document.removeEventListener('keyup', listener)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
render: () => {}
|
||||||
|
}
|
||||||
|
// #endif
|
||||||
@ -0,0 +1,563 @@
|
|||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
localdata: {
|
||||||
|
type: [Array, Object],
|
||||||
|
default () {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
spaceInfo: {
|
||||||
|
type: Object,
|
||||||
|
default () {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
collection: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
field: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
orderby: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
type: [String, Object],
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
pageData: {
|
||||||
|
type: String,
|
||||||
|
default: 'add'
|
||||||
|
},
|
||||||
|
pageCurrent: {
|
||||||
|
type: Number,
|
||||||
|
default: 1
|
||||||
|
},
|
||||||
|
pageSize: {
|
||||||
|
type: Number,
|
||||||
|
default: 20
|
||||||
|
},
|
||||||
|
getcount: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
getone: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
gettree: {
|
||||||
|
type: [Boolean, String],
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
manual: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
type: [Array, String, Number],
|
||||||
|
default () {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: [Array, String, Number],
|
||||||
|
default () {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
preload: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
stepSearh: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true
|
||||||
|
},
|
||||||
|
selfField: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
parentField: {
|
||||||
|
type: String,
|
||||||
|
default: ''
|
||||||
|
},
|
||||||
|
multiple: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
map: {
|
||||||
|
type: Object,
|
||||||
|
default() {
|
||||||
|
return {
|
||||||
|
text: "text",
|
||||||
|
value: "value"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
loading: false,
|
||||||
|
errorMessage: '',
|
||||||
|
loadMore: {
|
||||||
|
contentdown: '',
|
||||||
|
contentrefresh: '',
|
||||||
|
contentnomore: ''
|
||||||
|
},
|
||||||
|
dataList: [],
|
||||||
|
selected: [],
|
||||||
|
selectedIndex: 0,
|
||||||
|
page: {
|
||||||
|
current: this.pageCurrent,
|
||||||
|
size: this.pageSize,
|
||||||
|
count: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
isLocaldata() {
|
||||||
|
return !this.collection.length
|
||||||
|
},
|
||||||
|
postField() {
|
||||||
|
let fields = [this.field];
|
||||||
|
if (this.parentField) {
|
||||||
|
fields.push(`${this.parentField} as parent_value`);
|
||||||
|
}
|
||||||
|
return fields.join(',');
|
||||||
|
},
|
||||||
|
dataValue() {
|
||||||
|
let isModelValue = Array.isArray(this.modelValue) ? (this.modelValue.length > 0) : (this.modelValue !== null || this.modelValue !== undefined)
|
||||||
|
return isModelValue ? this.modelValue : this.value
|
||||||
|
},
|
||||||
|
hasValue() {
|
||||||
|
if (typeof this.dataValue === 'number') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return (this.dataValue != null) && (this.dataValue.length > 0)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.$watch(() => {
|
||||||
|
var al = [];
|
||||||
|
['pageCurrent',
|
||||||
|
'pageSize',
|
||||||
|
'spaceInfo',
|
||||||
|
'value',
|
||||||
|
'modelValue',
|
||||||
|
'localdata',
|
||||||
|
'collection',
|
||||||
|
'action',
|
||||||
|
'field',
|
||||||
|
'orderby',
|
||||||
|
'where',
|
||||||
|
'getont',
|
||||||
|
'getcount',
|
||||||
|
'gettree'
|
||||||
|
].forEach(key => {
|
||||||
|
al.push(this[key])
|
||||||
|
});
|
||||||
|
return al
|
||||||
|
}, (newValue, oldValue) => {
|
||||||
|
let needReset = false
|
||||||
|
for (let i = 2; i < newValue.length; i++) {
|
||||||
|
if (newValue[i] != oldValue[i]) {
|
||||||
|
needReset = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (newValue[0] != oldValue[0]) {
|
||||||
|
this.page.current = this.pageCurrent
|
||||||
|
}
|
||||||
|
this.page.size = this.pageSize
|
||||||
|
|
||||||
|
this.onPropsChange()
|
||||||
|
})
|
||||||
|
this._treeData = []
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
onPropsChange() {
|
||||||
|
this._treeData = []
|
||||||
|
},
|
||||||
|
getCommand(options = {}) {
|
||||||
|
/* eslint-disable no-undef */
|
||||||
|
let db = uniCloud.database(this.spaceInfo)
|
||||||
|
|
||||||
|
const action = options.action || this.action
|
||||||
|
if (action) {
|
||||||
|
db = db.action(action)
|
||||||
|
}
|
||||||
|
|
||||||
|
const collection = options.collection || this.collection
|
||||||
|
db = db.collection(collection)
|
||||||
|
|
||||||
|
const where = options.where || this.where
|
||||||
|
if (!(!where || !Object.keys(where).length)) {
|
||||||
|
db = db.where(where)
|
||||||
|
}
|
||||||
|
|
||||||
|
const field = options.field || this.field
|
||||||
|
if (field) {
|
||||||
|
db = db.field(field)
|
||||||
|
}
|
||||||
|
|
||||||
|
const orderby = options.orderby || this.orderby
|
||||||
|
if (orderby) {
|
||||||
|
db = db.orderBy(orderby)
|
||||||
|
}
|
||||||
|
|
||||||
|
const current = options.pageCurrent !== undefined ? options.pageCurrent : this.page.current
|
||||||
|
const size = options.pageSize !== undefined ? options.pageSize : this.page.size
|
||||||
|
const getCount = options.getcount !== undefined ? options.getcount : this.getcount
|
||||||
|
const getTree = options.gettree !== undefined ? options.gettree : this.gettree
|
||||||
|
|
||||||
|
const getOptions = {
|
||||||
|
getCount,
|
||||||
|
getTree
|
||||||
|
}
|
||||||
|
if (options.getTreePath) {
|
||||||
|
getOptions.getTreePath = options.getTreePath
|
||||||
|
}
|
||||||
|
|
||||||
|
db = db.skip(size * (current - 1)).limit(size).get(getOptions)
|
||||||
|
|
||||||
|
return db
|
||||||
|
},
|
||||||
|
getNodeData(callback) {
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.loading = true
|
||||||
|
this.getCommand({
|
||||||
|
field: this.postField,
|
||||||
|
where: this._pathWhere()
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false
|
||||||
|
this.selected = res.result.data
|
||||||
|
callback && callback()
|
||||||
|
}).catch((err) => {
|
||||||
|
this.loading = false
|
||||||
|
this.errorMessage = err
|
||||||
|
})
|
||||||
|
},
|
||||||
|
getTreePath(callback) {
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
this.getCommand({
|
||||||
|
field: this.postField,
|
||||||
|
getTreePath: {
|
||||||
|
startWith: `${this.selfField}=='${this.dataValue}'`
|
||||||
|
}
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false
|
||||||
|
let treePath = []
|
||||||
|
this._extractTreePath(res.result.data, treePath)
|
||||||
|
this.selected = treePath
|
||||||
|
callback && callback()
|
||||||
|
}).catch((err) => {
|
||||||
|
this.loading = false
|
||||||
|
this.errorMessage = err
|
||||||
|
})
|
||||||
|
},
|
||||||
|
loadData() {
|
||||||
|
if (this.isLocaldata) {
|
||||||
|
this._processLocalData()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.dataValue != null) {
|
||||||
|
this._loadNodeData((data) => {
|
||||||
|
this._treeData = data
|
||||||
|
this._updateBindData()
|
||||||
|
this._updateSelected()
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.stepSearh) {
|
||||||
|
this._loadNodeData((data) => {
|
||||||
|
this._treeData = data
|
||||||
|
this._updateBindData()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this._loadAllData((data) => {
|
||||||
|
this._treeData = []
|
||||||
|
this._extractTree(data, this._treeData, null)
|
||||||
|
this._updateBindData()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_loadAllData(callback) {
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
this.getCommand({
|
||||||
|
field: this.postField,
|
||||||
|
gettree: true,
|
||||||
|
startwith: `${this.selfField}=='${this.dataValue}'`
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false
|
||||||
|
callback(res.result.data)
|
||||||
|
this.onDataChange()
|
||||||
|
}).catch((err) => {
|
||||||
|
this.loading = false
|
||||||
|
this.errorMessage = err
|
||||||
|
})
|
||||||
|
},
|
||||||
|
_loadNodeData(callback, pw) {
|
||||||
|
if (this.loading) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.loading = true
|
||||||
|
|
||||||
|
this.getCommand({
|
||||||
|
field: this.postField,
|
||||||
|
where: pw || this._postWhere(),
|
||||||
|
pageSize: 500
|
||||||
|
}).then((res) => {
|
||||||
|
this.loading = false
|
||||||
|
callback(res.result.data)
|
||||||
|
this.onDataChange()
|
||||||
|
}).catch((err) => {
|
||||||
|
this.loading = false
|
||||||
|
this.errorMessage = err
|
||||||
|
})
|
||||||
|
},
|
||||||
|
_pathWhere() {
|
||||||
|
let result = []
|
||||||
|
let where_field = this._getParentNameByField();
|
||||||
|
if (where_field) {
|
||||||
|
result.push(`${where_field} == '${this.dataValue}'`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.where) {
|
||||||
|
return `(${this.where}) && (${result.join(' || ')})`
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.join(' || ')
|
||||||
|
},
|
||||||
|
_postWhere() {
|
||||||
|
let result = []
|
||||||
|
let selected = this.selected
|
||||||
|
let parentField = this.parentField
|
||||||
|
if (parentField) {
|
||||||
|
result.push(`${parentField} == null || ${parentField} == ""`)
|
||||||
|
}
|
||||||
|
if (selected.length) {
|
||||||
|
for (var i = 0; i < selected.length - 1; i++) {
|
||||||
|
result.push(`${parentField} == '${selected[i].value}'`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let where = []
|
||||||
|
if (this.where) {
|
||||||
|
where.push(`(${this.where})`)
|
||||||
|
}
|
||||||
|
if (result.length) {
|
||||||
|
where.push(`(${result.join(' || ')})`)
|
||||||
|
}
|
||||||
|
|
||||||
|
return where.join(' && ')
|
||||||
|
},
|
||||||
|
_nodeWhere() {
|
||||||
|
let result = []
|
||||||
|
let selected = this.selected
|
||||||
|
if (selected.length) {
|
||||||
|
result.push(`${this.parentField} == '${selected[selected.length - 1].value}'`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.where) {
|
||||||
|
return `(${this.where}) && (${result.join(' || ')})`
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.join(' || ')
|
||||||
|
},
|
||||||
|
_getParentNameByField() {
|
||||||
|
const fields = this.field.split(',');
|
||||||
|
let where_field = null;
|
||||||
|
for (let i = 0; i < fields.length; i++) {
|
||||||
|
const items = fields[i].split('as');
|
||||||
|
if (items.length < 2) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (items[1].trim() === 'value') {
|
||||||
|
where_field = items[0].trim();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return where_field
|
||||||
|
},
|
||||||
|
_isTreeView() {
|
||||||
|
return (this.parentField && this.selfField)
|
||||||
|
},
|
||||||
|
_updateSelected() {
|
||||||
|
var dl = this.dataList
|
||||||
|
var sl = this.selected
|
||||||
|
let textField = this.map.text
|
||||||
|
let valueField = this.map.value
|
||||||
|
for (var i = 0; i < sl.length; i++) {
|
||||||
|
var value = sl[i].value
|
||||||
|
var dl2 = dl[i]
|
||||||
|
for (var j = 0; j < dl2.length; j++) {
|
||||||
|
var item2 = dl2[j]
|
||||||
|
if (item2[valueField] === value) {
|
||||||
|
sl[i].text = item2[textField]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_updateBindData(node) {
|
||||||
|
const {
|
||||||
|
dataList,
|
||||||
|
hasNodes
|
||||||
|
} = this._filterData(this._treeData, this.selected)
|
||||||
|
|
||||||
|
let isleaf = this._stepSearh === false && !hasNodes
|
||||||
|
|
||||||
|
if (node) {
|
||||||
|
node.isleaf = isleaf
|
||||||
|
}
|
||||||
|
|
||||||
|
this.dataList = dataList
|
||||||
|
this.selectedIndex = dataList.length - 1
|
||||||
|
|
||||||
|
if (!isleaf && this.selected.length < dataList.length) {
|
||||||
|
this.selected.push({
|
||||||
|
value: null,
|
||||||
|
text: "请选择"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
isleaf,
|
||||||
|
hasNodes
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_filterData(data, paths) {
|
||||||
|
let dataList = []
|
||||||
|
let hasNodes = true
|
||||||
|
|
||||||
|
dataList.push(data.filter((item) => {
|
||||||
|
return (item.parent_value === null || item.parent_value === undefined || item.parent_value === '')
|
||||||
|
}))
|
||||||
|
for (let i = 0; i < paths.length; i++) {
|
||||||
|
var value = paths[i].value
|
||||||
|
var nodes = data.filter((item) => {
|
||||||
|
return item.parent_value === value
|
||||||
|
})
|
||||||
|
|
||||||
|
if (nodes.length) {
|
||||||
|
dataList.push(nodes)
|
||||||
|
} else {
|
||||||
|
hasNodes = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
dataList,
|
||||||
|
hasNodes
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_extractTree(nodes, result, parent_value) {
|
||||||
|
let list = result || []
|
||||||
|
let valueField = this.map.value
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
let node = nodes[i]
|
||||||
|
|
||||||
|
let child = {}
|
||||||
|
for (let key in node) {
|
||||||
|
if (key !== 'children') {
|
||||||
|
child[key] = node[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (parent_value !== null && parent_value !== undefined && parent_value !== '') {
|
||||||
|
child.parent_value = parent_value
|
||||||
|
}
|
||||||
|
result.push(child)
|
||||||
|
|
||||||
|
let children = node.children
|
||||||
|
if (children) {
|
||||||
|
this._extractTree(children, result, node[valueField])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_extractTreePath(nodes, result) {
|
||||||
|
let list = result || []
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
let node = nodes[i]
|
||||||
|
|
||||||
|
let child = {}
|
||||||
|
for (let key in node) {
|
||||||
|
if (key !== 'children') {
|
||||||
|
child[key] = node[key]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.push(child)
|
||||||
|
|
||||||
|
let children = node.children
|
||||||
|
if (children) {
|
||||||
|
this._extractTreePath(children, result)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
_findNodePath(key, nodes, path = []) {
|
||||||
|
let textField = this.map.text
|
||||||
|
let valueField = this.map.value
|
||||||
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
|
let node = nodes[i]
|
||||||
|
let children = node.children
|
||||||
|
let text = node[textField]
|
||||||
|
let value = node[valueField]
|
||||||
|
|
||||||
|
path.push({
|
||||||
|
value,
|
||||||
|
text
|
||||||
|
})
|
||||||
|
|
||||||
|
if (value === key) {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
|
||||||
|
if (children) {
|
||||||
|
const p = this._findNodePath(key, children, path)
|
||||||
|
if (p.length) {
|
||||||
|
return p
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path.pop()
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
},
|
||||||
|
_processLocalData() {
|
||||||
|
this._treeData = []
|
||||||
|
this._extractTree(this.localdata, this._treeData)
|
||||||
|
|
||||||
|
var inputValue = this.dataValue
|
||||||
|
if (inputValue === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(inputValue)) {
|
||||||
|
inputValue = inputValue[inputValue.length - 1]
|
||||||
|
if (typeof inputValue === 'object' && inputValue[this.map.value]) {
|
||||||
|
inputValue = inputValue[this.map.value]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.selected = this._findNodePath(inputValue, this.localdata)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,92 @@
|
|||||||
|
{
|
||||||
|
"id": "uni-data-picker",
|
||||||
|
"displayName": "uni-data-picker 数据驱动的picker选择器",
|
||||||
|
"version": "1.0.3",
|
||||||
|
"description": "单列、多列级联选择器,常用于省市区城市选择、公司部门选择、多级分类等场景",
|
||||||
|
"keywords": [
|
||||||
|
"uni-ui",
|
||||||
|
"uniui",
|
||||||
|
"picker",
|
||||||
|
"级联",
|
||||||
|
"省市区",
|
||||||
|
""
|
||||||
|
],
|
||||||
|
"repository": "https://github.com/dcloudio/uni-ui",
|
||||||
|
"engines": {
|
||||||
|
"HBuilderX": ""
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"example": "../../temps/example_temps"
|
||||||
|
},
|
||||||
|
"dcloudext": {
|
||||||
|
"category": [
|
||||||
|
"前端组件",
|
||||||
|
"通用组件"
|
||||||
|
],
|
||||||
|
"sale": {
|
||||||
|
"regular": {
|
||||||
|
"price": "0.00"
|
||||||
|
},
|
||||||
|
"sourcecode": {
|
||||||
|
"price": "0.00"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"contact": {
|
||||||
|
"qq": ""
|
||||||
|
},
|
||||||
|
"declaration": {
|
||||||
|
"ads": "无",
|
||||||
|
"data": "无",
|
||||||
|
"permissions": "无"
|
||||||
|
},
|
||||||
|
"npmurl": "https://www.npmjs.com/package/@dcloudio/uni-ui"
|
||||||
|
},
|
||||||
|
"uni_modules": {
|
||||||
|
"dependencies": [
|
||||||
|
"uni-load-more",
|
||||||
|
"uni-icons",
|
||||||
|
"uni-scss"
|
||||||
|
],
|
||||||
|
"encrypt": [],
|
||||||
|
"platforms": {
|
||||||
|
"cloud": {
|
||||||
|
"tcb": "y",
|
||||||
|
"aliyun": "y"
|
||||||
|
},
|
||||||
|
"client": {
|
||||||
|
"App": {
|
||||||
|
"app-vue": "y",
|
||||||
|
"app-nvue": "y"
|
||||||
|
},
|
||||||
|
"H5-mobile": {
|
||||||
|
"Safari": "y",
|
||||||
|
"Android Browser": "y",
|
||||||
|
"微信浏览器(Android)": "y",
|
||||||
|
"QQ浏览器(Android)": "y"
|
||||||
|
},
|
||||||
|
"H5-pc": {
|
||||||
|
"Chrome": "y",
|
||||||
|
"IE": "y",
|
||||||
|
"Edge": "y",
|
||||||
|
"Firefox": "y",
|
||||||
|
"Safari": "y"
|
||||||
|
},
|
||||||
|
"小程序": {
|
||||||
|
"微信": "y",
|
||||||
|
"阿里": "y",
|
||||||
|
"百度": "y",
|
||||||
|
"字节跳动": "y",
|
||||||
|
"QQ": "y"
|
||||||
|
},
|
||||||
|
"快应用": {
|
||||||
|
"华为": "u",
|
||||||
|
"联盟": "u"
|
||||||
|
},
|
||||||
|
"Vue": {
|
||||||
|
"vue2": "y",
|
||||||
|
"vue3": "y"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
const pageList = [
|
||||||
|
{ url: '/store/cat/index', name: '商品分类', icon: 'setting1 opacity-80' },
|
||||||
|
{ url: '/store/goods/index', name: '商品管理', icon: 'goods opacity-80' },
|
||||||
|
{ url: '/store/user/list', name: '会员管理', icon: 'user opacity-80' },
|
||||||
|
{ url: '/store/user/memberList', name: '会员等级', icon: 'lenovo opacity-80' },
|
||||||
|
{ url: '/store/order/index', name: '普通订单', icon: 'cart opacity-80' },
|
||||||
|
{ url: '/store/afterSale/index', name: '售后订单', icon: 'cart opacity-80' },
|
||||||
|
{ url: '/store/inpersonPay/index', name: '当面付订单', icon: 'cart opacity-80' },
|
||||||
|
{ url: '/store/discount/discount/index', name: '限时折扣', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '/store/discount/full_discount/index', name: '梯度折扣', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '/store/discount/full_set_redution/index', name: '满额立减', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '/store/points/setUp', name: '积分设置', icon: 'detection opacity-80' },
|
||||||
|
{ url: '/store/points/cat', name: '商品分类', icon: 'setting1 opacity-80' },
|
||||||
|
{ url: '/store/points/goods/index', name: '商品管理', icon: 'goods opacity-80' },
|
||||||
|
{ url: '/store/points/order', name: '订单管理', icon: 'lenovo opacity-80' },
|
||||||
|
{ url: '', name: '提现设置', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '', name: '分销提现', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '/store/recharge/index', name: '充值管理', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '/store/coupon/index', name: '优惠券', icon: 'chart-bubble opacity-80' },
|
||||||
|
{ url: '/store/check/list', name: '核销记录', icon: 'chart-bubble opacity-80' }
|
||||||
|
// Add more entries if needed
|
||||||
|
];
|
||||||
|
|
||||||
|
export default pageList
|
||||||
@ -1,48 +0,0 @@
|
|||||||
/**
|
|
||||||
* @des 支付方法
|
|
||||||
*/
|
|
||||||
export function paymentMethod(type) {
|
|
||||||
switch (type) {
|
|
||||||
case "1":
|
|
||||||
console.log("支付宝");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "2":
|
|
||||||
console.log("微信");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "3":
|
|
||||||
console.log("余额");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "4":
|
|
||||||
console.log("货到付款");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @des 订单类型
|
|
||||||
*/
|
|
||||||
export function getOrderType(type) {
|
|
||||||
const obj = {
|
|
||||||
1: "商城订单",
|
|
||||||
2: "秒杀订单",
|
|
||||||
3: "拼团订单",
|
|
||||||
};
|
|
||||||
return obj[type];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @des 支付类型
|
|
||||||
*/
|
|
||||||
export function getPayType(type) {
|
|
||||||
const obj = {
|
|
||||||
1: "支付宝",
|
|
||||||
2: "微信",
|
|
||||||
3: "余额",
|
|
||||||
3: "货到付款",
|
|
||||||
};
|
|
||||||
return obj[type];
|
|
||||||
}
|
|
||||||
@ -1,8 +0,0 @@
|
|||||||
export function regMobile(mobile) {
|
|
||||||
let re = /^1[2,3,4,5,6,7,8,9][0-9]{9}$/,
|
|
||||||
result = re.test(mobile);
|
|
||||||
if (!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue