main.vue 4.4 KB

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