main.vue 4.3 KB

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