Explorar o código

修改会员等级和销售

xgb hai 13 horas
pai
achega
8eb7852978
Modificáronse 1 ficheiros con 69 adicións e 3 borrados
  1. 69 3
      src/views/his/user/index.vue

+ 69 - 3
src/views/his/user/index.vue

@@ -200,7 +200,7 @@
         <!--  会员等级      -->
         <el-form-item label="会员等级" prop="level">
           <el-select v-model="form.level" placeholder="请选择会员等级" clearable size="small">
-            <el-option disabled
+            <el-option
               v-for="dict in userLevelOptions"
               :key="dict.dictValue"
               :label="dict.dictLabel"
@@ -238,6 +238,26 @@
             />
           </el-select>
         </el-form-item>
+        <el-form-item label="所属公司" prop="companyId">
+          <el-select style="width: 200px" v-model="changeCompanyUserForm.companyId" placeholder="请选择公司" clearable size="small" @change="handleCompanyChange">
+            <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="companyUserId">
+          <el-select style="width: 200px" v-model="changeCompanyUserForm.companyUserId" placeholder="请选择销售" clearable size="small" @change="handleCompanyUserChange">
+            <el-option
+              v-for="item in companyUserOptions"
+              :key="item.userId"
+              :label="item.nickName"
+              :value="item.userId"
+            />
+          </el-select>
+        </el-form-item>
         <el-form-item label="用户备注" prop="remark" >
           <el-input v-model="form.remark" placeholder="请输入用户备注" type="textarea"/>
         </el-form-item>
@@ -290,6 +310,10 @@ export default {
       companyUserNickName: null,
       companyOptions: [],
       companyUserOptions: [],
+      changeCompanyUserForm: {
+        companyId: null,
+        companyUserId: null
+      },
       show:{
               title:"用户详情",
               open:false,
@@ -398,9 +422,27 @@ export default {
     this.getDicts("user_is_promoter").then((response) => {
       this.userIsPromoterOptions = response.data;
     });
-
+    this.getCompanyList();
   },
   methods: {
+    /** 加载公司列表 */
+    getCompanyList() {
+      getCompanyList({}).then(response => {
+        this.companyOptions = response.data;
+      });
+    },
+    /** 公司选择变化 */
+    handleCompanyChange(companyId) {
+      if (companyId) {
+        this.changeCompanyUserForm.companyUserId = null;
+        getCompanyUserList({ companyId: companyId }).then(response => {
+          this.companyUserOptions = response.data;
+        });
+      } else {
+        this.companyUserOptions = [];
+        this.changeCompanyUserForm.companyUserId = null;
+      }
+    },
     /** 销售选择变化 */
     handleCompanyUserChange(userId) {
       if (!this.changeCompanyUserForm.companyId) {
@@ -492,6 +534,11 @@ export default {
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
+      this.changeCompanyUserForm = {
+        companyId: null,
+        companyUserId: null
+      };
+      this.companyUserOptions = [];
       const userId = row.userId || this.ids
       getUser(userId).then(response => {
         this.form = response.data;
@@ -499,14 +546,33 @@ export default {
         this.title = "修改用户";
         this.form.status = String(this.form.status)
         this.form.level = String(this.form.level)
-
+        if (this.form.companyId) {
+          this.changeCompanyUserForm.companyId = this.form.companyId;
+          getCompanyUserList({ companyId: this.form.companyId }).then(response => {
+            this.companyUserOptions = response.data;
+            if (this.form.companyUserId) {
+              this.changeCompanyUserForm.companyUserId = this.form.companyUserId;
+            }
+          });
+        }
       });
     },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
+          // 检查修改会员等级时公司和销售是否为空
+          if (this.form.userId != null && this.form.level && !this.changeCompanyUserForm.companyId) {
+            this.$message.warning('修改会员等级前,请先选择公司');
+            return;
+          }
+          if (this.form.userId != null && this.form.level && !this.changeCompanyUserForm.companyUserId) {
+            this.$message.warning('修改会员等级前,请先选择销售');
+            return;
+          }
           if (this.form.userId != null) {
+            this.form.companyId = this.changeCompanyUserForm.companyId;
+            this.form.companyUserId = this.changeCompanyUserForm.companyUserId;
             updateUser(this.form).then(response => {
               this.msgSuccess("修改成功");
               this.open = false;