Просмотр исходного кода

feat:完善table组件以及场景列表demo实例化

jinx 3 лет назад
Родитель
Сommit
cd2624aa12

+ 0 - 0
.prettierignore


+ 13 - 0
.prettierrc

@@ -0,0 +1,13 @@
+{
+  "printWidth": 200,
+  "tabWidth": 4,
+  "useTabs": false,
+  "semi": false,
+  "singleQuote": true,
+  "arrowParens": "avoid",
+  "bracketSpacing": true,
+  "disableLanguages": [],
+  "eslintIntegration": false,
+  "stylelintIntegration": false,
+  "tslintIntegration": false
+}

+ 4 - 4
README.md

@@ -1,7 +1,7 @@
-# Vue 3 + Vite
+#
 
-This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
+npm install
 
-## Recommended IDE Setup
+npm run dev
 
-- [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar)
+npm run build

+ 11 - 11
index.html

@@ -1,14 +1,14 @@
 <!DOCTYPE html>
 <html lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <link rel="icon" href="/favicon.ico" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Vite App</title>
-  </head>
-  <body>
-    <div id="app"></div>
-    <script src="https://use.fontawesome.com/276552fbe7.js"></script>
-    <script type="module" src="/src/main.js"></script>
-  </body>
+    <head>
+        <meta charset="UTF-8" />
+        <link rel="icon" href="/favicon.ico" />
+        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+        <title>Vite App</title>
+    </head>
+    <body>
+        <div id="app"></div>
+        <script src="https://use.fontawesome.com/276552fbe7.js"></script>
+        <script type="module" src="/src/main.js"></script>
+    </body>
 </html>

+ 23 - 29
package-lock.json

@@ -199,18 +199,18 @@
       "integrity": "sha512-FbpX+hD5BvXCQerEYO7jtAGHlhAkhTQ4KIV73kmLWNlawWhTiVuQxizgVb0BOkX5oG9cIRZ42EG++d/k/Efp0w=="
     },
     "@vueuse/core": {
-      "version": "6.1.0",
-      "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-6.1.0.tgz",
-      "integrity": "sha512-6KienU5QOWKuDqvHytep14274IGKyLlACzXjifOrgDQMkqvWZIUnDhpckT/1+O8n8DN59d5wzzICZI/2sfGCyg==",
+      "version": "6.8.0",
+      "resolved": "https://registry.npmjs.org/@vueuse/core/-/core-6.8.0.tgz",
+      "integrity": "sha512-C6KMBus29L/mVtA5eK26WAqj6tyPlugrKaPLi2uLtbV//BHjbxe1uo3gVXCc5SwouDEdc7zswlGPw/l0/++NRg==",
       "requires": {
-        "@vueuse/shared": "6.1.0",
+        "@vueuse/shared": "6.8.0",
         "vue-demi": "*"
       }
     },
     "@vueuse/shared": {
-      "version": "6.1.0",
-      "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-6.1.0.tgz",
-      "integrity": "sha512-teW0TUQryGnEprHeOI6oH8NPVJBirknxksEiNCtdEjIi8W7JSTg8JPO+e1XlGI6ly24NDlDXUDYaHJayiaXjuw==",
+      "version": "6.8.0",
+      "resolved": "https://registry.npmjs.org/@vueuse/shared/-/shared-6.8.0.tgz",
+      "integrity": "sha512-+YjehQ8Qe4Qgyq8iTToVOzp4sZBAZvScv3AGJSMi6HYbe54+nyjrRfS8DN4fA0eUahyftHKZ00WKgMe7TS5N0w==",
       "requires": {
         "vue-demi": "*"
       }
@@ -608,19 +608,18 @@
       }
     },
     "element-plus": {
-      "version": "1.1.0-beta.24",
-      "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-1.1.0-beta.24.tgz",
-      "integrity": "sha512-dmo61e/D6mwJVacMhxOMSPb5sZPt/FPsuQQfsOs1kJWkhGDmTlny/sZvgIQr1z0zh3pjlJadGAlNS+0nySPMmw==",
+      "version": "1.2.0-beta.3",
+      "resolved": "https://registry.npmjs.org/element-plus/-/element-plus-1.2.0-beta.3.tgz",
+      "integrity": "sha512-vvUxR3uL2k9K+WCWz/98hq4uPQ6jvfGf0hfzWvao7pySJkNQq9DtRPC6/4/zUceA/J6Y2Yo3xSbR19JRCwurRw==",
       "requires": {
         "@element-plus/icons": "^0.0.11",
         "@popperjs/core": "^2.10.2",
-        "@vueuse/core": "~6.1.0",
-        "async-validator": "^4.0.3",
+        "@vueuse/core": "^6.7.3",
+        "async-validator": "^4.0.7",
         "dayjs": "^1.10.7",
         "lodash": "^4.17.21",
-        "memoize-one": "^5.2.1",
-        "normalize-wheel-es": "^1.1.0",
-        "resize-observer-polyfill": "^1.5.1"
+        "memoize-one": "^6.0.0",
+        "normalize-wheel-es": "^1.1.0"
       }
     },
     "emoji-regex": {
@@ -1287,9 +1286,9 @@
       "dev": true
     },
     "memoize-one": {
-      "version": "5.2.1",
-      "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-5.2.1.tgz",
-      "integrity": "sha512-zYiwtZUcYyXKo/np96AGZAckk+FWWsUdJ3cHGGmld7+AhvcWmQyGCYUh1hc4Q/pkOhb65dQR/pqCyK0cOaHz4Q=="
+      "version": "6.0.0",
+      "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz",
+      "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw=="
     },
     "meow": {
       "version": "9.0.0",
@@ -1462,9 +1461,9 @@
       "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA=="
     },
     "normalize-wheel-es": {
-      "version": "1.1.0",
-      "resolved": "https://registry.npmjs.org/normalize-wheel-es/-/normalize-wheel-es-1.1.0.tgz",
-      "integrity": "sha512-gkcE5xzp8WkSGgu2HItXePGyh3qDOetgPYg0RnjclOIaWTCMB75NTrk0t6KVlbm6ShSikV3ykBFZMiR9GDkvkA=="
+      "version": "1.1.1",
+      "resolved": "https://registry.npmjs.org/normalize-wheel-es/-/normalize-wheel-es-1.1.1.tgz",
+      "integrity": "sha512-157VNH4CngrcsvF8xOVOe22cwniIR3nxSltdctvQeHZj8JttEeOXffK28jucWfWBXs0QNetAumjc1GiInnwX4w=="
     },
     "npmlog": {
       "version": "4.1.2",
@@ -1772,11 +1771,6 @@
       "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",
       "dev": true
     },
-    "resize-observer-polyfill": {
-      "version": "1.5.1",
-      "resolved": "https://registry.npmjs.org/resize-observer-polyfill/-/resize-observer-polyfill-1.5.1.tgz",
-      "integrity": "sha512-LwZrotdHOo12nQuZlHEmtuXdqGoOD0OhaxopaNFxWzInpEgaLWoVuAMbTzixuosCx2nEG58ngzW3vxdWoxIgdg=="
-    },
     "resolve": {
       "version": "1.20.0",
       "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz",
@@ -2181,9 +2175,9 @@
       }
     },
     "vue-demi": {
-      "version": "0.11.4",
-      "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.11.4.tgz",
-      "integrity": "sha512-/3xFwzSykLW2HiiLie43a+FFgNOcokbBJ+fzvFXd0r2T8MYohqvphUyDQ8lbAwzQ3Dlcrb1c9ykifGkhSIAk6A=="
+      "version": "0.12.1",
+      "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.12.1.tgz",
+      "integrity": "sha512-QL3ny+wX8c6Xm1/EZylbgzdoDolye+VpCXRhI2hug9dJTP3OUJ3lmiKN3CsVV3mOJKwFi0nsstbgob0vG7aoIw=="
     },
     "vue-router": {
       "version": "4.0.12",

+ 14 - 2
package.json

@@ -8,18 +8,30 @@
   },
   "dependencies": {
     "axios": "^0.23.0",
-    "element-plus": "^1.1.0-beta.24",
+    "element-plus": "^1.2.0-beta.3",
     "js-base64": "^3.7.2",
+    "lint-staged": "^10.5.4",
+    "prettier": "^2.2.1",
     "qs": "^6.10.1",
     "sass": "^1.43.3",
     "vue": "^3.2.16",
     "vue-router": "^4.0.12",
-    "vuex": "^4.0.2"
+    "vuex": "^4.0.2",
+    "yorkie": "^2.0.0"
   },
   "devDependencies": {
     "@vitejs/plugin-vue": "^1.9.3",
     "node-sass": "^6.0.1",
     "sass-loader": "^12.2.0",
     "vite": "^2.6.4"
+  },
+  "gitHooks": {
+    "pre-commit": "lint-staged",
+    "commit-msg": "node scripts/git-verify-commit.js"
+  },
+  "lint-staged": {
+    "*.js": [
+      "prettier --write"
+    ]
   }
 }

+ 1 - 0
src/api/api.js

@@ -1,3 +1,4 @@
 import { get, post } from '@/util/http/request'
 export const loginapi = (params) => post('/sys/login', params)
 export const menuList = (params) => get('/sys/menu/user')
+export const infoAnon = (params) => get('/sys/user/infoAnon/' + params)

BIN
src/assets/img/no_bg.png


BIN
src/assets/logo.png


+ 14 - 0
src/components/icon/index.js

@@ -0,0 +1,14 @@
+import {
+  HomeFilled,
+  Coin,
+  Sell,
+  PictureFilled,
+  Delete
+} from '@element-plus/icons'
+export default function injectIcon(app) {
+  app.component('homeFilled',HomeFilled)
+  app.component('coin',Coin)
+  app.component('sell',Sell)
+  app.component('pictureFilled',PictureFilled)
+  app.component('delete',Delete )
+}

+ 1 - 1
src/components/searchForm/index.vue

@@ -9,7 +9,7 @@
           <!-- <el-input
             v-model.trim="searchData.data[index].value" -->
           <el-input v-model="searchData[i.model]"
-                    placeholder="Please input" />
+                    :placeholder="i.placeholder" />
         </div>
         <div class="selectBox"
              v-if="i.type == 'select'">

+ 38 - 16
src/components/tableForm/index.vue

@@ -12,7 +12,8 @@
     </searchForm>
     <div id="tableForm">
       <div class="tableContent">
-        <el-table :data="tableData"
+        <el-table v-loading="loading"
+                  :data="tableData"
                   style="width: 100%">
           <el-table-column v-for="(item, i) in tableHeader"
                            :key="i"
@@ -49,14 +50,23 @@
         </el-table>
       </div>
       <div class="paginationBox">
+
         <el-pagination v-model:currentPage="currentPage2"
+                       layout="prev, pager, next"
+                       :page-sizes="sizes"
+                       :page-size="sizes[0]"
+                       :total="pageInfo.total || 100"
+                       @size-change="handleSizeChange"
+                       @current-change="handlePageChange"></el-pagination>
+        <!-- <el-pagination v-model:currentPage="currentPage2"
                        :page-sizes="sizes"
                        :page-size="sizes[0]"
-                       layout="sizes, prev, pager, next"
-                       :total="1000"
+                       layout="prev, pager, next"
+                       :total="pageInfo.total"
                        @size-change="handleSizeChange"
-                       @current-change="handleCurrentChange">
-        </el-pagination>
+                       @current-change="handlePageChange">
+        </el-pagination> -->
+
       </div>
     </div>
 
@@ -64,7 +74,14 @@
 </template>
 
 <script>
-import { defineComponent, reactive, ref, toRefs, onMounted } from 'vue'
+import {
+  defineComponent,
+  reactive,
+  ref,
+  toRefs,
+  onMounted,
+  getCurrentInstance,
+} from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import searchForm from '@/components/searchForm/index.vue'
 import vSolt from './vSolt.vue'
@@ -72,6 +89,8 @@ export default defineComponent({
   // props: ['dataApi', 'tableHeader'],
   props: {
     handleSearch: Function,
+    handleSizeChange: Function,
+    handlePageChange: Function,
     config: {
       type: Object,
       default: function () {
@@ -91,11 +110,22 @@ export default defineComponent({
         return null
       },
     },
+    pageInfo: {
+      type: Object,
+      default: function () {
+        return null
+      },
+    },
+    loading: {
+      type: Boolean,
+      default: false,
+    },
   },
   setup(props, context) {
+    const { ctx } = getCurrentInstance()
     const data = reactive({
       sizes: [10, 30, 50, 100],
-      currentPage2: ref(5),
+      currentPage2: ref(1),
       // tableData: [],
       pageParam: {
         limit: 10,
@@ -110,7 +140,6 @@ export default defineComponent({
     onMounted(() => {
       // handleTableData()
     })
-
     const handleTableData = () => {
       props
         .dataApi(data.pageParam)
@@ -120,15 +149,8 @@ export default defineComponent({
         })
         .catch((err) => {})
     }
-    const handleSizeChange = (val) => {
-      console.log(`${val} items per page`)
-    }
-    const handleCurrentChange = (val) => {
-      console.log(`current page: ${val}`)
-    }
+
     return {
-      handleSizeChange,
-      handleCurrentChange,
       ...toRefs(data),
     }
   },

+ 107 - 100
src/layout/aside/index.vue

@@ -15,13 +15,20 @@
              :key="index">
           <el-menu-item v-if="!item.children"
                         :index="item.path">
-            <i :class="item.icon"></i>
+
+            <el-icon :size="10">
+              <component :is="item.icon" />
+            </el-icon>
+            <!-- <i :class="item.icon"></i> -->
             <span>{{ item.name }}</span>
           </el-menu-item>
           <el-sub-menu v-else
                        :index="item.key">
             <template #title>
-              <i :class="item.icon"></i>
+              <!-- <i :class="item.icon"></i> -->
+              <el-icon :size="10">
+                <component :is="item.icon" />
+              </el-icon>
               <span>{{ item.name }}</span>
             </template>
             <div v-for="(j, j_index) in item.children"
@@ -39,109 +46,109 @@ import { defineComponent, reactive, ref, toRefs, onMounted } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { useStore } from 'vuex'
 export default defineComponent({
-  name: 'Aside',
-  components: {},
-  setup(props, ctx) {
-    const router = useRouter()
-    const route = useRoute()
-    const store = useStore()
-    const data = reactive({
-      muenList: [
-        {
-          name: '首页',
-          path: '/home',
-          icon: 'el-icon-location',
-          key: 'home',
-        },
-        {
-          name: 'VR场景',
-          path: null,
-          icon: 'el-icon-document',
-          key: 'vrList',
-          children: [
-            {
-              name: '场景列表',
-              path: '/sence',
-              icon: '',
-              key: 'sence',
-            },
-            {
-              name: '直播间',
-              path: '/live',
-              icon: '',
-              key: 'live',
-            },
-          ],
-        },
-        {
-          name: '商品管理',
-          path: null,
-          icon: 'el-icon-setting',
-          key: 'product',
-          children: [
-            {
-              name: '商品属性',
-              path: '/productNature',
-              icon: '',
-              key: 'productNature',
-            },
-            {
-              name: '商品列表',
-              path: '/productList',
-              icon: '',
-              key: 'productList',
-            },
-          ],
-        },
-      ],
-      activeName: '',
-    })
-    onMounted(() => {
-      //   data.activeName = route.meta.title;
-      let storeMenuList = JSON.parse(localStorage.getItem('menuList'))
-      console.log(storeMenuList)
-      // this.muenList = storeMenuList
-      data.activeName = route.path
-      console.log(data.activeName)
-      //   console.log(route.meta.title);
-    })
-    const handleOpen = (key, keyPath) => {
-      //   console.log(key, keyPath);
-    }
-    const handleClose = (key, keyPath) => {
-      //   console.log(key, keyPath);
-    }
-    const handleClick = (key, keyPath) => {
-      //   console.log(key, keyPath);
-      //   console.log(route);
-      // store.commit("setNavTitle", route.name);
-      // console.log(store.state.navTitle);
-    }
-    return {
-      handleOpen,
-      handleClose,
-      handleClick,
-      ...toRefs(data),
-    }
-  },
+    name: 'Aside',
+    components: {},
+    setup(props, ctx) {
+        const router = useRouter()
+        const route = useRoute()
+        const store = useStore()
+        const data = reactive({
+            muenList: [
+                {
+                    name: '首页',
+                    path: '/home',
+                    icon: 'homeFilled',
+                    key: 'home',
+                },
+                {
+                    name: 'VR场景',
+                    path: null,
+                    icon: 'coin',
+                    key: 'vrList',
+                    children: [
+                        {
+                            name: '场景列表',
+                            path: '/sence',
+                            icon: '',
+                            key: 'sence',
+                        },
+                        {
+                            name: '直播间',
+                            path: '/live',
+                            icon: '',
+                            key: 'live',
+                        },
+                    ],
+                },
+                {
+                    name: '商品管理',
+                    path: null,
+                    icon: 'sell',
+                    key: 'product',
+                    children: [
+                        {
+                            name: '商品属性',
+                            path: '/productNature',
+                            icon: '',
+                            key: 'productNature',
+                        },
+                        {
+                            name: '商品列表',
+                            path: '/productList',
+                            icon: '',
+                            key: 'productList',
+                        },
+                    ],
+                },
+            ],
+            activeName: '',
+        })
+        onMounted(() => {
+            //   data.activeName = route.meta.title;
+            let storeMenuList = JSON.parse(localStorage.getItem('menuList'))
+            console.log(storeMenuList)
+            // data.muenList = storeMenuList
+            data.activeName = route.path
+            console.log(data.activeName)
+            //   console.log(route.meta.title);
+        })
+        const handleOpen = (key, keyPath) => {
+            //   console.log(key, keyPath);
+        }
+        const handleClose = (key, keyPath) => {
+            //   console.log(key, keyPath);
+        }
+        const handleClick = (key, keyPath) => {
+            //   console.log(key, keyPath);
+            //   console.log(route);
+            // store.commit("setNavTitle", route.name);
+            // console.log(store.state.navTitle);
+        }
+        return {
+            handleOpen,
+            handleClose,
+            handleClick,
+            ...toRefs(data),
+        }
+    },
 })
 </script>
 
 <style scoped lang="scss">
 #aside {
-  width: 200px;
-  height: 100vh;
-  background: #2f4050;
-  .productName {
-    color: #fff;
-    text-align: center;
-    padding: 13px 0;
-    box-sizing: border-box;
-  }
-  .menuList {
-    .el-menu {
-      border-right: none;
+    width: 200px;
+    height: 100vh;
+    background: #2f4050;
+    .productName {
+        color: #fff;
+        text-align: center;
+        padding: 13px 0;
+        box-sizing: border-box;
+    }
+    .menuList {
+        .el-menu {
+            border-right: none;
+        }
     }
-  }
 }
 </style>

+ 15 - 5
src/layout/login/login.vue

@@ -16,7 +16,7 @@ import { defineComponent, reactive, ref, toRefs, onMounted } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { useStore } from 'vuex'
 import { Base64 } from 'js-base64'
-import { loginapi, menuList } from '@/api/api'
+import { loginapi, menuList, infoAnon } from '@/api/api'
 import { encodeStr } from '@/util/common'
 import { setLocalStorage } from '@/util/browser'
 export default defineComponent({
@@ -54,14 +54,24 @@ export default defineComponent({
       loginapi(params)
         .then((res) => {
           console.log(res)
-          store.commit('setUserInfo', res.user)
+
           store.commit('setToken', res.token)
           router.push('/home')
-          menuList()
+          infoAnon(res.user.userId)
             .then((res) => {
               console.log(res)
-              store.commit('setMenuList', res.menuList)
-              console.log(store.state.menuList)
+              store.commit('setUserInfo', res.user)
+            })
+            .catch((err) => {})
+          menuList()
+            .then((res) => {
+              if (res.code == 0) {
+                console.log(res)
+                store.commit('setMenuList', res.menuList)
+                console.log(store.state.menuList)
+              } else {
+              }
+              // store.commit('setToken', res.token)
             })
             .catch((err) => {})
         })

+ 6 - 0
src/main.js

@@ -1,12 +1,18 @@
 import { createApp } from 'vue'
 import ElementPlus from 'element-plus'
+// import {Edit} from '@element-plus/icons'
 import locale from 'element-plus/lib/locale/lang/zh-cn'
 import 'element-plus/dist/index.css'
 import App from './App.vue'
 import router from './router'
 import store from './store'
+import authDirective from '@/util/directive'
+import injectIcon from '@/components/icon'
 console.log(import.meta.env.VITE_USER_NAME)
 const app = createApp(App)
+// app.component('edit',Edit)
+authDirective(app, store)
+injectIcon(app)
 app.config.productionTip = false
 app.use(ElementPlus, {
   locale,

+ 8 - 0
src/router/index.js

@@ -55,6 +55,14 @@ router.beforeEach(function (to, from, next) {
     if (to.path !== '/login') {
       return next('/login')
     }
+  } else {
+    if (!store.state.userInfo) {
+      let info = JSON.parse(localStorage.getItem('userInfo')) || {}
+      store.commit('setUserInfo', info)
+    } else if (store.state.menuList.length == 0) {
+      let menuList = JSON.parse(localStorage.getItem('menuList')) || []
+      store.commit('setMenuList', menuList)
+    }
   }
   store.commit('setNavTitle', to.name)
   next()

+ 55 - 0
src/util/directive.js

@@ -0,0 +1,55 @@
+// export default function directive(app) {
+//   app.directive('auths', (el) => {
+//     el.style[binding.arg] = '100px'
+//   })
+// }
+
+export default function authDirective(app, store) {
+  // 单个权限验证(v-auth="xxx")
+  app.directive('auth', {
+    mounted(el, binding) {
+      console.log(store.state.userInfo)
+      if (!store.state.userInfo.roleIdList.some((v) => v === binding.value))
+        el.parentNode.removeChild(el)
+    },
+  })
+  // 多个权限验证,满足一个则显示(v-auths="[xxx,xxx]")
+  app.directive('auths', {
+    mounted(el, binding) {
+      let flag = false
+      store.state.userInfo.roleIdList.map((val) => {
+        binding.value.map((v) => {
+          if (val === v) flag = true
+        })
+      })
+      if (!flag) el.parentNode.removeChild(el)
+    },
+  })
+  // 多个权限验证,全部满足则显示(v-auth-all="[xxx,xxx]")
+  app.directive('auth-all', {
+    mounted(el, binding) {
+      const flag = judementSameArr(
+        binding.value,
+        store.state.userInfo.roleIdList
+      )
+      if (!flag) el.parentNode.removeChild(el)
+    },
+  })
+}
+
+/**
+ * 判断两数组是否相同
+ * @param news 新数据
+ * @param old 源数据
+ * @returns 两数组相同返回 `true`,反之则反
+ */
+function judementSameArr(news, old) {
+  let count = 0
+  const leng = old.length
+  for (let i in old) {
+    for (let j in news) {
+      if (old[i] === news[j]) count++
+    }
+  }
+  return count === leng ? true : false
+}

+ 253 - 202
src/views/sence/sence.vue

@@ -1,9 +1,15 @@
 <template>
   <div id="sence">
 
-    <tableForm :tableData="tableData"
+    <!-- <a v-auth-all="[2,1]">122</a> -->
+    <tableForm :loading="loading"
+               :tableData="tableData"
                :searchFormData="searchFormData"
-               :tableHeader="tableHeader">
+               :handleSearch="handleSearch"
+               :tableHeader="tableHeader"
+               :pageInfo="pageInfo"
+               :handlePageChange="handlePageChange"
+               :handleSizeChange="handleSizeChange">
 
       <!-- <template #button>
         <el-button type="success">新增</el-button>
@@ -25,16 +31,45 @@
                width="40%"
                :before-close="handleClose">
 
-      <el-form ref="formData"
-               label-width="80px">
+      <el-form label-width="140px"
+               :model="editData">
         <el-form-item label="场景名称">
-          <el-input></el-input>
+          <el-input v-model="editData.sceneName"></el-input>
         </el-form-item>
         <el-form-item label="封面">
-          <div class="">
+          <div class="picBox">
+            <img :src="editData.thumb ?editData.thumb:`@/assets/img/no_bg.png`"
+                 alt="">
+          </div>
+          <div class="contorlBtn">
+            <div>
+              <el-icon :size="14">
+                <pictureFilled />
+              </el-icon>
+            </div>
+            <div>
+              <el-icon :size="14">
+                <delete />
+              </el-icon>
+            </div>
+
+          </div>
+          <div class="Msg">
+            <p>1、支持png、jpg和gif图片格式;</p>
+            <p>2、最大可上传2M的图片。</p>
+            <p>3、推荐大小:400 * 400 像素</p>
+          </div>
+        </el-form-item>
 
+        <el-form-item label="是否在小程序里显示">
+          <div>
+            <el-radio v-model="radio1"
+                      label="1">是</el-radio>
+            <el-radio v-model="radio1"
+                      label="2">否</el-radio>
           </div>
         </el-form-item>
+
       </el-form>
 
       <template #footer>
@@ -49,221 +84,237 @@
 </template>
 
 <script>
-import {
-  defineComponent,
-  reactive,
-  ref,
-  toRefs,
-  onMounted,
-  getCurrentInstance,
-  h,
-} from 'vue'
+import { defineComponent, reactive, ref, toRefs, onMounted, getCurrentInstance, h } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import { ElMessageBox } from 'element-plus'
 import tableForm from '@/components/tableForm/index.vue'
 import { senceList } from '@/api/sence'
+// import { Edit } from '@element-plus/icons'
 export default defineComponent({
-  components: { tableForm },
-  setup(props) {
-    const { ctx } = getCurrentInstance()
-    const data = reactive({
-      dialogVisible: false,
-      pageParam: {
-        limit: 10,
-        nd: 1635487948418,
-        order: 'asc',
-        page: 1,
-        sidx: '',
-        token: localStorage.getItem('token'),
-        _search: false,
-      },
-    })
-    const searchFormData = ref({
-      formData: {},
-      searchList: [
-        {
-          type: 'input',
-          model: 'input_data',
-          inputType: 'text',
-        },
-        {
-          type: 'select',
-          model: 'select_data',
-          options: [
-            {
-              value: 'Option1',
-              label: 'Option1',
-            },
-            {
-              value: 'Option2',
-              label: 'Option2',
-            },
-            {
-              value: 'Option3',
-              label: 'Option3',
+    components: { tableForm },
+    setup(props) {
+        const { ctx } = getCurrentInstance()
+        const data = reactive({
+            radio1: '1',
+            editData: {},
+            loading: true,
+            dialogVisible: false,
+            pageInfo: {},
+            pageParam: {
+                limit: 10,
+                nd: 1635487948418,
+                order: 'asc',
+                page: 1,
+                sidx: '',
+                token: localStorage.getItem('token'),
+                _search: false,
             },
+        })
+
+        const searchFormData = ref({
+            formData: {},
+            searchList: [
+                {
+                    type: 'input',
+                    model: 'input_data',
+                    inputType: 'text',
+                    placeholder: '场景名称',
+                },
+            ],
+            // action: [
+            //   {
+            //     name: '新增',
+            //     clickFun: () => {
+            //       data.dialogVisible = true
+            //       // handleTableData()
+            //     },
+            //   },
+            // ],
+        })
+        const handleClose = () => {
+            console.log('handleClose')
+        }
+        const tableHeader = ref([
+            { prop: 'sceneName', label: '场景名称' },
             {
-              value: 'Option4',
-              label: 'Option4',
+                prop: 'thumb',
+                label: '封面',
+                render: params => {
+                    // console.log(params.row.thumb)
+                    return h('img', {
+                        style: {
+                            width: '100px',
+                            height: '100px',
+                        },
+                        src: params.row.thumb,
+                    })
+                },
             },
+            { prop: 'sceneUrl', label: '场景链接' },
             {
-              value: 'Option5',
-              label: 'Option5',
-            },
-          ],
-        },
-      ],
-      // action: [
-      //   {
-      //     name: '新增',
-      //     clickFun: () => {
-      //       data.dialogVisible = true
-      //       // handleTableData()
-      //     },
-      //   },
-      // ],
-    })
-    const handleClose = () => {
-      console.log('handleClose')
-    }
-    const tableHeader = ref([
-      { prop: 'sceneName', label: '场景名称' },
-      {
-        prop: 'thumb',
-        label: '封面',
-        render: (params) => {
-          // console.log(params.row.thumb)
-          return h('img', {
-            style: {
-              width: '100px',
-              height: '100px',
-            },
-            src: params.row.thumb,
-          })
-        },
-      },
-      { prop: 'sceneUrl', label: '场景链接' },
-      {
-        prop: 'sceneType',
-        label: '是否显示',
-        render: (params) => {
-          if (params.row.sceneType == 0) {
-            return h(
-              'span',
-              {
-                style: {
-                  fontSize: '10px',
-                  fontWeight: 600,
-                  backgroundColor: ' #ed5565',
-                  color: '#FFFFFF',
-                  padding: '3px 8px',
+                prop: 'sceneType',
+                label: '是否显示',
+                render: params => {
+                    if (params.row.sceneType == 0) {
+                        return h(
+                            'span',
+                            {
+                                style: {
+                                    fontSize: '10px',
+                                    fontWeight: 600,
+                                    backgroundColor: ' #ed5565',
+                                    color: '#FFFFFF',
+                                    padding: '3px 8px',
+                                },
+                            },
+                            '否'
+                        )
+                    } else {
+                        return h(
+                            'span',
+                            {
+                                style: {
+                                    fontSize: '10px',
+                                    fontWeight: 600,
+                                    backgroundColor: ' #409EFF',
+                                    color: '#FFFFFF',
+                                    padding: '3px 8px',
+                                },
+                            },
+                            '是'
+                        )
+                    }
                 },
-              },
-              '否'
-            )
-          } else {
-            return h(
-              'span',
-              {
-                style: {
-                  fontSize: '10px',
-                  fontWeight: 600,
-                  backgroundColor: ' #409EFF',
-                  color: '#FFFFFF',
-                  padding: '3px 8px',
-                },
-              },
-              '是'
-            )
-          }
-        },
-      },
-      {
-        // prop: 'action',
-        label: '操作',
-        action: [
-          {
-            name: '修改',
-            type: 'danger',
-            clickFun: (index, row) => {
-              // console.log(index, row)
-              editRow(index, row)
-            },
-          },
-          {
-            name: '打开编辑器',
-            type: 'success',
-            clickFun: (index, row) => {
-              console.log(index, row)
             },
-          },
-          {
-            name: '生成直播间',
-            clickFun: (index, row) => {
-              console.log(index, row)
-              hanldeDelRow(index, row)
+            {
+                // prop: 'action',
+                label: '操作',
+                action: [
+                    {
+                        name: '修改',
+                        type: 'danger',
+                        clickFun: (index, row) => {
+                            // console.log(index, row)
+                            editRow(index, row)
+                        },
+                    },
+                    {
+                        name: '打开编辑器',
+                        type: 'success',
+                        clickFun: (index, row) => {
+                            console.log(index, row)
+                        },
+                    },
+                    {
+                        name: '生成直播间',
+                        clickFun: (index, row) => {
+                            console.log(index, row)
+                            hanldeDelRow(index, row)
+                        },
+                    },
+                ],
             },
-          },
-        ],
-      },
-    ])
-    const tableData = ref([])
+        ])
+        const tableData = ref([])
 
-    // const getSenceList = (params) => {
-    //   return senceList(params)
-    // }
-    onMounted(() => {
-      handleTableData()
-    })
-    const handleSearch = (res) => {
-      console.log('handleSearch', res)
-    }
-    const handleTableData = async () => {
-      let res = await senceList(data.pageParam)
-      // .then((res) => {
-      //   console.log(res)
-      //   data.tableData = res.page.list
-      // })
-      // .catch((err) => {})
-      tableData.value = res.page.list
-      console.log(tableData)
-    }
-    const editRow = (index, row) => {
-      data.formData = row
-      data.dialogVisible = true
-      // console.log(formData.value.sceneName)
-    }
-    const hanldeDelRow = (index, row) => {
-      ElMessageBox.confirm('是否删除改数据?', {
-        confirmButtonText: '确认',
-        cancelButtonText: '取消',
-      })
-        .then(() => {
-          tableData.value.splice(index, 1)
+        // const getSenceList = (params) => {
+        //   return senceList(params)
+        // }
+        onMounted(() => {
+            handleTableData()
         })
-        .catch(() => {
-          // catch error
-        })
-    }
-    return {
-      handleSearch,
-      handleTableData,
-      handleClose,
-      tableHeader,
-      tableData,
-      searchFormData,
-      ...toRefs(data),
-    }
-  },
+        //分页
+        const handlePageChange = val => {
+            console.log(`current page: ${val}`)
+            data.pageParam.page = val
+            handleTableData()
+        }
+        //页码
+        const handleSizeChange = val => {
+            console.log(`${val} items per page`)
+            data.pageParam.limit = val
+            handleTableData()
+        }
+        const handleSearch = res => {
+            console.log('handleSearch', res)
+            data.pageParam.name = res.input_data
+            handleTableData()
+        }
+        const handleTableData = async () => {
+            data.loading = true
+            let res = await senceList(data.pageParam)
+
+            data.loading = false
+            tableData.value = res.page.list
+            data.pageInfo = res.page
+            console.log(tableData)
+        }
+        const editRow = (index, row) => {
+            data.dialogVisible = true
+
+            data.editData = JSON.parse(JSON.stringify(row))
+            console.log(data.editData)
+        }
+        const hanldeDelRow = (index, row) => {
+            ElMessageBox.confirm('是否删除改数据?', {
+                confirmButtonText: '确认',
+                cancelButtonText: '取消',
+            })
+                .then(() => {
+                    tableData.value.splice(index, 1)
+                })
+                .catch(() => {
+                    // catch error
+                })
+        }
+        return {
+            handleSizeChange,
+            handlePageChange,
+            handleSearch,
+            handleTableData,
+            handleClose,
+            tableHeader,
+            tableData,
+            searchFormData,
+            ...toRefs(data),
+        }
+    },
 })
 </script>
 
 <style  lang="scss">
 #sence {
-  .cell {
-    .el-link {
-      display: block;
+    .cell {
+        .el-link {
+            display: block;
+        }
+    }
+    .picBox {
+        width: 120px;
+        height: 120px;
+        img {
+            width: 100%;
+            height: 100%;
+        }
+    }
+    .contorlBtn {
+        display: flex;
+        align-items: center;
+        justify-content: flex-start;
+        margin: 10px;
+        > div {
+            cursor: pointer;
+            display: flex;
+            align-items: center;
+            justify-content: center;
+            margin-right: 10px;
+        }
+    }
+    .Msg {
+        > p {
+            font-size: 12px;
+            color: #676a6c;
+        }
     }
-  }
 }
 </style>