EnableDialog.vue
3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<template>
<div>
<a-modal v-model:open="dialogVisible" :title="titleVisible" @ok="handleOk" @cancel="handleCancel">
<a-spin :spinning="submitted" style="margin-top: 16px;">
<a-form layout="vertical" :model="postData" :label-col="labelCol" :wrapper-col="wrapperCol"
ref="formRef">
<div v-if="!pageStatus" class="tipBox">是否确认启用该账号?</div>
<div v-if="pageStatus" class="disabledTip">
<div class="outlinedBox">
<InfoCircleOutlined style="font-size: 15px; color: #FC8B0A;" />
</div>
<div class="disabledTxt">禁用后,该检测师将无法登录APP且无法被指派新任务,已在进行中的任务不受影响。是否确认禁用?</div>
</div>
<a-form-item v-if="pageStatus" name="remark" label="禁用原因"
:rules="[{ required: true, message: '请输入禁用原因' }]">
<a-textarea v-model:value="postData.remark" show-count :maxlength="200" style="width: 456px;" />
</a-form-item>
</a-form>
</a-spin>
</a-modal>
</div>
</template>
<script lang="ts">
import { Component } from 'vue-facing-decorator';
import { EnhanceFormComponent } from "@/core/form/EnhanceFormComponent";
import { DetectionController } from "@/api/DetectionController";
import { message } from "ant-design-vue";
import { User } from "lib/src/entity/security/entity/User";
import { InfoCircleOutlined } from "@ant-design/icons-vue";
@Component({
components: { InfoCircleOutlined }
})
export default class EnableDialog extends EnhanceFormComponent<User> {
dialogVisible = false;
titleVisible = "启用提示";
pageStatus = 1;
postData = { id: '', status: 1, remark: '' }
init(data): void {
this.pageStatus = data.status;
this.postData.id = data.id;
this.postData.status = data.status;
this.postData.remark = '';
this.titleVisible = !data.status ? "启用提示" : "账号禁用";
this.dialogVisible = true;
}
handleCancel() {
this.dialogVisible = false;
this.$emit("emitOk");
}
handleOk() {
this.$refs.formRef.validate().then((valid) => {
if (valid) {
this.submitted = true;
const formData = {
id: this.postData.id,
status: this.postData.status == 1 ? 0 : 1,
remark: this.postData.remark,
}
DetectionController.inspectStatus(this.axios, formData).then(response => {
if (response?.data?.code == '200') {
this.submitted = false;
message.success("操作成功");
this.$emit("emitOk");
this.dialogVisible = false;
} else {
message.error(response?.data?.message || '操作失败');
}
}).finally(() => this.submitted = false);
}
});
}
}
</script>
<style scoped lang="less">
.tipBox {
width: 100%;
height: 22px;
line-height: 22px;
color: #2f3133;
font-size: 14px;
font-weight: 400;
font-family: "HarmonyOSSansSC";
}
.disabledTip {
width: 100%;
height: 68px;
border-radius: 4px;
background: #fc8b0a1a;
display: flex;
margin-bottom: 20px;
margin-top: 24px;
}
.outlinedBox {
float: left;
margin-left: 16px;
margin-top: 16px;
}
.disabledTxt {
padding-top: 14px;
padding-bottom: 14px;
padding-right: 16px;
padding-left: 8px;
}
</style>