index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. <!--
  2. * @Descripttion: 用户权限--数据集
  3. * @version:
  4. * @Author: qianlishi
  5. * @Date: 2021-12-11 14:48:27
  6. * @LastEditors: qianlishi
  7. * @LastEditTime: 2022-04-14 18:48:24
  8. -->
  9. <template>
  10. <anji-crud ref="listPage" :option="crudOption">
  11. <template v-slot:tableButtons>
  12. <el-dropdown placement="bottom" @command="operateDataset">
  13. <el-button type="primary" icon="el-icon-plus">
  14. 新增
  15. <i class="el-icon-arrow-down el-icon--right"></i>
  16. </el-button>
  17. <el-dropdown-menu slot="dropdown">
  18. <el-dropdown-item command="sql">SQL</el-dropdown-item>
  19. <el-dropdown-item command="http">HTTP</el-dropdown-item>
  20. </el-dropdown-menu>
  21. </el-dropdown>
  22. </template>
  23. <template v-slot:pageSection>
  24. <EditDataSet
  25. ref="EditDataSet"
  26. :dataSet="dataSet"
  27. :visib="dialogVisibleSetDataSet"
  28. @handleClose="dialogVisibleSetDataSet = false"
  29. @refreshList="refreshList"
  30. />
  31. <DataView
  32. ref="DataView"
  33. :visib="dialogCaseResult"
  34. @handleClose="dialogCaseResult = false"
  35. />
  36. </template>
  37. </anji-crud>
  38. </template>
  39. <script>
  40. import {
  41. reportDataSetList,
  42. reportDataSetAdd,
  43. reportDataSetDeleteBatch,
  44. reportDataSetUpdate,
  45. reportDataSetDetail
  46. } from "@/api/reportDataSet";
  47. import EditDataSet from "./components/EditDataSet";
  48. import DataView from "./components/DataView";
  49. export default {
  50. name: "ReportDataSet",
  51. components: {
  52. EditDataSet: EditDataSet,
  53. DataView: DataView
  54. },
  55. data() {
  56. return {
  57. dialogVisibleSetDataSet: false,
  58. dataSet: {},
  59. dialogCaseResult: false,
  60. crudOption: {
  61. // 使用菜单做为页面标题
  62. title: "数据集",
  63. // 详情页中输入框左边文字宽度
  64. labelWidth: "120px",
  65. // 查询表单条件
  66. queryFormFields: [
  67. {
  68. inputType: "input",
  69. label: "数据集编码",
  70. field: "setCode"
  71. },
  72. {
  73. inputType: "input",
  74. label: "数据集名称",
  75. field: "setName"
  76. },
  77. {
  78. inputType: "anji-select", //form表单类型 input|input-number|anji-select(传递url或者dictCode)|anji-tree(左侧树)|date|datetime|datetimerange
  79. anjiSelectOption: {
  80. url: "/dataSource/queryAllDataSource",
  81. label: "sourceName",
  82. option: "sourceCode",
  83. mergeLabel: true
  84. },
  85. label: "数据源",
  86. field: "sourceCode"
  87. },
  88. {
  89. inputType: "anji-select", //form表单类型 input|input-number|anji-select(传递url或者dictCode)|anji-tree(左侧树)|date|datetime|datetimerange
  90. anjiSelectOption: {
  91. dictCode: "SET_TYPE"
  92. },
  93. label: "数据集类型",
  94. field: "setType"
  95. }
  96. ],
  97. // 表头按钮
  98. tableButtons: [
  99. {
  100. label: "删除",
  101. type: "danger",
  102. permission: "resultsetManage:delete",
  103. icon: "el-icon-delete",
  104. plain: false,
  105. click: () => {
  106. return this.$refs.listPage.handleDeleteBatch();
  107. }
  108. }
  109. ],
  110. // 表格行按钮
  111. rowButtons: [
  112. {
  113. label: "编辑",
  114. permission: "resultsetManage:update",
  115. click: row => {
  116. return this.operateDataset("edit", row);
  117. }
  118. },
  119. {
  120. label: "数据预览",
  121. permission: "resultsetManage:query",
  122. click: this.dataView
  123. },
  124. {
  125. label: "删除",
  126. permission: "resultsetManage:delete",
  127. click: row => {
  128. return this.$refs.listPage.handleDeleteBatch(row);
  129. }
  130. }
  131. ],
  132. // 操作按钮
  133. buttons: {
  134. rowButtonsWidth: 180, // row自定义按钮表格宽度
  135. query: {
  136. api: reportDataSetList,
  137. permission: "resultsetManage:query",
  138. sort: "update_time",
  139. order: "DESC"
  140. },
  141. queryByPrimarykey: {
  142. api: reportDataSetDetail,
  143. permission: "resultsetManage:detail"
  144. },
  145. add: {
  146. api: reportDataSetAdd,
  147. permission: "resultsetManage:insert",
  148. isShow: false
  149. },
  150. delete: {
  151. api: reportDataSetDeleteBatch,
  152. permission: "resultsetManage:delete"
  153. },
  154. edit: {
  155. api: reportDataSetUpdate,
  156. permission: "resultsetManage:update",
  157. isShow: false
  158. }
  159. },
  160. // 表格列
  161. columns: [
  162. {
  163. label: "",
  164. field: "id",
  165. primaryKey: true, // 根据主键查询详情或者根据主键删除时, 主键的
  166. tableHide: true, // 表格中不显示
  167. editHide: true // 编辑弹框中不显示
  168. },
  169. {
  170. label: "数据集编码", //数据集编码
  171. placeholder: "",
  172. field: "setCode",
  173. editField: "setCode",
  174. inputType: "input",
  175. rules: [
  176. { min: 1, max: 50, message: "不超过50个字符", trigger: "blur" }
  177. ],
  178. disabled: false
  179. },
  180. {
  181. label: "数据集名称", //数据集名称
  182. placeholder: "",
  183. field: "setName",
  184. editField: "setName",
  185. inputType: "input",
  186. rules: [
  187. { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" }
  188. ],
  189. disabled: false
  190. },
  191. {
  192. label: "描述", //数据集描述
  193. placeholder: "",
  194. field: "setDesc",
  195. editField: "setDesc",
  196. inputType: "input",
  197. rules: [
  198. { min: 1, max: 255, message: "不超过255个字符", trigger: "blur" }
  199. ],
  200. disabled: false
  201. },
  202. {
  203. label: "数据源编码", //数据源编码
  204. placeholder: "",
  205. field: "sourceCode",
  206. editField: "sourceCode",
  207. inputType: "input",
  208. rules: [
  209. { min: 1, max: 50, message: "不超过50个字符", trigger: "blur" }
  210. ],
  211. disabled: false
  212. },
  213. {
  214. label: "数据集类型", //数据源编码
  215. placeholder: "",
  216. field: "setType",
  217. editField: "setType",
  218. inputType: "input",
  219. rules: [
  220. { min: 1, max: 50, message: "不超过50个字符", trigger: "blur" }
  221. ],
  222. disabled: false
  223. },
  224. {
  225. label: "动态查询sql或者接口中的请求体", //动态查询sql或者接口中的请求体
  226. placeholder: "",
  227. field: "dynSentence",
  228. editField: "dynSentence",
  229. tableHide: true,
  230. inputType: "input",
  231. rules: [
  232. {
  233. min: 1,
  234. max: 2048,
  235. message: "不超过2048个字符",
  236. trigger: "blur"
  237. }
  238. ],
  239. disabled: false
  240. },
  241. {
  242. label: "结果案例", //结果案例
  243. placeholder: "",
  244. field: "caseResult",
  245. tableHide: true,
  246. editField: "caseResult",
  247. inputType: "input",
  248. rules: [
  249. {
  250. min: 1,
  251. max: 65535,
  252. message: "不超过65535个字符",
  253. trigger: "blur"
  254. }
  255. ],
  256. disabled: false
  257. },
  258. {
  259. label: "状态", //0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
  260. placeholder: "",
  261. field: "enableFlag",
  262. fieldTableRowRenderer: row => {
  263. return this.getDictLabelByCode("ENABLE_FLAG", row["enableFlag"]);
  264. },
  265. colorStyle: {
  266. 0: "table-danger", //key为editField渲染的值(字典的提交值)'红色': 'danger','蓝色': 'primary','绿色': 'success','黄色': 'warning','灰色': 'info','白色':''
  267. 1: "table-success"
  268. },
  269. editField: "enableFlag",
  270. inputType: "input",
  271. rules: [],
  272. disabled: false
  273. },
  274. {
  275. label: "删除标记", //0--未删除 1--已删除 DIC_NAME=DELETE_FLAG
  276. placeholder: "",
  277. field: "deleteFlag",
  278. editField: "deleteFlag",
  279. tableHide: true,
  280. inputType: "input",
  281. rules: [],
  282. disabled: false
  283. }
  284. ]
  285. }
  286. };
  287. },
  288. methods: {
  289. operateDataset(type, prop) {
  290. this.dialogVisibleSetDataSet = true;
  291. if (prop && prop.setType) {
  292. this.dataSet = prop;
  293. type = prop.setType;
  294. } else {
  295. this.dataSet = {};
  296. }
  297. this.$refs.EditDataSet.addOrEditDataSet(this.dataSet, type);
  298. },
  299. refreshList() {
  300. this.$refs.listPage.handleQueryForm("query");
  301. },
  302. dataView(prop) {
  303. this.dialogCaseResult = true;
  304. this.$refs.DataView.dataViewPreview(
  305. prop.setName,
  306. JSON.parse(prop.caseResult)
  307. );
  308. }
  309. }
  310. };
  311. </script>
  312. <style lang="scss" scoped>
  313. /deep/.el-dropdown {
  314. margin-right: 20px;
  315. }
  316. </style>