Ver código fonte

add:判断是否是销售电话,课程批量关联公司

ct 1 mês atrás
pai
commit
0372237fd8

+ 9 - 0
src/api/course/userCourse.js

@@ -35,6 +35,15 @@ export function updateUserCourse(data) {
   })
 }
 
+// 批量修改课程
+export function batchUpdateUserCourse(data) {
+  return request({
+    url: '/course/userCourse/batchUpdateUserCourse',
+    method: 'post',
+    data: data
+  })
+}
+
 //统一修改课程红包
 export function updateUserCourseRedPage(data) {
   return request({

+ 10 - 0
src/api/his/user.js

@@ -151,3 +151,13 @@ export function batchUnbindUser(data) {
     data: data
   })
 }
+
+
+// 判断是否是销售电话
+export function checkIsSales(data) {
+  return request({
+    url: '/his/user/checkIsSales',
+    method: 'post',
+    data: data
+  })
+}

+ 63 - 1
src/views/course/userCourse/index.vue

@@ -81,6 +81,18 @@
         >修改
         </el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="success"
+          plain
+          icon="el-icon-setting"
+          size="mini"
+          :disabled="multiple"
+          @click="handleUpdateCompany"
+          v-hasPermi="['course:userCourse:edit']"
+        >批量修改关联公司
+        </el-button>
+      </el-col>
       <el-col :span="1.5">
         <el-button
           type="danger"
@@ -433,6 +445,25 @@
       :title="show.title" :visible.sync="show.open" append-to-body>
       <userCourseCatalogDetails ref="userCourseCatalogDetails"/>
     </el-drawer>
+    <el-dialog :title="updateCourse.title" :visible.sync="updateCourse.open" width="1200px" append-to-body>
+      <el-form ref="updateCourseForm" :model="updateCourseForm"  label-width="110px">
+
+        <el-form-item label="关联公司" prop="tags">
+          <el-select v-model="updateCourseForm.companyIds" multiple placeholder="请选择公司" filterable clearable style="width: 90%;">
+            <el-option
+              v-for="dict in companyOptions"
+              :key="dict.dictValue"
+              :label="dict.dictLabel"
+              :value="dict.dictValue"
+            />
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitUpdateCourseForm">确 定</el-button>
+        <el-button @click="cancel">取 消</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
@@ -448,7 +479,7 @@ import {
   copyUserCourse,
   putOn,
   pullOff, updateUserCourseRedPage,
-  editConfig
+  editConfig,batchUpdateUserCourse
 } from '@/api/course/userCourse'
 
 import {getSelectableRange} from "@/api/qw/sopTemp";
@@ -481,6 +512,13 @@ export default {
   },
   data() {
     return {
+      updateCourseForm:{
+
+      },
+      updateCourse:{
+        open:false,
+        title:"批量修改课程关联公司"
+      },
       talentParam: {
         phone: null,
         talentId: null
@@ -703,6 +741,27 @@ export default {
     });
   },
   methods: {
+    /** 提交按钮 */
+    submitUpdateCourseForm() {
+      const courseIds = this.ids
+      if(!courseIds || courseIds.length === 0){
+        this.msgError("请选择需要修改的课程");
+        return;
+      }
+      this.updateCourseForm.courseIds = courseIds;
+      if(!this.updateCourseForm.companyIds || this.updateCourseForm.companyIds.length === 0){
+        this.msgError("请选择需要添加的关联公司");
+        return;
+      }
+      // 私域课程
+      batchUpdateUserCourse(this.updateCourseForm).then(response => {
+        this.msgSuccess("修改成功");
+        this.open = false;
+        this.updateCourseForm = {};
+        this.getList();
+        this.updateCourse.open = true;
+      });
+    },
     selectTalent() {
 
     },
@@ -846,6 +905,9 @@ export default {
       this.open = true;
       this.title = "添加课程";
     },
+    handleUpdateCompany() {
+      this.updateCourse.open = true;
+    },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();

+ 120 - 18
src/views/his/user/index.vue

@@ -188,7 +188,7 @@
           <el-input v-model="form.nickName" placeholder="请输入用户昵称" />
         </el-form-item>
         <el-form-item label="用户状态" prop="status">
-            <el-select v-model="form.status" placeholder="请选择状态" clearable size="small">
+            <el-select v-model="form.status" placeholder="请选择状态" clearable size="small" @change="handleStatusChange">
                   <el-option
                     v-for="dict in userOptions"
                     :key="dict.dictValue"
@@ -271,11 +271,29 @@
         <el-button @click="cancelAddPoint">取 消</el-button>
       </div>
     </el-dialog>
+
+    <!-- 确认拉黑对话框 -->
+    <el-dialog
+      title="确认操作"
+      :visible.sync="confirmDialog.visible"
+      width="400px"
+      append-to-body
+      :close-on-click-modal="false"
+    >
+      <div style="text-align: center; padding: 20px 0;">
+        <i class="el-icon-warning" style="color: #E6A23C; font-size: 48px; margin-bottom: 15px;"></i>
+        <p style="font-size: 16px; color: #606266;">此会员信息为公司员工账号,是否确认拉黑?</p>
+      </div>
+      <div slot="footer" class="dialog-footer">
+        <el-button @click="confirmDialog.visible = false">取 消</el-button>
+        <el-button type="danger" @click="confirmDisable">确认拉黑</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import { listUser, getUser, delUser, addUser, updateUser, exportUser, addPoint } from "@/api/his/user";
+import { listUser, getUser, delUser, addUser, updateUser, exportUser, addPoint,checkIsSales } from "@/api/his/user";
 import { getCompanyUserList, changeCompanyUser, getCompanyList } from '@/api/company/companyUser';
 import userDetails from '../../components/his/userDetails.vue';
 import userDetailsByNew from './userDetails.vue';
@@ -285,6 +303,19 @@ export default {
   components: {userDetails,userDetailsByNew},
   data() {
     return {
+      // 提交加载状态
+      submitLoading: false,
+
+      // 确认对话框
+      confirmDialog: {
+        visible: false,
+        // 暂存表单数据,等待确认后提交
+        pendingForm: null
+      },
+
+      // 记录状态是否从非禁用改为禁用
+      isChangingToDisable: false,
+
       userIsPromoterOptions:[],
       companyName: null,
       companyUserNickName: null,
@@ -401,6 +432,78 @@ export default {
 
   },
   methods: {
+    /** 检查是否为销售并提交 */
+    async checkAndSubmit() {
+      this.submitLoading = true;
+
+      try {
+        console.log("this.form.status",this.form.status);
+        const res = await checkIsSales(this.form);
+        const isSales = res.data === true || res.data === 'true' || (res.code === 200 && res.data);
+
+        if (isSales) {
+          // 是销售,弹出确认框,阻塞提交
+          this.confirmDialog.pendingForm = { ...this.form };
+          this.confirmDialog.visible = true;
+          this.submitLoading = false;
+          return false; // 返回 false,表示需要等待用户确认
+        } else {
+          // 不是销售,可以继续提交
+          return true;
+        }
+      } catch (error) {
+        this.submitLoading = false;
+        this.msgError("检查销售状态失败,请重试");
+        console.error(error);
+        return false; // 出错,阻塞提交
+      }
+    },
+
+    /** 确认拉黑 */
+    confirmDisable() {
+      this.confirmDialog.visible = false;
+      this.doSubmit(this.confirmDialog.pendingForm);
+    },
+
+    /** 执行提交 */
+    doSubmit(formData = null) {
+      const data = formData || this.form;
+      this.submitLoading = true;
+
+      if (this.form.userId != null) {
+        updateUser(data).then(response => {
+          this.submitLoading = false;
+          this.msgSuccess("修改成功");
+          this.open = false;
+          this.reset();
+          this.getList();
+        }).catch(() => {
+          this.submitLoading = false;
+        });
+      } else {
+        addUser(data).then(response => {
+          this.submitLoading = false;
+          this.msgSuccess("新增成功");
+          this.open = false;
+          this.reset();
+          this.getList();
+        }).catch(() => {
+          this.submitLoading = false;
+        });
+      }
+    },
+    /** 状态改变时的处理 */
+    handleStatusChange(value) {
+      // 判断是否是改为禁用状态(假设禁用状态的值为 "1" 或 "0",根据你的实际字典值调整)
+      // 启用是 "1",禁用是 "0"
+      const disableValue = "0"; // 请根据实际字典值调整
+      console.log("disableValue",value);
+      if (value === disableValue) {
+        this.isChangingToDisable = true;
+      } else {
+        this.isChangingToDisable = false;
+      }
+    },
     /** 销售选择变化 */
     handleCompanyUserChange(userId) {
       if (!this.changeCompanyUserForm.companyId) {
@@ -437,6 +540,7 @@ export default {
     cancel() {
       this.open = false;
       this.reset();
+      this.isChangingToDisable = false;
     },
     // 表单重置
     reset() {
@@ -463,6 +567,7 @@ export default {
         balance: null
       };
       this.resetForm("form");
+      this.isChangingToDisable = false;
     },
     /** 搜索按钮操作 */
     handleQuery() {
@@ -500,27 +605,24 @@ export default {
         this.form.status = String(this.form.status)
         this.form.level = String(this.form.level)
         this.form.isPromoter = String(this.form.isPromoter)
-
+        // 初始化状态变化标记
+        this.isChangingToDisable = false;
       });
     },
     /** 提交按钮 */
     submitForm() {
-      this.$refs["form"].validate(valid => {
-        if (valid) {
-          if (this.form.userId != null) {
-            updateUser(this.form).then(response => {
-              this.msgSuccess("修改成功");
-              this.open = false;
-              this.getList();
-            });
-          } else {
-            addUser(this.form).then(response => {
-              this.msgSuccess("新增成功");
-              this.open = false;
-              this.getList();
-            });
-          }
+      this.$refs["form"].validate(async valid => {
+        if (!valid) return;
+
+        // 如果是修改操作,且状态改为禁用(0),需要先判断是否是销售
+        if (this.form.userId != null && this.isChangingToDisable) {
+          // 等待校验完成
+          const canSubmit = await this.checkAndSubmit();
+          if (!canSubmit) return; // 校验未通过或需要等待确认,不继续执行
         }
+
+        // 直接提交(非禁用状态或校验通过)
+        this.doSubmit();
       });
     },
     /** 删除按钮操作 */