cnhis-design-vue 3.0.2 → 3.0.5

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.
@@ -0,0 +1,351 @@
1
+ import { defineComponent, ref, reactive, onMounted, computed, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode, normalizeClass, createCommentVNode, createBlock, renderSlot, normalizeStyle, toDisplayString, withDirectives, vShow, vModelSelect, vModelText, pushScopeId, popScopeId, createTextVNode } from 'vue';
2
+ import draggable from 'vuedraggable';
3
+ import { NSpin, NCheckbox, NTooltip, NButton } from 'naive-ui';
4
+
5
+ const KEY_COMPONENT_NAME = "C";
6
+
7
+ function create(vm) {
8
+ vm.name = KEY_COMPONENT_NAME + (vm.name || "");
9
+ return vm;
10
+ }
11
+
12
+ const _withScopeId = (n) => (pushScopeId("data-v-726261b7"), n = n(), popScopeId(), n);
13
+ const _hoisted_1 = { class: "fields-set-content" };
14
+ const _hoisted_2 = { class: "fields-table" };
15
+ const _hoisted_3 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", {
16
+ class: "width-show",
17
+ style: { "width": "4%" }
18
+ }, null, -1));
19
+ const _hoisted_4 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "width-large" }, "\u6240\u6709\u5B57\u6BB5", -1));
20
+ const _hoisted_5 = { class: "width-show" };
21
+ const _hoisted_6 = /* @__PURE__ */ createTextVNode(" \u663E\u793A ");
22
+ const _hoisted_7 = { class: "width-show" };
23
+ const _hoisted_8 = /* @__PURE__ */ createTextVNode(" \u6392\u5E8F ");
24
+ const _hoisted_9 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "width-showed" }, "\u56FA\u5B9A", -1));
25
+ const _hoisted_10 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "width-word" }, "\u81EA\u5B9A\u4E49\u6807\u9898", -1));
26
+ const _hoisted_11 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { class: "width-showed" }, "\u5217\u5BBD", -1));
27
+ const _hoisted_12 = ["onClick"];
28
+ const _hoisted_13 = { class: "width-show drag-icon-wrap" };
29
+ const _hoisted_14 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", {
30
+ class: "iconfont icon-a-menzhenyishengzhanxitongtubiaotuozhuai",
31
+ style: { "color": "#000" }
32
+ }, null, -1));
33
+ const _hoisted_15 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", null, "\u62D6\u62FD\u8C03\u6574\u987A\u5E8F", -1));
34
+ const _hoisted_16 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("span", { style: { "width": "14px", "margin-right": "6px" } }, null, -1));
35
+ const _hoisted_17 = { class: "width-show" };
36
+ const _hoisted_18 = { class: "width-show" };
37
+ const _hoisted_19 = { class: "width-showed" };
38
+ const _hoisted_20 = ["onUpdate:modelValue"];
39
+ const _hoisted_21 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("option", { value: 0 }, "\u4E0D\u56FA\u5B9A", -1));
40
+ const _hoisted_22 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("option", { value: 1 }, "\u5DE6\u56FA\u5B9A", -1));
41
+ const _hoisted_23 = /* @__PURE__ */ _withScopeId(() => /* @__PURE__ */ createElementVNode("option", { value: 2 }, "\u53F3\u56FA\u5B9A", -1));
42
+ const _hoisted_24 = [
43
+ _hoisted_21,
44
+ _hoisted_22,
45
+ _hoisted_23
46
+ ];
47
+ const _hoisted_25 = { class: "width-word" };
48
+ const _hoisted_26 = ["onUpdate:modelValue"];
49
+ const _hoisted_27 = { class: "width-showed" };
50
+ const _hoisted_28 = ["onUpdate:modelValue"];
51
+ const _hoisted_29 = {
52
+ key: 0,
53
+ class: "check-options"
54
+ };
55
+ const _hoisted_30 = { class: "btn-operate" };
56
+ const _hoisted_31 = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
57
+ const _hoisted_32 = /* @__PURE__ */ createTextVNode("\u4FDD\u5B58");
58
+ const __default__ = create({
59
+ name: "FieldSet"
60
+ });
61
+ var script = /* @__PURE__ */ defineComponent({
62
+ ...__default__,
63
+ props: {
64
+ fields: {
65
+ type: Array,
66
+ default: function () {
67
+ return [];
68
+ }
69
+ },
70
+ menuSource: {
71
+ type: String,
72
+ default: ""
73
+ },
74
+ drawerDirection: {
75
+ type: String,
76
+ default: "right"
77
+ },
78
+ footerFlag: {
79
+ type: Boolean,
80
+ default: true
81
+ }
82
+ },
83
+ emits: ["onSave", "onClose"],
84
+ setup(__props, { emit }) {
85
+ const props = __props;
86
+ const settingView = ref(null);
87
+ const state = reactive({
88
+ spinning: false,
89
+ isCustomSearch: true,
90
+ clickItem: {},
91
+ fields: props.fields
92
+ });
93
+ onMounted(() => {
94
+ hideTab();
95
+ });
96
+ const leftStyle = (ele) => {
97
+ return {
98
+ background: state.clickItem.sid === ele.sid ? "#f2f2f2" : void 0
99
+ };
100
+ };
101
+ const isMiddleAndAdmin = computed(() => props.menuSource == "middle");
102
+ const showCheckBox = (key) => {
103
+ return state.fields.some((i) => Object.prototype.hasOwnProperty.call(i, key));
104
+ };
105
+ const hideTab = () => {
106
+ if (isMiddleAndAdmin.value)
107
+ return;
108
+ if (props.drawerDirection === "right") {
109
+ settingView.value?.style.setProperty("margin", "auto");
110
+ }
111
+ else {
112
+ settingView.value?.style.setProperty("margin", "auto");
113
+ }
114
+ };
115
+ const handleFieldSave = () => {
116
+ let tableFields = [];
117
+ if (state.fields.length > 0) {
118
+ state.fields.forEach((item, i) => {
119
+ tableFields.push({
120
+ id: item.sid,
121
+ field: item.columnName,
122
+ visible: item.isShow == 1,
123
+ sequence: i,
124
+ sortable: item.isSort == 1,
125
+ title: item.alias || item.title,
126
+ fixed: item.isFixed ? item.isFixed == 1 ? "left" : "right" : "",
127
+ minWidth: item.colWidth
128
+ });
129
+ });
130
+ }
131
+ console.log("tableFields", tableFields);
132
+ emit("onSave", { tableFields });
133
+ };
134
+ const onCancle = () => {
135
+ emit("onClose");
136
+ };
137
+ const onChangeShow = (e, ele) => {
138
+ if (e == true) {
139
+ ele.isShow = 1;
140
+ }
141
+ else {
142
+ ele.isShow = 0;
143
+ }
144
+ };
145
+ const onChangeSort = (e, ele) => {
146
+ if (e == true) {
147
+ ele.isSort = 1;
148
+ }
149
+ else {
150
+ ele.isSort = 0;
151
+ }
152
+ };
153
+ const calculateCheck = (key) => {
154
+ if (!state.fields.length)
155
+ return false;
156
+ return state.fields.every((i) => {
157
+ if (!Object.prototype.hasOwnProperty.call(i, key))
158
+ return true;
159
+ return i[key];
160
+ });
161
+ };
162
+ const handleAllCheck = (e, key) => {
163
+ const value = e ? 1 : 0;
164
+ const data = state.fields.map((i) => {
165
+ if (Object.prototype.hasOwnProperty.call(i, key)) {
166
+ i[key] = value;
167
+ }
168
+ return i;
169
+ });
170
+ state.fields = data;
171
+ };
172
+ const handleFieldClick = (item) => {
173
+ state.clickItem = item;
174
+ };
175
+ return (_ctx, _cache) => {
176
+ return openBlock(), createElementBlock("div", {
177
+ ref_key: "settingView",
178
+ ref: settingView,
179
+ class: "setting-view"
180
+ }, [
181
+ createVNode(unref(NSpin), {
182
+ show: unref(state).spinning,
183
+ tip: "...",
184
+ style: { "width": "100%", "height": "100%" }
185
+ }, {
186
+ default: withCtx(() => [
187
+ createElementVNode("div", _hoisted_1, [
188
+ createElementVNode("div", _hoisted_2, [
189
+ createElementVNode("div", {
190
+ class: normalizeClass(["setting-title", { "seting-title-api": !unref(state).isCustomSearch }])
191
+ }, [
192
+ _hoisted_3,
193
+ createCommentVNode(" \u5B57\u6BB5\u540D\u79F0 "),
194
+ _hoisted_4,
195
+ createCommentVNode(" \u663E\u793A "),
196
+ createElementVNode("span", _hoisted_5, [
197
+ showCheckBox("isShow") ? (openBlock(), createBlock(unref(NCheckbox), {
198
+ key: 0,
199
+ checked: calculateCheck("isShow"),
200
+ "onUpdate:checked": _cache[0] || (_cache[0] = ($event) => handleAllCheck($event, "isShow"))
201
+ }, null, 8, ["checked"])) : createCommentVNode("v-if", true),
202
+ _hoisted_6
203
+ ]),
204
+ createCommentVNode(" \u6392\u5E8F "),
205
+ createElementVNode("span", _hoisted_7, [
206
+ showCheckBox("isSort") ? (openBlock(), createBlock(unref(NCheckbox), {
207
+ key: 0,
208
+ checked: calculateCheck("isSort"),
209
+ "onUpdate:checked": _cache[1] || (_cache[1] = ($event) => handleAllCheck($event, "isSort"))
210
+ }, null, 8, ["checked"])) : createCommentVNode("v-if", true),
211
+ _hoisted_8
212
+ ]),
213
+ createCommentVNode(" \u56FA\u5B9A "),
214
+ _hoisted_9,
215
+ renderSlot(_ctx.$slots, "default", {}, () => [
216
+ createCommentVNode(" \u81EA\u5B9A\u4E49\u6807\u9898 "),
217
+ _hoisted_10
218
+ ]),
219
+ createCommentVNode(" \u5217\u5BBD "),
220
+ _hoisted_11
221
+ ], 2),
222
+ createElementVNode("div", {
223
+ ref: "setShow",
224
+ class: normalizeClass(["set-show", { "set-show-api": !unref(state).isCustomSearch }])
225
+ }, [
226
+ createVNode(unref(draggable), {
227
+ list: unref(state).fields,
228
+ animation: "150",
229
+ "item-key": "sid",
230
+ tag: "ul"
231
+ }, {
232
+ item: withCtx(({ element }) => [
233
+ createElementVNode("li", {
234
+ class: "left-style",
235
+ style: normalizeStyle(leftStyle(element)),
236
+ onClick: ($event) => handleFieldClick(element)
237
+ }, [
238
+ createElementVNode("span", _hoisted_13, [
239
+ createVNode(unref(NTooltip), { trigger: "hover" }, {
240
+ trigger: withCtx(() => [
241
+ _hoisted_14
242
+ ]),
243
+ default: withCtx(() => [
244
+ _hoisted_15
245
+ ]),
246
+ _: 1
247
+ })
248
+ ]),
249
+ createCommentVNode(" \u5B57\u6BB5\u540D\u79F0 "),
250
+ createElementVNode("span", {
251
+ class: normalizeClass(["width-large title-item", { blue: element.extraField }])
252
+ }, [
253
+ _hoisted_16,
254
+ createElementVNode("span", null, toDisplayString(element.title), 1)
255
+ ], 2),
256
+ createCommentVNode(" \u663E\u793A "),
257
+ createElementVNode("span", _hoisted_17, [
258
+ withDirectives(createVNode(unref(NCheckbox), {
259
+ "default-checked": element.isShow == "1",
260
+ checked: element.isShow == "1" ? true : false,
261
+ "onUpdate:checked": ($event) => onChangeShow($event, element)
262
+ }, null, 8, ["default-checked", "checked", "onUpdate:checked"]), [
263
+ [vShow, element.sid != "0001"]
264
+ ])
265
+ ]),
266
+ createCommentVNode(" \u6392\u5E8F "),
267
+ createElementVNode("span", _hoisted_18, [
268
+ withDirectives(createVNode(unref(NCheckbox), {
269
+ "default-checked": element.isSort == "1",
270
+ disabled: element.notParticipatingSort == 1,
271
+ checked: !!element.isSort,
272
+ "onUpdate:checked": ($event) => onChangeSort($event, element)
273
+ }, null, 8, ["default-checked", "disabled", "checked", "onUpdate:checked"]), [
274
+ [vShow, element.sid != "0001"]
275
+ ])
276
+ ]),
277
+ createCommentVNode(" \u56FA\u5B9A "),
278
+ createElementVNode("span", _hoisted_19, [
279
+ withDirectives(createElementVNode("select", {
280
+ "onUpdate:modelValue": ($event) => element.isFixed = $event,
281
+ class: "is-sort-style"
282
+ }, _hoisted_24, 8, _hoisted_20), [
283
+ [vModelSelect, element.isFixed]
284
+ ])
285
+ ]),
286
+ renderSlot(_ctx.$slots, "default", {}, () => [
287
+ createCommentVNode(" \u81EA\u5B9A\u4E49\u6807\u9898 "),
288
+ createElementVNode("span", _hoisted_25, [
289
+ withDirectives(createElementVNode("input", {
290
+ "onUpdate:modelValue": ($event) => element.alias = $event,
291
+ class: "alias-style"
292
+ }, null, 8, _hoisted_26), [
293
+ [vShow, element.sid != "0001"],
294
+ [vModelText, element.alias]
295
+ ])
296
+ ])
297
+ ]),
298
+ createCommentVNode(" \u5217\u5BBD "),
299
+ createElementVNode("span", _hoisted_27, [
300
+ withDirectives(createElementVNode("input", {
301
+ "onUpdate:modelValue": ($event) => element.colWidth = $event,
302
+ class: "alias-style col-width-style"
303
+ }, null, 8, _hoisted_28), [
304
+ [vModelText, element.colWidth]
305
+ ])
306
+ ])
307
+ ], 12, _hoisted_12)
308
+ ]),
309
+ _: 3
310
+ }, 8, ["list"])
311
+ ], 2)
312
+ ]),
313
+ props.footerFlag ? (openBlock(), createElementBlock("div", _hoisted_29, [
314
+ createElementVNode("div", _hoisted_30, [
315
+ createVNode(unref(NButton), {
316
+ style: { "margin-right": "8px" },
317
+ onClick: onCancle
318
+ }, {
319
+ default: withCtx(() => [
320
+ _hoisted_31
321
+ ]),
322
+ _: 1
323
+ }),
324
+ createVNode(unref(NButton), {
325
+ type: "primary",
326
+ onClick: handleFieldSave
327
+ }, {
328
+ default: withCtx(() => [
329
+ _hoisted_32
330
+ ]),
331
+ _: 1
332
+ })
333
+ ])
334
+ ])) : createCommentVNode("v-if", true)
335
+ ])
336
+ ]),
337
+ _: 3
338
+ }, 8, ["show"])
339
+ ], 512);
340
+ };
341
+ }
342
+ });
343
+
344
+ script.__scopeId = "data-v-726261b7";
345
+ script.__file = "packages/field-set/src/FieldSet.vue";
346
+
347
+ script.install = function (app) {
348
+ app.component(script.name, script);
349
+ };
350
+
351
+ export { script as default };