This commit is contained in:
parent
129e38ec19
commit
1c1b9ef559
|
|
@ -391,7 +391,16 @@ async function handleSubmit() {
|
|||
console.log(`[fault-add] ====== 提交成功, 总耗时${Date.now() - t0}ms ======`)
|
||||
uni.showToast({ title: '提交成功', icon: 'success' })
|
||||
setTimeout(() => {
|
||||
// #ifdef H5
|
||||
// H5端页面栈可能因刷新丢失,navigateBack 可能回到首页而非故障列表
|
||||
// 直接 redirectTo 回故障列表页,确保回到上级页面
|
||||
uni.redirectTo({
|
||||
url: '/pages/fault-list/index?cableId=' + cableId.value + '&cableName=' + encodeURIComponent(form.cableName)
|
||||
})
|
||||
// #endif
|
||||
// #ifndef H5
|
||||
uni.navigateBack()
|
||||
// #endif
|
||||
}, 1500)
|
||||
} else {
|
||||
console.warn(`[fault-add] 业务失败: code=${res.code}, msg=${res.msg}`)
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
<text class="info-label">故障发生频次</text>
|
||||
<view class="info-value freq-row">
|
||||
<text class="freq-value">{{ detail.faultCount }}</text>
|
||||
<view class="freq-btn" @click="handleIncrement">
|
||||
<view class="freq-btn" @click="handleIncrement" v-if="canEdit">
|
||||
<text class="freq-btn-text">增加频次</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -90,7 +90,7 @@
|
|||
</view>
|
||||
<view class="info-value correction-row" v-else>
|
||||
<text>{{ detail.mileageCorrection || '未填写' }}</text>
|
||||
<view class="correction-btn edit-btn" @click="startEditCorrection">
|
||||
<view class="correction-btn edit-btn" @click="startEditCorrection" v-if="canEdit">
|
||||
<text class="correction-btn-text">修改</text>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -125,6 +125,9 @@ import { onLoad } from '@dcloudio/uni-app'
|
|||
import { getFaultDetail, incrementFaultCount, updateMileageCorrection } from '@/services/trunk'
|
||||
import { BASE_URL } from '@/services/api'
|
||||
import { openNavigation } from '@/utils/navigation'
|
||||
import store from '@/store'
|
||||
|
||||
const canEdit = store.hasPermi('odfcablefaults:edit')
|
||||
|
||||
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
||||
const faultId = ref('')
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
</view>
|
||||
|
||||
<!-- 底部固定按钮 -->
|
||||
<view class="bottom-bar">
|
||||
<view class="bottom-bar" v-if="canAdd">
|
||||
<view class="add-fault-btn" @click="goFaultAdd">
|
||||
<text class="add-fault-btn-text">新增故障</text>
|
||||
</view>
|
||||
|
|
@ -59,6 +59,7 @@
|
|||
import { ref } from 'vue'
|
||||
import { onLoad, onShow, onReachBottom } from '@dcloudio/uni-app'
|
||||
import { getFaultList } from '@/services/trunk'
|
||||
import store from '@/store'
|
||||
|
||||
const statusBarHeight = uni.getSystemInfoSync().statusBarHeight || 0
|
||||
const faultList = ref([])
|
||||
|
|
@ -68,6 +69,7 @@ const pageNum = ref(1)
|
|||
const pageSize = ref(20)
|
||||
const totalPage = ref(1)
|
||||
const loading = ref(false)
|
||||
const canAdd = store.hasPermi('odfcablefaults:add')
|
||||
|
||||
function calcDisplayMileage(mileage, mileageCorrection) {
|
||||
const m = parseFloat(mileage)
|
||||
|
|
|
|||
|
|
@ -39,8 +39,8 @@ const password = ref('')
|
|||
async function handleLogin() {
|
||||
const res = await appLogin(username.value, password.value)
|
||||
if (res.code === 200) {
|
||||
const { jwt, userId, userName } = res.data
|
||||
store.setAuth(jwt, userId, userName)
|
||||
const { jwt, userId, userName, permissions } = res.data
|
||||
store.setAuth(jwt, userId, userName, permissions)
|
||||
const permRes = await checkPermission()
|
||||
store.isPermission = permRes.code === 200
|
||||
// 获取用户功能版块权限
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@ const store = reactive({
|
|||
userName: uni.getStorageSync('userName') || '',
|
||||
isPermission: false,
|
||||
|
||||
// 用户菜单权限列表
|
||||
permissions: JSON.parse(uni.getStorageSync('permissions') || '[]'),
|
||||
|
||||
// 功能版块权限列表
|
||||
modules: JSON.parse(uni.getStorageSync('modules') || '[]'),
|
||||
|
||||
|
|
@ -16,13 +19,21 @@ const store = reactive({
|
|||
dictBusinessTypes: [], // 业务类型列表
|
||||
|
||||
// 设置认证信息
|
||||
setAuth(token, userId, userName) {
|
||||
setAuth(token, userId, userName, permissions) {
|
||||
this.token = token
|
||||
this.userId = userId
|
||||
this.userName = userName
|
||||
this.permissions = permissions || []
|
||||
uni.setStorageSync('token', token)
|
||||
uni.setStorageSync('userId', userId)
|
||||
uni.setStorageSync('userName', userName)
|
||||
uni.setStorageSync('permissions', JSON.stringify(this.permissions))
|
||||
},
|
||||
|
||||
// 检查是否拥有某个权限
|
||||
hasPermi(perm) {
|
||||
if (this.permissions.includes('*:*:*')) return true
|
||||
return this.permissions.includes(perm)
|
||||
},
|
||||
|
||||
// 设置功能版块权限
|
||||
|
|
@ -37,10 +48,12 @@ const store = reactive({
|
|||
this.userId = ''
|
||||
this.userName = ''
|
||||
this.isPermission = false
|
||||
this.permissions = []
|
||||
this.modules = []
|
||||
uni.removeStorageSync('token')
|
||||
uni.removeStorageSync('userId')
|
||||
uni.removeStorageSync('userName')
|
||||
uni.removeStorageSync('permissions')
|
||||
uni.removeStorageSync('modules')
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ namespace ZR.Admin.WebApi.Controllers.Business
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost("add")]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:list")]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:add")]
|
||||
[Log(Title = "干线故障", BusinessType = BusinessType.INSERT)]
|
||||
public async Task<IActionResult> Add([FromBody] OdfCableFaultAddDto dto)
|
||||
{
|
||||
|
|
@ -66,7 +66,7 @@ namespace ZR.Admin.WebApi.Controllers.Business
|
|||
/// 增加故障频次
|
||||
/// </summary>
|
||||
[HttpPost("incrementFaultCount/{id}")]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:list")]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:edit")]
|
||||
[Log(Title = "干线故障", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult IncrementFaultCount(int id)
|
||||
{
|
||||
|
|
@ -78,7 +78,7 @@ namespace ZR.Admin.WebApi.Controllers.Business
|
|||
/// 更新表显里程矫正
|
||||
/// </summary>
|
||||
[HttpPost("updateMileageCorrection/{id}")]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:list")]
|
||||
[ActionPermissionFilter(Permission = "odfcablefaults:edit")]
|
||||
[Log(Title = "干线故障", BusinessType = BusinessType.UPDATE)]
|
||||
public IActionResult UpdateMileageCorrection(int id, [FromBody] MileageCorrectionDto dto)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ namespace ZR.Admin.WebApi.Controllers.System
|
|||
};
|
||||
//CacheService.SetUserPerms(GlobalConstant.UserPermKEY + user.UserId, permissions);
|
||||
var jwt = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser));
|
||||
return SUCCESS(new { jwt, user.UserId, user.UserName });
|
||||
return SUCCESS(new { jwt, user.UserId, user.UserName, permissions });
|
||||
}
|
||||
//
|
||||
|
||||
|
|
|
|||
24
sql/v1.0.2.1/02_add_fault_add_edit_permissions.sql
Normal file
24
sql/v1.0.2.1/02_add_fault_add_edit_permissions.sql
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
-- =============================================
|
||||
-- 干线故障权限修复:新增 odfcablefaults:add 和 odfcablefaults:edit 菜单按钮
|
||||
-- 并分配给角色2(本部门及以下可编辑权限)和角色3(编辑角色)
|
||||
-- 角色4(查看权限)不分配,仅保留 list/query
|
||||
-- =============================================
|
||||
|
||||
-- 1. 插入新增和修改菜单按钮(ParentId=11200 即干线故障管理)
|
||||
SET IDENTITY_INSERT sys_menu ON;
|
||||
|
||||
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, MenuType, perms, Status, IsFrame, IsCache, Visible, Create_by, Create_time)
|
||||
VALUES (11223, N'新增', 11200, 2, 'F', 'odfcablefaults:add', 0, 1, 0, '0', 'admin', GETDATE());
|
||||
|
||||
INSERT INTO sys_menu (MenuId, MenuName, ParentId, OrderNum, MenuType, perms, Status, IsFrame, IsCache, Visible, Create_by, Create_time)
|
||||
VALUES (11224, N'修改', 11200, 3, 'F', 'odfcablefaults:edit', 0, 1, 0, '0', 'admin', GETDATE());
|
||||
|
||||
SET IDENTITY_INSERT sys_menu OFF;
|
||||
|
||||
-- 2. 角色2(本部门及以下可编辑权限)分配新增和修改权限
|
||||
INSERT INTO sys_role_menu (Role_id, Menu_id) VALUES (2, 11223);
|
||||
INSERT INTO sys_role_menu (Role_id, Menu_id) VALUES (2, 11224);
|
||||
|
||||
-- 3. 角色3(编辑角色)分配新增和修改权限
|
||||
INSERT INTO sys_role_menu (Role_id, Menu_id) VALUES (3, 11223);
|
||||
INSERT INTO sys_role_menu (Role_id, Menu_id) VALUES (3, 11224);
|
||||
Loading…
Reference in New Issue
Block a user