index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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. <template slot-scope="scope" slot="menu">
  33. <el-button
  34. type="text"
  35. icon="el-icon-view"
  36. size="small"
  37. @click.stop="beforeOpenPage(scope.row,scope.index)"
  38. >查看
  39. </el-button>
  40. <el-button
  41. type="text"
  42. icon="el-icon-edit"
  43. size="small"
  44. @click.stop="editOpen(scope.row,scope.index)"
  45. >编辑
  46. </el-button>
  47. <el-button
  48. type="text"
  49. icon="el-icon-delete"
  50. size="small"
  51. @click.stop="rowDel(scope.row,scope.index)"
  52. >删除
  53. </el-button>
  54. </template>
  55. </avue-crud>
  56. </basic-container>
  57. </el-col>
  58. </el-row>
  59. </template>
  60. <script>
  61. import option from "./configuration/mainList.json";
  62. import {customerList, typeSave,detail,deleteDetails,getDeptLazyTree} from "@/api/basicData/customerInformation"
  63. export default {
  64. name: "customerInformation",
  65. data() {
  66. return {
  67. form: {},
  68. option: option,
  69. parentId:0,
  70. dataList: [],
  71. treeOption: {
  72. nodeKey: 'id',
  73. lazy: true,
  74. treeLoad: function (node, resolve) {
  75. const parentId = (node.level === 0) ? 0 : node.data.id;
  76. getDeptLazyTree(parentId).then(res => {
  77. resolve(res.data.data.map(item => {
  78. return {
  79. ...item,
  80. leaf: !item.hasChildren
  81. }
  82. }))
  83. });
  84. },
  85. addBtn: false,
  86. menu: false,
  87. size: 'small',
  88. props: {
  89. labelText: '标题',
  90. label: 'title',
  91. value: 'value',
  92. children: 'children'
  93. }
  94. },
  95. page: {
  96. pageSize: 10,
  97. pagerCount: 5,
  98. total: 0,
  99. }
  100. }
  101. },
  102. created() {
  103. console.log('wangbadan')
  104. // this.onLoad()
  105. },
  106. methods: {
  107. nodeClick(data) {
  108. this.treeDeptId = data.id;
  109. this.page.currentPage = 1;
  110. this.onLoad(this.page);
  111. },
  112. //删除列表后面的删除按钮触发触发(row, index, done)
  113. rowDel(row, index, done) {
  114. this.$confirm("确定将选择数据删除?", {
  115. confirmButtonText: "确定",
  116. cancelButtonText: "取消",
  117. type: "warning"
  118. }).then(() => {
  119. return deleteDetails(row.id);
  120. }).then(() => {
  121. this.$message({
  122. type: "success",
  123. message: "操作成功!"
  124. });
  125. this.page.currentPage = 1;
  126. this.onLoad(this.page, {parentId:0});
  127. });
  128. },
  129. //修改时的修改按钮点击触发
  130. rowUpdate(row, index, done, loading) {
  131. typeSave(row).then(() => {
  132. this.$message({
  133. type: "success",
  134. message: "操作成功!"
  135. });
  136. // 数据回调进行刷新
  137. done(row);
  138. }, error => {
  139. window.console.log(error);
  140. loading();
  141. });
  142. },
  143. //新增修改时保存触发
  144. rowSave(row, done, loading) {
  145. typeSave(row).then(res => {
  146. console.log(res)
  147. done()
  148. })
  149. },
  150. //查询全部
  151. initData(){
  152. customerList().then(res => {
  153. console.log(this.form);
  154. const column = this.findObject(this.option.column, "parentId");
  155. column.dicData = res.data.data.records;
  156. });
  157. },
  158. //新增子项触发
  159. handleAdd(row) {
  160. this.parentId = row.id;
  161. const column = this.findObject(this.option.column, "parentId");
  162. column.value = row.id;
  163. column.addDisabled = true;
  164. this.$refs.crud.rowAdd();
  165. },
  166. //查看跳转页面
  167. beforeOpenPage(row,index) {
  168. this.$router.push({
  169. path: "/detailsPageEdit",
  170. query: { id: JSON.stringify(row.id) },
  171. });
  172. },
  173. //新增跳转页面
  174. beforeOpen(row,index) {
  175. this.$router.push({
  176. path: "/detailsPageEdit",
  177. query: { id: JSON.stringify(row.id) },
  178. });
  179. },
  180. editOpen(row,index){
  181. this.$router.push({
  182. path: "/detailsPageEdit",
  183. query: { id: JSON.stringify(row.id) },
  184. });
  185. },
  186. //点击新增时触发
  187. beforeClose(done) {
  188. this.parentId = "";
  189. const column = this.findObject(this.option.column, "parentId");
  190. column.value = "";
  191. column.addDisabled = false;
  192. done();
  193. },
  194. //点击搜索按钮触发
  195. searchChange(params, done) {
  196. console.log(params)
  197. this.page.currentPage = 1;
  198. this.onLoad(this.page, params);
  199. done()
  200. },
  201. searchReset() {
  202. console.log('1')
  203. },
  204. selectionChange() {
  205. console.log('1')
  206. },
  207. currentChange() {
  208. console.log('1')
  209. },
  210. sizeChange() {
  211. console.log('1')
  212. },
  213. refreshChange() {
  214. console.log('1')
  215. },
  216. onLoad(page, params = {parentId:0}) {
  217. let queryParams = Object.assign({}, params, {pageSize: page.pageSize, pageNum: page.currentPage,corpsTypeId:this.treeDeptId})
  218. customerList(queryParams).then(res => {
  219. this.dataList = res.data.data.records
  220. this.page.total = res.data.data.total
  221. })
  222. },
  223. //树桩列点击展开触发
  224. treeLoad(tree, treeNode, resolve) {
  225. const parentId = tree.id;
  226. customerList({parentId:parentId}).then(res => {
  227. resolve(res.data.data.records);
  228. });
  229. },
  230. }
  231. }
  232. </script>
  233. <style scoped>
  234. </style>