Quellcode durchsuchen

feat(liveroomProd): 直播间商品列表

furffico vor 1 Jahr
Ursprung
Commit
196fbc3eef

+ 5 - 0
src/main.ts

@@ -12,6 +12,11 @@ Vue.config.productionTip = false
 
 // 挂载全局
 Vue.prototype.isAuth = isAuth     // 权限方法
+Vue.prototype.$shortcut = {
+  notFound() {
+    router.push({ name: "404" })
+  }
+}
 
 // 保存整站vuex本地储存初始状态
 // process.env.VUE_APP_RESOURCES_URL['storeState'] = cloneDeep(store.state)

+ 5 - 0
src/router/index.ts

@@ -71,6 +71,11 @@ export const pages = [
     component: _import("modules/liveroom/liveroomEdit"),
     name: "liveroomEdit",
     meta: { title: "直播间信息", sidebar: false, icon: "", isTab: false }
+  }, {
+    path: "/liveroom/product/:id",
+    component: _import("modules/liveroom/liveroomProd"),
+    name: "liveroomProd",
+    meta: { title: "直播间产品", sidebar: false, icon: "", isTab: false }
   },
 ]
 

+ 3 - 1
src/views/modules/liveroom/liveroomList-opbar.vue

@@ -8,7 +8,9 @@
         <el-button type="warning" size="small" disabled><icon-svg name="playback" /></el-button>
       </el-tooltip>
       <el-tooltip effect="dark" content="商品库" placement="top" :enterable="false">
-        <el-button type="primary" size="small" disabled><icon-svg name="product" /></el-button>
+        <el-button type="primary" size="small"
+          @click="$router.push({ name: 'liveroomProd', params: { id: id.toString() } })">
+          <icon-svg name="product" /></el-button>
       </el-tooltip>
       <el-tooltip effect="dark" content="客户咨询" placement="top" :enterable="false">
         <el-button type="primary" size="small" disabled><icon-svg name="question" /></el-button>

+ 74 - 0
src/views/modules/liveroom/liveroomProd.vue

@@ -0,0 +1,74 @@
+<template>
+  <avue-crud ref="crud" :page="page" :data="dataList" :table-loading="dataListLoading" :option="tableOption">
+    <template slot-scope="scope" slot="kind">
+      <el-tag v-if="scope.row.kind" size="small" :type="scope.row.kind === '自营' ? 'primary' : 'success'">
+        {{ scope.row.kind }}
+      </el-tag>
+    </template>
+
+    <template slot-scope="{row,index}" slot="menu">
+      <el-button type="primary" icon="el-icon-edit" size="small"
+        @click="$router.push({ name: 'prodInfo', params: { id: row.id.toString() } })">修改</el-button>
+    </template>
+  </avue-crud>
+</template>
+
+<script lang="ts">
+import Vue from 'vue'
+import { tableOption } from '@/avue/crud/prodList.js'
+import httpx from '@/utils/httpx'
+import { IPage } from '@/utils/vo'
+import { isInteger } from 'lodash'
+
+export default Vue.extend({
+  data() {
+    return {
+      dataForm: {
+        prodName: ''
+      },
+      dataList: [],
+      page: {
+        total: 0, // 总页数
+        currentPage: 1, // 当前页数
+        pageSize: 10 // 每页显示多少条
+      },
+      dataListSelections: [],
+      dataListLoading: false,
+      tableOption: tableOption,
+      resourcesUrl: process.env.VUE_APP_RESOURCES_URL,
+      id: 0,
+    }
+  },
+
+  mounted() {
+    const id_str = this.$route.params.id
+    const id = parseInt(id_str)
+    if (isNaN(id) || !isInteger(id)) {
+      //@ts-ignore
+      this.$shortcut.notFound()
+    } else {
+      this.id = id
+      this.getDataList()
+    }
+  },
+
+  methods: {
+    // 获取数据列表
+    getDataList(page?: IPage, params?: null, done?: Function) {
+      this.dataListLoading = true
+      httpx.post(httpx.makeurl('/rooms/roomGoods'), {
+        id: this.id,
+        limit: page == null ? this.page.pageSize : page.pageSize,
+        page: page == null ? this.page.currentPage : page.currentPage,
+      }).then(({ data }) => {
+        this.dataList = data.goodsEntityList
+        this.page.total = data.total
+        this.dataListLoading = false
+        if (done) {
+          done()
+        }
+      })
+    },
+  }
+})
+</script>