@cmstops/pro-compo 0.3.31 → 0.3.32

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.
Files changed (67) hide show
  1. package/dist/index.css +84 -0
  2. package/dist/index.min.css +1 -1
  3. package/es/hooks/useAttachement.d.ts +20 -0
  4. package/es/hooks/useAttachement.js +95 -0
  5. package/es/hooks/useSelection.d.ts +23 -0
  6. package/es/hooks/useSelection.js +59 -0
  7. package/es/index.css +84 -0
  8. package/es/index.d.ts +2 -0
  9. package/es/index.js +2 -0
  10. package/es/index.less +2 -0
  11. package/es/selectResourceModal/component.d.ts +0 -0
  12. package/es/selectResourceModal/component.js +211 -0
  13. package/es/selectResourceModal/components/ListContent/index.d.ts +0 -0
  14. package/es/selectResourceModal/components/ListContent/index.js +92 -0
  15. package/es/selectResourceModal/components/ListFilter/index.d.ts +0 -0
  16. package/es/selectResourceModal/components/ListFilter/index.js +259 -0
  17. package/es/selectResourceModal/components/ListFilter/scripts/api.d.ts +1 -0
  18. package/es/selectResourceModal/components/ListFilter/scripts/api.js +9 -0
  19. package/es/selectResourceModal/components/ListSelected/index.d.ts +0 -0
  20. package/es/selectResourceModal/components/ListSelected/index.js +91 -0
  21. package/es/selectResourceModal/index.d.ts +2 -0
  22. package/es/selectResourceModal/index.js +7 -0
  23. package/es/selectResourceModal/style/css.js +4 -0
  24. package/es/selectResourceModal/style/index.css +31 -0
  25. package/es/selectResourceModal/style/index.d.ts +4 -0
  26. package/es/selectResourceModal/style/index.js +4 -0
  27. package/es/selectResourceModal/style/index.less +39 -0
  28. package/es/selectResourceModal/style/listContent.less +67 -0
  29. package/es/selectResourceModal/style/listFilter.less +17 -0
  30. package/es/selectResourceModal/style/listSelected.less +67 -0
  31. package/es/thumbCard/component.d.ts +0 -0
  32. package/es/thumbCard/component.js +114 -0
  33. package/es/thumbCard/index.d.ts +2 -0
  34. package/es/thumbCard/index.js +7 -0
  35. package/es/thumbCard/style/css.js +1 -0
  36. package/es/thumbCard/style/index.css +53 -0
  37. package/es/thumbCard/style/index.d.ts +1 -0
  38. package/es/thumbCard/style/index.js +1 -0
  39. package/es/thumbCard/style/index.less +70 -0
  40. package/es/utils/typeMap.d.ts +19 -0
  41. package/es/utils/typeMap.js +17 -1
  42. package/lib/hooks/useAttachement.js +100 -0
  43. package/lib/hooks/useSelection.js +60 -0
  44. package/lib/index.css +84 -0
  45. package/lib/index.js +4 -0
  46. package/lib/index.less +2 -0
  47. package/lib/selectResourceModal/component.js +212 -0
  48. package/lib/selectResourceModal/components/ListContent/index.js +93 -0
  49. package/lib/selectResourceModal/components/ListFilter/index.js +260 -0
  50. package/lib/selectResourceModal/components/ListFilter/scripts/api.js +11 -0
  51. package/lib/selectResourceModal/components/ListSelected/index.js +92 -0
  52. package/lib/selectResourceModal/index.js +8 -0
  53. package/lib/selectResourceModal/style/css.js +5 -0
  54. package/lib/selectResourceModal/style/index.css +31 -0
  55. package/lib/selectResourceModal/style/index.js +5 -0
  56. package/lib/selectResourceModal/style/index.less +39 -0
  57. package/lib/selectResourceModal/style/listContent.less +67 -0
  58. package/lib/selectResourceModal/style/listFilter.less +17 -0
  59. package/lib/selectResourceModal/style/listSelected.less +67 -0
  60. package/lib/thumbCard/component.js +115 -0
  61. package/lib/thumbCard/index.js +8 -0
  62. package/lib/thumbCard/style/css.js +2 -0
  63. package/lib/thumbCard/style/index.css +53 -0
  64. package/lib/thumbCard/style/index.js +2 -0
  65. package/lib/thumbCard/style/index.less +70 -0
  66. package/lib/utils/typeMap.js +20 -0
  67. package/package.json +2 -2
@@ -0,0 +1,23 @@
1
+ declare type QueryParams = {
2
+ limit: number;
3
+ offset: number;
4
+ keyword: string;
5
+ others?: any;
6
+ };
7
+ declare type HookOptionParams = {
8
+ labelStr: string;
9
+ valueStr: string;
10
+ func: (params: QueryParams) => any;
11
+ };
12
+ export default function useSelection(params: HookOptionParams): {
13
+ options: import("vue").Ref<{
14
+ label: string;
15
+ value: any;
16
+ }[]>;
17
+ loading: import("vue").Ref<boolean>;
18
+ keyword: import("vue").Ref<string>;
19
+ load: (more?: boolean | undefined) => Promise<void>;
20
+ handleSearch: (kw: string) => void;
21
+ loadMore: () => void;
22
+ };
23
+ export {};
@@ -0,0 +1,59 @@
1
+ import { ref, computed } from "vue";
2
+ function getLabelValue(list, options) {
3
+ const { labelStr, valueStr } = options;
4
+ return list.map((item) => {
5
+ return {
6
+ label: item[labelStr],
7
+ value: item[valueStr]
8
+ };
9
+ });
10
+ }
11
+ function useSelection(params) {
12
+ const { func, labelStr, valueStr } = params;
13
+ const lVParams = { labelStr, valueStr };
14
+ const limit = ref(10);
15
+ const offset = ref(0);
16
+ const keyword = ref("");
17
+ const options = ref([]);
18
+ const loading = ref(false);
19
+ const queryParams = computed(() => {
20
+ return {
21
+ limit: limit.value,
22
+ offset: offset.value,
23
+ keyword: keyword.value
24
+ };
25
+ });
26
+ async function load(more) {
27
+ loading.value = !more;
28
+ try {
29
+ const list = await func(queryParams.value);
30
+ if (more) {
31
+ options.value = options.value.concat(getLabelValue(list, lVParams));
32
+ } else {
33
+ options.value = getLabelValue(list, lVParams);
34
+ }
35
+ } catch (e) {
36
+ console.log(e);
37
+ } finally {
38
+ loading.value = false;
39
+ }
40
+ }
41
+ function loadMore() {
42
+ offset.value += limit.value;
43
+ load(true);
44
+ }
45
+ function handleSearch(kw) {
46
+ keyword.value = kw;
47
+ offset.value = 0;
48
+ load();
49
+ }
50
+ return {
51
+ options,
52
+ loading,
53
+ keyword,
54
+ load,
55
+ handleSearch,
56
+ loadMore
57
+ };
58
+ }
59
+ export { useSelection as default };
package/es/index.css CHANGED
@@ -4243,3 +4243,87 @@
4243
4243
  color: #fff;
4244
4244
  font-size: 18px;
4245
4245
  }
4246
+ .thumb-select-wrapper {
4247
+ position: relative;
4248
+ display: flex;
4249
+ align-items: center;
4250
+ justify-content: center;
4251
+ width: 100%;
4252
+ height: 100%;
4253
+ overflow: hidden;
4254
+ border-radius: 2px;
4255
+ cursor: pointer;
4256
+ }
4257
+ .thumb-select-wrapper .thumb-add {
4258
+ color: var(--color-text-2);
4259
+ font-size: 16px;
4260
+ cursor: pointer;
4261
+ }
4262
+ .thumb-select-wrapper .thumb-image img {
4263
+ width: 100%;
4264
+ height: 100%;
4265
+ }
4266
+ .thumb-select-wrapper .thumb-handler-list {
4267
+ position: absolute;
4268
+ bottom: 0;
4269
+ display: flex;
4270
+ gap: 10px;
4271
+ align-items: center;
4272
+ justify-content: center;
4273
+ width: 100%;
4274
+ height: 40px;
4275
+ opacity: 0;
4276
+ transition: all 0.3s ease-in-out;
4277
+ }
4278
+ .thumb-select-wrapper .thumb-handler-list .handler-item {
4279
+ padding: 0 8px;
4280
+ color: #fff;
4281
+ font-size: 12px;
4282
+ line-height: 26px;
4283
+ background-color: #000000b3;
4284
+ border-radius: 2px;
4285
+ cursor: pointer;
4286
+ }
4287
+ .thumb-select-wrapper .thumb-handler-list .handler-item:hover {
4288
+ color: rgba(255, 255, 255, 0.7);
4289
+ }
4290
+ .thumb-select-wrapper:hover .thumb-handler-list {
4291
+ opacity: 1;
4292
+ }
4293
+ .arco-dropdown-option-content {
4294
+ display: flex;
4295
+ gap: 8px;
4296
+ align-items: center;
4297
+ font-size: 14px;
4298
+ }
4299
+ .resource-select-container {
4300
+ display: flex;
4301
+ flex-direction: column;
4302
+ gap: 10px;
4303
+ box-sizing: border-box;
4304
+ height: 100%;
4305
+ }
4306
+ .resource-select-container .resource-select-filter,
4307
+ .resource-select-container .resource-select-content,
4308
+ .resource-select-container .resource-select-footer {
4309
+ padding: 0 16px 0;
4310
+ }
4311
+ .resource-select-container .resource-select-header .arco-tabs-nav::before {
4312
+ display: none;
4313
+ }
4314
+ .resource-select-container .resource-select-header .arco-tabs-content {
4315
+ display: none !important;
4316
+ }
4317
+ .resource-select-container .resource-select-content {
4318
+ flex: 1;
4319
+ overflow: hidden;
4320
+ }
4321
+ .resource-select-container .resource-select-footer {
4322
+ display: flex;
4323
+ justify-content: space-between;
4324
+ }
4325
+ .resource-select-container .resource-select-footer .footer-right {
4326
+ display: flex;
4327
+ gap: 10px;
4328
+ align-items: center;
4329
+ }
package/es/index.d.ts CHANGED
@@ -22,3 +22,5 @@ export { default as dataTags } from './dataTags';
22
22
  export { default as colorPalette } from './colorPalette';
23
23
  export { default as resourceGridList } from './resourceGridList';
24
24
  export { default as mediaView } from './mediaView';
25
+ export { default as thumbCard } from './thumbCard';
26
+ export { default as selectResourceModal } from './selectResourceModal';
package/es/index.js CHANGED
@@ -22,3 +22,5 @@ export { default as dataTags } from "./dataTags/index.js";
22
22
  export { default as colorPalette } from "./colorPalette/index.js";
23
23
  export { default as resourceGridList } from "./resourceGridList/index.js";
24
24
  export { default as mediaView } from "./mediaView/index.js";
25
+ export { default as thumbCard } from "./thumbCard/index.js";
26
+ export { default as selectResourceModal } from "./selectResourceModal/index.js";
package/es/index.less CHANGED
@@ -22,3 +22,5 @@
22
22
  @import './colorPalette/style/index.less';
23
23
  @import './resourceGridList/style/index.less';
24
24
  @import './mediaView/style/index.less';
25
+ @import './thumbCard/style/index.less';
26
+ @import './selectResourceModal/style/index.less';
File without changes
@@ -0,0 +1,211 @@
1
+ import { defineComponent, ref, provide, computed, onMounted, openBlock, createBlock, unref, withCtx, createElementBlock, createCommentVNode, createElementVNode, createVNode, createTextVNode } from "vue";
2
+ import { Drawer, Tabs, Button, TabPane, Scrollbar, Pagination } from "@arco-design/web-vue";
3
+ import emptyData from "../emptyData/index.js";
4
+ import _sfc_main$1 from "./components/ListFilter/index.js";
5
+ import _sfc_main$2 from "./components/ListContent/index.js";
6
+ import _sfc_main$3 from "./components/ListSelected/index.js";
7
+ import useAttachement from "../hooks/useAttachement.js";
8
+ import { DEFAULT_BASE_API } from "../config.js";
9
+ const _hoisted_1 = {
10
+ key: 0,
11
+ class: "resource-select-container"
12
+ };
13
+ const _hoisted_2 = { class: "resource-select-header" };
14
+ const _hoisted_3 = {
15
+ key: 0,
16
+ class: "resource-select-filter"
17
+ };
18
+ const _hoisted_4 = { class: "resource-select-content" };
19
+ const _hoisted_5 = { class: "resource-select-footer" };
20
+ const _hoisted_6 = { class: "footer-left" };
21
+ const _hoisted_7 = {
22
+ key: 0,
23
+ class: "footer-right"
24
+ };
25
+ const _sfc_main = defineComponent({
26
+ ...{ name: "selectResourceModal" },
27
+ __name: "component",
28
+ props: {
29
+ BASE_API: {},
30
+ visible: { type: Boolean },
31
+ userInfo: {},
32
+ maxcount: {}
33
+ },
34
+ emits: ["update:visible", "submit"],
35
+ setup(__props, { emit: __emit }) {
36
+ const props = __props;
37
+ const emits = __emit;
38
+ const BASE_API = props.BASE_API || DEFAULT_BASE_API;
39
+ const activeKey = ref("all");
40
+ provide("userInfo", computed(() => props.userInfo));
41
+ provide("baseAPI", BASE_API);
42
+ const {
43
+ list,
44
+ total,
45
+ limit,
46
+ loading,
47
+ changeKey,
48
+ changeFilter,
49
+ changePage,
50
+ changeSize,
51
+ loadData
52
+ } = useAttachement({ key: "all", BASE_API });
53
+ const selected = ref([]);
54
+ const selectedKeys = computed(() => selected.value.map((item) => item.id));
55
+ const disableSelect = computed(() => props.maxcount && selected.value.length >= props.maxcount);
56
+ function handleSelect(params) {
57
+ const { id } = params;
58
+ const index = selected.value.findIndex((item) => item.id === id);
59
+ if (index > -1)
60
+ selected.value.splice(index, 1);
61
+ else
62
+ selected.value.push(params);
63
+ }
64
+ function handleClear() {
65
+ selected.value = [];
66
+ }
67
+ function handleClose() {
68
+ handleClear();
69
+ emits("update:visible", false);
70
+ }
71
+ const handleSelectOne = (params) => {
72
+ if (Array.isArray(params))
73
+ emits("submit", params);
74
+ else
75
+ emits("submit", [params]);
76
+ handleClose();
77
+ };
78
+ function handleConfirm() {
79
+ handleSelectOne(selected.value);
80
+ }
81
+ function handleToUpload() {
82
+ changeKey("local");
83
+ activeKey.value = "local";
84
+ }
85
+ onMounted(() => {
86
+ loadData();
87
+ });
88
+ return (_ctx, _cache) => {
89
+ return openBlock(), createBlock(unref(Drawer), {
90
+ visible: _ctx.visible,
91
+ width: "1024px",
92
+ header: false,
93
+ footer: false
94
+ }, {
95
+ default: withCtx(() => [
96
+ _ctx.userInfo ? (openBlock(), createElementBlock("div", _hoisted_1, [
97
+ createCommentVNode(" \u5934\u90E8 "),
98
+ createElementVNode("div", _hoisted_2, [
99
+ createVNode(unref(Tabs), {
100
+ "active-key": activeKey.value,
101
+ "onUpdate:activeKey": _cache[0] || (_cache[0] = ($event) => activeKey.value = $event),
102
+ onChange: unref(changeKey)
103
+ }, {
104
+ extra: withCtx(() => [
105
+ createVNode(unref(Button), {
106
+ type: "text",
107
+ onClick: handleClose
108
+ }, {
109
+ default: withCtx(() => [
110
+ createTextVNode("\u5173\u95ED")
111
+ ]),
112
+ _: 1
113
+ })
114
+ ]),
115
+ default: withCtx(() => [
116
+ createVNode(unref(TabPane), {
117
+ key: "all",
118
+ title: "\u5168\u90E8\u7D20\u6750"
119
+ }),
120
+ createVNode(unref(TabPane), {
121
+ key: "my",
122
+ title: "\u6211\u7684\u7D20\u6750"
123
+ }),
124
+ createVNode(unref(TabPane), {
125
+ key: "remind",
126
+ title: "\u63D0\u9192\u6211\u7684"
127
+ }),
128
+ createVNode(unref(TabPane), {
129
+ key: "local",
130
+ title: "\u672C\u5730\u7D20\u6750"
131
+ })
132
+ ]),
133
+ _: 1
134
+ }, 8, ["active-key", "onChange"])
135
+ ]),
136
+ createCommentVNode(" \u7B5B\u9009 "),
137
+ activeKey.value !== "local" ? (openBlock(), createElementBlock("div", _hoisted_3, [
138
+ createVNode(_sfc_main$1, {
139
+ "disable-upload-by": activeKey.value !== "all",
140
+ onChange: unref(changeFilter),
141
+ onUpload: handleToUpload
142
+ }, null, 8, ["disable-upload-by", "onChange"])
143
+ ])) : createCommentVNode("v-if", true),
144
+ createCommentVNode(" \u5217\u8868\u90E8\u5206 "),
145
+ createElementVNode("div", _hoisted_4, [
146
+ createVNode(unref(Scrollbar), {
147
+ "outer-style": { height: "100%" },
148
+ style: { "height": "100%", "overflow": "auto" }
149
+ }, {
150
+ default: withCtx(() => [
151
+ createVNode(_sfc_main$2, {
152
+ loading: unref(loading),
153
+ list: unref(list),
154
+ disable: disableSelect.value,
155
+ "select-keys": selectedKeys.value,
156
+ onSelect: handleSelect,
157
+ onSelectOne: handleSelectOne
158
+ }, null, 8, ["loading", "list", "disable", "select-keys"])
159
+ ]),
160
+ _: 1
161
+ })
162
+ ]),
163
+ createCommentVNode(" \u5E95\u90E8 "),
164
+ createElementVNode("div", _hoisted_5, [
165
+ createElementVNode("div", _hoisted_6, [
166
+ activeKey.value !== "local" ? (openBlock(), createBlock(unref(Pagination), {
167
+ key: 0,
168
+ total: unref(total),
169
+ "page-size": unref(limit),
170
+ "show-total": "",
171
+ "show-page-size": "",
172
+ onChange: _cache[1] || (_cache[1] = (e) => unref(changePage)((e - 1) * unref(limit))),
173
+ onPageSizeChange: unref(changeSize)
174
+ }, null, 8, ["total", "page-size", "onPageSizeChange"])) : createCommentVNode("v-if", true)
175
+ ]),
176
+ selected.value.length ? (openBlock(), createElementBlock("div", _hoisted_7, [
177
+ createVNode(_sfc_main$3, {
178
+ maxcount: _ctx.maxcount,
179
+ selected: selected.value,
180
+ onRemove: handleSelect,
181
+ onClear: handleClear
182
+ }, null, 8, ["maxcount", "selected"]),
183
+ createVNode(unref(Button), { onClick: handleClose }, {
184
+ default: withCtx(() => [
185
+ createTextVNode("\u53D6\u6D88")
186
+ ]),
187
+ _: 1
188
+ }),
189
+ createVNode(unref(Button), {
190
+ type: "primary",
191
+ onClick: handleConfirm
192
+ }, {
193
+ default: withCtx(() => [
194
+ createTextVNode("\u786E\u5B9A")
195
+ ]),
196
+ _: 1
197
+ })
198
+ ])) : createCommentVNode("v-if", true)
199
+ ])
200
+ ])) : (openBlock(), createBlock(unref(emptyData), {
201
+ key: 1,
202
+ type: "empty",
203
+ customTip: "\u6682\u65E0\u6743\u9650"
204
+ }))
205
+ ]),
206
+ _: 1
207
+ }, 8, ["visible"]);
208
+ };
209
+ }
210
+ });
211
+ export { _sfc_main as default };
@@ -0,0 +1,92 @@
1
+ import { defineComponent, computed, openBlock, createElementBlock, Fragment, renderList, createElementVNode, createVNode, unref, toDisplayString, createCommentVNode, createBlock } from "vue";
2
+ import { Spin } from "@arco-design/web-vue";
3
+ import emptyData from "../../../emptyData/index.js";
4
+ import thumbCard from "../../../thumbCard/index.js";
5
+ const _hoisted_1 = { class: "card-list-wrapper" };
6
+ const _hoisted_2 = { class: "card-wrapper" };
7
+ const _hoisted_3 = { class: "card-alias" };
8
+ const _hoisted_4 = ["onClick"];
9
+ const _hoisted_5 = {
10
+ key: 0,
11
+ class: "check-box active"
12
+ };
13
+ const _hoisted_6 = {
14
+ key: 1,
15
+ class: "check-box"
16
+ };
17
+ const _sfc_main = defineComponent({
18
+ __name: "index",
19
+ props: {
20
+ loading: { type: Boolean },
21
+ list: {},
22
+ selectKeys: {},
23
+ disable: { type: Boolean }
24
+ },
25
+ emits: ["select", "select-one"],
26
+ setup(__props, { emit: __emit }) {
27
+ const props = __props;
28
+ const emits = __emit;
29
+ const handlersKey = computed(() => {
30
+ var _a;
31
+ if (((_a = props.selectKeys) == null ? void 0 : _a.length) > 0 || props.disable)
32
+ return [];
33
+ return [{ label: "\u9009\u7528", key: "select" }];
34
+ });
35
+ function handleOption(params) {
36
+ const { key, item } = params;
37
+ if (key === "select") {
38
+ emits("select-one", item);
39
+ }
40
+ }
41
+ function handleCheck(params) {
42
+ emits("select", params);
43
+ }
44
+ const selectedOrder = computed(() => {
45
+ var _a;
46
+ const result = {};
47
+ (_a = props.selectKeys) == null ? void 0 : _a.forEach((key, index) => {
48
+ result[key] = index + 1;
49
+ });
50
+ return result;
51
+ });
52
+ return (_ctx, _cache) => {
53
+ var _a, _b;
54
+ return openBlock(), createElementBlock("div", _hoisted_1, [
55
+ (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.list, (item) => {
56
+ return openBlock(), createElementBlock("div", {
57
+ key: item.id,
58
+ class: "card-wrapper-image"
59
+ }, [
60
+ createElementVNode("div", _hoisted_2, [
61
+ createVNode(unref(thumbCard), {
62
+ url: item.url,
63
+ thumb: item.thumb,
64
+ catalog: item.catalog,
65
+ meta: item,
66
+ "handlers-key": handlersKey.value,
67
+ onHandle: handleOption
68
+ }, null, 8, ["url", "thumb", "catalog", "meta", "handlers-key"])
69
+ ]),
70
+ createElementVNode("div", _hoisted_3, toDisplayString(item.alias), 1),
71
+ createElementVNode("div", {
72
+ class: "check-box-wrapper",
73
+ onClick: () => handleCheck(item)
74
+ }, [
75
+ selectedOrder.value[item.id] ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(selectedOrder.value[item.id]), 1)) : !_ctx.disable ? (openBlock(), createElementBlock("div", _hoisted_6)) : createCommentVNode("v-if", true)
76
+ ], 8, _hoisted_4)
77
+ ]);
78
+ }), 128)),
79
+ createCommentVNode(" \u7A7A\u72B6\u6001 "),
80
+ ((_a = _ctx.list) == null ? void 0 : _a.length) === 0 && _ctx.loading ? (openBlock(), createBlock(unref(Spin), {
81
+ key: 0,
82
+ loading: true
83
+ })) : !((_b = _ctx.list) == null ? void 0 : _b.length) ? (openBlock(), createBlock(unref(emptyData), {
84
+ key: 1,
85
+ type: "empty",
86
+ customTip: "\u6682\u65E0\u6570\u636E"
87
+ })) : createCommentVNode("v-if", true)
88
+ ]);
89
+ };
90
+ }
91
+ });
92
+ export { _sfc_main as default };