index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="annualGuarantee">
  3. <!-- 通用代码 左侧按钮 右侧输入框 下拉框 -->
  4. <div class="view-common-header">
  5. <div class="view-common-header-left">
  6. <el-button type="success" @click="handleAdd">新增</el-button>
  7. <el-button type="warning" @click="handleDelete">删除</el-button>
  8. <el-button type="primary" :disabled="tableData.length == 0" @click="allExport">导出</el-button>
  9. </div>
  10. <div class="view-common-header-right">
  11. <el-input @keyup.enter.native="fetchTableData('search')" placeholder="请输入内容" v-model="searchValue" class="input-select">
  12. <el-button @click="fetchTableData('search')" slot="append" icon="el-icon-search"></el-button>
  13. </el-input>
  14. </div>
  15. </div>
  16. <LTable ref="table" @select-all="selectAll" @selection-change="selection" :defaultFetch="true" :columns="columns" :dataSource="tableData" :options="options" :fetch="fetchTableData" :pagination="pagination" />
  17. <CrudDialog v-bind="modalConfig" ref="NewDialogRef" @crudDialogSubmit="crudDialogSubmit"></CrudDialog>
  18. </div>
  19. </template>
  20. <script>
  21. import { compareObj } from '@/utils/index'
  22. import { columns, options, modalConfig, data } from './index'
  23. import { socialSecurityPage, socialSecurityAdd, socialSecurityEdit, socialSecurityRemove, exportSocialSecurityExcel } from '@/api/task/carrierFlightMission'
  24. export default {
  25. name: 'AnnualGuarantee',
  26. components: {},
  27. data() {
  28. // 这里存放数据
  29. return {
  30. searchValue: '',
  31. removeArr: [],
  32. columns: columns(this),
  33. modalConfig: modalConfig(this),
  34. options,
  35. // 分页
  36. pagination: {
  37. total: 0,
  38. pageIndex: 1,
  39. pageSize: 20
  40. },
  41. tableData: data
  42. }
  43. },
  44. mounted() {},
  45. methods: {
  46. async fetchTableData(search) {
  47. let postData = {
  48. pageSize: this.pagination.pageSize,
  49. pageIndex: search ? 1 : this.pagination.pageIndex,
  50. keyword: this.searchValue
  51. }
  52. const { code, data } = await socialSecurityPage(postData)
  53. if (code == 200) {
  54. this.tableData = data.list
  55. this.pagination.total = data.totalCount
  56. }
  57. },
  58. handleAdd() {
  59. let config = {
  60. type: 'add',
  61. dataShow: {}, // 回填的值(字段对应上)
  62. title: '新增'
  63. }
  64. this.$refs.NewDialogRef.open(config)
  65. },
  66. handUpdate(row) {
  67. row.guaranteeYear = String(row.guaranteeYear)
  68. let config = {
  69. type: 'update',
  70. dataShow: row, // 回填的值(字段对应上)
  71. title: '编辑'
  72. }
  73. this.$refs.NewDialogRef.open(config)
  74. },
  75. handRemove(row) {
  76. this.$confirm('是否确认删除该数据', '提示', {
  77. confirmButtonText: '确定',
  78. cancelButtonText: '取消',
  79. type: 'warning'
  80. })
  81. .then(async () => {
  82. let params = {
  83. socialSecurityIds: [row.socialSecurityId]
  84. }
  85. await socialSecurityRemove(params)
  86. this.fetchTableData()
  87. this.$message({
  88. type: 'success',
  89. message: '删除成功!'
  90. })
  91. })
  92. .catch(() => {})
  93. },
  94. handleDelete() {
  95. this.$confirm('是否确认删除选中数据', '提示', {
  96. confirmButtonText: '确定',
  97. cancelButtonText: '取消',
  98. type: 'warning'
  99. })
  100. .then(async () => {
  101. let params = {
  102. socialSecurityIds: this.removeArr
  103. }
  104. await socialSecurityRemove(params)
  105. this.$refs.table.clearSelection()
  106. this.fetchTableData()
  107. this.$message({
  108. type: 'success',
  109. message: '删除成功!'
  110. })
  111. })
  112. .catch(() => {})
  113. },
  114. // 全选
  115. selectAll(data) {
  116. this.removeArr = []
  117. if (data.length > 0) {
  118. data.forEach((item) => {
  119. this.removeArr.push(item.socialSecurityId)
  120. })
  121. } else {
  122. this.removeArr = []
  123. }
  124. },
  125. // 单选
  126. selection(data) {
  127. this.removeArr = []
  128. data.forEach((item) => {
  129. this.removeArr.push(item.socialSecurityId)
  130. })
  131. },
  132. async crudDialogSubmit(data) {
  133. const { dialogData, type } = data
  134. if (type == 'update') {
  135. await socialSecurityEdit(dialogData)
  136. } else {
  137. await socialSecurityAdd(dialogData)
  138. }
  139. this.fetchTableData()
  140. this.$message({
  141. type: 'success',
  142. message: '操作成功!'
  143. })
  144. },
  145. handPriceList(row) {
  146. this.$router.push(`/carrierStandard/safeguardCost/${row.socialSecurityId}`)
  147. },
  148. //导出全部
  149. async allExport() {
  150. let params = {
  151. keyword: this.searchValue
  152. }
  153. await exportSocialSecurityExcel(params)
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss" scoped></style>