statementConfig.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532
  1. <template>
  2. <div class="container">
  3. <templatePopup
  4. ref="popupRef"
  5. :templateTitle="templateTitle"
  6. :templateType="templateType"
  7. @confirmEvent="confirmEvent"
  8. />
  9. <div class="header">
  10. <el-form label-width="120px">
  11. <div style="display: flex; padding: 10px">
  12. <el-form-item label="报表模板名称:">
  13. <el-input
  14. ref="search"
  15. v-model="form.templateName"
  16. suffix-icon="el-icon-search"
  17. placeholder="请输入模板名称"
  18. ></el-input>
  19. </el-form-item>
  20. <el-form-item label="报表模板格式:">
  21. <el-select
  22. placeholder="请选择报表模板格式"
  23. v-model="form.templateForm"
  24. >
  25. <el-option
  26. v-for="item in temFormatOptions"
  27. :key="item.value"
  28. :label="item.label"
  29. :value="item.value"
  30. ></el-option>
  31. </el-select>
  32. </el-form-item>
  33. <el-button class="reset-btn" @click="resetEvent">重置</el-button>
  34. <el-button class="search-btn" @click="searchEvent">查询</el-button>
  35. </div>
  36. </el-form>
  37. </div>
  38. <div class="content">
  39. <div class="content-inner-top">
  40. <div class="info">模板列表</div>
  41. <el-button class="add-btn" @click="addTemplate">添加模板</el-button>
  42. <el-button class="delete-btn" @click="batchDelete">批量删除</el-button>
  43. </div>
  44. <el-table
  45. ref="multipleTable"
  46. :data="tableData"
  47. tooltip-effect="dark"
  48. :header-cell-style="{ textAlign: 'center' }"
  49. :cell-style="{ textAlign: 'center' }"
  50. style="width: 100%"
  51. :height="400"
  52. @selection-change="handleSelectionChange"
  53. >
  54. <el-table-column type="selection" width="50"> </el-table-column>
  55. <el-table-column prop="templateName" label="模板名称">
  56. </el-table-column>
  57. <el-table-column prop="templateForm" label="模板格式">
  58. </el-table-column>
  59. <el-table-column prop="createUser" label="创建用户"> </el-table-column>
  60. <el-table-column prop="createTime" label="创建时间"> </el-table-column>
  61. <el-table-column prop="alterTime" label="修改时间"> </el-table-column>
  62. <el-table-column prop="operation" label="操作">
  63. <template slot-scope="scope">
  64. <el-button
  65. v-show="scope.row.templateName == null ? false : true"
  66. size="mini"
  67. type="text"
  68. style="color: #2ea8e6"
  69. @click="downloadTemplate(scope.row.template)"
  70. >点击下载</el-button
  71. >
  72. <el-button
  73. v-show="scope.row.templateName == null ? false : true"
  74. size="mini"
  75. type="text"
  76. style="color: #2ea8e6"
  77. @click="editTemplate(scope.row)"
  78. >编辑</el-button
  79. >
  80. <el-button
  81. v-show="scope.row.templateName == null ? false : true"
  82. size="mini"
  83. type="text"
  84. style="color: #2ea8e6"
  85. @click="deleteTemplate(scope.row)"
  86. >删除</el-button
  87. >
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. </div>
  92. <div class="bottom">
  93. <page :paginationData="paginationData"></page>
  94. </div>
  95. </div>
  96. </template>
  97. <script>
  98. import page from "@/components/pagination/index";
  99. import templatePopup from "@/views/dataManagement/templatePopup";
  100. import {
  101. addReportTemplate,
  102. getTableTemplateList,
  103. modifySingleTemplate,
  104. deleteSingleTemplate,
  105. deleteMultipleTemplates,
  106. downloadTemplate,
  107. } from "@/api/data/template";
  108. export default {
  109. components: { page, templatePopup },
  110. data() {
  111. return {
  112. templateTitle: "",
  113. templateType: "报表",
  114. form: {
  115. templateName: "",
  116. templateForm: "",
  117. },
  118. tableData: [],
  119. temFormatOptions: [
  120. {
  121. value: "",
  122. label: "全部",
  123. },
  124. {
  125. value: "Word",
  126. label: "Word",
  127. },
  128. {
  129. value: "Excel",
  130. label: "Excel",
  131. },
  132. {
  133. value: "PDF",
  134. label: "PDF",
  135. },
  136. ],
  137. defaultProps: {
  138. children: "children",
  139. label: "label",
  140. },
  141. currentPageSize: 10,
  142. currentPage: 1,
  143. paginationData: {
  144. pageSize: 10,
  145. pagerCount: 5,
  146. currentPage: 1,
  147. pageSizes: [5, 10, 20, 30],
  148. total: 0,
  149. currentChange: (val) => {
  150. this.getTableData(val);
  151. },
  152. handleSizeChange: (val) => {
  153. this.handleSizeChange(val);
  154. },
  155. },
  156. multipleSelection: [],
  157. };
  158. },
  159. watch: {
  160. filterText(val) {
  161. this.$refs.search.filter(val);
  162. },
  163. },
  164. mounted() {
  165. this.initData();
  166. },
  167. methods: {
  168. initData() {
  169. this.getTableData(1);
  170. },
  171. getTableData(val) {
  172. this.tableData = [];
  173. getTableTemplateList(
  174. val,
  175. this.currentPageSize,
  176. 0,
  177. this.form.templateName,
  178. this.form.templateForm
  179. ).then((res) => {
  180. if (res.data.code === 0 && res.data.data.length > 0) {
  181. this.paginationData.total = res.data.total;
  182. this.tableData = res.data.data.map((v) => {
  183. return {
  184. id: v.id,
  185. templateName: v.name,
  186. templateForm: v.format,
  187. createUser: v.creator,
  188. createTime: v.create_time,
  189. alterTime: v.update_time,
  190. template: v.template,
  191. introduction: v.introduction,
  192. };
  193. });
  194. }
  195. });
  196. },
  197. downloadTemplate(fileName) {
  198. downloadTemplate(fileName)
  199. .then((res) => {
  200. const data = res.data;
  201. if (data.type === "application/octet-stream") {
  202. const blob = new Blob([data], { type: data.type });
  203. const url = window.URL.createObjectURL(blob);
  204. const link = document.createElement("a");
  205. link.href = url;
  206. link.download = fileName;
  207. document.body.appendChild(link);
  208. link.click();
  209. }
  210. })
  211. .catch((err) => {
  212. this.$message.error("文件下载失败,请重新下载!");
  213. });
  214. },
  215. handleSizeChange(val) {
  216. this.currentPageSize = val;
  217. this.getTableData(this.currentPage);
  218. },
  219. handleSelectionChange(val) {
  220. this.multipleSelection = val;
  221. },
  222. filterNode(value, data) {
  223. if (!value) return true;
  224. return data.label.indexOf(value) !== -1;
  225. },
  226. resetEvent() {
  227. this.form.templateName = "";
  228. this.form.templateForm = "";
  229. this.searchEvent();
  230. },
  231. searchEvent() {
  232. this.getTableData(this.currentPage);
  233. },
  234. addTemplate() {
  235. this.templateTitle = "添加模板";
  236. this.$refs.popupRef.dialogVisible = true;
  237. this.$refs.popupRef.formData.name = "";
  238. this.$refs.popupRef.formData.format = "Excel";
  239. this.$refs.popupRef.formData.introduction = "";
  240. this.$refs.popupRef.formData.templateType = 0;
  241. },
  242. batchDelete() {
  243. if (this.multipleSelection.length > 0) {
  244. let arr = this.multipleSelection.map((v) => {
  245. return v.id;
  246. });
  247. deleteMultipleTemplates(JSON.stringify(arr)).then((res) => {
  248. if (res.data.code === 0) {
  249. this.$message.success("选中模板已删除!");
  250. this.getTableData(1);
  251. }
  252. });
  253. } else {
  254. this.$message.info("暂无需要删除的模板");
  255. }
  256. },
  257. editTemplate(data) {
  258. this.templateTitle = "编辑模板";
  259. this.$refs.popupRef.dialogVisible = true;
  260. this.$refs.popupRef.formData.id = data.id;
  261. this.$refs.popupRef.formData.templateType = 0;
  262. this.$refs.popupRef.formData.name = data.templateName;
  263. this.$refs.popupRef.formData.format = data.templateForm;
  264. data.introduction == "null"
  265. ? (this.$refs.popupRef.formData.introduction = "")
  266. : (this.$refs.popupRef.formData.introduction = data.introduction);
  267. },
  268. deleteTemplate(data) {
  269. deleteSingleTemplate(data.id).then((res) => {
  270. if (res.data.code === 0) {
  271. this.$message.success("模板已删除!");
  272. this.getTableData(1);
  273. }
  274. });
  275. },
  276. confirmEvent(data) {
  277. if (this.templateTitle === "添加模板") {
  278. let options = {
  279. templateName: data.name,
  280. templateFormat: data.format,
  281. introduction: data.introduction,
  282. templateType: 0,
  283. file: data.file,
  284. };
  285. addReportTemplate(options).then((res) => {
  286. if (res.data.code === -1) {
  287. this.$message.info("添加失败,请修改重新添加!");
  288. }
  289. if (res.data.code === 0) {
  290. this.$message.success("模板添加成功!");
  291. this.$refs.popupRef.dialogVisible = false;
  292. this.getTableData(1);
  293. }
  294. });
  295. }
  296. if (this.templateTitle === "编辑模板") {
  297. let options = {
  298. id: data.id,
  299. templateName: data.name,
  300. templateFormat: data.format,
  301. introduction: data.introduction,
  302. templateType: 0,
  303. file: data.file,
  304. };
  305. modifySingleTemplate(options).then((res) => {
  306. if (res.data.code === -1) {
  307. this.$message.info("模板修改失败");
  308. }
  309. if (res.data.code === 0) {
  310. this.$message.success("模板添加成功!");
  311. this.$refs.popupRef.dialogVisible = false;
  312. this.getTableData(1);
  313. }
  314. });
  315. }
  316. },
  317. },
  318. };
  319. </script>
  320. <style lang="less" scoped>
  321. .container {
  322. position: relative;
  323. height: 100%;
  324. line-height: 20px;
  325. background-color: rgba(255, 255, 255, 1);
  326. color: rgba(16, 16, 16, 1);
  327. font-size: 14px;
  328. text-align: center;
  329. overflow-y: auto;
  330. //box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.15);
  331. .header {
  332. margin: 2%;
  333. width: 96%;
  334. height: 60px;
  335. background-color: #fafafa;
  336. position: relative;
  337. border-radius: 4px;
  338. .reset-btn,
  339. .search-btn {
  340. height: 30px;
  341. width: 80px;
  342. position: absolute;
  343. color: #fff;
  344. display: flex;
  345. align-items: center;
  346. justify-content: center;
  347. top: 15px;
  348. }
  349. .reset-btn {
  350. background-color: #b3b3b3;
  351. right: 130px;
  352. }
  353. .search-btn {
  354. background-color: #2ea8e6;
  355. right: 25px;
  356. }
  357. .el-form-item {
  358. margin-bottom: 0 !important;
  359. margin-right: 60px !important;
  360. /deep/.el-form-item {
  361. margin-right: 50px;
  362. margin-bottom: 0;
  363. }
  364. /deep/.el-form-item__content {
  365. margin-left: 120px;
  366. }
  367. }
  368. }
  369. .content {
  370. width: 95%;
  371. position: absolute;
  372. margin-left: 2.5%;
  373. margin-right: 2.5%;
  374. margin-top: 30px;
  375. height: calc(80% - 110px);
  376. &-inner-top {
  377. width: 100%;
  378. height: 100px;
  379. position: absolute;
  380. .info {
  381. position: absolute;
  382. width: 150px;
  383. top: 0;
  384. left: 0;
  385. height: 60px;
  386. font-size: 25px;
  387. display: flex;
  388. align-items: center;
  389. font-weight: 550;
  390. color: #4d4d4d;
  391. }
  392. .add-btn,
  393. .delete-btn {
  394. padding: 3px;
  395. width: 80px;
  396. height: 30px;
  397. bottom: 15px;
  398. position: absolute;
  399. color: #fff;
  400. border-radius: 4px;
  401. }
  402. .add-btn {
  403. right: 100px;
  404. background-color: #2ea8e6;
  405. }
  406. .delete-btn {
  407. right: 10px;
  408. background-color: #b3b3b3;
  409. }
  410. }
  411. .el-table {
  412. position: absolute;
  413. top: 100px;
  414. width: 100%;
  415. height: calc(100% - 100px);
  416. border: 1px solid #f0f2f2;
  417. margin-top: 10px;
  418. font-size: 0.95rem;
  419. font-family: PingFang SC;
  420. font-weight: 500;
  421. color: #b2b2b2;
  422. background: rgba(255, 255, 255, 0.8);
  423. /deep/th {
  424. background: #f7fbff;
  425. }
  426. /deep/.el-checkbox {
  427. color: #b2b2b2;
  428. .el-checkbox__input.is-checked + .el-checkbox__label {
  429. color: #2ea8e6;
  430. }
  431. .el-checkbox__input.is-checked .el-checkbox__inner::after {
  432. width: 70%;
  433. height: 70%;
  434. background: #2ea8e6;
  435. border-radius: 0;
  436. transform: rotate(0deg) scaleY(1);
  437. position: static;
  438. // border: 1px solid #8DD9FF;
  439. }
  440. .el-checkbox__inner {
  441. border: 1px solid #8dd9ff;
  442. background: rgba(0, 170, 255, 0);
  443. display: flex;
  444. align-items: center;
  445. justify-content: center;
  446. position: static;
  447. &::after {
  448. transition: 0ms;
  449. }
  450. }
  451. .el-checkbox__label {
  452. padding-left: 0;
  453. font-size: 15px;
  454. position: absolute;
  455. top: 1px;
  456. left: 25px;
  457. }
  458. }
  459. }
  460. .el-select {
  461. width: 80px;
  462. margin-right: 20px;
  463. }
  464. }
  465. .bottom {
  466. position: absolute;
  467. left: 20px;
  468. right: 16px;
  469. bottom: 20px;
  470. height: 50px;
  471. line-height: 20px;
  472. background-color: rgba(255, 255, 255, 1);
  473. text-align: center;
  474. .checkbox {
  475. position: absolute;
  476. left: 29px;
  477. top: 15px;
  478. font-size: 14px;
  479. }
  480. .check-cancel {
  481. position: absolute;
  482. // line-height: 20px;
  483. font-size: 14px;
  484. text-align: center;
  485. left: 140px;
  486. top: 10px;
  487. }
  488. .bottom_button {
  489. position: absolute;
  490. left: 200px;
  491. margin-top: 15px;
  492. .delete {
  493. font-size: 14px;
  494. text-align: center;
  495. padding: 1px;
  496. }
  497. .disabled {
  498. font-size: 14px;
  499. text-align: center;
  500. padding: 1px;
  501. }
  502. .export {
  503. font-size: 14px;
  504. text-align: center;
  505. padding: 1px;
  506. }
  507. }
  508. }
  509. }
  510. </style>