detail.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <div class="system-dic-container">
  3. <div class="content">
  4. <div class="cont_box">
  5. <div class="title">数据源名称:{{ detail.name }}</div>
  6. <div class="pro-status"><span :class="developer_status == 1 ? 'on' : 'off'"></span>{{ developer_status == 1 ? '已发布' : '未发布' }}</div>
  7. <div class="pro-option" @click="CkOption">{{ developer_status == 1 ? '停用' : '发布' }}</div>
  8. </div>
  9. </div>
  10. <div class="content-box">
  11. <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
  12. <el-tab-pane label="数据源信息" name="1">
  13. <el-form size="default" label-width="110px" :inline="true">
  14. <el-divider content-position="left">基本信息</el-divider>
  15. <el-form-item label="数据源标识:">
  16. {{ detail.key }}
  17. </el-form-item>
  18. <el-form-item label="数据源名称:">
  19. {{ detail.name }}
  20. </el-form-item>
  21. <el-form-item label="数据源描述:">
  22. {{ detail.description }}
  23. </el-form-item>
  24. <el-form-item label="数据来源:">
  25. <span v-if="detail.from == 1">api导入</span>
  26. <span v-if="detail.from == 2">数据库</span>
  27. <span v-if="detail.from == 3">文件</span>
  28. </el-form-item>
  29. <el-divider content-position="left">规则表达式</el-divider>
  30. <div v-for="(item, index) in rule" :key="index">
  31. <el-form-item label="表达式:">
  32. {{ item.expression }}
  33. </el-form-item>
  34. <el-form-item label="参数:"> {{ item.params.name }}~ {{ item.params.value }} </el-form-item>
  35. <el-divider content-position="left">数据源配置</el-divider>
  36. <el-form-item label="请求方法:" prop="method">
  37. {{ config.method }}
  38. </el-form-item>
  39. <el-form-item label="请求地址:" prop="method">
  40. {{ config.url }}
  41. </el-form-item>
  42. <el-form-item label="更新时间:" prop="method">
  43. {{ config.interval }}
  44. {{ config.intervalUnit }}
  45. </el-form-item>
  46. <el-divider content-position="left">请求参数</el-divider>
  47. <div class="content-f" v-for="(item, index) in requestParams" :key="index">
  48. <el-form-item label="参数类型:">
  49. {{ item.type }}
  50. </el-form-item>
  51. <el-form-item label="参数标题:">
  52. {{ item.name }}
  53. </el-form-item>
  54. <el-form-item label="参数名:">
  55. {{ item.key }}
  56. </el-form-item>
  57. <el-form-item label="参数值:">
  58. {{ item.value }}
  59. </el-form-item>
  60. </div>
  61. </div>
  62. </el-form>
  63. </el-tab-pane>
  64. <el-tab-pane label="数据节点" name="2">
  65. <div class="wu-box">
  66. <div class="wu-title">
  67. <div class="title">数据节点</div>
  68. <div><el-button type="primary" @click="onOpenEdit()">添加</el-button></div>
  69. </div>
  70. <el-table :data="tableData.data" style="width: 100%">
  71. <el-table-column label="ID" align="center" prop="nodeId" width="80" />
  72. <el-table-column label="数据标识" prop="key" :show-overflow-tooltip="true" />
  73. <el-table-column label="数据名称" prop="name" :show-overflow-tooltip="true" />
  74. <el-table-column label="数据类型" prop="dataType" :show-overflow-tooltip="true" />
  75. <el-table-column label="数据取值项" prop="value" :show-overflow-tooltip="true" />
  76. <el-table-column prop="createdAt" label="创建时间" align="center" width="180"></el-table-column>
  77. <el-table-column label="操作" width="200" align="center" fixed="right">
  78. <template #default="scope">
  79. <el-button size="small" text type="warning" @click="onOpenEdit1(scope.row)">修改</el-button>
  80. <el-button size="small" text type="danger" @click="onRowDel(scope.row)">删除</el-button>
  81. </template>
  82. </el-table-column>
  83. </el-table>
  84. <pagination
  85. v-show="tableData.total > 0"
  86. :total="tableData.total"
  87. v-model:page="tableData.param.pageNum"
  88. v-model:limit="tableData.param.pageSize"
  89. @pagination="typeList"
  90. />
  91. </div>
  92. </el-tab-pane>
  93. </el-tabs>
  94. </div>
  95. <EditDic ref="editDicRef" @typeList="typeList" />
  96. </div>
  97. </template>
  98. <script lang="ts">
  99. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
  100. import { Delete, Edit, Search, Share, Upload } from '@element-plus/icons-vue';
  101. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  102. import { useRoute } from 'vue-router';
  103. import EditDic from './component/editNode.vue';
  104. import api from '/@/api/datahub';
  105. interface TableDataState {
  106. ids: number[];
  107. tableData: {
  108. data: [];
  109. total: number;
  110. loading: boolean;
  111. param: {
  112. pageNum: number;
  113. pageSize: number;
  114. name: string;
  115. deviceType: string;
  116. status: string;
  117. dateRange: string[];
  118. };
  119. };
  120. }
  121. export default defineComponent({
  122. name: 'dataDetail',
  123. components: { EditDic },
  124. setup(prop, context) {
  125. const editDicRef = ref();
  126. const route = useRoute();
  127. const state = reactive<TableDataState>({
  128. config: {},
  129. ruledata: [
  130. {
  131. expression: '',
  132. params: {},
  133. },
  134. ],
  135. rule: [
  136. {
  137. expression: '',
  138. params: {
  139. name: '',
  140. value: '',
  141. },
  142. },
  143. ],
  144. requestParams: [
  145. {
  146. type: '',
  147. key: '',
  148. name: '',
  149. value: '',
  150. },
  151. ],
  152. isShowDialog: false,
  153. detail: [],
  154. activeName: '1',
  155. developer_status: 0,
  156. tableData: {
  157. data: [],
  158. total: 0,
  159. loading: false,
  160. param: {
  161. pageNum: 1,
  162. pageSize: 10,
  163. sourceId: route.params && route.params.sourceId,
  164. status: '',
  165. dateRange: [],
  166. },
  167. },
  168. });
  169. onMounted(() => {
  170. const ids = route.params && route.params.sourceId;
  171. api.common.detail(ids).then((res: any) => {
  172. state.detail = res.data;
  173. state.developer_status = res.data.status;
  174. state.config = res.data.apiConfig;
  175. state.requestParams = res.data.apiConfig.requestParams;
  176. res.data.sourceRule.forEach((item, index) => {
  177. state.rule[index].expression = item.expression;
  178. state.rule[index].params.name = Object.keys(item.params);
  179. state.rule[index].params.value = item.params[Object.keys(item.params)];
  180. });
  181. });
  182. typeList();
  183. });
  184. const typeList = () => {
  185. api.node.getList(state.tableData.param).then((res: any) => {
  186. state.tableData.data = res.list;
  187. state.tableData.total = res.Total;
  188. });
  189. };
  190. const CkOption = () => {
  191. if (state.developer_status == 1) {
  192. api.common.undeploy({ sourceId: route.params.sourceId }).then((res: any) => {
  193. ElMessage.success('操作成功');
  194. state.developer_status = 0;
  195. });
  196. } else {
  197. api.common.deploy({ sourceId: route.params.sourceId }).then((res: any) => {
  198. ElMessage.success('操作成功');
  199. state.developer_status = 1;
  200. });
  201. }
  202. };
  203. const handleClick = (tab: TabsPaneContext, event: Event) => {
  204. console.log(tab, event);
  205. };
  206. const onRowDel = (row: TableDataRow) => {
  207. let msg = '你确定要删除所选数据?';
  208. let ids: number[] = [];
  209. if (row) {
  210. msg = `此操作将永久删除数据节点:“${row.name}”,是否继续?`;
  211. ids = row.nodeId;
  212. } else {
  213. ids = state.ids;
  214. }
  215. if (ids.length === 0) {
  216. ElMessage.error('请选择要删除的数据。');
  217. return;
  218. }
  219. ElMessageBox.confirm(msg, '提示', {
  220. confirmButtonText: '确认',
  221. cancelButtonText: '取消',
  222. type: 'warning',
  223. })
  224. .then(() => {
  225. api.node.delete(ids).then(() => {
  226. ElMessage.success('删除成功');
  227. typeList();
  228. });
  229. })
  230. .catch(() => {});
  231. };
  232. // 打开修改数据源弹窗
  233. const onOpenEdit = () => {
  234. editDicRef.value.openDialog({ sourceId: route.params.sourceId, nodeId: 0, isPk: 0 });
  235. };
  236. const onOpenEdit1 = (row: TableDataRow) => {
  237. editDicRef.value.openDialog(row);
  238. };
  239. return {
  240. Edit,
  241. editDicRef,
  242. typeList,
  243. onRowDel,
  244. onOpenEdit,
  245. onOpenEdit1,
  246. handleClick,
  247. CkOption,
  248. ...toRefs(state),
  249. };
  250. },
  251. });
  252. </script>
  253. <style>
  254. .content {
  255. background: #fff;
  256. width: 100%;
  257. padding: 20px;
  258. }
  259. .content-box {
  260. background: #fff;
  261. width: 100%;
  262. padding: 20px;
  263. margin-top: 20px;
  264. }
  265. .cont_box {
  266. display: flex;
  267. }
  268. .cont_box .title {
  269. font-size: 24px;
  270. }
  271. .cont_box .pro-status {
  272. line-height: 40px;
  273. margin-left: 30px;
  274. }
  275. .cont_box .pro-status .on {
  276. background: #52c41a;
  277. }
  278. .cont_box .pro-status .off {
  279. background: #c41a1a;
  280. }
  281. .cont_box .pro-status span {
  282. position: relative;
  283. top: -1px;
  284. display: inline-block;
  285. width: 6px;
  286. height: 6px;
  287. vertical-align: middle;
  288. border-radius: 50%;
  289. margin-right: 5px;
  290. }
  291. .cont_box .pro-option {
  292. line-height: 40px;
  293. margin-left: 10px;
  294. color: #1890ff;
  295. cursor: pointer;
  296. }
  297. .content-box .pro-box {
  298. display: flex;
  299. padding: 10px;
  300. }
  301. .content-box .pro-box .protitle {
  302. font-size: 18px;
  303. font-weight: bold;
  304. line-height: 35px;
  305. }
  306. .content-box .pro-box .buttonedit {
  307. border: 0px;
  308. color: #1890ff;
  309. }
  310. table {
  311. border-collapse: collapse;
  312. text-indent: initial;
  313. border-spacing: 2px;
  314. }
  315. tbody {
  316. box-sizing: border-box;
  317. display: table-row-group;
  318. vertical-align: middle;
  319. border-color: inherit;
  320. }
  321. tr {
  322. display: table-row;
  323. vertical-align: inherit;
  324. border-color: inherit;
  325. }
  326. .ant-descriptions-view {
  327. width: 100%;
  328. overflow: hidden;
  329. border-radius: 4px;
  330. }
  331. .ant-descriptions-view {
  332. border: 1px solid #e8e8e8;
  333. }
  334. .ant-descriptions-view table {
  335. width: 100%;
  336. table-layout: fixed;
  337. }
  338. .ant-descriptions-view > table {
  339. table-layout: auto;
  340. }
  341. .ant-descriptions-row {
  342. border-bottom: 1px solid #e8e8e8;
  343. }
  344. .ant-descriptions-item-label {
  345. color: rgba(0, 0, 0, 0.85);
  346. font-weight: 400;
  347. font-size: 14px;
  348. line-height: 1.5;
  349. }
  350. .ant-descriptions-item-label {
  351. padding: 16px 24px;
  352. border-right: 1px solid #e8e8e8;
  353. }
  354. .ant-descriptions-item-label {
  355. background-color: #fafafa;
  356. }
  357. .ant-descriptions-item-content {
  358. padding: 16px 24px;
  359. border-right: 1px solid #e8e8e8;
  360. display: table-cell;
  361. color: rgba(0, 0, 0, 0.65);
  362. font-size: 14px;
  363. line-height: 1.5;
  364. }
  365. .wu-box {
  366. border: #e8e8e8 solid 1px;
  367. padding: 20px;
  368. width: 100%;
  369. }
  370. .wu-box .wu-title {
  371. display: flex;
  372. flex-direction: row;
  373. justify-content: space-between;
  374. padding: 20px;
  375. border-bottom: #e8e8e8 1px solid;
  376. }
  377. .wu-box .wu-title .title {
  378. font-size: 18px;
  379. }
  380. </style>