index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <div>
  3. <basic-container v-if="isShow">
  4. <avue-crud :option="option"
  5. :data="dataList"
  6. ref="crud"
  7. v-model="form"
  8. :page.sync="page"
  9. @row-del="rowDel"
  10. @row-update="rowUpdate"
  11. :before-open="beforeOpen"
  12. :before-close="beforeClose"
  13. @row-save="rowSave"
  14. @search-change="searchChange"
  15. @search-reset="searchReset"
  16. @selection-change="selectionChange"
  17. @current-change="currentChange"
  18. @size-change="sizeChange"
  19. @refresh-change="refreshChange"
  20. @on-load="onLoad"
  21. @tree-load="treeLoad"
  22. @saveColumn="saveColumn">
  23. <template slot="menuLeft" slot-scope="{size}">
  24. <el-button type="success" :size="size" @click="copyOrder" :disabled="single">复制新单</el-button>
  25. <el-button type="info" :size="size" icon="el-icon-printer">报 表</el-button>
  26. </template>
  27. <template slot-scope="scope" slot="menu">
  28. <el-button
  29. type="text"
  30. icon="el-icon-view"
  31. size="small"
  32. @click.stop="beforeOpenPage(scope.row,scope.index)"
  33. >查看
  34. </el-button>
  35. <el-button
  36. type="text"
  37. icon="el-icon-edit"
  38. size="small"
  39. @click.stop="editOpen(scope.row,scope.index)"
  40. >编辑
  41. </el-button>
  42. <el-button
  43. type="text"
  44. icon="el-icon-delete"
  45. size="small"
  46. @click.stop="rowDel(scope.row,scope.index)"
  47. >删除
  48. </el-button>
  49. </template>
  50. </avue-crud>
  51. </basic-container>
  52. <detail-page
  53. ref="detail"
  54. @goBack="goBack"
  55. :detailData="detailData"
  56. v-else
  57. ></detail-page>
  58. </div>
  59. </template>
  60. <script>
  61. import option from "./configuration/mainList.json";
  62. import {customerList, typeSave, deleteDetails} from "@/api/basicData/receipt"
  63. import detailPage from "./detailsPageEdit";
  64. export default {
  65. name: "customerInformation",
  66. components: {
  67. detailPage
  68. },
  69. data() {
  70. return {
  71. form: {},
  72. option: {},
  73. parentId: 0,
  74. dataList: [],
  75. page: {
  76. pageSize: 10,
  77. pagerCount: 5,
  78. total: 0,
  79. },
  80. // 非单个禁用
  81. single: true,
  82. // 非多个禁用
  83. multiple: true,
  84. selection: [],
  85. isShow: true,
  86. detailData: {},
  87. }
  88. },
  89. async created() {
  90. this.option = await this.getColumnData(this.getColumnName(23), option);
  91. // this.onLoad()
  92. if (this.$route.query.form) {
  93. console.log(this.$route.query.form)
  94. this.detailData = {
  95. form: this.$route.query.form,
  96. };
  97. this.isShow = false;
  98. }
  99. },
  100. methods: {
  101. //删除列表后面的删除按钮触发触发(row, index, done)
  102. rowDel(row, index, done) {
  103. this.$confirm("确定将选择数据删除?", {
  104. confirmButtonText: "确定",
  105. cancelButtonText: "取消",
  106. type: "warning"
  107. }).then(() => {
  108. return deleteDetails(row.id);
  109. }).then(() => {
  110. this.$message({
  111. type: "success",
  112. message: "操作成功!"
  113. });
  114. this.page.currentPage = 1;
  115. this.onLoad(this.page, {parentId: 0});
  116. });
  117. },
  118. //修改时的修改按钮点击触发
  119. rowUpdate(row, index, done, loading) {
  120. typeSave(row).then(() => {
  121. this.$message({
  122. type: "success",
  123. message: "操作成功!"
  124. });
  125. // 数据回调进行刷新
  126. done(row);
  127. }, error => {
  128. window.console.log(error);
  129. loading();
  130. });
  131. },
  132. //新增修改时保存触发
  133. rowSave(row, done, loading) {
  134. typeSave(row).then(res => {
  135. console.log(res)
  136. done()
  137. })
  138. },
  139. //查询全部
  140. initData() {
  141. customerList().then(res => {
  142. console.log(this.form);
  143. const column = this.findObject(this.option.column, "parentId");
  144. column.dicData = res.data.data.records;
  145. });
  146. },
  147. //新增子项触发
  148. handleAdd(row) {
  149. this.parentId = row.id;
  150. const column = this.findObject(this.option.column, "parentId");
  151. column.value = row.id;
  152. column.addDisabled = true;
  153. this.$refs.crud.rowAdd();
  154. },
  155. //查看跳转页面
  156. beforeOpenPage(row, index) {
  157. // /receipt_detailsPageEdit
  158. this.detailData = {
  159. id: row.id,
  160. };
  161. this.isShow = false;
  162. },
  163. //新增跳转页面
  164. beforeOpen(row, index) {
  165. this.detailData = {
  166. id: row.id,
  167. };
  168. this.isShow = false;
  169. },
  170. editOpen(row, index) {
  171. this.detailData = {
  172. id: row.id,
  173. };
  174. this.isShow = false;
  175. },
  176. // 复制新单
  177. copyOrder() {
  178. const id = this.selection[0].id;
  179. this.detailData = {
  180. copyId: id,
  181. };
  182. this.isShow = false;
  183. },
  184. //点击新增时触发
  185. beforeClose(done) {
  186. this.parentId = "";
  187. const column = this.findObject(this.option.column, "parentId");
  188. column.value = "";
  189. column.addDisabled = false;
  190. done();
  191. },
  192. //点击搜索按钮触发
  193. searchChange(params, done) {
  194. console.log(params)
  195. this.page.currentPage = 1;
  196. this.onLoad(this.page, params);
  197. done()
  198. },
  199. searchReset() {
  200. console.log('1')
  201. },
  202. selectionChange(list) {
  203. this.selection = list;
  204. this.single = list.length !== 1;
  205. },
  206. currentChange() {
  207. console.log('1')
  208. },
  209. sizeChange() {
  210. console.log('1')
  211. },
  212. refreshChange() {
  213. console.log('1')
  214. },
  215. onLoad(page, params) {
  216. if (params) {
  217. if (params.businessDate) {
  218. this.$set(params, 'businessStartDate', params.businessDate[0]+ " " + "00:00:00")
  219. this.$set(params, 'businessEndDate', params.businessDate[1]+ " " + "23:59:59")
  220. this.$delete(params,'businessDate')
  221. }
  222. if (params.createTime) {
  223. this.$set(params, 'createStartTime', params.createTime[0]+ " " + "00:00:00")
  224. this.$set(params, 'createEndTime', params.createTime[1]+ " " + "23:59:59")
  225. this.$delete(params,'createTime')
  226. }
  227. }
  228. let queryParams = Object.assign({}, params, {
  229. size: page.pageSize,
  230. current: page.currentPage,
  231. billType:'SH',
  232. corpsTypeId: this.treeDeptId
  233. })
  234. customerList(queryParams).then(res => {
  235. this.dataList = res.data.data.records
  236. this.page.total = res.data.data.total
  237. })
  238. },
  239. //树桩列点击展开触发
  240. treeLoad(tree, treeNode, resolve) {
  241. const parentId = tree.id;
  242. customerList({parentId: parentId}).then(res => {
  243. resolve(res.data.data.records);
  244. });
  245. },
  246. goBack() {
  247. this.detailData=this.$options.data().detailData
  248. this.isShow = true;
  249. },
  250. //列保存触发
  251. async saveColumn() {
  252. /**
  253. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  254. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  255. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  256. */
  257. const inSave = await this.saveColumnData(
  258. this.getColumnName(23),
  259. this.option
  260. );
  261. if (inSave) {
  262. this.$message.success("保存成功");
  263. //关闭窗口
  264. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  265. }
  266. },
  267. }
  268. }
  269. </script>
  270. <style scoped>
  271. </style>