Commit 61517eb4 authored by 田翔's avatar 田翔

fix: 通过ID获取部门名称

parent ede9a08a
{
"name": "panda-xform",
"version": "5.3.5",
"description": "5.3.5 本人相关信息修改,隐藏增加变量",
"version": "5.3.7",
"description": "5.3.7 通过ID获取部门名称",
"keywords": [
"panda-xform"
],
......
......@@ -247,6 +247,16 @@ export function getUserName(userID) {
});
}
export function getGroupName(groupIds) {
return request({
headers: {
'Civ-Site': window?.globalConfig?.userInfo?.site
},
url: `PandaOMS/OMS/UserCenter/GetGroupName?groupIds=${groupIds}`,
method: 'get',
});
}
// 台账表单的提交
export function SubmitAccountData(tableName, key, value, data) {
return request({
......
......@@ -19,7 +19,7 @@ export const debounce = (fn, wait = 300) => {
}
//json值结构转化为数组值
export const jsonToValues = (data, paths) => {
const jsonToValues = (data, paths) => {
let formValue = []
Object.keys(data).map((k) => {
if (isObject(data[k])) {
......@@ -28,7 +28,7 @@ export const jsonToValues = (data, paths) => {
})
}
})
let values = Array.isArray(window.pandaXform.env) ? window.pandaXform.env : []
let values = Array.isArray(window.pandaXform.env) ? [...window.pandaXform.env] : []
if (Array.isArray(paths)) {
paths.forEach(v => {
let fieldName = v.path.split('.')[1]
......@@ -161,6 +161,7 @@ const getGroupHidden = (form, schema, gorupName) => {
const formFieldHide = async (params) => {
if ((new Date().getTime() - params.startTime) < 2000) return
console.log(1, jsonToValues(params.form.getValues(), params.paths))
let param = {
tableName: params.tableName,
filedFormulas: params.filedFormulas,
......
......@@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo, useContext } from 'react'
import { Input, message, ConfigProvider } from 'antd'
import Icon, { PlusOutlined } from '@ant-design/icons'
import * as icons from '@ant-design/icons'
import { GetFieldValueFromTable, getUserName } from '../../../../apis/process'
import { GetFieldValueFromTable, getUserName, getGroupName } from '../../../../apis/process'
import styles from './index.less'
const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'object')
......@@ -34,8 +34,6 @@ const TextInput = (props) => {
const { value, onChange, schema, addons } = props
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName, isStoreID, textDefalut } = schema
console.log('props', props)
const handleChange = (e) => {
if (addons) {
onChange(e.target.value)
......@@ -52,34 +50,47 @@ const TextInput = (props) => {
}
}
const getDeptInfo = async (groupIds) => {
const { code, data } = await getGroupName(groupIds)
if (code === 0) {
if (Array.isArray(data) && data.length > 0) {
onChange(data[0])
}
}
}
useEffect(() => {
let value = presetValue
let valueNext = presetValue
if (preview !== 'preview') {
if (!disabled) {
if (!value) {
if (textDefalut === '【本人姓名】') {
if (isStoreID) {
value = userInfo.OID + ''
valueNext = userInfo.OID + ''
} else {
value = userInfo.fullName
valueNext = userInfo.fullName
}
} else if (textDefalut === '【本人部门】') {
if (isStoreID) {
value = userInfo.depart.OID + ''
valueNext = userInfo.depart.OID + ''
} else {
value = userInfo.depart.name
valueNext = userInfo.depart.name
}
} else if (textDefalut === '【本人电话】') {
value = userInfo.Phone
valueNext = userInfo.Phone
}
}
}
if (addons) {
addons.setValue(addons.dataPath, value || '')
addons.setValue(addons.dataPath, valueNext || '')
} else {
onChange(value || '')
onChange(valueNext || '')
}
if (isStoreID && value) {
getUserInfo(value)
if (isStoreID && valueNext) {
if (textDefalut === '【本人姓名】') {
getUserInfo(valueNext)
} else if (textDefalut === '【本人部门】') {
getDeptInfo(valueNext)
}
}
}, [])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment