detail.vue 7.3 KB

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