index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10" class="mb8">
  4. <el-col :span="18">
  5. <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="0" @submit.native.prevent>
  6. <el-form-item label="" prop="appName" style="margin-right:10px">
  7. <el-input
  8. v-model="queryParams.appName"
  9. placeholder="请输入应用名称"
  10. clearable
  11. @keyup.enter="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item>
  15. <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
  16. <el-button icon="Refresh" @click="resetQuery">重置</el-button>
  17. </el-form-item>
  18. </el-form>
  19. </el-col>
  20. <el-col :span="6" style="text-align: right">
  21. <el-button
  22. type="primary"
  23. plain
  24. icon="Plus"
  25. @click="handleAdd"
  26. v-hasPermi="['obj:app:add']"
  27. >新增</el-button>
  28. <el-button type="info" plain icon="Download">下载agent</el-button>
  29. </el-col>
  30. </el-row>
  31. <el-table v-loading="loading" :data="appList" border>
  32. <el-table-column label="应用ID" align="center" prop="appId" width="80" />
  33. <el-table-column label="应用名称" align="left" prop="appName" />
  34. <el-table-column label="应用编码" align="left" prop="appCode" width="120" />
  35. <el-table-column label="IP地址" align="left" width="160">
  36. <template #default="scope">
  37. {{scope.row.appAddr}}:{{scope.row.appPort}}
  38. </template>
  39. </el-table-column>
  40. <el-table-column label="链路分析启动参数">
  41. <template #default="scope">
  42. <div v-html="outConfigKey(scope.row)" width="300"/>
  43. </template>
  44. </el-table-column>
  45. <!-- <el-table-column label="创建时间" align="center" prop="createTime" width="160">-->
  46. <!-- <template #default="scope">-->
  47. <!-- <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{mi}:{s}') }}</span>-->
  48. <!-- </template>-->
  49. <!-- </el-table-column>-->
  50. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
  51. <template #default="scope">
  52. <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['obj:app:edit']">修改</el-button>
  53. <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['obj:app:remove']">删除</el-button>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <pagination
  58. v-show="total>0"
  59. :total="total"
  60. v-model:page="queryParams.pageNum"
  61. v-model:limit="queryParams.pageSize"
  62. @pagination="getList"
  63. />
  64. <!-- 添加或修改应用程序管理对话框 -->
  65. <el-dialog :title="title" v-model="open" width="500px" append-to-body>
  66. <el-form ref="appRef" :model="form" :rules="rules" label-width="80px">
  67. <el-form-item label="应用名称" prop="appName">
  68. <el-input v-model="form.appName" placeholder="请输入应用名称" />
  69. </el-form-item>
  70. <el-form-item label="应用编码" prop="appCode">
  71. <el-input v-model="form.appCode" placeholder="请输入应用编码" />
  72. </el-form-item>
  73. <el-form-item label="IP地址" prop="appAddr">
  74. <el-input v-model="form.appAddr" placeholder="请输入IP地址" />
  75. </el-form-item>
  76. <el-form-item label="端口号" prop="appPort">
  77. <el-input v-model="form.appPort" placeholder="请输入端口号" />
  78. </el-form-item>
  79. <el-form-item label="备注">
  80. <el-input v-model="form.remark" type="textarea" placeholder="请输入备注" :autosize="{maxRows:6,minRows:3}" maxlength="300" show-word-limit/>
  81. </el-form-item>
  82. </el-form>
  83. <template #footer>
  84. <div class="dialog-footer">
  85. <el-button type="primary" @click="submitForm">确 定</el-button>
  86. <el-button @click="cancel">取 消</el-button>
  87. </div>
  88. </template>
  89. </el-dialog>
  90. </div>
  91. </template>
  92. <script setup name="App">
  93. import { listApp, getApp, delApp, addApp, updateApp } from "@/api/obj/app";
  94. const { proxy } = getCurrentInstance();
  95. const appList = ref([]);
  96. const open = ref(false);
  97. const loading = ref(true);
  98. const showSearch = ref(true);
  99. const ids = ref([]);
  100. const single = ref(true);
  101. const multiple = ref(true);
  102. const total = ref(0);
  103. const title = ref("");
  104. const daterangeCreateTime = ref([]);
  105. const daterangeUpdateTime = ref([]);
  106. const configKey=ref("")
  107. const data = reactive({
  108. form: {},
  109. queryParams: {
  110. pageNum: 1,
  111. pageSize: 10,
  112. appName: null,
  113. appCode: null,
  114. appAddr: null,
  115. appPort: null,
  116. createBy: null,
  117. createTime: null,
  118. updateBy: null,
  119. updateTime: null,
  120. remark: null
  121. },
  122. rules: {
  123. appName: [
  124. { required: true, message: "应用名称不能为空", trigger: "blur" }
  125. ],
  126. appCode: [
  127. { required: true, message: "应用编码不能为空", trigger: "blur" }
  128. ],
  129. appAddr: [
  130. { required: true, message: "IP地址不能为空", trigger: "blur" }
  131. ],
  132. appPort: [
  133. { required: true, message: "端口号不能为空", trigger: "blur" }
  134. ],
  135. }
  136. });
  137. const { queryParams, form, rules } = toRefs(data);
  138. /** 查询应用程序管理列表 */
  139. function getList() {
  140. loading.value = true;
  141. queryParams.value.params = {};
  142. if (null != daterangeCreateTime && '' != daterangeCreateTime) {
  143. queryParams.value.params["beginCreateTime"] = daterangeCreateTime.value[0];
  144. queryParams.value.params["endCreateTime"] = daterangeCreateTime.value[1];
  145. }
  146. if (null != daterangeUpdateTime && '' != daterangeUpdateTime) {
  147. queryParams.value.params["beginUpdateTime"] = daterangeUpdateTime.value[0];
  148. queryParams.value.params["endUpdateTime"] = daterangeUpdateTime.value[1];
  149. }
  150. listApp(queryParams.value).then(response => {
  151. appList.value = response.rows;
  152. total.value = response.total;
  153. loading.value = false;
  154. });
  155. }
  156. // 取消按钮
  157. function cancel() {
  158. open.value = false;
  159. reset();
  160. }
  161. // 表单重置
  162. function reset() {
  163. form.value = {
  164. appId: null,
  165. appName: null,
  166. appCode: null,
  167. appAddr: null,
  168. appPort: null,
  169. createBy: null,
  170. createTime: null,
  171. updateBy: null,
  172. updateTime: null,
  173. remark: null
  174. };
  175. proxy.resetForm("appRef");
  176. }
  177. /** 搜索按钮操作 */
  178. function handleQuery() {
  179. queryParams.value.pageNum = 1;
  180. getList();
  181. }
  182. /** 重置按钮操作 */
  183. function resetQuery() {
  184. daterangeCreateTime.value = [];
  185. daterangeUpdateTime.value = [];
  186. proxy.resetForm("queryRef");
  187. handleQuery();
  188. }
  189. // 多选框选中数据
  190. function handleSelectionChange(selection) {
  191. ids.value = selection.map(item => item.appId);
  192. single.value = selection.length != 1;
  193. multiple.value = !selection.length;
  194. }
  195. /**获取配置**/
  196. /** 新增按钮操作 */
  197. function handleAdd() {
  198. reset();
  199. open.value = true;
  200. title.value = "添加应用程序管理";
  201. }
  202. /** 修改按钮操作 */
  203. function handleUpdate(row) {
  204. reset();
  205. const _appId = row.appId || ids.value
  206. getApp(_appId).then(response => {
  207. form.value = response.data;
  208. open.value = true;
  209. title.value = "修改应用程序管理";
  210. });
  211. }
  212. /** 提交按钮 */
  213. function submitForm() {
  214. proxy.$refs["appRef"].validate(valid => {
  215. if (valid) {
  216. if (form.value.appId != null) {
  217. updateApp(form.value).then(response => {
  218. proxy.$modal.msgSuccess("修改成功");
  219. open.value = false;
  220. getList();
  221. });
  222. } else {
  223. addApp(form.value).then(response => {
  224. proxy.$modal.msgSuccess("新增成功");
  225. open.value = false;
  226. getList();
  227. });
  228. }
  229. }
  230. });
  231. }
  232. /** 删除按钮操作 */
  233. function handleDelete(row) {
  234. const _appIds = row.appId || ids.value;
  235. proxy.$modal.confirm('是否确认删除应用程序管理编号为"' + _appIds + '"的数据项?').then(function() {
  236. return delApp(_appIds);
  237. }).then(() => {
  238. getList();
  239. proxy.$modal.msgSuccess("删除成功");
  240. }).catch(() => {});
  241. }
  242. /** 导出按钮操作 */
  243. function handleExport() {
  244. proxy.download('obj/app/export', {
  245. ...queryParams.value
  246. }, `app_${new Date().getTime()}.xlsx`)
  247. }
  248. function outConfigKey(item){
  249. return configKey.value.replace(/\$\{code}/g, item.appCode);
  250. }
  251. function handleConfigKey() {
  252. proxy.getConfigKey("pp.start").then(response => {
  253. configKey.value = response.msg.replace(/\n/g, '<br/>')
  254. })
  255. }
  256. getList();
  257. handleConfigKey();
  258. </script>