calculationIndicator.vue 8.1 KB

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