index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <div>
  3. <basic-container v-show="!detailsOpen">
  4. <avue-crud
  5. :option="option"
  6. :search.sync="search"
  7. v-model="form"
  8. :table-loading="loading"
  9. :data="dataList"
  10. ref="crud"
  11. :key="key"
  12. @on-load="onLoad"
  13. @search-change="searchChange"
  14. @row-del="rowDel"
  15. @search-criteria-switch="searchCriteriaSwitch"
  16. @refresh-change="refreshChange"
  17. @resetColumn="resetColumnTwo('crud','option','optionList',257)"
  18. @saveColumn="saveColumnTwo('crud','option','optionList',257)"
  19. :page.sync="page">
  20. <template slot-scope="{type,size,row,$index}" slot="menu">
  21. <el-button icon="el-icon-view" :size="size" :type="type" @click="check(row)">查看</el-button>
  22. <el-button icon="el-icon-delete" :size="size" v-if="row.status == 0" :type="type" @click="$refs.crud.rowDel(row,$index)">删除
  23. </el-button>
  24. </template>
  25. <template slot="corpIdsSearch" slot-scope="scope">
  26. <crop-select v-model="search.corpIds" corpType="KH"></crop-select>
  27. </template>
  28. <template slot-scope="{type,size,row,$index}" slot="menuLeft">
  29. <el-button icon="el-icon-plus" type="primary" :size="size" @click="detailsOpen = true">创建单据</el-button>
  30. </template>
  31. </avue-crud>
  32. </basic-container>
  33. <detailsPage v-if="detailsOpen" :onLoad="form" :detailData="detailData" @backToList="backToList"></detailsPage>
  34. </div>
  35. </template>
  36. <script>
  37. import {getList, remove} from "@/api/annualBudget.js";
  38. import detailsPage from "./detailsPage"
  39. export default {
  40. name: "index",
  41. components: {
  42. detailsPage
  43. },
  44. data() {
  45. return {
  46. detailsOpen: false,
  47. loading: false,
  48. search: {},
  49. form: {},
  50. dataList: [],
  51. detailData: {},
  52. page: {
  53. pageSize: 20,
  54. currentPage: 1,
  55. total: 0,
  56. pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
  57. },
  58. key:0,
  59. option: {},
  60. optionList: {
  61. viewBtn: false,
  62. editBtn: false,
  63. delBtn: false,
  64. addBtn: false,
  65. index: true,
  66. span: 8,
  67. border: true,
  68. height:"auto",
  69. searchMenuPosition: "right",
  70. align: "center",
  71. menuWidth:140,
  72. searchSpan: 8,
  73. searchIcon: true,
  74. searchIndex: 2,
  75. highlightCurrentRow: true,
  76. dialogWidth: "70%",
  77. showSummary: true,
  78. sumColumnList: [{
  79. name: 'boxNumber',
  80. type: 'sum',
  81. decimals:0
  82. },{
  83. name: 'totalAmount',
  84. type: 'sum',
  85. decimals:2
  86. }],
  87. column: [{
  88. label: '标题',
  89. prop: 'title',
  90. width: 220,
  91. search: true
  92. },{
  93. label: "年份",
  94. prop: "particularYear",
  95. type: "year",
  96. search: true,
  97. overHidden: true,
  98. valueFormat: "yyyy",
  99. width: 100,
  100. },{
  101. label: "制单人",
  102. prop: "createUserName",
  103. searchProp:"createUser",
  104. overHidden: true,
  105. width: 100,
  106. search: true,
  107. filterable: true,
  108. remote: true,
  109. type: "select",
  110. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  111. props: {
  112. label: "account",
  113. value: "id",
  114. res: 'data.records'
  115. }
  116. }, {
  117. label: "制单日期",
  118. prop: "createTime",
  119. searchProp:"createTimeList",
  120. type: "date",
  121. overHidden: true,
  122. width: 200,
  123. searchRange: true,
  124. searchDefaultTime: ["00:00:00", "23:59:59"],
  125. format: "yyyy-MM-dd",
  126. valueFormat: "yyyy-MM-dd HH:mm:ss"
  127. }, {
  128. label: "更新人",
  129. prop: "updateUserName",
  130. searchProp:"updateUser",
  131. overHidden: true,
  132. width: 100,
  133. search: true,
  134. filterable: true,
  135. remote: true,
  136. type: "select",
  137. dicUrl: "/api/blade-user/page?size=20&current=1&account={{key}}",
  138. props: {
  139. label: "account",
  140. value: "id",
  141. res: 'data.records'
  142. }
  143. }, {
  144. label: "更新日期",
  145. prop: "updateTime",
  146. searchProp:"updateTimeList",
  147. type: "date",
  148. overHidden: true,
  149. width: 200,
  150. searchRange: true,
  151. searchDefaultTime: ["00:00:00", "23:59:59"],
  152. format: "yyyy-MM-dd",
  153. valueFormat: "yyyy-MM-dd HH:mm:ss"
  154. },{
  155. label: "客户名称",
  156. prop: "corpIds",
  157. hide:true,
  158. showColumn:false,
  159. searchOrder: 1,
  160. search: true
  161. }]
  162. }
  163. }
  164. },
  165. activated() {
  166. if (this.$route.query.check) {
  167. this.detailsOpen = false
  168. this.detailData = {
  169. id: this.$route.query.check.billId,
  170. check: this.$route.query.check,
  171. };
  172. this.form = {
  173. id:this.$route.query.check.billId
  174. }
  175. this.detailsOpen = true
  176. this.$router.$avueRouter.closeTag(window.location.hash.slice(1))
  177. }
  178. },
  179. async created() {
  180. this.option = await this.getColumnData(this.getColumnName(257), this.optionList);
  181. this.key++
  182. let i = 0;
  183. this.option.column.forEach(item => {
  184. if (item.search) i++
  185. })
  186. if (i % 3 !== 0) {
  187. const num = 3 - Number(i % 3)
  188. this.option.searchMenuSpan = num * 8;
  189. this.option.searchMenuPosition = "right";
  190. }
  191. },
  192. methods: {
  193. check(row){
  194. this.form = row
  195. this.detailsOpen = true
  196. },
  197. backToList(type) {
  198. this.form = {}
  199. this.detailsOpen = false
  200. if (type === 0){
  201. this.detailData = {}
  202. }
  203. this.onLoad(this.page,this.search)
  204. },
  205. searchCriteriaSwitch(type) {
  206. this.$refs.crud.getTableHeight();
  207. },
  208. //刷新
  209. refreshChange() {
  210. this.onLoad(this.page, this.search)
  211. },
  212. rowDel(form, index) {
  213. this.$confirm('此操作将永久删除该行, 是否继续?', '提示', {
  214. confirmButtonText: '确定',
  215. cancelButtonText: '取消',
  216. type: 'warning'
  217. }).then(() => {
  218. remove(form.id).then(res => {
  219. this.$message({
  220. type: 'success',
  221. message: '删除成功!'
  222. });
  223. })
  224. }).catch(() => {
  225. });
  226. },
  227. searchChange(params, done) {
  228. done();
  229. this.onLoad(this.page, params)
  230. },
  231. onLoad(page, params = {}) {
  232. params = {
  233. ...params,
  234. current: page.currentPage,
  235. size: page.pageSize,
  236. ...Object.assign(params, this.search)
  237. }
  238. this.loading = true
  239. getList(params).then(res => {
  240. this.dataList = res.data.data.records
  241. this.page.total = res.data.data.total
  242. this.loading = false
  243. }).finally(() => {
  244. this.loading = false
  245. })
  246. },
  247. //自定义列保存
  248. async saveColumnTwo(ref, option, optionBack, code) {
  249. /**
  250. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  251. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  252. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  253. */
  254. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  255. if (inSave) {
  256. this.$message.success("保存成功");
  257. //关闭窗口
  258. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  259. }
  260. },
  261. //自定义列重置
  262. async resetColumnTwo(ref, option, optionBack, code) {
  263. this[option] = this[optionBack];
  264. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  265. if (inSave) {
  266. this.$message.success("重置成功");
  267. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  268. }
  269. }
  270. }
  271. }
  272. </script>
  273. <style scoped>
  274. </style>