index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="classification-page">
  3. <div class="toolbar">
  4. <el-button type="success" @click="addBar">添加一级类别</el-button>
  5. </div>
  6. <el-table
  7. :data="tableData" style="width: 100%" border row-key="id"
  8. :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" :tree-props="{ children: 'childs' }"
  9. >
  10. <el-table-column prop="classifyName" label="商品类别" />
  11. <el-table-column prop="status" label="操作">
  12. <template slot-scope="scope">
  13. <el-button type="text" @click.native.prevent="checkRow(scope.row)">查看</el-button>
  14. <el-button type="text" @click.native.prevent="updateRow(scope.row)">编辑</el-button>
  15. <el-button type="text" @click.native.prevent="deleteRow(scope.row)">删除</el-button>
  16. </template>
  17. </el-table-column>
  18. </el-table>
  19. <div class="fenye">
  20. <el-pagination
  21. :current-page="currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="10"
  22. layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
  23. @current-change="handleCurrentChange"
  24. />
  25. </div>
  26. <EditDialog
  27. ref="edit" :dialog-visible="dialog.isVisible" :type="dialog.type" @close="editClose"
  28. @success="getProductCategory"
  29. />
  30. </div>
  31. </template>
  32. <script>
  33. // import {
  34. // getAllClass,
  35. // udeleteClass
  36. // } from '@/api/renovation'
  37. import {
  38. getAllClass,
  39. deleteClass
  40. } from '@/api/platformProduct'
  41. import EditDialog from './Edit'
  42. export default {
  43. components: {
  44. EditDialog
  45. },
  46. data() {
  47. return {
  48. dialogVisible: false,
  49. formParams: {
  50. page: 1,
  51. pageSize: 10
  52. },
  53. total: 1,
  54. tableData: [],
  55. currentPage: 1,
  56. dialog: {
  57. type: 'add',
  58. isVisible: false
  59. }
  60. }
  61. },
  62. created() {
  63. // this.getProductCategory()
  64. this.getAll(this.formParams)
  65. },
  66. methods: {
  67. handleSizeChange(val) {
  68. this.formParams.pageSize = val
  69. this.getAll(this.formParams)
  70. },
  71. handleCurrentChange(val) {
  72. this.formParams.page = val
  73. this.getAll(this.formParams)
  74. },
  75. fetch(config) {
  76. const { limit, page } = config
  77. this.formParams.pageIndex = page || 1
  78. this.formParams.pageSize = limit || 10
  79. this.getProductCategory()
  80. },
  81. addBar() {
  82. this.dialog = {
  83. type: 'add',
  84. isVisible: true
  85. }
  86. this.$refs.edit.setParams({ treeData: [] })
  87. },
  88. editClose() {
  89. this.dialog.isVisible = false
  90. },
  91. // 编辑
  92. updateRow(row) {
  93. const id = row.classifyId
  94. this.dialog = {
  95. type: 'edit',
  96. isVisible: true
  97. }
  98. this.$refs.edit.setParams({
  99. id
  100. })
  101. },
  102. // 查看
  103. checkRow(row) {
  104. const id = row.classifyId
  105. this.dialog = {
  106. type: 'check',
  107. isVisible: true
  108. }
  109. this.$refs.edit.setParams({
  110. id
  111. })
  112. },
  113. // 删除
  114. async deleteRow(row) {
  115. this.$confirm('此操作将永久删除该类别, 是否继续?', '提示', {
  116. confirmButtonText: '确定',
  117. cancelButtonText: '取消',
  118. type: 'warning'
  119. })
  120. .then(() => {
  121. deleteClass({ oneClassifyId: row.classifyId }).then((res) => {
  122. if (res.code === '') {
  123. this.$message({
  124. type: 'success',
  125. message: '删除成功!'
  126. })
  127. }
  128. this.getAll(this.formParams)
  129. })
  130. })
  131. .catch(() => {
  132. this.$message({
  133. type: 'info',
  134. message: '已取消删除'
  135. })
  136. })
  137. },
  138. async getProductCategory() {
  139. this.getAll(this.formParams)
  140. },
  141. async getAll(formParams) {
  142. const res = await getAllClass(formParams)
  143. this.tableData = res.data.list
  144. this.total = res.data.total
  145. }
  146. }
  147. }
  148. </script>
  149. <style lang="scss" scoped>
  150. @import url("../../../styles/elDialog.scss");
  151. .classification-page {
  152. padding: 15px 20px;
  153. .toolbar {
  154. margin-bottom: 15px;
  155. text-align: right;
  156. }
  157. }
  158. </style>