AddGroupAdvice.vue 64KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777
  1. <template>
  2. <div id="user-edit-group-advice">
  3. <el-dialog
  4. title="新增医嘱"
  5. :visible.sync="groupAddFormVisible"
  6. width="700px"
  7. >
  8. <el-form
  9. ref="groupForm"
  10. :rules="groupRules"
  11. :model="groupForm"
  12. label-width="90px"
  13. >
  14. <el-row>
  15. <el-col :span="12">
  16. <el-form-item label="医嘱类型 :" required prop="advice_type">
  17. <el-input value="临时" disabled></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="12">
  21. <el-form-item
  22. label="开始时间 :"
  23. required
  24. prop="start_time"
  25. style="width:100%;"
  26. >
  27. <el-date-picker
  28. type="datetime"
  29. format="yyyy-MM-dd HH:mm"
  30. value-format="yyyy-MM-dd HH:mm"
  31. placeholder="选择时间"
  32. v-model="groupForm.start_time"
  33. style="width:100%;"
  34. ></el-date-picker>
  35. </el-form-item>
  36. </el-col>
  37. </el-row>
  38. <el-form-item label="备注 :">
  39. <el-input type="textarea" v-model="groupForm.remark"></el-input>
  40. </el-form-item>
  41. <el-row>
  42. <el-col :span="12">
  43. <el-form-item label="开嘱医生 :">
  44. <span>{{ adminusername }} </span>
  45. </el-form-item>
  46. </el-col>
  47. <el-col :span="12">
  48. <el-form-item label="开嘱时间 :">
  49. <span>{{ groupForm.advice_date }} </span>
  50. </el-form-item>
  51. </el-col>
  52. </el-row>
  53. <el-row>
  54. <el-col :span="2">
  55. &nbsp;&nbsp;
  56. </el-col>
  57. <el-col :span="5">
  58. <el-button
  59. :disabled="
  60. $store.getters.xt_user.subscibe.state == 3 ? true : false
  61. "
  62. round
  63. @click="openAdviceTemplate()"
  64. >选择医嘱模板
  65. </el-button>
  66. </el-col>
  67. <el-col :span="5">
  68. <el-button
  69. :disabled="
  70. $store.getters.xt_user.subscibe.state == 3 ? true : false
  71. "
  72. round
  73. @click="openGroupAdvice(0)"
  74. >新增医嘱内容
  75. </el-button>
  76. </el-col>
  77. <el-col :span="5">
  78. <el-button
  79. :disabled="
  80. $store.getters.xt_user.subscibe.state == 3 ? true : false
  81. "
  82. round
  83. @click="openGroupAdvice(1)"
  84. >修改医嘱内容
  85. </el-button>
  86. </el-col>
  87. <el-col :span="5">
  88. <el-button
  89. :disabled="
  90. $store.getters.xt_user.subscibe.state == 3 ? true : false
  91. "
  92. round
  93. @click="openDeleteGroupAdvice()"
  94. >删除医嘱内容
  95. </el-button>
  96. </el-col>
  97. </el-row>
  98. <el-row>
  99. <el-col :span="24">
  100. <el-table
  101. id="user-edit-advice-name-table"
  102. :data="groupForm.adviceNames"
  103. border
  104. fit
  105. highlight-current-row
  106. :row-class-name="groupClassName"
  107. @current-change="selectGroupAdvice"
  108. style="width: 100%;margin-top: 10px;margin-bottom: 10px;"
  109. :row-key="getRowKey"
  110. ref="advicenametable"
  111. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  112. >
  113. <el-table-column
  114. label="医嘱名称"
  115. property="advice_name"
  116. style="word-break: keep-all;white-space:nowrap;"
  117. align="center"
  118. ></el-table-column>
  119. <el-table-column label="药品规格" align="center">
  120. <template slot-scope="scope">
  121. <span v-if="scope.row.advice_desc"
  122. >{{ scope.row.advice_desc
  123. }}{{ scope.row.drug_spec_unit }}</span
  124. >
  125. </template>
  126. </el-table-column>
  127. <!-- <el-table-column label="药品规格*数量" min-width="80" property="drug_spec" align="center">
  128. <template slot-scope="scope">
  129. <span
  130. v-if="scope.row.drug_spec!=0"
  131. >{{scope.row.drug_spec}}{{scope.row.drug_spec_unit}}</span>
  132. <span
  133. vf-i="scope.row.prescribing_number!=0"
  134. >*{{scope.row.prescribing_number}}{{scope.row.prescribing_number_unit}}</span>
  135. </template>
  136. </el-table-column> -->
  137. <el-table-column
  138. label="开药数量"
  139. min-width="80"
  140. property="prescribing_number"
  141. align="center"
  142. >
  143. <template slot-scope="scope">
  144. <span v-if="scope.row.prescribing_number != 0"
  145. >{{ scope.row.prescribing_number
  146. }}{{ scope.row.prescribing_number_unit }}</span
  147. >
  148. </template>
  149. </el-table-column>
  150. <el-table-column
  151. label="单次用量"
  152. min-width="80"
  153. property="single_dose"
  154. align="center"
  155. >
  156. <template slot-scope="scope">
  157. <span v-if="scope.row.single_dose != 0"
  158. >{{ scope.row.single_dose
  159. }}{{ scope.row.single_dose_unit }}</span
  160. >
  161. </template>
  162. </el-table-column>
  163. <el-table-column
  164. label="给药途径"
  165. min-width="80"
  166. property="delivery_way"
  167. align="center"
  168. >
  169. <template slot-scope="scope">
  170. <span v-if="scope.row.parent_row == 0">{{
  171. scope.row.delivery_way
  172. }}</span>
  173. </template>
  174. </el-table-column>
  175. <el-table-column
  176. label="执行频率"
  177. min-width="80"
  178. property="execution_frequency"
  179. align="center"
  180. >
  181. <template slot-scope="scope">
  182. <span v-if="scope.row.parent_row == 0">{{scope.row.execution_frequency}}</span>
  183. </template>
  184. </el-table-column>
  185. <!--<el-table-column label="医嘱嘱托" min-width="80" property="remark" align="center">-->
  186. <!--<template slot-scope="scope">-->
  187. <!--<span v-if="scope.row.parent_row==0">{{scope.row.remark}}</span>-->
  188. <!--</template>-->
  189. <!--</el-table-column>-->
  190. </el-table>
  191. </el-col>
  192. </el-row>
  193. </el-form>
  194. <div slot="footer" class="dialog-footer">
  195. <el-button
  196. :disabled="
  197. $store.getters.xt_user.subscibe.state == 3 ||
  198. groupForm.adviceNames.length == 0
  199. ? true
  200. : false
  201. "
  202. type="primary"
  203. @click="submitgroupAdvice('groupForm')"
  204. >保 存
  205. </el-button>
  206. </div>
  207. </el-dialog>
  208. <el-dialog
  209. title="选择医嘱模板"
  210. :close-on-click-modal="false"
  211. :visible.sync="templateFormVisible"
  212. width="72%"
  213. >
  214. <el-row :gutter="20">
  215. <el-col :span="8">
  216. <el-table
  217. :data="adviceTemplates"
  218. ref="templatetable"
  219. border
  220. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  221. highlight-current-row
  222. @current-change="templateTableChange"
  223. style="width: 100%"
  224. >
  225. <el-table-column prop="name" align="center" label="模板名称">
  226. </el-table-column>
  227. </el-table>
  228. </el-col>
  229. <el-col :span="16">
  230. <el-table
  231. id="dialysis-add-select-template-table"
  232. :data="selectedTemp.list"
  233. border
  234. :span-method="spanselecttable"
  235. @select="selectAdvice"
  236. @select-all="selectAllTemplateAdvice"
  237. @selection-change="changeAdvice"
  238. row-key="row_key"
  239. ref="selecttemplatetable"
  240. style="width: 100%"
  241. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  242. >
  243. <el-table-column type="selection" align="center" width="55">
  244. </el-table-column>
  245. <el-table-column
  246. label="医嘱内容"
  247. property="advice_name"
  248. style="word-break: keep-all;white-space:nowrap;"
  249. align="center"
  250. ></el-table-column>
  251. <el-table-column label="药品规格" align="center">
  252. <template slot-scope="scope">
  253. <span v-if="scope.row.advice_desc">{{ scope.row.advice_desc}}{{ scope.row.drug_spec_unit }}</span>
  254. </template>
  255. </el-table-column>
  256. <el-table-column
  257. label="开药数量"
  258. min-width="80"
  259. property="prescribing_number"
  260. align="center"
  261. >
  262. <template slot-scope="scope">
  263. <span v-if="scope.row.prescribing_number != 0">{{ scope.row.prescribing_number}}{{ scope.row.prescribing_number_unit }}</span>
  264. </template>
  265. </el-table-column>
  266. <el-table-column
  267. label="单次用量"
  268. min-width="80"
  269. property="single_dose"
  270. align="center"
  271. >
  272. <template slot-scope="scope">
  273. <span v-if="scope.row.single_dose != 0">{{ scope.row.single_dose}}{{ scope.row.single_dose_unit }}</span>
  274. </template>
  275. </el-table-column>
  276. <el-table-column
  277. label="给药途径"
  278. min-width="80"
  279. property="delivery_way"
  280. align="center"
  281. >
  282. <template slot-scope="scope">
  283. <span v-if="scope.row.parent_row == 0">{{scope.row.delivery_way}}</span>
  284. </template>
  285. </el-table-column>
  286. <el-table-column
  287. label="执行频率"
  288. min-width="80"
  289. property="execution_frequency"
  290. align="center"
  291. >
  292. <template slot-scope="scope">
  293. <span v-if="scope.row.parent_row == 0">{{
  294. scope.row.execution_frequency
  295. }}</span>
  296. </template>
  297. </el-table-column>
  298. </el-table>
  299. </el-col>
  300. </el-row>
  301. <div slot="footer" class="dialog-footer">
  302. <el-button @click="cancleDialog()">取消</el-button>
  303. <el-button
  304. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  305. type="primary"
  306. @click="newAddTempForm()"
  307. >保 存
  308. </el-button>
  309. </div>
  310. </el-dialog>
  311. <el-dialog
  312. title="选择医嘱模板"
  313. :visible.sync="oldTemplateFormVisible"
  314. width="700px"
  315. >
  316. <el-form ref="templateForm" :rules="templateRules" :model="templateForm">
  317. <el-row>
  318. <el-col :span="24">
  319. <el-form-item prop="id">
  320. <el-select
  321. v-model="templateForm.id"
  322. filterable
  323. clearable
  324. placeholder="请选择(输入可搜索)"
  325. style="width:100%"
  326. >
  327. <el-option
  328. v-for="item in adviceTemplates"
  329. :key="item.id"
  330. :label="item.name"
  331. :value="item.id"
  332. ></el-option>
  333. </el-select>
  334. </el-form-item>
  335. </el-col>
  336. </el-row>
  337. </el-form>
  338. <div slot="footer" class="dialog-footer">
  339. <el-button @click="templateFormVisible = false">取消</el-button>
  340. <el-button
  341. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  342. type="primary"
  343. @click="addTempForm('templateForm')"
  344. >保 存
  345. </el-button>
  346. </div>
  347. </el-dialog>
  348. <el-dialog
  349. :title="nameFormTitle"
  350. :visible.sync="nameFormVisible"
  351. width="854px"
  352. >
  353. <el-form
  354. ref="nameForm"
  355. :rules="nameRules"
  356. :model="nameForm"
  357. label-width="90px"
  358. >
  359. <el-row>
  360. <el-col :span="24">
  361. <el-form-item label="医嘱内容 :" required prop="advice_name">
  362. <el-autocomplete
  363. style="width:100%;"
  364. class="inline-input"
  365. v-model="nameForm.advice_name"
  366. :fetch-suggestions="querySearch"
  367. placeholder="请输入内容"
  368. @select="handleSelect"
  369. @input="changeDrugName"
  370. ></el-autocomplete>
  371. </el-form-item>
  372. <!-- <div style="margin-left:120px;margin-top:-20px;font-size:12px;color:red">
  373. 库存不足50
  374. </div> -->
  375. </el-col>
  376. </el-row>
  377. <el-row>
  378. <el-col :span="12">
  379. <el-form-item label="药品规格 :" prop="advice_desc">
  380. <el-col :span="8">
  381. <el-autocomplete
  382. style="width:100px;"
  383. class="inline-input"
  384. v-model="nameForm.advice_desc"
  385. :fetch-suggestions="querySearch1"
  386. placeholder="请输入内容"
  387. @select="handleSelect1"
  388. @input="changeDrugDesc"
  389. ></el-autocomplete>
  390. </el-col>
  391. <el-col class="line" :span="2">&nbsp;</el-col>
  392. <el-col :span="14">
  393. <el-select
  394. v-model="nameForm.drug_spec_unit"
  395. filterable
  396. clearable
  397. allow-create
  398. placeholder="选择"
  399. >
  400. <el-option
  401. v-for="item in unitsOption"
  402. :key="item.id"
  403. :label="item.name"
  404. :value="item.name"
  405. ></el-option>
  406. </el-select>
  407. </el-col>
  408. </el-form-item>
  409. </el-col>
  410. <el-col :span="12">
  411. <el-form-item label="开药数量 :" prop="prescribing_number">
  412. <el-col :span="8">
  413. <el-input v-model="nameForm.prescribing_number"></el-input>
  414. </el-col>
  415. <el-col class="line" :span="2">&nbsp;</el-col>
  416. <el-col :span="14">
  417. <el-select
  418. v-model="nameForm.prescribing_number_unit"
  419. filterable
  420. clearable
  421. allow-create
  422. placeholder="选择"
  423. >
  424. <el-option
  425. v-for="item in unitsOption"
  426. :key="item.id"
  427. :label="item.name"
  428. :value="item.name"
  429. ></el-option>
  430. </el-select>
  431. </el-col>
  432. </el-form-item>
  433. </el-col>
  434. <el-col :span="12">
  435. <el-form-item label="单次用量 :" prop="single_dose">
  436. <el-col :span="8">
  437. <el-input v-model="nameForm.single_dose"></el-input>
  438. </el-col>
  439. <el-col class="line" :span="2">&nbsp;</el-col>
  440. <el-col :span="14">
  441. <el-select
  442. v-model="nameForm.single_dose_unit"
  443. filterable
  444. clearable
  445. allow-create
  446. placeholder="选择"
  447. >
  448. <el-option
  449. v-for="item in unitsOption"
  450. :key="item.id"
  451. :label="item.name"
  452. :value="item.name"
  453. ></el-option>
  454. </el-select>
  455. </el-col>
  456. </el-form-item>
  457. </el-col>
  458. <el-col :span="12">
  459. <el-form-item label="给药途径 :" prop="delivery_way">
  460. <el-select
  461. v-model="nameForm.delivery_way"
  462. filterable
  463. clearable
  464. allow-create
  465. :disabled="isChild"
  466. placeholder="请选择(输入可搜索)"
  467. style="width:100%"
  468. >
  469. <el-option
  470. v-for="item in deliveryWayOptions"
  471. :key="item.id"
  472. :label="item.name"
  473. :value="item.name"
  474. ></el-option>
  475. </el-select>
  476. </el-form-item>
  477. </el-col>
  478. </el-row>
  479. <el-row>
  480. <el-col :span="12">
  481. <el-form-item label="执行频率 :" prop="execution_frequency">
  482. <el-select
  483. v-model="nameForm.execution_frequency"
  484. filterable
  485. clearable
  486. allow-create
  487. :disabled="isChild"
  488. placeholder="请选择(输入可搜索)"
  489. style="width:100%"
  490. >
  491. <el-option
  492. v-for="item in executionFrequencyOptions"
  493. :key="item.id"
  494. :label="item.name"
  495. :value="item.name"
  496. ></el-option>
  497. </el-select>
  498. </el-form-item>
  499. </el-col>
  500. </el-row>
  501. <!--<el-row>-->
  502. <!--<el-col :span="12">-->
  503. <!--<el-form-item label="医嘱嘱托 :" prop="delivery_way">-->
  504. <!--<el-input v-model="nameForm.remark"></el-input>-->
  505. <!--</el-form-item>-->
  506. <!--</el-col>-->
  507. <!--</el-row>-->
  508. </el-form>
  509. <div slot="footer" class="dialog-footer">
  510. <el-button @click="nameFormVisible = false">取消</el-button>
  511. <el-button
  512. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  513. type="primary"
  514. @click="submitNameForm('nameForm')"
  515. >保 存
  516. </el-button>
  517. </div>
  518. </el-dialog>
  519. </div>
  520. </template>
  521. <script>
  522. import {
  523. CreateDoctorAdvice,
  524. CreateGroupAdvice,
  525. DeleteDoctorAdvice,
  526. DeleteGroupAdvice,
  527. EditDoctorAdvice,
  528. getAdviceConfig,
  529. getDoctorAdviceList,
  530. StopDoctorAdvice
  531. } from "@/api/advice";
  532. import {getSelfMedicalList,getDrugDescByDrugName } from "@/api/drug/drug"
  533. import { duration } from 'moment';
  534. export default {
  535. name: "AddGroupAdvice",
  536. data() {
  537. return {
  538. editRowKey: 0,
  539. oldTemplateFormVisible: false,
  540. templateFormVisible: false,
  541. groupAddFormVisible: false,
  542. nameFormVisible: false,
  543. groupSelectRow: null,
  544. nameFormTitle: "",
  545. isChild: false,
  546. isEdit: false,
  547. adminusername: "",
  548. groupRules: {
  549. advice_type: [{ required: true, message: "请选择医嘱类型" }],
  550. advice_date: [{ required: true, message: "请选择医嘱时间" }],
  551. start_time: [{ required: true, message: "请选择开始时间" }],
  552. advice_name: [{ required: true, message: "请填写医嘱名称" }],
  553. advice_doctor: [{ required: true, message: "请选择开嘱医生" }]
  554. },
  555. nameRules: {
  556. advice_name: [{ required: true, message: "请填写医嘱内容" }]
  557. },
  558. templateRules: {
  559. id: [{ required: true, message: "请选择医嘱模板" }]
  560. },
  561. templateForm: { id: "" },
  562. nameForm: {
  563. advice_name: "",
  564. advice_desc: "",
  565. single_dose: "",
  566. single_dose_unit: "",
  567. drug_spec: "",
  568. drug_spec_unit: "",
  569. prescribing_number: "",
  570. prescribing_number_unit: "",
  571. delivery_way: "",
  572. execution_frequency: "",
  573. remark: "",
  574. isEdit: 0,
  575. index: 0,
  576. id: 0,
  577. children: [],
  578. drug_id:0,
  579. way:0,
  580. drug_name_id:0,
  581. },
  582. submitGroupForm: {
  583. advice_type: "",
  584. advice_date: "",
  585. start_time: "",
  586. adviceNames: [],
  587. advice_doctor: "",
  588. remark: "",
  589. parent_id: 0
  590. },
  591. groupForm: {
  592. advice_type: "",
  593. advice_date: "",
  594. start_time: "",
  595. adviceNames: [],
  596. advice_doctor: "",
  597. remark: "",
  598. parent_id: 0,
  599. drug_id:"",
  600. way:"",
  601. drug_name_id:0,
  602. },
  603. selectedTemp: { id: 0, name: "", org_id: 0, list: [], rows: [] },
  604. selectedTemplate: [],
  605. allSelectedTemplate: [],
  606. medicals:[],
  607. drugSpec:[],
  608. all_drug:[],
  609. current_drug_name:"",
  610. current_drug_spec: "",
  611. drug_id: 0,
  612. drug_name_id:"",
  613. src_type:"",
  614. private_drug_config:{},
  615. };
  616. },
  617. props: {
  618. patientID: 0,
  619. adviceType: 0,
  620. rowKey: 0,
  621. adviceTemplates: {
  622. type: Array,
  623. default: function() {
  624. return [];
  625. }
  626. },
  627. recordDate: "",
  628. adviceTypeOptions: {
  629. type: Array,
  630. default: function() {
  631. return [];
  632. }
  633. },
  634. deliveryWayOptions: {
  635. type: Array,
  636. default: () => []
  637. },
  638. unitsOption: {
  639. type: Array,
  640. default: function() {
  641. return [];
  642. }
  643. },
  644. executionFrequencyOptions: {
  645. type: Array,
  646. default: function() {
  647. return [];
  648. }
  649. },
  650. adviceTemplateMaps: {
  651. type: Object,
  652. default: function() {
  653. return {};
  654. }
  655. },
  656. adviceTableData: {
  657. type: Array,
  658. default: function() {
  659. return [];
  660. }
  661. },
  662. predialysis: {
  663. type: Object,
  664. default: () => {
  665. return { id: 0 }
  666. }
  667. },
  668. },
  669. methods: {
  670. submitgroupAdvice(formName) {
  671. this.$refs[formName].validate(valid => {
  672. if (valid) {
  673. var submitForm = {
  674. advice_type: this.groupForm.advice_type,
  675. advice_date: this.groupForm.advice_date,
  676. start_time: this.groupForm.start_time,
  677. adviceNames: [],
  678. advice_doctor: this.groupForm.advice_doctor,
  679. remark: this.groupForm.remark,
  680. parent_id: this.groupForm.parent_id,
  681. id:this.groupForm.id,
  682. };
  683. console.log("hhhhh",this.drug_id,this.nameForm.way)
  684. var adviceNames = [];
  685. for (const index in this.groupForm.adviceNames) {
  686. adviceNames.unshift(this.groupForm.adviceNames[index]);
  687. }
  688. for(let i=0;i<adviceNames.length;i++){
  689. adviceNames[i].template_id = "888888888"
  690. }
  691. submitForm.adviceNames = adviceNames;
  692. let mode = "1";
  693. console.log("88888888",submitForm)
  694. console.log("99999",this.medicals)
  695. if(this.private_drug_config != null&& this.private_drug_config.drug_start == 1){
  696. for(let index=0;index<submitForm.adviceNames.length;index++){
  697. for(let i=0;i<this.medicals.length;i++){
  698. if(submitForm.adviceNames[index].children.length >0){
  699. for(let y=0;y<submitForm.adviceNames[index].children.length;y++){
  700. if(submitForm.adviceNames[index].children[y].drug_id == this.medicals[i].drug_name_id){
  701. submitForm.adviceNames[index].children[y].drug_name_id = this.medicals[i].drug_name_id
  702. submitForm.adviceNames[index].children[y].way = 2
  703. }
  704. }
  705. }
  706. if(submitForm.adviceNames[index].children.length == 0){
  707. if(submitForm.adviceNames[index].drug_id == this.medicals[i].drug_name_id){
  708. console.log("进来了没有")
  709. submitForm.adviceNames[index].way = 2
  710. submitForm.adviceNames[index].drug_name_id = this.medicals[i].drug_name_id
  711. }
  712. }
  713. }
  714. }
  715. }
  716. console.log("2222",submitForm)
  717. CreateGroupAdvice(this.patientID, 0, submitForm, mode).then(
  718. response => {
  719. if (response.data.state == 0) {
  720. this.$message.error(response.data.msg);
  721. return false;
  722. } else {
  723. this.$notify({
  724. title: "成功",
  725. message: "新增成功",
  726. type: "success",
  727. duration: 2000
  728. });
  729. var childMap = {};
  730. for (const index in response.data.data.advices) {
  731. if (response.data.data.advices[index].parent_id == 0) {
  732. continue;
  733. }
  734. if (
  735. response.data.data.advices[index].parent_id in childMap ===
  736. false
  737. ) {
  738. childMap[response.data.data.advices[index].parent_id] = [];
  739. }
  740. childMap[response.data.data.advices[index].parent_id].unshift(
  741. response.data.data.advices[index]
  742. );
  743. }
  744. var parentArr = [];
  745. for (const index in response.data.data.advices) {
  746. if (response.data.data.advices[index].parent_id > 0) {
  747. continue;
  748. }
  749. parentArr.push(response.data.data.advices[index]);
  750. }
  751. for (const index in parentArr) {
  752. if (parentArr[index].id in childMap) {
  753. for (const j in childMap[parentArr[index].id]) {
  754. this.adviceTableData.unshift(
  755. childMap[parentArr[index].id][j]
  756. );
  757. }
  758. }
  759. this.adviceTableData.unshift(parentArr[index]);
  760. }
  761. // var alen = response.data.data.advices.length
  762. // for (let index = alen-1; index >=0; index--) {
  763. // this.adviceTableData.unshift(response.data.data.advices[index]);
  764. // }
  765. this.resetForm(formName);
  766. this.groupAddFormVisible = false;
  767. this.$parent.getDialysisScheduleDetail()
  768. return false;
  769. }
  770. }
  771. );
  772. }
  773. });
  774. },
  775. openDeleteGroupAdvice() {
  776. if (this.groupSelectRow === null) {
  777. this.$message.error("未选择要删除的医嘱内容");
  778. return;
  779. }
  780. var content = "";
  781. if (this.groupSelectRow.children.length > 0) {
  782. content = "确认删除此医嘱内容,包括它的子药?";
  783. } else {
  784. content = "确认删除此医嘱内容?";
  785. }
  786. var isChild = !!this.groupSelectRow.parent_row;
  787. var title = isChild ? "删除子药内容" : "删除医嘱内容";
  788. var msg = isChild ? "确认删除此子药内容?" : content;
  789. this.$confirm(msg, title, {
  790. confirmButtonText: "确定",
  791. cancelButtonText: "取消",
  792. type: "warning"
  793. })
  794. .then(() => {
  795. if (isChild) {
  796. for (const index in this.groupForm.adviceNames) {
  797. if (
  798. this.groupForm.adviceNames[index].row_key ==
  799. this.groupSelectRow.parent_row
  800. ) {
  801. for (const j in this.groupForm.adviceNames[index].children) {
  802. if (
  803. this.groupForm.adviceNames[index].children[j].row_key ==
  804. this.groupSelectRow.row_key
  805. ) {
  806. this.groupForm.adviceNames[index].children.splice(j, 1);
  807. this.$set(
  808. this.groupForm.adviceNames,
  809. index,
  810. this.groupForm.adviceNames[index]
  811. );
  812. break;
  813. }
  814. }
  815. }
  816. }
  817. } else {
  818. for (const index in this.groupForm.adviceNames) {
  819. if (
  820. this.groupForm.adviceNames[index].row_key ==
  821. this.groupSelectRow.row_key
  822. ) {
  823. this.groupForm.adviceNames.splice(index, 1);
  824. break;
  825. }
  826. }
  827. }
  828. })
  829. .catch(() => {});
  830. },
  831. submitNameForm(formName) {
  832. if(this.src_type == ""){
  833. this.nameForm.way = 1
  834. this.nameForm.drug_id = this.drug_id
  835. this.nameForm.drug_name_id = 0
  836. }
  837. if(this.src_type == 2){ //自备药
  838. var arr = this.nameForm.advice_name.split("(自备药)")
  839. this.nameForm.advice_name = arr[0]
  840. }
  841. var _this = this;
  842. this.$refs[formName].validate(valid => {
  843. if (valid) {
  844. if (_this.nameForm.isEdit) {
  845. var ale = _this.groupForm.adviceNames.length;
  846. if (_this.isChild) {
  847. for (let index = 0; index < ale; index++) {
  848. if (_this.groupSelectRow.parent_row ==_this.groupForm.adviceNames[index].row_key) {
  849. var cle = _this.groupForm.adviceNames[index].children.length;
  850. var children = _this.groupForm.adviceNames[index].children;
  851. for (let j = 0; j < ale; j++) {
  852. if (_this.groupSelectRow.row_key == children[j].row_key) {
  853. _this.groupForm.adviceNames[index].children[j].advice_name = _this.nameForm.advice_name;
  854. _this.groupForm.adviceNames[index].children[j].advice_desc = _this.nameForm.advice_desc;
  855. _this.groupForm.adviceNames[index].children[j].single_dose = "" + _this.nameForm.single_dose;
  856. _this.groupForm.adviceNames[index].children[j].single_dose_unit = _this.nameForm.single_dose_unit;
  857. _this.groupForm.adviceNames[index].children[j].drug_spec = "" + _this.nameForm.drug_spec;
  858. _this.groupForm.adviceNames[index].children[j].drug_spec_unit = _this.nameForm.drug_spec_unit;
  859. _this.groupForm.adviceNames[index].children[j].prescribing_number ="" + _this.nameForm.prescribing_number;
  860. _this.groupForm.adviceNames[index].children[j].prescribing_number_unit = _this.nameForm.prescribing_number_unit;
  861. _this.groupForm.adviceNames[index].children[j].delivery_way = _this.nameForm.delivery_way;
  862. _this.groupForm.adviceNames[index].children[j].execution_frequency =_this.nameForm.execution_frequency;
  863. _this.groupForm.adviceNames[index].children[j].remark =_this.nameForm.remark;
  864. // _this.groupForm.adviceNames[index].children[j].drug_id = _this.nameForm.drug_id;
  865. // _this.groupForm.adviceNames[index].children[j].way = _this.nameForm.way;
  866. // _this.groupForm.adviceNames[index].children[j].drug_name_id = _this.nameForm.drug_name_id;
  867. _this.$set(_this.groupForm.adviceNames[index].children,j,_this.groupForm.adviceNames[index].children[j]
  868. );
  869. break;
  870. }
  871. }
  872. }
  873. }
  874. } else {
  875. for (let index = 0; index < ale; index++) {
  876. if ( _this.groupSelectRow.row_key ==_this.groupForm.adviceNames[index].row_key) {
  877. _this.groupForm.adviceNames[index].advice_name =_this.nameForm.advice_name;
  878. _this.groupForm.adviceNames[index].advice_desc =_this.nameForm.advice_desc;
  879. _this.groupForm.adviceNames[index].single_dose ="" + _this.nameForm.single_dose;
  880. _this.groupForm.adviceNames[index].single_dose_unit =_this.nameForm.single_dose_unit;
  881. _this.groupForm.adviceNames[index].drug_spec = "" + _this.nameForm.drug_spec;
  882. _this.groupForm.adviceNames[index].drug_spec_unit =_this.nameForm.drug_spec_unit;
  883. _this.groupForm.adviceNames[index].prescribing_number ="" + _this.nameForm.prescribing_number;
  884. _this.groupForm.adviceNames[index].prescribing_number_unit =_this.nameForm.prescribing_number_unit;
  885. _this.groupForm.adviceNames[index].delivery_way =_this.nameForm.delivery_way;
  886. _this.groupForm.adviceNames[index].execution_frequency =_this.nameForm.execution_frequency;
  887. _this.groupForm.adviceNames[index].remark =_this.nameForm.remark;
  888. // _this.groupForm.adviceNames[index].children[j].drug_id = _this.nameForm.drug_id;
  889. // _this.groupForm.adviceNames[index].children[j].way = _this.nameForm.way;
  890. // _this.groupForm.adviceNames[index].children[j].drug_name_id = _this.nameForm.drug_name_id;
  891. _this.$set(
  892. _this.groupForm.adviceNames,
  893. index,
  894. _this.groupForm.adviceNames[index]
  895. );
  896. break;
  897. }
  898. }
  899. }
  900. } else {
  901. if (_this.isChild) {
  902. _this.editRowKey++;
  903. _this.nameForm.row_key = _this.editRowKey;
  904. var ale = _this.groupForm.adviceNames.length;
  905. for (let index = 0; index < ale; index++) {
  906. if (_this.nameForm.parent_row ==_this.groupForm.adviceNames[index].row_key) {
  907. _this.groupForm.adviceNames[index].children.push(_this.nameForm);
  908. _this.$set(_this.groupForm.adviceNames,index,_this.groupForm.adviceNames[index]);
  909. break;
  910. }
  911. }
  912. } else {
  913. _this.editRowKey++;
  914. _this.nameForm.row_key = _this.editRowKey;
  915. _this.groupForm.adviceNames.push(_this.nameForm);
  916. }
  917. }
  918. _this.nameFormVisible = false;
  919. }
  920. });
  921. },
  922. openGroupChild() {
  923. if (this.groupSelectRow === null) {
  924. this.$message.error("未选择医嘱内容,无法添加子药");
  925. return;
  926. } else if (this.groupSelectRow.parent_row > 0) {
  927. this.$notify.error({
  928. title: "错误",
  929. message: "子药不能添加子药"
  930. });
  931. return;
  932. }
  933. this.nameForm = {
  934. advice_name:"",
  935. advice_desc: "",
  936. single_dose: "",
  937. single_dose_unit: "",
  938. drug_spec: "",
  939. drug_spec_unit: "",
  940. prescribing_number: "",
  941. prescribing_number_unit: "",
  942. delivery_way: this.groupSelectRow.delivery_way,
  943. execution_frequency: this.groupSelectRow.execution_frequency,
  944. remark: "",
  945. isEdit: 0,
  946. index: 0,
  947. children: [],
  948. parent_row: this.groupSelectRow.row_key,
  949. id: 0
  950. };
  951. this.isChild = true;
  952. this.nameFormVisible = true;
  953. this.nameFormTitle = "添加子药内容";
  954. },
  955. openGroupAdvice(isEdit) {
  956. this.isChild = false;
  957. if (isEdit) {
  958. if (this.groupSelectRow === null) {
  959. this.$message.error("未选择要修改的医嘱内容");
  960. return;
  961. }
  962. if (this.groupSelectRow.parent_row) {
  963. this.isChild = true;
  964. }
  965. this.nameForm = {
  966. advice_name: this.groupSelectRow.advice_name,
  967. advice_desc: this.groupSelectRow.advice_desc,
  968. single_dose:
  969. this.groupSelectRow.single_dose != 0
  970. ? this.groupSelectRow.single_dose
  971. : "",
  972. single_dose_unit: this.groupSelectRow.single_dose_unit,
  973. drug_spec:
  974. this.groupSelectRow.drug_spec != 0
  975. ? this.groupSelectRow.drug_spec
  976. : "",
  977. drug_spec_unit: this.groupSelectRow.drug_spec_unit,
  978. prescribing_number:
  979. this.groupSelectRow.prescribing_number != 0
  980. ? this.groupSelectRow.prescribing_number
  981. : "",
  982. prescribing_number_unit: this.groupSelectRow.prescribing_number_unit,
  983. delivery_way: this.isChild ? "" : this.groupSelectRow.delivery_way,
  984. execution_frequency: this.isChild
  985. ? ""
  986. : this.groupSelectRow.execution_frequency,
  987. isEdit: 1,
  988. index: this.groupSelectRow.index,
  989. id: this.groupSelectRow.id,
  990. children: [],
  991. parent_row: this.groupSelectRow.parent_row,
  992. remark: this.groupSelectRow.remark,
  993. drug_name_id:this.groupSelectRow.drug_name_id,
  994. drug_id:this.groupSelectRow.drug_id,
  995. way:this.groupSelectRow.way
  996. // row_key:this.groupSelectRow.row_key,
  997. };
  998. this.nameFormTitle = "修改医嘱内容";
  999. } else {
  1000. this.nameForm = {
  1001. advice_name: "",
  1002. advice_desc: "",
  1003. single_dose: "",
  1004. single_dose_unit: "",
  1005. drug_spec: "",
  1006. drug_spec_unit: "",
  1007. prescribing_number: "",
  1008. prescribing_number_unit: "",
  1009. delivery_way: "",
  1010. execution_frequency: "",
  1011. isEdit: 0,
  1012. index: 0,
  1013. id: 0,
  1014. remark: "",
  1015. children: [],
  1016. parent_row: 0
  1017. };
  1018. this.nameFormTitle = "新增医嘱内容";
  1019. }
  1020. this.nameFormVisible = true;
  1021. },
  1022. changeAdvice(selection) {
  1023. this.selectedTemplate = selection;
  1024. },
  1025. selectAdvice(selection, row) {
  1026. console.log("row",row)
  1027. var adviceArray = this.adviceTemplateMaps[this.selectedTemp.id]
  1028. .DoctorAdviceTemplate;
  1029. console.log(adviceArray);
  1030. for (let y = 0; y < adviceArray.length; y++) {
  1031. adviceArray[y].selection = false;
  1032. }
  1033. if (selection.length > 0) {
  1034. for (let y = 0; y < adviceArray.length; y++) {
  1035. for (let i = 0; i < selection.length; i++) {
  1036. if (adviceArray[y].id == selection[i].advice_id) {
  1037. adviceArray[y].selection = true;
  1038. }
  1039. }
  1040. }
  1041. }
  1042. // console.log(adviceArray);
  1043. if (row.children.length > 0) {
  1044. for (const index in row.children) {
  1045. this.$refs.selecttemplatetable.toggleRowSelection(
  1046. row.children[index]
  1047. );
  1048. }
  1049. }
  1050. // 下面两步的作用是为了上选中的数据的输出顺序不变
  1051. for (const index in this.selectedTemp.list) {
  1052. this.$refs.selecttemplatetable.toggleRowSelection(
  1053. this.selectedTemp.list[index]
  1054. );
  1055. if (this.selectedTemp.list[index].children.length > 0) {
  1056. for (const j in this.selectedTemp.list[index].children) {
  1057. this.$refs.selecttemplatetable.toggleRowSelection(
  1058. this.selectedTemp.list[index].children[j]
  1059. );
  1060. }
  1061. }
  1062. }
  1063. for (const index in this.selectedTemp.list) {
  1064. this.$refs.selecttemplatetable.toggleRowSelection(
  1065. this.selectedTemp.list[index]
  1066. );
  1067. if (this.selectedTemp.list[index].children.length > 0) {
  1068. for (const j in this.selectedTemp.list[index].children) {
  1069. this.$refs.selecttemplatetable.toggleRowSelection(
  1070. this.selectedTemp.list[index].children[j]
  1071. );
  1072. }
  1073. }
  1074. }
  1075. },
  1076. spanselecttable({ row, column, rowIndex, columnIndex }) {
  1077. if (columnIndex == 0) {
  1078. const _row = this.selectedTemp.rows[rowIndex];
  1079. const _col = _row > 0 ? 1 : 0;
  1080. return {
  1081. rowspan: _row,
  1082. colspan: _col
  1083. };
  1084. }
  1085. },
  1086. calcselectedTemp() {
  1087. var rowKeys = 0;
  1088. for (const index in this.selectedTemp.list) {
  1089. var pkey = rowKeys;
  1090. this.selectedTemp.rows[rowKeys] = 1;
  1091. if (this.selectedTemp.list[index].children.length > 0) {
  1092. for (const childindex in this.selectedTemp.list[index].children) {
  1093. rowKeys++;
  1094. this.selectedTemp.rows[pkey] += 1;
  1095. this.selectedTemp.rows[rowKeys] = 0;
  1096. }
  1097. }
  1098. rowKeys++;
  1099. this.$nextTick(function() {
  1100. if (this.selectedTemp.list[index].selection) {
  1101. this.$refs.selecttemplatetable.toggleRowSelection(
  1102. this.selectedTemp.list[index]
  1103. );
  1104. }
  1105. });
  1106. }
  1107. },
  1108. templateTableChange(currentRow, oldCurrentRow) {
  1109. console.log("params -----",currentRow)
  1110. this.selectedTemp = { id: 0, name: "", org_id: 0, list: [], rows: [] };
  1111. if (currentRow == null) {
  1112. return false;
  1113. }
  1114. this.selectedTemp.id = currentRow.id;
  1115. this.selectedTemp.name = currentRow.name;
  1116. this.selectedTemp.org_id = currentRow.org_id;
  1117. if (this.selectedTemp.id in this.adviceTemplateMaps) {
  1118. var mapid = this.selectedTemp.id;
  1119. var thisRowKey = 0;
  1120. for (const index in this.adviceTemplateMaps[mapid].DoctorAdviceTemplate) {
  1121. thisRowKey++;
  1122. var item = {
  1123. advice_name: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].advice_name,
  1124. advice_desc: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].advice_desc,
  1125. single_dose:"" +this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].single_dose,
  1126. single_dose_unit: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].single_dose_unit,
  1127. drug_spec:"" +this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec,
  1128. drug_spec_unit: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec_unit,
  1129. prescribing_number:"" +this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].prescribing_number,
  1130. prescribing_number_unit: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].prescribing_number_unit,
  1131. delivery_way: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].delivery_way,
  1132. execution_frequency: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].execution_frequency,
  1133. selection: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].selection,
  1134. advice_id: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].id,
  1135. drug_id:this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_id,
  1136. way:this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].way,
  1137. drug_name_id:this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_name_id,
  1138. isEdit: 0,
  1139. id: 0,
  1140. children: [],
  1141. parent_row: 0,
  1142. row_key: thisRowKey
  1143. };
  1144. if (
  1145. "children" in
  1146. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index] &&
  1147. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].children
  1148. .length > 0
  1149. ) {
  1150. var parentRow = thisRowKey;
  1151. var children = this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1152. index
  1153. ].children;
  1154. for (const key in children) {
  1155. thisRowKey++;
  1156. var child = {
  1157. advice_id: children[key].id,
  1158. advice_name: children[key].advice_name,
  1159. advice_desc: children[key].advice_desc,
  1160. single_dose: "" + children[key].single_dose,
  1161. single_dose_unit: children[key].single_dose_unit,
  1162. drug_spec: "" + children[key].drug_spec,
  1163. drug_spec_unit: children[key].drug_spec_unit,
  1164. prescribing_number: "" + children[key].prescribing_number,
  1165. prescribing_number_unit: children[key].prescribing_number_unit,
  1166. delivery_way: children[key].delivery_way,
  1167. execution_frequency: children[key].execution_frequency,
  1168. drug_id:children[key].drug_id,
  1169. way:children[key].way,
  1170. drug_name_id:children[key].drug_name_id,
  1171. isEdit: 0,
  1172. id: 0,
  1173. children: [],
  1174. parent_row: parentRow,
  1175. row_key: thisRowKey,
  1176. };
  1177. item.children.push(child);
  1178. }
  1179. this.$set(item, "children", item.children);
  1180. }
  1181. this.selectedTemp.list.unshift(item);
  1182. }
  1183. }
  1184. },
  1185. newAddTempForm() {
  1186. this.allSelectedTemplate = [];
  1187. var thisRowKey = 0;
  1188. for (const indexs in this.adviceTemplateMaps) {
  1189. const adviceTemplate = this.adviceTemplateMaps[indexs];
  1190. for (const index in adviceTemplate.DoctorAdviceTemplate) {
  1191. if (adviceTemplate.DoctorAdviceTemplate[index].selection) {
  1192. thisRowKey++;
  1193. var item = {
  1194. advice_name:adviceTemplate.DoctorAdviceTemplate[index].advice_name,
  1195. advice_desc:adviceTemplate.DoctorAdviceTemplate[index].advice_desc,
  1196. single_dose:"" + adviceTemplate.DoctorAdviceTemplate[index].single_dose,
  1197. single_dose_unit:adviceTemplate.DoctorAdviceTemplate[index].single_dose_unit,
  1198. drug_spec:"" + adviceTemplate.DoctorAdviceTemplate[index].drug_spec,
  1199. drug_spec_unit:adviceTemplate.DoctorAdviceTemplate[index].drug_spec_unit,
  1200. prescribing_number:"" +adviceTemplate.DoctorAdviceTemplate[index].prescribing_number,
  1201. prescribing_number_unit:adviceTemplate.DoctorAdviceTemplate[index].prescribing_number_unit,
  1202. delivery_way:adviceTemplate.DoctorAdviceTemplate[index].delivery_way,
  1203. execution_frequency:adviceTemplate.DoctorAdviceTemplate[index].execution_frequency,
  1204. advice_id: adviceTemplate.DoctorAdviceTemplate[index].id,
  1205. selection: adviceTemplate.DoctorAdviceTemplate[index].selection,
  1206. drug_id: adviceTemplate.DoctorAdviceTemplate[index].drug_id,
  1207. way:adviceTemplate.DoctorAdviceTemplate[index].way,
  1208. drug_name_id:adviceTemplate.DoctorAdviceTemplate[index].drug_name_id,
  1209. isEdit: 0,
  1210. id: 0,
  1211. children: [],
  1212. parent_row: 0,
  1213. row_key: thisRowKey
  1214. };
  1215. console.log("items========",item)
  1216. if (
  1217. "children" in adviceTemplate.DoctorAdviceTemplate[index] &&
  1218. adviceTemplate.DoctorAdviceTemplate[index].children.length > 0
  1219. ) {
  1220. var parentRow = thisRowKey;
  1221. var children =
  1222. adviceTemplate.DoctorAdviceTemplate[index].children;
  1223. for (const key in children) {
  1224. thisRowKey++;
  1225. var child = {
  1226. advice_id: children[key].id,
  1227. advice_name: children[key].advice_name,
  1228. advice_desc: children[key].advice_desc,
  1229. single_dose: "" + children[key].single_dose,
  1230. single_dose_unit: children[key].single_dose_unit,
  1231. drug_spec: "" + children[key].drug_spec,
  1232. drug_spec_unit: children[key].drug_spec_unit,
  1233. prescribing_number: "" + children[key].prescribing_number,
  1234. prescribing_number_unit:children[key].prescribing_number_unit,
  1235. delivery_way: children[key].delivery_way,
  1236. execution_frequency: children[key].execution_frequency,
  1237. drug_id:children[key].drug_id,
  1238. way:children[key].way,
  1239. drug_name_id:children[key].drug_name_id,
  1240. isEdit: 0,
  1241. id: 0,
  1242. children: [],
  1243. parent_row: parentRow,
  1244. row_key: thisRowKey
  1245. };
  1246. item.children.push(child);
  1247. this.allSelectedTemplate.unshift(child);
  1248. }
  1249. this.$set(item, "children", item.children);
  1250. }
  1251. this.allSelectedTemplate.unshift(item);
  1252. adviceTemplate.DoctorAdviceTemplate[index].selection = false;
  1253. }
  1254. }
  1255. }
  1256. var childMap = {};
  1257. for (const index in this.allSelectedTemplate) {
  1258. if (this.allSelectedTemplate[index].parent_row > 0) {
  1259. if (!(this.allSelectedTemplate[index].parent_row in childMap)) {
  1260. childMap[this.allSelectedTemplate[index].parent_row] = [];
  1261. }
  1262. childMap[this.allSelectedTemplate[index].parent_row].push(
  1263. this.allSelectedTemplate[index]
  1264. );
  1265. }
  1266. }
  1267. for (const index in this.allSelectedTemplate) {
  1268. if (this.allSelectedTemplate[index].parent_row > 0) {
  1269. continue;
  1270. }
  1271. this.editRowKey++;
  1272. var item = {
  1273. advice_name: this.allSelectedTemplate[index].advice_name,
  1274. advice_desc: this.allSelectedTemplate[index].advice_desc,
  1275. single_dose: "" + this.allSelectedTemplate[index].single_dose,
  1276. single_dose_unit: this.allSelectedTemplate[index].single_dose_unit,
  1277. drug_spec: "" + this.allSelectedTemplate[index].drug_spec,
  1278. drug_spec_unit: this.allSelectedTemplate[index].drug_spec_unit,
  1279. prescribing_number:"" + this.allSelectedTemplate[index].prescribing_number,
  1280. prescribing_number_unit: this.allSelectedTemplate[index].prescribing_number_unit,
  1281. delivery_way: this.allSelectedTemplate[index].delivery_way,
  1282. execution_frequency: this.allSelectedTemplate[index].execution_frequency,
  1283. drug_id:this.allSelectedTemplate[index].drug_id,
  1284. way:this.allSelectedTemplate[index].way,
  1285. drug_name_id:this.allSelectedTemplate[index].drug_name_id,
  1286. isEdit: 0,
  1287. id: 0,
  1288. children: [],
  1289. parent_row: 0,
  1290. row_key: this.editRowKey
  1291. };
  1292. if (this.allSelectedTemplate[index].children.length > 0) {
  1293. if (this.allSelectedTemplate[index].row_key in childMap) {
  1294. var parentRow = this.editRowKey;
  1295. var children = childMap[this.allSelectedTemplate[index].row_key];
  1296. for (const key in children) {
  1297. this.editRowKey++;
  1298. var child = {
  1299. advice_name: children[key].advice_name,
  1300. advice_desc: children[key].advice_desc,
  1301. single_dose: "" + children[key].single_dose,
  1302. single_dose_unit: children[key].single_dose_unit,
  1303. drug_spec: "" + children[key].drug_spec,
  1304. drug_spec_unit: children[key].drug_spec_unit,
  1305. prescribing_number: "" + children[key].prescribing_number,
  1306. prescribing_number_unit: children[key].prescribing_number_unit,
  1307. delivery_way: children[key].delivery_way,
  1308. execution_frequency: children[key].execution_frequency,
  1309. drug_id:children[key].drug_id,
  1310. way:children[key].way,
  1311. drug_name_id:children[key].drug_name_id,
  1312. isEdit: 0,
  1313. id: 0,
  1314. children: [],
  1315. parent_row: parentRow,
  1316. row_key: this.editRowKey
  1317. };
  1318. item.children.push(child);
  1319. }
  1320. this.$set(item, "children", item.children);
  1321. }
  1322. }
  1323. console.log(this.groupForm.adviceNames)
  1324. this.groupForm.adviceNames.push(item);
  1325. }
  1326. this.templateFormVisible = false;
  1327. },
  1328. addTempForm(formName) {
  1329. var _this = this;
  1330. this.$refs[formName].validate(valid => {
  1331. if (valid) {
  1332. if (_this.templateForm.id in _this.adviceTemplateMaps) {
  1333. var mapid = _this.templateForm.id;
  1334. for (const index in _this.adviceTemplateMaps[mapid]
  1335. .DoctorAdviceTemplate) {
  1336. this.editRowKey++;
  1337. var item = {advice_name:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].advice_name,
  1338. advice_desc:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].advice_desc,
  1339. single_dose:"" +_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].single_dose,
  1340. single_dose_unit:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].single_dose_unit,
  1341. drug_spec:"" +_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec,
  1342. drug_spec_unit:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec_unit,
  1343. prescribing_number:"" +_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].prescribing_number,
  1344. prescribing_number_unit:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].prescribing_number_unit,
  1345. delivery_way:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].delivery_way,
  1346. execution_frequency:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].execution_frequency,
  1347. isEdit: 0,
  1348. id: 0,
  1349. children: [],
  1350. parent_row: 0,
  1351. row_key: this.editRowKey
  1352. };
  1353. if (
  1354. "children" in
  1355. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index] &&
  1356. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1357. .children
  1358. ) {
  1359. var parentRow = this.editRowKey;
  1360. var children =
  1361. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1362. .children;
  1363. for (const key in children) {
  1364. this.editRowKey++;
  1365. var child = {
  1366. advice_name: children[key].advice_name,
  1367. advice_desc: children[key].advice_desc,
  1368. single_dose: "" + children[key].single_dose,
  1369. single_dose_unit: children[key].single_dose_unit,
  1370. drug_spec: "" + children[key].drug_spec,
  1371. drug_spec_unit: children[key].drug_spec_unit,
  1372. prescribing_number: "" + children[key].prescribing_number,
  1373. prescribing_number_unit:
  1374. children[key].prescribing_number_unit,
  1375. delivery_way: children[key].delivery_way,
  1376. execution_frequency: children[key].execution_frequency,
  1377. isEdit: 0,
  1378. id: 0,
  1379. children: [],
  1380. parent_row: parentRow,
  1381. row_key: this.editRowKey
  1382. };
  1383. item.children.push(child);
  1384. }
  1385. _this.$set(item, "children", item.children);
  1386. }
  1387. _this.groupForm.adviceNames.unshift(item);
  1388. }
  1389. }
  1390. _this.templateFormVisible = false;
  1391. }
  1392. });
  1393. },
  1394. openAdviceTemplate() {
  1395. this.templateForm = { id: "" };
  1396. this.selectedTemp = { id: 0, name: "", org_id: 0, list: [], rows: [] };
  1397. this.selectedTemplate = [];
  1398. if (typeof this.$refs.templatetable !== "undefined") {
  1399. this.$refs.templatetable.setCurrentRow(null);
  1400. }
  1401. this.templateFormVisible = true;
  1402. },
  1403. selectGroupAdvice(row) {
  1404. this.groupSelectRow = row;
  1405. },
  1406. groupClassName({ row, rowIndex }) {
  1407. row.index = rowIndex;
  1408. },
  1409. getRowKey(row) {
  1410. return row.row_key;
  1411. },
  1412. resetForm(formName) {
  1413. this.$refs[formName].resetFields();
  1414. },
  1415. open() {
  1416. this.groupAddFormVisible = true;
  1417. this.groupSelectRow = null;
  1418. if (typeof this.$refs.advicenametable !== "undefined") {
  1419. this.$refs.advicenametable.setCurrentRow(null);
  1420. }
  1421. this.editRowKey = 0;
  1422. this.groupForm = {
  1423. advice_type: 2,
  1424. advice_date: this.recordDate,
  1425. start_time: "",
  1426. adviceNames: [],
  1427. advice_doctor: "",
  1428. remark: "",
  1429. parent_id: 0
  1430. };
  1431. var xtuser = this.$store.getters.xt_user;
  1432. // this.orgname = xtuser.org.org_name;
  1433. this.adminusername = xtuser.user.user_name;
  1434. if(this.$store.getters.xt_user.org.id == 10101){
  1435. if (this.predialysis.id > 0 && this.predialysis.created_time > 0) {
  1436. var date = new Date(this.predialysis.created_time * 1000)
  1437. var year = date.getFullYear()
  1438. var month = date.getMonth() + 1
  1439. var day = date.getDate()
  1440. var hours = date.getHours()
  1441. var minites = date.getMinutes()
  1442. if (month < 10) {
  1443. month = '0' + month
  1444. }
  1445. if (day < 10) {
  1446. day = '0' + day
  1447. }
  1448. if (hours < 10) {
  1449. hours = '0' + hours
  1450. }
  1451. if (minites < 10) {
  1452. minites = '0' + minites
  1453. }
  1454. this.groupForm.start_time = year + '-' + month + '-' + day + ' ' + hours + ':' + minites
  1455. } else {
  1456. var date = new Date()
  1457. var year = date.getFullYear()
  1458. var month = date.getMonth() + 1
  1459. var day = date.getDate()
  1460. var hours = date.getHours()
  1461. var minites = date.getMinutes()
  1462. if (month < 10) {
  1463. month = '0' + month
  1464. }
  1465. if (day < 10) {
  1466. day = '0' + day
  1467. }
  1468. if (hours < 10) {
  1469. hours = '0' + hours
  1470. }
  1471. if (minites < 10) {
  1472. minites = '0' + minites
  1473. }
  1474. this.groupForm.start_time = year + '-' + month + '-' + day + ' ' + hours + ':' + minites
  1475. }
  1476. }
  1477. },
  1478. selectAllTemplateAdvice(selection) {
  1479. console.log("params",selection)
  1480. var adviceArray = this.adviceTemplateMaps[this.selectedTemp.id].DoctorAdviceTemplate;
  1481. for (let y = 0; y < adviceArray.length; y++) {
  1482. adviceArray[y].selection = false;
  1483. }
  1484. if (selection.length > 0) {
  1485. for (let y = 0; y < adviceArray.length; y++) {
  1486. for (let i = 0; i < selection.length; i++) {
  1487. if (adviceArray[y].id == selection[i].advice_id) {
  1488. adviceArray[y].selection = true;
  1489. }
  1490. }
  1491. }
  1492. }
  1493. },
  1494. cancleDialog() {
  1495. this.templateFormVisible = false;
  1496. for (const indexs in this.adviceTemplateMaps) {
  1497. const adviceTemplate = this.adviceTemplateMaps[indexs];
  1498. for (const index in adviceTemplate.DoctorAdviceTemplate) {
  1499. adviceTemplate.DoctorAdviceTemplate[index].selection = false;
  1500. }
  1501. }
  1502. },
  1503. rand(min, max) {
  1504. return Math.floor(Math.random() * (max - min)) + min;
  1505. },
  1506. //
  1507. getSelfMedicalList(){
  1508. const params = {
  1509. patient_id:this.$route.query.patient_id
  1510. }
  1511. getSelfMedicalList(params).then(response=>{
  1512. if (response.data.state == 1) {
  1513. this.arr_drug = []
  1514. var medicalList = response.data.data.private_drug_list
  1515. console.log("medicallist",medicalList)
  1516. var base_drug_list = response.data.data.base_drug_list
  1517. var base_drug_cofig = response.data.data.base_drug_config
  1518. var private_drug_cofig = response.data.data.private_drug_config
  1519. if(private_drug_cofig != null&&private_drug_cofig.drug_start == 1) {
  1520. for (let i = 0; i < medicalList.length; i++) {
  1521. if(medicalList[i].drug_specs != null) {
  1522. for (let a = 0; a < medicalList[i].drug_specs.length; a++) {
  1523. medicalList[i].drug_specs[a]['type'] = 2
  1524. }
  1525. }
  1526. let obj = {
  1527. drug_name: "",
  1528. drug_desc: "",
  1529. delivery_way: "",
  1530. execution_frequency: "",
  1531. single_dose: "",
  1532. single_dose_unit: "",
  1533. prescribing_number: "",
  1534. prescribing_number_unit: "",
  1535. type_id: "",
  1536. type: "",
  1537. custom_id: "",
  1538. drug_specs: [],
  1539. }
  1540. medicalList[i].drug_name = medicalList[i].drug_name + "(自备药)"
  1541. obj.drug_name = medicalList[i].drug_name
  1542. obj.delivery_way = medicalList[i].delivery_way
  1543. obj.execution_frequency = medicalList[i].execution_frequency
  1544. obj.single_dose = medicalList[i].single_dose
  1545. obj.prescribing_number = medicalList[i].prescribing_number
  1546. obj.type_id = medicalList[i].id
  1547. obj.type = 2
  1548. obj.custom_id = this.rand(10000000, 99999999)
  1549. obj.drug_specs = medicalList[i].drug_specs
  1550. obj.id = medicalList[i].id
  1551. this.all_drug.push(obj)
  1552. }
  1553. }
  1554. for (let i = 0; i < base_drug_list.length; i++) {
  1555. if(base_drug_list[i].drug_specs != null) {
  1556. for (let a = 0; a < base_drug_list[i].drug_specs.length; a++) {
  1557. base_drug_list[i].drug_specs[a]['type'] = 1
  1558. }
  1559. }
  1560. let obj = {
  1561. drug_name: "",
  1562. drug_desc: "",
  1563. delivery_way: "",
  1564. execution_frequency: "",
  1565. single_dose: "",
  1566. single_dose_unit: "",
  1567. prescribing_number: "",
  1568. prescribing_number_unit: "",
  1569. type_id: "",
  1570. type: "",
  1571. custom_id: "",
  1572. drug_specs: [],
  1573. }
  1574. obj.drug_name = base_drug_list[i].drug_name
  1575. obj.delivery_way = base_drug_list[i].delivery_way
  1576. obj.execution_frequency = base_drug_list[i].execution_frequency
  1577. obj.single_dose = base_drug_list[i].single_dose
  1578. obj.prescribing_number = base_drug_list[i].prescribing_number
  1579. obj.type_id = base_drug_list[i].id
  1580. obj.type = 1
  1581. obj.custom_id = this.rand(10000000, 99999999)
  1582. obj.drug_specs = base_drug_list[i].drug_specs
  1583. obj.id = base_drug_list[i].id
  1584. this.all_drug.push(obj)
  1585. }
  1586. this.private_drug_config = response.data.data.private_drug_config
  1587. this.medicals = medicalList
  1588. }
  1589. })
  1590. },
  1591. changeDrugName(name){
  1592. this.current_drug_name = name
  1593. this.nameForm.advice_desc = ''
  1594. this.drugSpec = []
  1595. for (let i = 0; i < this.all_drug.length; i++) {
  1596. if (this.all_drug[i].drug_name == name) {
  1597. this.drugSpec = this.all_drug[i].drug_specs
  1598. }
  1599. }
  1600. },
  1601. changeDrugDesc(name) {
  1602. console.log("hhhhhhhhhh",this.drugSpec)
  1603. this.current_drug_spec = name
  1604. for (let i = 0; i < this.drugSpec.length; i++) {
  1605. if (this.drugSpec[i].drug_spec == name) {
  1606. this.nameForm.advice_desc = this.drugSpec[i].drug_spec
  1607. this.nameForm.prescribing_number = this.drugSpec[i].prescribing_number.toString()
  1608. this.nameForm.single_dose = this.drugSpec[i].single_dose.toString()
  1609. this.nameForm.delivery_way = this.drugSpec[i].delivery_way.toString()
  1610. this.nameForm.execution_frequency = this.drugSpec[i].execution_frequency.toString()
  1611. this.drug_id = this.drugSpec[i].id
  1612. this.src_type = this.drugSpec[i].type
  1613. this.nameForm.drug_id = this.drugSpec[i].id
  1614. this.nameForm.way = this.drugSpec[i].type
  1615. this.nameForm.single_dose_unit = this.drugSpec[i].min_unit
  1616. this.nameForm.drug_spec_unit = this.drugSpec[i].min_unit
  1617. this.nameForm.prescribing_number_unit = this.drugSpec[i].min_unit
  1618. if(this.drugSpec[i].drug_name_id){
  1619. this.nameForm.drug_name_id = this.drugSpec[i].drug_name_id
  1620. }else{
  1621. this.nameForm.drug_name_id = 0
  1622. }
  1623. }
  1624. }
  1625. },
  1626. querySearch(queryString, cb) {
  1627. console.log('queryString',queryString)
  1628. var restaurants = this.all_drug;
  1629. restaurants.map(item => {
  1630. item.value = item.drug_name
  1631. })
  1632. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
  1633. // 调用 callback 返回建议列表的数据
  1634. cb(results);
  1635. },
  1636. createFilter(queryString) {
  1637. return (restaurant) => {
  1638. return (restaurant.drug_name.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
  1639. };
  1640. },
  1641. querySearch1(queryString, cb) {
  1642. var restaurants = this.drugSpec;
  1643. console.log(restaurants)
  1644. restaurants.map(item => {
  1645. item.value = item.drug_spec
  1646. })
  1647. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
  1648. // 调用 callback 返回建议列表的数据
  1649. cb(results);
  1650. },
  1651. handleSelect(val){
  1652. console.log("22222",val)
  1653. this.drug_id = val.id
  1654. this.nameForm.way = 1
  1655. },
  1656. handleSelect1(){
  1657. }
  1658. },
  1659. watch: {
  1660. "selectedTemp.list": function() {
  1661. this.calcselectedTemp();
  1662. }
  1663. },
  1664. created(){
  1665. //获取自备药
  1666. this.getSelfMedicalList()
  1667. console.log("模板数据",this.adviceTemplates)
  1668. }
  1669. };
  1670. </script>
  1671. <style>
  1672. #user-edit-advice-name-table .el-table__row {
  1673. display: table-row !important;
  1674. }
  1675. #user-edit-advice-name-table .el-table__expand-icon {
  1676. -webkit-transform: rotate(90deg) !important;
  1677. transform: rotate(90deg) !important;
  1678. }
  1679. #dialysis-add-select-template-table .el-table__row {
  1680. display: table-row !important;
  1681. }
  1682. #dialysis-add-select-template-table .el-table__expand-icon {
  1683. -webkit-transform: rotate(90deg) !important;
  1684. transform: rotate(90deg) !important;
  1685. }
  1686. </style>