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

fix: 通过ID获取部门名称

parent ede9a08a
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "5.3.5", "version": "5.3.7",
"description": "5.3.5 本人相关信息修改,隐藏增加变量", "description": "5.3.7 通过ID获取部门名称",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -247,6 +247,16 @@ export function getUserName(userID) { ...@@ -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) { export function SubmitAccountData(tableName, key, value, data) {
return request({ return request({
......
...@@ -19,7 +19,7 @@ export const debounce = (fn, wait = 300) => { ...@@ -19,7 +19,7 @@ export const debounce = (fn, wait = 300) => {
} }
//json值结构转化为数组值 //json值结构转化为数组值
export const jsonToValues = (data, paths) => { const jsonToValues = (data, paths) => {
let formValue = [] let formValue = []
Object.keys(data).map((k) => { Object.keys(data).map((k) => {
if (isObject(data[k])) { if (isObject(data[k])) {
...@@ -28,7 +28,7 @@ export const jsonToValues = (data, paths) => { ...@@ -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)) { if (Array.isArray(paths)) {
paths.forEach(v => { paths.forEach(v => {
let fieldName = v.path.split('.')[1] let fieldName = v.path.split('.')[1]
...@@ -161,6 +161,7 @@ const getGroupHidden = (form, schema, gorupName) => { ...@@ -161,6 +161,7 @@ const getGroupHidden = (form, schema, gorupName) => {
const formFieldHide = async (params) => { const formFieldHide = async (params) => {
if ((new Date().getTime() - params.startTime) < 2000) return if ((new Date().getTime() - params.startTime) < 2000) return
console.log(1, jsonToValues(params.form.getValues(), params.paths))
let param = { let param = {
tableName: params.tableName, tableName: params.tableName,
filedFormulas: params.filedFormulas, filedFormulas: params.filedFormulas,
......
...@@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo, useContext } from 'react' ...@@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo, useContext } from 'react'
import { Input, message, ConfigProvider } from 'antd' import { Input, message, ConfigProvider } from 'antd'
import Icon, { PlusOutlined } from '@ant-design/icons' import Icon, { PlusOutlined } from '@ant-design/icons'
import * as icons 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' import styles from './index.less'
const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'object') const iconList = Object.keys(icons).filter((item) => typeof icons[item] === 'object')
...@@ -34,8 +34,6 @@ const TextInput = (props) => { ...@@ -34,8 +34,6 @@ const TextInput = (props) => {
const { value, onChange, schema, addons } = props const { value, onChange, schema, addons } = props
const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName, isStoreID, textDefalut } = schema const { title, disabled, placeholder, presetValue, addonBefore, addonAfter, maxLength, rules, uniqueVerify, tableName, fieldName, isStoreID, textDefalut } = schema
console.log('props', props)
const handleChange = (e) => { const handleChange = (e) => {
if (addons) { if (addons) {
onChange(e.target.value) onChange(e.target.value)
...@@ -52,34 +50,47 @@ const TextInput = (props) => { ...@@ -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(() => { useEffect(() => {
let value = presetValue let valueNext = presetValue
if (preview !== 'preview') { if (preview !== 'preview') {
if (!disabled) { if (!value) {
if (textDefalut === '【本人姓名】') { if (textDefalut === '【本人姓名】') {
if (isStoreID) { if (isStoreID) {
value = userInfo.OID + '' valueNext = userInfo.OID + ''
} else { } else {
value = userInfo.fullName valueNext = userInfo.fullName
} }
} else if (textDefalut === '【本人部门】') { } else if (textDefalut === '【本人部门】') {
if (isStoreID) { if (isStoreID) {
value = userInfo.depart.OID + '' valueNext = userInfo.depart.OID + ''
} else { } else {
value = userInfo.depart.name valueNext = userInfo.depart.name
} }
} else if (textDefalut === '【本人电话】') { } else if (textDefalut === '【本人电话】') {
value = userInfo.Phone valueNext = userInfo.Phone
} }
} }
} }
if (addons) { if (addons) {
addons.setValue(addons.dataPath, value || '') addons.setValue(addons.dataPath, valueNext || '')
} else { } else {
onChange(value || '') onChange(valueNext || '')
} }
if (isStoreID && value) { if (isStoreID && valueNext) {
getUserInfo(value) 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