main.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div>
  3. <el-dialog
  4. title="客户信息"
  5. class="el-dialogDeep"
  6. :visible.sync="portinfoVisible"
  7. width="60%"
  8. append-to-body
  9. @closed="closed"
  10. v-dialog-drag
  11. >
  12. <span>
  13. <el-row>
  14. <el-col :span="5">
  15. <el-scrollbar>
  16. <basic-container>
  17. <avue-tree
  18. :option="treeOption"
  19. :data="treeData"
  20. @node-click="nodeClick"
  21. />
  22. </basic-container>
  23. </el-scrollbar>
  24. </el-col>
  25. <el-col :span="19">
  26. <avue-crud
  27. :option="tableOption"
  28. :data="dataList"
  29. ref="crud"
  30. v-model="form"
  31. :page.sync="page"
  32. @search-change="searchChange"
  33. @refresh-change="refreshChange"
  34. @selection-change="selectionChange"
  35. @on-load="onLoad"
  36. @tree-load="treeLoad"
  37. :cell-style="cellStyle"
  38. >
  39. </avue-crud>
  40. </el-col>
  41. </el-row>
  42. </span>
  43. <span slot="footer" class="dialog-footer">
  44. <el-button @click="portinfoVisible = false">取 消</el-button>
  45. <el-button
  46. type="primary"
  47. @click="importCorp"
  48. :disabled="selectionList.length != 1"
  49. >确 定</el-button
  50. >
  51. </span>
  52. </el-dialog>
  53. </div>
  54. </template>
  55. <script>
  56. import option from "./configuration/mainList.json";
  57. import {
  58. customerList,
  59. getDeptLazyTree
  60. } from "@/api/basicData/customerInformation";
  61. export default {
  62. data() {
  63. return {
  64. loading: true,
  65. dataList: [],
  66. tableOption: option,
  67. form: {},
  68. search: {},
  69. treeDeptId: "",
  70. treeDeptName: "",
  71. height: window.innerHeight - 500,
  72. page: {
  73. currentPage: 1,
  74. total: 0,
  75. pageSize: 10
  76. },
  77. treeOption: {
  78. nodeKey: "id",
  79. lazy: true,
  80. treeLoad: function(node, resolve) {
  81. const parentId = node.level === 0 ? 0 : node.data.id;
  82. getDeptLazyTree(parentId).then(res => {
  83. resolve(
  84. res.data.data.map(item => {
  85. return {
  86. ...item,
  87. leaf: !item.hasChildren
  88. };
  89. })
  90. );
  91. });
  92. },
  93. addBtn: false,
  94. menu: false,
  95. size: "small",
  96. props: {
  97. labelText: "标题",
  98. label: "title",
  99. value: "value",
  100. children: "children"
  101. }
  102. },
  103. portinfoVisible: false,
  104. selectionList: []
  105. };
  106. },
  107. created() {},
  108. mounted() {
  109. option.height = window.innerHeight - 500;
  110. },
  111. methods: {
  112. cellStyle() {
  113. return "padding:0;height:40px;";
  114. },
  115. init() {
  116. this.portinfoVisible = true;
  117. },
  118. closed() {
  119. this.$refs.crud.toggleSelection();
  120. },
  121. importCorp() {
  122. this.$emit("importCorp", {
  123. id: this.selectionList[0].id,
  124. name: this.selectionList[0].cname
  125. });
  126. this.portinfoVisible = false;
  127. },
  128. onLoad(page, params = { parentId: 0 }) {
  129. let queryParams = Object.assign({}, params, {
  130. size: page.pageSize,
  131. current: page.currentPage,
  132. corpsTypeId: this.treeDeptId
  133. });
  134. customerList(queryParams).then(res => {
  135. this.dataList = res.data.data.records;
  136. this.page.total = res.data.data.total;
  137. if (this.page.total) {
  138. this.tableOption.height = window.innerHeight - 500;
  139. } else {
  140. this.tableOption.height = window.innerHeight - 200;
  141. }
  142. });
  143. },
  144. selectionChange(list) {
  145. this.selectionList = list;
  146. },
  147. sizeChange(val) {
  148. this.page.pageSize = val;
  149. this.getList();
  150. },
  151. currentChange(val) {
  152. this.page.currentPage = val;
  153. this.getList();
  154. },
  155. //刷新触发
  156. refreshChange() {
  157. this.page = {
  158. pageSize: 10,
  159. pagerCount: 1,
  160. total: 0
  161. };
  162. },
  163. saveColumn(row, column) {
  164. console.log(row, column);
  165. },
  166. //列表内展开树节点
  167. treeLoad(tree, treeNode, resolve) {
  168. const parentId = tree.id;
  169. customerList({ parentId: parentId }).then(res => {
  170. resolve(res.data.data.records);
  171. });
  172. },
  173. nodeClick(data) {
  174. this.treeDeptId = data.id;
  175. this.page.currentPage = 1;
  176. console.log(this.treeDeptId);
  177. this.onLoad(this.page);
  178. }
  179. }
  180. };
  181. </script>
  182. <style scoped lang="scss"></style>