Commit 68cc1cb7 authored by 刘文虎's avatar 刘文虎

拖动排序

parent ffbd4520
......@@ -4,6 +4,7 @@ export function getList(data) {
url: `/rest/user/bookClassification`,
method: 'GET',
data,
noLoading:true
})
}
......@@ -11,7 +12,8 @@ export function sortList(data) {
return request({
url: `/rest/user/bookClassification/sort`,
method: 'POST',
data
data,
noLoading:true
})
}
......@@ -27,6 +29,7 @@ export function update(data) {
return request({
url: `/rest/user/bookClassification`,
method: 'POST',
data
data,
noLoading:true
})
}
\ No newline at end of file
......@@ -183,7 +183,8 @@
"style" :
{
"navigationBarTitleText": "收支设置",
"enablePullDownRefresh": false
"enablePullDownRefresh": false,
"disableScroll": true
}
}
......
......@@ -5,40 +5,33 @@
<scroll-view :scroll-y="pageInfo.scrollY" class="product-section">
<view class="list">
<uni-swipe-action>
<view class="swipe-action-outside" v-for="(item, index) in optionLists" :key="item.guid">
<uni-swipe-action-item :right-options="options" bg-color="#f6f7fa" :index="item.guid" @click="onClick($event,item,index)" @change="swipeChange($event, index)">
<view
class="row list-row"
:data-index="index"
@longpress="longpress($event, item, index)"
@touchmove="dragMove"
@touchend="dragEnd($event, item)"
:class="{ 'ready-place': pageInfo.readyPlaceIndex === index }"
:id="`item-view-${item.guid}`"
:style="'height: ' + pageInfo.rowHeight + 'px;'"
@click.stop="closeAll"
>
<view class="item-view" @click.stop="clickCell(item,index)">
<view class="left-view">
<view class="image-view"><image :src="billStaticBaseUrl + item.icon" v-if="item.icon"></image></view>
<view class="name-view">{{ item.label }}</view>
</view>
</view>
<view class="swipe-action-outside" v-for="(item, index) in optionLists" :key="item.guid">
<uni-swipe-action-item :right-options="options" bg-color="#f6f7fa" :index="item.guid" @click="onClick($event,item,index)" @change="swipeChange($event, index)">
<view
class="row list-row"
:data-index="index"
@longpress="longpress($event, item, index)"
@touchmove="dragMove"
@touchend="dragEnd($event, item)"
:class="{ 'ready-place': pageInfo.readyPlaceIndex === index }"
:id="`item-view-${item.guid}`"
:style="'height: ' + pageInfo.rowHeight + 'px;'"
@click.stop="closeAll"
>
<view class="item-view" @click.stop="clickCell(item, index)">
<view class="left-view">
<view class="image-view"><image :src="billStaticBaseUrl + item.icon" v-if="item.icon"></image></view>
<view class="name-view">{{ item.label }}</view>
</view>
</uni-swipe-action-item>
</view>
</view>
</uni-swipe-action-item>
</view>
</uni-swipe-action>
</view>
</scroll-view>
<movable-area class="movable-area" :style="'display:' + movableViewInfo.showClass + '; height:' + pageInfo.scrollHeight + '%'">
<movable-view
class="row list-row movable-row"
:out-of-bounds="true"
damping="999"
:style="'height:' + pageInfo.rowHeight + 'px;'"
direction="vertical"
:y="movableViewInfo.y"
>
<movable-area class="movable-area" :class="{ 'movable-area-active': pageInfo.beginMove }">
<movable-view class="row list-row movable-row" :out-of-bounds="true" damping="999" :style="movableViewStyle" direction="vertical" :y="movableViewInfo.y">
<view class="item-view">
<view class="left-view">
<view class="image-view"><image :src="billStaticBaseUrl + movableViewInfo.data.icon" class="image-view" v-if="movableViewInfo.data.icon"></image></view>
......@@ -53,8 +46,8 @@
</template>
<script>
import UniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue';
import UniSwipeActionItem from '@/components/uni-swipe-action-item/uni-swipe-action-item.vue';
import UniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue';
import UniSwipeActionItem from '@/components/uni-swipe-action-item/uni-swipe-action-item.vue';
import PopInput from '@/components/pop-input-view';
import { billStaticBaseUrl } from '@/utils/config.js';
export default {
......@@ -63,7 +56,7 @@ export default {
components: {
UniSwipeAction,
UniSwipeActionItem,
PopInput,
PopInput
},
data() {
return {
......@@ -101,6 +94,7 @@ export default {
selectedIndex: null, // 放置的位置
beginMove: false
},
beginMove: false,
top: 0,
systemInfo: {}
};
......@@ -114,12 +108,21 @@ export default {
deep: true
}
},
computed: {},
computed: {
movableViewStyle() {
let style = `height: ${this.pageInfo.rowHeight}px`;
return style;
}
},
mounted() {
this.systemInfo = uni.getSystemInfoSync();
this.optionLists = [...this.list];
},
methods: {
beginMoveChange(){
this.beginMove=!this.beginMove
this.pageInfo.beginMove=!this.pageInfo.beginMove
},
clickCell(item) {
let flag = true;
this.optionLists.map(el => {
......@@ -131,13 +134,13 @@ export default {
this.toEdit(item);
}
},
onClick(e,item) {
onClick(e, item) {
console.log(e);
console.log('点击了' + (e.position === 'left' ? '左侧' : '右侧') + e.content.text + '按钮');
if(e.position === 'right'){
if(e.content.text==='删除'){
this.beforeDelete(item)
}else if(e.content.text==='编辑'){
if (e.position === 'right') {
if (e.content.text === '删除') {
this.beforeDelete(item);
} else if (e.content.text === '编辑') {
this.toEdit(item);
}
}
......@@ -157,28 +160,28 @@ export default {
}
});
uni.$once(`input-sure-payments-setting`, res => {
this.optionLists.map(el=>{
if(el.id===item.id){
el.label=res.content
this.optionLists.map(el => {
if (el.id === item.id) {
el.label = res.content;
}
})
});
this.$emit('onEdit', item);
});
},
handleConfirm() {
this.optionLists.map(item=>{
if(item.id===this.readyDeleteItem.id){
item.show=false
this.optionLists.map(item => {
if (item.id === this.readyDeleteItem.id) {
item.show = false;
}
})
});
this.$emit('onDelete', this.readyDeleteItem);
},
handleCancel() {
this.optionLists.map(item=>{
if(item.id===this.readyDeleteItem.id){
item.show=false
this.optionLists.map(item => {
if (item.id === this.readyDeleteItem.id) {
item.show = false;
}
})
});
},
beforeDelete(item) {
......@@ -194,9 +197,9 @@ export default {
},
closeAll() {
if (this.optionLists.length) {
this.optionLists.map(item=>{
item.show=false
})
this.optionLists.map(item => {
item.show = false;
});
}
},
async longpress(event, item) {
......@@ -212,6 +215,7 @@ export default {
.select(className);
info.boundingClientRect(data => {
//data - 各种参数
console.log('boundingClientRect', data);
this.top = data.top;
this.dragStart(event, item);
}).exec();
......@@ -221,6 +225,8 @@ export default {
console.log('dragStart');
// 开始本次拖拽
this.pageInfo.beginMove = true;
console.log('beginMove', this.beginMove);
// this.$set(this.pageInfo,'beginMove',true)
// 本次移动的view真实下标
var currentMoveIndex = (this.optionLists || []).findIndex(x => x.guid === item.guid);
console.log('currentMoveIndex', currentMoveIndex);
......@@ -243,7 +249,10 @@ export default {
movableViewInfo.data = this.optionLists[startIndex];
movableViewInfo.showClass = 'inline';
(this.movableViewInfo = movableViewInfo), (this.pageInfo = pageInfo);
this.movableViewInfo = movableViewInfo;
this.pageInfo = pageInfo;
console.log('movableViewInfo', this.movableViewInfo);
console.log('pageInfo', this.pageInfo.beginMove);
},
// 拖拽移动(按住不松)
dragMove(event) {
......@@ -284,7 +293,7 @@ export default {
}
},
// 拖拽结束(松手)
dragEnd(event,item) {
dragEnd(event, item) {
// 禁止无效的move
if (this.pageInfo.beginMove) {
console.log('dragEnd');
......@@ -350,6 +359,7 @@ export default {
}
.zhuti {
width: 100%;
height: 100%;
position: absolute;
top: 0;
bottom: 0;
......@@ -381,18 +391,20 @@ export default {
left: 0;
z-index: 10;
width: 100%;
// background-color: yellow;
visibility: hidden;
height: 100%;
}
.movable-area-active {
visibility: unset;
display: inline-block;
// display: block;
}
.movable-row {
box-shadow: #d9d9d9 0 0 20px;
.item-view {
}
}
.col1 {
width: 90%;
}
.col3 {
width: 6%;
color: #3c63eb;
}
.ready-place {
background: rgba(238, 240, 254, 0.6);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment