Commit aeade295 by pangchong

feat: 新增右滑

parent 9a74632b
...@@ -65,6 +65,18 @@ ...@@ -65,6 +65,18 @@
</up-checkbox> </up-checkbox>
</template> </template>
</up-checkbox-group> </up-checkbox-group>
<up-swipe-action v-else-if="getShowActions">
<template v-for="(item, index) in dataList" :key="index">
<up-swipe-action-item
closeOnClick
:threshold="50"
@click="(action) => handleAction(action, item, index)"
:options="getActionOptions"
>
<slot :item="item" :index="index"></slot>
</up-swipe-action-item>
</template>
</up-swipe-action>
<template v-for="(item, index) in dataList" :key="index" v-else> <template v-for="(item, index) in dataList" :key="index" v-else>
<slot :item="item" :index="index"></slot> <slot :item="item" :index="index"></slot>
</template> </template>
...@@ -80,14 +92,24 @@ ...@@ -80,14 +92,24 @@
</template> </template>
<!-- 消息提醒 --> <!-- 消息提醒 -->
<up-toast ref="uToastRef"></up-toast> <up-toast ref="uToastRef"></up-toast>
<up-modal
:width="250"
content="确认删除吗?"
:show="showConfirm"
showCancelButton
closeOnClickOverlay
@confirm="handleConfirm"
@cancel="showConfirm = false"
@close="showConfirm = false"
></up-modal>
</z-paging> </z-paging>
</template> </template>
<script setup> <script setup>
import { filterEmptyValues } from 'mocp/utils/tool' import { filterEmptyValues } from 'mocp/utils/tool'
import { computed, nextTick, onUnmounted, ref, watch } from 'vue' import { computed, nextTick, onUnmounted, reactive, ref, watch } from 'vue'
const dataList = ref([]) const dataList = ref([])
const es = defineEmits(['handleQuery', 'handleLeftClick', 'handleRightClick', 'handleFooterClick', 'handleChooseData']) const es = defineEmits(['handleQuery', 'handleLeftClick', 'handleRightClick', 'handleFooterClick', 'handleChooseData', 'handleDelete'])
const paging = ref() const paging = ref()
const ps = defineProps({ const ps = defineProps({
showEmpty: { showEmpty: {
...@@ -276,8 +298,46 @@ const ps = defineProps({ ...@@ -276,8 +298,46 @@ const ps = defineProps({
pageSize: { pageSize: {
type: Number, type: Number,
default: 10 default: 10
},
//右滑操作菜单
showDelete: {
type: Boolean,
default: false
} }
}) })
//右滑动操作菜单
const showConfirm = ref(false)
const actionItem = reactive({
item: null,
index: null
})
const getShowActions = computed(() => {
return ps.showDelete
})
const handleConfirm = () => {
showConfirm.value = false
es('handleDelete', actionItem.item, actionItem.index)
}
const handleAction = (action, item, index) => {
if (getActionOptions.value[action['index']].name == 'delete') {
showConfirm.value = true
actionItem.item = item
actionItem.index = index
}
}
const getActionOptions = computed(() => {
const actions = []
if (ps.showDelete) {
actions.push({
text: '移除',
name: 'delete',
style: {
backgroundColor: '#f53f3f'
}
})
}
return actions
})
// z-page样式 // z-page样式
const getPagingStyle = computed(() => { const getPagingStyle = computed(() => {
return { return {
...@@ -387,6 +447,7 @@ const openToast = (params) => { ...@@ -387,6 +447,7 @@ const openToast = (params) => {
uToastRef.value?.show(params) uToastRef.value?.show(params)
}) })
} }
uni.$on('useMessage', (params) => openToast(params)) uni.$on('useMessage', (params) => openToast(params))
onUnmounted(() => { onUnmounted(() => {
uni.$off('useMessage', openToast) uni.$off('useMessage', openToast)
...@@ -447,6 +508,20 @@ export default { ...@@ -447,6 +508,20 @@ export default {
:deep(.u-checkbox__icon-wrap) { :deep(.u-checkbox__icon-wrap) {
min-width: 18px; min-width: 18px;
} }
//右滑动菜单
:deep(.u-swipe-action-item):has(.item) {
border-radius: 12rpx;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
}
:deep(.u-swipe-action-item__right) {
top: 1px;
bottom: 1px;
right: 1px;
border-radius: 0 12rpx 12rpx 0;
}
} }
.cancel { .cancel {
font-size: 28rpx; font-size: 28rpx;
......
...@@ -19,19 +19,6 @@ ...@@ -19,19 +19,6 @@
> >
<template #default="{ item }"> <template #default="{ item }">
<template v-for="option in item.basicInfoList" :key="option.id"> <template v-for="option in item.basicInfoList" :key="option.id">
<up-swipe-action>
<up-swipe-action-item
@click="handleDelete(item)"
:options="[
{
text: '移除',
style: {
backgroundColor: '#f53f3f'
}
}
]"
></up-swipe-action-item>
</up-swipe-action>
<view class="item" @tap="goDetails(item, option)"> <view class="item" @tap="goDetails(item, option)">
<view class="item-title"> <view class="item-title">
<view class="left"> <view class="left">
...@@ -129,10 +116,6 @@ const goDetails = (data, option) => { ...@@ -129,10 +116,6 @@ const goDetails = (data, option) => {
windDamageManagementStore.setState('weatherSource', data.weatherSource) windDamageManagementStore.setState('weatherSource', data.weatherSource)
uni.$mocpJump.navigateTo(taskList[option.taskType].url) uni.$mocpJump.navigateTo(taskList[option.taskType].url)
} }
//删除
const handleDelete = (data) => {
console.log(data)
}
const handleQuery = ({ res }) => { const handleQuery = ({ res }) => {
myToDoStore.setState('windDamageManagementNum', myToDoStore.countWindDamageManagementNum(res.data)) myToDoStore.setState('windDamageManagementNum', myToDoStore.countWindDamageManagementNum(res.data))
} }
......
...@@ -16,19 +16,6 @@ ...@@ -16,19 +16,6 @@
auto auto
> >
<template #default="{ item }"> <template #default="{ item }">
<up-swipe-action>
<up-swipe-action-item
@click="handleDelete(item)"
:options="[
{
text: '移除',
style: {
backgroundColor: '#f53f3f'
}
}
]"
></up-swipe-action-item>
</up-swipe-action>
<view class="item" @tap="goDetails(item)"> <view class="item" @tap="goDetails(item)">
<view class="item-title"> <view class="item-title">
<view class="desc"> <view class="desc">
...@@ -68,10 +55,6 @@ const goDetails = (data) => { ...@@ -68,10 +55,6 @@ const goDetails = (data) => {
id: data.id id: data.id
}) })
} }
//删除
const handleDelete = (data) => {
console.log(data)
}
const handleQuery = ({ res }) => { const handleQuery = ({ res }) => {
myToDoStore.setState('appraisalRecordNum', parseInt(res.total) || 0) myToDoStore.setState('appraisalRecordNum', parseInt(res.total) || 0)
} }
......
...@@ -16,19 +16,6 @@ ...@@ -16,19 +16,6 @@
auto auto
> >
<template #default="{ item }"> <template #default="{ item }">
<up-swipe-action>
<up-swipe-action-item
@click="handleDelete(item)"
:options="[
{
text: '移除',
style: {
backgroundColor: '#f53f3f'
}
}
]"
></up-swipe-action-item>
</up-swipe-action>
<view class="item" @tap="goDetails(item)"> <view class="item" @tap="goDetails(item)">
<view class="item-title"> <view class="item-title">
<view class="left"> <view class="left">
...@@ -80,10 +67,6 @@ const ps = defineProps({ ...@@ -80,10 +67,6 @@ const ps = defineProps({
const goDetails = (data) => { const goDetails = (data) => {
uni.$mocpJump.navigateTo('/panel/assign-work/details', { id: data.id }) uni.$mocpJump.navigateTo('/panel/assign-work/details', { id: data.id })
} }
//删除
const handleDelete = (data) => {
console.log(data)
}
const handleQuery = ({ res }) => { const handleQuery = ({ res }) => {
myToDoStore.setState('assignWorkNum', parseInt(res.data.total) || 0) myToDoStore.setState('assignWorkNum', parseInt(res.data.total) || 0)
} }
......
...@@ -13,19 +13,6 @@ ...@@ -13,19 +13,6 @@
auto auto
> >
<template #default="{ item }"> <template #default="{ item }">
<up-swipe-action>
<up-swipe-action-item
@click="handleDelete(item)"
:options="[
{
text: '移除',
style: {
backgroundColor: '#f53f3f'
}
}
]"
></up-swipe-action-item>
</up-swipe-action>
<view class="item" @tap="goDetails(item)"> <view class="item" @tap="goDetails(item)">
<view class="item-title"> <view class="item-title">
<view class="left"> <view class="left">
...@@ -76,10 +63,6 @@ const goDetails = (data) => { ...@@ -76,10 +63,6 @@ const goDetails = (data) => {
moveDecisionStore.setState('details', data) moveDecisionStore.setState('details', data)
}) })
} }
//删除
const handleDelete = (data) => {
console.log(data)
}
const handleQuery = ({ res }) => { const handleQuery = ({ res }) => {
myToDoStore.setState('moveDecisionNum', parseInt(res.data.total) || 0) myToDoStore.setState('moveDecisionNum', parseInt(res.data.total) || 0)
} }
......
...@@ -13,19 +13,6 @@ ...@@ -13,19 +13,6 @@
auto auto
> >
<template #default="{ item }"> <template #default="{ item }">
<up-swipe-action>
<up-swipe-action-item
@click="handleDelete(item)"
:options="[
{
text: '移除',
style: {
backgroundColor: '#f53f3f'
}
}
]"
></up-swipe-action-item>
</up-swipe-action>
<view class="item" @tap="goDetails(item)"> <view class="item" @tap="goDetails(item)">
<view class="item-title"> <view class="item-title">
<view class="left"> <view class="left">
...@@ -82,10 +69,6 @@ const goDetails = (data) => { ...@@ -82,10 +69,6 @@ const goDetails = (data) => {
technologyEvaluationStore.setState('details', data) technologyEvaluationStore.setState('details', data)
}) })
} }
//删除
const handleDelete = (data) => {
console.log(data)
}
const handleQuery = ({ res }) => { const handleQuery = ({ res }) => {
myToDoStore.setState('technologyEvaluationNum', parseInt(res.data.total) || 0) myToDoStore.setState('technologyEvaluationNum', parseInt(res.data.total) || 0)
} }
......
...@@ -49,17 +49,11 @@ const confirm = () => { ...@@ -49,17 +49,11 @@ const confirm = () => {
} }
</script> </script>
<style lang="scss"> <style lang="scss">
.item {
margin-bottom: 0;
}
.u-swipe-action { .u-swipe-action {
margin-bottom: 16rpx; margin-bottom: 16rpx;
} }
</style> </style>
<style lang="scss" scoped> <style lang="scss" scoped>
.item:last-child {
margin-bottom: 0;
}
:deep(.u-collapse-item) { :deep(.u-collapse-item) {
margin-bottom: 16rpx; margin-bottom: 16rpx;
.u-cell__body { .u-cell__body {
......
:deep(.u-swipe-action-item) {
border-radius: 12rpx;
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
.item {
margin-bottom: 0;
}
}
.item { .item {
padding: 24rpx; padding: 24rpx;
margin-bottom: 16rpx;
border-radius: 12rpx; border-radius: 12rpx;
background: linear-gradient(#e6eeff, #ffffff, #ffffff); background: linear-gradient(#e6eeff, #ffffff, #ffffff);
margin-bottom: 16rpx;
&:last-child {
margin-bottom: 0;
}
&-title { &-title {
display: flex; display: flex;
align-items: center; align-items: center;
......
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