main.vue 4.7 KB

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