Parcourir la source

Merge branch 'master' of http://gogsb.soaringnova.com/liutao/ai-proj-demo

Zhang Li il y a 2 ans
Parent
commit
8fdf5e5f50

+ 2 - 2
src/module/taskmgmt/component/TaskForm.jsx

@@ -166,7 +166,7 @@ const TaskForm = ({ taskForm, taskType, taskInfo, jmWorkList }, ref) => {
               </>
             )}>
             {tagOptions.map(item => (
-              <Option key={item}>
+              <Option key={item} value={item} label={item}>
                 <Space>
                   <DeleteOutlined onClick={() => onDeleteTag(item)} />
                   <span>{item}</span>
@@ -186,7 +186,7 @@ const TaskForm = ({ taskForm, taskType, taskInfo, jmWorkList }, ref) => {
               placeholder="选择作业"
               allowClear>
               {jmWorkOptions.map(item => (
-                <Option key={item.id} value={item.id}>
+                <Option key={item.id} value={item.id} label={item.name}>
                   {item.name}
                 </Option>
               ))}

+ 18 - 8
src/module/workmgmt/component/JobCreate.jsx

@@ -582,8 +582,6 @@ export default function JobCreate() {
                 },
               ]}>
               <Select
-                showSearch
-                optionFilterProp="label"
                 placeholder="请选择作业类型..."
                 onSelect={onGenderChange}
                 options={jobTypeOptions}
@@ -713,7 +711,7 @@ export default function JobCreate() {
                   </>
                 )}>
                 {jobTags.map(item => (
-                  <Option key={item}>
+                  <Option key={item} value={item} label={item}>
                     <Space>
                       <DeleteOutlined onClick={() => onDeleteTag(item)} />
                       <span>{item}</span>
@@ -739,7 +737,10 @@ export default function JobCreate() {
                 showSearch
                 optionFilterProp="label">
                 {javaImages.map(item => (
-                  <Option key={item.value} value={item.value}>
+                  <Option
+                    key={item.value}
+                    value={item.value}
+                    label={item.label}>
                     {item.label}
                   </Option>
                 ))}
@@ -774,7 +775,10 @@ export default function JobCreate() {
                         onChange={onScriptFileChange}
                         disabled={radioValue === 'fromList' ? false : true}>
                         {javas.map(item => (
-                          <Option key={item.uri} value={item.name}>
+                          <Option
+                            key={item.uri}
+                            value={item.name}
+                            label={item.name}>
                             {item.name}
                           </Option>
                         ))}
@@ -875,7 +879,7 @@ export default function JobCreate() {
                   </>
                 )}>
                 {jobTags.map(item => (
-                  <Option key={item}>
+                  <Option key={item} value={item} label={item}>
                     <Space>
                       <DeleteOutlined onClick={() => onDeleteTag(item)} />
                       <span>{item}</span>
@@ -900,7 +904,10 @@ export default function JobCreate() {
                 placeholder="请选择镜像..."
                 allowClear>
                 {pythonImages.map(item => (
-                  <Option key={item.value} value={item.value}>
+                  <Option
+                    key={item.value}
+                    value={item.value}
+                    label={item.label}>
                     {item.label}
                   </Option>
                 ))}
@@ -935,7 +942,10 @@ export default function JobCreate() {
                         onChange={onScriptFileChange}
                         disabled={radioValue === 'fromList' ? false : true}>
                         {pythons.map(item => (
-                          <Option key={item.uri} value={item.name}>
+                          <Option
+                            key={item.uri}
+                            value={item.name}
+                            label={item.name}>
                             {item.name}
                           </Option>
                         ))}

+ 1 - 1
src/module/workmgmt/component/JobStepOne.jsx

@@ -168,7 +168,7 @@ export default function JobStepOne({ ConfigDataForm, SelectDag }) {
               </>
             )}>
             {jobTags.map(item => (
-              <Option key={item}>
+              <Option key={item} value={item} label={item}>
                 <Space>
                   <DeleteOutlined onClick={() => onDeleteTag(item)} />
                   <span>{item}</span>

+ 15 - 5
src/module/workmgmt/component/JobStepThree.jsx

@@ -173,7 +173,7 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
     }
   }
   const onTableSelect = async (val, index) => {
-    formatSchemaPreview(nodeState.index, false)
+    // formatSchemaPreview(nodeState.index, false)
     if (val !== undefined) {
       const { data } = await getLocalTableSchema(val)
       if (data.code === 200) {
@@ -191,6 +191,8 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
   const handleSyncData = (datasourceSchemas, nodeDataSchemas, index) => {
     const list = []
     const syncList = []
+    //整体结果
+    let node_result = true
     nodeDataSchemas.forEach(item => {
       const syncItem = datasourceSchemas.find(
         val => val.dataField === item.dataField
@@ -199,7 +201,12 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
         const handleType = syncItem.dataType.split('(')[0]
         const result =
           item.dataType === handleType ||
-          (item.dataType === 'string' && handleType === 'varchar')
+          (['varchar', 'string'].includes(item.dataType) &&
+            ['varchar', 'string'].includes(handleType)) ||
+          (['int', 'bigint'].includes(item.dataType) &&
+            ['int', 'bigint'].includes(handleType))
+
+        if (!result) node_result = false
         syncList.push({ datasource: syncItem, dag: item, result })
         datasourceSchemas = datasourceSchemas.filter(val => val !== syncItem)
       } else {
@@ -223,14 +230,13 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
         })
       })
     }
-    if (list.length === 0) {
+    if (list.length === 0 && node_result) {
       setNodeState({ index, state: true })
     } else {
       setNodeState({ index, state: false })
     }
 
     setNodeSchema({ index, list: syncList })
-    formatSchemaPreview(index, true)
   }
 
   const showStructure = index => {
@@ -264,6 +270,7 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
     const states = { ...nodeStates }
     states[nodeState.index] = nodeState.state
     setNodeStates(states)
+    formatSchemaPreview(nodeState.index, true)
   }, [nodeState])
 
   useEffect(() => {
@@ -313,7 +320,10 @@ export default function JobStepTwo({ OutputDataForm, dagData, checkSync }) {
                     <Select
                       showSearch
                       optionFilterProp="label"
-                      onSelect={val => onTableSelect(val, index)}>
+                      onChange={val => {
+                        formatSchemaPreview(index, false)
+                        onTableSelect(val, index)
+                      }}>
                       {tableData.map(item => (
                         <Option key={item} value={item}>
                           {item}

+ 19 - 5
src/module/workmgmt/component/JobStepTwo.jsx

@@ -171,7 +171,6 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
     }
   }
   const onTableSelect = async (val, index) => {
-    formatSchemaPreview(nodeState.index, false)
     if (val !== undefined) {
       const { data } = await getLocalTableSchema(val)
       if (data.code === 200) {
@@ -187,9 +186,14 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
   }
 
   const handleSyncData = (datasourceSchemas, nodeDataSchemas, index) => {
+    //不符合比对条件的
     const list = []
+    //符合比对条件的
     const syncList = []
+    //整体结果
+    let node_result = true
     nodeDataSchemas.forEach(item => {
+      // 字段相同
       const syncItem = datasourceSchemas.find(
         val => val.dataField === item.dataField
       )
@@ -197,13 +201,20 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
         const handleType = syncItem.dataType.split('(')[0]
         const result =
           item.dataType === handleType ||
-          (item.dataType === 'string' && handleType === 'varchar')
+          (['varchar', 'string'].includes(item.dataType) &&
+            ['varchar', 'string'].includes(handleType)) ||
+          (['int', 'bigint'].includes(item.dataType) &&
+            ['int', 'bigint'].includes(handleType))
+
+        if (!result) node_result = false
         syncList.push({ datasource: syncItem, dag: item, result })
+        // 将符合要求的从比对数组剔除
         datasourceSchemas = datasourceSchemas.filter(val => val !== syncItem)
       } else {
         list.push(item)
       }
     })
+    //两个数组不符合同字段要求剩余部分比对
     if (list.length > datasourceSchemas.length) {
       list.forEach((item, index) => {
         syncList.push({
@@ -221,14 +232,13 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
         })
       })
     }
-    if (list.length === 0) {
+    if (list.length === 0 && node_result) {
       setNodeState({ index, state: true })
     } else {
       setNodeState({ index, state: false })
     }
 
     setNodeSchema({ index, list: syncList })
-    formatSchemaPreview(index, true)
   }
 
   const showStructure = index => {
@@ -261,6 +271,7 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
     const states = { ...nodeStates }
     states[nodeState.index] = nodeState.state
     setNodeStates(states)
+    formatSchemaPreview(nodeState.index, true)
   }, [nodeState])
 
   useEffect(() => {
@@ -310,7 +321,10 @@ export default function JobStepTwo({ InputDataForm, dagData, checkSync }) {
                     <Select
                       showSearch
                       optionFilterProp="label"
-                      onSelect={val => onTableSelect(val, index)}>
+                      onChange={val => {
+                        formatSchemaPreview(index, false)
+                        onTableSelect(val, index)
+                      }}>
                       {tableData.map(item => (
                         <Option key={item} value={item}>
                           {item}