@meethive/components 0.0.9 → 0.0.11

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.
@@ -1,31 +1,33 @@
1
- import { defineComponent, useSlots, watch, onMounted, onUnmounted, computed, ref, reactive, inject } from 'vue';
1
+ import { defineComponent as _defineComponent } from 'vue';
2
+ import { unref as _unref, renderSlot as _renderSlot, withCtx as _withCtx, createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock, createCommentVNode as _createCommentVNode, normalizeProps as _normalizeProps, mergeProps as _mergeProps, renderList as _renderList, createSlots as _createSlots, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, createElementBlock as _createElementBlock } from "vue";
3
+ const _hoisted_1 = {
4
+ class: "jtable-body"
5
+ };
6
+ import { useSlots, watch, onMounted, onUnmounted, computed, ref, reactive, inject } from 'vue';
2
7
  import { Spin } from 'ant-design-vue';
3
8
  import { debounce } from 'lodash-es';
4
9
  import Header from './Header.js';
5
10
  import Alert from './Alert.js';
6
11
  import Content from './Content.js';
7
- import JPagination from './Pagination.js';
12
+ import Pagination from './Pagination.js';
8
13
  import { proTableProps } from './setting';
9
14
  import { TableConfig } from '../utils/constants';
10
15
  import { useTableInject } from './hooks';
11
16
  import useProTableStyle from './style';
12
17
  import { onlyMessage } from '@meethive/utils';
13
18
  import { useLocaleReceiver } from '../LocaleReciver';
14
- export default defineComponent({
15
- name: 'JProTable',
16
- components: {
17
- Spin,
18
- Header,
19
- Alert,
20
- Content,
21
- JPagination
19
+ const __sfc_main__ = _defineComponent({
20
+ ...{
21
+ name: 'JProTable'
22
22
  },
23
+ __name: 'ProTable',
23
24
  props: {
24
25
  ...proTableProps
25
26
  },
26
- setup(props, {
27
- expose
27
+ setup(__props, {
28
+ expose: __expose
28
29
  }) {
30
+ const props = __props;
29
31
  const tableConfig = inject(TableConfig, {
30
32
  pagination: {}
31
33
  });
@@ -234,26 +236,71 @@ export default defineComponent({
234
236
  onUnmounted(() => {
235
237
  window.onresize = null;
236
238
  });
237
- expose({
239
+ __expose({
238
240
  reload,
239
241
  dataSource: _dataSource
240
242
  });
241
- return {
242
- slots,
243
- hashId,
244
- loading,
245
- _dataSource,
246
- _mode,
247
- column,
248
- page,
249
- myPagination,
250
- showAlert,
251
- showPagination,
252
- extraSlots,
253
- _rowSelection,
254
- onCheck,
255
- onPageChange,
256
- onClose
243
+ return (_ctx, _cache) => {
244
+ return _openBlock(), _createElementBlock("div", {
245
+ class: _normalizeClass(['jtable-body-spin', _unref(hashId)]),
246
+ style: _normalizeStyle(_ctx.bodyStyle),
247
+ id: "jtable-body-spin"
248
+ }, [_createVNode(_unref(Spin), {
249
+ spinning: loading.value
250
+ }, {
251
+ default: _withCtx(() => [_createElementVNode("div", _hoisted_1, [_createVNode(Header, {
252
+ initMode: _ctx.mode,
253
+ mode: _mode.value,
254
+ modeValue: _ctx.modeValue,
255
+ onChange: onCheck
256
+ }, {
257
+ headerLeftRender: _withCtx(() => [_renderSlot(_ctx.$slots, "headerLeftRender")]),
258
+ headerRightRender: _withCtx(() => [_renderSlot(_ctx.$slots, "headerRightRender")]),
259
+ _: 3 /* FORWARDED */
260
+ }, 8 /* PROPS */, ["initMode", "mode", "modeValue"]), showAlert.value ? (_openBlock(), _createBlock(Alert, {
261
+ key: 0,
262
+ rowSelection: _ctx.rowSelection || _unref(_rowSelection),
263
+ onClose: onClose
264
+ }, {
265
+ default: _withCtx(() => [_renderSlot(_ctx.$slots, "alertRender", {
266
+ rowSelection: _ctx.rowSelection || _unref(_rowSelection),
267
+ onClose: onClose
268
+ })]),
269
+ _: 3 /* FORWARDED */
270
+ }, 8 /* PROPS */, ["rowSelection"])) : _createCommentVNode("v-if", true), _createVNode(Content, _mergeProps(props, {
271
+ mode: _mode.value,
272
+ dataSource: _dataSource.value,
273
+ column: column.value
274
+ }), _createSlots({
275
+ _: 2 /* DYNAMIC */
276
+ }, [_renderList(_unref(slots), (_, key) => {
277
+ return {
278
+ name: key,
279
+ fn: _withCtx(slotProps => [!extraSlots.includes(key) ? _renderSlot(_ctx.$slots, key, _normalizeProps(_mergeProps({
280
+ key: 0
281
+ }, slotProps))) : _createCommentVNode("v-if", true)])
282
+ };
283
+ })]), 1040 /* FULL_PROPS, DYNAMIC_SLOTS */, ["mode", "dataSource", "column"]), showPagination.value ? (_openBlock(), _createBlock(Pagination, _mergeProps({
284
+ key: 1
285
+ }, myPagination.value, {
286
+ total: page.total,
287
+ pageIndex: page.pageIndex,
288
+ pageSize: page.pageSize,
289
+ totalLoading: page.loading,
290
+ totalRequest: _ctx.totalRequest,
291
+ onChange: onPageChange
292
+ }), {
293
+ default: _withCtx(() => [_renderSlot(_ctx.$slots, "paginationRender", {
294
+ total: page.total,
295
+ pageSize: page.pageSize,
296
+ current: page.pageIndex + 1,
297
+ onChange: onPageChange
298
+ })]),
299
+ _: 3 /* FORWARDED */
300
+ }, 16 /* FULL_PROPS */, ["total", "pageIndex", "pageSize", "totalLoading", "totalRequest"])) : _createCommentVNode("v-if", true)])]),
301
+ _: 3 /* FORWARDED */
302
+ }, 8 /* PROPS */, ["spinning"])], 6 /* CLASS, STYLE */);
257
303
  };
258
304
  }
259
- });
305
+ });
306
+ export default __sfc_main__;
@@ -19,7 +19,7 @@ export const _alertProps = {
19
19
  default: true
20
20
  },
21
21
  rowSelection: {
22
- type: Object,
22
+ type: [Object, Boolean],
23
23
  default: () => undefined
24
24
  }
25
25
  }
@@ -0,0 +1,142 @@
1
+ import { defineComponent as _defineComponent } from 'vue';
2
+ import { unref as _unref, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, withCtx as _withCtx, createVNode as _createVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, withModifiers as _withModifiers } from "vue";
3
+ const _hoisted_1 = ["onClick"];
4
+ const _hoisted_2 = {
5
+ class: "delete"
6
+ };
7
+ const _hoisted_3 = {
8
+ key: 1,
9
+ class: "search-history-empty"
10
+ };
11
+ import { computed, ref } from 'vue';
12
+ import { isFunction } from 'lodash-es';
13
+ import { AIcon, Empty, Ellipsis } from '../../';
14
+ import { Popconfirm, Button, FormItemRest, Popover, message } from 'ant-design-vue';
15
+ import { useLocaleReceiver } from '../../LocaleReciver';
16
+ import useSearchStyle from '../style';
17
+ const __sfc_main__ = _defineComponent({
18
+ __name: 'History',
19
+ props: {
20
+ target: {
21
+ type: String,
22
+ default: '',
23
+ required: true
24
+ },
25
+ request: {
26
+ type: Function,
27
+ default: null
28
+ },
29
+ deleteRequest: {
30
+ type: Function,
31
+ default: null
32
+ },
33
+ deleteKey: {
34
+ type: String,
35
+ default: 'key'
36
+ }
37
+ },
38
+ emits: ['click', 'itemClick'],
39
+ setup(__props, {
40
+ emit: __emit
41
+ }) {
42
+ const props = __props;
43
+ const emit = __emit;
44
+ const prefixCls = computed(() => 'JSearch');
45
+ const [wrapSSR, hashId] = useSearchStyle(prefixCls);
46
+ const [contextLocale] = useLocaleReceiver('Search');
47
+ const historyList = ref([]);
48
+ const historyVisible = ref(false);
49
+ const showEmpty = computed(() => {
50
+ return historyList.value.length === 0;
51
+ });
52
+ const showHistoryList = async () => {
53
+ if (props.request) {
54
+ const resp = await props.request(props.target);
55
+ if (resp.success && resp.result.length) {
56
+ historyList.value = resp.result.filter(item => item.content);
57
+ } else {
58
+ historyList.value = [];
59
+ }
60
+ }
61
+ };
62
+ const visibleChange = async v => {
63
+ historyVisible.value = v;
64
+ };
65
+ const click = () => {
66
+ emit('click');
67
+ };
68
+ const itemClick = content => {
69
+ historyVisible.value = false;
70
+ emit('itemClick', content);
71
+ };
72
+ const deleteHistory = async item => {
73
+ if (props.deleteRequest && isFunction(props.deleteRequest)) {
74
+ const resp = await props.deleteRequest(props.target, item[props.deleteKey]);
75
+ historyVisible.value = false;
76
+ if (resp.success || resp.status === 200 || resp.code === 200) {
77
+ message.success(contextLocale.value.advanced.saveHistory.success);
78
+ } else {
79
+ message.error(contextLocale.value.advanced.saveHistory.fail);
80
+ }
81
+ }
82
+ };
83
+ return (_ctx, _cache) => {
84
+ return _openBlock(), _createElementBlock("div", {
85
+ class: _normalizeClass(['search-history-warp', _unref(hashId)])
86
+ }, [_createVNode(_unref(FormItemRest), null, {
87
+ default: _withCtx(() => [_createVNode(_unref(Button), {
88
+ class: "search-history-button",
89
+ type: "primary",
90
+ "html-type": "submit"
91
+ }, {
92
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(_unref(contextLocale).advanced.history.search), 1 /* TEXT */)]),
93
+ _: 1 /* STABLE */
94
+ })]),
95
+ _: 1 /* STABLE */
96
+ }), _createVNode(_unref(Popover), {
97
+ placement: "bottom",
98
+ trigger: "click",
99
+ "overlay-class-name": "search-history-list-pop",
100
+ open: historyVisible.value,
101
+ onVisibleChange: visibleChange
102
+ }, {
103
+ content: _withCtx(() => [!showEmpty.value ? (_openBlock(), _createElementBlock("div", {
104
+ key: 0,
105
+ class: _normalizeClass(['search-history-items', _unref(hashId)])
106
+ }, [(_openBlock(true), _createElementBlock(_Fragment, null, _renderList(historyList.value, item => {
107
+ return _openBlock(), _createElementBlock("div", {
108
+ key: item.id,
109
+ class: "search-history-item"
110
+ }, [_createElementVNode("div", {
111
+ class: "history-item--title",
112
+ onClick: $event => itemClick(item.content)
113
+ }, [_createVNode(_unref(Ellipsis), {
114
+ style: {
115
+ "width": "100%"
116
+ }
117
+ }, {
118
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(item.name), 1 /* TEXT */)]),
119
+ _: 2 /* DYNAMIC */
120
+ }, 1024 /* DYNAMIC_SLOTS */)], 8 /* PROPS */, _hoisted_1), _createVNode(_unref(Popconfirm), {
121
+ title: _unref(contextLocale).advanced.history.confirmDelete,
122
+ placement: "top",
123
+ onConfirm: $event => deleteHistory(item)
124
+ }, {
125
+ default: _withCtx(() => [_createElementVNode("span", _hoisted_2, [_createVNode(_unref(AIcon), {
126
+ type: "DeleteOutlined"
127
+ })])]),
128
+ _: 1 /* STABLE */
129
+ }, 8 /* PROPS */, ["title", "onConfirm"])]);
130
+ }), 128 /* KEYED_FRAGMENT */))], 2 /* CLASS */)) : (_openBlock(), _createElementBlock("div", _hoisted_3, [_createVNode(_unref(Empty))]))]),
131
+ default: _withCtx(() => [_createElementVNode("div", {
132
+ class: "search-history-button-icon",
133
+ onClick: _withModifiers(showHistoryList, ["stop"])
134
+ }, [_createVNode(_unref(AIcon), {
135
+ type: "DownOutlined"
136
+ })])]),
137
+ _: 1 /* STABLE */
138
+ }, 8 /* PROPS */, ["open"])], 2 /* CLASS */);
139
+ };
140
+ }
141
+ });
142
+ export default __sfc_main__;
@@ -0,0 +1,124 @@
1
+ import { defineComponent as _defineComponent } from 'vue';
2
+ import { unref as _unref, createVNode as _createVNode, withCtx as _withCtx, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, createBlock as _createBlock } from "vue";
3
+ const _hoisted_1 = {
4
+ key: 0,
5
+ style: {
6
+ "width": "240px"
7
+ }
8
+ };
9
+ import { ref, reactive } from 'vue';
10
+ import { Form, Button, FormItem, Popover, Textarea, message } from 'ant-design-vue';
11
+ import { isFunction } from 'lodash-es';
12
+ import { useLocaleReceiver } from '../../LocaleReciver';
13
+ const __sfc_main__ = _defineComponent({
14
+ __name: 'SaveHistory',
15
+ props: {
16
+ terms: {
17
+ type: Object,
18
+ default: () => ({})
19
+ },
20
+ target: {
21
+ type: String,
22
+ default: '',
23
+ required: true
24
+ },
25
+ request: {
26
+ type: Function,
27
+ default: null
28
+ }
29
+ },
30
+ setup(__props) {
31
+ const props = __props;
32
+ const [contextLocale] = useLocaleReceiver('Search');
33
+ const saveHistoryLoading = ref(false);
34
+ const visible = ref(false);
35
+ const formRef = ref();
36
+ const modelRef = reactive({
37
+ name: undefined
38
+ });
39
+ const visibleChange = e => {
40
+ visible.value = e;
41
+ if (!e) {
42
+ setTimeout(() => {
43
+ modelRef.name = undefined;
44
+ }, 100);
45
+ }
46
+ };
47
+
48
+ /**
49
+ * 保存当前查询条件
50
+ */
51
+ const saveHistory = async () => {
52
+ // 获取当前查询条件并转化为字符串
53
+ const formData = await formRef.value.validate();
54
+ if (formData && props.request && isFunction(props.request)) {
55
+ formData.content = JSON.stringify(props.terms);
56
+ saveHistoryLoading.value = true;
57
+ const resp = await props.request(formData, props.target);
58
+ saveHistoryLoading.value = false;
59
+ if (resp.success || resp.status === 200 || resp.code === 200) {
60
+ message.success(contextLocale.value.advanced.saveHistory.success);
61
+ visibleChange(false);
62
+ } else {
63
+ message.error(contextLocale.value.advanced.saveHistory.fail);
64
+ }
65
+ }
66
+ };
67
+ return (_ctx, _cache) => {
68
+ return _openBlock(), _createBlock(_unref(Popover), {
69
+ open: visible.value,
70
+ "onUpdate:open": _cache[1] || (_cache[1] = $event => visible.value = $event),
71
+ title: _unref(contextLocale).advanced.saveHistory.searchName,
72
+ trigger: "click",
73
+ placement: "bottom",
74
+ onVisibleChange: visibleChange
75
+ }, {
76
+ content: _withCtx(() => [visible.value ? (_openBlock(), _createElementBlock("div", _hoisted_1, [_createVNode(_unref(Form), {
77
+ ref_key: "formRef",
78
+ ref: formRef,
79
+ model: modelRef
80
+ }, {
81
+ default: _withCtx(() => [_createVNode(_unref(FormItem), {
82
+ name: "name",
83
+ rules: [{
84
+ required: true,
85
+ message: _unref(contextLocale).advanced.saveHistory.placeholder
86
+ }, {
87
+ max: 64,
88
+ message: _unref(contextLocale).advanced.saveHistory.ruleName
89
+ }]
90
+ }, {
91
+ default: _withCtx(() => [_createVNode(_unref(Textarea), {
92
+ value: modelRef.name,
93
+ "onUpdate:value": _cache[0] || (_cache[0] = $event => modelRef.name = $event),
94
+ rows: 3,
95
+ maxlength: 200
96
+ }, null, 8 /* PROPS */, ["value"])]),
97
+ _: 1 /* STABLE */
98
+ }, 8 /* PROPS */, ["rules"])]),
99
+ _: 1 /* STABLE */
100
+ }, 8 /* PROPS */, ["model"]), _createVNode(_unref(Button), {
101
+ loading: saveHistoryLoading.value,
102
+ type: "primary",
103
+ class: "save-btn",
104
+ style: {
105
+ "width": "100%"
106
+ },
107
+ onClick: saveHistory
108
+ }, {
109
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(_unref(contextLocale).advanced.saveHistory.save), 1 /* TEXT */)]),
110
+ _: 1 /* STABLE */
111
+ }, 8 /* PROPS */, ["loading"])])) : _createCommentVNode("v-if", true)]),
112
+ default: _withCtx(() => [_createVNode(_unref(Button), {
113
+ ghost: "",
114
+ type: "primary"
115
+ }, {
116
+ default: _withCtx(() => [_createTextVNode(_toDisplayString(_unref(contextLocale).advanced.saveHistory.save), 1 /* TEXT */)]),
117
+ _: 1 /* STABLE */
118
+ })]),
119
+ _: 1 /* STABLE */
120
+ }, 8 /* PROPS */, ["open", "title"]);
121
+ };
122
+ }
123
+ });
124
+ export default __sfc_main__;