-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #930 from iview/2.0
2.0
- Loading branch information
Showing
13 changed files
with
256 additions
and
12 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import env from './env' | ||
|
||
const DEV_URL = 'https://www.easy-mock.com/mock/5add9213ce4d0e69998a6f51/iview-admin/' | ||
const PRO_URL = 'https://produce.com' | ||
|
||
export default env === 'development' ? DEV_URL : PRO_URL | ||
export default process.env.NODE_ENV === 'development' ? DEV_URL : PRO_URL |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<template> | ||
<div class="drag-list-wrapper"> | ||
<div class="drag-list-con con1"> | ||
<slot name="left-title"></slot> | ||
<draggable class="drop-box1" :class="dropConClass.left" :options="options" :value="list1" @input="handleListChange($event, 'left')" @end="handleEnd($event, 'left')"> | ||
<div class="drag-list-item" v-for="(itemLeft, index) in list1" :key="`drag_li1_${index}`"> | ||
<slot name="left" :itemLeft="itemLeft">{{ itemLeft }}</slot> | ||
</div> | ||
</draggable> | ||
</div> | ||
<div class="drag-list-con con2"> | ||
<slot name="right-title"></slot> | ||
<draggable class="drop-box2" :class="dropConClass.right" :options="options" :value="list2" @input="handleListChange($event, 'right')" @end="handleEnd($event, 'right')"> | ||
<div class="drag-list-item" v-for="(itemRight, index) in list2" :key="`drag_li2_${index}`"> | ||
<slot name="right" :itemRight="itemRight">{{ itemRight }}</slot> | ||
</div> | ||
</draggable> | ||
</div> | ||
</div> | ||
</template> | ||
<script> | ||
import draggable from 'vuedraggable' | ||
export default { | ||
name: 'DragList', | ||
components: { | ||
draggable | ||
}, | ||
props: { | ||
list1: { | ||
type: Array, | ||
required: true | ||
}, | ||
list2: { | ||
type: Array, | ||
default: () => [] | ||
}, | ||
dropConClass: { | ||
type: Object, | ||
default: () => ({}) | ||
} | ||
}, | ||
data () { | ||
return { | ||
options: { group: 'drag_list' } | ||
} | ||
}, | ||
methods: { | ||
handleListChange (value, type) { | ||
if (type === 'left') this.$emit('update:list1', value) | ||
else this.$emit('update:list2', value) | ||
}, | ||
handleEnd (event, type) { | ||
const srcClassName = (event.srcElement || event.target).classList[0] | ||
const targetClassName = event.to.classList[0] | ||
let src = '' | ||
let target = '' | ||
if (srcClassName === targetClassName) { | ||
if (type === 'left') { | ||
src = 'left' | ||
target = 'left' | ||
} else { | ||
src = 'right' | ||
target = 'right' | ||
} | ||
} else { | ||
if (type === 'left') { | ||
src = 'left' | ||
target = 'right' | ||
} else { | ||
src = 'right' | ||
target = 'left' | ||
} | ||
} | ||
this.$emit('on-change', { | ||
src: src, | ||
target: target, | ||
oldIndex: event.oldIndex, | ||
newIndex: event.newIndex | ||
}) | ||
} | ||
} | ||
} | ||
</script> | ||
<style lang="less"> | ||
.drag-list-wrapper{ | ||
height: 100%; | ||
.drag-list-con{ | ||
width: 50%; | ||
float: left; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import DragList from './drag-list.vue' | ||
export default DragList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
import Mock from 'mockjs' | ||
import { login, logout, getUserInfo } from './login' | ||
import { getTableData } from './data' | ||
import { getTableData, getDragList } from './data' | ||
|
||
// 登录相关和获取用户信息 | ||
Mock.mock(/\/login/, login) | ||
Mock.mock(/\/get_info/, getUserInfo) | ||
Mock.mock(/\/logout/, logout) | ||
Mock.mock(/\/get_table_data/, getTableData) | ||
Mock.mock(/\/get_drag_list/, getDragList) | ||
|
||
export default Mock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
<template> | ||
<div> | ||
<Card> | ||
<div class="drag-box-card"> | ||
|
||
<!-- 切记设置list1和list2属性时,一定要添加.sync修饰符 --> | ||
<drag-list :list1.sync="list1" :list2.sync="list2" :dropConClass="dropConClass" @on-change="handleChange"> | ||
<h3 slot="left-title">待办事项</h3> | ||
<Card class="drag-item" slot="left" slot-scope="left">{{ left.itemLeft.name }}</Card> | ||
<h3 slot="right-title">完成事项</h3> | ||
<Card class="drag-item" slot="right" slot-scope="right">{{ right.itemRight.name }}</Card> | ||
</drag-list> | ||
|
||
</div> | ||
<div class="handle-log-box"> | ||
<h3>操作记录</h3> | ||
<div class="handle-inner-box"> | ||
<p v-for="(item, index) in handleList" :key="`handle_item_${index}`">{{ item }}</p> | ||
</div> | ||
</div> | ||
<div class="res-show-box"> | ||
<pre>{{ list1 }}</pre> | ||
</div> | ||
<div class="res-show-box"> | ||
<pre>{{ list2 }}</pre> | ||
</div> | ||
</Card> | ||
</div> | ||
</template> | ||
<script> | ||
import DragList from '_c/drag-list' | ||
import { getDragList } from '@/api/data' | ||
export default { | ||
name: 'drag_list_page', | ||
components: { | ||
DragList | ||
}, | ||
data () { | ||
return { | ||
list1: [], | ||
list2: [], | ||
dropConClass: { | ||
left: ['drop-box', 'left-drop-box'], | ||
right: ['drop-box', 'right-drop-box'] | ||
}, | ||
handleList: [] | ||
} | ||
}, | ||
methods: { | ||
handleChange ({ src, target, oldIndex, newIndex }) { | ||
this.handleList.push(`${src} => ${target}, ${oldIndex} => ${newIndex}`) | ||
} | ||
}, | ||
mounted () { | ||
getDragList().then(res => { | ||
this.list1 = res.data | ||
this.list2 = [res.data[0]] | ||
}) | ||
} | ||
} | ||
</script> | ||
<style lang="less"> | ||
.drag-box-card{ | ||
display: inline-block; | ||
width: 600px; | ||
height: 560px; | ||
.drag-item{ | ||
margin: 10px; | ||
} | ||
h3{ | ||
padding: 10px 15px; | ||
} | ||
.drop-box{ | ||
border: 1px solid #eeeeee; | ||
height: 455px; | ||
border-radius: 5px; | ||
} | ||
.left-drop-box{ | ||
margin-right: 10px; | ||
} | ||
.right-drop-box{ | ||
// | ||
} | ||
} | ||
.handle-log-box{ | ||
display: inline-block; | ||
margin-left: 20px; | ||
border: 1px solid #eeeeee; | ||
vertical-align: top; | ||
width: 200px; | ||
height: 500px; | ||
h3{ | ||
padding: 10px 14px; | ||
} | ||
.handle-inner-box{ | ||
height: ~"calc(100% - 44px)"; | ||
overflow: auto; | ||
p{ | ||
padding: 14px 0; | ||
margin: 0 14px; | ||
border-bottom: 1px dashed #eeeeee; | ||
} | ||
} | ||
} | ||
.res-show-box{ | ||
display: inline-block; | ||
margin-left: 20px; | ||
border: 1px solid #eeeeee; | ||
vertical-align: top; | ||
width: 350px; | ||
height: 570px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters