| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <template>
- <div class="classification-page">
- <div class="toolbar">
- <el-button type="success" @click="addBar">添加一级类别</el-button>
- </div>
- <el-table
- :data="tableData" style="width: 100%" border row-key="id"
- :header-cell-style="{ background: '#EEF3FF', color: '#333333' }" :tree-props="{ children: 'childs' }"
- >
- <el-table-column prop="classifyName" label="商品类别" />
- <el-table-column prop="status" label="操作">
- <template slot-scope="scope">
- <el-button type="text" @click.native.prevent="checkRow(scope.row)">查看</el-button>
- <el-button type="text" @click.native.prevent="updateRow(scope.row)">编辑</el-button>
- <el-button type="text" @click.native.prevent="deleteRow(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div class="fenye">
- <el-pagination
- :current-page="currentPage" :page-sizes="[10, 20, 50, 100]" :page-size="10"
- layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange"
- @current-change="handleCurrentChange"
- />
- </div>
- <EditDialog
- ref="edit" :dialog-visible="dialog.isVisible" :type="dialog.type" @close="editClose"
- @success="getProductCategory"
- />
- </div>
- </template>
- <script>
- // import {
- // getAllClass,
- // udeleteClass
- // } from '@/api/renovation'
- import {
- getAllClass,
- deleteClass
- } from '@/api/platformProduct'
- import EditDialog from './Edit'
- export default {
- components: {
- EditDialog
- },
- data() {
- return {
- dialogVisible: false,
- formParams: {
- page: 1,
- pageSize: 10
- },
- total: 1,
- tableData: [],
- currentPage: 1,
- dialog: {
- type: 'add',
- isVisible: false
- }
- }
- },
- created() {
- // this.getProductCategory()
- this.getAll(this.formParams)
- },
- methods: {
- handleSizeChange(val) {
- this.formParams.pageSize = val
- this.getAll(this.formParams)
- },
- handleCurrentChange(val) {
- this.formParams.page = val
- this.getAll(this.formParams)
- },
- fetch(config) {
- const { limit, page } = config
- this.formParams.pageIndex = page || 1
- this.formParams.pageSize = limit || 10
- this.getProductCategory()
- },
- addBar() {
- this.dialog = {
- type: 'add',
- isVisible: true
- }
- this.$refs.edit.setParams({ treeData: [] })
- },
- editClose() {
- this.dialog.isVisible = false
- },
- // 编辑
- updateRow(row) {
- const id = row.classifyId
- this.dialog = {
- type: 'edit',
- isVisible: true
- }
- this.$refs.edit.setParams({
- id
- })
- },
- // 查看
- checkRow(row) {
- const id = row.classifyId
- this.dialog = {
- type: 'check',
- isVisible: true
- }
- this.$refs.edit.setParams({
- id
- })
- },
- // 删除
- async deleteRow(row) {
- this.$confirm('此操作将永久删除该类别, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- })
- .then(() => {
- deleteClass({ oneClassifyId: row.classifyId }).then((res) => {
- if (res.code === '') {
- this.$message({
- type: 'success',
- message: '删除成功!'
- })
- }
- this.getAll(this.formParams)
- })
- })
- .catch(() => {
- this.$message({
- type: 'info',
- message: '已取消删除'
- })
- })
- },
- async getProductCategory() {
- this.getAll(this.formParams)
- },
- async getAll(formParams) {
- const res = await getAllClass(formParams)
- this.tableData = res.data.list
- this.total = res.data.total
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import url("../../../styles/elDialog.scss");
- .classification-page {
- padding: 15px 20px;
- .toolbar {
- margin-bottom: 15px;
- text-align: right;
- }
- }
- </style>
|