ns-base-module 2.0.6 → 2.0.7
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.
|
@@ -33,7 +33,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
33
33
|
// import { initLang } from "@/utils/language";
|
|
34
34
|
import { CopyOutlined, DeleteOutlined, PlusOutlined, SettingOutlined } from "@ant-design/icons";
|
|
35
35
|
import { Button, Checkbox, Input, message, Popconfirm, Popover, Radio, Tooltip, Tree } from "antd";
|
|
36
|
-
import { cloneDeep,
|
|
36
|
+
import { cloneDeep, get, isArray, isEmpty } from "lodash";
|
|
37
37
|
import React, { memo, useEffect, useMemo, useState } from "react";
|
|
38
38
|
import { DndProvider } from "react-dnd";
|
|
39
39
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
@@ -42,7 +42,7 @@ import "../../style/components/TableHeaderConfigPopover.scss";
|
|
|
42
42
|
import IconCreate from "../Icon";
|
|
43
43
|
import { initLang } from "../utils/language";
|
|
44
44
|
import { queryColumnsConfig, setFormTemplates } from "../utils/services/global";
|
|
45
|
-
import {
|
|
45
|
+
import { adapterColumns, sortColums } from "./utils";
|
|
46
46
|
// 设置界面
|
|
47
47
|
var ColumnsToolbarRender = /*#__PURE__*/memo(function (props) {
|
|
48
48
|
var columns = props.columns,
|
|
@@ -705,6 +705,18 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
705
705
|
_useState20 = _slicedToArray(_useState19, 2),
|
|
706
706
|
curItem = _useState20[0],
|
|
707
707
|
setCurItem = _useState20[1];
|
|
708
|
+
var mode = useMemo(function () {
|
|
709
|
+
try {
|
|
710
|
+
var userInfoStr = window.localStorage.getItem("userInfo");
|
|
711
|
+
if (userInfoStr) {
|
|
712
|
+
var userInfo = JSON.parse(userInfoStr);
|
|
713
|
+
return get(userInfo, "userPreferenceConfig.mode", "");
|
|
714
|
+
}
|
|
715
|
+
return "";
|
|
716
|
+
} catch (error) {
|
|
717
|
+
return "";
|
|
718
|
+
}
|
|
719
|
+
}, []);
|
|
708
720
|
var saveTempale = /*#__PURE__*/function () {
|
|
709
721
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(params) {
|
|
710
722
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
@@ -736,7 +748,7 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
736
748
|
var getColumnsFilter = /*#__PURE__*/function () {
|
|
737
749
|
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
738
750
|
var _res;
|
|
739
|
-
var res, _res2, _templateUser, _template;
|
|
751
|
+
var res, _res2, _templateUser, _template, hasDefault;
|
|
740
752
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
741
753
|
while (1) switch (_context4.prev = _context4.next) {
|
|
742
754
|
case 0:
|
|
@@ -769,6 +781,7 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
769
781
|
if ((_res = res) !== null && _res !== void 0 && (_res = _res.data) !== null && _res !== void 0 && _res.data) {
|
|
770
782
|
_templateUser = [];
|
|
771
783
|
_template = [];
|
|
784
|
+
hasDefault = false;
|
|
772
785
|
(_res2 = res) === null || _res2 === void 0 || (_res2 = _res2.data) === null || _res2 === void 0 || _res2.data.forEach(function (item) {
|
|
773
786
|
if (item.perms_type === "private") {
|
|
774
787
|
_templateUser.push(item);
|
|
@@ -776,6 +789,11 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
776
789
|
_template.push(item);
|
|
777
790
|
}
|
|
778
791
|
if (item.is_default === "Y") {
|
|
792
|
+
hasDefault = true;
|
|
793
|
+
setValue(item.value);
|
|
794
|
+
setCurItem(item);
|
|
795
|
+
}
|
|
796
|
+
if (item.is_default_public === "Y" && !hasDefault) {
|
|
779
797
|
setValue(item.value);
|
|
780
798
|
setCurItem(item);
|
|
781
799
|
}
|
|
@@ -812,39 +830,36 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
812
830
|
var handleSet = function handleSet(item) {
|
|
813
831
|
try {
|
|
814
832
|
// 匹配是否有字段修改
|
|
815
|
-
|
|
816
|
-
// 删掉新数组没有的字段
|
|
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
|
-
for (var _j = 0, _k2 = props.columns.length; _j < _k2; _j++) {
|
|
846
|
-
_loop3(_j);
|
|
847
|
-
}
|
|
833
|
+
// const JsonPares = JSON.parse(item.define) as any;
|
|
834
|
+
// // 删掉新数组没有的字段
|
|
835
|
+
// for (let j = 0, k = JsonPares.length; j < k; j++) {
|
|
836
|
+
// const _code = JsonPares[j].code ? "code" : "dataIndex";
|
|
837
|
+
// if (!find(props.columns, (o) => o[_code] === JsonPares[j][_code])) {
|
|
838
|
+
// JsonPares.splice(j, 1);
|
|
839
|
+
// k -= 1;
|
|
840
|
+
// }
|
|
841
|
+
// }
|
|
842
|
+
// // 新增新数组字段 || 更新名称
|
|
843
|
+
// for (let j = 0, k = props.columns.length; j < k; j++) {
|
|
844
|
+
// const _code = props.columns[j].code ? "code" : "dataIndex";
|
|
845
|
+
// const _findItem = find(
|
|
846
|
+
// JsonPares,
|
|
847
|
+
// (o) => o[_code] === props.columns[j][_code]
|
|
848
|
+
// );
|
|
849
|
+
// if (!_findItem) {
|
|
850
|
+
// JsonPares.push(initColumns([props.columns[j]], null)[0]);
|
|
851
|
+
// } else {
|
|
852
|
+
// // 更新名称
|
|
853
|
+
// if (_findItem.title !== props.columns[j].title) {
|
|
854
|
+
// _findItem.title = props.columns[j].title;
|
|
855
|
+
// }
|
|
856
|
+
// }
|
|
857
|
+
// }
|
|
858
|
+
|
|
859
|
+
var _adapterColumns = adapterColumns([_objectSpread(_objectSpread({}, item), {}, {
|
|
860
|
+
is_default: "Y"
|
|
861
|
+
})], props.columns),
|
|
862
|
+
JsonPares = _adapterColumns.JsonPares;
|
|
848
863
|
setColumnsCofnig(JsonPares);
|
|
849
864
|
setShowConfig(true);
|
|
850
865
|
setEditItem(item);
|
|
@@ -941,15 +956,15 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
941
956
|
var cancel = function cancel() {};
|
|
942
957
|
|
|
943
958
|
// 设置默认
|
|
944
|
-
var handleSaveDefault = function handleSaveDefault(isDefault) {
|
|
959
|
+
var handleSaveDefault = function handleSaveDefault(isDefault, code) {
|
|
945
960
|
var arr = [].concat(_toConsumableArray(templateUser), _toConsumableArray(template));
|
|
946
961
|
arr.forEach(function (item) {
|
|
947
962
|
if (item.value === value) {
|
|
948
963
|
saveTempale({
|
|
949
964
|
menu_code: menuCode,
|
|
950
965
|
form_template_code: formTemplateCode,
|
|
951
|
-
is_default: isDefault,
|
|
952
|
-
is_default_public: isDefault,
|
|
966
|
+
is_default: code !== "public" ? isDefault : "N",
|
|
967
|
+
is_default_public: code === "public" ? isDefault : "N",
|
|
953
968
|
code: item === null || item === void 0 ? void 0 : item.value,
|
|
954
969
|
name: item === null || item === void 0 ? void 0 : item.label,
|
|
955
970
|
configs: item === null || item === void 0 ? void 0 : item.define,
|
|
@@ -962,7 +977,10 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
962
977
|
id: "message.success.set"
|
|
963
978
|
}));
|
|
964
979
|
// 刷新列表
|
|
965
|
-
|
|
980
|
+
setCurItem(_objectSpread(_objectSpread({}, item), {}, {
|
|
981
|
+
is_default: code !== "public" ? isDefault : "N",
|
|
982
|
+
is_default_public: code === "public" ? isDefault : "N"
|
|
983
|
+
}));
|
|
966
984
|
getColumnsFilter();
|
|
967
985
|
}
|
|
968
986
|
});
|
|
@@ -1099,11 +1117,11 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1099
1117
|
}, /*#__PURE__*/React.createElement(Radio, {
|
|
1100
1118
|
value: item.value,
|
|
1101
1119
|
className: "list-radio-label"
|
|
1102
|
-
}, item.label), item.
|
|
1120
|
+
}, item.label), item.is_default_public === "Y" && /*#__PURE__*/React.createElement("span", {
|
|
1103
1121
|
className: "set-text-default"
|
|
1104
1122
|
}, initLang({
|
|
1105
1123
|
id: "prompt.text.default"
|
|
1106
|
-
})),
|
|
1124
|
+
})), /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
1107
1125
|
placement: "top",
|
|
1108
1126
|
title: initLang({
|
|
1109
1127
|
id: "prompt.copyTemplate"
|
|
@@ -1146,27 +1164,48 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1146
1164
|
return handleSet(item);
|
|
1147
1165
|
}
|
|
1148
1166
|
}))));
|
|
1149
|
-
}))),
|
|
1167
|
+
}))), /*#__PURE__*/React.createElement("div", {
|
|
1150
1168
|
style: {
|
|
1151
1169
|
position: "absolute",
|
|
1152
1170
|
left: 12,
|
|
1153
1171
|
bottom: 16
|
|
1154
1172
|
}
|
|
1155
|
-
}, (curItem === null || curItem === void 0 ? void 0 : curItem.is_default) === "Y" ? /*#__PURE__*/React.createElement(Button, {
|
|
1173
|
+
}, (curItem === null || curItem === void 0 ? void 0 : curItem.perms_type) !== "public" && /*#__PURE__*/React.createElement(React.Fragment, null, (curItem === null || curItem === void 0 ? void 0 : curItem.is_default) === "Y" ? /*#__PURE__*/React.createElement(Button, {
|
|
1156
1174
|
onClick: function onClick() {
|
|
1157
1175
|
return handleSaveDefault("N");
|
|
1158
1176
|
},
|
|
1159
|
-
size: "small"
|
|
1177
|
+
size: "small",
|
|
1178
|
+
type: "primary"
|
|
1160
1179
|
}, initLang({
|
|
1161
1180
|
id: "button.set.cancelDefault"
|
|
1162
1181
|
})) : /*#__PURE__*/React.createElement(Button, {
|
|
1163
1182
|
onClick: function onClick() {
|
|
1164
1183
|
return handleSaveDefault("Y");
|
|
1165
1184
|
},
|
|
1166
|
-
size: "small"
|
|
1185
|
+
size: "small",
|
|
1186
|
+
type: "primary"
|
|
1167
1187
|
}, initLang({
|
|
1168
1188
|
id: "button.set.default"
|
|
1169
|
-
})), /*#__PURE__*/React.createElement(Button, {
|
|
1189
|
+
}))), (curItem === null || curItem === void 0 ? void 0 : curItem.perms_type) == "public" && mode === "DEV" && /*#__PURE__*/React.createElement(React.Fragment, null, (curItem === null || curItem === void 0 ? void 0 : curItem.is_default_public) === "Y" ? /*#__PURE__*/React.createElement(Button, {
|
|
1190
|
+
onClick: function onClick() {
|
|
1191
|
+
return handleSaveDefault("N", "public");
|
|
1192
|
+
},
|
|
1193
|
+
size: "small",
|
|
1194
|
+
type: "primary"
|
|
1195
|
+
}, initLang({
|
|
1196
|
+
id: "button.set.cancelDefault"
|
|
1197
|
+
})) : /*#__PURE__*/React.createElement(Popconfirm, {
|
|
1198
|
+
title: "\u6CA1\u6709\u8BBE\u7F6E\u4E2A\u4EBA\u6A21\u677F\u7684\u7528\u6237\u5C06\u4F1A\u9ED8\u8BA4\u5230\u8BE5\u516C\u5171\u6A21\u677F!",
|
|
1199
|
+
onConfirm: function onConfirm() {
|
|
1200
|
+
handleSaveDefault("Y", "public");
|
|
1201
|
+
}
|
|
1202
|
+
// onCancel={() => {}}
|
|
1203
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1204
|
+
size: "small",
|
|
1205
|
+
type: "primary"
|
|
1206
|
+
}, initLang({
|
|
1207
|
+
id: "button.set.default"
|
|
1208
|
+
})))), /*#__PURE__*/React.createElement(Button, {
|
|
1170
1209
|
style: {
|
|
1171
1210
|
marginLeft: 8
|
|
1172
1211
|
},
|
|
@@ -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
|
// 子级是动态列 父级也必须是
|
|
@@ -126,9 +127,19 @@ export function adapterColumns(customColumns, columns) {
|
|
|
126
127
|
_loop2(k, j);
|
|
127
128
|
}
|
|
128
129
|
};
|
|
130
|
+
var item = null;
|
|
129
131
|
for (var n = 0, leng = customColumns.length; n < leng; n++) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
+
if (customColumns[n].is_default_public == "Y") {
|
|
133
|
+
item = customColumns[n];
|
|
134
|
+
}
|
|
135
|
+
if (customColumns[n].is_default == "Y") {
|
|
136
|
+
item = customColumns[n];
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
var _item2;
|
|
142
|
+
if ((_item2 = item) !== null && _item2 !== void 0 && _item2.is_default) {
|
|
132
143
|
var JsonPares = JSON.parse(item.define);
|
|
133
144
|
|
|
134
145
|
// 删 旧模板多出的字段
|
|
@@ -220,6 +231,11 @@ export function adapterColumns(customColumns, columns) {
|
|
|
220
231
|
item: item
|
|
221
232
|
};
|
|
222
233
|
}
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return {
|
|
236
|
+
JsonPares: null,
|
|
237
|
+
item: null
|
|
238
|
+
};
|
|
223
239
|
}
|
|
224
240
|
}
|
|
225
241
|
return {
|