AddGroupAdvice.vue 60KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687
  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-select
  363. v-model="nameForm.advice_name"
  364. filterable
  365. clearable
  366. allow-create
  367. :disabled="isChild"
  368. placeholder="请选择(输入可搜索)"
  369. style="width:200px"
  370. @change="changeDrugName"
  371. >
  372. <el-option
  373. v-for="(item,index) in all_drug"
  374. :key="index"
  375. :label="item.drug_name"
  376. :value="item.drug_name"
  377. ></el-option>
  378. </el-select>
  379. </el-form-item>
  380. <!-- <div style="margin-left:120px;margin-top:-20px;font-size:12px;color:red">
  381. 库存不足50
  382. </div> -->
  383. </el-col>
  384. </el-row>
  385. <el-row>
  386. <el-col :span="13">
  387. <!--<el-form-item label="规格 :" prop="advice_desc">-->
  388. <!--<el-input v-model="nameForm.advice_desc"></el-input>-->
  389. <!--</el-form-item>-->
  390. <el-form-item label="药品规格 :" prop="advice_desc">
  391. <el-col :span="10">
  392. <!-- <el-input v-model="nameForm.advice_desc"></el-input> -->
  393. <el-select
  394. v-model="nameForm.advice_desc"
  395. filterable
  396. clearable
  397. allow-create
  398. :disabled="isChild"
  399. placeholder="请选择(输入可搜索)"
  400. style="width:150px"
  401. @change="changeDrugDesc"
  402. >
  403. <el-option
  404. v-for="item in drugSpec"
  405. :key="item.id"
  406. :label="item.drug_spec"
  407. :value="item.drug_spec"
  408. ></el-option>
  409. </el-select>
  410. </el-col>
  411. <el-col class="line" :span="2">&nbsp;</el-col>
  412. <el-col :span="10">
  413. <el-select
  414. v-model="nameForm.drug_spec_unit"
  415. filterable
  416. clearable
  417. allow-create
  418. placeholder="选择"
  419. style="width:120px"
  420. >
  421. <el-option
  422. v-for="item in unitsOption"
  423. :key="item.id"
  424. :label="item.name"
  425. :value="item.name"
  426. ></el-option>
  427. </el-select>
  428. </el-col>
  429. </el-form-item>
  430. </el-col>
  431. <el-col :span="9">
  432. <el-form-item label="开药数量 :" prop="prescribing_number">
  433. <el-col :span="8">
  434. <el-input v-model="nameForm.prescribing_number"></el-input>
  435. </el-col>
  436. <el-col class="line" :span="2">&nbsp;</el-col>
  437. <el-col :span="14">
  438. <el-select
  439. v-model="nameForm.prescribing_number_unit"
  440. filterable
  441. clearable
  442. allow-create
  443. placeholder="选择"
  444. >
  445. <el-option
  446. v-for="item in unitsOption"
  447. :key="item.id"
  448. :label="item.name"
  449. :value="item.name"
  450. ></el-option>
  451. </el-select>
  452. </el-col>
  453. </el-form-item>
  454. </el-col>
  455. <el-col :span="12">
  456. <el-form-item label="单次用量 :" prop="single_dose">
  457. <el-col :span="8">
  458. <el-input v-model="nameForm.single_dose"></el-input>
  459. </el-col>
  460. <el-col class="line" :span="2">&nbsp;</el-col>
  461. <el-col :span="14">
  462. <el-select
  463. v-model="nameForm.single_dose_unit"
  464. filterable
  465. clearable
  466. allow-create
  467. placeholder="选择"
  468. >
  469. <el-option
  470. v-for="item in unitsOption"
  471. :key="item.id"
  472. :label="item.name"
  473. :value="item.name"
  474. ></el-option>
  475. </el-select>
  476. </el-col>
  477. </el-form-item>
  478. </el-col>
  479. <el-col :span="12">
  480. <el-form-item label="给药途径 :" prop="delivery_way">
  481. <el-select
  482. v-model="nameForm.delivery_way"
  483. filterable
  484. clearable
  485. allow-create
  486. :disabled="isChild"
  487. placeholder="请选择(输入可搜索)"
  488. style="width:100%"
  489. >
  490. <el-option
  491. v-for="item in deliveryWayOptions"
  492. :key="item.id"
  493. :label="item.name"
  494. :value="item.name"
  495. ></el-option>
  496. </el-select>
  497. </el-form-item>
  498. </el-col>
  499. </el-row>
  500. <el-row>
  501. <el-col :span="12">
  502. <el-form-item label="执行频率 :" prop="execution_frequency">
  503. <el-select
  504. v-model="nameForm.execution_frequency"
  505. filterable
  506. clearable
  507. allow-create
  508. :disabled="isChild"
  509. placeholder="请选择(输入可搜索)"
  510. style="width:100%"
  511. >
  512. <el-option
  513. v-for="item in executionFrequencyOptions"
  514. :key="item.id"
  515. :label="item.name"
  516. :value="item.name"
  517. ></el-option>
  518. </el-select>
  519. </el-form-item>
  520. </el-col>
  521. </el-row>
  522. <!--<el-row>-->
  523. <!--<el-col :span="12">-->
  524. <!--<el-form-item label="医嘱嘱托 :" prop="delivery_way">-->
  525. <!--<el-input v-model="nameForm.remark"></el-input>-->
  526. <!--</el-form-item>-->
  527. <!--</el-col>-->
  528. <!--</el-row>-->
  529. </el-form>
  530. <div slot="footer" class="dialog-footer">
  531. <el-button @click="nameFormVisible = false">取消</el-button>
  532. <el-button
  533. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  534. type="primary"
  535. @click="submitNameForm('nameForm')"
  536. >保 存
  537. </el-button>
  538. </div>
  539. </el-dialog>
  540. </div>
  541. </template>
  542. <script>
  543. import {
  544. CreateDoctorAdvice,
  545. CreateGroupAdvice,
  546. DeleteDoctorAdvice,
  547. DeleteGroupAdvice,
  548. EditDoctorAdvice,
  549. getAdviceConfig,
  550. getDoctorAdviceList,
  551. StopDoctorAdvice
  552. } from "@/api/advice";
  553. import {getSelfMedicalList,getDrugDescByDrugName } from "@/api/drug/drug"
  554. import { duration } from 'moment';
  555. export default {
  556. name: "AddGroupAdvice",
  557. data() {
  558. return {
  559. editRowKey: 0,
  560. oldTemplateFormVisible: false,
  561. templateFormVisible: false,
  562. groupAddFormVisible: false,
  563. nameFormVisible: false,
  564. groupSelectRow: null,
  565. nameFormTitle: "",
  566. isChild: false,
  567. isEdit: false,
  568. adminusername: "",
  569. groupRules: {
  570. advice_type: [{ required: true, message: "请选择医嘱类型" }],
  571. advice_date: [{ required: true, message: "请选择医嘱时间" }],
  572. start_time: [{ required: true, message: "请选择开始时间" }],
  573. advice_name: [{ required: true, message: "请填写医嘱名称" }],
  574. advice_doctor: [{ required: true, message: "请选择开嘱医生" }]
  575. },
  576. nameRules: {
  577. advice_name: [{ required: true, message: "请填写医嘱内容" }]
  578. },
  579. templateRules: {
  580. id: [{ required: true, message: "请选择医嘱模板" }]
  581. },
  582. templateForm: { id: "" },
  583. nameForm: {
  584. advice_name: "",
  585. advice_desc: "",
  586. single_dose: "",
  587. single_dose_unit: "",
  588. drug_spec: "",
  589. drug_spec_unit: "",
  590. prescribing_number: "",
  591. prescribing_number_unit: "",
  592. delivery_way: "",
  593. execution_frequency: "",
  594. remark: "",
  595. isEdit: 0,
  596. index: 0,
  597. id: 0,
  598. children: [],
  599. drug_id:"",
  600. way:"",
  601. },
  602. submitGroupForm: {
  603. advice_type: "",
  604. advice_date: "",
  605. start_time: "",
  606. adviceNames: [],
  607. advice_doctor: "",
  608. remark: "",
  609. parent_id: 0
  610. },
  611. groupForm: {
  612. advice_type: "",
  613. advice_date: "",
  614. start_time: "",
  615. adviceNames: [],
  616. advice_doctor: "",
  617. remark: "",
  618. parent_id: 0,
  619. drug_id:"",
  620. way:"",
  621. },
  622. selectedTemp: { id: 0, name: "", org_id: 0, list: [], rows: [] },
  623. selectedTemplate: [],
  624. allSelectedTemplate: [],
  625. medicals:[],
  626. drugSpec:[],
  627. all_drug:[],
  628. current_drug_name:"",
  629. current_drug_spec: "",
  630. drug_id: 0,
  631. src_type:""
  632. };
  633. },
  634. props: {
  635. patientID: 0,
  636. adviceType: 0,
  637. rowKey: 0,
  638. adviceTemplates: {
  639. type: Array,
  640. default: function() {
  641. return [];
  642. }
  643. },
  644. recordDate: "",
  645. adviceTypeOptions: {
  646. type: Array,
  647. default: function() {
  648. return [];
  649. }
  650. },
  651. deliveryWayOptions: {
  652. type: Array,
  653. default: () => []
  654. },
  655. unitsOption: {
  656. type: Array,
  657. default: function() {
  658. return [];
  659. }
  660. },
  661. executionFrequencyOptions: {
  662. type: Array,
  663. default: function() {
  664. return [];
  665. }
  666. },
  667. adviceTemplateMaps: {
  668. type: Object,
  669. default: function() {
  670. return {};
  671. }
  672. },
  673. adviceTableData: {
  674. type: Array,
  675. default: function() {
  676. return [];
  677. }
  678. },
  679. },
  680. methods: {
  681. submitgroupAdvice(formName) {
  682. this.$refs[formName].validate(valid => {
  683. if (valid) {
  684. var submitForm = {
  685. advice_type: this.groupForm.advice_type,
  686. advice_date: this.groupForm.advice_date,
  687. start_time: this.groupForm.start_time,
  688. adviceNames: [],
  689. advice_doctor: this.groupForm.advice_doctor,
  690. remark: this.groupForm.remark,
  691. parent_id: this.groupForm.parent_id
  692. };
  693. console.log("888888",this.groupForm.adviceNames)
  694. var adviceNames = [];
  695. for (const index in this.groupForm.adviceNames) {
  696. adviceNames.unshift(this.groupForm.adviceNames[index]);
  697. }
  698. submitForm.adviceNames = adviceNames;
  699. let mode = "1";
  700. console.log("88888888",submitForm)
  701. CreateGroupAdvice(this.patientID, 0, submitForm, mode).then(
  702. response => {
  703. if (response.data.state == 0) {
  704. this.$message.error(response.data.msg);
  705. return false;
  706. } else {
  707. this.$notify({
  708. title: "成功",
  709. message: "新增成功",
  710. type: "success",
  711. duration: 2000
  712. });
  713. var childMap = {};
  714. for (const index in response.data.data.advices) {
  715. if (response.data.data.advices[index].parent_id == 0) {
  716. continue;
  717. }
  718. if (
  719. response.data.data.advices[index].parent_id in childMap ===
  720. false
  721. ) {
  722. childMap[response.data.data.advices[index].parent_id] = [];
  723. }
  724. childMap[response.data.data.advices[index].parent_id].unshift(
  725. response.data.data.advices[index]
  726. );
  727. }
  728. var parentArr = [];
  729. for (const index in response.data.data.advices) {
  730. if (response.data.data.advices[index].parent_id > 0) {
  731. continue;
  732. }
  733. parentArr.push(response.data.data.advices[index]);
  734. }
  735. for (const index in parentArr) {
  736. if (parentArr[index].id in childMap) {
  737. for (const j in childMap[parentArr[index].id]) {
  738. this.adviceTableData.unshift(
  739. childMap[parentArr[index].id][j]
  740. );
  741. }
  742. }
  743. this.adviceTableData.unshift(parentArr[index]);
  744. }
  745. // var alen = response.data.data.advices.length
  746. // for (let index = alen-1; index >=0; index--) {
  747. // this.adviceTableData.unshift(response.data.data.advices[index]);
  748. // }
  749. this.resetForm(formName);
  750. this.groupAddFormVisible = false;
  751. this.$parent.getDialysisScheduleDetail()
  752. return false;
  753. }
  754. }
  755. );
  756. }
  757. });
  758. },
  759. openDeleteGroupAdvice() {
  760. if (this.groupSelectRow === null) {
  761. this.$message.error("未选择要删除的医嘱内容");
  762. return;
  763. }
  764. var content = "";
  765. if (this.groupSelectRow.children.length > 0) {
  766. content = "确认删除此医嘱内容,包括它的子药?";
  767. } else {
  768. content = "确认删除此医嘱内容?";
  769. }
  770. var isChild = !!this.groupSelectRow.parent_row;
  771. var title = isChild ? "删除子药内容" : "删除医嘱内容";
  772. var msg = isChild ? "确认删除此子药内容?" : content;
  773. this.$confirm(msg, title, {
  774. confirmButtonText: "确定",
  775. cancelButtonText: "取消",
  776. type: "warning"
  777. })
  778. .then(() => {
  779. if (isChild) {
  780. for (const index in this.groupForm.adviceNames) {
  781. if (
  782. this.groupForm.adviceNames[index].row_key ==
  783. this.groupSelectRow.parent_row
  784. ) {
  785. for (const j in this.groupForm.adviceNames[index].children) {
  786. if (
  787. this.groupForm.adviceNames[index].children[j].row_key ==
  788. this.groupSelectRow.row_key
  789. ) {
  790. this.groupForm.adviceNames[index].children.splice(j, 1);
  791. this.$set(
  792. this.groupForm.adviceNames,
  793. index,
  794. this.groupForm.adviceNames[index]
  795. );
  796. break;
  797. }
  798. }
  799. }
  800. }
  801. } else {
  802. for (const index in this.groupForm.adviceNames) {
  803. if (
  804. this.groupForm.adviceNames[index].row_key ==
  805. this.groupSelectRow.row_key
  806. ) {
  807. this.groupForm.adviceNames.splice(index, 1);
  808. break;
  809. }
  810. }
  811. }
  812. })
  813. .catch(() => {});
  814. },
  815. submitNameForm(formName) {
  816. console.log("=====",this.src_type)
  817. if(this.src_type == ""){
  818. this.nameForm.way = 0
  819. this.nameForm.drug_id = 0
  820. }
  821. if(this.src_type == 2){ //自备药
  822. var arr = this.nameForm.advice_name.split("(自备药)")
  823. this.nameForm.advice_name = arr[0]
  824. }
  825. // if(typeof(this.nameForm.advice_name) == "string"){
  826. // this.nameForm.advice_name == this.nameForm.advice_name
  827. // }
  828. // if(typeof(this.nameForm.advice_name) == "number"){
  829. // var drug_name = ""
  830. // var name = ""
  831. // var way = 0
  832. // this.nameForm.drug_id = this.nameForm.advice_name
  833. // for(let i=0;i<this.medicals.length;i++){
  834. // if(this.nameForm.advice_name == this.medicals[i].id){
  835. // name = this.medicals[i].drug_name
  836. // way = this.medicals[i].way
  837. // }
  838. // }
  839. // if(way == 1){
  840. // drug_name = name
  841. // }
  842. // if(way == 2){
  843. // var arr = name.split("(自备药)")
  844. // drug_name = arr[0]
  845. // }
  846. // this.nameForm.advice_name = drug_name
  847. // this.nameForm.way = way
  848. // }
  849. var _this = this;
  850. this.$refs[formName].validate(valid => {
  851. if (valid) {
  852. if (_this.nameForm.isEdit) {
  853. var ale = _this.groupForm.adviceNames.length;
  854. if (_this.isChild) {
  855. for (let index = 0; index < ale; index++) {
  856. if (_this.groupSelectRow.parent_row ==_this.groupForm.adviceNames[index].row_key) {
  857. var cle = _this.groupForm.adviceNames[index].children.length;
  858. var children = _this.groupForm.adviceNames[index].children;
  859. for (let j = 0; j < ale; j++) {
  860. if (_this.groupSelectRow.row_key == children[j].row_key) {
  861. _this.groupForm.adviceNames[index].children[j].advice_name = _this.nameForm.advice_name;
  862. _this.groupForm.adviceNames[index].children[j].advice_desc = _this.nameForm.advice_desc;
  863. _this.groupForm.adviceNames[index].children[j].single_dose = "" + _this.nameForm.single_dose;
  864. _this.groupForm.adviceNames[index].children[j].single_dose_unit = _this.nameForm.single_dose_unit;
  865. _this.groupForm.adviceNames[index].children[j].drug_spec = "" + _this.nameForm.drug_spec;
  866. _this.groupForm.adviceNames[index].children[j].drug_spec_unit = _this.nameForm.drug_spec_unit;
  867. _this.groupForm.adviceNames[index].children[j].prescribing_number ="" + _this.nameForm.prescribing_number;
  868. _this.groupForm.adviceNames[index].children[j].prescribing_number_unit = _this.nameForm.prescribing_number_unit;
  869. _this.groupForm.adviceNames[index].children[j].delivery_way = _this.nameForm.delivery_way;
  870. _this.groupForm.adviceNames[index].children[j].execution_frequency =_this.nameForm.execution_frequency;
  871. _this.groupForm.adviceNames[index].children[j].remark =_this.nameForm.remark;
  872. _this.groupForm.adviceNames[index].children[j].drug_id = _this.nameForm.drug_id;
  873. _this.groupForm.adviceNames[index].children[j].way = _this.nameForm.way;
  874. _this.$set(_this.groupForm.adviceNames[index].children,j,_this.groupForm.adviceNames[index].children[j]
  875. );
  876. break;
  877. }
  878. }
  879. }
  880. }
  881. } else {
  882. for (let index = 0; index < ale; index++) {
  883. if ( _this.groupSelectRow.row_key ==_this.groupForm.adviceNames[index].row_key) {
  884. _this.groupForm.adviceNames[index].advice_name =_this.nameForm.advice_name;
  885. _this.groupForm.adviceNames[index].advice_desc =_this.nameForm.advice_desc;
  886. _this.groupForm.adviceNames[index].single_dose ="" + _this.nameForm.single_dose;
  887. _this.groupForm.adviceNames[index].single_dose_unit =_this.nameForm.single_dose_unit;
  888. _this.groupForm.adviceNames[index].drug_spec = "" + _this.nameForm.drug_spec;
  889. _this.groupForm.adviceNames[index].drug_spec_unit =_this.nameForm.drug_spec_unit;
  890. _this.groupForm.adviceNames[index].prescribing_number ="" + _this.nameForm.prescribing_number;
  891. _this.groupForm.adviceNames[index].prescribing_number_unit =_this.nameForm.prescribing_number_unit;
  892. _this.groupForm.adviceNames[index].delivery_way =_this.nameForm.delivery_way;
  893. _this.groupForm.adviceNames[index].execution_frequency =_this.nameForm.execution_frequency;
  894. _this.groupForm.adviceNames[index].remark =_this.nameForm.remark;
  895. _this.groupForm.adviceNames[index].children[j].drug_id = _this.nameForm.drug_id;
  896. _this.groupForm.adviceNames[index].children[j].way = _this.nameForm.way;
  897. _this.$set(
  898. _this.groupForm.adviceNames,
  899. index,
  900. _this.groupForm.adviceNames[index]
  901. );
  902. break;
  903. }
  904. }
  905. }
  906. } else {
  907. if (_this.isChild) {
  908. _this.editRowKey++;
  909. _this.nameForm.row_key = _this.editRowKey;
  910. var ale = _this.groupForm.adviceNames.length;
  911. for (let index = 0; index < ale; index++) {
  912. if (_this.nameForm.parent_row ==_this.groupForm.adviceNames[index].row_key) {
  913. _this.groupForm.adviceNames[index].children.push(_this.nameForm);
  914. _this.$set(_this.groupForm.adviceNames,index,_this.groupForm.adviceNames[index]);
  915. break;
  916. }
  917. }
  918. } else {
  919. _this.editRowKey++;
  920. _this.nameForm.row_key = _this.editRowKey;
  921. _this.groupForm.adviceNames.push(_this.nameForm);
  922. }
  923. }
  924. _this.nameFormVisible = false;
  925. }
  926. });
  927. },
  928. openGroupChild() {
  929. if (this.groupSelectRow === null) {
  930. this.$message.error("未选择医嘱内容,无法添加子药");
  931. return;
  932. } else if (this.groupSelectRow.parent_row > 0) {
  933. this.$notify.error({
  934. title: "错误",
  935. message: "子药不能添加子药"
  936. });
  937. return;
  938. }
  939. this.nameForm = {
  940. advice_name:"",
  941. advice_desc: "",
  942. single_dose: "",
  943. single_dose_unit: "",
  944. drug_spec: "",
  945. drug_spec_unit: "",
  946. prescribing_number: "",
  947. prescribing_number_unit: "",
  948. delivery_way: this.groupSelectRow.delivery_way,
  949. execution_frequency: this.groupSelectRow.execution_frequency,
  950. remark: "",
  951. isEdit: 0,
  952. index: 0,
  953. children: [],
  954. parent_row: this.groupSelectRow.row_key,
  955. id: 0
  956. };
  957. this.isChild = true;
  958. this.nameFormVisible = true;
  959. this.nameFormTitle = "添加子药内容";
  960. },
  961. openGroupAdvice(isEdit) {
  962. this.isChild = false;
  963. if (isEdit) {
  964. if (this.groupSelectRow === null) {
  965. this.$message.error("未选择要修改的医嘱内容");
  966. return;
  967. }
  968. if (this.groupSelectRow.parent_row) {
  969. this.isChild = true;
  970. }
  971. this.nameForm = {
  972. advice_name: this.groupSelectRow.advice_name,
  973. advice_desc: this.groupSelectRow.advice_desc,
  974. single_dose:
  975. this.groupSelectRow.single_dose != 0
  976. ? this.groupSelectRow.single_dose
  977. : "",
  978. single_dose_unit: this.groupSelectRow.single_dose_unit,
  979. drug_spec:
  980. this.groupSelectRow.drug_spec != 0
  981. ? this.groupSelectRow.drug_spec
  982. : "",
  983. drug_spec_unit: this.groupSelectRow.drug_spec_unit,
  984. prescribing_number:
  985. this.groupSelectRow.prescribing_number != 0
  986. ? this.groupSelectRow.prescribing_number
  987. : "",
  988. prescribing_number_unit: this.groupSelectRow.prescribing_number_unit,
  989. delivery_way: this.isChild ? "" : this.groupSelectRow.delivery_way,
  990. execution_frequency: this.isChild
  991. ? ""
  992. : this.groupSelectRow.execution_frequency,
  993. isEdit: 1,
  994. index: this.groupSelectRow.index,
  995. id: this.groupSelectRow.id,
  996. children: [],
  997. parent_row: this.groupSelectRow.parent_row,
  998. remark: this.groupSelectRow.remark
  999. // row_key:this.groupSelectRow.row_key,
  1000. };
  1001. this.nameFormTitle = "修改医嘱内容";
  1002. } else {
  1003. this.nameForm = {
  1004. advice_name: "",
  1005. advice_desc: "",
  1006. single_dose: "",
  1007. single_dose_unit: "",
  1008. drug_spec: "",
  1009. drug_spec_unit: "",
  1010. prescribing_number: "",
  1011. prescribing_number_unit: "",
  1012. delivery_way: "",
  1013. execution_frequency: "",
  1014. isEdit: 0,
  1015. index: 0,
  1016. id: 0,
  1017. remark: "",
  1018. children: [],
  1019. parent_row: 0
  1020. };
  1021. this.nameFormTitle = "新增医嘱内容";
  1022. }
  1023. this.nameFormVisible = true;
  1024. },
  1025. changeAdvice(selection) {
  1026. this.selectedTemplate = selection;
  1027. },
  1028. selectAdvice(selection, row) {
  1029. // this.selectedTemplate = [];
  1030. // console.log(selection);
  1031. var adviceArray = this.adviceTemplateMaps[this.selectedTemp.id]
  1032. .DoctorAdviceTemplate;
  1033. console.log(adviceArray);
  1034. for (let y = 0; y < adviceArray.length; y++) {
  1035. adviceArray[y].selection = false;
  1036. }
  1037. if (selection.length > 0) {
  1038. for (let y = 0; y < adviceArray.length; y++) {
  1039. for (let i = 0; i < selection.length; i++) {
  1040. if (adviceArray[y].id == selection[i].advice_id) {
  1041. adviceArray[y].selection = true;
  1042. }
  1043. }
  1044. }
  1045. }
  1046. // console.log(adviceArray);
  1047. if (row.children.length > 0) {
  1048. for (const index in row.children) {
  1049. this.$refs.selecttemplatetable.toggleRowSelection(
  1050. row.children[index]
  1051. );
  1052. }
  1053. }
  1054. // 下面两步的作用是为了上选中的数据的输出顺序不变
  1055. for (const index in this.selectedTemp.list) {
  1056. this.$refs.selecttemplatetable.toggleRowSelection(
  1057. this.selectedTemp.list[index]
  1058. );
  1059. if (this.selectedTemp.list[index].children.length > 0) {
  1060. for (const j in this.selectedTemp.list[index].children) {
  1061. this.$refs.selecttemplatetable.toggleRowSelection(
  1062. this.selectedTemp.list[index].children[j]
  1063. );
  1064. }
  1065. }
  1066. }
  1067. for (const index in this.selectedTemp.list) {
  1068. this.$refs.selecttemplatetable.toggleRowSelection(
  1069. this.selectedTemp.list[index]
  1070. );
  1071. if (this.selectedTemp.list[index].children.length > 0) {
  1072. for (const j in this.selectedTemp.list[index].children) {
  1073. this.$refs.selecttemplatetable.toggleRowSelection(
  1074. this.selectedTemp.list[index].children[j]
  1075. );
  1076. }
  1077. }
  1078. }
  1079. },
  1080. spanselecttable({ row, column, rowIndex, columnIndex }) {
  1081. if (columnIndex == 0) {
  1082. const _row = this.selectedTemp.rows[rowIndex];
  1083. const _col = _row > 0 ? 1 : 0;
  1084. return {
  1085. rowspan: _row,
  1086. colspan: _col
  1087. };
  1088. }
  1089. },
  1090. calcselectedTemp() {
  1091. var rowKeys = 0;
  1092. for (const index in this.selectedTemp.list) {
  1093. var pkey = rowKeys;
  1094. this.selectedTemp.rows[rowKeys] = 1;
  1095. if (this.selectedTemp.list[index].children.length > 0) {
  1096. for (const childindex in this.selectedTemp.list[index].children) {
  1097. rowKeys++;
  1098. this.selectedTemp.rows[pkey] += 1;
  1099. this.selectedTemp.rows[rowKeys] = 0;
  1100. }
  1101. }
  1102. rowKeys++;
  1103. this.$nextTick(function() {
  1104. if (this.selectedTemp.list[index].selection) {
  1105. this.$refs.selecttemplatetable.toggleRowSelection(
  1106. this.selectedTemp.list[index]
  1107. );
  1108. }
  1109. });
  1110. }
  1111. },
  1112. templateTableChange(currentRow, oldCurrentRow) {
  1113. this.selectedTemp = { id: 0, name: "", org_id: 0, list: [], rows: [] };
  1114. if (currentRow == null) {
  1115. return false;
  1116. }
  1117. this.selectedTemp.id = currentRow.id;
  1118. this.selectedTemp.name = currentRow.name;
  1119. this.selectedTemp.org_id = currentRow.org_id;
  1120. if (this.selectedTemp.id in this.adviceTemplateMaps) {
  1121. var mapid = this.selectedTemp.id;
  1122. var thisRowKey = 0;
  1123. for (const index in this.adviceTemplateMaps[mapid]
  1124. .DoctorAdviceTemplate) {
  1125. thisRowKey++;
  1126. var item = {
  1127. advice_name: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1128. index
  1129. ].advice_name,
  1130. advice_desc: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1131. index
  1132. ].advice_desc,
  1133. single_dose:
  1134. "" +
  1135. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1136. .single_dose,
  1137. single_dose_unit: this.adviceTemplateMaps[mapid]
  1138. .DoctorAdviceTemplate[index].single_dose_unit,
  1139. drug_spec:
  1140. "" +
  1141. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec,
  1142. drug_spec_unit: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec_unit,
  1143. prescribing_number:
  1144. "" +
  1145. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1146. .prescribing_number,
  1147. prescribing_number_unit: this.adviceTemplateMaps[mapid]
  1148. .DoctorAdviceTemplate[index].prescribing_number_unit,
  1149. delivery_way: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1150. index
  1151. ].delivery_way,
  1152. execution_frequency: this.adviceTemplateMaps[mapid]
  1153. .DoctorAdviceTemplate[index].execution_frequency,
  1154. selection: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1155. index
  1156. ].selection,
  1157. advice_id: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1158. index
  1159. ].id,
  1160. isEdit: 0,
  1161. id: 0,
  1162. children: [],
  1163. parent_row: 0,
  1164. row_key: thisRowKey
  1165. };
  1166. if (
  1167. "children" in
  1168. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index] &&
  1169. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].children
  1170. .length > 0
  1171. ) {
  1172. var parentRow = thisRowKey;
  1173. var children = this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1174. index
  1175. ].children;
  1176. for (const key in children) {
  1177. thisRowKey++;
  1178. var child = {
  1179. advice_id: children[key].id,
  1180. advice_name: children[key].advice_name,
  1181. advice_desc: children[key].advice_desc,
  1182. single_dose: "" + children[key].single_dose,
  1183. single_dose_unit: children[key].single_dose_unit,
  1184. drug_spec: "" + children[key].drug_spec,
  1185. drug_spec_unit: children[key].drug_spec_unit,
  1186. prescribing_number: "" + children[key].prescribing_number,
  1187. prescribing_number_unit: children[key].prescribing_number_unit,
  1188. delivery_way: children[key].delivery_way,
  1189. execution_frequency: children[key].execution_frequency,
  1190. isEdit: 0,
  1191. id: 0,
  1192. children: [],
  1193. parent_row: parentRow,
  1194. row_key: thisRowKey
  1195. };
  1196. item.children.push(child);
  1197. }
  1198. this.$set(item, "children", item.children);
  1199. }
  1200. this.selectedTemp.list.unshift(item);
  1201. }
  1202. }
  1203. },
  1204. newAddTempForm() {
  1205. this.allSelectedTemplate = [];
  1206. var thisRowKey = 0;
  1207. for (const indexs in this.adviceTemplateMaps) {
  1208. const adviceTemplate = this.adviceTemplateMaps[indexs];
  1209. for (const index in adviceTemplate.DoctorAdviceTemplate) {
  1210. if (adviceTemplate.DoctorAdviceTemplate[index].selection) {
  1211. thisRowKey++;
  1212. var item = {
  1213. advice_name:
  1214. adviceTemplate.DoctorAdviceTemplate[index].advice_name,
  1215. advice_desc:
  1216. adviceTemplate.DoctorAdviceTemplate[index].advice_desc,
  1217. single_dose:
  1218. "" + adviceTemplate.DoctorAdviceTemplate[index].single_dose,
  1219. single_dose_unit:
  1220. adviceTemplate.DoctorAdviceTemplate[index].single_dose_unit,
  1221. drug_spec:
  1222. "" + adviceTemplate.DoctorAdviceTemplate[index].drug_spec,
  1223. drug_spec_unit:
  1224. adviceTemplate.DoctorAdviceTemplate[index].drug_spec_unit,
  1225. prescribing_number:
  1226. "" +
  1227. adviceTemplate.DoctorAdviceTemplate[index].prescribing_number,
  1228. prescribing_number_unit:
  1229. adviceTemplate.DoctorAdviceTemplate[index]
  1230. .prescribing_number_unit,
  1231. delivery_way:
  1232. adviceTemplate.DoctorAdviceTemplate[index].delivery_way,
  1233. execution_frequency:
  1234. adviceTemplate.DoctorAdviceTemplate[index].execution_frequency,
  1235. advice_id: adviceTemplate.DoctorAdviceTemplate[index].id,
  1236. selection: adviceTemplate.DoctorAdviceTemplate[index].selection,
  1237. isEdit: 0,
  1238. id: 0,
  1239. children: [],
  1240. parent_row: 0,
  1241. row_key: thisRowKey
  1242. };
  1243. if (
  1244. "children" in adviceTemplate.DoctorAdviceTemplate[index] &&
  1245. adviceTemplate.DoctorAdviceTemplate[index].children.length > 0
  1246. ) {
  1247. var parentRow = thisRowKey;
  1248. var children =
  1249. adviceTemplate.DoctorAdviceTemplate[index].children;
  1250. for (const key in children) {
  1251. thisRowKey++;
  1252. var child = {
  1253. advice_id: children[key].id,
  1254. advice_name: children[key].advice_name,
  1255. advice_desc: children[key].advice_desc,
  1256. single_dose: "" + children[key].single_dose,
  1257. single_dose_unit: children[key].single_dose_unit,
  1258. drug_spec: "" + children[key].drug_spec,
  1259. drug_spec_unit: children[key].drug_spec_unit,
  1260. prescribing_number: "" + children[key].prescribing_number,
  1261. prescribing_number_unit:
  1262. children[key].prescribing_number_unit,
  1263. delivery_way: children[key].delivery_way,
  1264. execution_frequency: children[key].execution_frequency,
  1265. isEdit: 0,
  1266. id: 0,
  1267. children: [],
  1268. parent_row: parentRow,
  1269. row_key: thisRowKey
  1270. };
  1271. item.children.push(child);
  1272. this.allSelectedTemplate.unshift(child);
  1273. }
  1274. this.$set(item, "children", item.children);
  1275. }
  1276. this.allSelectedTemplate.unshift(item);
  1277. adviceTemplate.DoctorAdviceTemplate[index].selection = false;
  1278. }
  1279. }
  1280. }
  1281. var childMap = {};
  1282. for (const index in this.allSelectedTemplate) {
  1283. if (this.allSelectedTemplate[index].parent_row > 0) {
  1284. if (!(this.allSelectedTemplate[index].parent_row in childMap)) {
  1285. childMap[this.allSelectedTemplate[index].parent_row] = [];
  1286. }
  1287. childMap[this.allSelectedTemplate[index].parent_row].push(
  1288. this.allSelectedTemplate[index]
  1289. );
  1290. }
  1291. }
  1292. for (const index in this.allSelectedTemplate) {
  1293. if (this.allSelectedTemplate[index].parent_row > 0) {
  1294. continue;
  1295. }
  1296. this.editRowKey++;
  1297. var item = {
  1298. advice_name: this.allSelectedTemplate[index].advice_name,
  1299. advice_desc: this.allSelectedTemplate[index].advice_desc,
  1300. single_dose: "" + this.allSelectedTemplate[index].single_dose,
  1301. single_dose_unit: this.allSelectedTemplate[index].single_dose_unit,
  1302. drug_spec: "" + this.allSelectedTemplate[index].drug_spec,
  1303. drug_spec_unit: this.allSelectedTemplate[index].drug_spec_unit,
  1304. prescribing_number:
  1305. "" + this.allSelectedTemplate[index].prescribing_number,
  1306. prescribing_number_unit: this.allSelectedTemplate[index]
  1307. .prescribing_number_unit,
  1308. delivery_way: this.allSelectedTemplate[index].delivery_way,
  1309. execution_frequency: this.allSelectedTemplate[index]
  1310. .execution_frequency,
  1311. isEdit: 0,
  1312. id: 0,
  1313. children: [],
  1314. parent_row: 0,
  1315. row_key: this.editRowKey
  1316. };
  1317. if (this.allSelectedTemplate[index].children.length > 0) {
  1318. if (this.allSelectedTemplate[index].row_key in childMap) {
  1319. var parentRow = this.editRowKey;
  1320. var children = childMap[this.allSelectedTemplate[index].row_key];
  1321. for (const key in children) {
  1322. this.editRowKey++;
  1323. var child = {
  1324. advice_name: children[key].advice_name,
  1325. advice_desc: children[key].advice_desc,
  1326. single_dose: "" + children[key].single_dose,
  1327. single_dose_unit: children[key].single_dose_unit,
  1328. drug_spec: "" + children[key].drug_spec,
  1329. drug_spec_unit: children[key].drug_spec_unit,
  1330. prescribing_number: "" + children[key].prescribing_number,
  1331. prescribing_number_unit: children[key].prescribing_number_unit,
  1332. delivery_way: children[key].delivery_way,
  1333. execution_frequency: children[key].execution_frequency,
  1334. isEdit: 0,
  1335. id: 0,
  1336. children: [],
  1337. parent_row: parentRow,
  1338. row_key: this.editRowKey
  1339. };
  1340. item.children.push(child);
  1341. }
  1342. this.$set(item, "children", item.children);
  1343. }
  1344. }
  1345. console.log(this.groupForm.adviceNames)
  1346. this.groupForm.adviceNames.push(item);
  1347. }
  1348. this.templateFormVisible = false;
  1349. },
  1350. addTempForm(formName) {
  1351. var _this = this;
  1352. this.$refs[formName].validate(valid => {
  1353. if (valid) {
  1354. if (_this.templateForm.id in _this.adviceTemplateMaps) {
  1355. var mapid = _this.templateForm.id;
  1356. for (const index in _this.adviceTemplateMaps[mapid]
  1357. .DoctorAdviceTemplate) {
  1358. this.editRowKey++;
  1359. var item = {advice_name:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].advice_name,
  1360. advice_desc:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].advice_desc,
  1361. single_dose:"" +_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].single_dose,
  1362. single_dose_unit:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].single_dose_unit,
  1363. drug_spec:"" +_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec,
  1364. drug_spec_unit:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_spec_unit,
  1365. prescribing_number:"" +_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].prescribing_number,
  1366. prescribing_number_unit:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].prescribing_number_unit,
  1367. delivery_way:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].delivery_way,
  1368. execution_frequency:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].execution_frequency,
  1369. isEdit: 0,
  1370. id: 0,
  1371. children: [],
  1372. parent_row: 0,
  1373. row_key: this.editRowKey
  1374. };
  1375. if (
  1376. "children" in
  1377. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index] &&
  1378. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1379. .children
  1380. ) {
  1381. var parentRow = this.editRowKey;
  1382. var children =
  1383. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1384. .children;
  1385. for (const key in children) {
  1386. this.editRowKey++;
  1387. var child = {
  1388. advice_name: children[key].advice_name,
  1389. advice_desc: children[key].advice_desc,
  1390. single_dose: "" + children[key].single_dose,
  1391. single_dose_unit: children[key].single_dose_unit,
  1392. drug_spec: "" + children[key].drug_spec,
  1393. drug_spec_unit: children[key].drug_spec_unit,
  1394. prescribing_number: "" + children[key].prescribing_number,
  1395. prescribing_number_unit:
  1396. children[key].prescribing_number_unit,
  1397. delivery_way: children[key].delivery_way,
  1398. execution_frequency: children[key].execution_frequency,
  1399. isEdit: 0,
  1400. id: 0,
  1401. children: [],
  1402. parent_row: parentRow,
  1403. row_key: this.editRowKey
  1404. };
  1405. item.children.push(child);
  1406. }
  1407. _this.$set(item, "children", item.children);
  1408. }
  1409. _this.groupForm.adviceNames.unshift(item);
  1410. }
  1411. }
  1412. _this.templateFormVisible = false;
  1413. }
  1414. });
  1415. },
  1416. openAdviceTemplate() {
  1417. this.templateForm = { id: "" };
  1418. this.selectedTemp = { id: 0, name: "", org_id: 0, list: [], rows: [] };
  1419. this.selectedTemplate = [];
  1420. if (typeof this.$refs.templatetable !== "undefined") {
  1421. this.$refs.templatetable.setCurrentRow(null);
  1422. }
  1423. this.templateFormVisible = true;
  1424. },
  1425. selectGroupAdvice(row) {
  1426. this.groupSelectRow = row;
  1427. },
  1428. groupClassName({ row, rowIndex }) {
  1429. row.index = rowIndex;
  1430. },
  1431. getRowKey(row) {
  1432. return row.row_key;
  1433. },
  1434. resetForm(formName) {
  1435. this.$refs[formName].resetFields();
  1436. },
  1437. open() {
  1438. this.groupAddFormVisible = true;
  1439. this.groupSelectRow = null;
  1440. if (typeof this.$refs.advicenametable !== "undefined") {
  1441. this.$refs.advicenametable.setCurrentRow(null);
  1442. }
  1443. this.editRowKey = 0;
  1444. this.groupForm = {
  1445. advice_type: 2,
  1446. advice_date: this.recordDate,
  1447. start_time: "",
  1448. adviceNames: [],
  1449. advice_doctor: "",
  1450. remark: "",
  1451. parent_id: 0
  1452. };
  1453. var xtuser = this.$store.getters.xt_user;
  1454. // this.orgname = xtuser.org.org_name;
  1455. this.adminusername = xtuser.user.user_name;
  1456. },
  1457. selectAllTemplateAdvice(selection) {
  1458. var adviceArray = this.adviceTemplateMaps[this.selectedTemp.id]
  1459. .DoctorAdviceTemplate;
  1460. for (let y = 0; y < adviceArray.length; y++) {
  1461. adviceArray[y].selection = false;
  1462. }
  1463. if (selection.length > 0) {
  1464. for (let y = 0; y < adviceArray.length; y++) {
  1465. for (let i = 0; i < selection.length; i++) {
  1466. if (adviceArray[y].id == selection[i].advice_id) {
  1467. adviceArray[y].selection = true;
  1468. }
  1469. }
  1470. }
  1471. }
  1472. },
  1473. cancleDialog() {
  1474. this.templateFormVisible = false;
  1475. for (const indexs in this.adviceTemplateMaps) {
  1476. const adviceTemplate = this.adviceTemplateMaps[indexs];
  1477. for (const index in adviceTemplate.DoctorAdviceTemplate) {
  1478. adviceTemplate.DoctorAdviceTemplate[index].selection = false;
  1479. }
  1480. }
  1481. },
  1482. rand(min, max) {
  1483. return Math.floor(Math.random() * (max - min)) + min;
  1484. },
  1485. //
  1486. getSelfMedicalList(){
  1487. const params = {
  1488. patient_id:this.$route.query.patient_id
  1489. }
  1490. getSelfMedicalList(params).then(response=>{
  1491. if (response.data.state == 1) {
  1492. this.arr_drug = []
  1493. var medicalList = response.data.data.private_drug_list
  1494. var base_drug_list = response.data.data.base_drug_list
  1495. var base_drug_cofig = response.data.data.base_drug_config
  1496. var private_drug_cofig = response.data.data.private_drug_config
  1497. if(private_drug_cofig != null&&private_drug_cofig.drug_start == 1) {
  1498. for (let i = 0; i < medicalList.length; i++) {
  1499. if(medicalList[i].drug_specs != null) {
  1500. for (let a = 0; a < medicalList[i].drug_specs.length; a++) {
  1501. medicalList[i].drug_specs[a]['type'] = 2
  1502. }
  1503. }
  1504. let obj = {
  1505. drug_name: "",
  1506. drug_desc: "",
  1507. delivery_way: "",
  1508. execution_frequency: "",
  1509. single_dose: "",
  1510. single_dose_unit: "",
  1511. prescribing_number: "",
  1512. prescribing_number_unit: "",
  1513. type_id: "",
  1514. type: "",
  1515. custom_id: "",
  1516. drug_specs: [],
  1517. }
  1518. medicalList[i].drug_name = medicalList[i].drug_name + "(自备药)"
  1519. obj.drug_name = medicalList[i].drug_name
  1520. obj.delivery_way = medicalList[i].delivery_way
  1521. obj.execution_frequency = medicalList[i].execution_frequency
  1522. obj.single_dose = medicalList[i].single_dose
  1523. obj.prescribing_number = medicalList[i].prescribing_number
  1524. obj.type_id = medicalList[i].id
  1525. obj.type = 2
  1526. obj.custom_id = this.rand(10000000, 99999999)
  1527. obj.drug_specs = medicalList[i].drug_specs
  1528. this.all_drug.push(obj)
  1529. }
  1530. }
  1531. for (let i = 0; i < base_drug_list.length; i++) {
  1532. if(base_drug_list[i].drug_specs != null) {
  1533. for (let a = 0; a < base_drug_list[i].drug_specs.length; a++) {
  1534. base_drug_list[i].drug_specs[a]['type'] = 1
  1535. }
  1536. }
  1537. let obj = {
  1538. drug_name: "",
  1539. drug_desc: "",
  1540. delivery_way: "",
  1541. execution_frequency: "",
  1542. single_dose: "",
  1543. single_dose_unit: "",
  1544. prescribing_number: "",
  1545. prescribing_number_unit: "",
  1546. type_id: "",
  1547. type: "",
  1548. custom_id: "",
  1549. drug_specs: [],
  1550. }
  1551. obj.drug_name = base_drug_list[i].drug_name
  1552. obj.delivery_way = base_drug_list[i].delivery_way
  1553. obj.execution_frequency = base_drug_list[i].execution_frequency
  1554. obj.single_dose = base_drug_list[i].single_dose
  1555. obj.prescribing_number = base_drug_list[i].prescribing_number
  1556. obj.type_id = base_drug_list[i].id
  1557. obj.type = 1
  1558. obj.custom_id = this.rand(10000000, 99999999)
  1559. obj.drug_specs = base_drug_list[i].drug_specs
  1560. this.all_drug.push(obj)
  1561. }
  1562. }
  1563. })
  1564. },
  1565. changeDrugName(name){
  1566. this.current_drug_name = name
  1567. this.nameForm.advice_desc = ''
  1568. this.drugSpec = []
  1569. for (let i = 0; i < this.all_drug.length; i++) {
  1570. if (this.all_drug[i].drug_name == name) {
  1571. this.drugSpec = this.all_drug[i].drug_specs
  1572. }
  1573. }
  1574. },
  1575. changeDrugDesc(name) {
  1576. this.current_drug_spec = name
  1577. for (let i = 0; i < this.drugSpec.length; i++) {
  1578. if (this.drugSpec[i].drug_spec == name) {
  1579. this.nameForm.advice_desc = this.drugSpec[i].drug_spec
  1580. this.nameForm.prescribing_number = this.drugSpec[i].prescribing_number.toString()
  1581. this.nameForm.single_dose = this.drugSpec[i].single_dose.toString()
  1582. this.nameForm.delivery_way = this.drugSpec[i].delivery_way.toString()
  1583. this.nameForm.execution_frequency = this.drugSpec[i].execution_frequency.toString()
  1584. this.drug_id = this.drugSpec[i].id
  1585. this.src_type = this.drugSpec[i].type
  1586. this.nameForm.drug_id = this.drugSpec[i].id
  1587. this.nameForm.way = this.drugSpec[i].type
  1588. }
  1589. }
  1590. }
  1591. },
  1592. watch: {
  1593. "selectedTemp.list": function() {
  1594. this.calcselectedTemp();
  1595. }
  1596. },
  1597. created(){
  1598. //获取自备药
  1599. this.getSelfMedicalList()
  1600. }
  1601. };
  1602. </script>
  1603. <style>
  1604. #user-edit-advice-name-table .el-table__row {
  1605. display: table-row !important;
  1606. }
  1607. #user-edit-advice-name-table .el-table__expand-icon {
  1608. -webkit-transform: rotate(90deg) !important;
  1609. transform: rotate(90deg) !important;
  1610. }
  1611. #dialysis-add-select-template-table .el-table__row {
  1612. display: table-row !important;
  1613. }
  1614. #dialysis-add-select-template-table .el-table__expand-icon {
  1615. -webkit-transform: rotate(90deg) !important;
  1616. transform: rotate(90deg) !important;
  1617. }
  1618. </style>