rainDataCache.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  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="4">
  13. <div class="box">
  14. <el-scrollbar>
  15. <basic-container>
  16. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick">
  17. <span class="el-tree-node__label" slot-scope="{ node, data }">
  18. <span>
  19. <i class="el-icon-office-building"></i>
  20. {{ (node || {}).label }}
  21. </span>
  22. </span>
  23. </avue-tree>
  24. </basic-container>
  25. </el-scrollbar>
  26. </div>
  27. </el-col>
  28. <el-col :span="20">
  29. <basic-container>
  30. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page"
  31. :before-open="beforeOpen" ref="crud" v-model="form" :permission="permissionList" @row-del="rowDel"
  32. @row-update="rowUpdate" @row-save="rowSave" @search-change="searchChange"
  33. @search-reset="searchReset" @selection-change="selectionChange" @current-change="currentChange"
  34. @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
  35. @select-change="selectChange" @sort-change="sortChange">
  36. </avue-crud>
  37. </basic-container>
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </template>
  42. <script>
  43. import { getPage, } from "@/api/data/dataRain.js";
  44. import { getTree } from "@/api/baseinfo/region.js";
  45. export default {
  46. components: {
  47. },
  48. data() {
  49. return {
  50. id: "",
  51. form: {},
  52. selectionList: [],
  53. query: {},
  54. sort: {},
  55. loading: true,
  56. page: {
  57. pageSize: 10,
  58. currentPage: 1,
  59. total: 0,
  60. },
  61. treeCode: '',
  62. treeParentCode: '',
  63. treeData: [],
  64. treeOption: {
  65. nodeKey: "id",
  66. defaultExpandedKeys: [],
  67. lazy: false,
  68. // treeLoad: function (node, resolve) {
  69. // const parentCode = (node.level === 0) ? "00" : node.data.value;
  70. // getLazyTree(parentCode).then(res => {
  71. // resolve(res.data.data.map(item => {
  72. // return {
  73. // ...item,
  74. // leaf: !item.hasChildren
  75. // }
  76. // }))
  77. // });
  78. // },
  79. addBtn: false,
  80. menu: true,
  81. size: "small",
  82. props: {
  83. labelText: "标题",
  84. label: "title",
  85. value: "value",
  86. children: "children",
  87. },
  88. },
  89. option: {
  90. labelWidth: 120,
  91. viewLabelWidth: 100,
  92. searchlabelWidth: 100,
  93. height: "auto",
  94. calcHeight: 80,
  95. align: "center",
  96. headerAlign: "center",
  97. lazy: false,
  98. tip: false,
  99. simplePage: true,
  100. searchShow: true,
  101. searchMenuSpan: 6,
  102. tree: true,
  103. border: true,
  104. index: true,
  105. selection: false,
  106. viewBtn: false,
  107. viewTitle: "测站信息",
  108. editBtn: false,
  109. delBtn: false,
  110. addBtn: false,
  111. menu: false,
  112. dialogType: "drawer",
  113. dialogClickModal: false,
  114. columnBtn: false,
  115. column: [
  116. {
  117. label: "站点编码",
  118. prop: "rtuCode",
  119. search: true,
  120. span: 24,
  121. width: 120,
  122. },
  123. {
  124. label: "站点名称",
  125. prop: "rtuName",
  126. search: true,
  127. span: 24,
  128. width: 160,
  129. },
  130. {
  131. label: "行政区",
  132. prop: "adCity",
  133. span: 24,
  134. editDisplay: false,
  135. addDisplay: false,
  136. html: true,
  137. formatter: (val) => {
  138. if (val.adCity && val.adDist) {
  139. return '<b>' + val.adCity + '</b>/' + '<b>' + val.adDist + '</b>'
  140. } else {
  141. return '<b>' + val.adCity + '</b>'
  142. }
  143. }
  144. },
  145. {
  146. label: "上报时间",
  147. prop: "tm",
  148. span: 24,
  149. sortable: 'custom',
  150. },
  151. {
  152. label: "时段长",
  153. prop: "intv",
  154. span: 24,
  155. html: true,
  156. formatter: (val) => {
  157. if (val.intv === 1.0) {
  158. return '<b>1小时</b>'
  159. } if (val.intv === 0.05) {
  160. return '<b>5分钟</b>'
  161. } else {
  162. return '';
  163. }
  164. }
  165. },
  166. {
  167. label: "时段降水量",
  168. prop: "drp",
  169. span: 24,
  170. sortable: 'custom',
  171. html: true,
  172. formatter: (val) => {
  173. if (val.drp != null) {
  174. return val.drp;
  175. } else {
  176. return "";
  177. }
  178. }
  179. },
  180. ],
  181. },
  182. data: [],
  183. };
  184. },
  185. computed: {
  186. // ...mapGetters(["userInfo", "permission"]),
  187. permissionList() {
  188. return {
  189. // addBtn: this.vaildData(this.permission.docCategory_add, false),
  190. // viewBtn: this.vaildData(this.permission.docCategory_view, false),
  191. // delBtn: this.vaildData(this.permission.docCategory_delete, false),
  192. // editBtn: this.vaildData(this.permission.docCategory_edit, false),
  193. };
  194. },
  195. ids() {
  196. let ids = [];
  197. this.selectionList.forEach((ele) => {
  198. ids.push(ele.id);
  199. });
  200. return ids.join(",");
  201. },
  202. },
  203. mounted() { },
  204. created() {
  205. this.initTree();
  206. },
  207. methods: {
  208. initTree() {
  209. this.treeData = [];
  210. getTree().then(res => {
  211. this.treeData = res.data.data.map(item => {
  212. return {
  213. ...item,
  214. leaf: !item.hasChildren
  215. }
  216. })
  217. this.treeOption.defaultExpandedKeys.push(this.treeData[0].id);
  218. this.treeCode = this.treeData[0].id;
  219. });
  220. },
  221. sortChange(val) {
  222. console.log(JSON.stringify(val))
  223. //prop":"tm","order":"ascending" descending
  224. let prop = val.prop;
  225. if (prop === 'tm') {
  226. this.page.currentPage = 1;
  227. let params = {};
  228. let order = val.order;
  229. if (order) {
  230. params['order'] = order;
  231. params['prop'] = prop;
  232. this.sort = {};
  233. Object.assign(this.sort, params)
  234. } else {
  235. this.sort = {};
  236. }
  237. this.onLoad(this.page, params);
  238. } else if (prop === 'drp') {
  239. this.page.currentPage = 1;
  240. let params = {};
  241. let order = val.order;
  242. if (order) {
  243. params['order'] = order;
  244. params['prop'] = prop;
  245. this.sort = {};
  246. Object.assign(this.sort, params)
  247. } else {
  248. this.sort = {};
  249. }
  250. this.onLoad(this.page, params);
  251. }
  252. },
  253. nodeClick(data) {
  254. this.treeCode = data.id;
  255. this.treeParentCode = data.parentId;
  256. this.query = {};
  257. this.query['adCode'] = this.treeCode;
  258. this.page.currentPage = 1;
  259. var params = {};
  260. this.onLoad(this.page, params);
  261. },
  262. searchReset() {
  263. this.page.currentPage = 1;
  264. this.onLoad(this.page);
  265. },
  266. searchChange(params, done) {
  267. this.page.currentPage = 1;
  268. this.onLoad(this.page, params);
  269. done();
  270. },
  271. selectionChange(list) {
  272. this.selectionList = list;
  273. },
  274. selectChange(item) {
  275. this.$message.success("" + item)
  276. },
  277. selectionClear() {
  278. this.selectionList = [];
  279. this.$refs.crud.toggleSelection();
  280. },
  281. currentChange(currentPage) {
  282. this.page.currentPage = currentPage;
  283. },
  284. sizeChange(pageSize) {
  285. this.page.pageSize = pageSize;
  286. },
  287. refreshChange() {
  288. var params = {};
  289. this.onLoad(this.page, params);
  290. },
  291. onLoad(page, params = {}) {
  292. this.loading = true;
  293. getPage(
  294. page.currentPage,
  295. page.pageSize,
  296. Object.assign(params, this.sort, this.query)
  297. ).then((res) => {
  298. const data = res.data.data;
  299. this.page.total = data.total;
  300. this.data = data.records;
  301. this.loading = false;
  302. this.selectionClear();
  303. });
  304. },
  305. },
  306. };
  307. </script>