Browse Source

feat: 商品和套餐添加所属公司

xdd 1 month ago
parent
commit
bda77ed6ca

+ 8 - 0
src/api/store/storeProduct.js

@@ -9,6 +9,14 @@ export function listStoreProduct(query) {
   })
 }
 
+export function batchModify(param) {
+  return request({
+    url: '/store/storeProduct/batchModify',
+    method: 'post',
+    data: param
+  })
+}
+
 // 查询商品详细
 export function getStoreProduct(productId) {
   return request({

+ 83 - 4
src/views/store/storeProduct/index.vue

@@ -37,6 +37,16 @@
               />
         </el-select>
       </el-form-item>
+      <el-form-item label="所属公司">
+        <el-select style="width: 240px" v-model="companyId" multiple placeholder="请选择企业" clearable size="small" >
+          <el-option
+            v-for="item in companyOptions"
+            :key="item.companyId"
+            :label="item.companyName"
+            :value="item.companyId"
+          />
+        </el-select>
+      </el-form-item>
       <!-- <el-form-item label="状态" prop="isShow">
          <el-select style="width: 240px" v-model="queryParams.isShow" placeholder="请选择状态" clearable size="small" >
          <el-option
@@ -47,6 +57,7 @@
               />
         </el-select>
       </el-form-item> -->
+
       <el-form-item>
         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -68,7 +79,7 @@
           type="success"
           icon="el-icon-edit"
           size="mini"
-          :disabled="single"
+          :disabled="multiple"
           @click="handleUpdate"
           v-hasPermi="['store:storeProduct:edit']"
         >修改</el-button>
@@ -178,6 +189,35 @@
       @pagination="getList"
     />
 
+    <el-dialog :title="title" :visible.sync="open1" width="580px" append-to-body>
+      <el-form ref="form1" :model="form1" :rules="rules" label-width="80px">
+        <el-form-item label="商品状态" prop="status">
+          <el-radio-group v-model="form1.isShow">
+            <el-radio :label="item.dictValue" v-for="item in isShowOptions" >{{item.dictLabel}}</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item label="商城展示" prop="isDisplay">
+          <el-radio-group v-model="form1.isDisplay">
+            <el-radio :label="item.dictValue" v-for="item in isDisplayOptions" >{{item.dictLabel}}</el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item label="所属公司" prop="companyId">
+          <el-select style="width: 220px" filterable multiple v-model="form1.companyId" placeholder="请选择公司名" clearable size="small">
+            <el-option
+              v-for="item in companyOptions"
+              :key="item.companyId"
+              :label="item.companyName"
+              :value="item.companyId"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitForm1">确 定</el-button>
+        <el-button @click="cancel1">取 消</el-button>
+      </div>
+    </el-dialog>
+
     <!-- 添加或修改商品对话框 -->
     <el-dialog :title="title" v-if="open" :fullscreen="isFullscreen" :visible.sync="open" width="1000px" append-to-body :show-close="false">
       <template v-slot:title>
@@ -578,7 +618,16 @@
 </template>
 
 <script>
-import {genFormatAttr, listStoreProduct, getStoreProduct, delStoreProduct, addOrEdit, exportStoreProduct,importTemplate } from "@/api/store/storeProduct";
+import {
+  genFormatAttr,
+  listStoreProduct,
+  getStoreProduct,
+  delStoreProduct,
+  addOrEdit,
+  exportStoreProduct,
+  importTemplate,
+  batchModify
+} from "@/api/store/storeProduct";
 import { getAllStoreProductCategory } from "@/api/store/storeProductCategory";
 import { getAllStoreProductRule } from "@/api/store/storeProductRule";
 import { getAllShippingTemplates } from "@/api/store/shippingTemplates";
@@ -607,6 +656,7 @@ export default {
   },
   data() {
     return {
+      companyId: null,
       uploadUrl:process.env.VUE_APP_BASE_API+"/common/uploadOSS",
       videoAccept:"video/*",
       upload: {
@@ -631,6 +681,8 @@ export default {
         attrsName: '',
         attrsVal: ''
       },
+      open1: false,
+      form1: {},
       isBtn: false,
       columns: [],
       attrs:[],
@@ -671,7 +723,7 @@ export default {
       // 选中数组
       ids: [],
       // 非单个禁用
-      single: true,
+      single: false,
       // 非多个禁用
       multiple: true,
       // 显示搜索条件
@@ -694,7 +746,7 @@ export default {
         productType: null,
         isShow: "1",
         barCode:null,
-
+        companyIds: null
       },
       // 表单参数
       form: {},
@@ -772,6 +824,27 @@ export default {
     this.getList();
   },
   methods: {
+    cancel1(){
+      this.open1 = false;
+    },
+    submitForm1(){
+      let param = {}
+      param.productId = this.ids;
+      param.goodsStatus = this.form1.isShow;
+      param.goodsIsShow = this.form1.isDisplay;
+      param.companyIds = this.companyId+''
+      batchModify(param).then(res=>{
+        if(res.code === 200){
+          this.$message.success("批量修改成功");
+          this.getList();
+        }
+      }).finally(()=>{
+        this.open1 = false;
+        this.form1.isShow = null;
+        this.form1.isDisplay = null;
+        this.form1.companyId = null;
+      })
+    },
     handleFullScreen(){
       this.isFullscreen = !this.isFullscreen;
     },
@@ -1048,6 +1121,7 @@ export default {
     /** 搜索按钮操作 */
     handleQuery() {
       this.queryParams.pageNum = 1;
+      this.queryParams.companyIds = this.companyId +''
       this.getList();
     },
     /** 重置按钮操作 */
@@ -1074,6 +1148,11 @@ export default {
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
+      if(this.ids.length > 1){
+        this.title = "批量修改商品";
+        this.open1 = true;
+        return;
+      }
       var that=this;
       this.reset();
       const productId = row.productId || this.ids

+ 21 - 1
src/views/store/storeProductPackage/index.vue

@@ -30,6 +30,16 @@
               />
         </el-select>
       </el-form-item>
+      <el-form-item label="公司" prop="companyId">
+        <el-select style="width: 220px" filterable v-model="queryParams.companyId" placeholder="请选择公司名" clearable size="small">
+          <el-option
+            v-for="item in companyOptions"
+            :key="item.companyId"
+            :label="item.companyName"
+            :value="item.companyId"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item>
         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -165,6 +175,16 @@
                 <el-radio :label="item.dictValue" v-for="item in statusOptions" >{{item.dictLabel}}</el-radio>
               </el-radio-group>
         </el-form-item>
+         <el-form-item label="公司" prop="companyId">
+           <el-select style="width: 220px" filterable v-model="form1.companyId" placeholder="请选择公司名" clearable size="small">
+             <el-option
+               v-for="item in companyOptions"
+               :key="item.companyId"
+               :label="item.companyName"
+               :value="item.companyId"
+             />
+           </el-select>
+         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
           <el-button type="primary" @click="submitForm1">确 定</el-button>
@@ -673,7 +693,7 @@ export default {
     },
       // 取消按钮
     cancel1() {
-      this.open = false;
+      this.open1 = false;
       this.reset();
     },
     // 表单重置