fault_drawer.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <div>
  3. <BasicForm>
  4. <template #templateID="{ model }">
  5. <el-select-v2
  6. v-model="model.templateID"
  7. :options="
  8. templateList.map((item) => ({
  9. label: item.templateName,
  10. value: item.templateID
  11. }))
  12. "
  13. placeholder="请选择操作模板"
  14. @change="handleTemplateChange"
  15. />
  16. </template>
  17. </BasicForm>
  18. </div>
  19. </template>
  20. <script setup lang="ts" name="DrawerOperation">
  21. import { useForm } from '@/components/form'
  22. import { Process } from '../common/process.type'
  23. import { ProcessFault, ProcessServer } from '@/api/course.api'
  24. const props = withDefaults(defineProps<{ node: Process.FaultNode }>(), {})
  25. const templateList = ref<ProcessFault[]>([])
  26. const templateSelected = ref<ProcessFault>()
  27. const [BasicForm, formApi] = useForm({
  28. labelWidth: '100px',
  29. schema: [
  30. { prop: 'role', label: '选择角色', component: 'ApiSelect', componentProps: { api: '/role/list', labelField: 'roleName', valueField: 'roleID' } },
  31. { prop: 'templateID', label: '操作模', component: 'Input' },
  32. { prop: 'templateType', label: '操作模板类型', component: 'Input' },
  33. { prop: 'category', label: '节点分类', component: 'Input' },
  34. { prop: 'categoryName', label: '分类名称', component: 'Input' },
  35. { prop: 'subCategory', label: '子分类', component: 'Input' },
  36. { prop: 'subCategoryName', label: '子分类名称', component: 'Input' },
  37. {
  38. prop: 'param1Type',
  39. label: '参数1类型',
  40. component: 'Select',
  41. colSpan: 10,
  42. componentProps: {
  43. placeholder: '请选择类型',
  44. options: [
  45. { label: '文本', value: 1 },
  46. { label: '数字', value: 2 },
  47. { label: '日期', value: 3 }
  48. ]
  49. },
  50. ifShow: () => templateSelected.value?.param1Type != -1
  51. },
  52. {
  53. prop: 'param1Desc',
  54. label: '',
  55. labelWidth: '0px',
  56. component: 'Input',
  57. componentProps: () => ({ placeholder: templateSelected.value?.param1Desc || '请输入参数' }),
  58. colSpan: 14,
  59. ifShow: () => templateSelected.value?.param1Type != -1
  60. },
  61. {
  62. prop: 'param2Type',
  63. label: '参数2类型',
  64. component: 'Select',
  65. componentProps: {
  66. placeholder: '请选择类型',
  67. options: [
  68. { label: '文本', value: 1 },
  69. { label: '数字', value: 2 },
  70. { label: '日期', value: 3 }
  71. ]
  72. },
  73. colSpan: 10,
  74. ifShow: () => templateSelected.value?.param2Type != -1
  75. },
  76. {
  77. prop: 'param2Desc',
  78. label: '',
  79. labelWidth: '0px',
  80. component: 'Input',
  81. componentProps: () => ({ placeholder: templateSelected.value?.param2Desc || '请输入参数' }),
  82. colSpan: 14,
  83. ifShow: () => templateSelected.value?.param2Type != -1
  84. },
  85. {
  86. prop: 'param3Type',
  87. label: '参数3类型',
  88. component: 'Select',
  89. colSpan: 10,
  90. componentProps: {
  91. placeholder: '请选择类型',
  92. options: [
  93. { label: '文本', value: 1 },
  94. { label: '数字', value: 2 },
  95. { label: '日期', value: 3 }
  96. ]
  97. },
  98. ifShow: () => templateSelected.value?.param3Type != -1
  99. },
  100. {
  101. prop: 'param3Desc',
  102. label: '',
  103. labelWidth: '0px',
  104. component: 'Input',
  105. componentProps: () => ({ placeholder: templateSelected.value?.param3Desc || '请输入参数' }),
  106. colSpan: 14,
  107. ifShow: () => templateSelected.value?.param3Type != -1
  108. },
  109. {
  110. prop: 'param4Type',
  111. label: '参数4类型',
  112. component: 'Select',
  113. colSpan: 10,
  114. componentProps: {
  115. placeholder: '请选择类型',
  116. options: [
  117. { label: '文本', value: 1 },
  118. { label: '数字', value: 2 },
  119. { label: '日期', value: 3 }
  120. ]
  121. },
  122. ifShow: () => templateSelected.value?.param4Type != -1
  123. },
  124. {
  125. prop: 'param4Desc',
  126. label: '',
  127. labelWidth: '0px',
  128. component: 'Input',
  129. componentProps: () => ({ placeholder: templateSelected.value?.param4Desc || '请输入参数' }),
  130. colSpan: 14,
  131. ifShow: () => templateSelected.value?.param4Type != -1
  132. },
  133. {
  134. prop: 'param5Type',
  135. label: '参数5类型',
  136. component: 'Select',
  137. colSpan: 10,
  138. componentProps: {
  139. placeholder: '请选择类型',
  140. options: [
  141. { label: '文本', value: 1 },
  142. { label: '数字', value: 2 },
  143. { label: '日期', value: 3 }
  144. ]
  145. },
  146. ifShow: () => templateSelected.value?.param5Type != -1
  147. },
  148. {
  149. prop: 'param5Desc',
  150. label: '',
  151. labelWidth: '0px',
  152. component: 'Input',
  153. componentProps: () => ({ placeholder: templateSelected.value?.param5Desc || '请输入参数' }),
  154. colSpan: 14,
  155. ifShow: () => templateSelected.value?.param5Type != -1
  156. }
  157. ]
  158. })
  159. const handleTemplateChange = (val: string) => {
  160. if (val) {
  161. const template = templateList.value.find((item) => item.templateID == val)
  162. if (template) {
  163. templateSelected.value = template
  164. }
  165. }
  166. }
  167. onMounted(async () => {
  168. const { data } = await ProcessServer.faultList()
  169. templateList.value = data || []
  170. nextTick(() => {
  171. formApi.setValues(props.node.nodeData || {})
  172. })
  173. })
  174. defineExpose({
  175. getNodeData: async (callback: (nodeData: Record<string, unknown>) => void) => {
  176. const data = await formApi.getValues()
  177. formApi.validate().then((valid) => {
  178. if (valid) {
  179. callback(data)
  180. } else {
  181. ElMessage.error('请检查节点配置是否完整')
  182. }
  183. })
  184. }
  185. })
  186. </script>