@titaui/pc 1.7.60 → 1.7.61
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.
- package/lib/components/dialog-confirm/index.css +5 -3
- package/lib/components/dynamic/dynamic.js +2 -1
- package/lib/components/file-list/index.js +12 -1
- package/lib/components/okr-detail/components/okr-tree/tree-node/o-child-node/edit-child-okr-weight.js +284 -0
- package/lib/components/okr-detail/components/okr-tree/tree-node/o-child-node/index.css +85 -0
- package/lib/components/okr-detail/components/okr-tree/tree-node/o-child-node/index.js +80 -24
- package/lib/components/okr-detail/components/okr-tree/tree-node/o-child-node/weight-input.js +95 -0
- package/lib/components/okr-detail/request-apis.js +25 -2
- package/lib/components/upload/index.js +16 -1
- package/lib/utils/auth.js +37 -2
- package/package.json +1 -1
- package/src/components/dialog-confirm/index.scss +5 -3
- package/src/components/dynamic/dynamic.tsx +1 -0
- package/src/components/file-list/index.tsx +10 -1
- package/src/components/okr-detail/components/okr-tree/tree-node/o-child-node/edit-child-okr-weight.tsx +126 -0
- package/src/components/okr-detail/components/okr-tree/tree-node/o-child-node/index.js +121 -64
- package/src/components/okr-detail/components/okr-tree/tree-node/o-child-node/index.scss +79 -6
- package/src/components/okr-detail/components/okr-tree/tree-node/o-child-node/weight-input.tsx +59 -0
- package/src/components/okr-detail/request-apis.ts +11 -3
- package/src/components/upload/index.tsx +14 -2
- package/src/utils/auth.js +21 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
14
|
+
var _tooltip = _interopRequireDefault(require("../../../../../tooltip"));
|
|
15
|
+
|
|
16
|
+
require("./index.css");
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
|
|
22
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
26
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
27
|
+
|
|
28
|
+
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."); }
|
|
29
|
+
|
|
30
|
+
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); }
|
|
31
|
+
|
|
32
|
+
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; }
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
37
|
+
|
|
38
|
+
var precls = "child-okrs-weight";
|
|
39
|
+
|
|
40
|
+
var WeightInput = function WeightInput(props) {
|
|
41
|
+
var value = props.value,
|
|
42
|
+
onChange = props.onChange,
|
|
43
|
+
workId = props.workId;
|
|
44
|
+
|
|
45
|
+
var _useState = (0, _react.useState)(false),
|
|
46
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
47
|
+
isError = _useState2[0],
|
|
48
|
+
setIsError = _useState2[1];
|
|
49
|
+
|
|
50
|
+
var onChangeHandler = function onChangeHandler(e) {
|
|
51
|
+
var currentValue = e.currentTarget.value;
|
|
52
|
+
setIsError(!/^(\d{1,2}(\.\d{1})?|100)$/g.test(currentValue));
|
|
53
|
+
onChange({
|
|
54
|
+
workId: workId,
|
|
55
|
+
value: currentValue,
|
|
56
|
+
isError: isError
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var onBlurHandler = function onBlurHandler(e) {
|
|
61
|
+
var currentValue = e.currentTarget.value;
|
|
62
|
+
|
|
63
|
+
if (currentValue == "") {
|
|
64
|
+
onChange({
|
|
65
|
+
workId: workId,
|
|
66
|
+
value: 0,
|
|
67
|
+
isError: false
|
|
68
|
+
});
|
|
69
|
+
setIsError(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
74
|
+
className: (0, _classnames["default"])("".concat(precls, "__item-weight-content"), _defineProperty({}, "".concat(precls, "__item-weight-content--error"), isError))
|
|
75
|
+
}, /*#__PURE__*/_react["default"].createElement(_tooltip["default"].Error, {
|
|
76
|
+
overlay: /*#__PURE__*/_react["default"].createElement("span", {
|
|
77
|
+
style: {
|
|
78
|
+
color: "#F05E5E"
|
|
79
|
+
}
|
|
80
|
+
}, "\u4EC5\u5141\u8BB8\u8F93\u5165 0-100 \u7684\u6570\u5B57\uFF0C\u4EC5\u652F\u6301\u4E00\u4F4D\u5C0F\u6570"),
|
|
81
|
+
placement: "top",
|
|
82
|
+
visible: isError
|
|
83
|
+
}, /*#__PURE__*/_react["default"].createElement("input", {
|
|
84
|
+
className: "".concat(precls, "__item-weight-input"),
|
|
85
|
+
type: "number",
|
|
86
|
+
value: value,
|
|
87
|
+
onChange: onChangeHandler,
|
|
88
|
+
onBlur: onBlurHandler
|
|
89
|
+
})), /*#__PURE__*/_react["default"].createElement("span", {
|
|
90
|
+
className: "".concat(precls, "__item-weight-suffix")
|
|
91
|
+
}, "%"));
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
var _default = WeightInput;
|
|
95
|
+
exports["default"] = _default;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.workDelete = exports.updateVisibility = exports.updateTaskStatus = exports.updateTaskPrincipal = exports.updateTaskDate = exports.updateProgressDesc = exports.updateProgress = exports.updateParentId = exports.updateOkrVisibility = exports.updateOkrPrincipal = exports.updateOkrName = exports.updateOCommitType = exports.updateOClassify = exports.updateKrProgressAndStatus = exports.updateKrPrincipal = exports.updateKrName = exports.updateKrDate = exports.updateConfidenceIndex = exports.updateClassify = exports.transferPrincipal = exports.start = exports.setTaskPriority = exports.saveODesc = exports.remindAction = exports.krChangeOrder = exports.getRelWorks = exports.getRelProgress = exports.getProgress = exports.getPraiseComments = exports.getOrg = exports.getOkrUsers = exports.getOkrDetail = exports.getKrsByCondition = exports.getKrs = exports.getFeedById = exports.deleteUser = exports.deleteProgressDesc = exports.deleteKr = exports.createNewKr = exports.close = exports.cancelRel = exports.cancelPraise = exports.cancelParentOkr = exports.addUserRelation = exports.addUser = exports.addPraise = exports.addComment = void 0;
|
|
6
|
+
exports.workDelete = exports.updateVisibility = exports.updateTaskStatus = exports.updateTaskPrincipal = exports.updateTaskDate = exports.updateProgressDesc = exports.updateProgress = exports.updateParentId = exports.updateOkrVisibility = exports.updateOkrPrincipal = exports.updateOkrName = exports.updateOCommitType = exports.updateOClassify = exports.updateKrProgressAndStatus = exports.updateKrPrincipal = exports.updateKrName = exports.updateKrDate = exports.updateConfidenceIndex = exports.updateClassify = exports.updateChildOkrWeight = exports.transferPrincipal = exports.start = exports.setTaskPriority = exports.saveODesc = exports.remindAction = exports.krChangeOrder = exports.getRelWorks = exports.getRelProgress = exports.getProgress = exports.getPraiseComments = exports.getOrg = exports.getOkrUsers = exports.getOkrDetail = exports.getKrsByCondition = exports.getKrs = exports.getFeedById = exports.deleteUser = exports.deleteProgressDesc = exports.deleteKr = exports.createNewKr = exports.close = exports.cancelRel = exports.cancelPraise = exports.cancelParentOkr = exports.addUserRelation = exports.addUser = exports.addPraise = exports.addComment = void 0;
|
|
7
7
|
|
|
8
8
|
var _qs = _interopRequireDefault(require("qs"));
|
|
9
9
|
|
|
@@ -11,6 +11,18 @@ var _request = require("../../utils/request");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
13
|
|
|
14
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
|
+
|
|
16
|
+
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."); }
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
21
|
+
|
|
22
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
14
26
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
27
|
|
|
16
28
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
@@ -517,4 +529,15 @@ var getRelWorks = function getRelWorks(okrId) {
|
|
|
517
529
|
return (0, _request.rget)("v1")("okr/detail/relWorks?okrId=".concat(okrId));
|
|
518
530
|
};
|
|
519
531
|
|
|
520
|
-
exports.getRelWorks = getRelWorks;
|
|
532
|
+
exports.getRelWorks = getRelWorks;
|
|
533
|
+
|
|
534
|
+
var updateChildOkrWeight = function updateChildOkrWeight(data) {
|
|
535
|
+
return (0, _request.rpost)('v1')('okr/weight/save', {
|
|
536
|
+
OkrWeights: _toConsumableArray(data)
|
|
537
|
+
}, {
|
|
538
|
+
// "headers": { "Content-Type": "application/x-www-form-urlencoded" },
|
|
539
|
+
"transformRequest": _qs["default"].stringify
|
|
540
|
+
});
|
|
541
|
+
};
|
|
542
|
+
|
|
543
|
+
exports.updateChildOkrWeight = updateChildOkrWeight;
|
|
@@ -329,6 +329,19 @@ var Upload = /*#__PURE__*/function (_PureComponent) {
|
|
|
329
329
|
});
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
+
_this.getImgIndex = function (index) {
|
|
333
|
+
var newIndex = 0;
|
|
334
|
+
var uploadSuccessFiles = _this.state.uploadSuccessFiles;
|
|
335
|
+
|
|
336
|
+
for (var i = 0; i < index; i++) {
|
|
337
|
+
if ((0, _util.isImg)(uploadSuccessFiles[i].FileType)) {
|
|
338
|
+
newIndex++;
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return newIndex;
|
|
343
|
+
};
|
|
344
|
+
|
|
332
345
|
_this.handlerUploadPreviewOptions = function (index, options) {
|
|
333
346
|
var _this$props2 = _this.props,
|
|
334
347
|
onSubmit = _this$props2.onSubmit,
|
|
@@ -356,7 +369,9 @@ var Upload = /*#__PURE__*/function (_PureComponent) {
|
|
|
356
369
|
uploadSuccessFiles: uploadResultFiles
|
|
357
370
|
});
|
|
358
371
|
} else if (options === 'preview') {
|
|
359
|
-
_this.
|
|
372
|
+
var imgIndex = _this.getImgIndex(index);
|
|
373
|
+
|
|
374
|
+
_this.refs.imgViewerRef.show(imgIndex);
|
|
360
375
|
} else if (options === 'reupload') {
|
|
361
376
|
var _reUploadFileInfo = _this.state.uploadSuccessFiles[index];
|
|
362
377
|
var reUploadFile = _this.state.selectFiles[_reUploadFileInfo.FileName];
|
package/lib/utils/auth.js
CHANGED
|
@@ -5,7 +5,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.hasSuperior = exports.OAuth = exports.KRAuth = exports.EAuth = exports.DynamicManagerAuth = exports.BaseAuth = void 0;
|
|
8
|
+
exports.hasSuperior = exports.OAuth = exports.KRAuth = exports.EAuth = exports.DynamicManagerAuth = exports.ChildAuth = exports.BaseAuth = void 0;
|
|
9
9
|
|
|
10
10
|
var _bsGlobal = require("./bs-global");
|
|
11
11
|
|
|
@@ -246,4 +246,39 @@ var DynamicManagerAuth = /*#__PURE__*/function (_BaseAuth4) {
|
|
|
246
246
|
return DynamicManagerAuth;
|
|
247
247
|
}(BaseAuth);
|
|
248
248
|
|
|
249
|
-
exports.DynamicManagerAuth = DynamicManagerAuth;
|
|
249
|
+
exports.DynamicManagerAuth = DynamicManagerAuth;
|
|
250
|
+
|
|
251
|
+
var ChildAuth = /*#__PURE__*/function (_BaseAuth5) {
|
|
252
|
+
_inherits(ChildAuth, _BaseAuth5);
|
|
253
|
+
|
|
254
|
+
var _super5 = _createSuper(ChildAuth);
|
|
255
|
+
|
|
256
|
+
function ChildAuth(props) {
|
|
257
|
+
var _this5;
|
|
258
|
+
|
|
259
|
+
_classCallCheck(this, ChildAuth);
|
|
260
|
+
|
|
261
|
+
_this5 = _super5.call(this, props);
|
|
262
|
+
var principalUser = props.principalUser;
|
|
263
|
+
_this5.userId = _this5.loginUserInfor.Id;
|
|
264
|
+
_this5.principalUser = principalUser;
|
|
265
|
+
return _this5;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
_createClass(ChildAuth, [{
|
|
269
|
+
key: "isPrincipalUser",
|
|
270
|
+
value: function isPrincipalUser() {
|
|
271
|
+
return this.userId == this.principalUser.userId;
|
|
272
|
+
} // 超管、助理、目标管理员以及目标负责人可以修改此目标下对齐子目标的权重;
|
|
273
|
+
|
|
274
|
+
}, {
|
|
275
|
+
key: "hasAuth",
|
|
276
|
+
value: function hasAuth() {
|
|
277
|
+
return this.isManager() || this.isPrincipalUser();
|
|
278
|
+
}
|
|
279
|
+
}]);
|
|
280
|
+
|
|
281
|
+
return ChildAuth;
|
|
282
|
+
}(BaseAuth);
|
|
283
|
+
|
|
284
|
+
exports.ChildAuth = ChildAuth;
|
package/package.json
CHANGED
|
@@ -5,14 +5,14 @@ $font-family: -apple-system, Arial, Verdana, Helvetica Neue, Helvetica,
|
|
|
5
5
|
display: inline-block;
|
|
6
6
|
width: 360px;
|
|
7
7
|
background: #ffffff;
|
|
8
|
-
border-radius:
|
|
8
|
+
border-radius: 24px;
|
|
9
9
|
|
|
10
10
|
&__btn {
|
|
11
11
|
display: inline-block;
|
|
12
12
|
width: 90px;
|
|
13
13
|
height: 32px;
|
|
14
14
|
line-height: 32px;
|
|
15
|
-
border-radius:
|
|
15
|
+
border-radius: 18px;
|
|
16
16
|
text-align: center;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -70,6 +70,7 @@ $font-family: -apple-system, Arial, Verdana, Helvetica Neue, Helvetica,
|
|
|
70
70
|
}
|
|
71
71
|
.rc-dialog-content {
|
|
72
72
|
box-shadow: none;
|
|
73
|
+
border-radius: 24px;
|
|
73
74
|
}
|
|
74
75
|
.rc-dialog-body {
|
|
75
76
|
padding: 22px 32px 0px 32px;
|
|
@@ -93,10 +94,11 @@ $font-family: -apple-system, Arial, Verdana, Helvetica Neue, Helvetica,
|
|
|
93
94
|
|
|
94
95
|
&__body {
|
|
95
96
|
position: relative;
|
|
97
|
+
display: flex;
|
|
96
98
|
|
|
97
99
|
&-icon {
|
|
98
100
|
display: inline-block;
|
|
99
|
-
font-size:
|
|
101
|
+
font-size: 14px;
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
&-title {
|
|
@@ -9,15 +9,24 @@ const prefix = "titaui-new-file-list";
|
|
|
9
9
|
|
|
10
10
|
const FileList: FC<IFileListProps> = ({ data, showDownload = true }) => {
|
|
11
11
|
const imgViewerRef = useRef();
|
|
12
|
+
const imageIndexRef = useRef(0);
|
|
12
13
|
const handleImgPreview = (index) => {
|
|
13
14
|
// @ts-ignore
|
|
14
15
|
imgViewerRef.current && imgViewerRef.current.show(index);
|
|
15
16
|
};
|
|
16
17
|
|
|
18
|
+
const getIndex = (file) => {
|
|
19
|
+
let index = imageIndexRef.current;
|
|
20
|
+
if (isImg(file.fileType)) {
|
|
21
|
+
imageIndexRef.current = index + 1;
|
|
22
|
+
}
|
|
23
|
+
return index
|
|
24
|
+
}
|
|
25
|
+
|
|
17
26
|
return (
|
|
18
27
|
<div className={prefix}>
|
|
19
28
|
{data.map((file, index) => (
|
|
20
|
-
<SingleFileCmp key={file.documentSource+index} data={file} index={
|
|
29
|
+
<SingleFileCmp key={file.documentSource+index} data={file} index={getIndex(file)} showDownload={showDownload} onPreview={handleImgPreview} />
|
|
21
30
|
))}
|
|
22
31
|
<ImgViewer showDownload={showDownload} data={data.filter(file => isImg(file.fileType))} ref={imgViewerRef}/>
|
|
23
32
|
</div>
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import Dialog from "../../../../../dialog";
|
|
3
|
+
import Toast from "../../../../../toast";
|
|
4
|
+
import DialogConfirm from "../../../../../dialog-confirm";
|
|
5
|
+
import { getRelWorks, updateChildOkrWeight } from "../../../../request-apis";
|
|
6
|
+
import WeightInput from "./weight-input";
|
|
7
|
+
|
|
8
|
+
import "./index.scss";
|
|
9
|
+
const { CancelButton, SureButton } = DialogConfirm;
|
|
10
|
+
interface IProps {
|
|
11
|
+
onOk: Function;
|
|
12
|
+
onCancel: Function;
|
|
13
|
+
visible: Boolean;
|
|
14
|
+
okrId: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const precls = "child-okrs-weight";
|
|
18
|
+
|
|
19
|
+
const EditChildOkrWeight = (props: IProps) => {
|
|
20
|
+
const { onOk, onCancel, visible = false, okrId } = props;
|
|
21
|
+
const [childOkrs, setChildOkrs] = useState([]);
|
|
22
|
+
const [showDialogConfirm, setShowDialogConfirm] = useState(false);
|
|
23
|
+
|
|
24
|
+
const getChildWork = async () => {
|
|
25
|
+
const { Data } = await getRelWorks(okrId);
|
|
26
|
+
const { childWorks = [] } = Data;
|
|
27
|
+
const authChildWorks = (childWorks || []).filter((item) => item.OkrVisible);
|
|
28
|
+
setChildOkrs(authChildWorks || []);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
visible && getChildWork();
|
|
33
|
+
}, [okrId, visible]);
|
|
34
|
+
|
|
35
|
+
const postData = async () => {
|
|
36
|
+
setShowDialogConfirm(false);
|
|
37
|
+
const data = childOkrs.map((item: any) => ({
|
|
38
|
+
OkrId: item.workId,
|
|
39
|
+
Weight: item.pweight,
|
|
40
|
+
}));
|
|
41
|
+
const result = await updateChildOkrWeight(data);
|
|
42
|
+
if (result.Code !== 0) {
|
|
43
|
+
Toast.Success("修改成功");
|
|
44
|
+
onOk();
|
|
45
|
+
} else {
|
|
46
|
+
Toast.Error(result.Message);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const handleOk = async () => {
|
|
51
|
+
let total = 0;
|
|
52
|
+
for (let i = 0; i < childOkrs.length; i++) {
|
|
53
|
+
const { pweight, isError } = childOkrs[i];
|
|
54
|
+
if (isError) return;
|
|
55
|
+
total += Number(pweight);
|
|
56
|
+
}
|
|
57
|
+
if (total > 100) {
|
|
58
|
+
Toast.Error("权重合计需控制在100%");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (total < 100) {
|
|
62
|
+
setShowDialogConfirm(true);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
postData();
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const onChangeHandler = (data) => {
|
|
69
|
+
const { workId, value, isError } = data;
|
|
70
|
+
const newChildren: any = childOkrs.map((item: any) => {
|
|
71
|
+
if (item.workId == workId) {
|
|
72
|
+
return {
|
|
73
|
+
...item,
|
|
74
|
+
pweight: value,
|
|
75
|
+
isError,
|
|
76
|
+
};
|
|
77
|
+
} else {
|
|
78
|
+
return item;
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
setChildOkrs(newChildren);
|
|
82
|
+
};
|
|
83
|
+
const closeDialogConfirm = () => setShowDialogConfirm(false);
|
|
84
|
+
return (
|
|
85
|
+
<>
|
|
86
|
+
<Dialog
|
|
87
|
+
title={"子目标权重设置"}
|
|
88
|
+
noHeadLine
|
|
89
|
+
noFooterLine
|
|
90
|
+
visible={visible}
|
|
91
|
+
width={600}
|
|
92
|
+
onClose={onCancel}
|
|
93
|
+
onCancel={onCancel}
|
|
94
|
+
onOk={handleOk}
|
|
95
|
+
>
|
|
96
|
+
<div className={`${precls}__content`}>
|
|
97
|
+
{childOkrs.map((item: any) => (
|
|
98
|
+
<div className={`${precls}__item`} key={item.workId}>
|
|
99
|
+
<span className={`${precls}__item-precls`} />
|
|
100
|
+
<div className={`${precls}__item-name`}>{item.workName}</div>
|
|
101
|
+
<div className={`${precls}__item-weight`}>
|
|
102
|
+
<span className={`${precls}__item-weight-label`}>权重</span>
|
|
103
|
+
<WeightInput
|
|
104
|
+
workId={item.workId}
|
|
105
|
+
value={item.pweight}
|
|
106
|
+
onChange={onChangeHandler}
|
|
107
|
+
/>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
))}
|
|
111
|
+
</div>
|
|
112
|
+
</Dialog>
|
|
113
|
+
<DialogConfirm visible={showDialogConfirm} type="warning">
|
|
114
|
+
{/* @ts-ignore */}
|
|
115
|
+
<span type="title">当前子目标权重合计小于100%,确定要保存吗?</span>
|
|
116
|
+
<CancelButton type="button" onClick={closeDialogConfirm}>
|
|
117
|
+
取消
|
|
118
|
+
</CancelButton>
|
|
119
|
+
<SureButton type="button" onClick={postData}>
|
|
120
|
+
确定
|
|
121
|
+
</SureButton>
|
|
122
|
+
</DialogConfirm>
|
|
123
|
+
</>
|
|
124
|
+
);
|
|
125
|
+
};
|
|
126
|
+
export default EditChildOkrWeight;
|
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
import React, { useState, useContext } from
|
|
2
|
-
import classNames from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
1
|
+
import React, { useState, useContext } from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
import { getBSGlobal } from "../../../../../../utils/bs-global";
|
|
4
|
+
import { ChildAuth } from "../../../../../../utils/auth";
|
|
5
|
+
import { CommonContext } from "../../../../context";
|
|
6
|
+
import { OkrRiskMapping } from "../../../../../progress/utils";
|
|
7
|
+
import drawerManager from "../../../../../drawer-manager";
|
|
8
|
+
import Progress from "../../../../../progress";
|
|
9
9
|
import OClassify from "../../../o-classify";
|
|
10
|
-
import
|
|
10
|
+
import Avatar from "../../../../../avatar";
|
|
11
|
+
import IconText from "../../../icon-text";
|
|
12
|
+
import OkrType from "../../../okr-type";
|
|
13
|
+
import preCls from "../../precls";
|
|
14
|
+
import EditChildOkrWeight from "./edit-child-okr-weight";
|
|
11
15
|
|
|
12
|
-
import
|
|
16
|
+
import "./index.scss";
|
|
13
17
|
|
|
14
18
|
const SeasonTectMap = {
|
|
15
|
-
1:
|
|
16
|
-
2:
|
|
17
|
-
3:
|
|
18
|
-
4:
|
|
19
|
+
1: "一",
|
|
20
|
+
2: "二",
|
|
21
|
+
3: "三",
|
|
22
|
+
4: "四",
|
|
19
23
|
};
|
|
20
24
|
|
|
21
|
-
export default props => {
|
|
25
|
+
export default (props) => {
|
|
22
26
|
const { data, style, title } = props;
|
|
27
|
+
const [editVisible, setEditVisible] = useState(false);
|
|
28
|
+
|
|
29
|
+
const { refreshAll, okrInfo } = useContext(CommonContext);
|
|
23
30
|
const [user] = useState(data.principalUser);
|
|
24
|
-
const [
|
|
31
|
+
const [OKrWeightSetting] = useState(
|
|
32
|
+
getBSGlobal("OkrAdvancedSetting")?.KRSetting?.OKrWeight || false
|
|
33
|
+
);
|
|
34
|
+
const [cycleDateStr] = useState(() => {
|
|
35
|
+
// 时间周期
|
|
25
36
|
const { cycleType, yqmnum, annualNum, startDate, endDate } = data;
|
|
26
37
|
switch (cycleType) {
|
|
27
38
|
case 1:
|
|
@@ -33,62 +44,108 @@ export default props => {
|
|
|
33
44
|
default:
|
|
34
45
|
return `自定义 ${startDate}-${endDate}`;
|
|
35
46
|
}
|
|
36
|
-
})
|
|
47
|
+
});
|
|
48
|
+
// 权限 & 非结束目标
|
|
49
|
+
const [canEdit] = useState(() => {
|
|
50
|
+
const hasAuth = new ChildAuth({
|
|
51
|
+
principalUser: okrInfo.principalUser,
|
|
52
|
+
}).hasAuth();
|
|
53
|
+
const livetime = okrInfo.status != 2;
|
|
54
|
+
return hasAuth && livetime;
|
|
55
|
+
});
|
|
37
56
|
|
|
38
|
-
|
|
57
|
+
const openWeightEditModal = () => setEditVisible(true);
|
|
58
|
+
const handleOk = () => {
|
|
59
|
+
setEditVisible(false);
|
|
60
|
+
refreshAll();
|
|
61
|
+
};
|
|
39
62
|
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
return (
|
|
64
|
+
<div className={classNames(`${preCls}__o-child-node`)} style={style}>
|
|
65
|
+
<div className={classNames(`${preCls}__o-child-node-h1`)}>
|
|
66
|
+
<span className={classNames(`${preCls}__o-child-node-prefix`)}></span>
|
|
42
67
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
68
|
+
<span
|
|
69
|
+
className={classNames(`${preCls}__o-child-node-title`)}
|
|
70
|
+
onClick={() => {
|
|
71
|
+
drawerManager.open("okrDetail", { okrId: data.workId });
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
{title}
|
|
75
|
+
</span>
|
|
46
76
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
77
|
+
<OClassify
|
|
78
|
+
editable={false}
|
|
79
|
+
okrClassify={data.okrClassify}
|
|
80
|
+
okrId={data.workId}
|
|
81
|
+
/>
|
|
82
|
+
</div>
|
|
53
83
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
84
|
+
<div className={classNames(`${preCls}__o-child-node-h2`)}>
|
|
85
|
+
<OkrType
|
|
86
|
+
editable={false}
|
|
87
|
+
type={{
|
|
88
|
+
okrType: data.okrType,
|
|
89
|
+
departmentId: data.departmentId,
|
|
90
|
+
departmentName: data.departmentName,
|
|
91
|
+
groupId: data.groupId,
|
|
92
|
+
groupName: data.groupName,
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
65
95
|
|
|
66
|
-
|
|
96
|
+
<Avatar.Text
|
|
97
|
+
name={user.name}
|
|
98
|
+
id={user.userId}
|
|
99
|
+
width={76}
|
|
100
|
+
editable={false}
|
|
101
|
+
/>
|
|
67
102
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
103
|
+
<IconText
|
|
104
|
+
width={400}
|
|
105
|
+
content={cycleDateStr}
|
|
106
|
+
editable={false}
|
|
107
|
+
icon="tu-icon-deferred"
|
|
108
|
+
/>
|
|
74
109
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
110
|
+
<div className={classNames(`${preCls}__o-child-node-right`)}>
|
|
111
|
+
{OKrWeightSetting && (
|
|
112
|
+
<div className={`${preCls}__o-child-node-weight`}>
|
|
113
|
+
<IconText
|
|
114
|
+
width={60}
|
|
115
|
+
editable={canEdit}
|
|
116
|
+
content={`${data.pweight}%`}
|
|
117
|
+
onTextClick={openWeightEditModal}
|
|
118
|
+
icon="tu-icon-app-quanzhong"
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
<div className={classNames(`${preCls}__o-child-node-progress`)}>
|
|
123
|
+
<Progress
|
|
124
|
+
percent={data.progress}
|
|
125
|
+
width={40}
|
|
126
|
+
backgroundColor="#F7F8FA"
|
|
127
|
+
width={40}
|
|
128
|
+
textColor={
|
|
129
|
+
data.status === 2
|
|
130
|
+
? "#89919f"
|
|
131
|
+
: OkrRiskMapping[data.manualRiskLevel].textColor
|
|
132
|
+
}
|
|
133
|
+
color={
|
|
134
|
+
data.status === 2
|
|
135
|
+
? "linear-gradient(270deg, #BFC7D5, #E1E5EC)"
|
|
136
|
+
: OkrRiskMapping[data.manualRiskLevel].line
|
|
137
|
+
}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
89
140
|
</div>
|
|
90
141
|
</div>
|
|
91
|
-
|
|
142
|
+
|
|
143
|
+
<EditChildOkrWeight
|
|
144
|
+
okrId={okrInfo.workId}
|
|
145
|
+
visible={editVisible}
|
|
146
|
+
onCancel={() => setEditVisible(false)}
|
|
147
|
+
onOk={handleOk}
|
|
148
|
+
/>
|
|
92
149
|
</div>
|
|
93
|
-
|
|
94
|
-
}
|
|
150
|
+
);
|
|
151
|
+
};
|