Przeglądaj źródła

商品管理添加商品新增商品分类、商品标签

hwb0 3 lat temu
rodzic
commit
fdaffb81e5

+ 1 - 0
src/api/business/banner.js

@@ -0,0 +1 @@
+import request from '@/utils/request'

+ 10 - 0
src/api/business/category.js

@@ -0,0 +1,10 @@
+import request from '@/utils/request'
+
+// 查询分类下拉列表
+export function goodsCategoryItems(data) {
+  return request({
+    url: '/api/v1/mp/admin/goods/category/items',
+    method: 'post',
+    data
+  })
+}

+ 10 - 0
src/api/business/tag.js

@@ -0,0 +1,10 @@
+import request from '@/utils/request'
+
+// 查询标签下拉列表
+export function goodsTagItems(data) {
+  return request({
+    url: '/api/v1/mp/admin/goods/tag/items',
+    method: 'post',
+    data
+  })
+}

+ 48 - 2
src/views/business/goods/add.vue

@@ -28,6 +28,35 @@
           </el-form-item>
         </el-col>
       </el-row>
+      <el-row :gutter="40" style="width: 500px">
+        <el-col :span="23">
+          <el-form-item label="商品分类" prop="categoryId">
+            <el-select
+              v-model="addData.categoryId"
+              placeholder="请选择商品分类"
+              clearable
+              size="small"
+            >
+              <el-option :label="item.name" :value="item.categoryId" v-for="(item, index) in goodsCategoryItemsList" :key="index" />
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
+       <el-row :gutter="40" style="width: 500px">
+        <el-col :span="23">
+          <el-form-item label="商品标签">
+            <el-select
+              v-model="addData.tagIds"
+              placeholder="请选择商品标签"
+              multiple 
+              clearable
+              size="small"
+            >
+              <el-option :label="item.name" :value="item.tagId" v-for="(item, index) in goodsTagItemsList" :key="index" />
+            </el-select>
+          </el-form-item>
+        </el-col>
+      </el-row>
       <el-divider content-position="left">价格库存</el-divider>
       <el-row>
         <el-col :span="23">
@@ -101,6 +130,8 @@ import Upload from '@/components/DragImageUpload'
 import Spec from './components/spec'
 import TinyEditor from '@/components/TinyEditor'
 import { getGoodsDetail, addGoods } from '@/api/business/goods'
+import { goodsCategoryItems } from '@/api/business/category'
+import { goodsTagItems } from '@/api/business/tag'
 import { publicFileGetUrl } from "@/api/common"
 import { accDiv, accMul } from '@/utils/util'
 export default {
@@ -113,6 +144,8 @@ export default {
     return {
       IMG_URL: publicFileGetUrl,
       id: this.$route.query.id,
+      goodsCategoryItemsList: [],
+      goodsTagItemsList: [],
       addData: {
         multiSku: 0,
         description: ''
@@ -120,6 +153,7 @@ export default {
       rules: {
         title: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
         picUrl: [{ required: true, message: '请上传商品图片', trigger: 'change' }],
+        categoryId: [{ required: true, message: '请选择商品分类', trigger: 'change' }],
         exchangeShow: [{ required: true, message: '请选择是否支持盲豆兑换', trigger: 'change' }],
         multiSku: [{ required: true, message: '请选择SKU类型', trigger: 'change' }],
         value: [
@@ -157,13 +191,15 @@ export default {
     }
   },
   created() {
+    this.getGoodsCategoryItems()
+    this.getGoodsTagItems()
     if (this.id) {
       getGoodsDetail(this.id).then(res => {
-        const { goodsId, title, picUrl, exchangeShow, multiSku, value, exchangePrice, cost, quantity, description, skuList } = res.data
+        const { goodsId, title, picUrl, exchangeShow, multiSku, value, exchangePrice, cost, quantity, description, skuList, categoryId, tagIds } = res.data
         this.addData = {
           value: accDiv(value, 100),
           cost: cost == '' || cost == null ? '' : accDiv(cost, 100),
-          goodsId, title, picUrl, exchangeShow, multiSku, exchangePrice, quantity, description, skuList
+          goodsId, title, picUrl, exchangeShow, multiSku, exchangePrice, quantity, description, skuList, categoryId, tagIds
         }
         if (multiSku && skuList instanceof Array && skuList.length > 0) {
           this.$nextTick(() => {
@@ -174,6 +210,16 @@ export default {
     }
   },
   methods: {
+    getGoodsCategoryItems(){
+      goodsCategoryItems({}).then(res => {
+        this.goodsCategoryItemsList = res && res.data
+      })
+    },
+    getGoodsTagItems(){
+      goodsTagItems({}).then(res => {
+        this.goodsTagItemsList = res && res.data
+      })
+    },
     updateItem() {
       if (this.addData.multiSku == 1) {
         this.$refs.spec.getSkuList()