index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <div class="airportInfo scroll-y">
  3. <div class="wrap">
  4. <MinHeader
  5. :is-auth="true"
  6. :is-statuser="true"
  7. @addForm="addServiceDialogShow"
  8. >
  9. <template #header>
  10. <div class="status flex-wrap">
  11. <div class="manageTitle">服务管理</div>
  12. <div class="status0"><span class="icon"></span>启动</div>
  13. <div class="status2"><span class="icon"></span>异常</div>
  14. <div class="status1"><span class="icon"></span>停止</div>
  15. </div>
  16. </template>
  17. </MinHeader>
  18. <div class="app-containers">
  19. <DataTable
  20. :is-Status="true"
  21. :table-header="tableColumns"
  22. :table-data="tableData"
  23. :table-btn-group="tableBtnGroup"
  24. btn-group-width="310px"
  25. :table-property="{ rowKey: 'ID' }"
  26. @btn-click="tableButtonClickHandler"
  27. />
  28. </div>
  29. <Dialog
  30. :width="serviceDialogWidth"
  31. :flag="serviceDialogVisible"
  32. :type="serviceDialogType"
  33. :del-name="delName"
  34. :msg-title="msgTitle"
  35. @del-remove="delSubmitHandler"
  36. @del-rest="delDialogHide"
  37. @submit-form="serviceSubmitHandler"
  38. @reset-form="serviceDialogHide"
  39. >
  40. <el-form
  41. ref="serviceFormRef"
  42. class="service-form"
  43. :model="serviceForm"
  44. :rules="serviceFormRules"
  45. label-position="right"
  46. label-width="90px"
  47. size="mini"
  48. >
  49. <el-row :gutter="36" type="flex">
  50. <el-col :span="12">
  51. <el-form-item label="服务名称" prop="serviceName">
  52. <el-input
  53. v-model="serviceForm.serviceName"
  54. placeholder="请输入服务名称"
  55. clearable
  56. />
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="12">
  60. <el-form-item
  61. label="前序输出编号"
  62. label-width="120px"
  63. prop="serviceOutputID"
  64. >
  65. <el-input
  66. v-model="serviceForm.serviceOutputID"
  67. placeholder="请输入前序输出编号"
  68. clearable
  69. />
  70. </el-form-item>
  71. </el-col>
  72. <el-col :span="12">
  73. <el-form-item label="类型" prop="serviceType">
  74. <el-select v-model="serviceForm.serviceType" clearable>
  75. <el-option :value="1" label="管理前端" />
  76. <el-option :value="2" label="管理后端" />
  77. <el-option :value="3" label="业务前端" />
  78. <el-option :value="4" label="业务后端" />
  79. </el-select>
  80. </el-form-item>
  81. </el-col>
  82. <el-col :span="12">
  83. <el-form-item label-width="14px">
  84. <el-radio-group v-model="serviceForm.isAsynchronous">
  85. <el-radio :label="1">同步</el-radio>
  86. <el-radio :label="0">异步</el-radio>
  87. </el-radio-group>
  88. </el-form-item>
  89. </el-col>
  90. <el-col :span="12">
  91. <div class="flex">
  92. <el-form-item label="数据来源" prop="dataSourceID">
  93. <el-select v-model="serviceForm.dataSourceID" clearable>
  94. <el-option
  95. v-for="dataSource in dataSourceList"
  96. :key="dataSource.dataSourceID"
  97. :value="dataSource.dataSourceID"
  98. :label="dataSource.dataSourceName"
  99. />
  100. </el-select>
  101. </el-form-item>
  102. <el-button
  103. type="primary"
  104. size="small"
  105. style="height: 28px; line-height: 0px"
  106. @click="addDataSourceDialogShow"
  107. >新增</el-button
  108. >
  109. </div>
  110. </el-col>
  111. <el-col :span="12">
  112. <el-form-item
  113. label="数据来源对象"
  114. label-width="120px"
  115. prop="sourceObjectName"
  116. >
  117. <el-input
  118. v-model="serviceForm.sourceObjectName"
  119. placeholder="请输入数据来源对象名称"
  120. clearable
  121. />
  122. </el-form-item>
  123. </el-col>
  124. <el-col :span="12">
  125. <el-form-item label="服务描述" prop="serviceDescribe">
  126. <el-input
  127. v-model="serviceForm.serviceDescribe"
  128. placeholder="请输入描述"
  129. clearable
  130. />
  131. </el-form-item>
  132. </el-col>
  133. <el-col :span="12">
  134. <el-form-item
  135. label="生命周期ID键名"
  136. prop="lifeCycleCol"
  137. label-width="120px"
  138. >
  139. <el-input
  140. v-model="serviceForm.lifeCycleCol"
  141. placeholder="请输入生命周期ID键名"
  142. clearable
  143. />
  144. </el-form-item>
  145. </el-col>
  146. <el-col :span="24">
  147. <el-form-item label="取值规则" prop="computingMethod">
  148. <el-input
  149. v-model="serviceForm.computingMethod"
  150. placeholder="请输入取值规则"
  151. type="textarea"
  152. :autosize="{ minRows: 4, maxRows: 4 }"
  153. resize="none"
  154. clearable
  155. />
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="24">
  159. <el-form-item label="检测规则" prop="validationExpression">
  160. <el-input
  161. v-model="serviceForm.validationExpression"
  162. placeholder="请输入检测规则"
  163. type="textarea"
  164. :autosize="{ minRows: 4, maxRows: 4 }"
  165. resize="none"
  166. clearable
  167. />
  168. </el-form-item>
  169. </el-col>
  170. <el-col :span="8">
  171. <el-form-item label="启动时间" prop="startTime">
  172. <el-date-picker
  173. v-model="serviceForm.startTime"
  174. type="datetime"
  175. format="yyyy-MM-dd HH:mm"
  176. value-format="yyyy-MM-dd HH:mm"
  177. placeholder="请选择启动时间"
  178. />
  179. </el-form-item>
  180. </el-col>
  181. <el-col :span="8">
  182. <el-form-item label="停止时间" prop="stopTime">
  183. <el-date-picker
  184. v-model="serviceForm.stopTime"
  185. type="datetime"
  186. format="yyyy-MM-dd HH:mm"
  187. value-format="yyyy-MM-dd HH:mm"
  188. placeholder="请选择停止时间"
  189. />
  190. </el-form-item>
  191. </el-col>
  192. <el-col :span="8">
  193. <el-form-item
  194. label="失败重试次数"
  195. prop="retryCount"
  196. label-width="100px"
  197. >
  198. <el-input
  199. v-model="serviceForm.retryCount"
  200. type="number"
  201. placeholder="请输入重试次数"
  202. clearable
  203. />
  204. </el-form-item>
  205. </el-col>
  206. <el-col :span="8">
  207. <el-form-item label="循环次数" prop="loopCount">
  208. <el-input
  209. v-model="serviceForm.loopCount"
  210. type="number"
  211. placeholder="请输入循环次数"
  212. clearable
  213. />
  214. </el-form-item>
  215. </el-col>
  216. <el-col :span="8">
  217. <el-form-item label="循环频率" prop="frequencyCount">
  218. <el-input
  219. v-model="serviceForm.frequencyCount"
  220. type="number"
  221. placeholder="请输入循环频率"
  222. clearable
  223. />
  224. </el-form-item>
  225. </el-col>
  226. <el-col :span="8">
  227. <el-form-item
  228. label="循环频率单位"
  229. prop="frequencyUnit"
  230. label-width="100px"
  231. >
  232. <el-select v-model="serviceForm.frequencyUnit" clearable>
  233. <el-option label="天" :value="24 * 60 * 60 * 1000" />
  234. <el-option label="小时" :value="60 * 60 * 1000" />
  235. <el-option label="分钟" :value="60 * 1000" />
  236. <el-option label="秒" :value="1000" />
  237. <el-option label="毫秒" :value="1" />
  238. </el-select>
  239. </el-form-item>
  240. </el-col>
  241. <el-col :span="12">
  242. <el-form-item
  243. label="日志存储位置"
  244. label-width="100px"
  245. prop="logDataSourceID"
  246. >
  247. <el-select v-model="serviceForm.logDataSourceID">
  248. <el-option
  249. v-for="dataSource in dataSourceList"
  250. :key="dataSource.dataSourceID"
  251. :value="dataSource.dataSourceID"
  252. :label="dataSource.dataSourceName"
  253. />
  254. </el-select>
  255. </el-form-item>
  256. </el-col>
  257. <el-col :span="12">
  258. <el-form-item
  259. label="日志过滤条件"
  260. label-width="100px"
  261. prop="logList"
  262. >
  263. <el-input
  264. v-model="serviceForm.logList"
  265. placeholder="请输入日志过滤条件"
  266. clearable
  267. />
  268. </el-form-item>
  269. </el-col>
  270. </el-row>
  271. </el-form>
  272. </Dialog>
  273. <Dialog
  274. type="add"
  275. width="500px"
  276. :flag="dataSourceDialogVisible"
  277. msg-title="新增数据来源"
  278. @submit-form="dataSourceSubmitHandler"
  279. @reset-form="dataSourceDialogHide"
  280. >
  281. <el-form ref="sourceFormRef" label-width="100px" :model="sourceForm">
  282. <el-form-item label="数据源名称">
  283. <el-input v-model="sourceForm.dataSourceName" size="small" />
  284. </el-form-item>
  285. <el-form-item label="协议名称">
  286. <el-select
  287. size="small"
  288. style="width: 100%"
  289. v-model="sourceForm.protocolName"
  290. placeholder="请选择活动区域"
  291. >
  292. <el-option
  293. v-for="protocol in protocolList"
  294. :key="protocol.protocolID"
  295. :label="protocol.protocolName"
  296. :value="protocol.protocolID"
  297. />
  298. </el-select>
  299. </el-form-item>
  300. <el-form-item label="连接参数">
  301. <el-input
  302. size="small"
  303. type="textarea"
  304. rows="3"
  305. v-model="sourceForm.connectConfig"
  306. />
  307. </el-form-item>
  308. </el-form>
  309. </Dialog>
  310. </div>
  311. </div>
  312. </template>
  313. <script setup lang="ts">
  314. import DataTable from '@/components/tableTemp/index.vue'
  315. import MinHeader from '@/components/minheader/index.vue'
  316. import Dialog from '@/components/dialog/index.vue'
  317. import { ElMessage, FormInstance } from 'element-plus'
  318. import { Query } from '@/api/dataIntegration'
  319. import {
  320. CommonTableColumn,
  321. CommonQueryResult,
  322. SelectOptionQueryResult,
  323. } from '~/common'
  324. interface DataSource {
  325. dataSourceID: string | number
  326. dataSourceName: string
  327. }
  328. interface Protocol {
  329. protocolID: string | number
  330. protocolName: string
  331. }
  332. // 表格
  333. const tableColumns = ref<CommonTableColumn[]>([])
  334. const tableData = ref<any[]>([])
  335. const page = ref(0)
  336. const noMore = ref(false)
  337. const rowTitle = ref('')
  338. onMounted(() => {
  339. getTableData()
  340. })
  341. const getTableData = async () => {
  342. try {
  343. const {
  344. code,
  345. returnData: { columnSet, listValues },
  346. message,
  347. }: CommonQueryResult = await Query({
  348. id: DATACONTENT_ID.sysServiceTable,
  349. dataContent: [],
  350. needPage: ++page.value,
  351. })
  352. if (Number(code) !== 0) {
  353. throw new Error(message || '失败')
  354. }
  355. if (listValues.length === 0) {
  356. page.value--
  357. noMore.value = false
  358. }
  359. const titleColumn = columnSet.find(column => column.needShow === 1)
  360. if (titleColumn) {
  361. rowTitle.value = titleColumn.columnName
  362. }
  363. tableColumns.value = columnSet.map(column => ({
  364. key: column.columnName,
  365. label: column.columnLabel,
  366. ...column,
  367. }))
  368. tableData.value.push(...listValues)
  369. } catch (error: any) {
  370. page.value--
  371. ElMessage.error(error.message)
  372. }
  373. }
  374. const tableBtnGroup = [
  375. {
  376. name: '查看',
  377. className: 'editBtn',
  378. param: 1,
  379. },
  380. {
  381. name: '编辑',
  382. className: 'editBtn',
  383. param: 2,
  384. },
  385. {
  386. name: '停止',
  387. className: 'editBtn',
  388. param: 3,
  389. },
  390. {
  391. name: '删除',
  392. className: 'delBtn',
  393. param: 4,
  394. },
  395. ]
  396. const tableButtonClickHandler = (
  397. rowIndex: number,
  398. row: object,
  399. param: number
  400. ) => {
  401. switch (param) {
  402. case 1:
  403. break
  404. case 2:
  405. break
  406. case 3:
  407. break
  408. case 4:
  409. break
  410. default:
  411. break
  412. }
  413. }
  414. // 新增/删除服务-弹窗
  415. const serviceDialogVisible = ref(false) // 弹窗开关
  416. const serviceDialogType = ref('del') // 弹窗类型是否删除
  417. const serviceDialogWidth = computed(() =>
  418. serviceDialogType.value === 'del' ? '600px' : '878px'
  419. )
  420. const delName = ref('') // 删除对象名
  421. const msgTitle = '新增服务管理' // 新增弹窗-标题
  422. const addServiceDialogShow = () => {
  423. getSelectOptions(DATACONTENT_ID.dataSourceOptions)
  424. serviceDialogType.value = 'add'
  425. serviceDialogVisible.value = true
  426. }
  427. const delSubmitHandler = () => {}
  428. const delDialogHide = () => {}
  429. const serviceDialogHide = () => {
  430. serviceFormRef.value?.resetFields()
  431. serviceDialogVisible.value = false
  432. }
  433. // 新增服务-表单
  434. const serviceFormRef = ref<FormInstance | null>(null)
  435. const serviceForm = reactive({
  436. serviceName: '',
  437. serviceOutputID: null,
  438. serviceType: null,
  439. dataSourceID: null,
  440. sourceObjectName: '',
  441. lifeCycleCol: '',
  442. isAsynchronous: 1,
  443. threads: null,
  444. datatype: null,
  445. computingMethod: '',
  446. validationExpression: '',
  447. startTime: null,
  448. stopTime: null,
  449. retryCount: null,
  450. loopCount: null,
  451. frequencyCount: null,
  452. frequencyUnit: null,
  453. serviceDescribe: '',
  454. logDataSourceID: null,
  455. logList: '',
  456. })
  457. const serviceFormRules = {
  458. serviceName: [
  459. {
  460. required: true,
  461. message: '请输入服务名称',
  462. trigger: ['change', 'blur'],
  463. },
  464. ],
  465. }
  466. const dataSourceList = ref<DataSource[]>([])
  467. const serviceSubmitHandler = () => {
  468. serviceDialogHide()
  469. }
  470. // 新增数据来源-弹窗
  471. const dataSourceDialogVisible = ref(false)
  472. const addDataSourceDialogShow = () => {
  473. getSelectOptions(DATACONTENT_ID.protocolOptions)
  474. dataSourceDialogVisible.value = true
  475. }
  476. const dataSourceDialogHide = () => {
  477. sourceFormRef.value?.resetFields()
  478. dataSourceDialogVisible.value = false
  479. }
  480. // 新增数据来源-表单
  481. const sourceFormRef = ref<FormInstance | null>(null)
  482. const sourceForm = reactive({
  483. dataSourceName: '',
  484. protocolName: '',
  485. connectConfig: '',
  486. })
  487. const protocolList = ref<Protocol[]>([])
  488. const dataSourceSubmitHandler = () => {
  489. dataSourceDialogHide()
  490. }
  491. const getSelectOptions = async (id: number) => {
  492. try {
  493. const {
  494. code,
  495. returnData: { listValues },
  496. message,
  497. }: SelectOptionQueryResult = await Query({
  498. id,
  499. dataContent: [],
  500. })
  501. if (Number(code) !== 0) {
  502. throw new Error(message || '失败')
  503. }
  504. const options = listValues.map(item => ({
  505. [item.setlabel]: item.k,
  506. [item.setvalue]: item.v,
  507. }))
  508. switch (id) {
  509. case DATACONTENT_ID.dataSourceOptions:
  510. dataSourceList.value = options as DataSource[]
  511. break
  512. case DATACONTENT_ID.protocolOptions:
  513. protocolList.value = options as Protocol[]
  514. break
  515. default:
  516. break
  517. }
  518. } catch (error: any) {
  519. ElMessage.error(error.message)
  520. }
  521. }
  522. </script>
  523. <style lang="scss" scoped>
  524. .app-containers {
  525. height: calc(100vh - 180px);
  526. }
  527. .icon {
  528. width: 14px;
  529. height: 14px;
  530. background: #2d67e3;
  531. border-radius: 2px;
  532. display: inline-block;
  533. vertical-align: middle;
  534. margin-right: 10px;
  535. position: relative;
  536. top: -2px;
  537. }
  538. .status0,
  539. .status2 {
  540. margin-right: 28px;
  541. position: relative;
  542. top: 5px;
  543. }
  544. .status1 {
  545. position: relative;
  546. top: 5px;
  547. .icon {
  548. background-color: #afb4bf;
  549. }
  550. }
  551. .status2 {
  552. .icon {
  553. background-color: #eb2f3b;
  554. }
  555. }
  556. .service-form:deep {
  557. display: flex;
  558. flex-wrap: wrap;
  559. padding-left: 20px;
  560. > .el-row {
  561. flex-wrap: wrap;
  562. > .el-col .el-form-item {
  563. margin-bottom: 20px;
  564. .el-form-item__label {
  565. padding-right: 16px;
  566. }
  567. .el-input,
  568. .el-select {
  569. width: 100%;
  570. }
  571. .el-input__inner,
  572. .el-textarea__inner {
  573. padding-left: 8px;
  574. }
  575. .el-date-editor {
  576. .el-input__prefix,
  577. .el-input__suffix {
  578. right: 5px;
  579. left: unset;
  580. font-size: 16px;
  581. color: #101116;
  582. .el-input__suffix-inner {
  583. font-size: 16px;
  584. }
  585. }
  586. &.value-not-null:hover .el-input__prefix {
  587. display: none;
  588. }
  589. }
  590. }
  591. }
  592. label,
  593. span,
  594. button,
  595. input,
  596. optgroup,
  597. select,
  598. textarea {
  599. font-family: Helvetica, Microsoft YaHei;
  600. font-size: 14px;
  601. font-weight: 400;
  602. }
  603. label {
  604. color: #303133;
  605. }
  606. input {
  607. color: #101116;
  608. &::-webkit-outer-spin-button,
  609. &::-webkit-inner-spin-button {
  610. appearance: none;
  611. -webkit-appearance: none !important;
  612. &[type='number'] {
  613. appearance: textfield;
  614. -moz-appearance: textfield !important;
  615. }
  616. }
  617. .el-radio {
  618. font-weight: 400;
  619. }
  620. }
  621. }
  622. </style>