This commit is contained in:
BianLzhaoMin 2025-11-18 18:01:33 +08:00
parent e31bd2c78f
commit 3c580c86f6
9 changed files with 346 additions and 168 deletions

View File

@ -4,7 +4,7 @@ VUE_APP_TITLE = 实名制管理系统
# 生产环境配置
ENV = 'production'
VUE_APP_ENV = 'production'
VUE_APP_SHOW_PARAMETER = true
VUE_APP_SHOW_PARAMETER = false
# 实名制管理系统/生产环境
VUE_APP_BASE_API = '/hd-real-name'

View File

@ -1,19 +1,21 @@
const getters = {
sidebar: state => state.app.sidebar,
size: state => state.app.size,
device: state => state.app.device,
dict: state => state.dict.dict,
visitedViews: state => state.tagsView.visitedViews,
cachedViews: state => state.tagsView.cachedViews,
token: state => state.user.token,
avatar: state => state.user.avatar,
name: state => state.user.name,
introduction: state => state.user.introduction,
roles: state => state.user.roles,
permissions: state => state.user.permissions,
permission_routes: state => state.permission.routes,
topbarRouters: state => state.permission.topbarRouters,
defaultRoutes: state => state.permission.defaultRoutes,
sidebarRouters: state => state.permission.sidebarRouters
sidebar: (state) => state.app.sidebar,
size: (state) => state.app.size,
device: (state) => state.app.device,
dict: (state) => state.dict.dict,
visitedViews: (state) => state.tagsView.visitedViews,
cachedViews: (state) => state.tagsView.cachedViews,
token: (state) => state.user.token,
avatar: (state) => state.user.avatar,
name: (state) => state.user.name,
introduction: (state) => state.user.introduction,
roles: (state) => state.user.roles,
permissions: (state) => state.user.permissions,
permission_routes: (state) => state.permission.routes,
topbarRouters: (state) => state.permission.topbarRouters,
defaultRoutes: (state) => state.permission.defaultRoutes,
sidebarRouters: (state) => state.permission.sidebarRouters,
companyId: (state) => state.user.companyId,
companyLevel: (state) => state.user.companyLevel,
}
export default getters

View File

@ -1,4 +1,12 @@
import { login, logout, getInfo, refreshToken, getPhoneCode, isLogin,isAdmin} from '@/api/login'
import {
login,
logout,
getInfo,
refreshToken,
getPhoneCode,
isLogin,
isAdmin,
} from '@/api/login'
import { getToken, setToken, setExpiresIn, removeToken } from '@/utils/auth'
// 更严格的手机号和邮箱正则表达式
@ -6,20 +14,37 @@ const phonePattern = /^(\+86)?1[3-9]\d{9}$/ // 支持前缀 +86
const emailPattern = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/
// 构建 payload 函数
const buildPayload = ({ loginMethod, username, password, uuid, code, mobile, verificationCode,phoneUuid }) => {
const buildPayload = ({
loginMethod,
username,
password,
uuid,
code,
mobile,
verificationCode,
phoneUuid,
}) => {
let loginType = ''
if (loginMethod === 'mobile') {
loginType = phonePattern.test(mobile.trim()) ? 'PHONE_OTP' : emailPattern.test(mobile.trim()) ? 'EMAIL_OTP' : 'PHONE_OTP'
loginType = phonePattern.test(mobile.trim())
? 'PHONE_OTP'
: emailPattern.test(mobile.trim())
? 'EMAIL_OTP'
: 'PHONE_OTP'
return {
username: mobile.trim(),
verificationCode,
uuid,
code,
loginType,
phoneUuid
phoneUuid,
}
} else {
loginType = phonePattern.test(username.trim()) ? 'PHONE_PASSWORD' : emailPattern.test(username.trim()) ? 'EMAIL_PASSWORD' : 'USERNAME_PASSWORD'
loginType = phonePattern.test(username.trim())
? 'PHONE_PASSWORD'
: emailPattern.test(username.trim())
? 'EMAIL_PASSWORD'
: 'USERNAME_PASSWORD'
return {
username: username.trim(),
password,
@ -27,7 +52,7 @@ const buildPayload = ({ loginMethod, username, password, uuid, code, mobile, ver
uuid,
code,
loginType,
phoneUuid
phoneUuid,
}
}
}
@ -39,7 +64,9 @@ const user = {
name: '',
avatar: '',
roles: [],
permissions: []
permissions: [],
companyId: '',
companyLevel: '',
},
mutations: {
@ -63,36 +90,43 @@ const user = {
},
SET_PERMISSIONS(state, permissions) {
state.permissions = permissions
}
},
SET_COMPANY_ID(state, companyId) {
state.companyId = companyId
},
SET_COMPANY_LEVEL(state, companyLevel) {
state.companyLevel = companyLevel
},
},
actions: {
IsLogin({ commit }, userInfo) {
const payload = buildPayload(userInfo)
return isLogin(payload)
.then(res => res)
.catch(error => Promise.reject(error))
.then((res) => res)
.catch((error) => Promise.reject(error))
},
IsAdmin({ commit }, userInfo) {
const payload = buildPayload(userInfo)
return isAdmin(payload)
.then(res => res)
.catch(error => Promise.reject(error))
.then((res) => res)
.catch((error) => Promise.reject(error))
},
// 登录
Login({ commit }, userInfo) {
const payload = buildPayload(userInfo)
return login(payload)
.then(res => {
.then((res) => {
const { access_token, expires_in } = res.data
setToken(access_token)
commit('SET_TOKEN', access_token)
setExpiresIn(expires_in)
commit('SET_EXPIRES_IN', expires_in)
return res;
return res
})
.catch(error => Promise.reject(error))
.catch((error) => Promise.reject(error))
},
// 获取手机验证码
@ -102,38 +136,50 @@ const user = {
uuid: userInfo.uuid,
code: userInfo.code,
phoneUuid: userInfo.phoneUuid,
verificationCodeType: userInfo.mobileCodeType
verificationCodeType: userInfo.mobileCodeType,
}
return getPhoneCode(payload)
.then(res => res)
.catch(error => Promise.reject(error))
.then((res) => res)
.catch((error) => Promise.reject(error))
},
// 获取用户信息
GetInfo({ commit }) {
return getInfo()
.then(res => {
.then((res) => {
const user = res.user
const avatar = user.avatar ? user.avatar : require('@/assets/images/profile.jpg')
commit('SET_ROLES', res.roles && res.roles.length > 0 ? res.roles : ['ROLE_DEFAULT'])
const avatar = user.avatar
? user.avatar
: require('@/assets/images/profile.jpg')
commit(
'SET_ROLES',
res.roles && res.roles.length > 0
? res.roles
: ['ROLE_DEFAULT'],
)
commit('SET_PERMISSIONS', res.permissions)
commit('SET_ID', user.userId)
commit('SET_NAME', user.userName)
commit('SET_AVATAR', avatar)
// 存储用户的公司id 和公司级别
commit('SET_COMPANY_ID', user.bandId)
commit('SET_COMPANY_LEVEL', user.roleLevel)
return res
})
.catch(error => Promise.reject(error))
.catch((error) => Promise.reject(error))
},
// 刷新 token
RefreshToken({ commit, state }) {
return refreshToken(state.token)
.then(res => {
.then((res) => {
const expiresIn = res.data
setExpiresIn(expiresIn)
commit('SET_EXPIRES_IN', expiresIn)
})
.catch(error => Promise.reject(error))
.catch((error) => Promise.reject(error))
},
// 退出登录
@ -145,18 +191,18 @@ const user = {
commit('SET_PERMISSIONS', [])
removeToken()
})
.catch(error => Promise.reject(error))
.catch((error) => Promise.reject(error))
},
// 前端退出
FedLogOut({ commit }) {
return new Promise(resolve => {
return new Promise((resolve) => {
commit('SET_TOKEN', '')
removeToken()
resolve()
})
}
}
},
},
}
export default user

View File

@ -8,6 +8,7 @@ export const formLabel = [
]
export const columnsList = [
{ t_props: 'subComName', t_label: '所属分公司' },
{ t_props: 'mainProName', t_label: '总工程名称' },
{ t_props: 'volLevel', t_label: '电压等级' },

View File

@ -94,6 +94,23 @@
:model="addOrEditForm"
:rules="addOrEditFormRules"
>
<el-form-item label="所属分公司" prop="subComId">
<el-select
clearable
filterable
style="width: 100%"
:disabled="subIsDisabled"
placeholder="请选择所属分公司"
v-model="addOrEditForm.subComId"
>
<el-option
:key="item.id"
:value="item.id"
:label="item.subCompanyName"
v-for="item in branchCompanyOptions"
/>
</el-select>
</el-form-item>
<el-form-item label="总工程名称" prop="mainProName">
<el-input
clearable
@ -195,12 +212,14 @@
<script>
import TableModel from '@/components/TableModel'
import DialogModel from '@/components/DialogModel'
import { formLabel, columnsList, dialogConfig } from './config'
import {
addAndEditAllProjectAPI,
deleteAllProjectAPI,
getAllProjectListAPI,
} from '@/api/basic-manage/project-manage/all-project'
import { getSubCompanySelectListCommonFun } from '@/utils/getCommonData'
export default {
name: 'All-project',
dicts: ['voltage_level', 'project_type', 'project_status'],
@ -215,16 +234,25 @@ export default {
columnsList,
dialogConfig,
getAllProjectListAPI,
subIsDisabled: false, //
lotProjectList: [], // ()
branchCompanyOptions: [], //
//
addOrEditForm: {
subComId: '', // id
id: '', // id
volLevel: '', //
mainProName: '', //
},
//
addOrEditFormRules: {
subComId: [
{
required: true,
trigger: 'change',
message: '请选择所属分公司',
},
],
mainProName: [
{
required: true,
@ -247,6 +275,11 @@ export default {
}
},
async created() {
//
this.branchCompanyOptions = await getSubCompanySelectListCommonFun() //
},
methods: {
//
onHandleExportAllProject(queryParams) {
@ -261,14 +294,16 @@ export default {
//
onHandleAddOrEditAllProject(type, data) {
this.getCurrentCompanyIdAndLevel() // id
this.dialogConfig.outerTitle =
type === 1 ? '新增总工程' : '修改总工程'
if (type === 2) {
const { mainProName, volLevel, id } = data
const { mainProName, volLevel, id, subComId } = data
this.addOrEditForm = {
id,
volLevel,
subComId: subComId === null ? '' : subComId * 1,
mainProName,
}
}
@ -377,6 +412,26 @@ export default {
return status || ''
},
//
onHandleSelectOrgId(node) {
this.addOrEditForm.subComId = node.parentId
// this.addOrEditForm.orgId = node.id
},
// id
getCurrentCompanyIdAndLevel() {
// id
const companyId = this.$store.getters.companyId
//
const companyLevel = this.$store.getters.companyLevel
if (companyLevel === '分公司级') {
this.addOrEditForm.subComId = companyId * 1
}
this.subIsDisabled = companyLevel === '分公司级'
},
},
}
</script>

View File

@ -102,7 +102,8 @@
placeholder="请选择所属分公司"
v-model="addOrEditForm.subComId"
:disabled="
dialogConfig.outerTitle === '修改项目部'
dialogConfig.outerTitle === '修改项目部' ||
subIsDisabled
"
>
<el-option
@ -234,6 +235,7 @@ export default {
columnsList,
dialogConfig,
getDeptProjectListAPI,
subIsDisabled: false, //
lotProjectList: [], // ()
branchCompanyOptions: [], //
@ -288,6 +290,7 @@ export default {
//
onHandleAddOrEditDeptProject(type, data, title) {
this.getCurrentCompanyIdAndLevel() // id
this.dialogConfig.outerTitle = `${title}项目部`
if (type === 2) {
const { id, orgName, isEnable, subComId } = data
@ -398,6 +401,20 @@ export default {
return data || ''
},
// id
getCurrentCompanyIdAndLevel() {
// id
const companyId = this.$store.getters.companyId
//
const companyLevel = this.$store.getters.companyLevel
if (companyLevel === '分公司级') {
this.addOrEditForm.subComId = companyId * 1
}
this.subIsDisabled = companyLevel === '分公司级'
},
},
async created() {

View File

@ -31,7 +31,27 @@
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="所属分公司" prop="subComId">
<el-select
clearable
filterable
style="width: 100%"
:disabled="subIsDisabled"
placeholder="请选择所属分公司"
v-model="addOrEditForm.subComId"
>
<el-option
:key="item.id"
:value="item.id"
:label="item.subCompanyName"
v-for="item in branchCompanyOptions"
/>
</el-select>
</el-form-item>
</el-col>
<!-- 法人信息 -->
<el-col :span="12">
<el-form-item label="法人联系电话" prop="legalPersonPhone">
@ -44,6 +64,8 @@
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="营业住址">
<el-input
@ -58,9 +80,8 @@
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="营业执照" >
<el-form-item label="营业执照">
<UploadImgFormData
:limit="1"
:file-size="10"
@ -74,7 +95,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电子公章" >
<el-form-item label="电子公章">
<UploadImgFormData
:limit="1"
:file-size="10"
@ -102,10 +123,7 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item
label="电子签名/法人印章"
>
<el-form-item label="电子签名/法人印章">
<UploadImgFormData
:limit="1"
:file-size="10"
@ -126,6 +144,7 @@
<script>
import UploadImgFormData from '@/components/UploadImgFormData'
import { addAndEditSubBaseInfoAPI } from '@/api/basic-manage/sub-manage/sub-base-info'
import { getSubCompanySelectListCommonFun } from '@/utils/getCommonData'
export default {
name: 'AddOrEditForm',
components: {
@ -144,6 +163,8 @@ export default {
},
data() {
return {
subIsDisabled: false, //
branchCompanyOptions: [], //
editUploadFileList: [], //
addOrEditForm: {
id: null, // id
@ -151,6 +172,7 @@ export default {
subAddress: '', //
legalPerson: '', //
legalPersonPhone: '', //
subComId: '', // id
idCard: [], //
businessLicense: [], //
@ -174,6 +196,14 @@ export default {
},
],
subComId: [
{
required: true,
trigger: 'change',
message: '请选择所属分公司',
},
],
legalPersonPhone: [
{
trigger: 'blur',
@ -213,6 +243,10 @@ export default {
},
}
},
async created() {
this.branchCompanyOptions = await getSubCompanySelectListCommonFun() //
this.getCurrentCompanyIdAndLevel() // id
},
methods: {
//
onHandleConfirmAddOrEditFun() {
@ -224,6 +258,7 @@ export default {
id,
idCard,
subName,
subComId,
subAddress,
legalPerson,
businessLicense,
@ -247,6 +282,7 @@ export default {
subAddress,
legalPerson,
legalPersonPhone,
subComId,
}
businessLicense.forEach((item) => {
@ -336,6 +372,20 @@ export default {
resetForm() {
this.$refs.addOrEditFormRef.resetFields()
},
// id
getCurrentCompanyIdAndLevel() {
// id
const companyId = this.$store.getters.companyId
//
const companyLevel = this.$store.getters.companyLevel
if (companyLevel === '分公司级') {
this.addOrEditForm.subComId = companyId * 1
}
this.subIsDisabled = companyLevel === '分公司级'
},
},
watch: {
@ -349,9 +399,10 @@ export default {
legalPerson,
contractFile,
legalPersonPhone,
subComId,
} = newVal
if (contractFile.length > 0) {
if (contractFile && contractFile.length > 0) {
this.editUploadFileList = contractFile //
//
@ -404,6 +455,7 @@ export default {
subName,
subAddress,
legalPerson,
subComId,
legalPersonPhone,
})
}

View File

@ -170,6 +170,8 @@ export default {
if (type === 2) {
Object.assign(this.editFormData, data)
this.editFormData.subComId =
data.subComId === null ? '' : data.subComId * 1
} else {
this.editFormData = {}
}

View File

@ -6,6 +6,9 @@
:showOperation="true"
:showRightTools="true"
ref="personEntryTableRef"
:sendParams="{
einStatus: '1',
}"
:columnsList="columnsList"
:request-api="getEntryPersonListAPI"
>