@titaui/pc 1.9.21 → 1.9.25

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.
@@ -152,8 +152,7 @@ var _default = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
152
152
 
153
153
  if (errors.length) {
154
154
  setHasError(true);
155
- setTip(errors[0].tip);
156
- inputRef.current.focus();
155
+ setTip(errors[0].tip); // inputRef.current.focus();
157
156
  }
158
157
 
159
158
  return errors;
@@ -64,6 +64,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
64
64
  var precls = "okr-drawer-header";
65
65
 
66
66
  var Header = function Header(props) {
67
+ var _window, _window$BSGlobal, _window$BSGlobal$OkrA, _window$BSGlobal$OkrA2;
68
+
67
69
  // 外部取到的 headInfo
68
70
  var okrInfo = props.okrInfo;
69
71
 
@@ -85,7 +87,7 @@ var Header = function Header(props) {
85
87
  setGeneralOkrClassify = _useContext.setGeneralOkrClassify,
86
88
  showOkrEvalute = _useContext.showOkrEvalute;
87
89
 
88
- var showOScore = window.BSGlobal.OkrAdvancedSetting.KRSetting.OScore;
90
+ var showOScore = (_window = window) === null || _window === void 0 ? void 0 : (_window$BSGlobal = _window.BSGlobal) === null || _window$BSGlobal === void 0 ? void 0 : (_window$BSGlobal$OkrA = _window$BSGlobal.OkrAdvancedSetting) === null || _window$BSGlobal$OkrA === void 0 ? void 0 : (_window$BSGlobal$OkrA2 = _window$BSGlobal$OkrA.KRSetting) === null || _window$BSGlobal$OkrA2 === void 0 ? void 0 : _window$BSGlobal$OkrA2.OScore;
89
91
  var _okrInfo$progressGrow = okrInfo.progressGrow,
90
92
  progressGrow = _okrInfo$progressGrow === void 0 ? 0 : _okrInfo$progressGrow,
91
93
  progress = okrInfo.progress;
@@ -184,11 +186,11 @@ var Header = function Header(props) {
184
186
  okrId: okrInfo.workId
185
187
  })), /*#__PURE__*/_react["default"].createElement("span", {
186
188
  className: "".concat(precls, "__action-item")
187
- }, (showOkrEvalute || showOScore) && /*#__PURE__*/_react["default"].createElement(_oScore["default"], {
188
- editable: editable,
189
+ }, (showOkrEvalute || showOScore || okrInfo.manualEvaluateValue) && /*#__PURE__*/_react["default"].createElement(_oScore["default"], {
190
+ editable: editable && showOScore,
189
191
  okrId: okrInfo.workId,
190
- score: okrInfo.evaluateValue,
191
- isEvaluate: okrInfo.manualEvaluateValue
192
+ score: showOkrEvalute || okrInfo.manualEvaluateValue ? okrInfo.evaluateValue : 0,
193
+ isEvaluate: okrInfo.manualEvaluateValue || showOkrEvalute && !!okrInfo.evaluateValue
192
194
  }))), /*#__PURE__*/_react["default"].createElement(_oProgressUpdate["default"], {
193
195
  okrInfo: okrInfo,
194
196
  renderContent: renderContent
@@ -75,8 +75,7 @@ var OScore = function OScore(props) {
75
75
  refreshAll = _useContext.refreshAll;
76
76
 
77
77
  var _useState3 = (0, _react.useState)({
78
- score: score,
79
- describe: ""
78
+ score: score == 1 ? '1' : Number(score).toFixed(2) * 1
80
79
  }),
81
80
  _useState4 = _slicedToArray(_useState3, 2),
82
81
  formFiedlsValue = _useState4[0],
@@ -84,6 +83,11 @@ var OScore = function OScore(props) {
84
83
 
85
84
  var formContainerRef = (0, _react.useRef)();
86
85
  var formRef = (0, _react.useRef)();
86
+ (0, _react.useEffect)(function () {
87
+ setFormFiedlsValue({
88
+ score: score == 1 ? '1' : Number(score).toFixed(2) * 1
89
+ });
90
+ }, [score]);
87
91
 
88
92
  var changeOScore = function changeOScore() {
89
93
  setVisible(true);
@@ -93,7 +97,15 @@ var OScore = function OScore(props) {
93
97
  setVisible(false);
94
98
  };
95
99
 
100
+ var checkForm = function checkForm() {
101
+ // @ts-ignore
102
+ var errors = formRef.current.verifing();
103
+ if (errors.length) return false;
104
+ return true;
105
+ };
106
+
96
107
  var handleOk = function handleOk() {
108
+ if (!checkForm()) return;
97
109
  (0, _requestApis.updateOScore)(formFiedlsValue.score, okrId).then(function (res) {
98
110
  if (!!res.Code) {
99
111
  _toast["default"].Success("".concat((0, _getLocale.getLocale)("OKR_MyO_Ew_Success")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@titaui/pc",
3
- "version": "1.9.21",
3
+ "version": "1.9.25",
4
4
  "nameCN": "",
5
5
  "description": "",
6
6
  "main": "src/index.js",
@@ -108,7 +108,7 @@ export default forwardRef((props: Props, ref) => {
108
108
  if (errors.length) {
109
109
  setHasError(true);
110
110
  setTip(errors[0].tip);
111
- inputRef.current.focus();
111
+ // inputRef.current.focus();
112
112
  }
113
113
  return errors;
114
114
  }
@@ -34,7 +34,7 @@ const Header = (props) => {
34
34
  setGeneralOkrClassify,
35
35
  showOkrEvalute,
36
36
  } = useContext(GeneralDataContext);
37
- const showOScore = window.BSGlobal.OkrAdvancedSetting.KRSetting.OScore
37
+ const showOScore = window?.BSGlobal?.OkrAdvancedSetting?.KRSetting?.OScore
38
38
  const { progressGrow = 0, progress } = okrInfo;
39
39
 
40
40
  const [auth, setAuth] = useState(false);
@@ -149,7 +149,7 @@ const Header = (props) => {
149
149
  <OCycle editable={editable} okrId={okrInfo.workId} />
150
150
  </span>
151
151
  <span className={`${precls}__action-item`}>
152
- {(showOkrEvalute || showOScore) && <Score editable={editable} okrId={okrInfo.workId} score={okrInfo.evaluateValue} isEvaluate={okrInfo.manualEvaluateValue} />}
152
+ {(showOkrEvalute || showOScore || okrInfo.manualEvaluateValue) && <Score editable={editable&&showOScore} okrId={okrInfo.workId} score={showOkrEvalute || okrInfo.manualEvaluateValue ? okrInfo.evaluateValue:0} isEvaluate={okrInfo.manualEvaluateValue || (showOkrEvalute && !!okrInfo.evaluateValue)} />}
153
153
  </span>
154
154
  </span>
155
155
  <OProgressUpdate okrInfo={okrInfo} renderContent={renderContent} />
@@ -1,4 +1,4 @@
1
- import React, { Fragment, useState, useRef, useContext } from "react";
1
+ import React, { Fragment, useState, useRef,useEffect, useContext } from "react";
2
2
  import { CommonContext } from "../../context";
3
3
  import { getLocale } from "../../../../utils/getLocale";
4
4
  import Score from "../score";
@@ -18,18 +18,23 @@ interface IOScoreProps {
18
18
  }
19
19
  interface FormFields {
20
20
  score: string | number;
21
- describe: string;
22
21
  }
23
22
  const OScore = (props: IOScoreProps) => {
24
23
  const { score, okrId, editable, ...restProps } = props;
25
24
  const [visible, setVisible] = useState(false);
26
25
  const { refreshAll } = useContext(CommonContext);
27
26
  const [formFiedlsValue, setFormFiedlsValue] = useState<FormFields>({
28
- score: score,
29
- describe: "",
27
+ score: score == 1 ? '1': Number(score).toFixed(2) * 1
30
28
  });
31
29
  const formContainerRef = useRef<any>();
32
30
  const formRef = useRef<any>();
31
+
32
+ useEffect(()=>{
33
+ setFormFiedlsValue({
34
+ score: score == 1 ? '1': Number(score).toFixed(2) * 1
35
+ })
36
+ },[score])
37
+
33
38
  const changeOScore = () => {
34
39
  setVisible(true);
35
40
  };
@@ -38,7 +43,15 @@ const OScore = (props: IOScoreProps) => {
38
43
  setVisible(false);
39
44
  };
40
45
 
46
+ const checkForm = () => {
47
+ // @ts-ignore
48
+ const errors = formRef.current.verifing();
49
+ if (errors.length) return false;
50
+ return true;
51
+ };
52
+
41
53
  const handleOk = () => {
54
+ if (!checkForm()) return;
42
55
  updateOScore(formFiedlsValue.score, okrId)
43
56
  .then((res) => {
44
57
  if (!!res.Code) {