Quellcode durchsuchen

多店铺,绑定店铺

yfh vor 1 Monat
Ursprung
Commit
01e0b0028c
2 geänderte Dateien mit 123 neuen und 1 gelöschten Zeilen
  1. 2 0
      src/views/company/company/index.vue
  2. 121 1
      src/views/his/company/index.vue

+ 2 - 0
src/views/company/company/index.vue

@@ -332,6 +332,7 @@ export default {
       bindShopForm: {
         companyId: null,
         shopId: null,
+        companyName: null,
       },
       bindShopRules: {
         shopId: [
@@ -474,6 +475,7 @@ export default {
     handleBindShop(row) {
       this.resetBindShopForm();
       this.bindShopForm.companyId = row.companyId;
+      this.bindShopForm.companyName = row.companyName;
       this.bindShopForm.shopId = row.storeId ? String(row.storeId) : '';
       this.bindShop.open = true;
     },

+ 121 - 1
src/views/his/company/index.vue

@@ -134,7 +134,7 @@
       <el-table-column label="创建时间" align="center" prop="createTime" width="180"/>
       <el-table-column label="更新时间" align="center" prop="updateTime" width="180"/>
       <!--      <el-table-column label="主机重启时间" align="center" prop="restartTime" width="180" />-->
-      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="200px">
+      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="300px">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -152,6 +152,14 @@
             v-hasPermi="['his:company:pass']"
           >重置密码
           </el-button>
+          <!-- 新增绑定店铺按钮 -->
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-shop"
+            @click="handleBindShop(scope.row)"
+            v-hasPermi="['company:company:bindShop']"
+          >绑定店铺</el-button>
           <el-button
             size="mini"
             type="text"
@@ -189,6 +197,38 @@
       @pagination="getList"
     />
 
+    <!-- 绑定店铺对话框 -->
+    <el-dialog :title="bindShop.title" :visible.sync="bindShop.open" width="600px" append-to-body>
+      <el-form ref="bindShopForm" :rules="bindShopRules" :model="bindShopForm" label-width="100px">
+        <el-form-item label="公司名称">
+          <el-input v-model="bindShopForm.companyName" disabled />
+        </el-form-item>
+        <el-form-item label="选择店铺" prop="shopId">
+          <el-select
+            v-model="bindShopForm.shopId"
+            placeholder="请选择店铺"
+            filterable
+            clearable
+            style="width: 100%"
+            @change="handleShopChange"
+          >
+            <el-option
+              v-for="shop in shopList"
+              :key="shop.storeId"
+              :label="shop.storeName"
+              :value="shop.storeId"
+            >
+              <span style="float: left">{{ shop.storeName }}</span>
+              <span style="float: right; color: #8492a6; font-size: 13px">{{ shop.storeId }}</span>
+            </el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitBindShopForm" :loading="bindShop.submitLoading">确 定</el-button>
+        <el-button @click="bindShop.open=false">取 消</el-button>
+      </div>
+    </el-dialog>
     <!-- 添加或修改诊所管理对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
 
@@ -491,6 +531,8 @@ import {
   exportCompany,
   resetPwd
 } from '@/api/his/company'
+import {bindShopCompany} from "@/api/company/company";
+import { storeList } from '@/api/hisStore/store'
 import { getFollowDoctorList } from '@/api/his/doctor'
 import { docList } from '@/api/his/doctor'
 import { getVoiceApiList } from '@/api/company/companyVoiceApi'
@@ -504,6 +546,24 @@ export default {
   name: 'Company',
   data() {
     return {
+      shopList: [], // 清空店铺列表
+      // 绑定店铺相关
+      bindShopForm: {
+        companyId: null,
+        shopId: null,
+        companyName: null,
+      },
+      bindShopRules: {
+        shopId: [
+          { required: true, message: "店铺不能为空", trigger: "blur" }
+        ]
+      },
+      bindShop: {
+        open: false,
+        title: "绑定店铺",
+        loading: false,
+        submitLoading: false
+      },
       // 表单参数
       deductForm: {
         money: 0
@@ -642,6 +702,7 @@ export default {
     }
   },
   created() {
+    this.storeList();
     this.getList()
     this.getDicts('sys_company_status').then(response => {
       this.statusOptions = response.data
@@ -673,6 +734,65 @@ export default {
     })
   },
   methods: {
+
+    /** 店铺选择变化 */
+    handleShopChange(shopId) {
+      if (shopId) {
+        // 可以在这里获取选中店铺的详细信息
+        console.log('选中的店铺ID:', shopId);
+      }
+    },
+    /** 绑定店铺按钮操作 */
+    handleBindShop(row) {
+      this.resetBindShopForm();
+      this.bindShopForm.companyId = row.companyId;
+      this.bindShopForm.companyName = row.companyName;
+      this.bindShopForm.shopId = row.storeId ? String(row.storeId) : '';
+      this.bindShop.open = true;
+    },
+    /** 重置绑定店铺表单 */
+    resetBindShopForm() {
+      this.bindShopForm = {
+        companyId: null,
+        companyName: '',
+        shopId: null,
+        shopName: '',
+        remark: ''
+      };
+      this.resetForm("bindShopForm");
+    },
+    /** 提交绑定店铺表单 */
+    submitBindShopForm() {
+      this.$refs["bindShopForm"].validate(valid => {
+        if (valid) {
+          this.bindShop.submitLoading = true;
+          console.log( this.bindShopForm.companyId)
+          console.log( this.bindShopForm.shopId)
+          // 调用绑定店铺的API
+          bindShopCompany({
+            companyId: this.bindShopForm.companyId,
+            storeId: this.bindShopForm.shopId
+          }).then(response => {
+            if (response.code === 200) {
+              this.msgSuccess("绑定店铺成功");
+              this.bindShop.open = false;
+              this.getList(); // 刷新列表
+            } else {
+              this.msgError(response.msg);
+            }
+            this.bindShop.submitLoading = false;
+          }).catch(() => {
+            this.bindShop.submitLoading = false;
+          });
+        }
+      });
+    },
+    storeList() {
+      storeList().then(response => {
+        console.log(response.data)
+        this.shopList = response.data;
+      });
+    },
     handleRecharge(row) {
       const companyId = row.companyId
       this.rechargeForm.companyId = row.companyId