@titaui/pc 1.15.89-beta.7 → 1.15.89-beta.8

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.
@@ -176,7 +176,7 @@ var _default = function _default() {
176
176
  deWeightData[item.id] = item;
177
177
  });
178
178
  var result = Object.values(deWeightData);
179
- setRawTreeData(_toConsumableArray(result));
179
+ setRawTreeData([].concat(result));
180
180
  setTreeData((0, _utils.toTree)(rawTreeData));
181
181
  resolve(true);
182
182
  });
@@ -75,8 +75,6 @@ var KRWeight = function KRWeight(_ref) {
75
75
  };
76
76
 
77
77
  var handleBlur = function handleBlur(e) {
78
- var _e$target$innerText$s, _e$target$innerText$s2;
79
-
80
78
  e.persist();
81
79
  var inputValue = parseFloat(e.target.innerText);
82
80
 
@@ -91,8 +89,7 @@ var KRWeight = function KRWeight(_ref) {
91
89
  }
92
90
  }
93
91
 
94
- var pointNum = ((_e$target$innerText$s = e.target.innerText.split('.')[1]) === null || _e$target$innerText$s === void 0 ? void 0 : _e$target$innerText$s.length) >= 4 ? 4 : ((_e$target$innerText$s2 = e.target.innerText.split('.')[1]) === null || _e$target$innerText$s2 === void 0 ? void 0 : _e$target$innerText$s2.length) || 0;
95
- var resultValue = Number.isNaN(inputValue) ? 0 : inputValue.toFixed(pointNum);
92
+ var resultValue = Number.isNaN(inputValue) ? 0 : inputValue.toFixed(1);
96
93
  setInputValue(resultValue + '%');
97
94
 
98
95
  if (onChange) {
@@ -135,17 +132,16 @@ var krWeightRenderer = function krWeightRenderer(update) {
135
132
  }, [rootData]);
136
133
 
137
134
  var handleEditKRWeight = function handleEditKRWeight(data) {
138
- rootDataRef.current.krs[rowIdx].krWeight = parseFloat(data).toFixed(1);
135
+ rootDataRef.current.krs[rowIdx].krWeight = parseFloat(parseFloat(data).toFixed(1));
139
136
  var _rootDataRef$current$ = rootDataRef.current.krs,
140
137
  krs = _rootDataRef$current$ === void 0 ? [] : _rootDataRef$current$;
141
138
  var lastIndex = krs.length - 1;
142
139
  var totalWeight = krs.slice(0, lastIndex).reduce(function (pre, cur) {
143
140
  return pre + parseFloat(cur.krWeight);
144
- }, 0);
145
- console.log('totalWeight', totalWeight); // 自动计算最后一个 kr 的权重
141
+ }, 0); // 自动计算最后一个 kr 的权重
146
142
 
147
143
  rootDataRef.current.krs[lastIndex] = _objectSpread(_objectSpread({}, rootDataRef.current.krs[lastIndex]), {}, {
148
- krWeight: (100 - totalWeight).toFixed(1)
144
+ krWeight: parseFloat((100 - totalWeight).toFixed(1))
149
145
  });
150
146
  update({
151
147
  type: 'update',
@@ -161,11 +157,10 @@ var krWeightRenderer = function krWeightRenderer(update) {
161
157
  }).reduce(function (pre, cur) {
162
158
  return pre + parseFloat(cur) || 0;
163
159
  }, 0);
164
- console.log('totalWeight', totalWeight);
165
160
  return totalWeight <= 100;
166
161
  }, [rootData, rowIdx]);
167
162
  return /*#__PURE__*/_react["default"].createElement(KRWeight, {
168
- value: data.krWeight,
163
+ value: (data && data.krWeight || 0).toFixed(1),
169
164
  onChange: handleEditKRWeight,
170
165
  disabled: isLast,
171
166
  onChangeBefore: onChangeBefore
@@ -9,6 +9,11 @@
9
9
  cursor: pointer;
10
10
  }
11
11
 
12
+ .tita-okr-excel-create-okr-align__empty {
13
+ font-size: 14px;
14
+ color: #bfc7d5;
15
+ }
16
+
12
17
  .tita-okr-excel-create-okr-align__okr {
13
18
  display: flex;
14
19
  align-items: center;
@@ -23,10 +28,6 @@
23
28
  padding: 2px 6px;
24
29
  }
25
30
 
26
- .tita-okr-excel-create-okr-align__okr--empty {
27
- color: #bfc7d5;
28
- }
29
-
30
31
  .tita-okr-excel-create-okr-align__okr-name {
31
32
  overflow: hidden;
32
33
  text-overflow: ellipsis;
@@ -17,6 +17,8 @@ var _changeOkrModal = _interopRequireDefault(require("../../../change-okr-modal"
17
17
 
18
18
  var _tooltipText = _interopRequireDefault(require("../../../tooltip/tooltip-text"));
19
19
 
20
+ var _getLocale = require("../../../../utils/getLocale");
21
+
20
22
  require("./index.css");
21
23
 
22
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -94,7 +96,10 @@ var alignOKRRender = function alignOKRRender(update) {
94
96
  var renderAlignObj = (0, _react.useMemo)(function () {
95
97
  var _classNames;
96
98
 
97
- return parent.parentName && /*#__PURE__*/_react["default"].createElement("div", {
99
+ if (!parent.parentName) return /*#__PURE__*/_react["default"].createElement("p", {
100
+ className: "".concat(preCls, "__empty")
101
+ }, (0, _getLocale.getLocale)('Mod_Pleaseselect'));
102
+ return /*#__PURE__*/_react["default"].createElement("div", {
98
103
  className: "".concat(preCls, "__okr")
99
104
  }, /*#__PURE__*/_react["default"].createElement("i", {
100
105
  className: (0, _classnames["default"])("".concat(preCls, "__okr-icon"), (_classNames = {}, _defineProperty(_classNames, 'tu-icon-O', parent.parentType === 1), _defineProperty(_classNames, 'tu-icon-KR', parent.parentType !== 1), _classNames))
@@ -96,7 +96,7 @@ var Classify = function Classify(_ref) {
96
96
  }, OKRClassifyMap[value] ? /*#__PURE__*/_react["default"].createElement("img", {
97
97
  className: "".concat(prefix, "__content-img"),
98
98
  src: IconMap[value]
99
- }) : null, OKRClassifyMap[value] ? OKRClassifyMap[value] : '请选择')));
99
+ }) : null, OKRClassifyMap[value] ? OKRClassifyMap[value] : (0, _getLocale.getLocale)('Mod_Pleaseselect'))));
100
100
  };
101
101
 
102
102
  var _default = function _default(update) {
@@ -11,6 +11,10 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _richEditor = require("@titaui/rich-editor");
13
13
 
14
+ var _classnames = _interopRequireDefault(require("classnames"));
15
+
16
+ var _inputWithErrPopup = _interopRequireDefault(require("../../../create-okr-modal/fields/input-with-err-popup"));
17
+
14
18
  var _getLocale = require("../../../../utils/getLocale");
15
19
 
16
20
  var _i18nFrontTranslate = require("../../../../utils/i18n-front-translate");
@@ -19,8 +23,6 @@ var _utils = require("../../utils");
19
23
 
20
24
  require("./index.css");
21
25
 
22
- var _classnames = _interopRequireDefault(require("classnames"));
23
-
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
27
 
26
28
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -31,10 +33,6 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
31
33
 
32
34
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
33
35
 
34
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
35
-
36
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
37
-
38
36
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
39
37
 
40
38
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
@@ -45,10 +43,24 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
45
43
 
46
44
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
47
45
 
46
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
47
+
48
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
49
+
50
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
51
+
52
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
53
+
54
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
55
+
56
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
57
+
48
58
  var preCls = 'tita-okr-excel-create-okr-name';
49
59
 
50
60
  var OkrNameRenderer = function OkrNameRenderer(update, isO) {
51
61
  return function (_ref) {
62
+ var _okrNameData$pureText;
63
+
52
64
  var data = _ref.data,
53
65
  rowIdx = _ref.rowIdx,
54
66
  rootIdx = _ref.rootIdx,
@@ -65,7 +77,7 @@ var OkrNameRenderer = function OkrNameRenderer(update, isO) {
65
77
  // 如果不一致,则新增加的 kr 权重设置为 0
66
78
  var preKrWeight = -1;
67
79
  var updated = false;
68
- rootData.krs.findIndex(function (_ref2) {
80
+ rootDataRef.current.krs.findIndex(function (_ref2) {
69
81
  var krWeight = _ref2.krWeight;
70
82
 
71
83
  if (preKrWeight === -1) {
@@ -76,13 +88,15 @@ var OkrNameRenderer = function OkrNameRenderer(update, isO) {
76
88
  if (preKrWeight !== krWeight) updated = true;
77
89
  return updated;
78
90
  });
79
- rootData.krs.push(_objectSpread(_objectSpread({}, (0, _utils.getKrItemData)()), {}, {
91
+ rootDataRef.current.krs = [].concat(_toConsumableArray(rootDataRef.current.krs.map(function (item) {
92
+ return _objectSpread({}, item);
93
+ })), [_objectSpread(_objectSpread({}, (0, _utils.getKrItemData)()), {}, {
80
94
  krWeight: 0
81
- }));
95
+ })]);
82
96
 
83
97
  if (!updated) {
84
- var krWeight = (100 / rootData.krs.length).toFixed(1);
85
- rootData.krs = rootData.krs.map(function (item) {
98
+ var krWeight = parseFloat((100 / rootDataRef.current.krs.length).toFixed(1));
99
+ rootDataRef.current.krs = rootDataRef.current.krs.map(function (item) {
86
100
  return _objectSpread(_objectSpread({}, item), {}, {
87
101
  krWeight: krWeight
88
102
  });
@@ -92,7 +106,7 @@ var OkrNameRenderer = function OkrNameRenderer(update, isO) {
92
106
  update({
93
107
  type: 'update',
94
108
  rootIdx: rootIdx,
95
- itemData: rootData
109
+ itemData: rootDataRef.current
96
110
  });
97
111
  };
98
112
 
@@ -106,18 +120,13 @@ var OkrNameRenderer = function OkrNameRenderer(update, isO) {
106
120
 
107
121
  var _useState = (0, _react.useState)({
108
122
  richText: '',
123
+ pureTextExcludeAt: '',
109
124
  editorState: 'normal'
110
125
  }),
111
126
  _useState2 = _slicedToArray(_useState, 2),
112
127
  okrNameData = _useState2[0],
113
128
  setOkrNameData = _useState2[1];
114
129
 
115
- (0, _react.useEffect)(function () {
116
- setOkrNameData({
117
- richText: data.mileStoneNameRichText
118
- });
119
- }, [data.mileStoneNameRichText]);
120
-
121
130
  var _useState3 = (0, _react.useState)(''),
122
131
  _useState4 = _slicedToArray(_useState3, 2),
123
132
  errorTip = _useState4[0],
@@ -178,6 +187,7 @@ var OkrNameRenderer = function OkrNameRenderer(update, isO) {
178
187
  });
179
188
  };
180
189
 
190
+ var length = ((_okrNameData$pureText = okrNameData.pureTextExcludeAt) === null || _okrNameData$pureText === void 0 ? void 0 : _okrNameData$pureText.length) | 0;
181
191
  return /*#__PURE__*/_react["default"].createElement("div", {
182
192
  className: (0, _classnames["default"])("".concat(preCls), _defineProperty({}, "".concat(preCls, "--isO"), isO))
183
193
  }, /*#__PURE__*/_react["default"].createElement("span", {
@@ -185,14 +195,18 @@ var OkrNameRenderer = function OkrNameRenderer(update, isO) {
185
195
  }, isO ? 'O:' : "KR".concat(rowIdx + 1, ":")), /*#__PURE__*/_react["default"].createElement("span", {
186
196
  onClick: onRemoveHanlder,
187
197
  className: "".concat(preCls, "__close tu-icon-del")
188
- }), /*#__PURE__*/_react["default"].createElement(_richEditor.TitaInlineRichEditor, {
198
+ }), /*#__PURE__*/_react["default"].createElement(_inputWithErrPopup["default"], {
199
+ strLength: length,
200
+ maxLength: 500,
201
+ position: "top"
202
+ }, /*#__PURE__*/_react["default"].createElement(_richEditor.TitaInlineRichEditor, {
189
203
  key: okrNameData.editorState,
190
204
  editable: true,
191
205
  initialState: JSON.parse(data.workNameRichText || data.mileStoneNameRichText || '{}'),
192
206
  onDocChange: onChangeHandler,
193
207
  ref: mentionInputRef,
194
208
  placeholder: isO ? (0, _getLocale.getLocale)('OKR_MyO_Enteobjname') : (0, _getLocale.getLocale)('OKR_MyO_Pop_FillKeyR')
195
- }));
209
+ })));
196
210
  };
197
211
  };
198
212
 
@@ -53,6 +53,14 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
53
53
 
54
54
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
55
55
 
56
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
57
+
58
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
59
+
60
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
61
+
62
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
63
+
56
64
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
57
65
 
58
66
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -125,6 +133,7 @@ var OKRExcelCreate = function OKRExcelCreate(_ref3) {
125
133
  rootUuid = _ref4.rootUuid;
126
134
 
127
135
  if (type === 'update') {
136
+ itemData.krs = _toConsumableArray(itemData.krs);
128
137
  data.current[rootIdx] = itemData;
129
138
  }
130
139
 
@@ -146,8 +155,38 @@ var OKRExcelCreate = function OKRExcelCreate(_ref3) {
146
155
  });
147
156
  var krIndex = data.current[rootIndex].krs.findIndex(function (item) {
148
157
  return item.uuid === uuid;
158
+ }); // 重新计算最后一个 kr 的权重
159
+
160
+ var effectiveKrs = data.current[rootIndex].krs.filter(function (_ref5) {
161
+ var isDelete = _ref5.isDelete;
162
+ return !isDelete;
149
163
  });
150
- data.current[rootIndex].krs[krIndex].isDelete = true;
164
+ var averageWeight = parseFloat((100 / effectiveKrs.length).toFixed(1));
165
+ data.current[rootIndex].krs[krIndex].isDelete = true; // 是否是均分的
166
+
167
+ var isAverage = effectiveKrs.findIndex(function (item) {
168
+ return item.krWeight !== averageWeight;
169
+ }) === -1;
170
+
171
+ if (isAverage) {
172
+ data.current[rootIndex].krs = data.current[rootIndex].krs.map(function (item) {
173
+ return _objectSpread(_objectSpread({}, item), {}, {
174
+ krWeight: parseFloat((100 / (effectiveKrs.length - 1)).toFixed(1))
175
+ });
176
+ });
177
+ } else {
178
+ var newEffectiveKrs = data.current[rootIndex].krs.filter(function (_ref6) {
179
+ var isDelete = _ref6.isDelete;
180
+ return !isDelete;
181
+ });
182
+ var totalWeight = newEffectiveKrs.slice(0, newEffectiveKrs.length - 1).reduce(function (pre, cur) {
183
+ return pre + cur.krWeight;
184
+ }, 0);
185
+ newEffectiveKrs[newEffectiveKrs.length - 1].krWeight = parseFloat((100 - totalWeight).toFixed(1));
186
+ data.current[rootIndex].krs = data.current[rootIndex].krs.map(function (item) {
187
+ return _objectSpread({}, item);
188
+ });
189
+ }
151
190
  }
152
191
 
153
192
  if (onChange) onChange(data.current.map(function (item) {
@@ -274,7 +313,7 @@ var OKRExcelCreate = function OKRExcelCreate(_ref3) {
274
313
  className: "".concat(preCls, "__add-o")
275
314
  }, /*#__PURE__*/_react["default"].createElement("i", {
276
315
  className: "tu-icon-add1"
277
- }), /*#__PURE__*/_react["default"].createElement("p", null, (0, _getLocale.getLocale)(isMax ? 'OKR_ComAll_AddObjective' : 'OKR_ComAll_AddObjective')))));
316
+ }), /*#__PURE__*/_react["default"].createElement("p", null, (0, _getLocale.getLocale)(isMax ? 'OKR_ComAll_Supports50' : 'OKR_ComAll_AddObjective')))));
278
317
  };
279
318
 
280
319
  var _default = OKRExcelCreate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titaui/pc",
3
- "version": "1.15.89-beta.7",
3
+ "version": "1.15.89-beta.8",
4
4
  "nameCN": "",
5
5
  "description": "",
6
6
  "main": "lib/index.js",