main.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. :close-on-click-modal="false"
  12. v-dialog-drag
  13. >
  14. <span>
  15. <el-row>
  16. <el-col :span="4">
  17. <el-scrollbar>
  18. <basic-container>
  19. <avue-tree
  20. :option="treeOption"
  21. :data="treeData"
  22. @node-click="nodeClick"
  23. :style="treeStyle"
  24. />
  25. </basic-container>
  26. </el-scrollbar>
  27. </el-col>
  28. <el-col :span="20">
  29. <avue-crud
  30. :option="tableOption"
  31. :data="dataList"
  32. ref="crud"
  33. v-model="form"
  34. :page.sync="page"
  35. @search-change="searchChange"
  36. @refresh-change="refreshChange"
  37. @selection-change="selectionChange"
  38. @on-load="onLoad"
  39. @tree-load="treeLoad"
  40. :cell-style="cellStyle"
  41. >
  42. </avue-crud>
  43. </el-col>
  44. </el-row>
  45. </span>
  46. <span slot="footer" class="dialog-footer">
  47. <el-button @click="portinfoVisible = false">取 消</el-button>
  48. <el-button
  49. type="primary"
  50. @click="importCorp"
  51. :disabled="selectionList.length != 1"
  52. >确 定</el-button
  53. >
  54. </span>
  55. </el-dialog>
  56. </div>
  57. </template>
  58. <script>
  59. import option from "./configuration/mainList.json";
  60. import {
  61. customerList,
  62. getDeptLazyTree
  63. } from "@/api/basicData/customerInformation";
  64. export default {
  65. data() {
  66. return {
  67. loading: true,
  68. dataList: [],
  69. tableOption: option,
  70. form: {},
  71. search: {},
  72. treeDeptId: "",
  73. treeDeptName: "",
  74. page: {
  75. currentPage: 1,
  76. total: 0,
  77. pageSize: 10
  78. },
  79. treeOption: {
  80. nodeKey: "id",
  81. lazy: true,
  82. treeLoad: function(node, resolve) {
  83. const parentId = node.level === 0 ? 0 : node.data.id;
  84. getDeptLazyTree({ parentId: parentId, corpType: "KH" }).then(res => {
  85. resolve(
  86. res.data.data.map(item => {
  87. return {
  88. ...item,
  89. leaf: !item.hasChildren
  90. };
  91. })
  92. );
  93. });
  94. },
  95. addBtn: false,
  96. menu: false,
  97. size: "small",
  98. props: {
  99. labelText: "标题",
  100. label: "title",
  101. value: "value",
  102. children: "children"
  103. }
  104. },
  105. portinfoVisible: false,
  106. selectionList: [],
  107. treeStyle: "height:" + (window.innerHeight - 315) + "px"
  108. };
  109. },
  110. created() {},
  111. mounted() {},
  112. methods: {
  113. cellStyle() {
  114. return "padding:0;height:40px;";
  115. },
  116. init() {
  117. this.portinfoVisible = true;
  118. },
  119. closed() {
  120. this.$refs.crud.toggleSelection();
  121. },
  122. importCorp() {
  123. this.$emit("importCorp", {
  124. id: this.selectionList[0].id,
  125. name: this.selectionList[0].cname
  126. });
  127. this.portinfoVisible = false;
  128. },
  129. onLoad(page, params = { parentId: 0 }) {
  130. let queryParams = Object.assign({}, params, {
  131. size: page.pageSize,
  132. current: page.currentPage,
  133. corpsTypeId: this.treeDeptId,
  134. corpType: "KH"
  135. });
  136. customerList(queryParams).then(res => {
  137. this.dataList = res.data.data.records;
  138. this.page.total = res.data.data.total;
  139. if (this.page.total) {
  140. this.tableOption.height = window.innerHeight - 350;
  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>