index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :getList="getList"
  5. :exportList="exportList"
  6. :columnParsing="columnParsing"
  7. :optionsEvensGroup="optionsEvensGroup"
  8. :tableAttributes="tableAttributes"
  9. :tableEvents="tableEvents"
  10. >
  11. </template-page>
  12. </template>
  13. <script>
  14. import TemplatePage from '@/components/template/template-page-1.vue'
  15. import import_mixin from '@/components/template/import_mixin.js'
  16. import {
  17. partsOldOutList,
  18. partsOldOutExport,
  19. partsOldOutDel,
  20. partsOldOutImport
  21. } from '@/api/material-system/center/center-old-parts-shop-out'
  22. import operation_mixin from '@/components/template/operation_mixin.js'
  23. export default {
  24. components: { TemplatePage },
  25. mixins: [import_mixin, operation_mixin],
  26. data() {
  27. return {
  28. // 表格属性
  29. tableAttributes: {
  30. // 启用勾选列
  31. selectColumn: true
  32. },
  33. // 表格事件
  34. tableEvents: {
  35. 'selection-change': this.selectionChange
  36. },
  37. recordSelected: []
  38. }
  39. },
  40. computed: {
  41. optionsEvensGroup() {
  42. return [
  43. [
  44. [
  45. this.optionsEvensAuth('dels', {
  46. click: () => {
  47. this.dels()
  48. }
  49. })
  50. ]
  51. ],
  52. [
  53. [
  54. this.optionsEvensAuth('import', ({ moduleName }) => {
  55. return {
  56. name: moduleName,
  57. render: () => {
  58. return this.importButton(partsOldOutImport, moduleName)
  59. }
  60. }
  61. })
  62. ]
  63. ]
  64. ]
  65. }
  66. },
  67. methods: {
  68. // 列表请求函数
  69. getList(...p) {
  70. this.recordSelected = []
  71. return partsOldOutList(...p)
  72. },
  73. // 列表导出函数
  74. exportList: partsOldOutExport,
  75. // 表格列解析渲染数据更改
  76. columnParsing(item, defaultData) {
  77. return defaultData
  78. },
  79. // 监听勾选变化
  80. selectionChange(data) {
  81. this.recordSelected = data
  82. },
  83. // 批量删除
  84. dels() {
  85. if (this.recordSelected.length) {
  86. this.$confirm('此操作将删除数据, 是否继续?', '提示', {
  87. confirmButtonText: '确定',
  88. cancelButtonText: '取消',
  89. type: 'warning'
  90. })
  91. .then(() => {
  92. partsOldOutDel({
  93. ids: this.recordSelected.map(item => item.id).join(',')
  94. })
  95. .then(res => {
  96. this.$refs.pageRef.refreshList()
  97. this.$message({
  98. type: 'success',
  99. message: '删除成功!'
  100. })
  101. })
  102. .catch(() => {
  103. this.$message({
  104. type: 'error',
  105. message: '删除失败'
  106. })
  107. })
  108. })
  109. .catch(() => {
  110. this.$message({
  111. type: 'info',
  112. message: '已取消删除'
  113. })
  114. })
  115. } else {
  116. this.$message({
  117. type: 'info',
  118. message: '请先勾选需要删除的数据!'
  119. })
  120. }
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped></style>