index.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <basic-container>
  3. <avue-crud :option="option"
  4. :data="dataList"
  5. ref="crud"
  6. v-model="form"
  7. :page.sync="page"
  8. @row-del="rowDel"
  9. @row-update="rowUpdate"
  10. :before-open="beforeOpen"
  11. :before-close="beforeClose"
  12. @row-save="rowSave"
  13. @search-change="searchChange"
  14. @search-reset="searchReset"
  15. @selection-change="selectionChange"
  16. @current-change="currentChange"
  17. @size-change="sizeChange"
  18. @refresh-change="refreshChange"
  19. @on-load="onLoad"
  20. @tree-load="treeLoad">
  21. <template slot-scope="scope" slot="menu">
  22. <el-button
  23. type="text"
  24. icon="el-icon-view"
  25. size="small"
  26. @click.stop="beforeOpenPage(scope.row,scope.index)"
  27. >查看
  28. </el-button>
  29. <el-button
  30. type="text"
  31. icon="el-icon-edit"
  32. size="small"
  33. @click.stop="editOpen(scope.row,scope.index)"
  34. >编辑
  35. </el-button>
  36. <el-button
  37. type="text"
  38. icon="el-icon-delete"
  39. size="small"
  40. @click.stop="rowDel(scope.row,scope.index)"
  41. >删除
  42. </el-button>
  43. </template>
  44. </avue-crud>
  45. </basic-container>
  46. </template>
  47. <script>
  48. import option from "./configuration/mainList.json";
  49. import {customerList, typeSave, deleteDetails} from "@/api/basicData/receipt"
  50. export default {
  51. name: "customerInformation",
  52. data() {
  53. return {
  54. form: {},
  55. option: option,
  56. parentId: 0,
  57. dataList: [],
  58. page: {
  59. pageSize: 10,
  60. pagerCount: 5,
  61. total: 0,
  62. }
  63. }
  64. },
  65. created() {
  66. // this.onLoad()
  67. },
  68. methods: {
  69. //删除列表后面的删除按钮触发触发(row, index, done)
  70. rowDel(row, index, done) {
  71. this.$confirm("确定将选择数据删除?", {
  72. confirmButtonText: "确定",
  73. cancelButtonText: "取消",
  74. type: "warning"
  75. }).then(() => {
  76. return deleteDetails(row.id);
  77. }).then(() => {
  78. this.$message({
  79. type: "success",
  80. message: "操作成功!"
  81. });
  82. this.page.currentPage = 1;
  83. this.onLoad(this.page, {parentId: 0});
  84. });
  85. },
  86. //修改时的修改按钮点击触发
  87. rowUpdate(row, index, done, loading) {
  88. typeSave(row).then(() => {
  89. this.$message({
  90. type: "success",
  91. message: "操作成功!"
  92. });
  93. // 数据回调进行刷新
  94. done(row);
  95. }, error => {
  96. window.console.log(error);
  97. loading();
  98. });
  99. },
  100. //新增修改时保存触发
  101. rowSave(row, done, loading) {
  102. typeSave(row).then(res => {
  103. console.log(res)
  104. done()
  105. })
  106. },
  107. //查询全部
  108. initData() {
  109. customerList().then(res => {
  110. console.log(this.form);
  111. const column = this.findObject(this.option.column, "parentId");
  112. column.dicData = res.data.data.records;
  113. });
  114. },
  115. //新增子项触发
  116. handleAdd(row) {
  117. this.parentId = row.id;
  118. const column = this.findObject(this.option.column, "parentId");
  119. column.value = row.id;
  120. column.addDisabled = true;
  121. this.$refs.crud.rowAdd();
  122. },
  123. //查看跳转页面
  124. beforeOpenPage(row, index) {
  125. this.$router.push({
  126. path: "/receipt_detailsPageEdit",
  127. query: {id: JSON.stringify(row.id)},
  128. });
  129. },
  130. //新增跳转页面
  131. beforeOpen(row, index) {
  132. this.$router.push({
  133. path: "/receipt_detailsPageEdit",
  134. query: {id: JSON.stringify(row.id)},
  135. });
  136. },
  137. editOpen(row, index) {
  138. this.$router.push({
  139. path: "/receipt_detailsPageEdit",
  140. query: {id: JSON.stringify(row.id)},
  141. });
  142. },
  143. //点击新增时触发
  144. beforeClose(done) {
  145. this.parentId = "";
  146. const column = this.findObject(this.option.column, "parentId");
  147. column.value = "";
  148. column.addDisabled = false;
  149. done();
  150. },
  151. //点击搜索按钮触发
  152. searchChange(params, done) {
  153. console.log(params)
  154. this.page.currentPage = 1;
  155. this.onLoad(this.page, params);
  156. done()
  157. },
  158. searchReset() {
  159. console.log('1')
  160. },
  161. selectionChange() {
  162. console.log('1')
  163. },
  164. currentChange() {
  165. console.log('1')
  166. },
  167. sizeChange() {
  168. console.log('1')
  169. },
  170. refreshChange() {
  171. console.log('1')
  172. },
  173. onLoad(page, params = {parentId: 0}) {
  174. let queryParams = Object.assign({}, params, {
  175. size: page.pageSize,
  176. current: page.currentPage,
  177. billType:'SH',
  178. corpsTypeId: this.treeDeptId
  179. })
  180. customerList(queryParams).then(res => {
  181. this.dataList = res.data.data.records
  182. this.page.total = res.data.data.total
  183. })
  184. },
  185. //树桩列点击展开触发
  186. treeLoad(tree, treeNode, resolve) {
  187. const parentId = tree.id;
  188. customerList({parentId: parentId}).then(res => {
  189. resolve(res.data.data.records);
  190. });
  191. },
  192. }
  193. }
  194. </script>
  195. <style scoped>
  196. </style>