ns-base-module 1.1.65 → 1.1.67
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,
|
|
@@ -814,39 +814,36 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
814
814
|
var handleSet = function handleSet(item) {
|
|
815
815
|
try {
|
|
816
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
|
-
}
|
|
846
|
-
|
|
847
|
-
for (var _j = 0, _k2 = props.columns.length; _j < _k2; _j++) {
|
|
848
|
-
_loop3(_j);
|
|
849
|
-
}
|
|
817
|
+
// const JsonPares = JSON.parse(item.define) as any;
|
|
818
|
+
// // 删掉新数组没有的字段
|
|
819
|
+
// for (let j = 0, k = JsonPares.length; j < k; j++) {
|
|
820
|
+
// const _code = JsonPares[j].code ? "code" : "dataIndex";
|
|
821
|
+
// if (!find(props.columns, (o) => o[_code] === JsonPares[j][_code])) {
|
|
822
|
+
// JsonPares.splice(j, 1);
|
|
823
|
+
// k -= 1;
|
|
824
|
+
// }
|
|
825
|
+
// }
|
|
826
|
+
// // 新增新数组字段 || 更新名称
|
|
827
|
+
// for (let j = 0, k = props.columns.length; j < k; j++) {
|
|
828
|
+
// const _code = props.columns[j].code ? "code" : "dataIndex";
|
|
829
|
+
// const _findItem = find(
|
|
830
|
+
// JsonPares,
|
|
831
|
+
// (o) => o[_code] === props.columns[j][_code]
|
|
832
|
+
// );
|
|
833
|
+
// if (!_findItem) {
|
|
834
|
+
// JsonPares.push(initColumns([props.columns[j]], null)[0]);
|
|
835
|
+
// } else {
|
|
836
|
+
// // 更新名称
|
|
837
|
+
// if (_findItem.title !== props.columns[j].title) {
|
|
838
|
+
// _findItem.title = props.columns[j].title;
|
|
839
|
+
// }
|
|
840
|
+
// }
|
|
841
|
+
// }
|
|
842
|
+
|
|
843
|
+
var _adapterColumns = adapterColumns([_objectSpread(_objectSpread({}, item), {}, {
|
|
844
|
+
is_default: "Y"
|
|
845
|
+
})], props.columns),
|
|
846
|
+
JsonPares = _adapterColumns.JsonPares;
|
|
850
847
|
setColumnsCofnig(JsonPares);
|
|
851
848
|
setShowConfig(true);
|
|
852
849
|
setEditItem(item);
|
|
@@ -943,15 +940,15 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
943
940
|
var cancel = function cancel() {};
|
|
944
941
|
|
|
945
942
|
// 设置默认
|
|
946
|
-
var handleSaveDefault = function handleSaveDefault(isDefault) {
|
|
943
|
+
var handleSaveDefault = function handleSaveDefault(isDefault, code) {
|
|
947
944
|
var arr = [].concat(_toConsumableArray(templateUser), _toConsumableArray(template));
|
|
948
945
|
arr.forEach(function (item) {
|
|
949
946
|
if (item.value === value) {
|
|
950
947
|
saveTempale({
|
|
951
948
|
menu_code: menuCode,
|
|
952
949
|
form_template_code: formTemplateCode,
|
|
953
|
-
is_default: isDefault,
|
|
954
|
-
is_default_public: isDefault,
|
|
950
|
+
is_default: code !== "public" ? isDefault : "N",
|
|
951
|
+
is_default_public: code === "public" ? isDefault : "N",
|
|
955
952
|
code: item === null || item === void 0 ? void 0 : item.value,
|
|
956
953
|
name: item === null || item === void 0 ? void 0 : item.label,
|
|
957
954
|
configs: item === null || item === void 0 ? void 0 : item.define,
|
|
@@ -1171,7 +1168,26 @@ var ColumnsToolbar = function ColumnsToolbar(_ref4) {
|
|
|
1171
1168
|
type: "primary"
|
|
1172
1169
|
}, initLang({
|
|
1173
1170
|
id: "button.set.default"
|
|
1174
|
-
}))), /*#__PURE__*/React.createElement(Button, {
|
|
1171
|
+
}))), (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_public) === "Y" ? /*#__PURE__*/React.createElement(Button, {
|
|
1172
|
+
onClick: function onClick() {
|
|
1173
|
+
return handleSaveDefault("N", "public");
|
|
1174
|
+
},
|
|
1175
|
+
size: "small",
|
|
1176
|
+
type: "primary"
|
|
1177
|
+
}, initLang({
|
|
1178
|
+
id: "button.set.cancelDefault"
|
|
1179
|
+
})) : /*#__PURE__*/React.createElement(Popconfirm, {
|
|
1180
|
+
title: "\u6CA1\u6709\u8BBE\u7F6E\u4E2A\u4EBA\u6A21\u677F\u7684\u7528\u6237\u5C06\u4F1A\u9ED8\u8BA4\u5230\u8BE5\u516C\u5171\u6A21\u677F!",
|
|
1181
|
+
onConfirm: function onConfirm() {
|
|
1182
|
+
handleSaveDefault("Y", "public");
|
|
1183
|
+
}
|
|
1184
|
+
// onCancel={() => {}}
|
|
1185
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
1186
|
+
size: "small",
|
|
1187
|
+
type: "primary"
|
|
1188
|
+
}, initLang({
|
|
1189
|
+
id: "button.set.default"
|
|
1190
|
+
})))), /*#__PURE__*/React.createElement(Button, {
|
|
1175
1191
|
style: {
|
|
1176
1192
|
marginLeft: 8
|
|
1177
1193
|
},
|
|
@@ -105,6 +105,7 @@ var updateTemplateFilds = function updateTemplateFilds(JsonPares, _columns) {
|
|
|
105
105
|
* */
|
|
106
106
|
export function adapterColumns(customColumns, columns) {
|
|
107
107
|
if (customColumns && customColumns.length && columns && columns.length) {
|
|
108
|
+
var _item2;
|
|
108
109
|
// 展平 columns, 1,子是动态列 父级必须是,父级的表头宽度取决于子级设置.2,子级是浮动 父级同步 解决首行选择框的浮动
|
|
109
110
|
var _columns = flatColumns(columns);
|
|
110
111
|
var itemLoop = function itemLoop(arr, commad) {
|
|
@@ -126,100 +127,107 @@ 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
|
-
|
|
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
|
+
if ((_item2 = item) !== null && _item2 !== void 0 && _item2.is_default) {
|
|
141
|
+
var JsonPares = JSON.parse(item.define);
|
|
133
142
|
|
|
134
|
-
|
|
135
|
-
|
|
143
|
+
// 删 旧模板多出的字段
|
|
144
|
+
itemLoop(JsonPares, "del");
|
|
136
145
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
146
|
+
// 展平 columns
|
|
147
|
+
var flaJsonPares = flatColumns(JsonPares);
|
|
148
|
+
// 增 新字段加最后
|
|
149
|
+
var _loop3 = function _loop3(j) {
|
|
150
|
+
var _code = _columns[j].code ? "code" : "dataIndex";
|
|
151
|
+
if (!find(flaJsonPares, function (o) {
|
|
152
|
+
return o[_code] === _columns[j][_code];
|
|
153
|
+
})) {
|
|
154
|
+
var _item = initColumns([_columns[j]], null)[0];
|
|
155
|
+
if (_item.customizable !== false) {
|
|
156
|
+
// 不是动态列
|
|
157
|
+
if (_item.fixed === "left") {
|
|
158
|
+
JsonPares.unshift(_item);
|
|
159
|
+
} else {
|
|
160
|
+
JsonPares.push(_item);
|
|
153
161
|
}
|
|
154
162
|
}
|
|
163
|
+
}
|
|
155
164
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
});
|
|
163
|
-
if (h) {
|
|
164
|
-
d.width = h.width;
|
|
165
|
-
d.fixed = h.fixed;
|
|
166
|
-
d.checked = h.checked;
|
|
167
|
-
}
|
|
168
|
-
if (d.children && d.children.length && h !== null && h !== void 0 && h.children && h !== null && h !== void 0 && h.children.length) {
|
|
169
|
-
loopSetChildren(d.children, h.children);
|
|
170
|
-
}
|
|
165
|
+
// 动态列 columns[j].customizable === false 不能用模板,用列表数据
|
|
166
|
+
if (_columns[j].customizable === false && _code) {
|
|
167
|
+
var loopSetChildren = function loopSetChildren(arr1, arr2) {
|
|
168
|
+
arr1.forEach(function (d) {
|
|
169
|
+
var h = find(arr2, function (o) {
|
|
170
|
+
return o[_code] === d[_code];
|
|
171
171
|
});
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
_JsonPares[i]
|
|
187
|
-
|
|
172
|
+
if (h) {
|
|
173
|
+
d.width = h.width;
|
|
174
|
+
d.fixed = h.fixed;
|
|
175
|
+
d.checked = h.checked;
|
|
176
|
+
}
|
|
177
|
+
if (d.children && d.children.length && h !== null && h !== void 0 && h.children && h !== null && h !== void 0 && h.children.length) {
|
|
178
|
+
loopSetChildren(d.children, h.children);
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
var loopSetZable = function loopSetZable(_JsonPares) {
|
|
183
|
+
for (var i = 0, l = _JsonPares.length; i < l; i++) {
|
|
184
|
+
if (_columns[j][_code] === _JsonPares[i][_code]) {
|
|
185
|
+
var obj = {
|
|
186
|
+
width: _JsonPares[i].width,
|
|
187
|
+
fixed: _JsonPares[i].fixed,
|
|
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);
|
|
188
193
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
// }
|
|
193
|
-
// }
|
|
194
|
+
var d = initColumns([_columns[j]], null)[0];
|
|
195
|
+
_JsonPares[i] = _objectSpread({}, d);
|
|
196
|
+
return;
|
|
194
197
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
198
|
+
// else {
|
|
199
|
+
// if (_JsonPares[i].children && _JsonPares[i].children.length) {
|
|
200
|
+
// loopSetZable(_JsonPares[i].children);
|
|
201
|
+
// }
|
|
202
|
+
// }
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
loopSetZable(JsonPares);
|
|
201
206
|
}
|
|
207
|
+
};
|
|
208
|
+
for (var j = 0, k = _columns.length; j < k; j++) {
|
|
209
|
+
_loop3(j);
|
|
210
|
+
}
|
|
202
211
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
// 子级是否全部 浮动
|
|
213
|
+
JsonPares.forEach(function (dd) {
|
|
214
|
+
if (dd.fixed && dd.children && dd.children.length) {
|
|
215
|
+
var isAllChildrenFixed = true;
|
|
216
|
+
dd.children.forEach(function (hh) {
|
|
217
|
+
if (hh.checked && hh.fixed !== dd.fixed) {
|
|
218
|
+
isAllChildrenFixed = false;
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
dd.isAllChildrenFixed = isAllChildrenFixed;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
215
224
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
225
|
+
// 替成新配置
|
|
226
|
+
updateTemplateFilds(JsonPares, _columns);
|
|
227
|
+
return {
|
|
228
|
+
JsonPares: JsonPares,
|
|
229
|
+
item: item
|
|
230
|
+
};
|
|
223
231
|
}
|
|
224
232
|
}
|
|
225
233
|
return {
|