detail.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <template>
  2. <div class="system-dic-container">
  3. <div class="content">
  4. <div class="cont_box">
  5. <div class="title">模型标识:{{ detail.key }}</div>
  6. <div class="title" style="margin-left: 20px">模型表名:{{ detail.name }}</div>
  7. <div class="pro-status"><span :class="developer_status == 1 ? 'on' : 'off'"></span>{{ developer_status == 1 ? '已发布' : '未发布' }}</div>
  8. <div class="pro-option" v-auth="'startOrStop'" @click="CkOption">{{ developer_status == 1 ? '停用' : '发布' }}</div>
  9. </div>
  10. </div>
  11. <div class="content-box">
  12. <div class="wu-box">
  13. <div class="system-user-search mb15">
  14. <el-form :model="tableData.param" ref="queryRef" inline label-width="130px">
  15. <el-form-item label="字段标题" prop="name">
  16. <el-input v-model="tableData.param.name" placeholder="请输入字段标题" clearable style="width: 240px" @keyup.enter.native="typeList" />
  17. </el-form-item>
  18. <el-form-item label="字段名称" prop="key">
  19. <el-input v-model="tableData.param.key" placeholder="请输入字段名称" clearable style="width: 240px" @keyup.enter.native="typeList" />
  20. </el-form-item>
  21. <el-form-item>
  22. <el-button type="primary" class="ml10" @click="typeList">
  23. <el-icon>
  24. <ele-Search />
  25. </el-icon>
  26. 查询
  27. </el-button>
  28. <el-button @click="resetQuery()">
  29. <el-icon>
  30. <ele-Refresh />
  31. </el-icon>
  32. 重置
  33. </el-button>
  34. <el-button type="success" class="ml10" @click="onOpenAdd" v-auth="'add'" v-if="developer_status == 0">
  35. <el-icon>
  36. <ele-FolderAdd />
  37. </el-icon>
  38. 新增字段节点
  39. </el-button>
  40. <!-- <el-button type="danger" class="ml10" @click="onRowDel(null)">
  41. <el-icon>
  42. <ele-Delete />
  43. </el-icon>
  44. 删除
  45. </el-button> -->
  46. </el-form-item>
  47. </el-form>
  48. </div>
  49. <el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading">
  50. <el-table-column label="ID" align="center" prop="id" width="100" v-col="'id'" />
  51. <el-table-column label="字段名称" prop="key" width="120" show-overflow-tooltip v-col="'key'" />
  52. <el-table-column label="字段标题" prop="name" width="120" show-overflow-tooltip v-col="'name'" />
  53. <el-table-column label="类型" prop="dataType" width="85" show-overflow-tooltip v-col="'dataType'" />
  54. <el-table-column label="数据源名称" align="center" v-col="'from'">
  55. <template #default="scope">
  56. <span v-if="scope.row.from == 2">{{ scope.row.source.name }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="默认值" prop="default" width="80" show-overflow-tooltip v-col="'default'" />
  60. <el-table-column label="备注说明" prop="desc" width="100" show-overflow-tooltip v-col="'value'" />
  61. <el-table-column prop="createdAt" label="创建时间" align="center" width="160" v-col="'createdAt'"></el-table-column>
  62. <el-table-column label="操作" width="100" align="center" fixed="right">
  63. <template #default="scope">
  64. <el-button size="small" text type="warning" @click="onOpenEdit(scope.row)" v-if="developer_status == 0" v-auth="'edit'">修改</el-button>
  65. <el-button size="small" text type="danger" @click="onRowDel(scope.row)" v-if="developer_status == 0" v-auth="'del'">删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!-- <pagination
  70. v-show="tableData.data.length > 0"
  71. :total="tableData.total"
  72. v-model:page="tableData.param.pageNum"
  73. v-model:limit="tableData.param.pageSize"
  74. @pagination="typeList"
  75. /> -->
  76. </div>
  77. </div>
  78. <EditDic ref="editDicRef" @typeList="typeList" />
  79. <RelationDic ref="relationRef" @typeList="typeList" />
  80. </div>
  81. </template>
  82. <script lang="ts">
  83. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
  84. import { Edit } from '@element-plus/icons-vue';
  85. import { ElMessageBox, ElMessage } from 'element-plus';
  86. import { useRoute } from 'vue-router';
  87. import EditDic from './component/editNode.vue';
  88. import RelationDic from './component/relation.vue';
  89. import api from '/@/api/datahub';
  90. export default defineComponent({
  91. name: 'dataDetail',
  92. components: { EditDic, RelationDic },
  93. setup(prop, context) {
  94. const editDicRef = ref();
  95. const relationRef = ref();
  96. const route = useRoute();
  97. const state = reactive<any>({
  98. detail: [],
  99. developer_status: 0,
  100. tableData: {
  101. data: [],
  102. total: 0,
  103. loading: false,
  104. param: {
  105. pageNum: 1,
  106. pageSize: 10,
  107. tid: route.params.id as string,
  108. status: '',
  109. key: '',
  110. name: '',
  111. },
  112. },
  113. });
  114. onMounted(() => {
  115. const ids = route.params?.id as string;
  116. api.template.detail(ids).then((res: any) => {
  117. state.detail = res.data;
  118. state.developer_status = res.data.status
  119. });
  120. typeList();
  121. });
  122. const typeList = () => {
  123. state.tableData.loading = true;
  124. api.tnode.getList(state.tableData.param).then((res: any) => {
  125. state.tableData.data = res.list;
  126. //state.tableData.total = res.Total;
  127. }).finally(() => (state.tableData.loading = false));
  128. };
  129. const resetQuery = () => {
  130. state.tableData.param.key = ''
  131. state.tableData.param.name = ''
  132. typeList();
  133. };
  134. const handleClick = (tab: TabsPaneContext, event: Event) => {
  135. };
  136. const onRowDel = (row: TableDataRow) => {
  137. let msg = '你确定要删除所选数据?';
  138. let ids: number[] = [];
  139. if (row) {
  140. msg = `此操作将永久删除数据节点:“${row.name}”,是否继续?`;
  141. ids = row.id;
  142. } else {
  143. ids = state.ids;
  144. }
  145. if (ids.length === 0) {
  146. ElMessage.error('请选择要删除的数据。');
  147. return;
  148. }
  149. ElMessageBox.confirm(msg, '提示', {
  150. confirmButtonText: '确认',
  151. cancelButtonText: '取消',
  152. type: 'warning',
  153. })
  154. .then(() => {
  155. api.tnode.delete(ids).then(() => {
  156. ElMessage.success('删除成功');
  157. typeList();
  158. });
  159. })
  160. .catch(() => { });
  161. };
  162. // 打开修改数据源弹窗
  163. const onOpenEdit = (row: TableDataRow) => {
  164. editDicRef.value.openDialog(row);
  165. };
  166. const onOpenAdd = () => {
  167. editDicRef.value.openDialog({ tid: route.params.id, id: 0, from: 1, isSorting: 0, isDesc: 1 });
  168. };
  169. const CkOption = () => {
  170. //检测是否需要设置关联
  171. api.template.relation_check(route.params.id).then((res: any) => {
  172. if (res.yes && state.developer_status == 0) {
  173. let ids = {
  174. id: route.params.id,
  175. }
  176. relationRef.value.openDialog(ids);
  177. } else {
  178. if (state.developer_status == 1) {
  179. api.tnode.undeploy({ id: route.params.id }).then((res: any) => {
  180. ElMessage.success('操作成功');
  181. state.developer_status = 0;
  182. });
  183. } else {
  184. api.tnode.deploy({ id: route.params.id }).then((res: any) => {
  185. ElMessage.success('操作成功');
  186. state.developer_status = 1;
  187. });
  188. }
  189. }
  190. });
  191. };
  192. return {
  193. Edit,
  194. CkOption,
  195. relationRef,
  196. editDicRef,
  197. onOpenAdd,
  198. resetQuery,
  199. typeList,
  200. onRowDel,
  201. onOpenEdit,
  202. handleClick,
  203. ...toRefs(state),
  204. };
  205. },
  206. });
  207. </script>
  208. <style scoped>
  209. .content {
  210. background: #fff;
  211. width: 100%;
  212. padding: 20px;
  213. }
  214. .content-box {
  215. background: #fff;
  216. width: 100%;
  217. padding: 20px;
  218. margin-top: 20px;
  219. }
  220. .cont_box {
  221. display: flex;
  222. }
  223. .cont_box .title {
  224. font-size: 18px;
  225. }
  226. .cont_box .pro-status {
  227. line-height: 30px;
  228. margin-left: 30px;
  229. }
  230. .cont_box .pro-status .on {
  231. background: #52c41a;
  232. }
  233. .cont_box .pro-status .off {
  234. background: #c41a1a;
  235. }
  236. .cont_box .pro-status span {
  237. position: relative;
  238. top: -1px;
  239. display: inline-block;
  240. width: 6px;
  241. height: 6px;
  242. vertical-align: middle;
  243. border-radius: 50%;
  244. margin-right: 5px;
  245. }
  246. .cont_box .pro-option {
  247. line-height: 30px;
  248. margin-left: 10px;
  249. color: #1890ff;
  250. cursor: pointer;
  251. }
  252. .content-box .pro-box {
  253. display: flex;
  254. padding: 10px;
  255. }
  256. .content-box .pro-box .protitle {
  257. font-size: 18px;
  258. font-weight: bold;
  259. line-height: 35px;
  260. }
  261. .content-box .pro-box .buttonedit {
  262. border: 0px;
  263. color: #1890ff;
  264. }
  265. </style>