|
@@ -1,16 +1,26 @@
|
|
|
<template>
|
|
|
- <VueDraggable class="draggable" ref="el" v-model="list" @sort="onChange">
|
|
|
- <div class="item" v-for="item in list" :key="item.id" @click="handleItem(item)">
|
|
|
- <img class="itemImg" src="https://4dscene.4dage.com/new4dkk/v2/lang/images/home/caseList/bwg.png" alt="" />
|
|
|
- <div class="text">{{ item.name }}</div>
|
|
|
- </div>
|
|
|
- </VueDraggable>
|
|
|
+ <div class="VueDraggable">
|
|
|
+ <VueDraggable v-if="list.length" class="draggable" ref="el" v-model="list" @sort="onChange">
|
|
|
+ <div class="item" v-for="(item, index) in list" :key="item.id" @click="handleItem(index)">
|
|
|
+ <img class="itemImg" src="https://4dscene.4dage.com/new4dkk/v2/lang/images/home/caseList/bwg.png" alt="" />
|
|
|
+ <div class="text">{{ item.name }}</div>
|
|
|
+ <CircleCloseFilled @click.stop="handleDet(index)" class="itemIcon" />
|
|
|
+ </div>
|
|
|
+ </VueDraggable>
|
|
|
+ <el-empty class="empty" v-else description="请上传现场照片" />
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, onMounted } from 'vue'
|
|
|
+import { ref, onMounted, watch } from 'vue'
|
|
|
+import { Case } from "@/store/case";
|
|
|
import { VueDraggable } from 'vue-draggable-plus'
|
|
|
-const props = defineProps({ list: Array });
|
|
|
+// import { IconRabbish } from '@element-plus/icons-vue'
|
|
|
+const props = defineProps({ sortType: Boolean });
|
|
|
+const emit = defineEmits<{
|
|
|
+ (e: "changeList", value: Case[] | null): void;
|
|
|
+ (e: "handleItem", value: Number | null): void;
|
|
|
+}>();
|
|
|
const list = ref([
|
|
|
{
|
|
|
name: 'Joao1',
|
|
@@ -103,15 +113,23 @@ const list = ref([
|
|
|
}
|
|
|
])
|
|
|
|
|
|
-const emit = defineEmits<{
|
|
|
- (e: "changeList", value: Array | null): void;
|
|
|
-}>();
|
|
|
+watch(()=>props.sortType,(newValue, oldValue)=>{
|
|
|
+ console.log('sum is changed',newValue,oldValue);
|
|
|
+ emit("changeList", list.value);
|
|
|
+},{ deep: true, immediate:true})
|
|
|
+
|
|
|
function onChange(event: any) {
|
|
|
emit("changeList", list.value);
|
|
|
}
|
|
|
-function handleItem(item) {
|
|
|
+function handleItem(index) {
|
|
|
+ emit("handleItem", index);
|
|
|
|
|
|
}
|
|
|
+function handleDet(index: Number) {
|
|
|
+ list.value.splice(index, 1)
|
|
|
+ emit("changeList", list.value);
|
|
|
+ console.log('handleDet', list.value);
|
|
|
+}
|
|
|
onMounted(() => {
|
|
|
emit("changeList", list.value);
|
|
|
// emit("update:list", props.list.value);
|
|
@@ -120,17 +138,35 @@ onMounted(() => {
|
|
|
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
+.empty{
|
|
|
+ width: 200px;
|
|
|
+}
|
|
|
.draggable{
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
justify-content: space-between;
|
|
|
.item {
|
|
|
+ position: relative;
|
|
|
// flex: 0 0 50%; /* 每个子元素占用50%的宽度 */
|
|
|
width: calc(50% - 4px);
|
|
|
margin-top: 16px;
|
|
|
.itemImg{
|
|
|
width: 100%;
|
|
|
}
|
|
|
+ .itemIcon{
|
|
|
+ width: 20px;
|
|
|
+ height: 20px;
|
|
|
+ color: var(--el-color-primary);
|
|
|
+ position: absolute;
|
|
|
+ right: -10px;
|
|
|
+ top: -10px;
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ &:hover{
|
|
|
+ .itemIcon{
|
|
|
+ display:block;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|