index.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. },
  92. activated() {
  93. setTimeout(() => {
  94. if (this.$route.query.form) {
  95. this.detailData = {
  96. form: this.$route.query.form,
  97. };
  98. this.$store.commit("DOM_IN_DETAIL");
  99. this.isShow = false;
  100. }
  101. }, 100);
  102. },
  103. methods: {
  104. //删除列表后面的删除按钮触发触发(row, index, done)
  105. rowDel(row, index, done) {
  106. this.$confirm("确定将选择数据删除?", {
  107. confirmButtonText: "确定",
  108. cancelButtonText: "取消",
  109. type: "warning"
  110. }).then(() => {
  111. return deleteDetails(row.id);
  112. }).then(() => {
  113. this.$message({
  114. type: "success",
  115. message: "操作成功!"
  116. });
  117. this.page.currentPage = 1;
  118. this.onLoad(this.page, {parentId: 0});
  119. });
  120. },
  121. //修改时的修改按钮点击触发
  122. rowUpdate(row, index, done, loading) {
  123. typeSave(row).then(() => {
  124. this.$message({
  125. type: "success",
  126. message: "操作成功!"
  127. });
  128. // 数据回调进行刷新
  129. done(row);
  130. }, error => {
  131. window.console.log(error);
  132. loading();
  133. });
  134. },
  135. //新增修改时保存触发
  136. rowSave(row, done, loading) {
  137. typeSave(row).then(res => {
  138. console.log(res)
  139. done()
  140. })
  141. },
  142. //查询全部
  143. initData() {
  144. customerList().then(res => {
  145. console.log(this.form);
  146. const column = this.findObject(this.option.column, "parentId");
  147. column.dicData = res.data.data.records;
  148. });
  149. },
  150. //新增子项触发
  151. handleAdd(row) {
  152. this.parentId = row.id;
  153. const column = this.findObject(this.option.column, "parentId");
  154. column.value = row.id;
  155. column.addDisabled = true;
  156. this.$refs.crud.rowAdd();
  157. },
  158. //查看跳转页面
  159. beforeOpenPage(row, index) {
  160. // /receipt_detailsPageEdit
  161. this.detailData = {
  162. id: row.id,
  163. };
  164. this.isShow = false;
  165. this.$store.commit("DOM_IN_DETAIL");
  166. },
  167. //新增跳转页面
  168. beforeOpen(row, index) {
  169. this.detailData = {
  170. id: row.id,
  171. };
  172. this.isShow = false;
  173. this.$store.commit("DOM_IN_DETAIL");
  174. },
  175. editOpen(row, index) {
  176. this.detailData = {
  177. id: row.id,
  178. };
  179. this.isShow = false;
  180. this.$store.commit("DOM_IN_DETAIL");
  181. },
  182. // 复制新单
  183. copyOrder() {
  184. const id = this.selection[0].id;
  185. this.detailData = {
  186. copyId: id,
  187. };
  188. this.isShow = false;
  189. this.$store.commit("DOM_IN_DETAIL");
  190. },
  191. //点击新增时触发
  192. beforeClose(done) {
  193. this.parentId = "";
  194. const column = this.findObject(this.option.column, "parentId");
  195. column.value = "";
  196. column.addDisabled = false;
  197. done();
  198. },
  199. //点击搜索按钮触发
  200. searchChange(params, done) {
  201. console.log(params)
  202. this.page.currentPage = 1;
  203. this.onLoad(this.page, params);
  204. done()
  205. },
  206. searchReset() {
  207. console.log('1')
  208. },
  209. selectionChange(list) {
  210. this.selection = list;
  211. this.single = list.length !== 1;
  212. },
  213. currentChange() {
  214. console.log('1')
  215. },
  216. sizeChange() {
  217. console.log('1')
  218. },
  219. refreshChange() {
  220. console.log('1')
  221. },
  222. onLoad(page, params) {
  223. if (params) {
  224. if (params.businessDate) {
  225. this.$set(params, 'businessStartDate', params.businessDate[0]+ " " + "00:00:00")
  226. this.$set(params, 'businessEndDate', params.businessDate[1]+ " " + "23:59:59")
  227. this.$delete(params,'businessDate')
  228. }
  229. if (params.createTime) {
  230. this.$set(params, 'createStartTime', params.createTime[0]+ " " + "00:00:00")
  231. this.$set(params, 'createEndTime', params.createTime[1]+ " " + "23:59:59")
  232. this.$delete(params,'createTime')
  233. }
  234. }
  235. let queryParams = Object.assign({}, params, {
  236. size: page.pageSize,
  237. current: page.currentPage,
  238. billType:'SH',
  239. corpsTypeId: this.treeDeptId
  240. })
  241. customerList(queryParams).then(res => {
  242. this.dataList = res.data.data.records
  243. this.page.total = res.data.data.total
  244. })
  245. },
  246. //树桩列点击展开触发
  247. treeLoad(tree, treeNode, resolve) {
  248. const parentId = tree.id;
  249. customerList({parentId: parentId}).then(res => {
  250. resolve(res.data.data.records);
  251. });
  252. },
  253. goBack() {
  254. this.detailData=this.$options.data().detailData
  255. this.isShow = true;
  256. this.$store.commit("DOM_OUT_DETAIL");
  257. },
  258. //列保存触发
  259. async saveColumn() {
  260. /**
  261. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  262. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  263. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  264. */
  265. const inSave = await this.saveColumnData(
  266. this.getColumnName(23),
  267. this.option
  268. );
  269. if (inSave) {
  270. this.$message.success("保存成功");
  271. //关闭窗口
  272. this.$refs.crud.$refs.dialogColumn.columnBox = false;
  273. }
  274. },
  275. }
  276. }
  277. </script>
  278. <style scoped>
  279. </style>