ns-base-module 1.1.66 → 1.1.68
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.
|
@@ -32,7 +32,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
32
32
|
// import { initLang } from "@/utils/language";
|
|
33
33
|
import { CopyOutlined, DeleteOutlined, PlusOutlined, SettingOutlined, ShareAltOutlined, UserOutlined } from "@ant-design/icons";
|
|
34
34
|
import { Button, Checkbox, Input, message, Popconfirm, Popover, Radio, Tooltip, Tree } from "antd";
|
|
35
|
-
import { cloneDeep,
|
|
35
|
+
import { cloneDeep, isArray, isEmpty } from "lodash";
|
|
36
36
|
import React, { memo, useEffect, useMemo, useState } from "react";
|
|
37
37
|
import { DndProvider } from "react-dnd";
|
|
38
38
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
@@ -40,7 +40,7 @@ import Dustbin from "./Dustbin";
|
|
|
40
40
|
import "../../style/components/TableHeaderConfigPopover.scss";
|
|
41
41
|
import { initLang } from "../utils/language";
|
|
42
42
|
import { queryColumnsConfig, setFormTemplates } from "../utils/services/global";
|
|
43
|
-
import {
|
|
43
|
+
import { adapterColumns, sortColums } from "./utils";
|
|
44
44
|
// 设置界面
|
|
45
45
|
var ColumnsToolbarRender = /*#__PURE__*/memo(function (props) {
|
|
46
46
|
var columns = props.columns,
|
|
@@ -738,7 +738,7 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
738
738
|
var getColumnsFilter = /*#__PURE__*/function () {
|
|
739
739
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
740
740
|
var _res;
|
|
741
|
-
var res, _res2, _templateUser, _template;
|
|
741
|
+
var res, _res2, _templateUser, _template, hasDefault;
|
|
742
742
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
743
743
|
while (1) switch (_context4.prev = _context4.next) {
|
|
744
744
|
case 0:
|
|
@@ -771,6 +771,7 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
771
771
|
if ((_res = res) !== null && _res !== void 0 && (_res = _res.data) !== null && _res !== void 0 && _res.data) {
|
|
772
772
|
_templateUser = [];
|
|
773
773
|
_template = [];
|
|
774
|
+
hasDefault = false;
|
|
774
775
|
(_res2 = res) === null || _res2 === void 0 || (_res2 = _res2.data) === null || _res2 === void 0 || _res2.data.forEach(function (item) {
|
|
775
776
|
if (item.perms_type === "private") {
|
|
776
777
|
_templateUser.push(item);
|
|
@@ -778,6 +779,11 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
778
779
|
_template.push(item);
|
|
779
780
|
}
|
|
780
781
|
if (item.is_default === "Y") {
|
|
782
|
+
hasDefault = true;
|
|
783
|
+
setValue(item.value);
|
|
784
|
+
setCurItem(item);
|
|
785
|
+
}
|
|
786
|
+
if (item.is_default_public === "Y" && !hasDefault) {
|
|
781
787
|
setValue(item.value);
|
|
782
788
|
setCurItem(item);
|
|
783
789
|
}
|
|
@@ -814,39 +820,36 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
814
820
|
var handleSet = function handleSet(item) {
|
|
815
821
|
try {
|
|
816
822
|
// 匹配是否有字段修改
|
|
817
|
-
|
|
818
|
-
// 删掉新数组没有的字段
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
//
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
}
|
|
846
|
-
|
|
847
|
-
for (var _j = 0, _k2 = props.columns.length; _j < _k2; _j++) {
|
|
848
|
-
_loop3(_j);
|
|
849
|
-
}
|
|
823
|
+
// const JsonPares = JSON.parse(item.define) as any;
|
|
824
|
+
// // 删掉新数组没有的字段
|
|
825
|
+
// for (let j = 0, k = JsonPares.length; j < k; j++) {
|
|
826
|
+
// const _code = JsonPares[j].code ? "code" : "dataIndex";
|
|
827
|
+
// if (!find(props.columns, (o) => o[_code] === JsonPares[j][_code])) {
|
|
828
|
+
// JsonPares.splice(j, 1);
|
|
829
|
+
// k -= 1;
|
|
830
|
+
// }
|
|
831
|
+
// }
|
|
832
|
+
// // 新增新数组字段 || 更新名称
|
|
833
|
+
// for (let j = 0, k = props.columns.length; j < k; j++) {
|
|
834
|
+
// const _code = props.columns[j].code ? "code" : "dataIndex";
|
|
835
|
+
// const _findItem = find(
|
|
836
|
+
// JsonPares,
|
|
837
|
+
// (o) => o[_code] === props.columns[j][_code]
|
|
838
|
+
// );
|
|
839
|
+
// if (!_findItem) {
|
|
840
|
+
// JsonPares.push(initColumns([props.columns[j]], null)[0]);
|
|
841
|
+
// } else {
|
|
842
|
+
// // 更新名称
|
|
843
|
+
// if (_findItem.title !== props.columns[j].title) {
|
|
844
|
+
// _findItem.title = props.columns[j].title;
|
|
845
|
+
// }
|
|
846
|
+
// }
|
|
847
|
+
// }
|
|
848
|
+
|
|
849
|
+
var _adapterColumns = adapterColumns([_objectSpread(_objectSpread({}, item), {}, {
|
|
850
|
+
is_default: "Y"
|
|
851
|
+
})], props.columns),
|
|
852
|
+
JsonPares = _adapterColumns.JsonPares;
|
|
850
853
|
setColumnsCofnig(JsonPares);
|
|
851
854
|
setShowConfig(true);
|
|
852
855
|
setEditItem(item);
|
|
@@ -964,7 +967,10 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
964
967
|
id: "message.success.set"
|
|
965
968
|
}));
|
|
966
969
|
// 刷新列表
|
|
967
|
-
|
|
970
|
+
setCurItem(_objectSpread(_objectSpread({}, item), {}, {
|
|
971
|
+
is_default: code !== "public" ? isDefault : "N",
|
|
972
|
+
is_default_public: code === "public" ? isDefault : "N"
|
|
973
|
+
}));
|
|
968
974
|
getColumnsFilter();
|
|
969
975
|
}
|
|
970
976
|
});
|
|
@@ -1102,7 +1108,7 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1102
1108
|
}, /*#__PURE__*/React.createElement(Radio, {
|
|
1103
1109
|
value: item.value,
|
|
1104
1110
|
className: "list-radio-label"
|
|
1105
|
-
}, item.label), item.
|
|
1111
|
+
}, item.label), item.is_default_public === "Y" && /*#__PURE__*/React.createElement("span", {
|
|
1106
1112
|
className: "set-text-default"
|
|
1107
1113
|
}, initLang({
|
|
1108
1114
|
id: "prompt.text.default"
|
|
@@ -46,7 +46,8 @@ export var initColumns = function initColumns(arr, parent) {
|
|
|
46
46
|
var flatColumns = function flatColumns(_columns) {
|
|
47
47
|
var initArr = [];
|
|
48
48
|
var flatArr = function flatArr(arr) {
|
|
49
|
-
|
|
49
|
+
var _arr$forEach;
|
|
50
|
+
arr === null || arr === void 0 || (_arr$forEach = arr.forEach) === null || _arr$forEach === void 0 || _arr$forEach.call(arr, function (item) {
|
|
50
51
|
initArr.push(item);
|
|
51
52
|
if (Array.isArray(item.children) && item.children.length) {
|
|
52
53
|
// 子级是动态列 父级也必须是
|
|
@@ -105,7 +106,6 @@ var updateTemplateFilds = function updateTemplateFilds(JsonPares, _columns) {
|
|
|
105
106
|
* */
|
|
106
107
|
export function adapterColumns(customColumns, columns) {
|
|
107
108
|
if (customColumns && customColumns.length && columns && columns.length) {
|
|
108
|
-
var _item2;
|
|
109
109
|
// 展平 columns, 1,子是动态列 父级必须是,父级的表头宽度取决于子级设置.2,子级是浮动 父级同步 解决首行选择框的浮动
|
|
110
110
|
var _columns = flatColumns(columns);
|
|
111
111
|
var itemLoop = function itemLoop(arr, commad) {
|
|
@@ -137,98 +137,101 @@ export function adapterColumns(customColumns, columns) {
|
|
|
137
137
|
break;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
var
|
|
140
|
+
try {
|
|
141
|
+
var _item2;
|
|
142
|
+
if ((_item2 = item) !== null && _item2 !== void 0 && _item2.is_default) {
|
|
143
|
+
var JsonPares = JSON.parse(item.define);
|
|
142
144
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
// 删 旧模板多出的字段
|
|
146
|
+
itemLoop(JsonPares, "del");
|
|
145
147
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
// 展平 columns
|
|
149
|
+
var flaJsonPares = flatColumns(JsonPares);
|
|
150
|
+
// 增 新字段加最后
|
|
151
|
+
var _loop3 = function _loop3(j) {
|
|
152
|
+
var _code = _columns[j].code ? "code" : "dataIndex";
|
|
153
|
+
if (!find(flaJsonPares, function (o) {
|
|
154
|
+
return o[_code] === _columns[j][_code];
|
|
155
|
+
})) {
|
|
156
|
+
var _item = initColumns([_columns[j]], null)[0];
|
|
157
|
+
if (_item.customizable !== false) {
|
|
158
|
+
// 不是动态列
|
|
159
|
+
if (_item.fixed === "left") {
|
|
160
|
+
JsonPares.unshift(_item);
|
|
161
|
+
} else {
|
|
162
|
+
JsonPares.push(_item);
|
|
163
|
+
}
|
|
161
164
|
}
|
|
162
165
|
}
|
|
163
|
-
}
|
|
164
166
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
167
|
+
// 动态列 columns[j].customizable === false 不能用模板,用列表数据
|
|
168
|
+
if (_columns[j].customizable === false && _code) {
|
|
169
|
+
var loopSetChildren = function loopSetChildren(arr1, arr2) {
|
|
170
|
+
arr1.forEach(function (d) {
|
|
171
|
+
var h = find(arr2, function (o) {
|
|
172
|
+
return o[_code] === d[_code];
|
|
173
|
+
});
|
|
174
|
+
if (h) {
|
|
175
|
+
d.width = h.width;
|
|
176
|
+
d.fixed = h.fixed;
|
|
177
|
+
d.checked = h.checked;
|
|
178
|
+
}
|
|
179
|
+
if (d.children && d.children.length && h !== null && h !== void 0 && h.children && h !== null && h !== void 0 && h.children.length) {
|
|
180
|
+
loopSetChildren(d.children, h.children);
|
|
181
|
+
}
|
|
171
182
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
checked: _JsonPares[i].checked
|
|
189
|
-
};
|
|
190
|
-
_columns[j] = _objectSpread(_objectSpread({}, _columns[j]), obj);
|
|
191
|
-
if (_columns[j].children && _columns[j].children.length && _JsonPares[i].children && _JsonPares[i].children.length) {
|
|
192
|
-
loopSetChildren(_columns[j].children, _JsonPares[i].children);
|
|
183
|
+
};
|
|
184
|
+
var loopSetZable = function loopSetZable(_JsonPares) {
|
|
185
|
+
for (var i = 0, l = _JsonPares.length; i < l; i++) {
|
|
186
|
+
if (_columns[j][_code] === _JsonPares[i][_code]) {
|
|
187
|
+
var obj = {
|
|
188
|
+
width: _JsonPares[i].width,
|
|
189
|
+
fixed: _JsonPares[i].fixed,
|
|
190
|
+
checked: _JsonPares[i].checked
|
|
191
|
+
};
|
|
192
|
+
_columns[j] = _objectSpread(_objectSpread({}, _columns[j]), obj);
|
|
193
|
+
if (_columns[j].children && _columns[j].children.length && _JsonPares[i].children && _JsonPares[i].children.length) {
|
|
194
|
+
loopSetChildren(_columns[j].children, _JsonPares[i].children);
|
|
195
|
+
}
|
|
196
|
+
var d = initColumns([_columns[j]], null)[0];
|
|
197
|
+
_JsonPares[i] = _objectSpread({}, d);
|
|
198
|
+
return;
|
|
193
199
|
}
|
|
194
|
-
|
|
195
|
-
_JsonPares[i]
|
|
196
|
-
|
|
200
|
+
// else {
|
|
201
|
+
// if (_JsonPares[i].children && _JsonPares[i].children.length) {
|
|
202
|
+
// loopSetZable(_JsonPares[i].children);
|
|
203
|
+
// }
|
|
204
|
+
// }
|
|
197
205
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
};
|
|
205
|
-
loopSetZable(JsonPares);
|
|
206
|
+
};
|
|
207
|
+
loopSetZable(JsonPares);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
for (var j = 0, k = _columns.length; j < k; j++) {
|
|
211
|
+
_loop3(j);
|
|
206
212
|
}
|
|
207
|
-
};
|
|
208
|
-
for (var j = 0, k = _columns.length; j < k; j++) {
|
|
209
|
-
_loop3(j);
|
|
210
|
-
}
|
|
211
213
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
214
|
+
// 子级是否全部 浮动
|
|
215
|
+
JsonPares.forEach(function (dd) {
|
|
216
|
+
if (dd.fixed && dd.children && dd.children.length) {
|
|
217
|
+
var isAllChildrenFixed = true;
|
|
218
|
+
dd.children.forEach(function (hh) {
|
|
219
|
+
if (hh.checked && hh.fixed !== dd.fixed) {
|
|
220
|
+
isAllChildrenFixed = false;
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
dd.isAllChildrenFixed = isAllChildrenFixed;
|
|
224
|
+
}
|
|
225
|
+
});
|
|
224
226
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
// 替成新配置
|
|
228
|
+
updateTemplateFilds(JsonPares, _columns);
|
|
229
|
+
return {
|
|
230
|
+
JsonPares: JsonPares,
|
|
231
|
+
item: item
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
} catch (error) {}
|
|
232
235
|
}
|
|
233
236
|
return {
|
|
234
237
|
JsonPares: null,
|