Explorar el Código

2024.04.06
- 完善加入选品参数传参及其展示框;

zweiqin hace 1 año
padre
commit
2180293799

+ 2 - 1
package.json

@@ -32,7 +32,8 @@
 		"vue-quill-editor": "^3.0.6",
 		"vue-router": "3.0.6",
 		"vuedraggable": "^2.24.3",
-		"vuex": "3.1.0"
+		"vuex": "3.1.0",
+		"xe-utils": "^3.5.24"
 	},
 	"devDependencies": {
 		"@vue/cli-plugin-babel": "4.4.4",

+ 3 - 2
src/views/commodity/commoditySystem/addCommodity.vue

@@ -71,7 +71,7 @@
                 v-for="(item, index) in groupList" :key="index" :label="item.groupName"
                 :value="item.shopGroupId"
                 />
-              </el-select> -->
+                </el-select> -->
             </el-form-item>
             <el-form-item label="品牌">
               <el-select v-model="form.brandId" clearable placeholder="请选择品牌">
@@ -211,6 +211,7 @@ export default {
         shelveState: '', // 是否上架 1-上架 0-不上架
         ifOversold: '', // 是否允许超卖 1-是 0-否
         ifCredit: '', // 是否支持积分兑换 1-是 0-否
+        ifSelection: -1,
         creditLimit: '', // 单笔订单限制使用多少积分
         ifHuabei: 1, // 是否支持花呗分期 1-是 0-否
         productText: '', // 商品描述(富文本)
@@ -418,6 +419,7 @@ export default {
         shelveState: ' ',
         ifOversold: '',
         ifCredit: '',
+        ifSelection: -1,
         creditLimit: '',
         ifHuabei: 1,
         productText: '',
@@ -551,7 +553,6 @@ export default {
       if (this.productId) {
         this.form.productId = this.productId
         const sku = JSON.parse(sessionStorage.getItem('form'))
-        // console.log(sku)
         sku.forEach((element, i) => {
           for (let index = 0; index < this.form.skus.length; index++) {
             if (i === index) {

+ 1 - 1
src/views/selectionCenter/distributionPricingPlan/components/EditModal.vue

@@ -163,7 +163,7 @@ export default {
       this.$refs.formData.validate(async (valid) => {
         if (valid) {
           await this.$validatorForm('formData')
-          const loading = this.$elLoading()
+          const loading = this.$loading({ text: '提交中,请稍候……' })
           try {
             const { ...otps } = this.formData
             const params = {

+ 19 - 15
src/views/selectionCenter/productSelectionList/components/PlatformSelection.vue

@@ -89,7 +89,10 @@
               <el-button size="mini" @click="handleDetail(row)">
                 查看
               </el-button>
-              <el-button :disabled="row.ifSelection" type="success" size="mini" @click="handleSelectPlatformSelection(row)">
+              <el-button
+                :disabled="row.ifSelection" type="success" size="mini"
+                @click="$refs.SelectionAddModal && $refs.SelectionAddModal.handleOpen(row)"
+              >
                 加入
               </el-button>
             </template>
@@ -108,19 +111,24 @@
 
       <!-- 查看详情 -->
       <DetailModal ref="DetailModal" @success="getList" />
+      <!-- 加入选品 -->
+      <SelectionAddModal ref="SelectionAddModal" @success="getList" />
     </div>
   </el-dialog>
 </template>
 
 <script>
 import DetailModal from './DetailModal'
-import { shopSelectionGetPlatformLibrary, shopSelectionSelectShopLibrary } from '@/api/selectionCenter/selectionCenter'
-import { getBrandList, commodityListGetAll } from '@/api/commodity'
+import SelectionAddModal from './SelectionAddModal'
+import { shopSelectionGetPlatformLibrary } from '@/api/selectionCenter/selectionCenter'
+import { getBrandList, getGroupSelect } from '@/api/commodity'
+import XeUtils from 'xe-utils'
 
 export default {
   name: 'PlatformSelection',
   components: {
-    DetailModal
+    DetailModal,
+    SelectionAddModal
   },
   data() {
     return {
@@ -176,20 +184,16 @@ export default {
       this.$refs.DetailModal && this.$refs.DetailModal.handleOpen(row)
     },
     async getGroupDataList() {
-      const result = await commodityListGetAll({ search: '', page: 1, pageSize: 9999 })
-      this.groupList = result.data.list
+      const result = await getGroupSelect({})
+      XeUtils.eachTree(result.data, (item) => {
+        if (Array.isArray(item.childs) && item.childs.length === 0) {
+          item.childs = undefined
+        }
+      }, { children: 'childs' })
+      this.groupList = result.data
     },
     handleOpen(params = {}) {
       this.visible = true
-    },
-    handleSelectPlatformSelection(row) {
-      this.$confirm('确定选择此项?')
-        .then(async () => {
-          await shopSelectionSelectShopLibrary({ productId: row.productId })
-          this.$message({ message: '加入成功!', type: 'success' })
-          this.handleSearch()
-        })
-        .catch(() => {})
     }
   }
 }

+ 147 - 0
src/views/selectionCenter/productSelectionList/components/SelectionAddModal.vue

@@ -0,0 +1,147 @@
+<template>
+  <el-dialog
+    :visible.sync="visible"
+    v-bind="modalOptions"
+    append-to-body
+  >
+    <el-form
+      ref="formData"
+      :model="formData"
+      :rules="formRules"
+      size="mini"
+      label-suffix=":"
+      label-width="150px"
+    >
+      <el-form-item label="平台分类" prop="classifyId">
+        <el-cascader
+          v-model="formData.classifyId" placeholder="请选择平台分类" :options="categoryList"
+          :props="{ checkStrictly: false, expandTrigger: 'hover', label: 'categoryName', value: 'id', children: 'childs' }" clearable
+        />
+      </el-form-item>
+      <el-form-item label="商家分组" prop="shopGroupId">
+        <el-cascader
+          v-model="formData.shopGroupId" placeholder="请选择分组类型" :options="groupList"
+          :props="{ checkStrictly: true, expandTrigger: 'hover', label: 'groupName', value: 'shopGroupId', children: 'childs' }"
+          clearable size="mini" class="filter-item" style="width: 200px;margin-left: 10px;"
+        />
+      </el-form-item>
+      <el-form-item label="是否上架" prop="shelveState">
+        <el-radio-group v-model="formData.shelveState">
+          <el-radio :label="1">是</el-radio>
+          <el-radio :label="0">否</el-radio>
+        </el-radio-group>
+      </el-form-item>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button size="mini" @click="handleClose">取 消</el-button>
+      <el-button type="primary" size="mini" @click="handleSubmit">确 定</el-button>
+    </span>
+  </el-dialog>
+</template>
+
+<script>
+import { getShopId } from '@/utils/auth'
+import { shopSelectionSelectShopLibrary } from '@/api/selectionCenter/selectionCenter'
+import { getClassify, getGroupSelect } from '@/api/commodity'
+import XeUtils from 'xe-utils'
+
+export default {
+  name: 'SelectionAddModal',
+  components: {
+  },
+  data() {
+    return {
+      modalOptions: {
+        closeOnClickModal: false,
+        width: '820px',
+        title: '补充信息'
+      },
+      visible: false,
+      formData: {
+        shopId: getShopId(),
+        productId: '',
+        shopParentId: '',
+        classifyId: '',
+        shopGroupId: [],
+        shelveState: ''
+      },
+      formRules: {
+        classifyId: [
+          { required: true, type: 'array', message: '缺少平台分类' }
+        ],
+        shopGroupId: [
+          { required: true, type: 'array', message: '缺少商家分组' }
+        ],
+        shelveState: [
+          { required: true, message: '请选择是否上架' }
+        ]
+      },
+      groupList: [],
+      categoryList: []
+    }
+  },
+  methods: {
+    handleClose() {
+      this.visible = false
+    },
+    async getCategoryTreeList() {
+      const res = await getClassify()
+      XeUtils.eachTree(res.data, (item) => {
+        if (Array.isArray(item.childs) && item.childs.length === 0) {
+          item.childs = undefined
+        }
+      }, { children: 'childs' })
+      this.categoryList = res.data
+    },
+    async getGroupDataList() {
+      const result = await getGroupSelect({})
+      XeUtils.eachTree(result.data, (item) => {
+        if (Array.isArray(item.childs) && item.childs.length === 0) {
+          item.childs = undefined
+        }
+      }, { children: 'childs' })
+      this.groupList = result.data
+    },
+    handleOpen(params = {}) {
+      this.getCategoryTreeList()
+      this.getGroupDataList()
+      this.formData.productId = params.productId
+      this.formData.shopParentId = params.shopId
+      this.visible = true
+      this.$refs.formData && this.$refs.formData.resetFields()
+    },
+    handleSubmit() {
+      this.$confirm('确定选择加入该选品吗?')
+        .then(async () => {
+          this.$refs.formData.validate(async (valid) => {
+            if (valid) {
+              const loading = this.$loading({ text: '提交中,请稍候……' })
+              try {
+                const { classifyId, shopGroupId, ...otps } = this.formData
+                const params = {
+                  ...otps,
+                  classifyId: classifyId[classifyId.length - 1],
+                  shopGroupId: shopGroupId[shopGroupId.length - 1]
+                }
+                await shopSelectionSelectShopLibrary(params)
+                loading.close()
+                this.$message({ message: `加入成功!`, type: 'success' })
+                this.$emit('success')
+                this.visible = false
+              } catch (e) {
+                loading.close()
+              } finally {
+                loading.close()
+              }
+            } else {
+              this.$message({ message: '请输入相关信息', type: 'warning' })
+              return false
+            }
+          })
+        })
+        .catch(() => {})
+    }
+  }
+}
+</script>
+

+ 6 - 0
src/views/selectionCenter/productSelectionList/index.vue

@@ -121,6 +121,7 @@ import PlatformSelection from './components/PlatformSelection'
 import DetailModal from './components/DetailModal'
 import { shopSelectionGetLibrary } from '@/api/selectionCenter/selectionCenter'
 import { getBrandList, getClassify } from '@/api/commodity'
+import XeUtils from 'xe-utils'
 
 export default {
   name: 'ProductSelectionList',
@@ -174,6 +175,11 @@ export default {
     },
     async getCategoryTreeList() {
       const res = await getClassify({})
+      XeUtils.eachTree(res.data, (item) => {
+        if (Array.isArray(item.childs) && item.childs.length === 0) {
+          item.childs = undefined
+        }
+      }, { children: 'childs' })
       this.categoryList = res.data
     }
   }