TestController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <?php
  2. namespace App\Admin\Controllers;
  3. use App\Http\Controllers\Controller;
  4. use App\Model\Test;
  5. use Encore\Admin\Show;
  6. use Encore\Admin\Form;
  7. use Encore\Admin\Grid;
  8. use Encore\Admin\Facades\Admin;
  9. use App\Model\ZhSickNess;
  10. use Encore\Admin\Layout\Content;
  11. use Encore\Admin\Controllers\ModelForm;
  12. use Illuminate\Support\Facades\Request;
  13. class TestController extends Controller
  14. {
  15. use ModelForm;
  16. public function index()
  17. {
  18. $lable = request('label') ?? 'ZhSickNess';
  19. return Admin::content(function (Content $content) {
  20. $content->header('中医知识库');
  21. $content->description('列表');
  22. $content->body($this->grid());
  23. });
  24. }
  25. public function create()
  26. {
  27. return Admin::content(function (Content $content) {
  28. $content->header('中医知识库');
  29. $content->description('新增');
  30. $content->body($this->form());
  31. });
  32. }
  33. public function edit($id)
  34. {
  35. return Admin::content(function (Content $content) use ($id) {
  36. $content->header('Test');
  37. $content->description();
  38. $content->body($this->form($id)->edit($id));
  39. });
  40. }
  41. protected function show($id)
  42. {
  43. $zyzsk = new Test();
  44. $show = new Show($zyzsk->findOrFail($id));
  45. $show->field('name' , '名称');
  46. $label = $zyzsk->getlabel($id);
  47. switch ($label) {
  48. case 'SickNess':
  49. $show->field('department' , '科室');
  50. $show->field('apparatus' , '器官');
  51. $show->field('tongueCondition' , '舌象');
  52. $show->field('symptom' , '症状');
  53. $show->field('therapeuticMethod' , '治法');
  54. $show->field('source' , '来源');
  55. $show->field('pulseCondition' , '脉象');
  56. $show->field('dietTherapy' , '食物治疗');
  57. $show->field('acupuncturePoints' , '穴位');
  58. break;
  59. case 'Thing':
  60. $show->field('composition' , '成分');
  61. break;
  62. case 'CnMedicinalCrop':
  63. $show->field('toxicity' , '毒性');
  64. $show->field('indications' , '适应症');
  65. $show->field('source' , '来源');
  66. //$show->field('pageRankScore');
  67. $show->field('pharmacology' , '药理');
  68. break;
  69. case 'CnPatentMedicine':
  70. $show->field('pageRankScore');
  71. break;
  72. case 'Constitution':
  73. $show->field('overallFeature' , '整体特征');
  74. $show->field('notEat' , '忌口');
  75. $show->field('tendency' , '流行病学');
  76. $show->field('exercise' , '锻炼');
  77. $show->field('dietTherapy' , '饮食疗法');
  78. $show->field('psychologicalFeature' , '心理特征');
  79. $show->field('commonPerformance' , '共同表现');
  80. $show->field('meridianHealth' , '经络健康');
  81. $show->field('medicineRegimen', '药方');
  82. break;
  83. case 'Prescription':
  84. $show->field('composition' , '成分');
  85. //$show->field('pageRankScore');
  86. break;
  87. case 'TonicDiet':
  88. $show->field('composition' , '成分');
  89. //$show->field('pageRankScore');
  90. break;
  91. }
  92. $show->field('dateModified' , '日期');
  93. return $show;
  94. }
  95. protected function form($id = '',$label)
  96. {
  97. echo $$label;die;
  98. $this->hidden('type')->value(3);
  99. if(isset($id)) {
  100. if(!$id){
  101. $url = Request::path();
  102. $arr = explode('/' , $url);
  103. $id = $arr[2];
  104. }
  105. $test = new test();
  106. $label = $test->getlabel($id);
  107. // 编辑
  108. switch ($label) {
  109. case 'SickNess':
  110. return Admin::form(Test::class, function (Form $form) {
  111. $form->display('id' , 'Id');
  112. $form->text('name' , '名称');
  113. $form->text('department' , '科室');
  114. $form->text('apparatus' , '器官');
  115. $form->text('tongueCondition' , '舌象');
  116. $form->text('symptom' , '症状');
  117. $form->text('therapeuticMethod' , '治法');
  118. $form->text('source' , '来源');
  119. $form->text('pulseCondition' , '脉象');
  120. $form->text('dietTherapy' , '食物治疗');
  121. $form->text('acupuncturePoints' , '穴位');
  122. $form->text('pageRankScore');
  123. });
  124. break;
  125. case 'Thing';
  126. return Admin::form(Test::class, function (Form $form) {
  127. $form->text('name');
  128. $form->text('composition');
  129. $form->text('pageRankScore');
  130. });
  131. break;
  132. case 'CnMedicinalCrop';
  133. return Admin::form(Test::class, function (Form $form) {
  134. $form->text('name');
  135. $form->text('toxicity');
  136. $form->text('indications');
  137. $form->text('source');
  138. $form->text('pageRankScore');
  139. $form->text('pharmacology');
  140. });
  141. break;
  142. case 'CnPatentMedicine';
  143. return Admin::form(Test::class, function (Form $form) {
  144. $form->text('name');
  145. $form->text('pageRankScore');
  146. });
  147. break;
  148. case 'Constitution';
  149. return Admin::form(Test::class, function (Form $form) {
  150. $form->text('name');
  151. $form->text('overallFeature');
  152. $form->text('notEat');
  153. $form->text('tendency');
  154. $form->text('exercise');
  155. $form->text('dietTherapy');
  156. $form->text('pageRankScore');
  157. $form->text('psychologicalFeature');
  158. $form->text('commonPerformance');
  159. $form->text('meridianHealth');
  160. $form->text('medicineRegimen');
  161. });
  162. break;
  163. case 'Prescription';
  164. return Admin::form(Test::class, function (Form $form) {
  165. $form->text('name');
  166. $form->text('composition');
  167. $form->text('pageRankScore');
  168. });
  169. break;
  170. case 'TonicDiet';
  171. return Admin::form(Test::class, function (Form $form) {
  172. $form->text('name');
  173. $form->text('composition');
  174. $form->text('pageRankScore');
  175. });
  176. break;
  177. case 'ChannelCollateral':
  178. return Admin::form(Test::class, function (Form $form) {
  179. $form->text('name' , '名称');
  180. $form->text('indications' , '主治');
  181. $form->text('channelSymptom' , '经脉循行及其病候');
  182. $form->text('collateralSymptom' , '络脉循行及其病候');
  183. $form->text('divergentMeridian' , '经别循行');
  184. $form->text('aponeuroticSystem' , '经筋循行及其病候');
  185. $form->text('clinicalFeature' , '经络症状主要临床表现');
  186. $form->text('mechanismAnalysis' , '经络病机分析');
  187. $form->text('source' , '数据来源');
  188. });
  189. break;
  190. }
  191. } else {
  192. // 创建
  193. return Admin::form(Test::class, function (Form $form) {
  194. $form->text('name');
  195. });
  196. }
  197. }
  198. // Grid
  199. protected function grid()
  200. {
  201. $lable = request('label') ?? 'SickNess';
  202. switch ($lable){
  203. case 'SickNess';
  204. $aa = ZhSickNess::class;
  205. break;
  206. }
  207. return Admin::grid($aa, function (Grid $grid) use($lable) {
  208. //return Admin::grid(Test::class, function (Grid $grid) {
  209. //$label = request('label') ?? 'SickNess';
  210. //$grid->id('Id')->setAttributes(['style' => 'font-family:PMingLiU;']);
  211. $grid->name('名称')->setAttributes(['style' => 'font-family:PMingLiU;']);
  212. switch ($lable) {
  213. case 'TonicDiet':
  214. $grid->composition('成分')->setAttributes(['style' => 'font-family:PMingLiU;']);
  215. break;
  216. case 'SickNess':
  217. $grid->department('所属科室')->setAttributes(['style' => 'font-family:PMingLiU;']);
  218. $grid->apparatus('器官')->setAttributes(['style' => 'font-family:PMingLiU;']);
  219. $grid->tongueCondition('舌象')->setAttributes(['style' => 'font-family:PMingLiU;']);
  220. $grid->symptom('症状')->setAttributes(['style' => 'font-family:PMingLiU;']);
  221. $grid->therapeuticMethod('治法')->setAttributes(['style' => 'font-family:PMingLiU;']);
  222. $grid->source('来源')->setAttributes(['style' => 'font-family:PMingLiU;']);
  223. $grid->pulseCondition('脉象')->setAttributes(['style' => 'font-family:PMingLiU;']);
  224. $grid->dietTherapy('食物治疗')->setAttributes(['style' => 'font-family:PMingLiU;']);
  225. $grid->acupuncturePoints('穴位')->setAttributes(['style' => 'font-family:PMingLiU;']);
  226. //$grid->pageRankScore()->setAttributes(['style' => 'font-family:PMingLiU;']);
  227. break;
  228. case 'CnMedicinalCrop':
  229. $grid->toxicity('毒性')->setAttributes(['style' => 'font-family:PMingLiU;']);
  230. $grid->indications('适应症')->setAttributes(['style' => 'font-family:PMingLiU;']);
  231. $grid->source('来源')->setAttributes(['style' => 'font-family:PMingLiU;']);
  232. $grid->pageRankScore()->setAttributes(['style' => 'font-family:PMingLiU;']);
  233. $grid->pharmacology('药理')->setAttributes(['style' => 'font-family:PMingLiU;']);
  234. break;
  235. case 'CnPatentMedicine':
  236. break;
  237. case 'Thing':
  238. $grid->composition('成分')->setAttributes(['style' => 'font-family:PMingLiU;']);
  239. break;
  240. case 'Constitution':
  241. $grid->overallFeature('整体特征')->setAttributes(['style' => 'font-family:PMingLiU;']);
  242. $grid->notEat('忌口')->setAttributes(['style' => 'font-family:PMingLiU;']);
  243. $grid->tendency('流行病学')->setAttributes(['style' => 'font-family:PMingLiU;']);
  244. $grid->exercise('锻炼')->setAttributes(['style' => 'font-family:PMingLiU;']);
  245. $grid->dietTherapy('饮食疗法')->setAttributes(['style' => 'font-family:PMingLiU;']);
  246. $grid->psychologicalFeature('心理特征')->setAttributes(['style' => 'font-family:PMingLiU;']);
  247. $grid->commonPerformance('共同表现')->setAttributes(['style' => 'font-family:PMingLiU;']);
  248. $grid->meridianHealth('经络健康')->setAttributes(['style' => 'font-family:PMingLiU;']);
  249. $grid->medicineRegimen('药方')->setAttributes(['style' => 'font-family:PMingLiU;']);
  250. break;
  251. case 'Prescription':
  252. $grid->composition('成分')->setAttributes(['style' => 'font-family:PMingLiU;']);
  253. break;
  254. case 'ChannelCollateral':
  255. $grid->indications('主治');
  256. $grid->channelSymptom('经脉循行及其病候');
  257. $grid->collateralSymptom('络脉循行及其病候');
  258. $grid->divergentMeridian('经别循行');
  259. $grid->aponeuroticSystem('经筋循行及其病候');
  260. $grid->clinicalFeature('经络症状主要临床表现');
  261. $grid->mechanismAnalysis('经络病机分析');
  262. $grid->source('数据来源');
  263. break;
  264. }
  265. $grid->dateModified('日期')->setAttributes(['style' => 'font-family:PMingLiU;']);
  266. //$grid->classification();
  267. $grid->paginate(20);
  268. // 禁用导出数据按钮
  269. $grid->actions(function ($actions) {
  270. // $actions->disableView();
  271. // $actions->disableEdit();
  272. $actions->disableDelete();
  273. //$actions->add(new Update());
  274. //dd($actions->row);
  275. });
  276. $grid->disableCreateButton();
  277. //$grid->disableCreateButton();
  278. $grid->disableExport();
  279. $grid->filter(function ($filter) {
  280. $filter->disableIdFilter();
  281. $filter->like('name' , '输入搜索名称');
  282. });
  283. });
  284. }
  285. }