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

拖动排序

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