|
|
@@ -1,74 +1,66 @@
|
|
|
<template>
|
|
|
- <div class="nut-addresslist">
|
|
|
- <general-shell
|
|
|
- v-if="!longPressEdition && !swipeEdition"
|
|
|
- v-for="(item, index) of dataArray"
|
|
|
- :key="'general' + index"
|
|
|
- :item="item"
|
|
|
- @handleDelIcon="clickDelIcon"
|
|
|
- @handleEditIcon="clickEditIcon"
|
|
|
- @handleItemContent="clickContentItem"
|
|
|
- @handelSwipeDel="clickSwipeDel"
|
|
|
- >
|
|
|
- </general-shell>
|
|
|
- <long-press-shell
|
|
|
- v-if="longPressEdition && !swipeEdition"
|
|
|
- v-for="(item, index) of dataArray"
|
|
|
- :key="'longpress' + index"
|
|
|
- :item="item"
|
|
|
- @handleDelIcon="clickDelIcon"
|
|
|
- @handleEditIcon="clickEditIcon"
|
|
|
- @handleItemContent="clickContentItem"
|
|
|
- @handleCopy="clickLongCopy"
|
|
|
- @handleSet="clickLongSet"
|
|
|
- @handleDel="clickLongDel"
|
|
|
- >
|
|
|
- <template v-slot:contentInfo>
|
|
|
- <slot name="iteminfos"></slot>
|
|
|
- </template>
|
|
|
- <template v-slot:contentIcons>
|
|
|
- <slot name="itemicon"></slot>
|
|
|
- </template>
|
|
|
- <template v-slot:contentAddrs>
|
|
|
- <slot name="itemaddr"></slot>
|
|
|
- </template>
|
|
|
- <template v-slot:longpressAll>
|
|
|
- <slot name="longpressbtns"></slot>
|
|
|
- </template>
|
|
|
- </long-press-shell>
|
|
|
- <swipe-shell
|
|
|
- v-if="!longPressEdition && swipeEdition"
|
|
|
- v-for="(item, index) of dataArray"
|
|
|
- :key="'swipe' + index"
|
|
|
- :item="item"
|
|
|
- @handleDelIcon="clickDelIcon"
|
|
|
- @handleEditIcon="clickEditIcon"
|
|
|
- @handleItemContent="clickContentItem"
|
|
|
- @handelSwipeDel="clickSwipeDel"
|
|
|
- >
|
|
|
- <template v-slot:contentInfo>
|
|
|
- <slot name="iteminfos"></slot>
|
|
|
- </template>
|
|
|
- <template v-slot:contentIcons>
|
|
|
- <slot name="itemicon"></slot>
|
|
|
- </template>
|
|
|
- <template v-slot:contentAddrs>
|
|
|
- <slot name="itemaddr"></slot>
|
|
|
- </template>
|
|
|
- <template v-slot:swiperightbtn>
|
|
|
- <slot name="swiperight"></slot>
|
|
|
- </template>
|
|
|
- </swipe-shell>
|
|
|
+ <div :class="classes">
|
|
|
+ <template v-if="!swipeEdition">
|
|
|
+ <general-shell
|
|
|
+ v-for="(item, index) of dataArray"
|
|
|
+ :key="index"
|
|
|
+ :item="item"
|
|
|
+ :longPress="longPress"
|
|
|
+ @delIcon="clickDelIcon"
|
|
|
+ @editIcon="clickEditIcon"
|
|
|
+ @itemClick="clickContentItem"
|
|
|
+ @swipeDel="clickSwipeDel"
|
|
|
+ @longCopy="clickLongCopy"
|
|
|
+ @longSet="clickLongSet"
|
|
|
+ @longDel="clickLongDel"
|
|
|
+ >
|
|
|
+ <template v-slot:contentInfo v-if="longPress">
|
|
|
+ <slot name="iteminfos"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:contentIcons v-if="longPress">
|
|
|
+ <slot name="itemicon"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:contentAddrs v-if="longPress">
|
|
|
+ <slot name="itemaddr"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:longpressAll v-if="longPress">
|
|
|
+ <slot name="longpressbtns"></slot>
|
|
|
+ </template>
|
|
|
+ </general-shell>
|
|
|
+ </template>
|
|
|
+ <template v-if="swipeEdition">
|
|
|
+ <swipe-shell
|
|
|
+ v-for="(item, index) of dataArray"
|
|
|
+ :key="index"
|
|
|
+ :item="item"
|
|
|
+ @delIcon="clickDelIcon"
|
|
|
+ @editIcon="clickEditIcon"
|
|
|
+ @itemClick="clickContentItem"
|
|
|
+ @swipeDel="clickSwipeDel"
|
|
|
+ >
|
|
|
+ <template v-slot:contentInfo>
|
|
|
+ <slot name="iteminfos"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:contentIcons>
|
|
|
+ <slot name="itemicon"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:contentAddrs>
|
|
|
+ <slot name="itemaddr"></slot>
|
|
|
+ </template>
|
|
|
+ <template v-slot:swiperightbtn>
|
|
|
+ <slot name="swiperight"></slot>
|
|
|
+ </template>
|
|
|
+ </swipe-shell>
|
|
|
+ </template>
|
|
|
<div class="nut-addresslist__bottom" v-if="showBottomButton" @click="addAddress">
|
|
|
<nut-button block type="danger">{{ translate('addAddress') }}</nut-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
-import { toRefs, reactive, onMounted, ref, watch } from 'vue';
|
|
|
+import { reactive, onMounted, ref, watch, computed } from 'vue';
|
|
|
import { createComponent } from '@/packages/utils/create';
|
|
|
const { componentName, create, translate } = createComponent('addresslist');
|
|
|
-import LongPressShell from './components/LongPressShell.vue';
|
|
|
import SwipeShell from './components/SwipeShell.vue';
|
|
|
import GeneralShell from './components/GeneralShell.vue';
|
|
|
import { floatData } from '@/packages/utils/util';
|
|
|
@@ -78,7 +70,7 @@ export default create({
|
|
|
type: Array,
|
|
|
default: []
|
|
|
},
|
|
|
- longPressEdition: {
|
|
|
+ longPress: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
},
|
|
|
@@ -96,20 +88,10 @@ export default create({
|
|
|
}
|
|
|
},
|
|
|
components: {
|
|
|
- LongPressShell,
|
|
|
SwipeShell,
|
|
|
GeneralShell
|
|
|
},
|
|
|
- emits: [
|
|
|
- 'handelDelIcon',
|
|
|
- 'handelEditIcon',
|
|
|
- 'handelItem',
|
|
|
- 'longPressCopyClick',
|
|
|
- 'longPressSetClick',
|
|
|
- 'longPressDelClick',
|
|
|
- 'swipeDelClick',
|
|
|
- 'addAddressClick'
|
|
|
- ],
|
|
|
+ emits: ['delIcon', 'editIcon', 'itemClick', 'longCopy', 'longSet', 'longDel', 'swipeDel', 'add'],
|
|
|
|
|
|
setup(props, { emit }) {
|
|
|
const dataArray = ref([]);
|
|
|
@@ -120,59 +102,64 @@ export default create({
|
|
|
defaultAddress: false,
|
|
|
fullAddress: '北京市通州区测试测试测试测试测试测试测试测试测试'
|
|
|
});
|
|
|
+ const classes = computed(() => {
|
|
|
+ const prefixCls = componentName;
|
|
|
+ return {
|
|
|
+ [prefixCls]: true
|
|
|
+ };
|
|
|
+ });
|
|
|
//磨平参数差异
|
|
|
const trowelData = () => {
|
|
|
- // console.log('props.data', props.data);
|
|
|
if (Object.keys(props.dataMapOptions).length > 0) {
|
|
|
- dataArray.value = props.data.map((item, index) => {
|
|
|
+ dataArray.value = props.data.map((item) => {
|
|
|
return floatData(dataInfo, item, props.dataMapOptions);
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- // 监听props.data的变更重新渲染列表
|
|
|
watch(
|
|
|
() => props.data,
|
|
|
() => trowelData(),
|
|
|
{ deep: true }
|
|
|
);
|
|
|
|
|
|
- const clickDelIcon = (event, item) => {
|
|
|
- emit('handelDelIcon', event, item);
|
|
|
+ const clickDelIcon = (event: Event, item: unknown) => {
|
|
|
+ emit('delIcon', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const clickEditIcon = (event, item) => {
|
|
|
- emit('handelEditIcon', event, item);
|
|
|
+ const clickEditIcon = (event: Event, item: unknown) => {
|
|
|
+ emit('editIcon', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const clickContentItem = (event, item) => {
|
|
|
- emit('handelItem', event, item);
|
|
|
+ const clickContentItem = (event: Event, item: unknown) => {
|
|
|
+ emit('itemClick', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const clickLongCopy = (event, item) => {
|
|
|
- emit('longPressCopyClick', event, item);
|
|
|
+ const clickLongCopy = (event: Event, item: unknown) => {
|
|
|
+ emit('longCopy', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const clickLongSet = (event, item) => {
|
|
|
- emit('longPressSetClick', event, item);
|
|
|
+ const clickLongSet = (event: Event, item: unknown) => {
|
|
|
+ emit('longSet', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const clickLongDel = (event, item) => {
|
|
|
- emit('longPressDelClick', event, item);
|
|
|
+ const clickLongDel = (event: Event, item: unknown) => {
|
|
|
+ emit('longDel', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const clickSwipeDel = (event, item) => {
|
|
|
- emit('swipeDelClick', event, item);
|
|
|
+ const clickSwipeDel = (event: Event, item: unknown) => {
|
|
|
+ emit('swipeDel', event, item);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
- const addAddress = (event) => {
|
|
|
- emit('addAddressClick', event);
|
|
|
+ const addAddress = (event: Event) => {
|
|
|
+ emit('add', event);
|
|
|
event.stopPropagation();
|
|
|
};
|
|
|
onMounted(() => {
|
|
|
trowelData();
|
|
|
});
|
|
|
return {
|
|
|
+ classes,
|
|
|
clickDelIcon,
|
|
|
clickEditIcon,
|
|
|
clickContentItem,
|