ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<script lang="ts" setup>
import type { PropType } from 'vue';
 
import { reactive, toRefs } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
 
import { MenuOutlined, PushpinOutlined } from '@ant-design/icons-vue';
import { Popover, Tooltip } from 'ant-design-vue';
 
import { delView, setDefaultView } from '#/api/onlineDev/visualDev';
import { $t } from '#/locales';
 
interface State {
  visible: boolean;
}
 
const props = defineProps({
  menuId: { type: String },
  viewList: { type: Array as PropType<any[]>, default: () => [] },
});
const emit = defineEmits(['itemClick', 'reload']);
const state = reactive<State>({
  visible: false,
});
const { visible } = toRefs(state);
const { createMessage, createConfirm } = useMessage();
function handleClick(item) {
  emit('itemClick', item);
}
function handleDel(id) {
  state.visible = false;
  createConfirm({
    iconType: 'warning',
    title: $t('common.tipTitle'),
    content: '确定要删除此视图,是否继续?',
    onOk: () => {
      delView(id, props.menuId).then((res) => {
        createMessage.success(res.msg);
        emit('reload');
      });
    },
  });
}
function handleDefault(item) {
  if (item.status === 1) return;
  state.visible = false;
  createConfirm({
    iconType: 'warning',
    title: $t('common.tipTitle'),
    content: '设置此视图为默认视图,是否继续?',
    onOk: () => {
      setDefaultView(item.id, props.menuId).then((res) => {
        createMessage.success(res.msg);
        emit('reload');
      });
    },
  });
}
</script>
<template>
  <Tooltip placement="top">
    <template #title>
      <span>{{ $t('component.table.viewList') }}</span>
    </template>
    <Popover v-model:open="visible" placement="bottomRight" trigger="click" overlay-class-name="jnpf-view-list-popover">
      <template #content>
        <div class="content">
          <div v-for="item in viewList" :key="item.id" class="item" @click="handleClick(item)">
            <span class="item-name">{{ item.fullName }}</span>
            <div class="item-delete">
              <i class="icon-ym icon-ym-app-delete" @click.stop="handleDel(item.id)" v-if="item.type !== 0"></i>
            </div>
            <div class="item-default">
              <PushpinOutlined :class="{ 'item-default-icon': item.status == 0 }" @click.stop="handleDefault(item)" />
            </div>
          </div>
        </div>
      </template>
      <MenuOutlined />
    </Popover>
  </Tooltip>
</template>
<style lang="scss">
.jnpf-view-list-popover {
  .ant-popover-inner-content {
    padding: 0;
 
    .content {
      width: 230px;
      max-height: 250px;
      overflow: auto;
 
      .item {
        display: flex;
        align-items: center;
        height: 36px;
        padding: 0 8px 0 18px;
        margin: 4px 6px;
        cursor: pointer;
        border-radius: 6px;
 
        &:hover {
          background-color: var(--selected-hover-bg);
 
          .item-delete i {
            display: block;
          }
        }
 
        .item-name {
          flex: 1;
        }
 
        .item-delete {
          width: 14px;
 
          i {
            display: none;
            font-size: 14px;
          }
        }
 
        .item-default {
          margin-left: 12px;
 
          i {
            font-size: 14px;
          }
 
          .item-default-icon {
            color: var(--primary-color);
          }
        }
      }
    }
  }
}
</style>