Blame view

admin-web-master/src/views/renovation/commdityClass/index.vue 4.76 KB
3f535f30   杨鑫   '初始'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
  <template>
    <div style="background-color:#f7f7f7;padding:10px 10px;">
      <div class="classification-page">
        <div style="height:58px;line-height:58px;">
          <div style="color:#0006"> <span>商品管理</span>   <span style="padding:0 5px;">></span>  <span style="color:#000000e6">商品类别</span></div>
        </div>
        <div class="toolbar">
          <el-button style="background-color: #3F9B6A;color: #fff" @click="addBar">添加一级类别</el-button>
        </div>
        <el-table
          :data="tableData"
          row-key="id"
         :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}"
          :tree-props="{ children: 'childs' }"
        >
          <el-table-column prop="classifyName" label="商品类别" />
          <el-table-column prop="status" label="操作">
            <template slot-scope="scope">
              <div class="tableBtn greens" @click="checkRow(scope.row)">查看</div>
              <div class="tableBtn greens" @click="updateRow(scope.row)">编辑</div>
              <div class="tableBtn greens" @click="deleteRow(scope.row)">删除</div>
            </template>
          </el-table-column>
        </el-table>
        <div class="fenye">
          <el-pagination
            :current-page="currentPage"
3f535f30   杨鑫   '初始'
28
            :page-size="10"
855bef33   杨鑫   '最新版本'
29
            layout="total, prev, pager, next"
3f535f30   杨鑫   '初始'
30
            :total="total"
855bef33   杨鑫   '最新版本'
31
  		  background
3f535f30   杨鑫   '初始'
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
        <edit-dialog
          ref="edit"
          :dialog-visible="dialog.isVisible"
          :type="dialog.type"
          @close="editClose"
          @success="getProductCategory"
        />
      </div>
    </div>
  </template>
  <script>
  import {
    commdityClassGetAll,
    commdityClassDelete
  } from '@/api/renovation'
  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: 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(() => {
            commdityClassDelete({ 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 commdityClassGetAll(formParams)
        this.tableData = res.data.list
        this.total = res.data.total
      }
    }
  }
  </script>
  <style lang="scss" scoped>
  @import url("../../../styles/elDialog.scss");
  
  .classification-page {
    padding: 0  20px 20px 20px;
    min-height: calc(100vh - 50px - 20px);
    background-color: #Fff;
    .toolbar {
      margin-bottom: 15px;
  
    }
  }
    .tableBtn {
         display: inline-block;
         margin-right: 10px;
       }
  
     .greens {
         color: #3F9B6A ;
       }
       ::v-deep .buttonHover:hover{
         color:#3f9b6a !important;
         border-color: #c5e1d2 !important;
         background-color: #ecf5f0 !important;
         outline: none;
       }
       ::v-deep .el-pagination__total {
           position: absolute;
           left: 10px;
         }
  </style>