rtuimport.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <!--
  2. * @Title:
  3. * @Description:
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <el-row>
  12. <el-col :span="24">
  13. <basic-container>
  14. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
  15. :before-open="beforeOpen" ref="crud" v-model="form" :permission="permissionList"
  16. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  17. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  18. @on-load="onLoad">
  19. <template slot-scope="{ row, index }" slot="menu">
  20. <el-button type="text" size="small" @click="openDetail(row)">导入详情
  21. </el-button>
  22. </template>
  23. </avue-crud>
  24. </basic-container>
  25. </el-col>
  26. </el-row>
  27. <el-dialog title="导入详情" :visible.sync="detailDialog" width="60%" height="60%" :close-on-click-modal="false"
  28. append-to-body v-if="detailDialog">
  29. <rtuimportdetail :id="id" ref="rtuimportdetail">
  30. </rtuimportdetail>
  31. </el-dialog>
  32. </div>
  33. </template>
  34. <script>
  35. import { getPage } from "@/api/data/rtuImport.js";
  36. import rtuimportdetail from "./rtuimportdetail.vue";
  37. export default {
  38. components: {
  39. rtuimportdetail
  40. },
  41. data() {
  42. return {
  43. detailDialog: false,
  44. loading: false,
  45. id: "",
  46. editForm: {},
  47. editDialog: false,
  48. form: {},
  49. selectionList: [],
  50. query: {},
  51. page: {
  52. pageSize: 10,
  53. currentPage: 1,
  54. total: 0,
  55. },
  56. option: {
  57. labelWidth: 120,
  58. viewLabelWidth: 100,
  59. searchlabelWidth: 100,
  60. height: "auto",
  61. calcHeight: 80,
  62. align: "center",
  63. headerAlign: "center",
  64. lazy: false,
  65. tip: false,
  66. simplePage: true,
  67. searchShow: true,
  68. searchMenuSpan: 6,
  69. tree: true,
  70. border: true,
  71. index: true,
  72. selection: false,
  73. viewBtn: false,
  74. viewTitle: "测站导入",
  75. editBtn: false,
  76. delBtn: false,
  77. addBtn: false,
  78. menu: true,
  79. menuWidth: 120,
  80. dialogType: "drawer",
  81. dialogClickModal: false,
  82. columnBtn: false,
  83. column: [
  84. {
  85. label: "导入结果",
  86. prop: "importStatus",
  87. span: 24,
  88. width: 120,
  89. html: true,
  90. formatter: (val) => {
  91. if (val.importStatus === 0) {
  92. return '<b style="color:blue">导入中</b>'
  93. } else if (val.importStatus === 1) {
  94. return '<b style="color:green">导入成功</b>'
  95. } else if (val.importStatus === 2) {
  96. return '<b style="color:red">导入失败</b>'
  97. } else {
  98. return '';
  99. }
  100. },
  101. },
  102. {
  103. label: "操作用户",
  104. prop: "createUserName",
  105. span: 24,
  106. width: 120,
  107. editDisplay: false,
  108. addDisplay: false,
  109. },
  110. {
  111. label: "导入时间",
  112. prop: "importTime",
  113. span: 24,
  114. },
  115. {
  116. label: "导入说明",
  117. prop: "remark",
  118. span: 24,
  119. overHidden: true,
  120. },
  121. {
  122. label: "导入操作类型",
  123. prop: "saveType",
  124. span: 24,
  125. width: 160,
  126. html: true,
  127. formatter: (val) => {
  128. if (val.saveType === 0) {
  129. return '<b style="color:blue">只新增</b>'
  130. } else if (val.saveType === 1) {
  131. return '<b style="color:red">覆盖已有测站</b>'
  132. } else {
  133. return '';
  134. }
  135. },
  136. },
  137. {
  138. label: "文件名称",
  139. prop: "fileName",
  140. span: 24,
  141. overHidden: true,
  142. },
  143. ],
  144. },
  145. data: [],
  146. };
  147. },
  148. computed: {
  149. // ...mapGetters(["userInfo", "permission"]),
  150. permissionList() {
  151. return {
  152. // addBtn: this.vaildData(this.permission.docCategory_add, false),
  153. // viewBtn: this.vaildData(this.permission.docCategory_view, false),
  154. // delBtn: this.vaildData(this.permission.docCategory_delete, false),
  155. // editBtn: this.vaildData(this.permission.docCategory_edit, false),
  156. };
  157. },
  158. ids() {
  159. let ids = [];
  160. this.selectionList.forEach((ele) => {
  161. ids.push(ele.id);
  162. });
  163. return ids.join(",");
  164. },
  165. },
  166. mounted() { },
  167. created() {
  168. },
  169. methods: {
  170. openDetail(row) {
  171. this.id = row.id;
  172. this.detailDialog = true;
  173. this.$nextTick(() => {
  174. this.$refs["rtuimportdetail"].init();
  175. });
  176. },
  177. searchReset() {
  178. this.query = {};
  179. this.onLoad(this.page);
  180. },
  181. searchChange(params, done) {
  182. this.query = params;
  183. this.page.currentPage = 1;
  184. this.onLoad(this.page, params);
  185. done();
  186. },
  187. selectionChange(list) {
  188. this.selectionList = list;
  189. },
  190. selectionClear() {
  191. this.selectionList = [];
  192. this.$refs.crud.toggleSelection();
  193. },
  194. currentChange(currentPage) {
  195. this.page.currentPage = currentPage;
  196. },
  197. sizeChange(pageSize) {
  198. this.page.pageSize = pageSize;
  199. },
  200. refreshChange() {
  201. this.onLoad(this.page, this.query);
  202. },
  203. onLoad(page, params = {}) {
  204. this.loading = true;
  205. getPage(
  206. page.currentPage,
  207. page.pageSize,
  208. Object.assign(params, this.query)
  209. ).then((res) => {
  210. const data = res.data.data;
  211. this.page.total = data.total;
  212. this.data = data.records;
  213. this.loading = false;
  214. this.selectionClear();
  215. });
  216. },
  217. },
  218. };
  219. </script>