Bladeren bron

商城小程序修改 绑定appid部分代码

xgb 1 dag geleden
bovenliggende
commit
c91e84804b

+ 47 - 3
src/views/hisStore/menu/index.vue

@@ -10,6 +10,17 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
+
+      <el-form-item label="小程序" prop="appId">
+        <el-select v-model="queryParams.appId" placeholder="请选择所属小程序" clearable size="small">
+          <el-option
+            v-for="dict in appMallOptions"
+            :key="dict.appid"
+            :label="dict.name + '(' + dict.appid + ')'"
+            :value="dict.appid"
+          />
+        </el-select>
+      </el-form-item>
       <el-form-item>
         <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -55,6 +66,11 @@
       <el-table-column type="selection" width="55" align="center" />
       <el-table-column label="ID" align="center" prop="menuId" />
       <el-table-column label="菜单名称" align="center" prop="menuName" />
+      <el-table-column label="小程序" align="center" prop="appId" >
+        <template slot-scope="scope">
+          <el-tag prop="appId" v-for="(item, index) in appMallOptions"    v-if="scope.row.appId==item.appid">{{item.name}}</el-tag>
+        </template>
+      </el-table-column>
       <el-table-column label="图标" align="center" width="120">
         <template slot-scope="scope">
           <el-popover
@@ -142,6 +158,16 @@
             />
           </el-select>
         </el-form-item>
+        <el-form-item label="小程序" prop="appIds">
+          <el-select style="width: 200px" v-model="appIds" placeholder="请选择所属小程序" clearable size="small" multiple>
+            <el-option
+              v-for="dict in appMallOptions"
+              :key="dict.appid"
+              :label="dict.name + '(' + dict.appid + ')'"
+              :value="dict.appid"
+            />
+          </el-select>
+        </el-form-item>
         <el-form-item label="状态" prop="isShow">
               <el-radio-group v-model="form.isShow">
                 <el-radio v-for="dict in statusOptions" :key="dict.dictValue" :label="dict.dictValue">{{dict.dictLabel}}</el-radio>
@@ -158,6 +184,7 @@
 
 <script>
 import { listMenu, getMenu, delMenu, addMenu, updateMenu, exportMenu } from "@/api/hisStore/menu";
+import {list as getAppMallOptions} from '@/api/course/coursePlaySourceConfig';
 import Material from '@/components/Material'
 export default {
   name: "Menu",
@@ -171,6 +198,7 @@ export default {
   },
   data() {
     return {
+      appMallOptions:[],
       activeName:"00",
       menuLinkTypeOptions:[],
       menuTypeOptions:[
@@ -201,6 +229,8 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      // 小程序列表
+      appIds:[], // 选择的小程序
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -231,11 +261,17 @@ export default {
     this.getDicts("common_status").then((response) => {
       this.statusOptions = response.data;
     });
-
+    this.getAppMallOptions();
     this.getList();
 
   },
   methods: {
+    // 获取小程序选项列表
+    getAppMallOptions() {
+      getAppMallOptions({pageNum:1,pageSize:100,isMall:1}).then(response => {
+        this.appMallOptions = response.rows;
+      })
+    },
     handleClick(tab,event){
       this.activeName=tab.name;
       if(tab.name=="00"){
@@ -274,6 +310,7 @@ export default {
         menuType:null,
       };
       this.imageArr=[];
+      this.appIds=[];
       this.resetForm("form");
     },
     /** 搜索按钮操作 */
@@ -316,6 +353,8 @@ export default {
         if(this.form.icon!=null){
           this.imageArr=this.form.icon.split(",");
         }
+        // 处理小程序多绑定
+        this.appIds = this.form.appIds ? this.form.appIds.split(',') : [];
         this.open = true;
         this.title = "修改菜单管理";
       });
@@ -324,8 +363,13 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
+          // 小程序
+          const params = {
+            ...this.form,
+            appIds: this.appIds.join(',') // 数组转字符串
+          };
           if (this.form.menuId != null) {
-            updateMenu(this.form).then(response => {
+            updateMenu(params).then(response => {
               if (response.code === 200) {
                 this.msgSuccess("修改成功");
                 this.open = false;
@@ -333,7 +377,7 @@ export default {
               }
             });
           } else {
-            addMenu(this.form).then(response => {
+            addMenu(params).then(response => {
               if (response.code === 200) {
                 this.msgSuccess("新增成功");
                 this.open = false;

+ 53 - 4
src/views/hisStore/storeProduct/index.vue

@@ -47,6 +47,16 @@
           />
         </el-select>
       </el-form-item>
+      <el-form-item label="所属小程序" prop="appId">
+        <el-select style="width: 240px" v-model="queryParams.appId" placeholder="请选择所属小程序" clearable size="small">
+          <el-option
+            v-for="dict in appMallOptions"
+            :key="dict.appid"
+            :label="dict.name + '(' + dict.appid + ')'"
+            :value="dict.appid"
+          />
+        </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
@@ -567,6 +577,16 @@
             />
           </el-select>
         </el-form-item>
+        <el-form-item label="所属小程序" prop="appIds">
+          <el-select style="width: 240px" v-model="appIds" placeholder="请选择所属小程序" clearable size="small" multiple>
+            <el-option
+              v-for="dict in appMallOptions"
+              :key="dict.appid"
+              :label="dict.name + '(' + dict.appid + ')'"
+              :value="dict.appid"
+            />
+          </el-select>
+        </el-form-item>
         <el-form-item label="国药准字" v-if="form.productType==2" prop="prescribeCode">
           <el-input v-model="form.prescribeCode" placeholder="请输入国药准字" />
         </el-form-item>
@@ -638,6 +658,8 @@ import Editor from '@/components/Editor/wang';
 import Material from '@/components/Material'
 import singleImg from '@/components/Material/single'
 import { getCompanyList } from "@/api/company/company";
+import { listStore } from '@/api/hisStore/store'
+import {list as getAppMallOptions} from "@/api/course/coursePlaySourceConfig";
 export default {
   name: "HisStoreProduct",
   components: {
@@ -743,7 +765,9 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
-
+      // 小程序列表
+      appMallOptions:[],
+      appIds:[], // 选择的小程序
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -752,7 +776,8 @@ export default {
         productType: null,
         isShow: "1",
         barCode:null,
-        companyIds: null
+        companyIds: null,
+        appId:null
       },
       // 表单参数
       form: {},
@@ -827,10 +852,21 @@ export default {
     getCompanyList().then(response => {
       this.companyOptions = response.data;
     });
+    // 查询小程序
+    this.getAppMallOptions();
+
+    listStore(this.storeForm).then(response => {
+      this.storeOptions = response.rows;
+    });
     this.getTreeselect();
     this.getList();
   },
   methods: {
+    getAppMallOptions() {
+      getAppMallOptions({pageNum:1,pageSize:100}).then(response => {
+        this.appMallOptions = response.rows;
+      })
+    },
     cancel1(){
       this.open1 = false;
     },
@@ -1188,6 +1224,7 @@ export default {
         if (response.data.companyIds != null && response.data.companyIds != undefined && response.data.companyIds.length > 0) {
           this.form.companyIds = response.data.companyIds.split(',').map(Number);
         }
+        this.appIds = this.form.appIds ? this.form.appIds.split(',') : [];
         setTimeout(() => {
           that.generate();
         }, 200);
@@ -1249,12 +1286,24 @@ export default {
           if (this.form.companyIds != null && this.form.companyIds != undefined) {
             this.form.companyIds = this.form.companyIds.join(',');
           }
-          addOrEdit(this.form).then(response => {
+          // 小程序
+          const params = {
+            ...this.form,
+            appIds: this.appIds.join(',') // 数组转字符串
+          };
+          addOrEdit(params).then(response => {
             if (response.code === 200) {
-              this.msgSuccess("修改成功");
+              // 根据是否有productId判断是新增还是修改
+              if (this.form.productId) {
+                this.msgSuccess("修改成功");
+              } else {
+                this.msgSuccess("新增成功");
+              }
               this.open = false;
               this.getList();
             }
+          }).catch(error => {
+            this.$message.error('请求失败: ' + error.message)
           });
         }
       });

+ 48 - 4
src/views/hisStore/storeProductCategory/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
+    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
       <el-form-item label="分类名称" prop="cateName">
         <el-input
           v-model="queryParams.cateName"
@@ -10,6 +10,16 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
+      <el-form-item label="所属小程序" prop="appId">
+        <el-select style="width: 240px" v-model="queryParams.appId" placeholder="请选择所属小程序" clearable size="small">
+          <el-option
+            v-for="dict in appMallOptions"
+            :key="dict.appid"
+            :label="dict.name + '(' + dict.appid + ')'"
+            :value="dict.appid"
+          />
+        </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>
@@ -85,7 +95,16 @@
         <el-form-item label="排序" prop="sort">
           <el-input-number v-model="form.sort" placeholder="请输入排序" />
         </el-form-item>
-
+        <el-form-item label="所属小程序" prop="appIds" v-if="form.pid==0">
+          <el-select style="width: 240px" v-model="appIds" placeholder="请选择所属小程序" clearable size="small" multiple>
+            <el-option
+              v-for="dict in appMallOptions"
+              :key="dict.appid"
+              :label="dict.name + '(' + dict.appid + ')'"
+              :value="dict.appid"
+            />
+          </el-select>
+        </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -99,6 +118,7 @@ import { listStoreProductCategory, getStoreProductCategory, delStoreProductCateg
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import Material from '@/components/Material'
+import { list as getAppMallOptions } from '@/api/course/coursePlaySourceConfig'
 export default {
   name: "HisStoreProductCategory",
   components: {
@@ -125,12 +145,16 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      appIds:[], // 选择的小程序
+      // 小程序列表
+      appMallOptions:[],
       // 查询参数
       queryParams: {
         pid: null,
         cateName: null,
         sort: null,
         pic: null,
+        appId:null,
         isShow: null,
         isDel: null
       },
@@ -151,9 +175,19 @@ export default {
     };
   },
   created() {
+
+    // 查询小程序
+    this.getAppMallOptions();
+
     this.getList();
   },
   methods: {
+
+    getAppMallOptions() {
+      getAppMallOptions({pageNum:1,pageSize:100}).then(response => {
+        this.appMallOptions = response.rows;
+      })
+    },
     /** 查询商品分类列表 */
     getList() {
       this.loading = true;
@@ -232,6 +266,9 @@ export default {
         if(this.form.pic){
           this.picArr=this.form.pic.split(",");
         }
+
+        this.appIds = this.form.appIds ? this.form.appIds.split(',') : [];
+
         this.form.isShow = response.data.isShow.toString();
         this.open = true;
         this.title = "修改商品分类";
@@ -241,8 +278,15 @@ export default {
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
+
+          // 小程序
+          const params = {
+            ...this.form,
+            appIds: this.appIds.join(',') // 数组转字符串
+          };
+
           if (this.form.cateId != null) {
-            updateStoreProductCategory(this.form).then(response => {
+            updateStoreProductCategory(params).then(response => {
               if (response.code === 200) {
                 this.msgSuccess("修改成功");
                 this.open = false;
@@ -250,7 +294,7 @@ export default {
               }
             });
           } else {
-            addStoreProductCategory(this.form).then(response => {
+            addStoreProductCategory(params).then(response => {
               if (response.code === 200) {
                 this.msgSuccess("新增成功");
                 this.open = false;