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

refactor: 优化代码格式并简化对象展开语法

style: 统一箭头函数语法和模板格式
refactor(process): 重构流程节点处理逻辑
zhanghaijun 1 год назад
Родитель
Сommit
e8abb6a959

+ 2 - 16
.vscode/dialog.code-snippets

@@ -82,14 +82,7 @@
       "  })",
       "  })",
       "  const [BasicForm, formApi] = useForm({",
       "  const [BasicForm, formApi] = useForm({",
       "    labelWidth: '120px',",
       "    labelWidth: '120px',",
-      "    schema: [",
-      "      {",
-      "        prop: 'name',",
-      "        label: '姓名',",
-      "        component: 'Input',",
-      "        rules: [{ required: true, message: '请输入姓名' }]",
-      "      }",
-      "    ]",
+      "    schema: [{ prop: 'name', label: '姓名', component: 'Input', rules: [{ required: true, message: '请输入姓名' }] }]",
       "  })",
       "  })",
       "  defineExpose({",
       "  defineExpose({",
       "    show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
       "    show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
@@ -133,14 +126,7 @@
       "  })",
       "  })",
       "  const [BasicForm, formApi] = useForm({",
       "  const [BasicForm, formApi] = useForm({",
       "    labelWidth: '120px',",
       "    labelWidth: '120px',",
-      "    schema: [",
-      "      {",
-      "        prop: 'name',",
-      "        label: '姓名',",
-      "        component: 'Input',",
-      "        rules: [{ required: true, message: '请输入姓名' }]",
-      "      }",
-      "    ]",
+      "    schema: [{ prop: 'name', label: '姓名', component: 'Input', rules: [{ required: true, message: '请输入姓名' }] }]",
       "  })",
       "  })",
       "  defineExpose({",
       "  defineExpose({",
       "    show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",
       "    show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {",

+ 66 - 9
scripts/process.ts

@@ -1,21 +1,78 @@
 import { ProcessHelper } from '../src/components/business/EasyProcess/common/process.helper'
 import { ProcessHelper } from '../src/components/business/EasyProcess/common/process.helper'
 import { nodeConfigData } from '../src/components/business/EasyProcess/common/process.data'
 import { nodeConfigData } from '../src/components/business/EasyProcess/common/process.data'
-import { EasyProcess } from '../src/components/business/EasyProcess/common/process.type'
 
 
 const nodeStart = nodeConfigData['start'].defaultNode()
 const nodeStart = nodeConfigData['start'].defaultNode()
 const processHelper = new ProcessHelper(nodeStart)
 const processHelper = new ProcessHelper(nodeStart)
 
 
-const nodeRouter: EasyProcess.RouterNode = nodeConfigData['router'].defaultNode() as EasyProcess.RouterNode
-processHelper.addNode(nodeStart.nodeId!, nodeRouter)
+const faultNode = nodeConfigData['fault'].defaultNode()
+const voiceNode = nodeConfigData['voice'].defaultNode()
+const operationNode = nodeConfigData['operation'].defaultNode()
 
 
-const nodeFault = nodeConfigData['fault'].defaultNode()
-processHelper.addNode(nodeRouter.conditionNodes![0].nodeId!, nodeConfigData['fault'].defaultNode())
-processHelper.addNode(nodeRouter.conditionNodes![0].nodeId!, nodeFault)
+processHelper.addNode(nodeStart.nodeId!, faultNode)
+processHelper.addNode(faultNode.nodeId!, voiceNode)
+processHelper.addNode(voiceNode.nodeId!, operationNode)
 
 
-processHelper.addNode(nodeRouter.nodeId!, nodeConfigData['voice'].defaultNode())
-processHelper.addNode(nodeRouter.nodeId!, nodeConfigData['voice'].defaultNode())
+processHelper.updateNode(faultNode.nodeId!, {
+  nodeName: '故障处理节点',
+  templateID: 0,
+  templateName: '',
+  category: 0,
+  categoryName: '',
+  faultLogicMap: 0,
+  param1Desc: '',
+  param1Type: 0,
+  param2Desc: '',
+  param2Type: 0,
+  param3Desc: '',
+  param3Type: 0,
+  param4Desc: '',
+  param4Type: 0,
+  param5Desc: '',
+  param5Type: 0,
+  subCategory: 0,
+  subCategoryName: ''
+})
+processHelper.updateNode(voiceNode.nodeId!, {
+  nodeName: '语音处理节点',
+  templateID: 0,
+  templateName: '',
+  category: 0,
+  categoryName: '',
+  subCategory: 0,
+  subCategoryName: '',
+  faultLogicMap: 0,
+  param1Desc: '',
+  param1Type: 0,
+  param2Desc: '',
+  param2Type: 0,
+  param3Desc: '',
+  param3Type: 0,
+  param4Desc: '',
+  param4Type: 0,
+  param5Desc: '',
+  param5Type: 0
+})
+processHelper.updateNode(operationNode.nodeId!, {
+  nodeName: '操作处理节点',
+  category: 0,
+  categoryName: '',
+  subCategory: 0,
+  subCategoryName: '',
+  templateID: 0,
+  templateName: '',
+  templateType: 0,
+  param1Desc: '',
+  param1Type: 0,
+  param2Desc: '',
+  param2Type: 0,
+  param3Desc: '',
+  param3Type: 0,
+  param4Desc: '',
+  param4Type: 0,
+  param5Desc: '',
+  param5Type: 0
+})
 
 
-processHelper.addNode(nodeFault.nodeId!, nodeConfigData['router'].defaultNode())
 processHelper.printTree()
 processHelper.printTree()
 
 
 const data = processHelper.getProcessData()
 const data = processHelper.getProcessData()

+ 2 - 9
src/components/business/EasyProcess/node/fault/index.vue

@@ -22,17 +22,10 @@
   })
   })
   const [BasicForm, formApi] = useForm({
   const [BasicForm, formApi] = useForm({
     labelWidth: '120px',
     labelWidth: '120px',
-    schema: [
-      {
-        prop: 'name',
-        label: '姓名',
-        component: 'Input',
-        rules: [{ required: true, message: '请输入姓名' }]
-      }
-    ]
+    schema: [{ prop: 'name', label: '姓名', component: 'Input', rules: [{ required: true, message: '请输入姓名' }] }]
   })
   })
   defineExpose({
   defineExpose({
-    show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {
+    show: ({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) => {
       record.value = data
       record.value = data
       crudApi.value = getCrudApi()
       crudApi.value = getCrudApi()
       dialogApi.open()
       dialogApi.open()

+ 2 - 2
src/components/crud/crud.vue

@@ -9,8 +9,8 @@
             <template #more>
             <template #more>
               <ElButton>
               <ElButton>
                 <template #icon><Icon class="icon-more" icon="ant-design:down-outlined" /></template>
                 <template #icon><Icon class="icon-more" icon="ant-design:down-outlined" /></template>
-                更多操作</ElButton
-              >
+                更多操作
+              </ElButton>
             </template>
             </template>
           </TableAction>
           </TableAction>
         </slot>
         </slot>

+ 3 - 10
src/components/dialog/dialog.vue

@@ -96,19 +96,12 @@
     }
     }
   }
   }
   const methods: MyDialogInstance = {
   const methods: MyDialogInstance = {
-    open() {
-      dialogVisible.value = true
-    },
-    close() {
-      dialogVisible.value = false
-    },
+    open: () => (dialogVisible.value = true),
+    close: () => (dialogVisible.value = false),
     // 设置组件状态(props)
     // 设置组件状态(props)
     setState(state: MyDialogProps) {
     setState(state: MyDialogProps) {
       return new Promise((resolve) => {
       return new Promise((resolve) => {
-        dialogPropsRef.value = {
-          ...dialogPropsRef.value,
-          ...state
-        }
+        dialogPropsRef.value = { ...dialogPropsRef.value, ...state }
         nextTick(() => {
         nextTick(() => {
           resolve()
           resolve()
         })
         })

+ 2 - 13
src/components/table-action/table-action.vue

@@ -3,15 +3,7 @@
 
 
   import { computed, h, type PropType, reactive, toRaw, type VNode } from 'vue'
   import { computed, h, type PropType, reactive, toRaw, type VNode } from 'vue'
   import { Icon } from '../icon'
   import { Icon } from '../icon'
-  import {
-    ElButton,
-    ElDropdown,
-    ElDropdownItem,
-    ElDropdownMenu,
-    ElMessageBox,
-    ElPopconfirm,
-    ElSpace
-  } from 'element-plus'
+  import { ElButton, ElDropdown, ElDropdownItem, ElDropdownMenu, ElMessageBox, ElPopconfirm, ElSpace } from 'element-plus'
   import { useAuth } from '@/composables/useAuth'
   import { useAuth } from '@/composables/useAuth'
   import { isBoolean, isFunction } from 'lodash-es'
   import { isBoolean, isFunction } from 'lodash-es'
 
 
@@ -104,10 +96,7 @@
     }
     }
     // 如果存在dialogRef,则直接调用show方法
     // 如果存在dialogRef,则直接调用show方法
     if (action.dialogRef) {
     if (action.dialogRef) {
-      const params =
-        (typeof action.dialogParams === 'function'
-          ? action.dialogParams(props.record || {})
-          : action.dialogParams) || {}
+      const params = (typeof action.dialogParams === 'function' ? action.dialogParams(props.record || {}) : action.dialogParams) || {}
       const dialogRef = action.dialogRef
       const dialogRef = action.dialogRef
       newAction.onClick = () => {
       newAction.onClick = () => {
         if (isFunction((dialogRef.value || dialogRef).show)) {
         if (isFunction((dialogRef.value || dialogRef).show)) {

+ 3 - 11
src/views/sys/dict-item/index.vue

@@ -6,24 +6,16 @@
 <script setup lang="tsx">
 <script setup lang="tsx">
   import { useCrud } from '@/components/crud'
   import { useCrud } from '@/components/crud'
   import { crudSchema } from './schemas'
   import { crudSchema } from './schemas'
-  const props = defineProps<{
-    dictId?: string
-  }>()
+  const props = defineProps<{ dictId?: string }>()
   const [BasicCrud] = useCrud({
   const [BasicCrud] = useCrud({
     ...crudSchema,
     ...crudSchema,
     // 查询参数处理
     // 查询参数处理
     beforeFetch(params: any) {
     beforeFetch(params: any) {
-      return {
-        ...params,
-        m_EQ_dictId: props.dictId
-      }
+      return { ...params, m_EQ_dictId: props.dictId }
     },
     },
     // 表单提交前处理
     // 表单提交前处理
     transformFormValues(values: any) {
     transformFormValues(values: any) {
-      return {
-        ...values,
-        dictId: props.dictId
-      }
+      return { ...values, dictId: props.dictId }
     },
     },
     toolbarActions: [],
     toolbarActions: [],
     dropDownToolbarActions: [],
     dropDownToolbarActions: [],

+ 1 - 1
src/views/sys/dict/dict-item-wrap.vue

@@ -17,7 +17,7 @@
     destroyOnClose: true
     destroyOnClose: true
   })
   })
   defineExpose({
   defineExpose({
-    show({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) {
+    show: ({ data, getCrudApi }: { data: any; getCrudApi: () => CrudMethods }) => {
       record.value = data
       record.value = data
       crudApi.value = getCrudApi()
       crudApi.value = getCrudApi()
       dialogApi.setState({ title: `【${data.name}】字典项管理` })
       dialogApi.setState({ title: `【${data.name}】字典项管理` })