领导人员功能开发功能开发
This commit is contained in:
parent
85deffe64d
commit
9df9082b19
|
|
@ -0,0 +1,19 @@
|
|||
// src/api/system/custInfo.js
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function listCustInfo(query) {
|
||||
return request({
|
||||
url: '/smart-canteen/custInfo/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 切换功能状态
|
||||
export function toggleFunction(data) {
|
||||
return request({
|
||||
url: '/smart-canteen/custInfo/toggleFunction',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
import CryptoJS from "crypto-js";
|
||||
|
||||
/**
|
||||
* 解密
|
||||
*/
|
||||
export function bnsCloudDecrypt(word) {
|
||||
const key = CryptoJS.enc.Utf8.parse("bonus@cloud@2025");
|
||||
const decrypt = CryptoJS.AES.decrypt(word, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
return CryptoJS.enc.Utf8.stringify(decrypt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
export function bnsCloudEncrypt(word) {
|
||||
const key = CryptoJS.enc.Utf8.parse("bonus@cloud@2025");
|
||||
const src = CryptoJS.enc.Utf8.parse(word);
|
||||
const encrypted = CryptoJS.AES.encrypt(src, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
return encrypted.toString();
|
||||
}
|
||||
|
|
@ -0,0 +1,327 @@
|
|||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 查询条件 -->
|
||||
<el-form :inline="true" :model="queryParams" class="demo-form-inline">
|
||||
<el-form-item label="组织">
|
||||
<el-cascader
|
||||
v-model="selectedOrg"
|
||||
:options="orgOptions"
|
||||
:show-all-levels="false"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择组织"
|
||||
:props="{
|
||||
checkStrictly: true,
|
||||
expandTrigger: 'hover',
|
||||
value: 'orgId',
|
||||
label: 'orgName',
|
||||
children: 'children'
|
||||
}"
|
||||
style="width: 260px;"
|
||||
>
|
||||
</el-cascader>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="人员姓名">
|
||||
<el-input v-model="queryParams.custName" placeholder="请输入人员姓名" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="领导配置">
|
||||
<el-select v-model="queryParams.functionStatus" placeholder="请选择功能状态" clearable>
|
||||
<el-option label="全部" value="" />
|
||||
<el-option label="已开启" value="1" />
|
||||
<el-option label="未开启" value="0" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||
<el-button @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- 数据表格:使用后端分页返回的数据,前端不再二次 slice -->
|
||||
<el-table
|
||||
:data="tableData"
|
||||
border
|
||||
style="width: 100%"
|
||||
:header-cell-style="tableHeaderStyle"
|
||||
:cell-style="tableCellStyle"
|
||||
v-loading="loading"
|
||||
element-loading-text="数据加载中..."
|
||||
element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(255, 255, 255, 0.8)"
|
||||
>
|
||||
<!-- 序号列:连续分页序号 -->
|
||||
<el-table-column
|
||||
label="序号"
|
||||
align="center"
|
||||
type="index"
|
||||
:index="indexMethod"
|
||||
width="80"
|
||||
/>
|
||||
<el-table-column
|
||||
label="组织"
|
||||
prop="orgFullName"
|
||||
align="center"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column label="人员姓名" prop="custNameResult" align="center" />
|
||||
<el-table-column label="人员ID" prop="custId" align="center" />
|
||||
<el-table-column label="人员编号" prop="custNumResult" align="center" />
|
||||
<el-table-column label="手机号码" prop="phoneResult" align="center" />
|
||||
<el-table-column label="创建时间" prop="crtime" align="center" />
|
||||
<el-table-column label="领导配置" align="center" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.hasFunction"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
@change="toggleFunctionStatus(scope.row)"
|
||||
/>
|
||||
<div style="margin-top: 5px; font-size: 12px; color: #666;">
|
||||
{{ scope.row.hasFunction ? '已开启' : '未开启' }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 分页 -->
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNum"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listCustInfo, toggleFunction } from '@/api/system/custInfo'
|
||||
import { getTree } from '@/api/canteen/canteenRecord'
|
||||
|
||||
export default {
|
||||
name: 'CustInfo',
|
||||
data() {
|
||||
return {
|
||||
selectedOrg: [],
|
||||
orgOptions: [],
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
startPayTime: '',
|
||||
endPayTime: '',
|
||||
custName: '',
|
||||
functionStatus: '',
|
||||
configCode: 'LEADER_CONFIG'
|
||||
},
|
||||
tableData: [],
|
||||
total: 0,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getTree()
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
// 序号计算方法:和消费记录页面保持一致
|
||||
indexMethod(index) {
|
||||
return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1
|
||||
},
|
||||
|
||||
// 表格样式:和消费记录页面保持一致
|
||||
tableHeaderStyle() {
|
||||
return {
|
||||
background: "#f5f7fa",
|
||||
fontWeight: "bold",
|
||||
textAlign: "center"
|
||||
}
|
||||
},
|
||||
|
||||
tableCellStyle() {
|
||||
return {
|
||||
textAlign: "center"
|
||||
}
|
||||
},
|
||||
|
||||
getTree() {
|
||||
getTree().then(res => {
|
||||
this.orgOptions = res
|
||||
})
|
||||
},
|
||||
|
||||
getAllChildIds(node) {
|
||||
let ids = [node.orgId]
|
||||
if (node.children && node.children.length > 0) {
|
||||
node.children.forEach(child => {
|
||||
ids = ids.concat(this.getAllChildIds(child))
|
||||
})
|
||||
}
|
||||
return ids
|
||||
},
|
||||
|
||||
getSelectedOrgIds() {
|
||||
if (!this.selectedOrg || this.selectedOrg.length === 0) return []
|
||||
const lastValue = this.selectedOrg[this.selectedOrg.length - 1]
|
||||
|
||||
let stack = [...this.orgOptions]
|
||||
let node = null
|
||||
for (const val of this.selectedOrg) {
|
||||
node = stack.find(item => item.orgId === val)
|
||||
if (!node) break
|
||||
stack = node.children || []
|
||||
}
|
||||
|
||||
if (node) {
|
||||
return this.getAllChildIds(node)
|
||||
}
|
||||
return [lastValue]
|
||||
},
|
||||
|
||||
// 获取列表数据:和消费记录页面保持一致的逻辑
|
||||
getList() {
|
||||
this.loading = true
|
||||
const orgIds = this.getSelectedOrgIds()
|
||||
|
||||
const params = {
|
||||
pageNum: this.queryParams.pageNum,
|
||||
pageSize: this.queryParams.pageSize,
|
||||
custName: this.queryParams.custName,
|
||||
functionStatus: this.queryParams.functionStatus,
|
||||
configCode: this.queryParams.configCode,
|
||||
selectedOrg: orgIds // 这里必须和消费记录页面保持一致
|
||||
}
|
||||
|
||||
// 移除空值参数
|
||||
Object.keys(params).forEach(key => {
|
||||
if (params[key] === '' || params[key] === null || params[key] === undefined) {
|
||||
delete params[key]
|
||||
}
|
||||
})
|
||||
|
||||
// 如果selectedOrg是空数组,也删除这个参数
|
||||
if (params.selectedOrg && params.selectedOrg.length === 0) {
|
||||
delete params.selectedOrg
|
||||
}
|
||||
|
||||
listCustInfo(params).then(response => {
|
||||
// 关键:确保数据正确处理
|
||||
console.log('API响应:', response) // 调试用
|
||||
|
||||
// 这里需要根据后端实际返回的结构调整
|
||||
// 如果是若依的标准返回结构
|
||||
if (response && response.rows) {
|
||||
this.tableData = response.rows || []
|
||||
this.total = Number(response.total) || 0
|
||||
}
|
||||
// 如果是自定义返回结构
|
||||
else if (response && response.data) {
|
||||
this.tableData = response.data.rows || response.data.list || []
|
||||
this.total = Number(response.data.total) || 0
|
||||
}
|
||||
// 如果是直接返回数组
|
||||
else if (Array.isArray(response)) {
|
||||
this.tableData = response
|
||||
this.total = response.length
|
||||
}
|
||||
// 其他情况
|
||||
else {
|
||||
this.tableData = []
|
||||
this.total = 0
|
||||
}
|
||||
|
||||
console.log('处理后数据:', {
|
||||
tableData: this.tableData,
|
||||
total: this.total
|
||||
}) // 调试用
|
||||
|
||||
this.loading = false
|
||||
}).catch(error => {
|
||||
console.error('查询失败:', error)
|
||||
this.tableData = []
|
||||
this.total = 0
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
|
||||
resetQuery() {
|
||||
this.selectedOrg = []
|
||||
this.queryParams = {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
startPayTime: '',
|
||||
endPayTime: '',
|
||||
custName: '',
|
||||
functionStatus: '',
|
||||
configCode: 'LEADER_CONFIG'
|
||||
}
|
||||
this.getList()
|
||||
},
|
||||
|
||||
toggleFunctionStatus(row) {
|
||||
const oldStatus = !row.hasFunction
|
||||
const statusText = row.hasFunction ? '开启' : '关闭'
|
||||
|
||||
this.$confirm(`确定要${statusText}该人员的领导配置吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
toggleFunction({
|
||||
custId: row.custId,
|
||||
configCode: 'LEADER_CONFIG',
|
||||
hasFunction: row.hasFunction
|
||||
}).then(response => {
|
||||
this.$modal.msgSuccess(response.msg || '操作成功')
|
||||
// 刷新当前页数据
|
||||
this.getList()
|
||||
}).catch(error => {
|
||||
row.hasFunction = oldStatus
|
||||
this.$modal.msgError(error.msg || '操作失败')
|
||||
})
|
||||
}).catch(() => {
|
||||
row.hasFunction = oldStatus
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.demo-form-inline {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.demo-form-inline .el-form-item {
|
||||
margin-right: 15px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* 压缩表格行高度 */
|
||||
::v-deep .el-table__row {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
::v-deep .el-table .cell {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
font-size: 13px;
|
||||
line-height: 18px;
|
||||
}
|
||||
|
||||
::v-deep .el-table__header-wrapper th {
|
||||
padding-top: 8px !important;
|
||||
padding-bottom: 8px !important;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue