serviceEdit.vue 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. <template>
  2. <div class="service-edit">
  3. <div class="service-basic-wrapper">
  4. <Minheader
  5. is-journal
  6. is-statuser
  7. is-slot
  8. is-preser
  9. slot-permission="slot_edit_page"
  10. save-permission="service_save_button"
  11. log-permission="view_log_button"
  12. @add-journal-form="logDialogShow"
  13. @add-slot-form="slotDialogShow"
  14. @preser-form="serviceSubmitHandler"
  15. >
  16. <template #header>
  17. <div class="status flex-wrap">
  18. <div class="manageTitle">当前服务ID:{{ serviceID }}</div>
  19. <div class="service-state">{{ serviceState }}</div>
  20. </div>
  21. </template>
  22. </Minheader>
  23. <div class="form-wrapper">
  24. <el-form
  25. :model="serviceForm"
  26. class="w100 flex-wrap"
  27. label-width="100px"
  28. >
  29. <div class="w20 pd30">
  30. <el-form-item label="名称" prop="serviceName" size="default">
  31. <el-input
  32. v-model="serviceForm.serviceName"
  33. placeholder="请输入服务名称"
  34. clearable
  35. />
  36. </el-form-item>
  37. </div>
  38. <div class="w20 pd30 flex">
  39. <el-form-item label="业务类型" prop="serviceType" size="default">
  40. <el-select v-model="serviceForm.serviceType" style="width: 100px">
  41. <el-option :value="1" label="管理前端" />
  42. <el-option :value="2" label="管理后端" />
  43. <el-option :value="3" label="业务前端" />
  44. <el-option :value="4" label="业务后端" />
  45. </el-select>
  46. </el-form-item>
  47. <el-form-item
  48. class="isAsynchronous"
  49. prop="isAsynchronous"
  50. size="default"
  51. label-width="0"
  52. >
  53. <el-select
  54. v-model="serviceForm.isAsynchronous"
  55. style="width: 80px"
  56. >
  57. <el-option :value="1" label="同步"></el-option>
  58. <el-option :value="0" label="异步"></el-option>
  59. </el-select>
  60. </el-form-item>
  61. </div>
  62. <div class="w20 pd30">
  63. <el-form-item label="启动时间" prop="hasStartTime" size="default">
  64. <el-date-picker
  65. v-model="serviceForm.hasStartTime"
  66. type="datetime"
  67. format="yyyy-MM-dd HH:mm"
  68. value-format="yyyy-MM-dd HH:mm"
  69. placeholder="请选择启动时间"
  70. />
  71. </el-form-item>
  72. </div>
  73. <div class="w20 pd30">
  74. <el-form-item label="停止时间" prop="hasEndTime" size="default">
  75. <el-date-picker
  76. v-model="serviceForm.hasEndTime"
  77. type="datetime"
  78. format="yyyy-MM-dd HH:mm"
  79. value-format="yyyy-MM-dd HH:mm"
  80. placeholder="请选择停止时间"
  81. />
  82. </el-form-item>
  83. </div>
  84. <div class="w20">
  85. <el-form-item
  86. label="前序输出编号"
  87. prop="serviceOutputID"
  88. size="default"
  89. >
  90. <el-input
  91. v-model="serviceForm.serviceOutputID"
  92. placeholder="请输入前序输出编号"
  93. clearable
  94. />
  95. </el-form-item>
  96. </div>
  97. </el-form>
  98. </div>
  99. </div>
  100. <div class="service-config-wrapper">
  101. <Minheader is-statuser>
  102. <template #header>
  103. <div class="status flex-wrap">
  104. <div class="manageTitle">主动采集配置</div>
  105. </div>
  106. </template>
  107. </Minheader>
  108. <div class="form-wrapper">
  109. <el-form
  110. :model="serviceForm"
  111. class="w100 flex-wrap"
  112. label-width="100px"
  113. >
  114. <div class="w20 pd30">
  115. <el-form-item
  116. v-if="selectOptionMap[queryTemplateIDMap.dataSourceID]"
  117. label="数据源"
  118. prop="dataSourceID"
  119. size="default"
  120. >
  121. <el-select v-model="serviceForm.dataSourceID" clearable>
  122. <el-option
  123. v-for="option in selectOptionMap[
  124. queryTemplateIDMap.dataSourceID
  125. ]"
  126. :key="option[option.setvalue]"
  127. :value="option[option.setvalue]"
  128. :label="option[option.setlabel]"
  129. />
  130. </el-select>
  131. </el-form-item>
  132. </div>
  133. <div class="w40">
  134. <el-form-item
  135. label="详细位置"
  136. prop="sourceObjectName"
  137. size="default"
  138. >
  139. <el-input
  140. v-model="serviceForm.sourceObjectName"
  141. placeholder="请输入详细位置"
  142. clearable
  143. />
  144. </el-form-item>
  145. </div>
  146. <div class="w40">
  147. <el-form-item
  148. label="服务描述"
  149. prop="serviceDescribe"
  150. size="default"
  151. >
  152. <el-input
  153. v-model="serviceForm.serviceDescribe"
  154. placeholder="请输入服务描述"
  155. clearable
  156. />
  157. </el-form-item>
  158. </div>
  159. <div class="w20 pd30">
  160. <el-form-item label="计划启动时间" prop="startTime" size="default">
  161. <el-date-picker
  162. v-model="serviceForm.startTime"
  163. type="datetime"
  164. format="yyyy-MM-dd HH:mm"
  165. value-format="yyyy-MM-dd HH:mm"
  166. placeholder="请选择启动时间"
  167. />
  168. </el-form-item>
  169. </div>
  170. <div class="w20 pd30">
  171. <el-form-item label="计划停止时间" prop="stopTime" size="default">
  172. <el-date-picker
  173. v-model="serviceForm.stopTime"
  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. </div>
  181. <div class="w20 pd30">
  182. <el-form-item label="错误重试" prop="retryCount" size="default">
  183. <el-input
  184. v-model="serviceForm.retryCount"
  185. placeholder="请输入重试次数"
  186. clearable
  187. />
  188. </el-form-item>
  189. </div>
  190. <div class="w20 pd30">
  191. <el-form-item label="循环次数" prop="loopCount" size="default">
  192. <el-input
  193. v-model="serviceForm.loopCount"
  194. placeholder="请输入循环次数"
  195. clearable
  196. />
  197. </el-form-item>
  198. </div>
  199. <div class="w20">
  200. <el-form-item label="循环频率" prop="frequencyCount" size="default">
  201. <el-input
  202. v-model="serviceForm.frequencyCount"
  203. placeholder="请输入循环频率"
  204. clearable
  205. />
  206. </el-form-item>
  207. </div>
  208. </el-form>
  209. </div>
  210. </div>
  211. <div class="service-receive-wrapper">
  212. <Minheader is-statuser>
  213. <template #header>
  214. <div class="status flex-wrap">
  215. <div class="manageTitle">统一接收</div>
  216. </div>
  217. </template>
  218. </Minheader>
  219. <div class="form-wrapper">
  220. <el-form
  221. :model="serviceForm"
  222. class="w100 flex-wrap"
  223. label-width="100px"
  224. >
  225. <div class="w50 pd30">
  226. <el-form-item
  227. label="生命周期编号"
  228. prop="lifeCycleCol"
  229. size="default"
  230. >
  231. <el-input
  232. v-model="serviceForm.lifeCycleCol"
  233. placeholder="请输入生命周期编号"
  234. clearable
  235. />
  236. </el-form-item>
  237. </div>
  238. <div class="w50 pd30"></div>
  239. <div class="w50 pd30">
  240. <el-form-item
  241. label="取值表达式"
  242. prop="computingMethod"
  243. size="default"
  244. >
  245. <el-input
  246. v-model="serviceForm.computingMethod"
  247. placeholder="请输入取值表达式"
  248. type="textarea"
  249. :autosize="{
  250. minRows: 2,
  251. maxRows: 2,
  252. }"
  253. resize="none"
  254. clearable
  255. />
  256. </el-form-item>
  257. </div>
  258. <div class="w50">
  259. <el-form-item
  260. label="检测表达式"
  261. prop="validationExpression"
  262. size="default"
  263. >
  264. <el-input
  265. v-model="serviceForm.validationExpression"
  266. placeholder="请输入检测表达式"
  267. type="textarea"
  268. :autosize="{
  269. minRows: 2,
  270. maxRows: 2,
  271. }"
  272. resize="none"
  273. clearable
  274. />
  275. </el-form-item>
  276. </div>
  277. </el-form>
  278. </div>
  279. </div>
  280. <div class="service-output-wrapper">
  281. <el-row :gutter="24">
  282. <el-col :span="12">
  283. <Minheader
  284. :is-statuser="true"
  285. :is-auth="true"
  286. power-data="new_service_output_location_button"
  287. @addForm="outputDialogShow"
  288. >
  289. <template #header>
  290. <div class="status flex-wrap">
  291. <div class="manageTitle">输出</div>
  292. </div>
  293. </template>
  294. </Minheader>
  295. <div class="app-containers">
  296. <DataTable
  297. :table-header="outputTableColumns"
  298. :table-data="outputTableData"
  299. :table-btn-group="outputTableButtonGroup"
  300. @btnClick="outputTableButtonClickHandler"
  301. />
  302. </div>
  303. </el-col>
  304. <el-col :span="12">
  305. <Minheader :is-statuser="true">
  306. <template #header>
  307. <div class="status flex-wrap">
  308. <div class="manageTitle">日志记录</div>
  309. </div>
  310. </template>
  311. </Minheader>
  312. <div class="form-wrapper">
  313. <el-form
  314. :model="serviceForm"
  315. class="w100 flex-wrap"
  316. label-width="110px"
  317. >
  318. <div class="w50 pd30">
  319. <el-form-item
  320. v-if="selectOptionMap[queryTemplateIDMap.dataSourceID]"
  321. label="日志存储数据源"
  322. prop="logDataSourceID"
  323. size="default"
  324. >
  325. <el-select v-model="serviceForm.logDataSourceID">
  326. <el-option
  327. v-for="option in selectOptionMap[
  328. queryTemplateIDMap.dataSourceID
  329. ]"
  330. :key="option[option.setvalue]"
  331. :value="option[option.setvalue]"
  332. :label="option[option.setlabel]"
  333. />
  334. </el-select>
  335. </el-form-item>
  336. </div>
  337. <div class="w50 pd30">
  338. <el-form-item
  339. label="详细位置"
  340. prop="logDataSourceName"
  341. size="default"
  342. >
  343. <el-input
  344. v-model="serviceForm.logDataSourceName"
  345. placeholder="请输入详细位置"
  346. clearable
  347. />
  348. </el-form-item>
  349. </div>
  350. <div class="w100 pd30">
  351. <el-form-item
  352. label="日志输出条件"
  353. prop="logList"
  354. size="default"
  355. >
  356. <el-input
  357. v-model="serviceForm.logList"
  358. placeholder="请输入日志输出条件"
  359. type="textarea"
  360. :autosize="{
  361. minRows: 5,
  362. maxRows: 5,
  363. }"
  364. resize="none"
  365. clearable
  366. />
  367. </el-form-item>
  368. </div>
  369. </el-form>
  370. </div>
  371. </el-col>
  372. </el-row>
  373. </div>
  374. <Dialog
  375. width="852px"
  376. :flag="logDialogVisible"
  377. :with-footer="false"
  378. msg-title="查看日志"
  379. @resetForm="logDialogHide"
  380. >
  381. <div class="logDialog">
  382. <div class="interfaceLog">
  383. <div class="interfaceLog_head flex">
  384. <div class="interfaceLog_head_time flex-wrap">
  385. <div class="interfaceLog_head_time_start r12">
  386. <el-date-picker
  387. v-model="logStartTime"
  388. size="default"
  389. type="datetime"
  390. placeholder="选择开始日期时间"
  391. format="YYYY-MM-DD HH:mm:ss"
  392. value-format="YYYY-MM-DD HH:mm:ss"
  393. :clearable="false"
  394. @change="logTimeChangeHandler"
  395. />
  396. </div>
  397. <div class="interfaceLog_head_time_end">
  398. <el-date-picker
  399. v-model="logEndTime"
  400. size="default"
  401. type="datetime"
  402. placeholder="选择结束日期时间"
  403. format="YYYY-MM-DD HH:mm:ss"
  404. value-format="YYYY-MM-DD HH:mm:ss"
  405. :clearable="false"
  406. @change="logTimeChangeHandler"
  407. />
  408. </div>
  409. </div>
  410. <div class="flex">
  411. <el-input
  412. v-model="logSearchText"
  413. size="default"
  414. placeholder="请输入搜索关键词"
  415. clearable
  416. style="width: 180px"
  417. @clear="logSearchClearHandler"
  418. />
  419. <el-button
  420. size="default"
  421. type="primary"
  422. style="margin-left: 16px"
  423. @click="logSearchHandler"
  424. >查询</el-button
  425. >
  426. </div>
  427. </div>
  428. <div
  429. v-loading="logTableLoading"
  430. element-loading-text="拼命加载中"
  431. element-loading-spinner="el-icon-loading"
  432. element-loading-background="rgba(0, 0, 0, 0.8)"
  433. class="interfaceLog_content flex-wrap"
  434. >
  435. <el-table
  436. :data="logTableData"
  437. class="table"
  438. height="500px"
  439. stripe
  440. border
  441. style="width: 100%; margin-top: 20px"
  442. >
  443. <el-table-column prop="logTime" width="200" label="时间">
  444. </el-table-column>
  445. <el-table-column prop="logType" width="100" label="类型">
  446. </el-table-column>
  447. <el-table-column width="200" label="位置">
  448. <template #default="scope">
  449. <el-tooltip
  450. class="item"
  451. effect="dark"
  452. :content="scope.row.logPositionID"
  453. placement="top"
  454. >
  455. <div class="logPositionID">
  456. {{ scope.row.logPositionID }}
  457. </div>
  458. </el-tooltip>
  459. </template>
  460. </el-table-column>
  461. <el-table-column width="100" prop="resultCode" label="成败">
  462. </el-table-column>
  463. <el-table-column label="详情">
  464. <template #default="scope">
  465. <div class="flex-wrap">
  466. <el-tooltip
  467. class="item"
  468. effect="dark"
  469. :content="scope.row.resultDetails"
  470. placement="top"
  471. >
  472. <span :id="'logId' + scope.$index" class="logDetails">{{
  473. scope.row.resultDetails
  474. }}</span>
  475. </el-tooltip>
  476. <el-button
  477. @click="logCopy(scope.$index)"
  478. style="margin-left: 10px"
  479. type="text"
  480. >复制</el-button
  481. >
  482. </div>
  483. </template>
  484. </el-table-column>
  485. </el-table>
  486. </div>
  487. </div>
  488. </div>
  489. </Dialog>
  490. <Dialog
  491. width="852px"
  492. :flag="slotDialogVisible"
  493. msg-title="插槽编辑"
  494. @submit-form="slotSubmitHandler"
  495. @reset-form="slotDialogHide"
  496. >
  497. <div class="logcont">
  498. <Minheader
  499. :is-auth="true"
  500. :is-statuser="true"
  501. @addForm="editSlotDialogShow"
  502. >
  503. <template #header>
  504. <div class="status flex-wrap">
  505. <div class="manageTitle">插槽列表</div>
  506. </div>
  507. </template>
  508. </Minheader>
  509. </div>
  510. <div style="padding: 0 24px 24px 24px" class="dialog-content">
  511. <DataTable
  512. :table-header="slotTableColumns"
  513. :table-data="slotTableData"
  514. :table-btn-group="slotTableButtonGroups"
  515. selection-enable
  516. :table-property="{ headerCellClassName: 'hide-header-check' }"
  517. class="slot-table"
  518. @select="slotSelectHandler"
  519. @btnClick="slotTableButtonClickHandler"
  520. />
  521. </div>
  522. </Dialog>
  523. <Dialog
  524. :flag="editSlotDialogVisible"
  525. :type="editSlotDialogType"
  526. :msg-title="editSlotDialogTitle"
  527. :del-name="deployNodeName"
  528. @submit-form="editSlotSubmitHandler"
  529. @reset-form="editSlotDialogHide"
  530. @del-remove="editSlotSubmitHandler"
  531. @del-rest="editSlotDialogHide"
  532. >
  533. <div class="form-wrapper">
  534. <AutoForm
  535. :model="slotForm"
  536. :items="slotTableColumns"
  537. :select-option-map="selectOptionMap"
  538. label-width="100px"
  539. />
  540. </div>
  541. </Dialog>
  542. <Dialog
  543. :flag="outputDialogVisible"
  544. :type="outputDialogType"
  545. :msg-title="outputDialogTitle"
  546. :del-name="'服务输出' + serviceOutputID"
  547. @submit-form="outputSubmitHandler"
  548. @reset-form="outputDialogHide"
  549. @del-remove="outputSubmitHandler"
  550. @del-rest="outputDialogHide"
  551. >
  552. <div class="form-wrapper">
  553. <AutoForm
  554. :model="outputForm"
  555. :items="outputTableColumns"
  556. :select-option-map="selectOptionMap"
  557. />
  558. </div>
  559. </Dialog>
  560. </div>
  561. </template>
  562. <script setup lang="ts">
  563. import Minheader from '@/components/minheader/index.vue'
  564. import DataTable from '@/components/tableTemp/index.vue'
  565. import Dialog from '@/components/dialog/index.vue'
  566. import AutoForm from '../components/AutoForm.vue'
  567. import {
  568. CommonTableColumn,
  569. SelectOptionQueryResult,
  570. SelectOption,
  571. CommonData,
  572. } from '~/common'
  573. import { ElMessage } from 'element-plus'
  574. import { Query, GeneralDataReception } from '@/api/webApi'
  575. const queryTemplateIDMap = reactive<{
  576. [x: string]: number
  577. }>({})
  578. const selectOptionMap = reactive<{
  579. [id: number]: SelectOption[]
  580. }>({})
  581. const getSelectOptionOfColumn = (columns: CommonTableColumn[]) => {
  582. columns.forEach(async ({ columnName, listqueryTemplateID }) => {
  583. if (listqueryTemplateID !== null && !queryTemplateIDMap[columnName]) {
  584. queryTemplateIDMap[columnName] = listqueryTemplateID
  585. if (!selectOptionMap[listqueryTemplateID]) {
  586. selectOptionMap[listqueryTemplateID] = []
  587. selectOptionMap[listqueryTemplateID] = await getSelectOptions(
  588. listqueryTemplateID
  589. )
  590. }
  591. }
  592. })
  593. }
  594. const getSelectOptions = async (id: number) => {
  595. try {
  596. const {
  597. code,
  598. returnData,
  599. message,
  600. }: SelectOptionQueryResult = await Query({
  601. id,
  602. dataContent: [],
  603. })
  604. if (Number(code) !== 0) {
  605. throw new Error(message ?? '失败')
  606. }
  607. const listValues = returnData.listValues || returnData
  608. const options = listValues.map(({ k, v, setlabel, setvalue }) => ({
  609. k,
  610. v,
  611. setlabel,
  612. setvalue,
  613. [setlabel]: k,
  614. [setvalue]: v,
  615. }))
  616. return options
  617. } catch (error) {
  618. console.error(error)
  619. return []
  620. }
  621. }
  622. const route = useRoute()
  623. const serviceID = Number(route.query.serviceID)
  624. const serviceState = computed(() =>
  625. route.query.runState === '运行' ? '进行中' : '停止'
  626. ) //状态
  627. const serviceForm = reactive({
  628. serviceName: '',
  629. serviceOutputID: null,
  630. serviceType: null,
  631. sourceObjectName: '',
  632. lifeCycleCol: '',
  633. serviceDescribe: '',
  634. threads: null,
  635. isAsynchronous: 1,
  636. datatype: null,
  637. dataSourceID: null,
  638. computingMethod: '',
  639. validationExpression: '',
  640. startTime: null,
  641. stopTime: null,
  642. retryCount: null,
  643. loopCount: null,
  644. frequencyCount: null,
  645. frequencyUnit: null,
  646. logDataSourceID: null,
  647. logList: '',
  648. logDataSourceName: null,
  649. dataSourceName: null,
  650. hasStartTime: null,
  651. hasEndTime: null,
  652. })
  653. const getServiceDetail = async () => {
  654. try {
  655. const {
  656. code,
  657. returnData: { listValues },
  658. message,
  659. } = await Query({
  660. id: DATACONTENT_ID.sysServiceDetail,
  661. dataContent: [serviceID],
  662. })
  663. if (Number(code) !== 0) {
  664. throw new Error(message ?? '失败')
  665. }
  666. if (!listValues.length) {
  667. throw new Error('未查询到服务信息')
  668. }
  669. Object.entries(listValues[0]).forEach(([key, value]) => {
  670. serviceForm[key] = value
  671. })
  672. } catch (error) {
  673. console.error(error)
  674. }
  675. }
  676. onMounted(() => {
  677. getServiceDetail()
  678. })
  679. const serviceSubmitHandler = async () => {
  680. try {
  681. const dataContent = {
  682. serviceID,
  683. ...serviceForm,
  684. event: 2,
  685. }
  686. Object.keys(dataContent).forEach(key => {
  687. if (
  688. ![
  689. 'serviceName',
  690. 'sourceObjectName',
  691. 'lifeCycleCol',
  692. 'serviceDescribe',
  693. 'computingMethod',
  694. 'validationExpression',
  695. 'logList',
  696. ].includes(key) &&
  697. dataContent[key] === ''
  698. ) {
  699. dataContent[key] = null
  700. }
  701. })
  702. const { code, message } = await GeneralDataReception({
  703. serviceId: SERVICE_ID.sysServiceEdit,
  704. dataContent: JSON.stringify(dataContent),
  705. btnAuth: 'service_editor_button',
  706. })
  707. if (Number(code) === 0) {
  708. ElMessage.success(message ?? '成功')
  709. } else {
  710. throw new Error(message ?? '失败')
  711. }
  712. } catch (error) {
  713. console.error(error)
  714. }
  715. }
  716. // 输出-表格
  717. const outputTableColumns = ref<CommonTableColumn[]>([])
  718. const outputTableData = ref<CommonData[]>([])
  719. const getOutputTable = async () => {
  720. try {
  721. const {
  722. code,
  723. returnData: { columnSet, listValues },
  724. message,
  725. } = await Query({
  726. id: DATACONTENT_ID.sysServiceOutTable,
  727. dataContent: [serviceID],
  728. })
  729. if (Number(code) !== 0) {
  730. throw new Error(message ?? '失败')
  731. }
  732. getSelectOptionOfColumn(columnSet)
  733. outputTableColumns.value = columnSet
  734. outputTableData.value = listValues
  735. } catch (error) {
  736. console.error(error)
  737. }
  738. }
  739. onMounted(() => {
  740. getOutputTable()
  741. })
  742. const outputTableButtonGroup = [
  743. {
  744. name: '编辑',
  745. className: 'editBtn',
  746. param: 1,
  747. is: 'service_edit_output_location_button',
  748. },
  749. {
  750. name: '删除',
  751. className: 'delBtn',
  752. param: 2,
  753. is: 'service_delete_output_location_button',
  754. },
  755. ]
  756. const outputTableButtonClickHandler = (
  757. rowIndex: number,
  758. row: CommonData,
  759. param: number
  760. ) => {
  761. switch (param) {
  762. case 1:
  763. outputDialogShow(2, row)
  764. break
  765. case 2:
  766. outputDialogShow(3, row)
  767. break
  768. default:
  769. break
  770. }
  771. }
  772. // 输出-新增/编辑
  773. const outputDialogVisible = ref(false)
  774. const outputDialogType = ref('')
  775. const outputDialogTitle = ref('')
  776. const serviceOutputID = ref<string | number>()
  777. const outputDialogShow = (operate: number = 1, row: CommonData) => {
  778. switch (operate) {
  779. case 1:
  780. outputDialogType.value = 'add'
  781. outputDialogTitle.value = '新增输出'
  782. break
  783. case 2:
  784. outputDialogType.value = 'edit'
  785. outputDialogTitle.value = '编辑输出'
  786. Object.entries(row).forEach(([key, value]) => {
  787. outputForm[key] = value
  788. const column = outputTableColumns.value.find(
  789. column => column.columnName === key
  790. )
  791. if (typeof column?.listqueryTemplateID === 'number') {
  792. const selectOptions = selectOptionMap[column.listqueryTemplateID]
  793. const option = selectOptions.find(option => option.k === value)
  794. if (option) {
  795. outputForm[option.setvalue] = option.v
  796. }
  797. }
  798. })
  799. break
  800. case 3:
  801. outputDialogType.value = 'del'
  802. outputDialogTitle.value = '删除输出'
  803. break
  804. default:
  805. break
  806. }
  807. serviceOutputID.value = (row && row['serviceOutputID']) ?? ''
  808. outputDialogVisible.value = true
  809. }
  810. const outputDialogHide = () => {
  811. outputDialogVisible.value = false
  812. Object.keys(outputForm).forEach(key => {
  813. outputForm[key] = null
  814. })
  815. }
  816. const outputForm = reactive<CommonData>({})
  817. const outputSubmitHandler = async () => {
  818. try {
  819. const dataContent = {
  820. serviceID,
  821. }
  822. switch (outputDialogType.value) {
  823. case 'add':
  824. Object.assign(dataContent, {
  825. event: 1,
  826. ...outputForm,
  827. })
  828. break
  829. case 'edit':
  830. Object.assign(dataContent, {
  831. event: 2,
  832. serviceOutputID: serviceOutputID.value,
  833. ...outputForm,
  834. })
  835. break
  836. case 'delete':
  837. Object.assign(dataContent, {
  838. event: 3,
  839. serviceOutputID: serviceOutputID.value,
  840. })
  841. break
  842. default:
  843. break
  844. }
  845. const { code, message } = await GeneralDataReception({
  846. serviceId: SERVICE_ID.sysServiceOutputEdit,
  847. dataContent: JSON.stringify(dataContent),
  848. })
  849. if (Number(code) === 0) {
  850. ElMessage.success(message ?? '成功')
  851. outputDialogHide()
  852. } else {
  853. throw new Error(message ?? '失败')
  854. }
  855. } catch (error) {
  856. console.error(error)
  857. }
  858. }
  859. // 日志弹框
  860. const logDialogVisible = ref(false)
  861. const logDialogShow = () => {
  862. logDialogVisible.value = true
  863. getToday()
  864. getLogTableData()
  865. }
  866. const logDialogHide = () => {
  867. logDialogVisible.value = false
  868. }
  869. const logStartTime = ref('')
  870. const logEndTime = ref('')
  871. const getToday = () => {
  872. function numberFormat(number) {
  873. const string = '0' + number
  874. return string.slice(-2)
  875. }
  876. const now = new Date()
  877. const year = now.getFullYear()
  878. const month = now.getMonth() + 1
  879. const date = now.getDate()
  880. const today = `${year}-${numberFormat(month)}-${numberFormat(date)}`
  881. logStartTime.value = `${today} 00:00:00`
  882. logEndTime.value = `${today} 23:59:59`
  883. }
  884. const logTimeChangeHandler = () => {
  885. if (!logStartTime.value || !logEndTime.value) {
  886. return
  887. }
  888. const startTime = new Date(logStartTime.value).getTime()
  889. const endTime = new Date(logEndTime.value).getTime()
  890. if (startTime > endTime) {
  891. ElMessage.error('开始时间不能大于结束时间')
  892. logEndTime.value = ''
  893. return
  894. }
  895. if (startTime < endTime - (3 * 24 * 60 * 60 - 1) * 1000) {
  896. ElMessage.error('间隔时间不能大于三天')
  897. logEndTime.value = ''
  898. return
  899. }
  900. resetLogTable()
  901. getLogTableData()
  902. }
  903. const logSearchText = ref('')
  904. const logSearchHandler = () => {
  905. getLogTableData()
  906. }
  907. const logSearchClearHandler = () => {
  908. getLogTableData()
  909. }
  910. const logTableData = ref<CommonData[]>([])
  911. const logTableLoading = ref(false)
  912. const resetLogTable = () => {
  913. logTableData.value = []
  914. }
  915. const getLogTableData = async () => {
  916. try {
  917. logTableLoading.value = true
  918. const {
  919. code,
  920. returnData: { listValues },
  921. } = await Query({
  922. id: DATACONTENT_ID.sysServiceTopologyTable,
  923. dataContent: [serviceID, logStartTime.value, logEndTime.value],
  924. })
  925. if (Number(code) !== 0) {
  926. throw new Error('获取数据失败')
  927. }
  928. logTableData.value = listValues
  929. logTableLoading.value = false
  930. } catch (error) {
  931. console.error(error)
  932. logTableLoading.value = false
  933. }
  934. }
  935. // 选择插槽
  936. const slotDialogVisible = ref(false)
  937. const slotDialogShow = () => {
  938. getSlotTable()
  939. slotDialogVisible.value = true
  940. }
  941. const slotDialogHide = () => {
  942. slotDialogVisible.value = false
  943. }
  944. const slotTableColumns = ref<CommonTableColumn[]>([])
  945. const slotTableData = ref<CommonData[]>([])
  946. const getSlotTable = async () => {
  947. try {
  948. const {
  949. code,
  950. returnData: { columnSet, listValues },
  951. message,
  952. } = await Query({
  953. id: DATACONTENT_ID.sysServiceNodeList,
  954. dataContent: [serviceID],
  955. })
  956. if (Number(code) !== 0) {
  957. throw new Error(message ?? '失败')
  958. }
  959. getSelectOptionOfColumn(columnSet)
  960. slotTableColumns.value = columnSet
  961. slotTableData.value = listValues
  962. } catch (error) {
  963. console.error(error)
  964. }
  965. }
  966. const slotTableButtonGroups = [
  967. {
  968. name: '编辑',
  969. className: 'editBtn',
  970. param: 1,
  971. is: 'machine_editing_button'
  972. },
  973. {
  974. name: '删除',
  975. className: 'delBtn',
  976. param: 2,
  977. is: 'machine_deletion_button'
  978. },
  979. ]
  980. const slotTableButtonClickHandler = (
  981. rowIndex: number,
  982. row: CommonData,
  983. param: number
  984. ) => {
  985. switch (param) {
  986. case 1:
  987. editSlotDialogShow(2, row)
  988. break
  989. case 2:
  990. editSlotDialogShow(3, row)
  991. break
  992. default:
  993. break
  994. }
  995. }
  996. const slotSelectHandler = (selection, row) => {
  997. console.log(selection, row)
  998. }
  999. const slotSubmitHandler = () => {
  1000. slotDialogHide()
  1001. }
  1002. // 插槽-新增/编辑
  1003. const editSlotDialogType = ref('')
  1004. const editSlotDialogTitle = ref('')
  1005. const deployNodeName = ref('')
  1006. const editSlotDialogVisible = ref(false)
  1007. const editSlotDialogShow = (operate: number = 1, row: CommonData) => {
  1008. switch (operate) {
  1009. case 1:
  1010. editSlotDialogType.value = 'add'
  1011. editSlotDialogTitle.value = '新增插槽'
  1012. break
  1013. case 2:
  1014. editSlotDialogType.value = 'edit'
  1015. editSlotDialogTitle.value = '编辑插槽'
  1016. Object.entries(row).forEach(([key, value]) => {
  1017. slotForm[key] = value
  1018. const column = slotTableColumns.value.find(
  1019. column => column.columnName === key
  1020. )
  1021. if (typeof column?.listqueryTemplateID === 'number') {
  1022. const selectOptions = selectOptionMap[column.listqueryTemplateID]
  1023. const option = selectOptions.find(option => option.k === value)
  1024. if (option) {
  1025. slotForm[option.setvalue] = option.v
  1026. }
  1027. }
  1028. })
  1029. break
  1030. case 3:
  1031. editSlotDialogType.value = 'del'
  1032. editSlotDialogTitle.value = '删除插槽'
  1033. break
  1034. default:
  1035. break
  1036. }
  1037. deployNodeName.value = (row && (row['deployNodeName'] as string)) ?? ''
  1038. editSlotDialogVisible.value = true
  1039. }
  1040. const editSlotDialogHide = () => {
  1041. editSlotDialogVisible.value = false
  1042. Object.keys(slotForm).forEach(key => {
  1043. slotForm[key] = null
  1044. })
  1045. }
  1046. const slotForm = reactive<CommonData>({})
  1047. const editSlotSubmitHandler = () => {
  1048. editSlotDialogHide()
  1049. }
  1050. //复制
  1051. const logCopy = index => {
  1052. const ele = document.getElementById('logId' + index)
  1053. const val = ele!.innerText
  1054. try {
  1055. const input = document.createElement('input')
  1056. //将input的值设置为需要复制的内容
  1057. input.value = val
  1058. //添加input标签
  1059. document.body.appendChild(input)
  1060. //选中input标签
  1061. input.select()
  1062. //执行复制
  1063. document.execCommand('copy')
  1064. //移除input标签
  1065. document.body.removeChild(input)
  1066. // this.$message.success("复制成功");
  1067. } catch (e) {
  1068. // this.$message.error("复制失败");
  1069. }
  1070. }
  1071. </script>
  1072. <style lang="scss" scoped>
  1073. .service-edit {
  1074. height: 100%;
  1075. .service-basic-wrapper {
  1076. height: 140px;
  1077. background: #ffffff;
  1078. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  1079. border-radius: 4px;
  1080. margin-bottom: 16px;
  1081. padding: 24px;
  1082. }
  1083. .service-config-wrapper {
  1084. height: 196px;
  1085. background: #ffffff;
  1086. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  1087. border-radius: 4px;
  1088. margin-bottom: 16px;
  1089. padding: 24px;
  1090. }
  1091. .service-receive-wrapper {
  1092. height: 192px;
  1093. background: #ffffff;
  1094. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  1095. border-radius: 4px;
  1096. margin-bottom: 16px;
  1097. padding: 24px;
  1098. }
  1099. .service-output-wrapper {
  1100. height: 250px;
  1101. background: #ffffff;
  1102. box-shadow: 0px 3px 3px 0px rgba(0, 0, 0, 0.1);
  1103. border-radius: 4px;
  1104. padding: 24px;
  1105. }
  1106. .form-wrapper {
  1107. width: 100%;
  1108. .w100 {
  1109. width: 100%;
  1110. }
  1111. .w50 {
  1112. width: 50%;
  1113. }
  1114. .w40 {
  1115. width: 40%;
  1116. }
  1117. .w20 {
  1118. width: 20%;
  1119. }
  1120. .pd30 {
  1121. padding: 0 30px 0 0;
  1122. }
  1123. }
  1124. }
  1125. .service-state {
  1126. font-size: 20px;
  1127. font-family: Microsoft YaHei;
  1128. font-weight: bold;
  1129. color: #53b074;
  1130. }
  1131. .app-containers {
  1132. height: 170px;
  1133. }
  1134. .interfaceLog {
  1135. padding: 0 24px 24px 24px;
  1136. }
  1137. .logcont {
  1138. padding: 0 24px 0px 24px;
  1139. }
  1140. :deep
  1141. .slot-table
  1142. .el-table__header
  1143. .el-table__cell.hide-header-check:first-child
  1144. .el-checkbox {
  1145. display: none;
  1146. }
  1147. </style>