index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <template-page
  3. ref="pageRef"
  4. :get-list="getList"
  5. :table-attributes="tableAttributes"
  6. :table-events="tableEvents"
  7. :options-evens-group="optionsEvensGroup"
  8. :moreParameters="moreParameters"
  9. :column-parsing="columnParsing"
  10. :exportList="exportList"
  11. :operation="operation()"
  12. >
  13. </template-page>
  14. </template>
  15. <script>
  16. import TemplatePage from '@/components/template/template-page-1.vue'
  17. import import_mixin from '@/components/template/import_mixin.js'
  18. import { workerStockList, workerStockListExport, workerStockImportM, workerStockDel } from '@/api/inventoryManagement'
  19. import { commonTemplateDownload } from '@/api/common.js'
  20. import operation_mixin from '@/components/template/operation_mixin.js'
  21. export default {
  22. components: { TemplatePage },
  23. mixins: [import_mixin, operation_mixin],
  24. data() {
  25. return {
  26. // 表格属性
  27. tableAttributes: {
  28. // 启用勾选列
  29. selectColumn: false
  30. },
  31. // 表格事件
  32. tableEvents: {
  33. 'selection-change': this.selectionChange
  34. },
  35. // 勾选选中行
  36. recordSelected: []
  37. }
  38. },
  39. computed: {
  40. // 事件组合
  41. optionsEvensGroup() {
  42. return [
  43. [
  44. [
  45. this.optionsEvensAuth('template', {
  46. click: () => {
  47. commonTemplateDownload({ name: '辅材师傅库存.xlsx' }, `${this.$route.meta.title}`)
  48. .then(res => {
  49. this.$message({
  50. message: '下载成功',
  51. type: 'success'
  52. })
  53. })
  54. .catch(err => {
  55. this.$message.error('下载失败')
  56. })
  57. }
  58. })
  59. ],
  60. [
  61. this.optionsEvensAuth('imp', ({ moduleName }) => {
  62. return {
  63. name: moduleName,
  64. render: () => {
  65. return this.importButton(workerStockImportM, moduleName)
  66. }
  67. }
  68. })
  69. ]
  70. ]
  71. ]
  72. },
  73. // 更多参数
  74. moreParameters() {
  75. return []
  76. }
  77. },
  78. methods: {
  79. // 列表请求函数
  80. getList: workerStockList,
  81. // 列表导出函数
  82. exportList: workerStockListExport,
  83. // 表格列解析渲染数据更改
  84. columnParsing(item, defaultData) {
  85. return defaultData
  86. },
  87. // 监听勾选变化
  88. selectionChange(data) {
  89. this.recordSelected = data
  90. },
  91. operation() {
  92. return this.operationBtn({
  93. del: {
  94. prompt: '此操作将永久删除数据, 是否继续?',
  95. click: ({ row, index, column }) => {
  96. workerStockDel([row.id]).then(res => {
  97. this.$message({
  98. message: '删除成功',
  99. type: 'success'
  100. })
  101. this.$refs?.pageRef?.refreshList()
  102. })
  103. }
  104. }
  105. })
  106. }
  107. }
  108. }
  109. </script>
  110. <style lang="scss" scoped></style>