index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <!--
  2. * @Descripttion: 报表设计--报表管理
  3. * @version:
  4. * @Author: qianlishi
  5. * @Date: 2021-12-11 14:48:27
  6. * @LastEditors: qianlishi
  7. * @LastEditTime: 2022-05-14 15:23:55
  8. -->
  9. <template>
  10. <anji-crud ref="listPage" :option="crudOption">
  11. <template v-slot:pageSection>
  12. <Share
  13. :visib="visibleForShareDialog"
  14. :reportCode="reportCodeForShareDialog"
  15. :reportName="reportNameForShareDialog"
  16. @handleClose="visibleForShareDialog = false"
  17. />
  18. </template>
  19. </anji-crud>
  20. </template>
  21. <script>
  22. import {
  23. reportList,
  24. reportAdd,
  25. reportDeleteBatch,
  26. reportUpdate,
  27. reportDetail,
  28. reportCopy
  29. } from "@/api/reportmanage";
  30. import Share from "./components/share";
  31. import { validateEngOrNum } from "@/utils/validate";
  32. import { verificationSet } from "@/api/report";
  33. export default {
  34. name: "Report",
  35. components: {
  36. anjiCrud: require("@/components/AnjiPlus/anji-crud/anji-crud").default,
  37. Share
  38. },
  39. data() {
  40. return {
  41. // 分享
  42. visibleForShareDialog: false,
  43. reportCodeForShareDialog: "",
  44. reportNameForShareDialog: "",
  45. crudOption: {
  46. // 使用菜单做为页面标题
  47. title: "报表管理",
  48. // 详情页中输入框左边文字宽度
  49. labelWidth: "120px",
  50. // 查询表单条件
  51. queryFormFields: [
  52. {
  53. inputType: "anji-select", //form表单类型 input|input-number|anji-select(传递url或者dictCode)|anji-tree(左侧树)|date|datetime|datetimerange
  54. anjiSelectOption: {
  55. dictCode: "REPORT_TYPE"
  56. },
  57. label: "报表类型",
  58. field: "reportType"
  59. },
  60. {
  61. inputType: "input",
  62. label: "报表名称",
  63. field: "reportName"
  64. },
  65. {
  66. inputType: "input",
  67. label: "报表编码",
  68. field: "reportCode"
  69. },
  70. {
  71. inputType: "input",
  72. label: "制作人",
  73. field: "reportAuthor"
  74. }
  75. ],
  76. // 表头按钮
  77. tableButtons: [
  78. {
  79. label: "新增",
  80. type: "", // primary、success、info、warning、danger
  81. permission: "reportManage:insert", // 按钮权限码
  82. icon: "el-icon-plus",
  83. plain: true,
  84. click: () => {
  85. return this.$refs.listPage.handleOpenEditView("add");
  86. }
  87. },
  88. {
  89. label: "删除",
  90. type: "danger",
  91. permission: "reportManage:delete",
  92. icon: "el-icon-delete",
  93. plain: false,
  94. click: () => {
  95. return this.$refs.listPage.handleDeleteBatch();
  96. }
  97. }
  98. ],
  99. // 表格行按钮
  100. rowButtons: [
  101. {
  102. label: "编辑",
  103. permission: "reportManage:update",
  104. click: row => {
  105. return this.$refs.listPage.handleOpenEditView("edit", row);
  106. }
  107. },
  108. {
  109. label: "预览",
  110. permission: "bigScreenManage:view",
  111. click: this.preview
  112. },
  113. {
  114. label: "设计",
  115. permission: "bigScreenManage:design",
  116. click: this.design
  117. },
  118. {
  119. label: "分享",
  120. permission: "bigScreenManage:share",
  121. click: this.shareReport
  122. },
  123. {
  124. label: "复制",
  125. permission: "bigScreenManage:copy",
  126. click: this.copyReport
  127. },
  128. {
  129. label: "删除",
  130. permission: "reportManage:delete",
  131. click: row => {
  132. return this.$refs.listPage.handleDeleteBatch(row);
  133. }
  134. }
  135. ],
  136. // 操作按钮
  137. buttons: {
  138. query: {
  139. api: reportList,
  140. permission: "reportManage:query",
  141. sort: "update_time",
  142. order: "DESC"
  143. },
  144. queryByPrimarykey: {
  145. api: reportDetail,
  146. permission: "reportManage:detail"
  147. },
  148. add: {
  149. api: reportAdd,
  150. permission: "reportManage:insert"
  151. },
  152. delete: {
  153. api: reportDeleteBatch,
  154. permission: "reportManage:delete"
  155. },
  156. edit: {
  157. api: reportUpdate,
  158. permission: "reportManage:update"
  159. },
  160. rowButtonsWidth: 150 // row自定义按钮表格宽度
  161. },
  162. // 表格列
  163. columns: [
  164. {
  165. label: "",
  166. field: "id",
  167. primaryKey: true, // 根据主键查询详情或者根据主键删除时, 主键的
  168. tableHide: true, // 表格中不显示
  169. editHide: true // 编辑弹框中不显示
  170. },
  171. {
  172. label: "报表名称", //名称
  173. placeholder: "",
  174. field: "reportName",
  175. editField: "reportName",
  176. inputType: "input",
  177. rules: [
  178. { required: true, message: "请输入报表名称", trigger: "blur" },
  179. { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" }
  180. ],
  181. disabled: false
  182. },
  183. {
  184. label: "报表编码", //报表编码
  185. placeholder: "唯一标识",
  186. field: "reportCode",
  187. editField: "reportCode",
  188. inputType: "input",
  189. rules: [
  190. { required: true, message: "请输入报表编码", trigger: "blur" },
  191. { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" },
  192. { validator: validateEngOrNum, trigger: "blur" }
  193. ],
  194. disabled: "disableOnEdit"
  195. },
  196. {
  197. label: "分组", //分组,暂时不展示出来
  198. placeholder: "",
  199. field: "reportGroup",
  200. tableHide: true,
  201. editHide: true,
  202. editField: "reportGroup",
  203. inputType: "input",
  204. rules: [
  205. { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" }
  206. ],
  207. disabled: false,
  208. defaultValue: "default"
  209. },
  210. {
  211. label: "报表类型", //报表类型-目前仅支持大屏报表,暂时不展示出来
  212. placeholder: "",
  213. field: "reportType",
  214. editField: "reportType",
  215. inputType: "anji-select",
  216. fieldTableRowRenderer: row => {
  217. return this.getDictLabelByCode("REPORT_TYPE", row["reportType"]);
  218. },
  219. anjiSelectOption: {
  220. dictCode: "REPORT_TYPE"
  221. },
  222. rules: [
  223. { required: true, message: "请输入报表类型", trigger: "blur" },
  224. { min: 1, max: 20, message: "不超过20个字符", trigger: "blur" }
  225. ],
  226. disabled: "disableOnEdit"
  227. },
  228. {
  229. label: "制作人", //名称
  230. placeholder: "",
  231. field: "reportAuthor",
  232. editField: "reportAuthor",
  233. inputType: "input",
  234. rules: [
  235. { min: 1, max: 100, message: "不超过100个字符", trigger: "blur" }
  236. ],
  237. disabled: false
  238. },
  239. {
  240. label: "描述", //报表描述
  241. placeholder: "",
  242. field: "reportDesc",
  243. editField: "reportDesc",
  244. inputType: "input",
  245. rules: [
  246. { min: 1, max: 255, message: "不超过255个字符", trigger: "blur" }
  247. ],
  248. disabled: false
  249. },
  250. {
  251. label: "状态", //0--已禁用 1--已启用 DIC_NAME=ENABLE_FLAG
  252. placeholder: "",
  253. field: "enableFlag",
  254. fieldTableRowRenderer: row => {
  255. return this.getDictLabelByCode("ENABLE_FLAG", row["enableFlag"]);
  256. },
  257. colorStyle: {
  258. 0: "table-danger", //key为editField渲染的值(字典的提交值)'红色': 'danger','蓝色': 'primary','绿色': 'success','黄色': 'warning','灰色': 'info','白色':''
  259. 1: "table-success"
  260. },
  261. editField: "enableFlag",
  262. inputType: "anji-select",
  263. anjiSelectOption: {
  264. dictCode: "ENABLE_FLAG"
  265. },
  266. rules: [],
  267. disabled: false,
  268. defaultValue: 1
  269. },
  270. {
  271. label: "删除标记", //0--未删除 1--已删除 DIC_NAME=DELETE_FLAG
  272. placeholder: "",
  273. field: "deleteFlag",
  274. editHide: true,
  275. editField: "deleteFlag",
  276. tableHide: true,
  277. inputType: "input",
  278. rules: [],
  279. disabled: false
  280. },
  281. {
  282. label: "报表缩略图", //报表缩略图
  283. placeholder: "",
  284. field: "reportImage",
  285. editField: "reportImage",
  286. inputType: "anji-upload",
  287. tableHide: true,
  288. anjiUpload: {
  289. limit: 1 // 文件大小 Number 类型
  290. }
  291. }
  292. ],
  293. // 弹出框表单对应的值有改动时
  294. // formData 整个表单,通过编辑打开弹出框,根据主键查询数据时,fieldName, fieldVal, fieldExtend为空
  295. // fieldName 触发修改的input name
  296. // fieldVal input最新值
  297. // fieldExtend 对于select型的扩展值
  298. formChange: (formData, fieldName, fieldVal, fieldExtend) => {
  299. if (fieldName == "reportImage" && fieldVal.length > 0) {
  300. formData["reportImage"] = fieldVal && fieldVal[0].url;
  301. }
  302. }
  303. }
  304. };
  305. },
  306. created() {},
  307. methods: {
  308. handleOpenDialog1() {
  309. alert("自定义按钮1点击事件");
  310. },
  311. // 预览
  312. preview(val) {
  313. let routePath = "";
  314. if (val.reportType === "report_excel") {
  315. routePath = "/excelreport/viewer";
  316. } else {
  317. routePath = "/bigscreen/viewer";
  318. }
  319. let routeUrl = this.$router.resolve({
  320. path: routePath,
  321. query: { reportCode: val.reportCode }
  322. });
  323. window.open(routeUrl.href, "_blank");
  324. },
  325. // 设计
  326. design(val) {
  327. let routePath = "";
  328. if (val.reportType === "report_excel") {
  329. routePath = "/excelreport/designer";
  330. } else {
  331. routePath = "/bigscreen/designer";
  332. }
  333. let routeUrl = this.$router.resolve({
  334. path: routePath,
  335. query: {
  336. reportCode: val.reportCode
  337. }
  338. });
  339. window.open(routeUrl.href, "_blank");
  340. },
  341. //分享
  342. shareReport(val) {
  343. if (val.reportType == "report_excel") {
  344. //excel暂不支持
  345. this.$message.warning("暂不支持excel报表分享");
  346. return;
  347. }
  348. this.reportCodeForShareDialog = val.reportCode;
  349. this.reportNameForShareDialog = val.reportName;
  350. this.visibleForShareDialog = true;
  351. },
  352. //复制
  353. async copyReport(val) {
  354. const { code } = await reportCopy(val);
  355. if (code != "200") {
  356. return;
  357. }
  358. this.$message.success("复制成功");
  359. this.$refs.listPage.handleQueryForm("query");
  360. }
  361. }
  362. };
  363. </script>