index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  1. <template>
  2. <div class="container">
  3. <div class="header">
  4. <el-menu
  5. :default-active="activeIndex"
  6. class="el-menu-demo"
  7. mode="horizontal"
  8. @select="handleSelect"
  9. >
  10. <el-menu-item
  11. v-for="(item, index) in indexList"
  12. :key="index"
  13. :index="item.id+''"
  14. >
  15. <el-button round>{{item.name}}</el-button>
  16. </el-menu-item>
  17. </el-menu>
  18. </div>
  19. <div class="left-pane">
  20. <el-input
  21. placeholder="请输入关键字"
  22. suffix-icon="el-icon-search"
  23. v-model="filterText"
  24. ></el-input>
  25. <div class="tree_container">
  26. <el-tree
  27. ref="tree"
  28. :data="indexSecondList"
  29. :props="defaultProps"
  30. node-key="id"
  31. default-expand-all
  32. :filter-node-method="filterNode"
  33. @node-click="handleNodeClick"
  34. >
  35. <span slot-scope="{node}">
  36. <span style="padding-left: 10px; vertical-align: text-bottom;">{{ node.label }}</span>
  37. </span>
  38. </el-tree>
  39. </div>
  40. </div>
  41. <div
  42. class="right-pane"
  43. v-if="tableData.length!=0"
  44. >
  45. <div>
  46. <p class="info">{{selectedIndexItem.name}}</p>
  47. <!-- <el-button class="new_button">新建</el-button> -->
  48. </div>
  49. <el-table
  50. ref="multipleTable"
  51. :data="tableData"
  52. tooltip-effect="dark"
  53. :header-cell-style="{ textAlign: 'center' }"
  54. :cell-style="{ textAlign: 'center' }"
  55. style="width: 100%"
  56. >
  57. <!-- @selection-change="handleSelectionChange" -->
  58. <!-- <el-table-column
  59. type="selection"
  60. width="50"
  61. >
  62. </el-table-column> -->
  63. <el-table-column
  64. prop="name"
  65. label="指标名称"
  66. >
  67. </el-table-column>
  68. <!-- <el-table-column
  69. prop="indexUnit"
  70. label="指标单位"
  71. >
  72. </el-table-column> -->
  73. <el-table-column
  74. prop="defaultValue"
  75. label="默认值"
  76. >
  77. </el-table-column>
  78. <el-table-column
  79. prop="compare"
  80. label="比较值"
  81. >
  82. </el-table-column>
  83. <el-table-column
  84. prop="rule"
  85. label="计算规则"
  86. >
  87. </el-table-column>
  88. <el-table-column
  89. prop="operation"
  90. label="操作"
  91. >
  92. <template slot-scope="scope">
  93. <el-button
  94. size="mini"
  95. type="text"
  96. @click="edit(scope.row)"
  97. >编辑</el-button>
  98. </template>
  99. </el-table-column>
  100. </el-table>
  101. </div>
  102. <div class="bottom">
  103. <page
  104. class="page"
  105. :paginationData="paginationData"
  106. ></page>
  107. </div>
  108. <editDialog
  109. ref="editDialog"
  110. v-bind="{
  111. update:getSecondListAfterUpdate,
  112. beforeFrom:selectedSingleIndex
  113. }"
  114. ></editDialog>
  115. </div>
  116. </template>
  117. <script>
  118. import page from "@/components/pagination/index";
  119. // import dropdown from "@/components/Dropdown/index";
  120. import editDialog from "./dialog/editDialog.vue";
  121. import api from "@/api/systemConfig/api";
  122. export default {
  123. components: {
  124. editDialog,
  125. page,
  126. // dropdown,
  127. },
  128. data() {
  129. return {
  130. total: 0,
  131. filterText: "",
  132. show: true,
  133. value: "test",
  134. activeIndex: "1",
  135. indexList: [],
  136. indexSecondList: [],
  137. defaultProps: {
  138. children: "children",
  139. label: "name",
  140. },
  141. selectedIndexItem: null,
  142. tableData: [],
  143. selectedSingleIndex: null,
  144. paginationData: {
  145. pageSize: 10,
  146. pagerCount: 5,
  147. currentPage: 1,
  148. pageSizes: [5, 10, 20, 30],
  149. total: 0,
  150. currentChange: (val) => {
  151. this.handlePageChange(val);
  152. },
  153. handleSizeChange: (val) => {
  154. this.handleSizeChange(val);
  155. },
  156. },
  157. };
  158. },
  159. mounted() {
  160. this.getIndexList();
  161. },
  162. watch: {
  163. filterText(val) {
  164. this.$refs.tree.filter(val);
  165. },
  166. },
  167. methods: {
  168. filterNode(value, data) {
  169. if (!value) return true;
  170. return data.name.indexOf(value) !== -1;
  171. },
  172. handleSelect(key, keyPath) {
  173. this.activeIndex = key;
  174. this.indexSecondList =
  175. this.indexList[Number(this.activeIndex) - 1].children;
  176. },
  177. handleNodeClick(data, node) {
  178. this.selectedIndexItem = data;
  179. this.resetPageConfig();
  180. this.handlePageChange(1);
  181. },
  182. handlePageChange(val) {
  183. this.paginationData.currentPage = val;
  184. this.getSecondList({
  185. parent_id: this.selectedIndexItem.id,
  186. page_size: this.paginationData.pageSize,
  187. page: val,
  188. })
  189. .then((result) => {})
  190. .catch((err) => {});
  191. },
  192. handleSizeChange(val) {
  193. this.paginationData.pageSize = val;
  194. this.getSecondList({
  195. parent_id: this.selectedIndexItem.id,
  196. page_size: val,
  197. page: this.paginationData.currentPage,
  198. })
  199. .then((result) => {})
  200. .catch((err) => {});
  201. },
  202. resetPageConfig(obj) {
  203. let t = {
  204. pageSize: 10,
  205. pagerCount: 5,
  206. currentPage: 1,
  207. pageSizes: [5, 10, 20, 30],
  208. total: 30,
  209. currentChange: (val) => {
  210. this.handlePageChange(val);
  211. },
  212. handleSizeChange: (val) => {
  213. this.handleSizeChange(val);
  214. },
  215. };
  216. if (obj != null || obj != undefined) {
  217. for (const key in obj) {
  218. t[key] = obj[key];
  219. }
  220. this.paginationData = t;
  221. }
  222. },
  223. getIndexList() {
  224. let that = this;
  225. return new Promise((resolve, reject) => {
  226. api
  227. .getIndexList({ id: -1 })
  228. .then((result) => {
  229. that.indexList = result.data.data.data;
  230. that.indexSecondList =
  231. that.indexList[Number(that.activeIndex) - 1].children;
  232. resolve();
  233. })
  234. .catch((err) => {});
  235. });
  236. },
  237. getSecondList(param) {
  238. let that = this;
  239. return new Promise((resolve, reject) => {
  240. api
  241. .getIndexSecondList(param)
  242. .then((result) => {
  243. that.tableData = result.data.data.data.list;
  244. that.paginationData.total = result.data.data.data.total
  245. // "compare": null,
  246. // "defaultValue": "0",
  247. // "id": 4,
  248. // "isDel": 0,
  249. // "name": "\u4eca\u65e5\u79bb\u5f00\u5927\u697c(\u4eba)",
  250. // "parentId": 7,
  251. // "remark": null,
  252. // "rule": null,
  253. // "units": "",
  254. // "useSite": null
  255. })
  256. .catch((err) => {});
  257. });
  258. },
  259. getSecondListAfterUpdate() {
  260. this.resetPageConfig({
  261. currentPage: 1,
  262. });
  263. this.handlePageChange(1);
  264. },
  265. edit(data) {
  266. this.$refs.editDialog.dialogVisible = true;
  267. this.selectedSingleIndex = data;
  268. },
  269. },
  270. };
  271. </script>
  272. <style lang="less" scoped>
  273. .container {
  274. position: relative;
  275. width: 100%;
  276. height: 100%;
  277. line-height: 20px;
  278. background-color: rgba(255, 255, 255, 1);
  279. color: rgba(16, 16, 16, 1);
  280. font-size: 14px;
  281. .header {
  282. .el-menu-item {
  283. font-size: 16px;
  284. }
  285. .el-menu.el-menu--horizontal {
  286. border-bottom: 0px solid #e6e6e6;
  287. .el-menu-item {
  288. border-bottom: 0px;
  289. padding-left: 10px;
  290. padding-right: 10px;
  291. .el-button {
  292. color: #606266;
  293. border-color: #ebebeb;
  294. border: 1px solid #ebebeb;
  295. }
  296. }
  297. > .el-menu-item.is-active {
  298. border-bottom: 0px;
  299. .el-button {
  300. color: #ffffff;
  301. border-color: #2ea8e6;
  302. background-color: #2ea8e6;
  303. }
  304. }
  305. }
  306. }
  307. .left-pane {
  308. width: 300px;
  309. padding: 15px;
  310. height: calc(100% - 90px);
  311. display: inline-block;
  312. .tree_container {
  313. height: calc(100% - 45px);
  314. margin-top: 10px;
  315. margin-bottom: 10px;
  316. overflow: hidden;
  317. overflow-y: auto;
  318. .el-tree {
  319. height: 100%;
  320. background-color: #fafafa;
  321. /deep/.el-tree-node__content {
  322. align-items: center;
  323. height: 30px;
  324. cursor: pointer;
  325. font-size: 16px;
  326. position: relative;
  327. color: #999999;
  328. padding-top: 10px;
  329. padding-left: 30px !important;
  330. .operate_btns {
  331. position: absolute;
  332. right: 20px;
  333. display: none;
  334. }
  335. &:hover,
  336. :focus-within {
  337. background-color: #f7fbff;
  338. .operate_btns {
  339. display: inline;
  340. }
  341. }
  342. }
  343. /deep/.el-tree-node__children {
  344. .el-tree-node__content {
  345. padding-left: 60px !important;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. .right-pane {
  352. box-sizing: border-box;
  353. padding: 15px;
  354. width: calc(100% - 330px);
  355. height: calc(100% - 120px);
  356. display: inline-block;
  357. vertical-align: top;
  358. .info {
  359. text-align: left;
  360. padding: 10px;
  361. font-size: 25px;
  362. }
  363. .new_button {
  364. padding: 5px;
  365. width: 100px;
  366. position: relative;
  367. left: 42%;
  368. text-align: center;
  369. font-size: 16px;
  370. color: #fff;
  371. background: #3da0d6;
  372. }
  373. .el-table {
  374. margin-top: 10px;
  375. }
  376. .el-select {
  377. width: 80px;
  378. margin-right: 20px;
  379. }
  380. }
  381. .bottom {
  382. position: absolute;
  383. left: 345px;
  384. right: 16px;
  385. bottom: 30px;
  386. height: 50px;
  387. line-height: 20px;
  388. text-align: center;
  389. .checkbox {
  390. position: absolute;
  391. left: 30px;
  392. top: 15px;
  393. font-size: 14px;
  394. }
  395. .check-cancel {
  396. position: absolute;
  397. // line-height: 20px;
  398. font-size: 14px;
  399. text-align: center;
  400. left: 140px;
  401. top: 10px;
  402. }
  403. }
  404. }
  405. </style>