mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
chore:更换到主分支
This commit is contained in:
200
src/views/components/draggable/index.vue
Normal file
200
src/views/components/draggable/index.vue
Normal file
@@ -0,0 +1,200 @@
|
||||
<template>
|
||||
<div class="drag-container">
|
||||
<!-- grid列表拖拽 -->
|
||||
<el-row :gutter="25">
|
||||
<el-col :xs="25" :sm="8" :md="8" :lg="8">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>grid列表拖拽</span>
|
||||
</div>
|
||||
</template>
|
||||
<draggable
|
||||
v-model="gridLists"
|
||||
class="grid-container"
|
||||
item-key="grid"
|
||||
animation="300"
|
||||
chosenClass="chosen"
|
||||
forceFallback="true"
|
||||
>
|
||||
<template #item="{ element }">
|
||||
<div :class="'item'+' '+ 'item-' + element.num">{{ element.num }}</div>
|
||||
</template>
|
||||
</draggable>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="25" :sm="8" :md="8" :lg="8">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>单列拖拽</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 单列拖拽 -->
|
||||
<draggable
|
||||
v-model="lists"
|
||||
item-key="name"
|
||||
@change="change"
|
||||
chosen-class="chosen"
|
||||
force-fallback="true"
|
||||
animation="300"
|
||||
>
|
||||
<template #item="{ element, index }">
|
||||
<div class="item-single">{{element.name}} {{ index }}</div>
|
||||
</template>
|
||||
</draggable>
|
||||
</el-card>
|
||||
</el-col>
|
||||
|
||||
<el-col :xs="25" :sm="8" :md="8" :lg="8">
|
||||
<el-card>
|
||||
<template #header>
|
||||
<div class="card-header">
|
||||
<span>拖拽实现元素位置切换</span>
|
||||
</div>
|
||||
</template>
|
||||
<!-- 拖拽实现元素位置切换 -->
|
||||
<div class="cut-container">
|
||||
<div class="item-cut" v-for="(item,index) in cutLists" :key="index">
|
||||
<p>{{ item.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang='ts'>
|
||||
import draggable from "vuedraggable";
|
||||
import { reactive, toRefs, onMounted } from "vue";
|
||||
export default {
|
||||
components: { draggable },
|
||||
setup() {
|
||||
const myArray = reactive({
|
||||
gridLists: [
|
||||
{ grid: "cn", num: 1 },
|
||||
{ grid: "cn", num: 2 },
|
||||
{ grid: "cn", num: 3 },
|
||||
{ grid: "cn", num: 4 },
|
||||
{ grid: "cn", num: 5 },
|
||||
{ grid: "cn", num: 6 },
|
||||
{ grid: "cn", num: 7 },
|
||||
{ grid: "cn", num: 8 },
|
||||
{ grid: "cn", num: 9 },
|
||||
],
|
||||
lists: [
|
||||
{ people: "cn", id: 1, name: "www.itxst.com" },
|
||||
{ people: "cn", id: 2, name: "www.baidu.com" },
|
||||
{ people: "cn", id: 3, name: "www.taobao.com" },
|
||||
{ people: "cn", id: 4, name: "www.google.com" },
|
||||
],
|
||||
cutLists: [
|
||||
{ people: "cn", id: 1, name: "cut1" },
|
||||
{ people: "cn", id: 2, name: "cut2" },
|
||||
{ people: "cn", id: 3, name: "cut3" },
|
||||
{ people: "cn", id: 4, name: "cut4" },
|
||||
],
|
||||
});
|
||||
|
||||
const change = (evt): void => {
|
||||
console.log("evt: ", evt);
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
// 使用原生sortable实现元素位置切换
|
||||
// @ts-ignore
|
||||
new Sortable(document.querySelector(".cut-container"), {
|
||||
swap: true,
|
||||
forceFallback: true,
|
||||
chosenClass: "chosen",
|
||||
swapClass: "highlight",
|
||||
animation: 300,
|
||||
});
|
||||
});
|
||||
|
||||
return {
|
||||
...toRefs(myArray),
|
||||
change,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
/* grid列表拖拽 */
|
||||
.grid-container {
|
||||
display: grid;
|
||||
grid-template-columns: 33.3% 33.3% 33.3%;
|
||||
grid-template-rows: 33.3% 33.3% 33.3%;
|
||||
}
|
||||
|
||||
.item-single {
|
||||
font-size: 1.5em;
|
||||
height: 77px;
|
||||
text-align: center;
|
||||
line-height: 85px;
|
||||
border: 1px solid #e5e4e9;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.item-cut {
|
||||
font-size: 1.5em;
|
||||
height: 77px;
|
||||
text-align: center;
|
||||
border: 1px solid #e5e4e9;
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
.item {
|
||||
font-size: 2em;
|
||||
text-align: center;
|
||||
line-height: 100px;
|
||||
border: 1px solid #e5e4e9;
|
||||
cursor: move;
|
||||
@media screen and (max-width: 750px) {
|
||||
line-height: 90px;
|
||||
}
|
||||
}
|
||||
|
||||
.item-1 {
|
||||
background-color: #ef342a;
|
||||
}
|
||||
|
||||
.item-2 {
|
||||
background-color: #f68f26;
|
||||
}
|
||||
|
||||
.item-3 {
|
||||
background-color: #4ba946;
|
||||
}
|
||||
|
||||
.item-4 {
|
||||
background-color: #0376c2;
|
||||
}
|
||||
|
||||
.item-5 {
|
||||
background-color: #c077af;
|
||||
}
|
||||
|
||||
.item-6 {
|
||||
background-color: #f8d29d;
|
||||
}
|
||||
|
||||
.item-7 {
|
||||
background-color: #b5a87f;
|
||||
}
|
||||
|
||||
.item-8 {
|
||||
background-color: #d0e4a9;
|
||||
}
|
||||
|
||||
.item-9 {
|
||||
background-color: #4dc7ec;
|
||||
}
|
||||
|
||||
.chosen {
|
||||
border: solid 2px #3089dc !important;
|
||||
}
|
||||
</style>
|
||||
85
src/views/components/split-pane/index.vue
Normal file
85
src/views/components/split-pane/index.vue
Normal file
@@ -0,0 +1,85 @@
|
||||
<template>
|
||||
<div class="split-pane">
|
||||
<splitpane :splitSet="settingLR">
|
||||
<!-- #paneL 表示指定该组件为左侧面板 -->
|
||||
<template #paneL>
|
||||
<!-- 自定义左侧面板的内容 -->
|
||||
<div class="dv-a">A</div>
|
||||
</template>
|
||||
<!-- #paneR 表示指定该组件为右侧面板 -->
|
||||
<template #paneR>
|
||||
<!-- 再次将右侧面板进行拆分 -->
|
||||
<splitpane :splitSet="settingTB">
|
||||
<template #paneL>
|
||||
<div class="dv-b">B</div>
|
||||
</template>
|
||||
<template #paneR>
|
||||
<div class="dv-c">C</div>
|
||||
</template>
|
||||
</splitpane>
|
||||
</template>
|
||||
</splitpane>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import splitpane, {
|
||||
ContextProps,
|
||||
} from "../../../components/splitPane/index.vue";
|
||||
import { reactive } from "vue";
|
||||
export default {
|
||||
name: "split",
|
||||
components: {
|
||||
splitpane,
|
||||
},
|
||||
setup() {
|
||||
const settingLR: ContextProps = reactive({
|
||||
minPercent: 20,
|
||||
defaultPercent: 40,
|
||||
split: "vertical",
|
||||
});
|
||||
|
||||
const settingTB: ContextProps = reactive({
|
||||
minPercent: 20,
|
||||
defaultPercent: 40,
|
||||
split: "horizontal",
|
||||
});
|
||||
|
||||
return {
|
||||
settingLR,
|
||||
settingTB,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
$W: 100%;
|
||||
$H: 80vh;
|
||||
.split-pane {
|
||||
width: 98%;
|
||||
height: $H;
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
font-size: 50px;
|
||||
color: #fff;
|
||||
.dv-a,
|
||||
.dv-b,
|
||||
.dv-c {
|
||||
width: $W;
|
||||
height: $W;
|
||||
background: rgba($color: dodgerblue, $alpha: 0.8);
|
||||
line-height: $H;
|
||||
}
|
||||
.dv-b,
|
||||
.dv-c {
|
||||
line-height: 250px;
|
||||
}
|
||||
.dv-b {
|
||||
background: rgba($color: #000, $alpha: 0.8);
|
||||
}
|
||||
.dv-c {
|
||||
background: rgba($color: #ce272d, $alpha: 0.8);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user