Browse Source

商品模块接口对接

e 5 years ago
parent
commit
ef710b465f

+ 24 - 0
src/api/goods.js

@@ -39,3 +39,27 @@ export function saveGoodsSort(sorts) {
     params: sorts
   })
 }
+
+export function getAddList(query) {
+  return request({
+    url: '/product/cmMallOrganizeProducts/toAddProduct1',
+    method: 'get',
+    params: query
+  })
+}
+
+export function saveAddList(data) {
+  return request({
+    url: '/product/cmMallOrganizeProducts/saveAddProductInfo',
+    method: 'post',
+    data: data
+  })
+}
+
+export function canncelProduct(data) {
+  return request({
+    url: '/product/cmMallOrganizeProducts/canncelProduct',
+    method: 'post',
+    data: data
+  })
+}

+ 1 - 1
src/router/index.js

@@ -120,7 +120,7 @@ export const constantRoutes = [
         path: 'list/preferred',
         name: 'PreferredProduct',
         component: () => import('@/views/goods/list-preferred'),
-        meta: { title: '星范优', noCache: true, activeMenu: '/goods/list' },
+        meta: { title: '星范优', noCache: true, activeMenu: '/goods/list' },
         hidden: true
       },
       {

+ 22 - 9
src/views/goods/list-commonly.vue

@@ -3,9 +3,9 @@
 
     <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
       <el-menu-item index="0"><router-link to="/goods/list">全部商品</router-link></el-menu-item>
-      <el-menu-item v-if="modules.firstModulesName" index="1"><router-link to="/goods/list/preferred">{{ modules.firstModulesName }}</router-link></el-menu-item>
-      <el-menu-item v-if="modules.secondModulesName" index="2"><router-link to="/goods/list/preferential">{{ modules.secondModulesName }}</router-link></el-menu-item>
-      <el-menu-item v-if="modules.thirdModulesName" index="3"><router-link to="/goods/list/commonly">{{ modules.thirdModulesName }}</router-link></el-menu-item>
+      <el-menu-item v-if="modules && modules.firstModulesName" index="1"><router-link to="/goods/list/preferred">{{ modules.firstModulesName }}</router-link></el-menu-item>
+      <el-menu-item v-if="modules && modules.secondModulesName" index="2"><router-link to="/goods/list/preferential">{{ modules.secondModulesName }}</router-link></el-menu-item>
+      <el-menu-item v-if="modules && modules.thirdModulesName" index="3"><router-link to="/goods/list/commonly">{{ modules.thirdModulesName }}</router-link></el-menu-item>
     </el-menu>
 
     <div class="filter-container" style="margin-top:20px;">
@@ -57,14 +57,14 @@
           <span>{{ row.addTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="排序值" align="center" prop="sort">
+      <el-table-column label="排序值" align="center" prop="commonlyProductSort">
         <template slot-scope="{row}">
-          <el-input v-model="row.preferredProductSort" style="width:60px;" size="small" />
+          <el-input v-model="row.commonlyProductSort" size="small" type="number" min="1" />
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="{row}">
-          <el-button :vid="row.id" type="primary" size="small">取消</el-button>
+          <el-button type="primary" size="small" @click="cancelGoods(row.id)">取消</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -75,7 +75,7 @@
 </template>
 
 <script>
-import { getList, getModule, saveGoodsSort } from '@/api/goods'
+import { getList, getModule, saveGoodsSort, canncelProduct } from '@/api/goods'
 import Pagination from '@/components/Pagination'
 export default {
   components: { Pagination },
@@ -125,9 +125,22 @@ export default {
     batchSaveSort() {
       const sorts = []
       this.list.map(item => {
-        sorts.push(item.id + '-' + item.preferredProduct)
+        sorts.push(item.id + '-' + item.commonlyProductSort)
       })
-      saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.activeIndex }).then(() => {
+      saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.activeIndex }).then(response => {
+        this.$notify({
+          title: response.code * 1 === 1 ? 'Success' : 'Error',
+          message: response.msg,
+          type: response.code * 1 === 1 ? 'success' : 'error',
+          duration: 2000
+        })
+        this.fetchData()
+      }).catch(() => {
+        this.fetchData()
+      })
+    },
+    cancelGoods(id) {
+      canncelProduct({ id: id, modules: this.activeIndex }).then(() => {
         this.fetchData()
       }).catch(() => {
         this.fetchData()

+ 22 - 9
src/views/goods/list-preferential.vue

@@ -3,9 +3,9 @@
 
     <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
       <el-menu-item index="0"><router-link to="/goods/list">全部商品</router-link></el-menu-item>
-      <el-menu-item v-if="modules.firstModulesName" index="1"><router-link to="/goods/list/preferred">{{ modules.firstModulesName }}</router-link></el-menu-item>
-      <el-menu-item v-if="modules.secondModulesName" index="2"><router-link to="/goods/list/preferential">{{ modules.secondModulesName }}</router-link></el-menu-item>
-      <el-menu-item v-if="modules.thirdModulesName" index="3"><router-link to="/goods/list/commonly">{{ modules.thirdModulesName }}</router-link></el-menu-item>
+      <el-menu-item v-if="modules && modules.firstModulesName" index="1"><router-link to="/goods/list/preferred">{{ modules.firstModulesName }}</router-link></el-menu-item>
+      <el-menu-item v-if="modules && modules.secondModulesName" index="2"><router-link to="/goods/list/preferential">{{ modules.secondModulesName }}</router-link></el-menu-item>
+      <el-menu-item v-if="modules && modules.thirdModulesName" index="3"><router-link to="/goods/list/commonly">{{ modules.thirdModulesName }}</router-link></el-menu-item>
     </el-menu>
 
     <div class="filter-container" style="margin-top:20px;">
@@ -57,14 +57,14 @@
           <span>{{ row.addTime | parseTime('{y}-{m}-{d} {h}:{i}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="排序值" align="center" prop="sort">
+      <el-table-column label="排序值" align="center" prop="preferentialProductSort">
         <template slot-scope="{row}">
-          <el-input v-model="row.preferredProductSort" style="width:60px;" size="small" />
+          <el-input v-model="row.preferentialProductSort" size="small" type="number" min="1" />
         </template>
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="{row}">
-          <el-button :vid="row.id" type="primary" size="small">取消</el-button>
+          <el-button type="primary" size="small" @click="cancelGoods(row.id)">取消</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -75,7 +75,7 @@
 </template>
 
 <script>
-import { getList, getModule, saveGoodsSort } from '@/api/goods'
+import { getList, getModule, saveGoodsSort, canncelProduct } from '@/api/goods'
 import Pagination from '@/components/Pagination'
 export default {
   components: { Pagination },
@@ -125,9 +125,22 @@ export default {
     batchSaveSort() {
       const sorts = []
       this.list.map(item => {
-        sorts.push(item.id + '-' + item.preferredProduct)
+        sorts.push(item.id + '-' + item.preferentialProductSort)
       })
-      saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.activeIndex }).then(() => {
+      saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.activeIndex }).then(response => {
+        this.$notify({
+          title: response.code * 1 === 1 ? 'Success' : 'Error',
+          message: response.msg,
+          type: response.code * 1 === 1 ? 'success' : 'error',
+          duration: 2000
+        })
+        this.fetchData()
+      }).catch(() => {
+        this.fetchData()
+      })
+    },
+    cancelGoods(id) {
+      canncelProduct({ id: id, modules: this.activeIndex }).then(() => {
         this.fetchData()
       }).catch(() => {
         this.fetchData()

+ 16 - 3
src/views/goods/list-preferred.vue

@@ -64,7 +64,7 @@
       </el-table-column>
       <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
         <template slot-scope="{row}">
-          <el-button :vid="row.id" type="primary" size="small">取消</el-button>
+          <el-button type="primary" size="small" @click="cancelGoods(row.id)">取消</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -75,7 +75,7 @@
 </template>
 
 <script>
-import { getList, getModule, saveGoodsSort } from '@/api/goods'
+import { getList, getModule, saveGoodsSort, canncelProduct } from '@/api/goods'
 import Pagination from '@/components/Pagination'
 export default {
   components: { Pagination },
@@ -127,7 +127,20 @@ export default {
       this.list.map(item => {
         sorts.push(item.id + '-' + item.preferredProductSort)
       })
-      saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.activeIndex }).then(() => {
+      saveGoodsSort({ newProducSorttList: sorts.join(','), modules: this.activeIndex }).then(response => {
+        this.$notify({
+          title: response.code * 1 === 1 ? 'Success' : 'Error',
+          message: response.msg,
+          type: response.code * 1 === 1 ? 'success' : 'error',
+          duration: 2000
+        })
+        this.fetchData()
+      }).catch(() => {
+        this.fetchData()
+      })
+    },
+    cancelGoods(id) {
+      canncelProduct({ id: id, modules: this.activeIndex }).then(() => {
         this.fetchData()
       }).catch(() => {
         this.fetchData()

+ 50 - 11
src/views/goods/list-select.vue

@@ -1,8 +1,10 @@
 <template>
   <div class="app-container">
 
-    <el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal">
-      <el-menu-item index="1">选择商品</el-menu-item>
+    <el-menu :default-active="moduleId" class="el-menu-demo" mode="horizontal">
+      <el-menu-item v-if="moduleId===1 && modules && modules.firstModulesName" index="1">{{ modules.firstModulesName }}</el-menu-item>
+      <el-menu-item v-if="moduleId===2 && modules && modules.secondModulesName" index="2">{{ modules.secondModulesName }}</el-menu-item>
+      <el-menu-item v-if="moduleId===3 && modules && modules.thirdModulesName" index="3">{{ modules.thirdModulesName }}</el-menu-item>
     </el-menu>
 
     <div class="filter-container" style="margin-top:20px;">
@@ -17,7 +19,7 @@
       <el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">
         搜索
       </el-button>
-      <el-button class="filter-item" type="primary" icon="el-icon-check">确定选择</el-button>
+      <el-button class="filter-item" type="primary" icon="el-icon-check" @click="confirmChoose()">确定选择</el-button>
       <el-button class="filter-item" type="primary" icon="el-icon-close" @click="toggleSelection()">取消选择</el-button>
     </div>
 
@@ -54,7 +56,7 @@
 </template>
 
 <script>
-import { getList } from '@/api/goods'
+import { getAddList, getModule, saveAddList } from '@/api/goods'
 import Pagination from '@/components/Pagination'
 export default {
   components: { Pagination },
@@ -70,10 +72,10 @@ export default {
   data() {
     return {
       list: null,
+      modules: null,
       classify: null,
       listLoading: true,
       total: 0,
-      activeIndex: '1',
       listQuery: {
         index: 1,
         pageSize: 20,
@@ -82,30 +84,67 @@ export default {
         productName: '',
         shopName: '',
         classifyID: ''
-      }
+      },
+      multipleSelection: []
     }
   },
   computed: {
     moduleId: function() {
-      return window.location.href.split('/').reverse()[0]
+      return window.location.href.split('/').reverse()[0] * 1
     }
   },
   created() {
+    this.getModuleType()
     this.fetchData()
   },
   methods: {
+    getModuleType() {
+      getModule({ organizeID: this.organizeID }).then(response => {
+        this.modules = response.data[0]
+      })
+    },
     fetchData() {
       this.listLoading = true
-      getList(this.listQuery).then(response => {
-        const { organizeProductsPage, listByEffective } = response.data
-        this.list = organizeProductsPage.results
-        this.total = organizeProductsPage.totalRecord
+      getAddList(this.listQuery).then(response => {
+        const { productsPage, listByEffective } = response.data
+        this.list = productsPage.results
+        this.total = productsPage.totalRecord
         this.classify = listByEffective
         this.listLoading = false
       })
     },
     handleFilter() {
       this.fetchData()
+    },
+    toggleSelection(rows) {
+      if (rows) {
+        rows.forEach(row => {
+          this.$refs.multipleTable.toggleRowSelection(row)
+        })
+      } else {
+        this.$refs.multipleTable.clearSelection()
+      }
+    },
+    handleSelectionChange(val) {
+      this.multipleSelection = val
+    },
+    confirmChoose() {
+      console.log(this.multipleSelection)
+      const itemsList = []
+      this.multipleSelection.map(item => {
+        itemsList.push(item.id)
+      })
+      saveAddList({ itemsList: itemsList, organizeID: this.organizeID, modules: this.moduleId }).then(response => {
+        this.$notify({
+          title: response.code * 1 === 1 ? 'Success' : 'Error',
+          message: response.code * 1 === 1 ? '添加成功' : response.msg,
+          type: response.code * 1 === 1 ? 'success' : 'error',
+          duration: 2000
+        })
+        this.fetchData()
+      }).catch(() => {
+        this.fetchData()
+      })
     }
   }
 }

+ 1 - 1
src/views/goods/list.vue

@@ -204,7 +204,7 @@ export default {
   methods: {
     getModuleType() {
       getModule({ organizeID: this.organizeID }).then(response => {
-        this.modules = response.data
+        this.modules = response.data[0]
       })
     },
     fetchData() {