Fix: Refactor Organization CRUD {id} to {code}
This commit is contained in:
@@ -28,13 +28,15 @@ export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
|
||||
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Division) => ({
|
||||
value: item.id ? Number(item.id) : item.code,
|
||||
value: useCodeAsValue ? item.code
|
||||
: item.id ? Number(item.id)
|
||||
: item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
@@ -46,10 +48,12 @@ export async function getValueLabelList(params: any = null): Promise<{ value: st
|
||||
* @param divisions Array of division objects from API
|
||||
* @returns TreeItem[]
|
||||
*/
|
||||
export function getValueTreeItems(divisions: any[]): TreeItem[] {
|
||||
export function getValueTreeItems(divisions: any[], byCode = true): TreeItem[] {
|
||||
return divisions
|
||||
.map((division: Division) => ({
|
||||
value: division.id ? String(division.id) : division.code,
|
||||
value: byCode ? String(division.code)
|
||||
: String(division.id) ? String(division.id)
|
||||
: division.code,
|
||||
label: division.name,
|
||||
hasChildren: Array.isArray(division.childrens) && division.childrens.length > 0,
|
||||
children:
|
||||
|
||||
@@ -27,13 +27,15 @@ export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
|
||||
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Installation) => ({
|
||||
value: item.id ? Number(item.id) : item.code,
|
||||
value: useCodeAsValue ? item.code
|
||||
: item.id ? Number(item.id)
|
||||
: item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -28,13 +28,15 @@ export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
|
||||
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Specialist) => ({
|
||||
value: item.id ? Number(item.id) : item.code,
|
||||
value: useCodeAsValue ? item.code
|
||||
: item.id ? Number(item.id)
|
||||
: item.code,
|
||||
label: item.name,
|
||||
parent: item.unit_id ? Number(item.unit_id) : null,
|
||||
}))
|
||||
|
||||
@@ -27,13 +27,15 @@ export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
|
||||
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Subspecialist) => ({
|
||||
value: item.id ? Number(item.id) : item.code,
|
||||
value: useCodeAsValue ? item.code
|
||||
: item.id ? Number(item.id)
|
||||
: item.code,
|
||||
label: item.name,
|
||||
parent: item.specialist_id ? Number(item.specialist_id) : null,
|
||||
}))
|
||||
|
||||
@@ -27,13 +27,15 @@ export function remove(id: number | string) {
|
||||
return base.remove(path, id, name)
|
||||
}
|
||||
|
||||
export async function getValueLabelList(params: any = null): Promise<{ value: string; label: string }[]> {
|
||||
export async function getValueLabelList(params: any = null, useCodeAsValue = false): Promise<{ value: string; label: string }[]> {
|
||||
let data: { value: string; label: string }[] = []
|
||||
const result = await getList(params)
|
||||
if (result.success) {
|
||||
const resultData = result.body?.data || []
|
||||
data = resultData.map((item: Unit) => ({
|
||||
value: item.id,
|
||||
value: useCodeAsValue ? item.code
|
||||
: item.id ? Number(item.id)
|
||||
: item.code,
|
||||
label: item.name,
|
||||
}))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user