index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form
  5. v-show="showSearch"
  6. ref="queryForm"
  7. :model="queryParams"
  8. size="small"
  9. :inline="true"
  10. label-width="68px"
  11. >
  12. <el-form-item label="查询名称" prop="name">
  13. <el-input
  14. v-model="queryParams.name"
  15. placeholder="请输入查询名称"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item label="查询状态" prop="status">
  21. <DictSelect
  22. v-model="queryParams.status"
  23. placeholder="请选择查询状态"
  24. dict-type="COMMON_STATUS"
  25. />
  26. </el-form-item>
  27. <el-form-item>
  28. <el-button type="primary" icon="el-icon-search" @click="handleQuery"
  29. >搜索</el-button
  30. >
  31. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  32. </el-form-item>
  33. </el-form>
  34. <!-- 操作工具栏 -->
  35. <el-row :gutter="10" class="mb8">
  36. <el-col :span="1.5">
  37. <el-button
  38. v-hasPermi="['infra:query-manage:create']"
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="openForm(undefined)"
  44. >新增</el-button
  45. >
  46. </el-col>
  47. <!-- <el-col :span="1.5">
  48. <el-button
  49. type="warning"
  50. plain
  51. icon="el-icon-download"
  52. size="mini"
  53. @click="handleExport"
  54. :loading="exportLoading"
  55. v-hasPermi="['infra:query-manage:export']"
  56. >导出全部</el-button
  57. >
  58. </el-col> -->
  59. <el-col :span="1.5">
  60. <el-button
  61. type="info"
  62. plain
  63. icon="el-icon-sort"
  64. size="mini"
  65. @click="toggleExpandAll"
  66. >展开/折叠</el-button
  67. >
  68. </el-col>
  69. <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
  70. </el-row>
  71. <el-table
  72. v-if="refreshTable"
  73. v-loading="loading"
  74. :data="list"
  75. row-key="id"
  76. border
  77. :default-expand-all="isExpandAll"
  78. :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
  79. >
  80. <!-- <el-table-column label="主键id" align="center" prop="id" /> -->
  81. <el-table-column label="查询编码" align="center" prop="code" />
  82. <el-table-column label="查询名称" align="center" prop="name">
  83. <!-- -->
  84. <template #default="{ row }">
  85. <span v-if="row.parentId == 0 || row.status == 1">{{
  86. row.name
  87. }}</span>
  88. <el-link v-else type="primary" @click="handleToQuery(row.id)">{{
  89. row.name
  90. }}</el-link>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="显示顺序" align="center" prop="sort" />
  94. <el-table-column label="查询状态" align="center" prop="status">
  95. <template #default="{ row }">
  96. <dict-tag type="common_status" :value="row.status" />
  97. </template>
  98. </el-table-column>
  99. <el-table-column
  100. label="创建时间"
  101. align="center"
  102. prop="createTime"
  103. width="180"
  104. >
  105. <template v-slot="scope">
  106. <span>{{ parseTime(scope.row.createTime) }}</span>
  107. </template>
  108. </el-table-column>
  109. <el-table-column
  110. label="操作"
  111. align="center"
  112. class-name="small-padding fixed-width"
  113. >
  114. <template v-slot="scope">
  115. <el-button
  116. v-if="scope.row.parentId == 0"
  117. type="text"
  118. icon="el-icon-plus"
  119. size="mini"
  120. @click="handleAdd(scope.row)"
  121. >新增</el-button
  122. >
  123. <el-button
  124. v-hasPermi="['infra:query-manage:update']"
  125. size="mini"
  126. type="text"
  127. icon="el-icon-edit"
  128. @click="openForm(scope.row.id)"
  129. >修改</el-button
  130. >
  131. <el-button
  132. v-hasPermi="['infra:query-manage:delete']"
  133. class="text-danger"
  134. size="mini"
  135. type="text"
  136. icon="el-icon-delete"
  137. @click="handleDelete(scope.row)"
  138. >删除</el-button
  139. >
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <!-- 对话框(添加 / 修改) -->
  144. <QueryManageForm ref="formRef" @success="getList" />
  145. </div>
  146. </template>
  147. <script>
  148. import * as QueryManageApi from "@/api/mes/queryManage/index";
  149. import QueryManageForm from "./QueryManageForm.vue";
  150. export default {
  151. name: "QueryManage",
  152. components: {
  153. QueryManageForm,
  154. },
  155. data() {
  156. return {
  157. // 遮罩层
  158. loading: true,
  159. // 导出遮罩层
  160. exportLoading: false,
  161. // 显示搜索条件
  162. showSearch: true,
  163. // 总条数
  164. total: 0,
  165. // 查询管理列表
  166. list: [],
  167. // 选中行
  168. currentRow: {},
  169. // 是否展开,默认全部折叠
  170. isExpandAll: false,
  171. // 重新渲染表格状态
  172. refreshTable: true,
  173. // 查询参数
  174. queryParams: {
  175. code: null,
  176. name: null,
  177. parentId: null,
  178. sort: null,
  179. status: null,
  180. dataSourceConfigId: null,
  181. sqlStatement: null,
  182. createTime: [],
  183. },
  184. };
  185. },
  186. created() {
  187. this.getList();
  188. },
  189. methods: {
  190. /** 展开/折叠操作 */
  191. toggleExpandAll() {
  192. this.refreshTable = false;
  193. this.isExpandAll = !this.isExpandAll;
  194. this.$nextTick(() => {
  195. this.refreshTable = true;
  196. });
  197. },
  198. handleToQuery(id) {
  199. this.$router.push({
  200. path: `/querymanage/queryForm?id=${id}`,
  201. });
  202. },
  203. /** 查询列表 */
  204. async getList() {
  205. try {
  206. this.loading = true;
  207. const res = await QueryManageApi.getQueryManagePage(this.queryParams);
  208. // this.list = res.data.list;
  209. this.list = this.handleTree(res.data.list, "id");
  210. this.total = res.data.total;
  211. } finally {
  212. this.loading = false;
  213. }
  214. },
  215. /** 搜索按钮操作 */
  216. handleQuery() {
  217. this.getList();
  218. },
  219. /** 重置按钮操作 */
  220. resetQuery() {
  221. this.resetForm("queryForm");
  222. this.handleQuery();
  223. },
  224. /** 添加/修改操作 */
  225. openForm(id) {
  226. this.$refs["formRef"].open(id);
  227. },
  228. handleAdd({ name, id }) {
  229. this.$refs["formRef"].formData.parentId = id;
  230. this.$refs["formRef"].formData.parentName = name;
  231. this.$refs["formRef"].open();
  232. },
  233. /** 删除按钮操作 */
  234. async handleDelete(row) {
  235. const id = row.id;
  236. await this.$modal.confirm(
  237. '是否确认删除查询管理编号为"' + id + '"的数据项?'
  238. );
  239. try {
  240. await QueryManageApi.deleteQueryManage(id);
  241. await this.getList();
  242. this.$modal.msgSuccess("删除成功");
  243. } catch {}
  244. },
  245. /** 导出按钮操作 */
  246. async handleExport() {
  247. await this.$modal.confirm("是否确认导出所有查询管理数据项?");
  248. try {
  249. this.exportLoading = true;
  250. const res = await QueryManageApi.exportQueryManageExcel(
  251. this.queryParams
  252. );
  253. this.$download.excel(res, "查询管理.xls");
  254. } catch {
  255. } finally {
  256. this.exportLoading = false;
  257. }
  258. },
  259. },
  260. };
  261. </script>