领导人员功能开发功能开发

This commit is contained in:
lizhenhua 2025-12-17 17:27:06 +08:00
parent 85deffe64d
commit 9df9082b19
3 changed files with 372 additions and 0 deletions

View File

@ -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
})
}

26
src/utils/newaes.js Normal file
View File

@ -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();
}

View File

@ -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>