فهرست منبع

feat(user): backend alignment + adapt category to avue-crud

furffico 1 سال پیش
والد
کامیت
fe2151ecf5
5فایلهای تغییر یافته به همراه153 افزوده شده و 125 حذف شده
  1. 52 0
      src/crud/prod/category.ts
  2. 29 25
      src/crud/user/user.js
  3. 36 71
      src/views/modules/prod/category.vue
  4. 1 1
      src/views/modules/prod/prodList.vue
  5. 35 28
      src/views/modules/user/user.vue

+ 52 - 0
src/crud/prod/category.ts

@@ -0,0 +1,52 @@
+export const tableOption = {
+    searchMenuSpan: 6,
+    columnBtn: false,
+    border: true,
+    selection: true,
+    stripe: true,
+    menuAlign: 'center',
+    menuFixed: false,
+    align: 'center',
+    refreshBtn: true,
+    searchSize: 'mini',
+    addBtn: false,
+    editBtn: false,
+    delBtn: false,
+    viewBtn: false,
+    props: {
+      label: 'label',
+      value: 'value'
+    },
+    column: [
+    {
+      label: "#",
+      prop: "categoryId",
+      editDisabled: true,
+      addDisabled: true
+    }, {
+      label: '分类名',
+      prop: 'categoryName',
+      search: true,
+      align: "left",
+      minWidth: 300,
+    }, {
+      label: '优先级',
+      prop: 'seq'
+    },
+    {
+        label: "状态",
+        prop: 'status',
+        search: true,
+        slot: true,
+        type: 'select',
+        dicData: [
+            {
+                label: '下线',
+                value: 0
+            }, {
+                label: '正常',
+                value: 1
+            }
+        ]
+    }]
+}

+ 29 - 25
src/crud/user/user.js

@@ -3,17 +3,17 @@ export const tableOption = {
   columnBtn: false,
   border: true,
   // selection: true,
-  index: true,
-  indexLabel: '#',
+  // index: true,
+  // indexLabel: '#',
   stripe: true,
   menuAlign: 'center',
-  menuWidth: 350,
+  // menuWidth: 350,
   align: 'center',
   refreshBtn: false,
   searchSize: 'mini',
   addBtn: false,
   editBtn: false,
-  delBtn: false,
+  delBtn: true,
   viewBtn: false,
   props: {
     label: 'label',
@@ -21,20 +21,24 @@ export const tableOption = {
   },
   column: [
     {
-      label: '用户编号',
-      prop: 'userId',
+      label: '#',
+      prop: 'id',
       search: false,
     },
     {
       label: '用户昵称',
-      prop: 'nickName',
+      prop: 'nickname',
       search: true
     }, 
     {
       label: '手机号码',
-      prop: 'userMobile',
+      prop: 'phoneHidden',
       search: true
     },
+    {
+      label: '角色',
+      prop: 'role',
+    },
     // {
     //   label: '用户头像',
     //   prop: 'pic',
@@ -43,25 +47,25 @@ export const tableOption = {
     //   listType: 'picture-img',
     //   slot: true
     // }, 
-    {
-      label: '状态',
-      prop: 'status',
-      search: true,
-      type: 'select',
-      slot: true,
-      dicData: [
-        {
-          label: '禁用',
-          value: 0
-        }, {
-          label: '正常',
-          value: 1
-        }
-      ]
-    }, 
+    // {
+    //   label: '状态',
+    //   prop: 'status',
+    //   search: true,
+    //   type: 'select',
+    //   slot: true,
+    //   dicData: [
+    //     {
+    //       label: '禁用',
+    //       value: 0
+    //     }, {
+    //       label: '正常',
+    //       value: 1
+    //     }
+    //   ]
+    // }, 
     {
       label: '注册时间',
-      prop: 'userRegtime',
+      prop: 'createdAt',
       imgWidth: 150
     }
   ]

+ 36 - 71
src/views/modules/prod/category.vue

@@ -1,83 +1,47 @@
 <template>
-  <div class="mod-category">
-    <el-form :inline="true"
-             :model="dataForm">
-      <el-form-item>
-        <el-button v-if="isAuth('prod:category:save')"
+  <div>
+    
+  <avue-crud 
+    ref="crud"
+    :page="page"
+    :data="dataList"
+    :table-loading="dataListLoading"
+    :option="tableOption"
+  >
+    <template slot-scope="scope" slot="menuLeft" >
+      <el-button v-if="isAuth('prod:category:save')"
                    type="primary"
                    icon="el-icon-plus"
                    size="small"
                    @click="addOrUpdateHandle()">新增</el-button>
-      </el-form-item>
-    </el-form>
-    <el-table :data="dataList"
-              border
-              row-key="categoryId"
-              style="width: 100%;">
-      
-      <el-table-column prop="categoryId"
-                       header-align="left"
-                       treeKey="categoryId"
-                       width="150"
-                       label="#">
-      </el-table-column>
+    </template>
+    
+    <template slot-scope="scope" slot="status">
+      <el-tag v-if="scope.row.status === 1" size="small" type="success">正常</el-tag>
+      <el-tag v-else size="small" type="warning">下线</el-tag>
+    </template>
 
-      <el-table-column prop="categoryName"
-                       header-align="center"
-                       width="150"
-                       label="分类名称">
-      </el-table-column>
-      <!--el-table-column prop="pic"
-                       header-align="center"
-                       align="center"
-                       label="图片">
-        <template slot-scope="scope">
-          <img :src="resourcesUrl + scope.row.pic " />
-        </template>
-      </el-table-column-->
-      <el-table-column prop="status"
-                       header-align="center"
-                       align="center"
-                       label="状态">
-        <template slot-scope="scope">
-          <el-tag v-if="scope.row.status === 0"
+    <template slot-scope="scope" slot="menu">
+      <el-button v-if="isAuth('prod:category:update')"
+                  type="primary"
                   size="small"
-                  type="danger">下线</el-tag>
-          <el-tag v-else
-                  size="small">正常</el-tag>
-        </template>
-      </el-table-column>
-      <el-table-column prop="seq"
-                       header-align="center"
-                       align="center"
-                       label="优先级">
-      </el-table-column>
-      <el-table-column 
-                       header-align="center"
-                       align="center"
-                       label="操作">
-        <template slot-scope="scope">
-          <el-button v-if="isAuth('prod:category:update')"
-                     type="primary"
-                     size="small"
-                     @click="addOrUpdateHandle(scope.row.categoryId)">修改</el-button>
-          <el-button v-if="isAuth('prod:category:delete')"
-                     type="danger"
-                     size="small"
-                     @click="deleteHandle(scope.row.categoryId)">删除</el-button>
-        </template>
-      </el-table-column>
-    </el-table>
-    <!-- 弹窗, 新增 / 修改 -->
-    <add-or-update v-if="addOrUpdateVisible"
-                   ref="addOrUpdate"
-                   @refreshDataList="getDataList"></add-or-update>
-  </div>
+                  @click="addOrUpdateHandle(scope.row.categoryId)">修改</el-button>
+      <el-button v-if="isAuth('prod:category:delete')"
+                  type="danger"
+                  size="small"
+                  @click="deleteHandle(scope.row.categoryId)">删除</el-button>
+    </template>
+  </avue-crud>
+  <!-- 弹窗, 新增 / 修改 -->
+  <add-or-update v-if="addOrUpdateVisible"
+                  ref="addOrUpdate"
+                  @refreshDataList="getDataList"></add-or-update>
+</div>
 </template>
 
 <script>
 import AddOrUpdate from './category-add-or-update'
-import { treeDataTranslate } from '@/utils'
+import { tableOption } from '@/crud/prod/category'
 
 export default {
   data () {
@@ -86,7 +50,8 @@ export default {
       dataList: [],
       dataListLoading: false,
       addOrUpdateVisible: false,
-      resourcesUrl: process.env.VUE_APP_RESOURCES_URL
+      resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
+      tableOption
     }
   },
   components: {
@@ -105,7 +70,7 @@ export default {
         params: this.$http.adornParams()
       }).then(({ data }) => {
         // this.dataList = treeDataTranslate(data, 'categoryId', 'parentId')
-        this.dataList = treeDataTranslate(data, 'parentId')
+        this.dataList = data
         this.dataListLoading = false
       })
     },

+ 1 - 1
src/views/modules/prod/prodList.vue

@@ -9,7 +9,7 @@
                @search-change="searchChange"
                @selection-change="selectionChange"
                @on-load="getDataList"
-               @row-update="onedit">
+               >
       <template slot="menuLeft">
         <el-button type="primary"
                    icon="el-icon-plus"

+ 35 - 28
src/views/modules/user/user.vue

@@ -1,7 +1,8 @@
 <template>
   <div class="mod-user">
     <avue-crud ref="crud" :page="page" :data="dataList" :option="tableOption" @search-change="searchChange"
-      @selection-change="selectionChange" @on-load="getDataList">
+      @selection-change="selectionChange" @on-load="getDataList"
+      @row-del="deleteUser">
       <!--      <template slot="menuLeft">-->
       <!--        <el-button type="danger"-->
       <!--                   @click="deleteHandle()"-->
@@ -21,17 +22,6 @@
         <el-tag v-if="scope.row.status === 0" size="small" type="danger">禁用</el-tag>
         <el-tag v-else size="small">正常</el-tag>
       </template>
-
-      <template slot-scope="scope" slot="menu">
-        <el-button type="primary" icon="el-icon-edit" size="small" v-if="isAuth('admin:user:update')"
-          @click.stop="addOrUpdateHandle(scope.row.userId)">编辑</el-button>
-
-        <!--        <el-button type="danger"-->
-        <!--                   icon="el-icon-delete"-->
-        <!--                   size="small"-->
-        <!--                   v-if="isAuth('admin:user:delete')"-->
-        <!--                   @click.stop="deleteHandle(scope.row.userId)">删除</el-button>-->
-      </template>
     </avue-crud>
 
     <!-- 弹窗, 新增 / 修改 -->
@@ -42,6 +32,8 @@
 <script>
 import { tableOption } from '@/crud/user/user'
 import AddOrUpdate from './user-add-or-update'
+import Axios from 'axios'
+
 export default {
   data() {
     return {
@@ -51,7 +43,7 @@ export default {
       addOrUpdateVisible: false,
       tableOption: tableOption,
       page: {
-        total: 0, // 总页数
+        total: 12, // 总页数
         currentPage: 1, // 当前页数
         pageSize: 10 // 每页显示多少条
       }
@@ -61,24 +53,39 @@ export default {
     AddOrUpdate
   },
   methods: {
+    deleteUser(user){
+      this.$confirm(`确定进行删除操作?`, '提示', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning'
+      }).then(() => {
+        console.log(user.id)
+        Axios.post("/user/deleteUser", {id: user.id}
+        ).then(({ data }) => {
+          console.log(data)
+          this.$message({
+            message: '操作成功',
+            type: 'success',
+            duration: 1500,
+            onClose: () => {
+              this.getDataList()
+            }
+          })
+        })
+      })
+    },
     // 获取数据列表
     getDataList(page, params, done) {
       this.dataListLoading = true
-      this.$http({
-        url: this.$http.adornUrl('/admin/user/page'),
-        method: 'get',
-        params: this.$http.adornParams(
-          Object.assign(
-            {
-              current: page == null ? this.page.currentPage : page.currentPage,
-              size: page == null ? this.page.pageSize : page.pageSize
-            },
-            params
-          )
-        )
-      }).then(({ data }) => {
-        this.dataList = data.records
-        this.page.total = data.total
+      Axios.post(this.$http.adornUrl('/user/queryUserList'),
+      Object.assign({
+          phone: "",
+          nickName: "",
+          limit: page == null ? this.page.pageSize : page.pageSize,
+          page: page == null ? this.page.currentPage : page.currentPage,
+      },params)).then(({data})=>{
+        this.dataList = data.data.userList
+        this.page.total = data.data.total
         this.dataListLoading = false
         if (done) {
           done()