valentichu 3 tygodni temu
rodzic
commit
b2cea1f42e

Plik diff jest za duży
+ 0 - 0
lib/index.js


+ 20 - 14
src/pages/Alarm/components/complex.jsx

@@ -32,6 +32,11 @@ function TranslateText(arr) {
   return arr?.[0];
 }
 
+const getPaginationTotalText = (total) => {
+  const dtLanguage = localStorage.getItem("dtLanguage");
+  return dtLanguage === "en" ? `${total} items` : `共${total}条`;
+};
+
 const Complex = (props, ref) => {
   const { message } = App.useApp();
   const { editId, groupList = [], showList, formula } = props;
@@ -50,7 +55,7 @@ const Complex = (props, ref) => {
   const [paginationProps, setPaginationProps] = useState({
     pageSize: 15,
     current: 1,
-    showTotal: (total) => `共${total}条`,
+    showTotal: (total) => getPaginationTotalText(total),
     // showQuickJumper: true,
     // showSizeChanger:true,
     // size:'Large',
@@ -60,7 +65,10 @@ const Complex = (props, ref) => {
   const [ruleOptions, setRuleOptions] = useState([]);
 
   const handleTableChange = async (pagination) => {
-    setPaginationProps({ ...pagination, showTotal: (total) => `共${total}条` });
+    setPaginationProps({
+      ...pagination,
+      showTotal: (total) => getPaginationTotalText(total),
+    });
     // setCurrentPage(pagination.current);
     // setPageSize(pagination.pageSize)
   };
@@ -117,7 +125,7 @@ const Complex = (props, ref) => {
       if (state === 0) {
         props?.onConfirm?.(data?.id);
         form.resetFields();
-        message.success("保存成功");
+        message.success(TranslateText(["保存成功", "Seted"]));
       } else {
         message.error(state_info);
       }
@@ -140,7 +148,7 @@ const Complex = (props, ref) => {
       if (state === 0) {
         props?.onConfirm?.(data.id);
         form.resetFields();
-        message.success("保存成功");
+        message.success(TranslateText(["保存成功", "Seted"]));
       } else {
         message.error(state_info);
       }
@@ -278,9 +286,7 @@ const Complex = (props, ref) => {
           >
             {showList && (
               <>
-                <Form.Item
-                  label={TranslateText(["告警类型", "Alarm type"])}
-                >
+                <Form.Item label={TranslateText(["告警类型", "Alarm type"])}>
                   <Radio.Group
                     value={type}
                     onChange={(e) => setType(e.target.value)}
@@ -302,10 +308,7 @@ const Complex = (props, ref) => {
                     rules={[
                       {
                         required: true,
-                        message: TranslateText([
-                          "请选择规则",
-                          "Please choose",
-                        ]),
+                        message: TranslateText(["请选择规则", "Please choose rule"]),
                         validator: () => {
                           return new Promise((resolve, reject) => {
                             if (alarmId) {
@@ -324,7 +327,7 @@ const Complex = (props, ref) => {
                       onChange={setAlarmId}
                       style={{ width: 320 }}
                       options={ruleOptions}
-                      placeholder={TranslateText(["请选择", "Please choose"])}
+                      placeholder={TranslateText(["请选择规则", "Please choose rule"])}
                     />
                   </Form.Item>
                 )}
@@ -455,7 +458,10 @@ const Complex = (props, ref) => {
                   rules={[
                     {
                       required: true,
-                      message: "请输入条件",
+                      message: TranslateText([
+                        "请输入条件",
+                        "Please input condition",
+                      ]),
                       validator: () => {
                         return new Promise((resolve, reject) => {
                           if (formuRef.current.getFinalStr()) {
@@ -535,7 +541,7 @@ const Complex = (props, ref) => {
                       ["", undefined, null].indexOf(dateTime) !== -1 &&
                       status === 1 && (
                         <div style={{ color: "var(--dt-error-color1)" }}>
-                          请输入数字
+                          {TranslateText(["请输入数字", "Please input number"])}
                         </div>
                       )}
                   </div>

+ 3 - 1
src/pages/Alarm/components/components/AlarmConfirm/index.jsx

@@ -39,7 +39,7 @@ const Index = (props) => {
     });
 
     if (res.state === 0) {
-      message.success("确认成功");
+      message.success(TranslateText(["确认成功", "Confirmed"]));
       props.onCancel?.();
       props.onConfirm?.(res?.data?.[0]);
       window.dispatchEvent(new CustomEvent("refreshAlarmHistoryFromConfirm"));
@@ -66,6 +66,8 @@ const Index = (props) => {
       onCancel={onModalCancel}
       destroyOnClose
       zIndex={1002}
+      okText={TranslateText(["确定", "OK"])}
+      cancelText={TranslateText(["取消", "Cancel"])}
     >
       <Form
         name="basic"

+ 49 - 41
src/pages/Alarm/components/components/AlarmDetail/index.jsx

@@ -428,50 +428,54 @@ const Index = (props) => {
           style={{
             margin: "0px 0px",
             width: "calc(100% - 287px)",
-      }}
-      labelStyle={{ width: 72 }}
-    >
-      <Descriptions.Item
-        span={3}
-        label={TranslateText(["告警名称", "Alarm name"])}
-      >
-        {props.data?.data?.name}
-      </Descriptions.Item>
-      {props.data?.data?.point_id !== null &&
-        props.data?.data?.point_id !== "" &&
-        props.data?.data?.point_id !== undefined && (
-          <Descriptions.Item label={TranslateText(["点位编号", "Point id"])}>
-            {props.data?.data?.point_id}
+          }}
+          labelStyle={{ width: 72 }}
+        >
+          <Descriptions.Item
+            span={3}
+            label={TranslateText(["告警名称", "Alarm name"])}
+          >
+            {props.data?.data?.name}
           </Descriptions.Item>
-        )}
-      <Descriptions.Item label={TranslateText(["告警类型", "Alarm type"])}>
-        {alarmTypeMap[props.data?.data?.type]}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["告警级别", "Alarm level"])}>
-        {levelMap[props.data?.data?.alarm_level]}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["告警时间", "Alarm time"])}>
-        {props.data?.data?.created_time}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["恢复时间", "Recovery at"])}>
-        {props.data?.data?.recovery_time || "-"}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["持续时间", "Duration"])}>
-        {getDur(props?.data?.data?.duration)}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["确认人", "Occurred at"])}>
-        {props.data?.data?.confirmed_oper_name}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["确认时间", "Confirmed at"])}>
-        {props.data?.data?.confirmed_time}
-      </Descriptions.Item>
-      <Descriptions.Item label={TranslateText(["备注信息", "Remark"])}>
-        {props.data?.data?.remark}
-      </Descriptions.Item>
-    </Descriptions>
+          {props.data?.data?.point_id !== null &&
+            props.data?.data?.point_id !== "" &&
+            props.data?.data?.point_id !== undefined && (
+              <Descriptions.Item
+                label={TranslateText(["点位编号", "Point id"])}
+              >
+                {props.data?.data?.point_id}
+              </Descriptions.Item>
+            )}
+          <Descriptions.Item label={TranslateText(["告警类型", "Alarm type"])}>
+            {alarmTypeMap[props.data?.data?.type]}
+          </Descriptions.Item>
+          <Descriptions.Item label={TranslateText(["告警级别", "Alarm level"])}>
+            {levelMap[props.data?.data?.alarm_level]}
+          </Descriptions.Item>
+          <Descriptions.Item label={TranslateText(["告警时间", "Alarm time"])}>
+            {props.data?.data?.created_time}
+          </Descriptions.Item>
+          <Descriptions.Item label={TranslateText(["恢复时间", "Recovery at"])}>
+            {props.data?.data?.recovery_time || "-"}
+          </Descriptions.Item>
+          <Descriptions.Item label={TranslateText(["持续时间", "Duration"])}>
+            {getDur(props?.data?.data?.duration)}
+          </Descriptions.Item>
+          <Descriptions.Item label={TranslateText(["确认人", "Confirmed by"])}>
+            {props.data?.data?.confirmed_oper_name}
+          </Descriptions.Item>
+          <Descriptions.Item
+            label={TranslateText(["确认时间", "Confirmed at"])}
+          >
+            {props.data?.data?.confirmed_time}
+          </Descriptions.Item>
+          <Descriptions.Item label={TranslateText(["备注信息", "Remark"])}>
+            {props.data?.data?.remark}
+          </Descriptions.Item>
+        </Descriptions>
         <div className={styles.divide}></div>
         <div className={styles.oper}>
-          {props.data?.data?.status === 2 ? <Check></Check> : <Alert></Alert>}
+          {props.data?.data?.status === 2 ? <Check /> : <Alert />}
           <div className={styles.status}>
             {alarmStatusMap[props.data?.data?.status]}
           </div>
@@ -509,6 +513,10 @@ const Index = (props) => {
               onChange={setRange}
               style={{ width: 360, zIndex: 99999 }}
               presets={rangePresets}
+              placeholder={[
+                TranslateText(["开始日期", "Start date"]),
+                TranslateText(["结束日期", "End date"]),
+              ]}
             />
           </div>
 

+ 25 - 9
src/pages/Alarm/components/components/AlarmHistory/index.jsx

@@ -96,7 +96,10 @@ const alarmStatusMap = {
   2: TranslateText(["已结束", "Ended"]),
 };
 
-const showTotal = (total) => `共${total}条`;
+const getPaginationTotalText = (total) => {
+  const dtLanguage = localStorage.getItem("dtLanguage");
+  return dtLanguage === "en" ? `${total} items` : `共${total}条`;
+};
 
 const alarmStatusOptions = [
   {
@@ -225,7 +228,9 @@ const Index = (props) => {
       dataIndex: "created_time",
       fixed: "left",
       render: (text, record) =>
-        text ? dayjs(text).format("YYYY-MM-DD HH:mm:ss") : "暂无",
+        text
+          ? dayjs(text).format("YYYY-MM-DD HH:mm:ss")
+          : TranslateText(["暂无", "None"]),
     },
     {
       title: TranslateText(["告警名称", "Alarm name"]),
@@ -333,7 +338,7 @@ const Index = (props) => {
       render: (_, record) => (
         <div style={{ display: "flex" }}>
           <a onClick={() => props.onSelect(record)} type="link">
-            详情
+            {TranslateText(["详情", "Detail"])}
           </a>
           <a
             onClick={() => onConfirm(record)}
@@ -341,7 +346,9 @@ const Index = (props) => {
             disabled={record.op_status === 1}
             style={{ marginLeft: 10 }}
           >
-            {record.op_status !== 1 ? "确认" : "已确认"}
+            {record.op_status !== 1
+              ? TranslateText(["确认", "Confirm"])
+              : TranslateText(["已确认", "Confirmed"])}
           </a>
         </div>
       ),
@@ -362,7 +369,10 @@ const Index = (props) => {
               setPage(1);
               run();
             }}
-            placeholder="请输入告警名称"
+            placeholder={TranslateText([
+              "请输入告警名称",
+              "Please enter alarm name",
+            ])}
             style={{
               width: 240,
             }}
@@ -388,7 +398,7 @@ const Index = (props) => {
             }}
             allowClear
             options={alarmStatusOptions}
-            placeholder="告警状态"
+            placeholder={TranslateText(["告警状态", "Alarm status"])}
           ></Select>
           <Select
             value={opStatus}
@@ -401,7 +411,7 @@ const Index = (props) => {
               width: 120,
               marginLeft: 16,
             }}
-            placeholder="确认状态"
+            placeholder={TranslateText(["确认状态", "Confirm status"])}
             allowClear
             options={periodOptions}
           ></Select>
@@ -417,11 +427,17 @@ const Index = (props) => {
               marginLeft: 16,
             }}
             allowClear={true}
+            placeholder={[
+              TranslateText(["开始日期", "Start date"]),
+              TranslateText(["结束日期", "End date"]),
+            ]}
             disabledDate={disabledDate}
           />
         </div>
         <div>
-          <Button onClick={onExport}>导出</Button>
+          <Button onClick={onExport}>
+            {TranslateText(["导出", "Export"])}
+          </Button>
         </div>
       </div>
       <Table
@@ -441,7 +457,7 @@ const Index = (props) => {
         <Pagination
           onChange={setPage}
           total={total}
-          showTotal={showTotal}
+          showTotal={getPaginationTotalText}
           showSizeChanger={false}
           pageSize={15}
           current={page}

+ 26 - 3
src/pages/Alarm/components/detail.jsx

@@ -16,6 +16,23 @@ import AlarmDetail from "./components/AlarmDetail";
 import AlarmConfirm from "./components/AlarmConfirm";
 // import { AlarmConfig } from "./components/AlarmConfig";
 
+function TranslateText(arr) {
+  const dtLanguage = localStorage.getItem("dtLanguage");
+  if (!Array.isArray(arr)) {
+    return arr;
+  }
+
+  if (arr.length < 2 && arr.length > 0) {
+    return arr?.[0];
+  }
+
+  if (dtLanguage === "en") {
+    return arr?.[1];
+  }
+
+  return arr?.[0];
+}
+
 const Detail = (props) => {
   const { options, isDiagram } = props;
   const [tags, setTags] = useState([]);
@@ -85,7 +102,7 @@ const Detail = (props) => {
   return (
     <>
       <Modal
-        title="告警记录"
+        title={TranslateText(["告警记录", "Alarm History"])}
         centered
         open={props.open}
         width="90vw"
@@ -119,11 +136,17 @@ const Detail = (props) => {
                   activeKey={current}
                   type="card"
                   items={[
-                    { label: "告警记录", children: null, key: "history" },
+                    {
+                      label: TranslateText(["告警记录", "Alarm History"]),
+                      children: null,
+                      key: "history",
+                    },
                     ...tags.map((item, index) => ({
                       label: (
                         <div className={styles.tagContainer}>
-                          <div className={styles.label}>详情</div>
+                          <div className={styles.label}>
+                            {TranslateText(["详情", "Detail"])}
+                          </div>
                           <CloseOutlined
                             style={{ fontSize: 10 }}
                             onClick={(e) => {

+ 2 - 2
src/pages/Alarm/components/easy.jsx

@@ -155,7 +155,7 @@ const Easy = (props, ref) => {
         .then((res) => {
           if (res?.state === 0) {
             form.resetFields();
-            message.success("保存成功");
+            message.success(TranslateText(["保存成功", "Seted"]));
             props.onConfirm();
           } else {
             message.error(res?.state_info);
@@ -248,7 +248,7 @@ const Easy = (props, ref) => {
         .then((res) => {
           if (res?.state === 0) {
             form.resetFields();
-            message.success("保存成功");
+            message.success(TranslateText(["保存成功", "Seted"]));
             props.onConfirm();
           } else {
             message.error(res?.state_info);

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików