leave.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <!--
  2. - Copyright (c) 2018-2025, lengleng All rights reserved.
  3. -
  4. - Redistribution and use in source and binary forms, with or without
  5. - modification, are permitted provided that the following conditions are met:
  6. -
  7. - Redistributions of source code must retain the above copyright notice,
  8. - this list of conditions and the following disclaimer.
  9. - Redistributions in binary form must reproduce the above copyright
  10. - notice, this list of conditions and the following disclaimer in the
  11. - documentation and/or other materials provided with the distribution.
  12. - Neither the name of the pig4cloud.com developer nor the names of its
  13. - contributors may be used to endorse or promote products derived from
  14. - this software without specific prior written permission.
  15. - Author: lengleng (wangiegie@gmail.com)
  16. -->
  17. <template>
  18. <div class="execution">
  19. <basic-container>
  20. <avue-crud
  21. ref="crud"
  22. :page="page"
  23. :data="tableData"
  24. :table-loading="tableLoading"
  25. :option="tableOption"
  26. @on-load="getList"
  27. @search-change="searchChange"
  28. @refresh-change="refreshChange"
  29. @size-change="sizeChange"
  30. @current-change="currentChange"
  31. @row-update="handleUpdate"
  32. @row-save="handleSave"
  33. @row-del="rowDel">
  34. <template slot="menuLeft">
  35. <el-button
  36. v-if="permissions.act_leavebill_add"
  37. type="primary"
  38. @click="handleAdd">新 增
  39. </el-button>
  40. </template>
  41. <template
  42. slot-scope="scope"
  43. slot="menuBtn">
  44. <el-dropdown-item
  45. v-if="permissions.act_leavebill_edit && scope.row.state == 0"
  46. divided
  47. @click.native="handleSubmit(scope.row,scope.index)">提交
  48. </el-dropdown-item>
  49. <el-dropdown-item
  50. v-if="permissions.act_leavebill_edit"
  51. divided
  52. @click.native="handleEdit(scope.row,scope.index)">编辑
  53. </el-dropdown-item>
  54. <el-dropdown-item
  55. v-if="permissions.act_leavebill_del"
  56. divided
  57. @click.native="handleDel(scope.row,'suspend')">删除
  58. </el-dropdown-item>
  59. </template>
  60. </avue-crud>
  61. </basic-container>
  62. </div>
  63. </template>
  64. <script>
  65. import { addObj, delObj, fetchList, putObj, submit } from '@/api/activiti/leave-bill'
  66. import { tableOption } from '@/const/crud/activiti/leave-bill'
  67. import AvueUeditor from 'avue-plugin-ueditor';
  68. import { mapGetters } from 'vuex'
  69. export default {
  70. comments: {
  71. AvueUeditor
  72. },
  73. name: 'LeaveBill',
  74. data() {
  75. return {
  76. searchForm: {},
  77. tableData: [],
  78. page: {
  79. total: 0, // 总页数
  80. currentPage: 1, // 当前页数
  81. pageSize: 20 // 每页显示多少条
  82. },
  83. tableLoading: false,
  84. tableOption: tableOption
  85. }
  86. },
  87. created() {
  88. },
  89. mounted: function() {
  90. },
  91. computed: {
  92. ...mapGetters(['permissions'])
  93. },
  94. methods: {
  95. getList(page, params) {
  96. this.tableLoading = true
  97. fetchList(Object.assign({
  98. descs: 'create_time',
  99. current: page.currentPage,
  100. size: page.pageSize
  101. }, params, this.searchForm)).then(response => {
  102. this.tableData = response.data.data.records
  103. this.page.total = response.data.data.total
  104. this.tableLoading = false
  105. })
  106. },
  107. handleAdd: function() {
  108. this.$refs.crud.rowAdd()
  109. },
  110. handleEdit(row, index) {
  111. this.$refs.crud.rowEdit(row, index)
  112. },
  113. handleDel(row, index) {
  114. this.$refs.crud.rowDel(row, index)
  115. },
  116. rowDel: function(row, index) {
  117. this.$confirm('是否确认删除ID为' + row.leaveId, '提示', {
  118. confirmButtonText: '确定',
  119. cancelButtonText: '取消',
  120. type: 'warning'
  121. }).then(function() {
  122. return delObj(row.leaveId)
  123. }).then(() => {
  124. this.$message.success('删除成功')
  125. })
  126. },
  127. handleSubmit: function(row, index) {
  128. this.$confirm('是否确认提交ID为' + row.leaveId, '提示', {
  129. confirmButtonText: '确定',
  130. cancelButtonText: '取消',
  131. type: 'warning'
  132. }).then(function() {
  133. return submit(row.leaveId)
  134. }).then(() => {
  135. this.$message.success('提交成功')
  136. this.getList(this.page)
  137. })
  138. },
  139. handleUpdate: function(row, index, done) {
  140. putObj(row).then(() => {
  141. this.$message.success('修改成功')
  142. done()
  143. this.getList(this.page)
  144. })
  145. },
  146. handleSave: function(row, done) {
  147. addObj(row).then(() => {
  148. this.$message.success('添加成功')
  149. done()
  150. this.getList(this.page)
  151. })
  152. },
  153. searchChange(form, done) {
  154. this.searchForm = form
  155. this.getList(this.page, form)
  156. done()
  157. },
  158. sizeChange(pageSize){
  159. this.page.pageSize = pageSize
  160. },
  161. currentChange(current){
  162. this.page.currentPage = current
  163. },
  164. refreshChange() {
  165. this.getList(this.page)
  166. }
  167. }
  168. }
  169. </script>