刘光辉
11 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
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
<script lang="ts" setup>
import { reactive, toRefs } from 'vue';
 
import { ScrollContainer } from '@jnpf/ui';
 
import { Badge } from 'ant-design-vue';
import draggable from 'vuedraggable';
 
import { inputComponents, layoutComponents, selectComponents, systemComponents } from '../helper/componentMap';
 
defineProps({
  cloneComponent: { default: undefined, type: Function },
});
 
const emit = defineEmits(['onLeftEnd', 'addComponent']);
 
const newComList = ['relationQuery'];
 
interface State {
  leftComponents: any[];
  leftActiveKey: string[];
}
 
const state = reactive<State>({
  leftComponents: [
    { id: '1', title: '基础控件', list: inputComponents },
    { id: '2', title: '高级控件', list: selectComponents },
    { id: '3', title: '系统控件', list: systemComponents },
    { id: '4', title: '布局控件', list: layoutComponents },
  ],
  leftActiveKey: ['1', '2', '3', '4'],
});
const { leftComponents, leftActiveKey } = toRefs(state);
 
function onLeftEnd(e) {
  emit('onLeftEnd', e);
}
function addComponent(e) {
  emit('addComponent', e);
}
</script>
<template>
  <ScrollContainer>
    <a-collapse v-model:active-key="leftActiveKey" expand-icon-position="end" ghost>
      <a-collapse-panel :header="item.title" :key="item.id" v-for="item in leftComponents" class="components-list">
        <draggable
          class="components-draggable"
          v-model="item.list"
          item-key="__config__.jnpfKey"
          filter=".disabled"
          :sort="false"
          draggable=".components-item"
          :clone="cloneComponent"
          :group="{ name: 'componentsGroup', pull: 'clone', put: false }"
          @end="onLeftEnd">
          <template #item="{ element }">
            <div class="components-item" @click="addComponent(element)">
              <div class="components-body">
                <i :class="element.__config__.tagIcon"></i>
                {{ element.__config__.label }}
                <BasicHelp
                  :text="element.__config__.jnpfKey == 'relationQuery' ? '不支持代码生成、设计子表、移动端' : '不支持代码生成'"
                  v-if="['calculate', 'dateCalculate', 'relationQuery'].includes(element.__config__.jnpfKey)" />
              </div>
              <Badge class="components-badge" count="NEW" v-if="newComList.includes(element.__config__.jnpfKey)" />
            </div>
          </template>
        </draggable>
      </a-collapse-panel>
    </a-collapse>
  </ScrollContainer>
</template>