index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <el-row>
  3. <el-col :span="5">
  4. <div class="box">
  5. <el-scrollbar>
  6. <basic-container>
  7. <avue-tree :option="treeOption" :data="treeData" @node-click="nodeClick"/>
  8. </basic-container>
  9. </el-scrollbar>
  10. </div>
  11. </el-col>
  12. <el-col :span="19">
  13. <basic-container>
  14. <avue-crud :option="option"
  15. :data="dataList"
  16. ref="crud"
  17. v-model="form"
  18. :page.sync="page"
  19. @row-del="rowDel"
  20. @row-update="rowUpdate"
  21. :before-open="beforeOpen"
  22. :before-close="beforeClose"
  23. @row-save="rowSave"
  24. @search-change="searchChange"
  25. @search-reset="searchReset"
  26. @selection-change="selectionChange"
  27. @current-change="currentChange"
  28. @size-change="sizeChange"
  29. @refresh-change="refreshChange"
  30. @on-load="onLoad"
  31. @tree-load="treeLoad">
  32. </avue-crud>
  33. </basic-container>
  34. </el-col>
  35. </el-row>
  36. </template>
  37. <script>
  38. import option from "./configuration/mainList.json";
  39. import {customerList, typeSave,detail,deleteDetails,getDeptLazyTree,getDeptTree} from "@/api/basicData/basicFeesDesc"
  40. export default {
  41. name: "customerInformation",
  42. data() {
  43. return {
  44. form: {},
  45. option: option,
  46. treeOption: {
  47. nodeKey: 'id',
  48. lazy: true,
  49. treeLoad: function (node, resolve) {
  50. const parentId = (node.level === 0) ? 0 : node.data.id;
  51. getDeptLazyTree(parentId).then(res => {
  52. resolve(res.data.data.map(item => {
  53. return {
  54. ...item,
  55. leaf: !item.hasChildren
  56. }
  57. }))
  58. });
  59. },
  60. addBtn: false,
  61. menu: false,
  62. size: 'small',
  63. props: {
  64. labelText: '标题',
  65. label: 'title',
  66. value: 'value',
  67. children: 'children'
  68. }
  69. },
  70. parentId:0,
  71. dataList: [],
  72. page: {
  73. pageSize: 10,
  74. pagerCount: 5,
  75. total: 0,
  76. },
  77. treeDeptId:'',
  78. }
  79. },
  80. created() {
  81. // customerList({parentId:0}).then(res => {
  82. // console.log(res.data.data.records)
  83. // this.dataList = res.data.data.records
  84. // })
  85. },
  86. methods: {
  87. //展开主页左边类型
  88. nodeClick(data) {
  89. this.treeDeptId = data.id;
  90. this.page.currentPage = 1;
  91. this.onLoad(this.page);
  92. },
  93. //删除列表后面的删除按钮触发触发(row, index, done)
  94. rowDel(row, index, done) {
  95. this.$confirm("确定将选择数据删除?", {
  96. confirmButtonText: "确定",
  97. cancelButtonText: "取消",
  98. type: "warning"
  99. }).then(() => {
  100. return deleteDetails(row.id);
  101. }).then(() => {
  102. this.$message({
  103. type: "success",
  104. message: "操作成功!"
  105. });
  106. // 数据回调进行刷新
  107. done(row);
  108. });
  109. },
  110. //修改时的修改按钮点击触发
  111. rowUpdate(row, index, done, loading) {
  112. typeSave(row).then(() => {
  113. this.$message({
  114. type: "success",
  115. message: "操作成功!"
  116. });
  117. // 数据回调进行刷新
  118. done(row);
  119. }, error => {
  120. window.console.log(error);
  121. loading();
  122. });
  123. },
  124. //新增修改时保存触发
  125. rowSave(row, done, loading) {
  126. console.log(row)
  127. row.feesTypeId = row.feesTypeId.join(',')
  128. typeSave(row).then(res => {
  129. this.page.currentPage = 1;
  130. this.onLoad(this.page, {parentId: 0});
  131. console.log(res)
  132. done()
  133. })
  134. },
  135. //查询全部
  136. initData(){
  137. getDeptTree().then(res => {
  138. console.log(this.form);
  139. const column = this.findObject(this.option.column, "feesTypeId");
  140. column.dicData = res.data.data;
  141. });
  142. },
  143. //新增子项触发
  144. handleAdd(row) {
  145. this.parentId = row.id;
  146. // const column = this.findObject(this.option.column, "parentId");
  147. // column.value = row.id;
  148. // column.addDisabled = true;
  149. this.$refs.crud.rowAdd();
  150. },
  151. //新增子项和新增触发查询所有
  152. beforeOpen(done, type) {
  153. if (["add"].includes(type)) {
  154. this.option.column.forEach(e=>{
  155. if(e.prop=='feesTypeId'){
  156. this.$set(this.option.column,2,{...e,value:this.treeDeptId})
  157. }
  158. })
  159. }
  160. if (["add", "edit"].includes(type)) {
  161. this.initData();
  162. }
  163. if (["edit", "view"].includes(type)) {
  164. detail(this.form.id).then(res => {
  165. this.form = res.data.data;
  166. });
  167. }
  168. done();
  169. },
  170. //点击新增时触发
  171. beforeClose(done) {
  172. this.parentId = "";
  173. // const column = this.findObject(this.option.column, "parentId");
  174. // column.value = "";
  175. // column.addDisabled = false;
  176. done();
  177. },
  178. //点击搜索按钮触发
  179. searchChange(params, done) {
  180. this.page.currentPage = 1;
  181. this.onLoad(this.page, params);
  182. done()
  183. },
  184. //搜索重置按钮触发
  185. searchReset() {
  186. this.query = {};
  187. this.treeDeptId = '';
  188. this.onLoad(this.page);
  189. },
  190. selectionChange() {
  191. console.log('1')
  192. },
  193. currentChange() {
  194. console.log('1')
  195. },
  196. sizeChange() {
  197. console.log('1')
  198. },
  199. refreshChange() {
  200. console.log('1')
  201. },
  202. onLoad(page, params = {parentId:0}) {
  203. let queryParams = Object.assign({}, params, {size: page.pageSize, current: page.currentPage,parentId:0,feesTypeId:this.treeDeptId})
  204. customerList(queryParams).then(res => {
  205. this.dataList = res.data.data.records
  206. this.page.total = res.data.data.total
  207. })
  208. },
  209. //树桩列点击展开触发
  210. treeLoad(tree, treeNode, resolve) {
  211. const parentId = tree.id;
  212. customerList({parentId:parentId}).then(res => {
  213. resolve(res.data.data.records);
  214. });
  215. },
  216. }
  217. }
  218. </script>
  219. <style scoped>
  220. </style>