File tree Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Expand file tree Collapse file tree 1 file changed +14
-16
lines changed Original file line number Diff line number Diff line change @@ -332,26 +332,24 @@ const getPostOptions = async () => {
332
332
const res = await getSimplePostList ()
333
333
postOptions .value .push (... res )
334
334
}
335
- const dataFormater = (val ) => {
336
- return deptFormater (deptOptions .value , val )
337
- }
335
+ const dataFormater = computed (() => (deptId : number ) => deptFormater (deptOptions .value , deptId ))
336
+
338
337
// 部门回显
339
- const deptFormater = (ary , val : any ) => {
340
- var o = ' '
341
- if (ary && val ) {
342
- for (const v of ary ) {
343
- if (v .id == val ) {
344
- o = v .name
345
- if (o ) return o
346
- } else if (v .children ?.length ) {
347
- o = deptFormater (v .children , val )
348
- if (o ) return o
338
+ const deptFormater = (arr : Tree [], deptId : number ) => {
339
+ let deptName = ' '
340
+ if (arr && deptId ) {
341
+ for (const item of arr ) {
342
+ if (item .id === deptId ) {
343
+ deptName = item .name
344
+ break
345
+ }
346
+ if (item .children ) {
347
+ deptName = deptFormater (item .children , deptId ) ?? ' '
348
+ break
349
349
}
350
350
}
351
- return o
352
- } else {
353
- return val
354
351
}
352
+ return deptName
355
353
}
356
354
357
355
// 设置标题
You can’t perform that action at this time.
0 commit comments