|
|
@@ -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();
|
|
|
});
|
|
|
},
|
|
|
/** 删除按钮操作 */
|