MultidimensionalTable.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <el-table
  3. row-key="id"
  4. :tree-props="{ children: 'children' }"
  5. :data="fileLists.result"
  6. border
  7. size="mini"
  8. :height="tableHeight"
  9. highlight-current-row
  10. tooltip-effect="dark"
  11. ref="fileListsTable"
  12. @row-click="(row, column, e) => loadTableHeader(row, column, e)"
  13. style="width: 100%; height: 100%;"
  14. class="multidimensional-table"
  15. >
  16. <el-table-column prop="count" label="" width="50"></el-table-column>
  17. <el-table-column
  18. prop="filename"
  19. label="文件名称"
  20. :show-overflow-tooltip="true"
  21. min-width="120"
  22. ></el-table-column>
  23. <!-- <el-table-column prop="generatedStr" label="类型" min-width="50"> </el-table-column> -->
  24. </el-table>
  25. </template>
  26. <script>
  27. import pagination from "@/components/Pagination.vue";
  28. import { uploadedGroupList } from "@/service/createmodel/apiLogin";
  29. export default {
  30. components: {
  31. pagination
  32. },
  33. data() {
  34. return {
  35. beforePayload: {
  36. page: 1,
  37. pageSize: 20,
  38. generated: "false"
  39. },
  40. activeName: "first",
  41. isAliPay: true,
  42. // 要展开的行,数值的元素是row的key值
  43. expands: []
  44. };
  45. },
  46. computed: {
  47. fileLists: {
  48. get() {
  49. let fileLists = this.$store.getters.getFilesList;
  50. fileLists.result = fileLists.result.map((res, idx) => {
  51. return {
  52. ...res,
  53. count: "",
  54. filename: res.groupName
  55. };
  56. });
  57. console.log(fileLists, "dddd");
  58. return fileLists;
  59. }
  60. },
  61. activeName1: {
  62. get() {
  63. return this.$store.getters.getFileActiveName;
  64. },
  65. set(val) {
  66. this.$store.commit("set_file_active_name", "first");
  67. }
  68. }
  69. },
  70. created() {
  71. let offsetHeight = 42;
  72. // let locationhref = window.location.href;
  73. // if(locationhref.indexOf('alipay') !== -1){
  74. // this.isAliPay = true
  75. // offsetHeight = 42
  76. // }
  77. this.tableHeight = this.getTableHeight(183 + offsetHeight);
  78. },
  79. mounted() {
  80. this.init();
  81. },
  82. methods: {
  83. handleClick(tab) {
  84. let payload = {
  85. page: 1,
  86. pageSize: 20,
  87. generated: "false"
  88. };
  89. if (this.activeName === "first") {
  90. payload.generated = "false";
  91. } else {
  92. payload.generated = "true";
  93. }
  94. this.$store.commit("set_file_active_name", payload.generated);
  95. this.loadFLTable(payload);
  96. },
  97. filterTag(value, row) {
  98. return row.tag === value;
  99. },
  100. init() {
  101. let payload = {
  102. page: 1,
  103. pageSize: 20,
  104. generated: "true"
  105. };
  106. // uploadedGroupList (this.setModelId(payload)).then(res=> {
  107. // debugger
  108. // })
  109. this.loadFLTable(payload);
  110. },
  111. loadFLTable(payload) {
  112. const loading = this.$loading({
  113. lock: true,
  114. text: "请耐心等待,正在加载数据。。",
  115. spinner: "el-icon-loading",
  116. background: "rgba(0, 0, 0, 0.7)"
  117. });
  118. this.beforePayload = payload;
  119. this.$store
  120. .dispatch("view_uploaded_group_list", this.setModelId(payload))
  121. .then(data => {
  122. loading.close();
  123. if (data.code == 200) {
  124. this.$store.commit("set_files_list", data);
  125. } else {
  126. this.$message({
  127. type: "error",
  128. message: data.message ? data.message : "加载失败"
  129. });
  130. }
  131. });
  132. },
  133. loadTableHeader(row, column, e) {
  134. if (row.children && row.children.length > 0) {
  135. if (
  136. e.currentTarget.firstElementChild.firstElementChild
  137. .firstElementChild.tagName == "DIV"
  138. ) {
  139. e.currentTarget.firstElementChild.firstElementChild.firstElementChild.click();
  140. } else {
  141. e.currentTarget.firstElementChild.firstElementChild.firstElementChild.nextElementSibling.click();
  142. }
  143. return;
  144. }
  145. this.$store.commit("set_current_fileobj", row);
  146. let payload = {
  147. page: 1,
  148. pageSize: 20,
  149. fileId: row.id
  150. };
  151. this.$store.commit("set_current_temp_pagesize", 20);
  152. this.$store.commit("set_up_search_sort_params", payload); // 保存文件基础信心
  153. this.loadSearchSortData(payload); // 加载文件内容
  154. this.loadTableHeaderDataById(payload); // 加载文件headers
  155. },
  156. // 搜索排序加载文件
  157. loadSearchSortData(payload) {
  158. const loading = this.$loading({
  159. lock: true,
  160. text: "请耐心等待,正在加载数据。。",
  161. spinner: "el-icon-loading",
  162. background: "rgba(0, 0, 0, 0.7)"
  163. });
  164. let upSearchSortParams = this.$store.getters.getUpSearchSortParams;
  165. let currentFile = this.$store.getters.getCurrentFile;
  166. payload.fileId = currentFile.id;
  167. payload.orders = upSearchSortParams.orders;
  168. payload.values = upSearchSortParams.values;
  169. payload.mode = upSearchSortParams.mode;
  170. this.beforePayload = payload;
  171. if(this.$store.state.fileStore.fileobj.filename.indexOf('对手透视') != -1){
  172. if(this.$store.state.fileStore.fileobj.filename.indexOf('数据分析-对手透视') != -1){
  173. payload.deleteName = 2
  174. }else{
  175. payload.deleteName = 1
  176. }
  177. }
  178. this.$store
  179. .dispatch("view_data_by_query", this.setModelId(payload))
  180. .then(data => {
  181. loading.close();
  182. if (data.code == 200) {
  183. this.$store.commit("set_file_content_by_id", data);
  184. } else {
  185. this.$message({
  186. type: "error",
  187. message: data.message ? data.message : "加载失败"
  188. });
  189. }
  190. });
  191. },
  192. loadTableHeaderDataById(payload) {
  193. const loading = this.$loading({
  194. lock: true,
  195. text: "请耐心等待。。",
  196. spinner: "el-icon-loading",
  197. background: "rgba(0, 0, 0, 0.7)"
  198. });
  199. let params = { fileId: payload.fileId };
  200. this.$store.commit("set_table_header", {});
  201. this.$store
  202. .dispatch("get_headers_by_id", this.setModelId(params))
  203. .then(data => {
  204. loading.close();
  205. if (data.code == 200) {
  206. this.$store.commit("set_table_header", data.result);
  207. this.loadDetailHeaders(payload.fileId);
  208. } else {
  209. this.$message({
  210. type: "error",
  211. message: data.message ? data.message : "失败"
  212. });
  213. }
  214. });
  215. },
  216. loadDetailHeaders(id) {
  217. let payload = {
  218. fileId: id
  219. };
  220. this.$store
  221. .dispatch("view_detail_ali_headers", this.setModelId(payload))
  222. .then(data => {
  223. if (data.code == 200) {
  224. let headResult = data.result;
  225. let finalHeaders = {};
  226. for (let v in headResult.fields) {
  227. finalHeaders[v] = {
  228. label: headResult.fields[v],
  229. alignment: "left",
  230. clickable: "none",
  231. valueType: "none"
  232. };
  233. for (let k in headResult.mainProps) {
  234. if (v == k) {
  235. finalHeaders[v] = {
  236. label: headResult.fields[v],
  237. alignment:
  238. headResult.mainProps[v].alignment,
  239. clickable:
  240. headResult.mainProps[v].clickable,
  241. valueType:
  242. headResult.mainProps[v].valueType
  243. };
  244. }
  245. }
  246. }
  247. this.$store.commit(
  248. "set_current_ali_headers",
  249. finalHeaders
  250. );
  251. } else {
  252. let msg = data.message ? data.message : "加载失败";
  253. console.log(msg);
  254. //this.$message({ type: "error", message: data.message ? data.message : "加载失败" });
  255. }
  256. });
  257. }
  258. }
  259. };
  260. </script>
  261. <style scoped>
  262. .excel-btns {
  263. border-top: 2px outset wheat;
  264. border-bottom: 2px outset wheat;
  265. padding: 5px 10px;
  266. text-align: right;
  267. }
  268. .left-files {
  269. height: 100%;
  270. padding-top: 0px;
  271. height: calc(100vh - 110px);
  272. border-right: none;
  273. background: #032d58;
  274. min-height: 700px;
  275. }
  276. </style>
  277. <style>
  278. .multidimensional-table .el-table__row--level-1 .cell {
  279. padding-left: 25px;
  280. }
  281. .multidimensional-table [class*="el-table__row--level"] .el-table__expand-icon {
  282. color: #fff;
  283. }
  284. </style>