Просмотр исходного кода

fix: bug#9280、8690、9204、9212、7811

xieyonghong 3 лет назад
Родитель
Сommit
fb1bd5342b

+ 10 - 7
src/components/SearchComponent/index.less

@@ -53,16 +53,19 @@
 
   .history {
     width: 176px;
-
-    .list {
-      display: flex;
-      align-items: center;
-      justify-content: space-between;
-      width: 148px;
-    }
   }
 }
+.list {
+  display: flex;
+  gap: 4px;
+  align-items: center;
+  justify-content: space-between;
+  width: 148px;
+}
 
+.list-text {
+  flex: 1 1 auto;
+}
 .saveLog {
   width: 100%;
   margin-top: 5px;

+ 49 - 45
src/components/SearchComponent/index.tsx

@@ -510,51 +510,6 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     handleForm(_expand);
   };
 
-  const historyDom = (
-    <Menu className={styles.history}>
-      {history.length > 0 ? (
-        history.map((item: SearchHistory) => (
-          <Menu.Item key={item.id || randomString(9)}>
-            <div className={styles.list}>
-              <Typography.Text
-                ellipsis={{ tooltip: item.name }}
-                onClick={() => handleHistory(item)}
-              >
-                {item.name}
-              </Typography.Text>
-              <Popconfirm
-                title="确定删除嘛"
-                onConfirm={async () => {
-                  const response = await service.history.remove(`${target}-search`, item.key);
-                  if (response.status === 200) {
-                    onlyMessage('操作成功');
-                    const temp = history.filter((h: any) => h.key !== item.key);
-                    setHistory(temp);
-                  }
-                }}
-              >
-                <DeleteOutlined />
-              </Popconfirm>
-            </div>
-          </Menu.Item>
-        ))
-      ) : (
-        <Menu.Item>
-          <div
-            style={{
-              display: 'flex',
-              justifyContent: 'center',
-              alignItems: 'center',
-              width: '148px',
-            }}
-          >
-            <Empty />
-          </div>
-        </Menu.Item>
-      )}
-    </Menu>
-  );
-
   const formatValue = (value: SearchTermsUI): SearchTermsServer => {
     let _value = ui2Server(value);
     // 处理默认查询参数
@@ -679,6 +634,55 @@ const SearchComponent = <T extends Record<string, any>>(props: Props<T>) => {
     }
   }, []);
 
+  const historyDom = (
+    <Menu className={styles.history}>
+      {history.length > 0 ? (
+        history.map((item: SearchHistory) => (
+          <Menu.Item
+            key={item.id || randomString(9)}
+            onClick={() => {
+              handleHistory(item);
+              handleSearch();
+            }}
+          >
+            <div className={styles.list}>
+              <Typography.Text className={styles['list-text']} ellipsis={{ tooltip: item.name }}>
+                {item.name}
+              </Typography.Text>
+              <Popconfirm
+                title="确定删除嘛"
+                onConfirm={async (e) => {
+                  e?.stopPropagation();
+                  const response = await service.history.remove(`${target}-search`, item.key);
+                  if (response.status === 200) {
+                    onlyMessage('操作成功');
+                    const temp = history.filter((h: any) => h.key !== item.key);
+                    setHistory(temp);
+                  }
+                }}
+              >
+                <DeleteOutlined />
+              </Popconfirm>
+            </div>
+          </Menu.Item>
+        ))
+      ) : (
+        <Menu.Item>
+          <div
+            style={{
+              display: 'flex',
+              justifyContent: 'center',
+              alignItems: 'center',
+              width: '148px',
+            }}
+          >
+            <Empty />
+          </div>
+        </Menu.Item>
+      )}
+    </Menu>
+  );
+
   const handleSaveLog = async () => {
     const value = await form.submit<SearchTermsUI>();
     const value2 = await historyForm.submit<{ alias: string }>();

+ 2 - 1
src/pages/media/DashBoard/index.tsx

@@ -144,9 +144,10 @@ export default () => {
           // minInterval: 1,
         },
         grid: {
-          left: '80px',
+          left: 50,
           right: 0,
           top: '2%',
+          bottom: 20,
         },
         color: ['#2F54EB'],
         series: [

+ 18 - 16
src/pages/rule-engine/Scene/Save/action/ListItem/FilterGroup.tsx

@@ -16,6 +16,7 @@ interface TermsProps {
   branchesName: number;
   branchGroup: number;
   isLast: boolean;
+  isFirst: boolean;
   label?: any;
   paramsOptions: any[];
   actionColumns: any[];
@@ -53,6 +54,22 @@ export default observer((props: TermsProps) => {
   return (
     <div className="terms-params">
       <div className="terms-params-warp">
+        {!props.isFirst && (
+          <div className="term-type-warp">
+            <DropdownButton
+              options={[
+                { title: '并且', key: 'and' },
+                { title: '或者', key: 'or' },
+              ]}
+              isTree={false}
+              type="type"
+              value={props.data.type}
+              onChange={(v) => {
+                props.data.type = v;
+              }}
+            />
+          </div>
+        )}
         <div
           className="terms-params-content"
           onMouseOver={() => {
@@ -187,22 +204,7 @@ export default observer((props: TermsProps) => {
             </div>
           </Popconfirm>
         </div>
-        {!props.isLast ? (
-          <div className="term-type-warp">
-            <DropdownButton
-              options={[
-                { title: '并且', key: 'and' },
-                { title: '或者', key: 'or' },
-              ]}
-              isTree={false}
-              type="type"
-              value={props.data.type}
-              onChange={(v) => {
-                props.data.type = v;
-              }}
-            />
-          </div>
-        ) : (
+        {!props.isLast && (
           <div className="terms-group-add" onClick={props.onAddGroup}>
             <div className="terms-content">
               <PlusOutlined style={{ fontSize: 12, paddingRight: 4 }} />

+ 2 - 0
src/pages/rule-engine/Scene/Save/terms/branchItem.tsx

@@ -106,6 +106,7 @@ export default observer((props: BranchesItemProps) => {
                       name={dIndex}
                       data={item}
                       key={item.key}
+                      isFirst={dIndex === 0}
                       paramsOptions={props.paramsOptions}
                       isLast={dIndex === when!.length - 1}
                       onValueChange={(data) => {
@@ -116,6 +117,7 @@ export default observer((props: BranchesItemProps) => {
                       }}
                       onDelete={() => {
                         FormModel.current.branches![props.name].when.splice(dIndex, 1);
+                        FormModel.current.options?.when[props.name].terms?.splice(dIndex, 1);
                       }}
                     />
                   ))

+ 19 - 16
src/pages/rule-engine/Scene/Save/terms/term.tsx

@@ -20,6 +20,7 @@ interface TermsProps {
   onValueChange: (data: TermsType) => void;
   onLabelChange: (label: any) => void;
   onDelete: () => void;
+  isFirst: boolean;
 }
 
 export default observer((props: TermsProps) => {
@@ -52,6 +53,22 @@ export default observer((props: TermsProps) => {
   return (
     <div className="terms-params">
       <div className="terms-params-warp">
+        {!props.isFirst && (
+          <div className="term-type-warp">
+            <DropdownButton
+              options={[
+                { title: '并且', key: 'and' },
+                { title: '或者', key: 'or' },
+              ]}
+              isTree={false}
+              type="type"
+              value={props.data.type}
+              onChange={(v) => {
+                props.data.type = v;
+              }}
+            />
+          </div>
+        )}
         <div
           className="terms-params-content"
           onMouseOver={() => {
@@ -126,6 +143,7 @@ export default observer((props: TermsProps) => {
                     }
                     onDelete={() => {
                       terms.splice(index, 1);
+                      FormModel.current.options?.when[props.whenName]?.terms?.splice(index, 1);
                       // setTerms([...terms]);
                       // props.onValueChange({
                       //   terms: terms,
@@ -177,22 +195,7 @@ export default observer((props: TermsProps) => {
             </div>
           </Popconfirm>
         </div>
-        {!props.isLast ? (
-          <div className="term-type-warp">
-            <DropdownButton
-              options={[
-                { title: '并且', key: 'and' },
-                { title: '或者', key: 'or' },
-              ]}
-              isTree={false}
-              type="type"
-              value={props.data.type}
-              onChange={(v) => {
-                props.data.type = v;
-              }}
-            />
-          </div>
-        ) : (
+        {props.isLast && (
           <div className="terms-group-add" onClick={addTerms}>
             <div className="terms-content">
               <PlusOutlined style={{ fontSize: 12, paddingRight: 4 }} />