代码更新

This commit is contained in:
GaoHao
2025-02-26 19:46:20 +08:00
parent 7519ffced3
commit b4a0393d2d
413 changed files with 7483 additions and 60762 deletions

View File

@@ -1,128 +0,0 @@
<template>
<view class="item">
<view class="u-flex u-row-between">
<view>#{{index+1}} {{data.name}}</view>
<view class="color-666 u-font-24 id">ID:{{data.id}}</view>
</view>
<view class="u-m-t-16 color-666 u-font-24 u-p-b-24 border-bottom">
添加时间
<uni-dateformat :date="data.createdAt"></uni-dateformat>
</view>
<view class="u-m-t-24">
<view v-for="(spec,specIndex) in data.specList" :key="specIndex">
<view class="font-bold " :class="{'u-m-t-32':specIndex>0}"> {{spec.name}}</view>
<view class="u-m-t-24 bg-gray u-flex u-flex-wrap options u-p-24">
<view class="u-flex option" v-for="(option,optionIndex) in spec.value" :key="optionIndex" @tap="statusClick(optionIndex)">
{{option}}
<!-- <view class="sellout" v-if="option.sellOut">已售罄</view>
<view class="tag-primary tag" v-if="option.status">上架中</view>
<view class="tag-gray tag" v-else>上架中</view> -->
</view>
</view>
</view>
</view>
<view class="u-m-t-20 u-flex u-row-right btns">
<my-button @tap="del" :plain="btnProps.plain" :fontSize="btnProps.fontSize" :width="btnProps.width" :height="btnProps.height" type="cancel" :shape="btnProps.shape" >删除</my-button>
<my-button @tap="edit" :plain="btnProps.plain" :fontSize="btnProps.fontSize" :width="btnProps.width" :height="btnProps.height" :shape="btnProps.shape">编辑</my-button>
</view>
</view>
</template>
<script setup>
import { reactive, ref } from 'vue';
import myButton from "@/components/my-components/my-button.vue"
import go from '@/commons/utils/go.js'
const props=defineProps({
index:{
type:Number,
},
data:{
type:Object,
default:()=>{
return {}
}
}
})
const emits=defineEmits(['del','edit','statusClick'])
function del(){
emits('del',props.index)
}
function edit(){
uni.$emit('edit:spec',props.data)
uni.setStorageSync('spec',props.data)
go.to('PAGES_PRODUCT_GUIGE_ADD', {
type: 'edit'
})
// emits('edit',props.index)
}
function statusClick(optionIndex){
emits('statusClick',[props.index,optionIndex])
}
const btnProps=reactive({
shape:'circle',
width:120,
height:48,
fontSize:24,
plain:true
})
</script>
<style lang="scss" scoped>
.btns{
gap: 0 20rpx;
}
.item{
background: #FFFFFF;
padding: 32rpx 24rpx;
border-radius: 18rpx 18rpx 18rpx 18rpx;
margin-bottom: 30rpx;
.id{
background: #F4F4F4;
padding: 6rpx 10rpx;
border-radius: 8rpx 8rpx 8rpx 8rpx;
}
.options{
gap: 10rpx 50rpx;
.option{
padding: 12rpx 40rpx;
background: #F0F2F5;
border-radius: 4rpx;
font-size: 24rpx;
position: relative;
color: #666;
overflow: hidden;
.tag{
position: absolute;
right: 0;
top: 0;
font-size: 12rpx;
right: 0;
padding: 2rpx 4rpx;
border-radius: 0rpx 4rpx 4rpx 4rpx;
}
.sellout{
position: absolute;
left: 0;
right: 0;
bottom: 0;
background-color: rgb(147, 147, 153);
color: #fff;
text-align: center;
font-size: 20rpx;
}
.tag-primary{
background-color: $my-main-color;
color: #fff;
}
.tag-gray{
background-color: rgb(147, 147, 153);
color: #fff;
}
}
}
}
</style>

View File

@@ -0,0 +1,56 @@
<template>
<view style="display: flex;line-height: 60rpx;align-items: center;justify-content: space-between;" @click="clickNode(data)">
<view style="display: flex;align-items: center;">
<view v-if="data.children && data.children.length">
<uni-icons v-if="data.isOpen" type="bottom" size="16" color="#2A5EFF"></uni-icons>
<uni-icons v-else type="forward" size="16"></uni-icons>
</view>
<view style="padding-left: 10px;">{{ data.name }}</view>
</view>
<view style="display: flex;align-items: center;justify-content: space-between;">
<view @tap.stop="del" style="font-size:24rpx;color: #999;">删除</view>
<view @tap.stop="edit" style="font-size:24rpx;color: #318AFE;margin-left: 20rpx;">编辑</view>
</view>
</view>
<view v-if="data.children && data.children.length && data.isOpen" style="margin-left: 16px;padding: 10rpx;line-height: 60rpx;">
<tree-item v-for="(child,index) in data.children" :key="child.id" :data="child"
@clickNode="clickNode"></tree-item>
</view>
</template>
<script setup>
import { reactive, ref } from 'vue';
import treeItem from './tree-item.vue'
import go from '@/commons/utils/go.js'
const props=defineProps({
data:{
type:Object,
default:()=>{
return {}
}
}
})
const emits=defineEmits(['del','edit'])
function clickNode(item) {
item.isOpen = !item.isOpen
}
function del(){
emits('del',props.index)
}
function edit(){
uni.setStorageSync('spec',props.data)
go.to('PAGES_PRODUCT_GUIGE_ADD', {
type: 'edit'
})
}
</script>
<style lang="scss" scoped>
</style>

View File

@@ -1,37 +1,16 @@
<template>
<view class="u-p-30 min-page bg-gray">
<view v-for="(item,index) in pageData.list" :key="index">
<specifications-item @statusClick="specificationsStatusClick" @del="delSpecifications" @edit="editSpecifications" :data="item" :index="index"></specifications-item>
<view class="min-page bg-gray" style="padding: 30rpx 30rpx 200rpx 30rpx;">
<view style="background-color: #fff;border-radius: 10rpx;">
<view style="padding: 10px 10px 0 10px;">
<uni-easyinput suffixIcon="search" v-model="pageData.query.name" placeholder="请输入规格搜索" @iconClick="search"
@blur="search" trim></uni-easyinput>
</view>
<view v-for="(item,index) in pageData.list" :key="index" style="padding: 10rpx;" v-if="pageData.loading">
<tree-item @del="delSpecifications(index)" :data="item" ></tree-item>
</view>
</view>
<view class="u-m-t-44">
<my-pagination :size="pageData.query.size" :totalElements="pageData.totalElements" @change="pageChange"></my-pagination>
<view style="height: 200rpx;"></view>
</view>
<my-model :showBtn="modelData.showBtn" ref="model" @confirm="modelConfirm" :title="modelData.title" :desc="modelData.desc">
<template #desc>
<view class="u-p-30 u-m-t-40 u-p-b-60" v-if="specificationsData">
<view class="u-flex u-row-between">
<view>当前状态</view>
<view class="u-flex-1 u-p-l-60">
<uni-data-checkbox v-model="specificationsData.status"
@change="specificationsStatusChange"
:localdata="statusData"></uni-data-checkbox>
</view>
</view>
<view class="u-m-t-30 u-p-t-30" style="border-top: 1px solid rgb(245, 245, 245);">
<view class="u-flex u-row-between">
<view>售罄</view>
<my-switch @change="specificationsSellOutChange" v-model="specificationsData.sellOut"></my-switch>
</view>
</view>
</view>
</template>
</my-model>
<view class="fixed-b">
<my-button @tap="toAdd" shape="circle">添加规格组</my-button>
</view>
@@ -39,82 +18,97 @@
</template>
<script setup>
import {
reactive,
ref
} from 'vue';
import { reactive, ref } from 'vue';
import {onLoad,onShow} from '@dcloudio/uni-app'
import go from '@/commons/utils/go.js';
import myPagination from '@/components/my-components/my-pagination.vue'
import myModel from '@/components/my-components/my-model.vue'
import myButton from '@/components/my-components/my-button.vue'
import mySwitch from '@/components/my-components/my-switch.vue'
import specificationsItem from './components/specifications-item.vue'
import {$productSpec} from '@/http/yskApi/goods.js'
import treeItem from './components/tree-item.vue'
import { getSpecList,delSpec } from '@/api/product.js'
const statusData=[
{
text: '上架中',
value: 1
},
{
text: '已下架',
value: 0
}
]
const model = ref(null)
const specificationsData=reactive({
index:null,
optionIndex:null,
status:1,
sellOut:false
})
function specificationsSellOutChange(isSellOut){
const {index,optionIndex}=specificationsData
if(index!==null&&optionIndex!==null){
pageData.list[index].options[optionIndex].sellOut=isSellOut
}
}
function specificationsStatusChange(e){
const {index,optionIndex}=specificationsData
if(index!==null&&optionIndex!==null){
pageData.list[index].options[optionIndex].status=e.detail.value
}
}
function modelOpen(){
model.value.open()
}
function modelClose(){
model.value.close()
}
function modelConfirm(){
console.log('modelConfirm');
modelClose()
}
const modelData = reactive({
title: '',
desc: '',
showBtn:true
})
const pageData = reactive({
loading: true,
query:{
page: 0,
size:10
name: ""
},
totalElements:0,
list: []
})
onShow(()=>{
init()
})
function init(){
getSpecList(pageData.query).then(res=>{
pageData.list=res
})
pageData.list.map(item=>{
filterData(item)
})
}
/**
* 搜索
*/
function search() {
if( pageData.query.name == ""){
init()
return false;
}
pageData.loading = false
pageData.list = filterSearch(pageData.list, pageData.query.name || '')
setTimeout(() => {
pageData.loading = true
}, 10)
}
/**
* 搜索数据处理
* @param {Object} data
* @param {Object} keyword
*/
function filterSearch(data, keyword) {
return data.filter(node => {
// 判断当前节点是否匹配筛选条件
if (node.name.includes(keyword)) {
if(!node.type){
node.isOpen=true
}
return true;
}
// 递归过滤子节点
if (node.children && node.children.length) {
node.children = filterSearch(node.children, keyword);
node.isOpen=true
return node.children.length > 0;
}
return false;
});
}
/**
* 请求获取数据处理
* @param {Object} item
*/
function filterData (item) {
item.isOpen = false
if( item.children && item.children.length > 0 ){
item.children.map(item=>{
filterData(item)
})
}
}
/**
* 删除规格
* @param {Object} index
*/
function delSpecifications(index){
uni.showModal({
title: '提示',
content: '删除后使用此模板的商品将取消此规格,是否继续?',
content: '删除后使用此规格的商品将取消此规格,是否继续?',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
$productSpec.del([pageData.list[index].id]).then(res=>{
delSpec(pageData.list[index].id).then(res=>{
uni.showToast({
title:'删除成功',
icon:'none'
@@ -125,52 +119,15 @@
}
});
}
function specificationsStatusClick(arr){
console.log(arr);
modelData.title=pageData.list[arr[0]].name
modelData.desc=''
modelData.showBtn=false
specificationsData.status=1
specificationsData.sellOut=false
specificationsData.index=arr[0]
specificationsData.optionIndex=arr[1]
// modelOpen()
}
function pageChange(page) {
pageData.query.page=page-1
init()
}
let emitName = 'guigeEdit'
uni.$on(emitName, function(data) {
console.log(data);
})
function editSpecifications(index){
uni.setStorageSync('guige', pageData.list[index])
emitName='guigeEdit'
go.to('PAGES_PRODUCT_GUIGE_ADD', {
emitName: emitName
})
}
/**
* 新增规格
*/
function toAdd() {
// uni.setStorageSync('guige', FormData.specificationsGroup)
go.to('PAGES_PRODUCT_GUIGE_ADD')
}
function init(){
$productSpec.get(pageData.query).then(res=>{
console.log(res);
pageData.list=res.content
pageData.totalElements=res.totalElements
})
}
onShow(()=>{
init()
})
</script>
<style lang="scss">