index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <el-row>
  3. <el-col :span="5">
  4. <div class="box">
  5. <el-scrollbar>
  6. <basic-container>
  7. <avue-tree
  8. :option="treeOption"
  9. :data="treeData"
  10. @node-click="nodeClick"
  11. />
  12. </basic-container>
  13. </el-scrollbar>
  14. </div>
  15. </el-col>
  16. <el-col :span="19">
  17. <basic-container>
  18. <avue-crud
  19. :option="option"
  20. :data="dataList"
  21. ref="crud"
  22. v-model="form"
  23. :page.sync="page"
  24. @row-del="rowDel"
  25. @row-update="rowUpdate"
  26. :before-open="beforeOpen"
  27. :before-close="beforeClose"
  28. @row-save="rowSave"
  29. @search-change="searchChange"
  30. @search-reset="searchReset"
  31. @selection-change="selectionChange"
  32. @current-change="currentChange"
  33. @size-change="sizeChange"
  34. @refresh-change="refreshChange"
  35. @on-load="onLoad"
  36. @tree-load="treeLoad"
  37. >
  38. <template slot="menuLeft">
  39. <el-button
  40. icon="el-icon-printer"
  41. size="small"
  42. type="primary"
  43. @click.stop="openReport()"
  44. >报表
  45. </el-button>
  46. </template>
  47. <template slot-scope="scope" slot="menu">
  48. <el-button
  49. type="text"
  50. icon="el-icon-view"
  51. size="small"
  52. @click.stop="beforeOpenPage(scope.row, scope.index)"
  53. >查看
  54. </el-button>
  55. <el-button
  56. type="text"
  57. icon="el-icon-edit"
  58. size="small"
  59. @click.stop="editOpen(scope.row, scope.index)"
  60. >编辑
  61. </el-button>
  62. <el-button
  63. type="text"
  64. icon="el-icon-delete"
  65. size="small"
  66. @click.stop="rowDel(scope.row, scope.index)"
  67. >删除
  68. </el-button>
  69. </template>
  70. </avue-crud>
  71. <report-dialog
  72. :switchDialog="switchDialog"
  73. @onClose="onClose()"
  74. ></report-dialog>
  75. </basic-container>
  76. </el-col>
  77. </el-row>
  78. </template>
  79. <script>
  80. import option from "./configuration/mainList.json";
  81. import {
  82. customerList,
  83. typeSave,
  84. detail,
  85. deleteDetails,
  86. getDeptLazyTree
  87. } from "@/api/basicData/customerInformation";
  88. import reportDialog from "@/components/report-dialog/main";
  89. export default {
  90. name: "customerInformation",
  91. data() {
  92. return {
  93. reportQuery:{},
  94. switchDialog: false,
  95. treeDeptId:"",
  96. form: {},
  97. option: option,
  98. parentId: 0,
  99. dataList: [],
  100. treeOption: {
  101. nodeKey: "id",
  102. lazy: true,
  103. treeLoad: function(node, resolve) {
  104. const parentId = node.level === 0 ? 0 : node.data.id;
  105. getDeptLazyTree(parentId).then(res => {
  106. resolve(
  107. res.data.data.map(item => {
  108. return {
  109. ...item,
  110. leaf: !item.hasChildren
  111. };
  112. })
  113. );
  114. });
  115. },
  116. addBtn: false,
  117. menu: false,
  118. size: "small",
  119. props: {
  120. labelText: "标题",
  121. label: "title",
  122. value: "value",
  123. children: "children"
  124. }
  125. },
  126. page: {
  127. pageSize: 10,
  128. pagerCount: 5,
  129. total: 0
  130. }
  131. };
  132. },
  133. components: {
  134. reportDialog
  135. },
  136. created() {
  137. console.log("wangbadan");
  138. // this.onLoad()
  139. },
  140. methods: {
  141. nodeClick(data) {
  142. this.treeDeptId = data.id;
  143. this.page.currentPage = 1;
  144. this.onLoad(this.page);
  145. },
  146. //删除列表后面的删除按钮触发触发(row, index, done)
  147. rowDel(row, index, done) {
  148. this.$confirm("确定将选择数据删除?", {
  149. confirmButtonText: "确定",
  150. cancelButtonText: "取消",
  151. type: "warning"
  152. })
  153. .then(() => {
  154. return deleteDetails(row.id);
  155. })
  156. .then(() => {
  157. this.$message({
  158. type: "success",
  159. message: "操作成功!"
  160. });
  161. this.page.currentPage = 1;
  162. this.onLoad(this.page, { parentId: 0 });
  163. });
  164. },
  165. //修改时的修改按钮点击触发
  166. rowUpdate(row, index, done, loading) {
  167. typeSave(row).then(
  168. () => {
  169. this.$message({
  170. type: "success",
  171. message: "操作成功!"
  172. });
  173. // 数据回调进行刷新
  174. done(row);
  175. },
  176. error => {
  177. window.console.log(error);
  178. loading();
  179. }
  180. );
  181. },
  182. //新增修改时保存触发
  183. rowSave(row, done, loading) {
  184. typeSave(row).then(res => {
  185. console.log(res);
  186. done();
  187. });
  188. },
  189. //查询全部
  190. initData() {
  191. customerList().then(res => {
  192. console.log(this.form);
  193. const column = this.findObject(this.option.column, "parentId");
  194. column.dicData = res.data.data.records;
  195. });
  196. },
  197. //新增子项触发
  198. handleAdd(row) {
  199. this.parentId = row.id;
  200. const column = this.findObject(this.option.column, "parentId");
  201. column.value = row.id;
  202. column.addDisabled = true;
  203. this.$refs.crud.rowAdd();
  204. },
  205. //查看跳转页面
  206. beforeOpenPage(row, index) {
  207. this.$router.push({
  208. path: "/detailsPageEdit",
  209. query: { id: JSON.stringify(row.id) }
  210. });
  211. },
  212. //新增跳转页面
  213. beforeOpen(row, index) {
  214. this.$router.push({
  215. path: "/detailsPageEdit",
  216. query: { id: JSON.stringify(row.id),treeDeptId:this.treeDeptId }
  217. });
  218. },
  219. editOpen(row, index) {
  220. this.$router.push({
  221. path: "/detailsPageEdit",
  222. query: { id: JSON.stringify(row.id) }
  223. });
  224. },
  225. //点击新增时触发
  226. beforeClose(done) {
  227. this.parentId = "";
  228. const column = this.findObject(this.option.column, "parentId");
  229. column.value = "";
  230. column.addDisabled = false;
  231. done();
  232. },
  233. //点击搜索按钮触发
  234. searchChange(params, done) {
  235. console.log(params);
  236. this.page.currentPage = 1;
  237. this.onLoad(this.page, params);
  238. done();
  239. },
  240. //搜索重置按钮触发
  241. searchReset() {
  242. this.treeDeptId = "";
  243. this.onLoad(this.page);
  244. },
  245. selectionChange() {
  246. console.log("1");
  247. },
  248. currentChange() {
  249. console.log("1");
  250. },
  251. sizeChange() {
  252. console.log("1");
  253. },
  254. refreshChange() {
  255. console.log("1");
  256. },
  257. onLoad(page, params = { parentId: 0 }) {
  258. let queryParams = Object.assign({}, params, {
  259. size: page.pageSize,
  260. current: page.currentPage,
  261. corpsTypeId: this.treeDeptId
  262. });
  263. customerList(queryParams).then(res => {
  264. this.dataList = res.data.data.records;
  265. console.log(res.data.data.total);
  266. this.page.total = res.data.data.total;
  267. console.log(this.page);
  268. });
  269. },
  270. //树桩列点击展开触发
  271. treeLoad(tree, treeNode, resolve) {
  272. const parentId = tree.id;
  273. customerList({ parentId: parentId }).then(res => {
  274. resolve(res.data.data.records);
  275. });
  276. },
  277. openReport() {
  278. this.switchDialog =! this.switchDialog;
  279. },
  280. onClose(val) {
  281. this.switchDialog = val;
  282. }
  283. }
  284. };
  285. </script>
  286. <style scoped></style>