privilege-ops-panel.vue
3.88 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
<template>
<div class="privilege-ops-panel">
<el-alert
type="warning"
show-icon
:closable="false"
title="越权操作说明"
description="此处操作不受小程序跨月、开单作废开关等限制,但仍会校验是否存在消耗、退卡、补缴、储扣等关联数据。仅系统管理员可用,所有操作写入业务日志。"
class="privilege-alert"
/>
<el-card shadow="never" class="config-section">
<div slot="header" class="config-section__header">
<span>开单作废</span>
<span class="config-section__tag config-section__tag--danger">越权</span>
</div>
<p class="config-section__tip">
输入开单 ID 后执行作废。若该单已产生耗卡、退卡、有效补缴或储扣引用,系统将拒绝作废。
</p>
<el-form ref="formRef" :model="form" :rules="rules" label-width="96px" class="privilege-form">
<el-form-item label="开单 ID" prop="id">
<el-input
v-model.trim="form.id"
clearable
placeholder="请输入开单记录 ID"
maxlength="50"
show-word-limit
/>
</el-form-item>
<el-form-item label="作废原因" prop="remarks">
<el-input
v-model.trim="form.remarks"
type="textarea"
:rows="3"
maxlength="200"
show-word-limit
placeholder="请填写作废原因,便于审计追溯"
/>
</el-form-item>
<el-form-item>
<el-button type="danger" :loading="submitting" @click="handleSubmit">执行作废</el-button>
<el-button @click="resetForm">重置</el-button>
</el-form-item>
</el-form>
</el-card>
</div>
</template>
<script>
import { privilegeCancelBilling } from '@/api/extend/privilegeOps'
export default {
name: 'PrivilegeOpsPanel',
data() {
return {
submitting: false,
form: {
id: '',
remarks: ''
},
rules: {
id: [{ required: true, message: '请输入开单 ID', trigger: 'blur' }],
remarks: [{ required: true, message: '请填写作废原因', trigger: 'blur' }]
}
}
},
methods: {
resetForm() {
this.form = { id: '', remarks: '' }
this.$nextTick(() => {
this.$refs.formRef && this.$refs.formRef.clearValidate()
})
},
handleSubmit() {
this.$refs.formRef.validate(valid => {
if (!valid) return
this.$confirm(
`确认越权作废开单 ${this.form.id} 吗?此操作不可撤销。`,
'越权作废确认',
{ type: 'warning', confirmButtonText: '确认作废', cancelButtonText: '取消' }
)
.then(() => this.doCancel())
.catch(() => {})
})
},
async doCancel() {
this.submitting = true
try {
const res = await privilegeCancelBilling({
id: this.form.id,
remarks: this.form.remarks
})
this.$message.success((res && res.msg) || '作废成功')
this.resetForm()
} catch (e) {
const msg = (e && e.message) || (e && e.msg) || '作废失败'
this.$message.error(msg)
} finally {
this.submitting = false
}
}
}
}
</script>
<style lang="scss" scoped>
.privilege-ops-panel {
max-width: 720px;
}
.privilege-alert {
margin-bottom: 16px;
}
.config-section {
border: 1px solid #fde2e2;
}
.config-section__header {
display: flex;
align-items: center;
gap: 10px;
font-weight: 600;
}
.config-section__tag {
font-size: 12px;
font-weight: 500;
padding: 2px 8px;
border-radius: 4px;
background: #f0f9eb;
color: #67c23a;
}
.config-section__tag--danger {
background: #fef0f0;
color: #f56c6c;
}
.config-section__tip {
margin: 0 0 16px;
font-size: 13px;
line-height: 1.6;
color: #909399;
}
.privilege-form {
max-width: 560px;
}
</style>