Compare commits
No commits in common. 'c9fb4ceb6cd52312764a47a023f2dbc30029b72e' and '7699ef41d03001db2c9f3dc677ab01e8d94d2308' have entirely different histories.
c9fb4ceb6c
...
7699ef41d0
45 changed files with 804 additions and 1711 deletions
@ -1,21 +1,8 @@
@@ -1,21 +1,8 @@
|
||||
/* global MyConfig */ |
||||
import request, { download } from '@/utils/request' |
||||
|
||||
const IMPORT_EXCEL_PATH = '/business/hazard/importData' |
||||
const IMPORT_ZIP_PATH = '/business/hazard/importZip' |
||||
const IMPORT_TEMPLATE_PATH = '/business/hazard/importTemplate' |
||||
import request from '@/utils/request' |
||||
|
||||
export function listHazardLedger(query) { return request({ url: '/flowable/hazard/todoList', method: 'get', params: query }) } |
||||
export function getHazardLedgerDetail(id) { return request({ url: '/business/hazard/info/' + id, method: 'get' }) } |
||||
export function listHazardLedgerAttachments(reportId) { return request({ url: '/business/hazard/attachment/' + reportId, method: 'get' }) } |
||||
export function exportHazardLedger(data) { return request({ url: '/business/hazard/export', method: 'post', data, responseType: 'blob' }) } |
||||
|
||||
// el-upload 的上传地址需要完整 URL,统一在 API 层拼接,避免页面直接写请求地址。
|
||||
// mode: 'excel' 导入历史隐患数据 Excel;'image' 导入历史隐患数据 ZIP 包(Excel + 图片附件)。
|
||||
export function getHazardImportAction(mode) { return MyConfig.BASE_API.replace(/\/$/, '') + (mode === 'image' ? IMPORT_ZIP_PATH : IMPORT_EXCEL_PATH) } |
||||
|
||||
// 下载历史隐患导入模板(POST,后端直接返回 Excel 文件流)。
|
||||
export function downloadHazardImportTemplate() { return download(IMPORT_TEMPLATE_PATH, {}, '历史隐患导入模板_' + new Date().getTime() + '.xlsx') } |
||||
|
||||
// api.json 当前未声明同步重试接口,禁止在前端猜测 URL。
|
||||
export function retryHazardSync() { return Promise.reject(new Error('后端接口文档未提供隐患同步重试接口')) } |
||||
|
||||
@ -1,12 +0,0 @@
@@ -1,12 +0,0 @@
|
||||
import request from '@/utils/request' |
||||
|
||||
// 手动调整积分(PC管理端):points 正数补发、负数扣减,reason 为调整原因
|
||||
// 三个参数以 query 形式提交(后端同时支持 x-www-form-urlencoded)
|
||||
export function adjustPoints(params) { |
||||
return request({ url: '/business/points/balance/adjust', method: 'post', params }) |
||||
} |
||||
|
||||
// 查询指定用户的积分账户
|
||||
export function getBalanceByUserId(userId) { |
||||
return request({ url: '/business/points/balance/getByUserId/' + userId, method: 'get' }) |
||||
} |
||||
@ -1,236 +0,0 @@
@@ -1,236 +0,0 @@
|
||||
<template> |
||||
<data-list-panel modern-table> |
||||
<template #header> |
||||
<div class="adjust-heading"> |
||||
<div class="adjust-heading__title">手动调整积分 · 补发 / 扣减</div> |
||||
<div class="adjust-heading__description"> |
||||
正数为补发、负数为扣减。操作会生成积分流水(MANUAL_ADD / MANUAL_DEDUCT)并写入审计日志,请谨慎操作。 |
||||
</div> |
||||
</div> |
||||
</template> |
||||
|
||||
<el-form |
||||
ref="adjustForm" |
||||
:model="form" |
||||
:rules="rules" |
||||
label-width="96px" |
||||
size="small" |
||||
class="adjust-form" |
||||
> |
||||
<el-form-item label="目标用户" prop="userId"> |
||||
<el-cascader |
||||
v-model="form.userId" |
||||
:options="orgOptions" |
||||
:props="cascaderProps" |
||||
:loading="orgLoading" |
||||
filterable |
||||
clearable |
||||
placeholder="按部门选择用户" |
||||
style="width: 100%; max-width: 420px" |
||||
@change="handleUserChange" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item label="当前积分"> |
||||
<span class="adjust-balance">{{ balanceText }}</span> |
||||
</el-form-item> |
||||
<el-form-item label="调整积分" prop="points"> |
||||
<el-input-number |
||||
v-model="form.points" |
||||
:min="-100000" |
||||
:max="100000" |
||||
:precision="0" |
||||
:step="10" |
||||
style="width: 200px" |
||||
/> |
||||
<span class="adjust-hint">正数补发,负数扣减,不能为 0</span> |
||||
</el-form-item> |
||||
<el-form-item label="调整原因" prop="reason"> |
||||
<el-input |
||||
v-model.trim="form.reason" |
||||
type="textarea" |
||||
:rows="3" |
||||
maxlength="200" |
||||
show-word-limit |
||||
placeholder="请填写调整原因(会写入审计日志)" |
||||
style="max-width: 560px" |
||||
/> |
||||
</el-form-item> |
||||
<el-form-item> |
||||
<el-button type="primary" :loading="submitting" @click="handleSubmit">提交调整</el-button> |
||||
<el-button @click="resetForm">重置</el-button> |
||||
</el-form-item> |
||||
</el-form> |
||||
</data-list-panel> |
||||
</template> |
||||
|
||||
<script> |
||||
import { adjustPoints, getBalanceByUserId } from '@/api/points/balance' |
||||
import { getOrgUsers } from '@/api/system/user' |
||||
|
||||
export default { |
||||
name: 'AdjustBalancePanel', |
||||
data() { |
||||
const pointsValidator = (rule, value, callback) => { |
||||
if (value === undefined || value === null || value === '') { |
||||
callback(new Error('请输入调整积分')) |
||||
} else if (Number(value) === 0) { |
||||
callback(new Error('调整积分不能为 0')) |
||||
} else { |
||||
callback() |
||||
} |
||||
} |
||||
return { |
||||
orgLoading: false, |
||||
orgOptions: [], |
||||
balanceLoading: false, |
||||
balance: null, |
||||
submitting: false, |
||||
// emitPath: false → v-model 直接是选中的用户 ID(只允许选叶子节点) |
||||
cascaderProps: { value: 'id', label: 'label', children: 'children', emitPath: false }, |
||||
form: { userId: undefined, points: undefined, reason: '' }, |
||||
rules: { |
||||
userId: [{ required: true, message: '请选择目标用户', trigger: 'change' }], |
||||
points: [{ validator: pointsValidator, trigger: 'change' }], |
||||
reason: [{ required: true, message: '请填写调整原因', trigger: 'blur' }] |
||||
} |
||||
} |
||||
}, |
||||
computed: { |
||||
balanceText() { |
||||
if (this.balanceLoading) return '加载中...' |
||||
if (!this.balance) return '—' |
||||
const available = this.balance.availableBalance |
||||
const frozen = this.balance.frozenBalance |
||||
const frozenText = |
||||
frozen === undefined || frozen === null ? '' : `(冻结 ${frozen})` |
||||
return `可用 ${available === undefined || available === null ? '—' : available}${frozenText}` |
||||
}, |
||||
selectedUserLabel() { |
||||
const target = this.form.userId === undefined || this.form.userId === null ? '' : String(this.form.userId) |
||||
if (!target) return '' |
||||
let label = '' |
||||
const walk = nodes => { |
||||
(nodes || []).forEach(node => { |
||||
if (label) return |
||||
if (String(node.id) === target) { |
||||
label = node.label || node.name || '' |
||||
return |
||||
} |
||||
if (node.children) walk(node.children) |
||||
}) |
||||
} |
||||
walk(this.orgOptions) |
||||
return label |
||||
} |
||||
}, |
||||
created() { |
||||
this.loadOrgUsers() |
||||
}, |
||||
methods: { |
||||
loadOrgUsers() { |
||||
this.orgLoading = true |
||||
getOrgUsers() |
||||
.then(response => { |
||||
const payload = response && response.data !== undefined ? response.data : response |
||||
this.orgOptions = Array.isArray(payload) |
||||
? payload |
||||
: payload.list || payload.rows || [] |
||||
}) |
||||
.catch(() => { |
||||
this.orgOptions = [] |
||||
this.$modal.msgError('组织架构加载失败,请稍后重试') |
||||
}) |
||||
.finally(() => { |
||||
this.orgLoading = false |
||||
}) |
||||
}, |
||||
handleUserChange(userId) { |
||||
this.form.points = undefined |
||||
this.loadBalance(userId) |
||||
}, |
||||
loadBalance(userId) { |
||||
if (userId === undefined || userId === null || userId === '') { |
||||
this.balance = null |
||||
return |
||||
} |
||||
this.balanceLoading = true |
||||
getBalanceByUserId(userId) |
||||
.then(response => { |
||||
this.balance = response && response.data !== undefined ? response.data : response |
||||
}) |
||||
.catch(() => { |
||||
this.balance = null |
||||
}) |
||||
.finally(() => { |
||||
this.balanceLoading = false |
||||
}) |
||||
}, |
||||
handleSubmit() { |
||||
this.$refs.adjustForm.validate(valid => { |
||||
if (!valid) return |
||||
const points = Number(this.form.points) |
||||
const action = points > 0 ? '补发' : '扣减' |
||||
const userLabel = this.selectedUserLabel || `用户ID ${this.form.userId}` |
||||
this.$confirm( |
||||
`确认对「${userLabel}」${action} ${Math.abs(points)} 积分?操作将生成积分流水与审计日志,且不可撤销。`, |
||||
'手动调整积分', |
||||
{ type: 'warning' } |
||||
) |
||||
.then(() => { |
||||
this.submitting = true |
||||
return adjustPoints({ |
||||
userId: this.form.userId, |
||||
points, |
||||
reason: this.form.reason |
||||
}) |
||||
}) |
||||
.then(() => { |
||||
this.$modal.msgSuccess('积分调整成功') |
||||
this.loadBalance(this.form.userId) |
||||
}) |
||||
.catch(error => { |
||||
// 取消确认;接口失败已由请求拦截器统一提示,无需重复弹错 |
||||
if (error === 'cancel') return |
||||
}) |
||||
.finally(() => { |
||||
this.submitting = false |
||||
}) |
||||
}) |
||||
}, |
||||
resetForm() { |
||||
this.$refs.adjustForm.resetFields() |
||||
this.form.points = undefined |
||||
this.balance = null |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" scoped> |
||||
.adjust-heading__title { |
||||
color: #1a1a2e; |
||||
font-size: 14px; |
||||
font-weight: 600; |
||||
line-height: 20px; |
||||
} |
||||
.adjust-heading__description { |
||||
margin-top: 6px; |
||||
color: #9898ae; |
||||
font-size: 11px; |
||||
font-weight: 400; |
||||
line-height: 18px; |
||||
} |
||||
.adjust-form { |
||||
max-width: 720px; |
||||
padding-top: 4px; |
||||
} |
||||
.adjust-balance { |
||||
color: #1a1a2e; |
||||
font-size: 13px; |
||||
} |
||||
.adjust-hint { |
||||
margin-left: 10px; |
||||
color: #9898ae; |
||||
font-size: 12px; |
||||
} |
||||
</style> |
||||
Loading…
Reference in new issue