Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵增煜
/
tzt-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
52935ca0
authored
Dec 23, 2024
by
赵增煜
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
json处理bug修复
parent
f978627e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
app/Admin/Controllers/ExternalPrescriptionController.php
+17
-8
No files found.
app/Admin/Controllers/ExternalPrescriptionController.php
View file @
52935ca0
...
...
@@ -35,14 +35,22 @@ protected function grid()
$grid
->
column
(
'patient_id_card'
);
$grid
->
column
(
'doctor_name'
);
$grid
->
column
(
'diagnosis'
);
$grid
->
column
(
'drug_info'
);
$grid
->
column
(
'drug_info'
)
->
pluck
(
'drug_name'
)
->
label
();
$grid
->
column
(
'drug_info'
)
->
display
(
function
(
$drugInfo
)
{
return
array_map
(
function
(
$item
)
{
$item
=
json_decode
(
$item
,
true
);
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
},
$drugInfo
);
})
->
label
();
$grid
->
column
(
'drug_info'
)
->
display
(
function
(
$drugInfoJson
)
{
// 尝试将 $drugInfoJson 解码为数组
$drugInfoArray
=
json_decode
(
$drugInfoJson
,
true
);
// 检查解码是否成功且 $drugInfoArray 是一个数组
if
(
is_array
(
$drugInfoArray
))
{
// 使用 array_map 来格式化每个药物的信息
$formattedDrugs
=
array_map
(
function
(
$item
)
{
return
$item
[
'drug_name'
]
.
' : '
.
(
$item
[
'drug_spec'
]
??
''
)
.
' : '
.
$item
[
'drug_num'
];
},
$drugInfoArray
);
// 将数组转换为以逗号分隔的字符串(或根据您的需求进行其他格式化)
return
implode
(
', '
,
$formattedDrugs
);
}
else
{
// 如果解码失败或 $drugInfoJson 不是一个有效的 JSON 字符串,返回原始值或错误消息
return
$drugInfoJson
;
// 或者返回一个错误消息,如 'Invalid JSON'
}
})
->
label
();
// 设置列的标签
$grid
->
column
(
'pharmacist_name'
);
$grid
->
column
(
'review_at'
);
$grid
->
column
(
'pharmacist_attr'
);
...
...
@@ -62,6 +70,7 @@ protected function grid()
$filter
->
expand
();
// 默认展开搜索框
$filter
->
equal
(
'external_prescription_id'
,
'580处方单编号'
)
->
width
(
3
);
$filter
->
equal
(
'pharmacy_id'
)
->
select
(
PharmacyModel
::
all
()
->
pluck
(
'name'
,
'id'
))
->
width
(
3
);
$filter
->
equal
(
'pharmacy_id'
,
'药店编号'
)
->
width
(
3
);
});
// 行按钮控制
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment