代码更新
This commit is contained in:
@@ -3,33 +3,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {
|
||||
ref, warn, watch, watchEffect,
|
||||
onMounted,reactive
|
||||
} from 'vue';
|
||||
import {$tbShopCategory} from '@/http/yskApi/goods.js'
|
||||
import { ref, watch, onMounted,reactive } from 'vue';
|
||||
import { categoryPage } from '@/api/cateGory.js'
|
||||
const emite=defineEmits(['change','update:isShow','confirm'])
|
||||
const props = defineProps({
|
||||
showAllText:{
|
||||
type:Boolean,
|
||||
default:true
|
||||
},
|
||||
width: {
|
||||
type: [Number, String],
|
||||
default: 264
|
||||
},
|
||||
height: {
|
||||
type: [Number, String],
|
||||
default: 420
|
||||
},
|
||||
right: {
|
||||
type: [Number, String],
|
||||
default: 30
|
||||
},
|
||||
bottom: {
|
||||
type: [Number, String],
|
||||
default: 0
|
||||
},
|
||||
isShow:{
|
||||
type:Boolean,
|
||||
default:false
|
||||
@@ -38,54 +15,35 @@
|
||||
|
||||
let show = ref(props.isShow)
|
||||
|
||||
const category=reactive({
|
||||
list:[],
|
||||
})
|
||||
onMounted(()=>{
|
||||
categoryPage({
|
||||
page:1,size:200
|
||||
}).then(res=>{
|
||||
res.records.unshift({
|
||||
name:'全部',
|
||||
id:'',
|
||||
})
|
||||
category.list = [res.records]
|
||||
})
|
||||
})
|
||||
watch(()=>show.value,(newval)=>{
|
||||
emite('change',newval)
|
||||
emite('update:isShow',newval)
|
||||
})
|
||||
watch(()=>props.isShow,(newval)=>{
|
||||
console.log(newval);
|
||||
show.value=newval
|
||||
})
|
||||
|
||||
function confirm(e){
|
||||
console.log(e.value[0]);
|
||||
show.value = false
|
||||
emite('confirm',e.value[0])
|
||||
}
|
||||
function close() {
|
||||
console.log('close');
|
||||
show.value = false
|
||||
}
|
||||
|
||||
|
||||
const category=reactive({
|
||||
list:[],
|
||||
})
|
||||
onMounted(()=>{
|
||||
$tbShopCategory({
|
||||
page:0,size:200
|
||||
}).then(res=>{
|
||||
res.content.unshift({
|
||||
name:'全部',
|
||||
id:'',
|
||||
childrenList:[]
|
||||
})
|
||||
category.list=[res.content.reduce((prve, cur) => {
|
||||
prve.push(...[{
|
||||
...cur,
|
||||
name: '' + cur.name,
|
||||
childrenList:undefined
|
||||
}, ...cur.childrenList.map(v => {
|
||||
return {
|
||||
...v,
|
||||
name: '' + v.name
|
||||
}
|
||||
})])
|
||||
return prve
|
||||
}, [])]
|
||||
console.log(category.list);
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
Reference in New Issue
Block a user