fit2cloud-ui-plus 0.0.1-beta.5 → 0.0.1-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fit2cloud-ui-plus",
3
- "version": "0.0.1-beta.5",
3
+ "version": "0.0.1-beta.6",
4
4
  "private": false,
5
5
  "main": "./lib/fit2cloud-ui-plus.es.js",
6
6
  "files": [
@@ -65,7 +65,7 @@ const props = defineProps({
65
65
  type: Number,
66
66
  default: 0
67
67
  },
68
- components: Array,
68
+ components: Array as any,
69
69
  drawerWidth: {
70
70
  type: [Number, String],
71
71
  default: "680px"
@@ -9,33 +9,37 @@
9
9
 
10
10
  <script setup lang="ts">
11
11
 
12
+ import FuReadWriteSwitch from "@/components/read-write-switch/FuReadWriteSwitch.vue";
12
13
  import { ref, watch } from "vue";
14
+
13
15
  defineOptions({ name: "FuInputRwSwitch" });
14
16
  const props = defineProps({
15
- value: [String, Number],
17
+ modelValue: [String, Number],
16
18
  writeTrigger: {
17
19
  type: String,
18
- default: "click",
20
+ default: "onClick",
19
21
  validator: (value: string) => {
20
- return ['click', 'dblclick'].includes(value)
22
+ return ['onClick', 'onDblclick'].includes(value)
21
23
  }
22
24
  }
23
25
  })
24
26
  const emit = defineEmits(["input", "blur"])
25
27
 
26
- const data = ref(props.value)
28
+ const data = ref(props.modelValue)
27
29
 
28
- watch(() => props.value, (v) => {
30
+ watch(() => props.modelValue, (v) => {
29
31
  data.value = v
30
32
  })
31
33
 
32
34
  function input(e: Event) {
33
35
  emit("input", data.value, e)
34
36
  }
37
+
35
38
  function blur(read: Function, e: Event) {
36
39
  emit("blur", data.value, e)
37
40
  read()
38
41
  }
42
+
39
43
  function keydown(read: Function, e: KeyboardEvent) {
40
44
  if (e.key === "Enter") {
41
45
  read()
@@ -1,28 +1,27 @@
1
1
  <script lang="ts">
2
- import { ref, watch, defineComponent, h, nextTick } from 'vue'
3
- import { uuid } from "@/tools/utils"
2
+ import {ref, watch, defineComponent, h, nextTick} from 'vue'
3
+ import {uuid} from "@/tools/utils"
4
4
 
5
- const TRIGGERS = ['manual', 'click', 'dblclick']
5
+ const TRIGGERS = ['manual', 'onClick', 'onDblclick']
6
6
 
7
7
  export default defineComponent({
8
8
  name: "FuReadWriteSwitch",
9
9
  props: {
10
- value: Boolean,
10
+ modelValue: Boolean,
11
11
  data: [String, Number, Boolean],
12
12
  writeTrigger: {
13
13
  type: String,
14
- default: "click",
14
+ default: "onClick",
15
15
  validator: (value: string) => {
16
16
  return TRIGGERS.includes(value)
17
17
  }
18
18
  }
19
19
  },
20
20
 
21
- setup(props, { slots, emit }) {
21
+ setup(props, {slots, emit}) {
22
22
  const id = ref(uuid())
23
- const write = ref(props.value === undefined ? false : props.value)
24
- watch(() => props.value, (v) => {
25
- console.log(v)
23
+ const write = ref(props.modelValue === undefined ? false : props.modelValue)
24
+ watch(() => props.modelValue, (v) => {
26
25
  if (v === write.value) return
27
26
 
28
27
  if (v) {
@@ -33,12 +32,13 @@ export default defineComponent({
33
32
  })
34
33
 
35
34
  function change() {
36
- emit("input", write.value)
35
+ emit("update:modelValue", write.value)
37
36
  emit("change", [props.data, write.value])
38
37
  }
38
+
39
39
  function switchWrite() {
40
40
  write.value = true
41
-
41
+
42
42
  nextTick(() => {
43
43
  // 目前只支持input和textarea自动获取焦点
44
44
  const nid = document.getElementById(id.value)
@@ -52,39 +52,41 @@ export default defineComponent({
52
52
  change()
53
53
  })
54
54
  }
55
+
55
56
  function switchRead() {
56
57
  write.value = false
57
58
  change()
58
59
  }
59
-
60
- const context: any = {
61
- class: "fu-read-write-switch",
62
- attrs: { id: id.value },
63
- on: {}
64
- }
65
60
 
66
- // 读状态添加触发写状态的事件
67
- if (!write.value && props.writeTrigger !== TRIGGERS[0]) {
68
- context.on[props.writeTrigger] = switchWrite
69
- }
70
- // 没有slot时显示文本数据
71
- let children: any = props.data
61
+ return () => {
62
+ const context: any = {
63
+ class: "fu-read-write-switch",
64
+ id: id.value,
65
+ }
72
66
 
73
- // 读状态内容,提供切换到写状态的方法
74
- if (!write.value && slots.read) {
75
- children = slots.read({
76
- write: switchWrite
77
- })
78
- }
67
+ // 读状态添加触发写状态的事件
68
+ if (!write.value && props.writeTrigger !== TRIGGERS[0]) {
69
+ context[props.writeTrigger] = switchWrite
70
+ }
71
+ // 没有slot时显示文本数据
72
+ let children: any = props.data
79
73
 
80
- // 写状态内容,提供切换到读状态的方法
81
- if (write.value && slots.default) {
82
- children = slots.default({
83
- read: switchRead
84
- })
85
- }
74
+ // 读状态内容,提供切换到写状态的方法
75
+ if (!write.value && slots.read) {
76
+ children = slots.read({
77
+ write: switchWrite
78
+ })
79
+ }
86
80
 
87
- return () => h("div", context, children)
81
+ // 写状态内容,提供切换到读状态的方法
82
+ if (write.value && slots.default) {
83
+ children = slots.default({
84
+ read: switchRead
85
+ })
86
+ }
87
+
88
+ return h("div", context, children)
89
+ }
88
90
  }
89
91
 
90
92
  })
@@ -17,23 +17,27 @@
17
17
  </template>
18
18
 
19
19
  <script setup lang="ts">
20
- import { ref, watch } from "vue";
20
+ import { ref, watch, PropType } from "vue";
21
+ import { OptionProps } from "./types";
21
22
  defineOptions({ name: "FuSelectRwSwitch" });
22
23
  const props = defineProps({
23
- value: [String, Number],
24
- options: Array,
24
+ modelValue: [String, Number],
25
+ options: {
26
+ type: Array as PropType<OptionProps[]>,
27
+ default: []
28
+ },
25
29
  writeTrigger: {
26
30
  type: String,
27
- default: "click",
31
+ default: "onClick",
28
32
  validator: (value: string) => {
29
- return ['click', 'dblclick'].includes(value)
33
+ return ['onClick', 'onDblclick'].includes(value)
30
34
  }
31
35
  }
32
36
  })
33
37
  const emit = defineEmits(["input", "blur", "change"])
34
- const data = ref(props.value)
38
+ const data = ref(props.modelValue)
35
39
 
36
- watch(() => props.value, (v) => {
40
+ watch(() => props.modelValue, (v) => {
37
41
  data.value = v
38
42
  })
39
43
  function input(e: Event) {
@@ -0,0 +1,4 @@
1
+ export interface OptionProps {
2
+ label: string
3
+ value: string | number
4
+ }
@@ -8,7 +8,7 @@
8
8
  @mouseover="hover = true" @mouseleave="hover = false">
9
9
  <div class="icon" v-if="resizerType === 'resizer'">
10
10
  <slot name="resizer">
11
- <i class="el-icon-more"></i>
11
+ <el-icon :size="10"><MoreFilled /></el-icon>
12
12
  </slot>
13
13
  </div>
14
14
  </div>
@@ -1,40 +1,46 @@
1
- import { h } from 'vue'
1
+ import { h } from "vue";
2
2
 
3
3
  const isFix = (node: any) => {
4
- const includeTag = node.type.name.indexOf("FuTableColumnDropdown") >= 0
5
- const { fix } = node.props
6
- let { type } = node.props
7
- return (fix !== undefined && fix !== false) || ["selection", "index", "expand"].includes(type) || includeTag
8
- }
4
+ const includeTag = node.type.name.indexOf("FuTableColumnDropdown") >= 0;
5
+ const { fix } = node.props;
6
+ let { type } = node.props;
7
+ return (
8
+ (fix !== undefined && fix !== false) ||
9
+ ["selection", "index", "expand"].includes(type) ||
10
+ includeTag
11
+ );
12
+ };
9
13
 
10
14
  const getLabel = (node: any) => {
11
- if (node.props.label) return node.props.label
12
- const prefix = "FU-T-"
13
- const includeTag = node.type.name.indexOf("FuTableColumnDropdown") >= 0
14
- let { label, type } = node.props
15
- if (includeTag) label = prefix + "dropdown"
16
- label ??= node.props.label
17
- label ??= prefix + type
15
+ if (node.props.label) return node.props.label;
16
+ const prefix = "FU-T-";
17
+ const includeTag = node.type.name.indexOf("FuTableColumnDropdown") >= 0;
18
+ let { label, type } = node.props;
19
+ if (includeTag) label = prefix + "dropdown";
20
+ label ??= node.props.label;
21
+ label ??= prefix + type;
18
22
  return label;
19
- }
23
+ };
24
+
20
25
  const FuTableBody = (props: any, context: any) => {
21
- const slots = context.slots.default()
26
+ let slots = context.slots.default();
22
27
  const nodes: any = [];
23
- let { columns } = props
24
- const children = slots[0].children.filter((c: any) => c.type.name !== undefined)
25
- if (!children) return nodes
26
- if (!columns || columns?.length === 0) return children
28
+ let { columns } = props;
29
+ if (typeof slots[0].children[0].type === "symbol") {
30
+ slots = slots[0].children;
31
+ }
32
+ const children = slots[0].children.filter((c: any) => c.type.name !== undefined);
33
+ if (!children) return nodes;
34
+ if (!columns || columns?.length === 0) return children;
27
35
  columns.forEach((col: any) => {
28
36
  let node = children.find((child: any) => {
29
- return col.label === getLabel(child)
30
- })
37
+ return col.label === getLabel(child);
38
+ });
31
39
  if (node && (isFix(node) || col.show !== false)) {
32
40
  nodes.push(node);
33
41
  }
34
- })
35
- return nodes
36
- }
42
+ });
43
+ return nodes;
44
+ };
37
45
 
38
46
  export default FuTableBody;
39
-
40
-
@@ -33,6 +33,9 @@
33
33
  </template>
34
34
  <script lang="ts" setup>
35
35
  import { computed, getCurrentInstance } from "vue";
36
+ import { PropType } from "vue";
37
+ import { DropdownProps } from "@/tools/types";
38
+
36
39
  defineOptions({ name: "FuTableColumnDropdown" });
37
40
  const props = defineProps({
38
41
  showType: {
@@ -41,7 +44,7 @@ const props = defineProps({
41
44
  validator: (value: string) => ["always", "hover", "selected"].includes(value),
42
45
  },
43
46
  menus: {
44
- type: Array,
47
+ type: Array as PropType<DropdownProps[]>,
45
48
  default: () => [],
46
49
  },
47
50
  title: String,
@@ -56,7 +59,7 @@ const props = defineProps({
56
59
 
57
60
  });
58
61
 
59
- const instance = getCurrentInstance()
62
+ const instance = getCurrentInstance() as any
60
63
 
61
64
 
62
65
  const isShow = computed(() => {
@@ -1,18 +1,19 @@
1
1
  <template>
2
2
  <div style="display: inline-block">
3
3
  <!-- :size="configSize" -->
4
- <el-button class="fu-search-bar-button" :icon="icon" @click="visible = true">{{t('fu.table.custom_table_rows')}}</el-button>
4
+ <el-button class="fu-search-bar-button" :icon="icon" @click="visible = true">{{ t('fu.table.custom_table_rows') }}
5
+ </el-button>
5
6
  <el-dialog custom-class="fu-table-column-select-dialog" v-model="visible" @open="open" append-to-body>
6
- <template #title>
7
+ <template #header>
7
8
  <h3>
8
9
  {{ t('fu.table.custom_table_fields') }}
9
10
  </h3>
10
- <el-alert :title="t('fu.table.custom_table_fields_desc')" type="info" :closable="false"/>
11
+ <el-alert :title="t('fu.table.custom_table_fields_desc')" type="info" :closable="false" />
11
12
  </template>
12
13
 
13
14
  <el-checkbox v-for="(c, i) in cloneColumns" :key="i" v-model="c.show" :checked="c.show !== false" draggable="true"
14
- @dragstart="dragstart($event, i)" @dragenter="dragenter" @dragleave="dragleave"
15
- @dragover.prevent @dragend="dragend" @drop="drop($event, cloneColumns, i)" v-show="!c.fix">
15
+ @dragstart="dragstart($event, i)" @dragenter="dragenter" @dragleave="dragleave" @dragover.prevent
16
+ @dragend="dragend" @drop="drop($event, cloneColumns, i)" v-show="!c.fix">
16
17
  {{ c.label }}
17
18
  </el-checkbox>
18
19
 
@@ -30,9 +31,9 @@
30
31
  </template>
31
32
 
32
33
  <script setup lang="ts">
33
- import {ref, inject} from "vue";
34
- import {tableColumnSelect} from "./utils"
35
- import {useLocale} from "@/hooks"
34
+ import { ref, inject } from "vue";
35
+ import { tableColumnSelect } from "./utils"
36
+ import { useLocale } from "@/hooks"
36
37
 
37
38
  const props = defineProps({
38
39
  icon: {
@@ -53,7 +54,7 @@ const props = defineProps({
53
54
 
54
55
  const localKey = inject("localKey")
55
56
 
56
- const {t} = useLocale()
57
+ const { t } = useLocale()
57
58
 
58
59
  const cloneColumn = (source: any, target: any) => {
59
60
  source.forEach((col: any) => {
@@ -72,7 +73,7 @@ const {
72
73
  drop
73
74
  } = tableColumnSelect(localKey)
74
75
 
75
- const cloneColumns = ref([])
76
+ const cloneColumns = ref([]) as any
76
77
  const visible = ref(false)
77
78
 
78
79
  function open() {
@@ -82,7 +83,7 @@ function open() {
82
83
 
83
84
  function ok() {
84
85
  props.columns.splice(0, props.columns.length)
85
- cloneColumns.value.forEach(c => {
86
+ cloneColumns.value.forEach((c: any) => {
86
87
  props.columns.push(c)
87
88
  })
88
89
  visible.value = false
@@ -1,14 +1,14 @@
1
1
  <template>
2
2
  <el-popover class="fu-table-column-select" popper-class="fu-table-column-select-popper" :trigger="trigger"
3
- :show-arrow="false" v-show="hasSelect">
3
+ :show-arrow="false" v-show="hasSelect">
4
4
  <h3>
5
5
  {{ t('fu.table.custom_table_fields') }}
6
6
  </h3>
7
7
  <div class="fu-table-column-select-popper__body">
8
8
  <div v-for="(c, i) in columns" :key="i" class="fu-table-column-select-popper__item">
9
9
  <el-checkbox v-model="c.show" :checked="c.show !== false" draggable="true" @dragstart="dragstart($event, i)"
10
- @dragenter="dragenter" @dragleave="dragleave" @dragover.prevent @dragend="dragend"
11
- @drop="drop($event, columns, i)" v-show="!c.fix">
10
+ @dragenter="dragenter" @dragleave="dragleave" @dragover.prevent @dragend="dragend"
11
+ @drop="drop($event, columns, i)" v-show="!c.fix">
12
12
  {{ c.label }}
13
13
  </el-checkbox>
14
14
  </div>
@@ -20,16 +20,16 @@
20
20
  </div>
21
21
 
22
22
  <template #reference>
23
- <el-button class="fu-search-bar-button" :icon="icon">{{t('fu.table.custom_table_rows')}}</el-button>
23
+ <el-button class="fu-search-bar-button" :icon="icon">{{ t('fu.table.custom_table_rows') }}</el-button>
24
24
  </template>
25
25
  <!-- :size="configSize" -->
26
26
  </el-popover>
27
27
  </template>
28
28
 
29
29
  <script setup lang="ts">
30
- import {computed, inject} from "vue";
31
- import {tableColumnSelect} from "./utils"
32
- import {useLocale} from "@/hooks"
30
+ import { computed, inject } from "vue";
31
+ import { tableColumnSelect } from "./utils"
32
+ import { useLocale } from "@/hooks"
33
33
 
34
34
  const props = defineProps({
35
35
  icon: {
@@ -42,13 +42,13 @@ const props = defineProps({
42
42
  validator: (value: string) => ['click', 'hover'].includes(value)
43
43
  },
44
44
  columns: {
45
- type: Array,
45
+ type: Array as any,
46
46
  default: () => []
47
47
  },
48
48
 
49
49
  });
50
50
 
51
- const {t} = useLocale()
51
+ const { t } = useLocale()
52
52
 
53
53
  const localKey = inject("localKey")
54
54
 
@@ -6,7 +6,7 @@ export const tableColumnSelect = (localKey: any) => {
6
6
  return localKey ? "FU-T-" + localKey : ''
7
7
  })
8
8
 
9
- function dragstart(event: DragEvent, index: string) {
9
+ function dragstart(event: DragEvent, index: any) {
10
10
  if (event.dataTransfer) {
11
11
  event.dataTransfer.effectAllowed = "move"
12
12
  event.dataTransfer.setData("source_index", index)
@@ -15,15 +15,17 @@ export const tableColumnSelect = (localKey: any) => {
15
15
 
16
16
  function dragenter(event: DragEvent) {
17
17
  event.preventDefault()
18
- if (event.target) {
19
- event.target.style.opacity = .2
18
+ let target = event.target as HTMLElement
19
+ if (target) {
20
+ target.style.opacity= ".2"
20
21
  }
21
22
  }
22
23
 
23
24
  function dragleave(event: DragEvent) {
24
25
  event.preventDefault()
25
- if (event.target) {
26
- event.target.style.opacity = ""
26
+ let target = event.target as HTMLElement
27
+ if (target) {
28
+ target.style.opacity = ""
27
29
  }
28
30
  }
29
31
 
@@ -34,6 +36,7 @@ export const tableColumnSelect = (localKey: any) => {
34
36
  }
35
37
 
36
38
  function drop(event: DragEvent, list: any, index: number) {
39
+ let target = event.target as HTMLElement
37
40
  let source_index = Number(event.dataTransfer?.getData("source_index"))
38
41
  let target_index = index
39
42
  if (target_index > source_index) {
@@ -43,8 +46,8 @@ export const tableColumnSelect = (localKey: any) => {
43
46
  list.splice(target_index, 0, list[source_index])
44
47
  list.splice(source_index + 1, 1)
45
48
  }
46
- if (event.target) {
47
- event.target.style.opacity = ""
49
+ if (target) {
50
+ target.style.opacity = ""
48
51
  }
49
52
  }
50
53
 
@@ -10,7 +10,7 @@
10
10
  </el-button>
11
11
  <template #dropdown>
12
12
  <el-dropdown-menu>
13
- <el-dropdown-item v-for="(btn, i) in buttons" :key="i" :icon="type === 'icon'&& btn.icon" :disabled="disabled(btn)"
13
+ <el-dropdown-item v-for="(btn, i) in buttons" :key="i" :icon="type === 'icon'? btn.icon: ''" :disabled="disabled(btn)"
14
14
  :command="btn">
15
15
  {{ btn.label }}
16
16
  </el-dropdown-item>
@@ -21,12 +21,14 @@
21
21
  <script lang="ts" setup>
22
22
  import { computed } from "vue";
23
23
  import { useLocale } from "@/hooks"
24
+ import { PropType } from "vue";
25
+ import { DropdownProps } from "@/tools/types";
24
26
 
25
27
  const { t } = useLocale()
26
28
  const props = defineProps({
27
29
  row: Object,
28
30
  buttons: {
29
- type: Array,
31
+ type: Array as PropType<DropdownProps[]>,
30
32
  required: true
31
33
  },
32
34
  size: {
@@ -5,8 +5,8 @@
5
5
  </template>
6
6
  <template #default="{ row }">
7
7
  <fu-table-button :icon="type === 'icon'" v-for="(btn, i) in defaultButtons(row)" :key="i"
8
- @click.stop="btn.click(row)" :disabled="disableButton(btn, row)" :label="btn.label" :type="btn.type || 'primary'"
9
- link>
8
+ @click.stop="btn.click(row)" :disabled="disableButton(btn, row)" :label="btn.label"
9
+ :type="btn.type || 'primary'" link>
10
10
  <el-icon v-if="type === 'icon'">
11
11
  <component :is="btn.icon" />
12
12
  </el-icon>
@@ -52,13 +52,13 @@ const hasShowFunc = computed(() => {
52
52
  return props.buttons.some((btn: any) => typeof btn.show === "function")
53
53
  });
54
54
 
55
- const defaultButtons = computed(() => {
55
+ const defaultButtons: any = computed(() => {
56
56
  return function (row: any) {
57
57
  return hasMore(row) ? showButtons(row).slice(0, props.ellipsis) : showButtons(row)
58
58
  }
59
59
  });
60
60
 
61
- const moreButtons = computed(() => {
61
+ const moreButtons: any = computed(() => {
62
62
  return function (row: any) {
63
63
  return hasMore(row) ? showButtons(row).slice(props.ellipsis) : []
64
64
  }
@@ -66,7 +66,7 @@ const moreButtons = computed(() => {
66
66
 
67
67
  const computeWidth = computed(() => {
68
68
  let length = hasShowFunc.value ? props.ellipsis : defaultButtons.value.length
69
- let buttonsWidth = 35 + length * 58 + 58
69
+ let buttonsWidth: string | number = 35 + length * 58 + 58
70
70
  if (props.minWidth) {
71
71
  buttonsWidth = buttonsWidth < props.minWidth ? props.minWidth : buttonsWidth
72
72
  }
@@ -2,7 +2,7 @@
2
2
  <el-tabs class="fu-tabs" :before-leave="beforeLeave" :editable="false" :addable="false" v-bind="$attrs">
3
3
  <slot></slot>
4
4
  <el-tab-pane name="add" key="add" v-if="addable">
5
- <template v-slot:label>
5
+ <template #label>
6
6
  <slot name="add">
7
7
  <!-- 下拉方式 -->
8
8
  <el-dropdown @command="handleCommand" v-if="addType === 'dropdown'" :trigger="addTrigger">
@@ -38,6 +38,8 @@
38
38
  </template>
39
39
 
40
40
  <script lang="ts" setup>
41
+ import { PropType } from "vue";
42
+ import { DropdownProps } from "@/tools/types";
41
43
  import { uuid } from "@/tools/utils";
42
44
  defineOptions({ name: "FuTabs" });
43
45
  type TabPanelName = string | number
@@ -48,7 +50,7 @@ const props = defineProps({
48
50
  validator: (val: string) => ["default", "dropdown"].includes(val),
49
51
  },
50
52
  dropdownMenus: {
51
- type: Array,
53
+ type: Array as PropType<DropdownProps[]>,
52
54
  default: () => [],
53
55
  },
54
56
  addTrigger: {
@@ -14,15 +14,9 @@
14
14
  );
15
15
 
16
16
  // fit2cloud ui variables
17
-
18
17
  $filter-color: #646A73 !default;
19
18
  $filter-drawer-color: #646A73 !default;
20
19
  $filter-condition-color: #0C296E !default;
21
20
  $filter-condition-bgColor: rgba(51, 112, 255, 0.1) !default;
22
21
  $filter-option-bgColor: #F5F6F7 !default;
23
22
  $filter-scroll-bgColor: rgba(31, 35, 41, 0.1) !default;
24
-
25
- // $fu-search-bar-width: 100% !default;
26
- // $fu-search-bar-height: 48px !default;
27
- // $fu-search-bar-condition-color: #424242 !default;
28
- // $fu-search-bar-condition-bgColor: #E6E6E6 !default;
@@ -3,7 +3,7 @@
3
3
 
4
4
  @include b(tabs) {
5
5
  #tab-add {
6
- .el-icon-close {
6
+ .is-icon-close {
7
7
  display: none;
8
8
  }
9
9
  }
@@ -0,0 +1,9 @@
1
+ export interface DropdownProps {
2
+ icon?: string
3
+ disabled?: boolean
4
+ divided?: boolean
5
+ command?: string | number | object
6
+ label?: string | number
7
+ [k:string]: any;
8
+ }
9
+