Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

EditGroupAdvice.vue 93KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491
  1. <template>
  2. <div id="user-edit-group-advice">
  3. <el-dialog
  4. title="编辑医嘱"
  5. :visible.sync="groupEditFormVisible"
  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 label="开始时间 :" required prop="start_time">
  22. <el-date-picker
  23. type="datetime"
  24. format="yyyy-MM-dd HH:mm"
  25. value-format="yyyy-MM-dd HH:mm"
  26. placeholder="选择时间"
  27. v-model="groupForm.start_time"
  28. ></el-date-picker>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. <el-row>
  33. <el-col :span="12">
  34. <el-form-item label="开嘱医生 :">
  35. <span>{{ adminusername }} </span>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="12">
  39. <el-form-item label="开嘱时间 :">
  40. <span>{{ groupForm.advice_date }} </span>
  41. </el-form-item>
  42. </el-col>
  43. </el-row>
  44. <el-row>
  45. <el-col :span="2">&nbsp;&nbsp;</el-col>
  46. <el-col :span="5">
  47. <el-button
  48. :disabled="
  49. $store.getters.xt_user.subscibe.state == 3 ? true : false
  50. "
  51. round
  52. @click="openAdviceTemplate()"
  53. >选择医嘱模板
  54. </el-button>
  55. </el-col>
  56. <el-col :span="5">
  57. <el-button
  58. :disabled="
  59. $store.getters.xt_user.subscibe.state == 3 ? true : false
  60. "
  61. round
  62. @click="openGroupAdvice(0)"
  63. >新增医嘱内容
  64. </el-button>
  65. </el-col>
  66. <el-col :span="5">
  67. <el-button
  68. :disabled="
  69. $store.getters.xt_user.subscibe.state == 3 ? true : false
  70. "
  71. round
  72. @click="openGroupAdvice(1)"
  73. >修改医嘱内容
  74. </el-button>
  75. </el-col>
  76. <el-col :span="5">
  77. <el-button
  78. :disabled="
  79. $store.getters.xt_user.subscibe.state == 3 ? true : false
  80. "
  81. round
  82. @click="openDeleteGroupAdvice()"
  83. >删除医嘱内容
  84. </el-button>
  85. </el-col>
  86. </el-row>
  87. <el-row>
  88. <el-col :span="24">
  89. <el-table
  90. id="user-edit-advice-name-table"
  91. :data="groupForm.adviceNames"
  92. border
  93. fit
  94. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  95. highlight-current-row
  96. :row-class-name="groupClassName"
  97. @current-change="selectGroupAdvice"
  98. style="width: 100%;margin-top: 10px;margin-bottom: 10px;"
  99. :row-key="getRowKey"
  100. ref="advicenametable"
  101. >
  102. <el-table-column
  103. label="医嘱名称"
  104. property="advice_name"
  105. align="center"
  106. style="word-break: keep-all;white-space:nowrap;"
  107. ></el-table-column>
  108. <el-table-column
  109. label="药品规格"
  110. property="advice_desc"
  111. align="center"
  112. >
  113. <template slot-scope="scope">
  114. <span v-if="scope.row.advice_desc"
  115. >{{ scope.row.advice_desc
  116. }}{{ scope.row.drug_spec_unit }}</span
  117. >
  118. </template>
  119. </el-table-column>
  120. <!-- <el-table-column label="药品规格*数量" min-width="80" property="drug_spec" align="center">
  121. <template slot-scope="scope">
  122. <span
  123. v-if="scope.row.drug_spec!=0"
  124. >{{scope.row.drug_spec}}{{scope.row.drug_spec_unit}}</span>
  125. <span
  126. v-if="scope.row.prescribing_number!=0"
  127. >*{{scope.row.prescribing_number}}{{scope.row.prescribing_number_unit}}</span>
  128. </template>
  129. </el-table-column> -->
  130. <el-table-column
  131. label="开药数量"
  132. min-width="80"
  133. property="prescribing_number"
  134. align="center"
  135. >
  136. <template slot-scope="scope">
  137. <span v-if="scope.row.prescribing_number != 0"
  138. >{{ scope.row.prescribing_number
  139. }}{{ scope.row.prescribing_number_unit }}</span
  140. >
  141. </template>
  142. </el-table-column>
  143. <el-table-column
  144. label="单次用量"
  145. min-width="80"
  146. property="single_dose"
  147. align="center"
  148. >
  149. <template slot-scope="scope">
  150. <span v-if="scope.row.single_dose != 0"
  151. >{{ scope.row.single_dose
  152. }}{{ scope.row.single_dose_unit }}</span
  153. >
  154. </template>
  155. </el-table-column>
  156. <el-table-column
  157. label="给药途径"
  158. min-width="80"
  159. property="delivery_way"
  160. align="center"
  161. >
  162. <template slot-scope="scope">
  163. <span v-if="scope.row.parent_row == 0">{{
  164. scope.row.delivery_way
  165. }}</span>
  166. </template>
  167. </el-table-column>
  168. <el-table-column
  169. label="执行频率"
  170. min-width="80"
  171. property="execution_frequency"
  172. align="center"
  173. >
  174. <template slot-scope="scope">
  175. <span v-if="scope.row.parent_row == 0">{{
  176. scope.row.execution_frequency
  177. }}</span>
  178. </template>
  179. </el-table-column>
  180. <el-table-column
  181. label="医嘱嘱托"
  182. min-width="80"
  183. property="remark"
  184. align="center"
  185. >
  186. <template slot-scope="scope">
  187. <span v-if="scope.row.parent_row == 0">{{
  188. scope.row.remark
  189. }}</span>
  190. </template>
  191. </el-table-column>
  192. </el-table>
  193. </el-col>
  194. </el-row>
  195. </el-form>
  196. <span slot="footer" class="dialog-footer">
  197. <el-button @click="groupEditFormVisible = false">取 消</el-button>
  198. <el-button type="primary" @click="SaveEditAdvices">保 存</el-button>
  199. </span>
  200. </el-dialog>
  201. <el-dialog
  202. title="选择医嘱模板"
  203. :visible.sync="templateFormVisible"
  204. width="72%"
  205. :close-on-click-modal="false"
  206. >
  207. <el-row :gutter="20">
  208. <el-col :span="8">
  209. <el-table
  210. :data="adviceTemplates"
  211. ref="templatetable"
  212. border
  213. highlight-current-row
  214. @current-change="templateTableChange"
  215. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  216. style="width: 100%"
  217. >
  218. <el-table-column prop="name" align="center" label="模板名称">
  219. </el-table-column>
  220. </el-table>
  221. </el-col>
  222. <el-col :span="16">
  223. <el-table
  224. id="dialysis-update-select-template-table"
  225. :data="selectedTemp.list"
  226. border
  227. :span-method="spanselecttable"
  228. @select="selectAdvice"
  229. @selection-change="changeAdvice"
  230. @select-all="selectAllTemplateAdvice"
  231. row-key="row_key"
  232. ref="selecttemplatetable"
  233. style="width: 100%"
  234. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)' }"
  235. >
  236. <el-table-column type="selection" width="55"> </el-table-column>
  237. <el-table-column
  238. label="医嘱内容"
  239. property="advice_name"
  240. align="center"
  241. style="word-break: keep-all;white-space:nowrap;"
  242. ></el-table-column>
  243. <el-table-column label="规格" align="center">
  244. <template slot-scope="scope">
  245. <span v-if="scope.row.advice_desc"
  246. >{{ scope.row.advice_desc
  247. }}{{ scope.row.drug_spec_unit }}</span
  248. >
  249. </template>
  250. </el-table-column>
  251. <el-table-column
  252. label="开药数量"
  253. min-width="80"
  254. property="prescribing_number"
  255. align="center"
  256. >
  257. <template slot-scope="scope">
  258. <span v-if="scope.row.prescribing_number != 0"
  259. >{{ scope.row.prescribing_number
  260. }}{{ scope.row.prescribing_number_unit }}</span
  261. >
  262. </template>
  263. </el-table-column>
  264. <el-table-column
  265. label="单次用量"
  266. min-width="80"
  267. property="single_dose"
  268. align="center"
  269. >
  270. <template slot-scope="scope">
  271. <span v-if="scope.row.single_dose != 0"
  272. >{{ scope.row.single_dose
  273. }}{{ scope.row.single_dose_unit }}</span
  274. >
  275. </template>
  276. </el-table-column>
  277. <el-table-column
  278. label="给药途径"
  279. min-width="80"
  280. property="delivery_way"
  281. align="center"
  282. >
  283. <template slot-scope="scope">
  284. <span v-if="scope.row.parent_row == 0">{{
  285. scope.row.delivery_way
  286. }}</span>
  287. </template>
  288. </el-table-column>
  289. <el-table-column
  290. label="执行频率"
  291. min-width="80"
  292. property="execution_frequency"
  293. align="center"
  294. >
  295. <template slot-scope="scope">
  296. <span v-if="scope.row.parent_row == 0">{{
  297. scope.row.execution_frequency
  298. }}</span>
  299. </template>
  300. </el-table-column>
  301. </el-table>
  302. </el-col>
  303. </el-row>
  304. <div slot="footer" class="dialog-footer">
  305. <el-button @click="cancleDialog()">取消</el-button>
  306. <el-button
  307. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  308. type="primary"
  309. @click="newAddTempForm()"
  310. >保 存
  311. </el-button>
  312. </div>
  313. </el-dialog>
  314. <el-dialog
  315. title="选择医嘱模板"
  316. :visible.sync="oldTemplateFormVisible"
  317. width="700px"
  318. >
  319. <el-form ref="templateForm" :rules="templateRules" :model="templateForm">
  320. <el-row>
  321. <el-col :span="24">
  322. <el-form-item prop="id">
  323. <el-select
  324. v-model="templateForm.id"
  325. filterable
  326. clearable
  327. placeholder="请选择(输入可搜索)"
  328. style="width:100%"
  329. >
  330. <el-option
  331. v-for="item in adviceTemplates"
  332. :key="item.id"
  333. :label="item.name"
  334. :value="item.id"
  335. ></el-option>
  336. </el-select>
  337. </el-form-item>
  338. </el-col>
  339. </el-row>
  340. </el-form>
  341. <div slot="footer" class="dialog-footer">
  342. <el-button @click="templateFormVisible = false">取消</el-button>
  343. <el-button
  344. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  345. type="primary"
  346. @click="addTempForm('templateForm')"
  347. >保 存
  348. </el-button>
  349. </div>
  350. </el-dialog>
  351. <el-dialog
  352. :title="nameFormTitle"
  353. :visible.sync="nameFormVisible"
  354. width="800px"
  355. >
  356. <el-form
  357. ref="nameForm"
  358. :rules="nameRules"
  359. :model="nameForm"
  360. label-width="120px"
  361. >
  362. <el-row>
  363. <el-col :span="10">
  364. <el-form-item label="医嘱内容 :" required prop="advice_name">
  365. <!-- <el-input v-model="nameForm.advice_name"></el-input> -->
  366. <!-- <el-select
  367. v-model="nameForm.advice_name"
  368. filterable
  369. clearable
  370. allow-create
  371. :disabled="isChild"
  372. placeholder="请选择(输入可搜索)"
  373. style="width:200px"
  374. @change="changeDrugName"
  375. >
  376. <el-option
  377. v-for="(item,index) in all_drug"
  378. :key="index"
  379. :label="item.drug_name"
  380. :value="item.drug_name"
  381. ></el-option>
  382. </el-select> -->
  383. <el-autocomplete
  384. style="width:100%;"
  385. class="inline-input"
  386. v-model="nameForm.advice_name"
  387. :fetch-suggestions="querySearch"
  388. placeholder="请输入内容"
  389. @input="changeDrugName"
  390. ></el-autocomplete>
  391. </el-form-item>
  392. </el-col>
  393. <el-col :span="14">
  394. <!--<el-form-item label="规格 :" prop="advice_desc">-->
  395. <!--<el-input v-model="nameForm.advice_desc"></el-input>-->
  396. <!--</el-form-item>-->
  397. <el-form-item label="药品规格 :" prop="advice_desc">
  398. <el-col :span="10">
  399. <!-- <el-input v-model="nameForm.advice_desc"></el-input> -->
  400. <!-- <el-select
  401. v-model="nameForm.advice_desc"
  402. filterable
  403. clearable
  404. allow-create
  405. :disabled="isChild"
  406. placeholder="请选择(输入可搜索)"
  407. style="width:150px"
  408. @change="changeDrugDesc"
  409. >
  410. <el-option
  411. v-for="item in drugSpec"
  412. :key="item.id"
  413. :label="item.drug_spec"
  414. :value="item.drug_spec"
  415. ></el-option>
  416. </el-select> -->
  417. <el-autocomplete
  418. style="width:100px;"
  419. class="inline-input"
  420. v-model="nameForm.advice_desc"
  421. :fetch-suggestions="querySearch1"
  422. placeholder="请输入内容"
  423. @input="changeDrugDesc"
  424. ></el-autocomplete>
  425. </el-col>
  426. <el-col class="line" :span="2">&nbsp;</el-col>
  427. <el-col :span="10">
  428. <el-select
  429. v-model="nameForm.drug_spec_unit"
  430. filterable
  431. clearable
  432. allow-create
  433. placeholder="选择"
  434. >
  435. <el-option
  436. v-for="item in unitsOption"
  437. :key="item.id"
  438. :label="item.name"
  439. :value="item.name"
  440. ></el-option>
  441. </el-select>
  442. </el-col>
  443. </el-form-item>
  444. </el-col>
  445. </el-row>
  446. <el-row>
  447. <el-col :span="12">
  448. <el-form-item label="开药数量 :" prop="prescribing_number">
  449. <el-col :span="8">
  450. <el-input v-model="nameForm.prescribing_number"></el-input>
  451. </el-col>
  452. <el-col class="line" :span="2">&nbsp;</el-col>
  453. <el-col :span="14">
  454. <el-select
  455. v-model="nameForm.prescribing_number_unit"
  456. filterable
  457. clearable
  458. allow-create
  459. placeholder="选择"
  460. >
  461. <el-option
  462. v-for="item in unitsOption"
  463. :key="item.id"
  464. :label="item.name"
  465. :value="item.name"
  466. ></el-option>
  467. </el-select>
  468. </el-col>
  469. </el-form-item>
  470. </el-col>
  471. <el-col :span="12">
  472. <el-form-item label="单次用量 :" prop="single_dose">
  473. <el-col :span="8">
  474. <el-input v-model="nameForm.single_dose"></el-input>
  475. </el-col>
  476. <el-col class="line" :span="2">&nbsp;</el-col>
  477. <el-col :span="14">
  478. <el-select
  479. v-model="nameForm.single_dose_unit"
  480. filterable
  481. clearable
  482. allow-create
  483. placeholder="选择"
  484. >
  485. <el-option
  486. v-for="item in unitsOption"
  487. :key="item.id"
  488. :label="item.name"
  489. :value="item.name"
  490. ></el-option>
  491. </el-select>
  492. </el-col>
  493. </el-form-item>
  494. </el-col>
  495. </el-row>
  496. <el-row>
  497. <el-col :span="12">
  498. <el-form-item label="给药途径 :" prop="delivery_way">
  499. <el-select
  500. v-model="nameForm.delivery_way"
  501. filterable
  502. clearable
  503. allow-create
  504. :disabled="isChild"
  505. placeholder="请选择(输入可搜索)"
  506. style="width:100%"
  507. >
  508. <el-option
  509. v-for="item in deliveryWayOptions"
  510. :key="item.id"
  511. :label="item.name"
  512. :value="item.name"
  513. ></el-option>
  514. </el-select>
  515. </el-form-item>
  516. </el-col>
  517. <el-col :span="12">
  518. <el-form-item label="执行频率 :" prop="execution_frequency">
  519. <el-select
  520. v-model="nameForm.execution_frequency"
  521. filterable
  522. clearable
  523. allow-create
  524. :disabled="isChild"
  525. placeholder="请选择(输入可搜索)"
  526. style="width:100%"
  527. >
  528. <el-option
  529. v-for="item in executionFrequencyOptions"
  530. :key="item.id"
  531. :label="item.name"
  532. :value="item.name"
  533. ></el-option>
  534. </el-select>
  535. </el-form-item>
  536. </el-col>
  537. </el-row>
  538. </el-form>
  539. <div slot="footer" class="dialog-footer">
  540. <el-button @click="nameFormVisible = false">取消</el-button>
  541. <el-button
  542. :disabled="$store.getters.xt_user.subscibe.state == 3 ? true : false"
  543. type="primary"
  544. @click="submitNameForm('nameForm')"
  545. >保 存
  546. </el-button>
  547. </div>
  548. </el-dialog>
  549. </div>
  550. </template>
  551. <script>
  552. import {
  553. CreateDoctorAdvice,
  554. CreateGroupAdvice,
  555. DeleteDoctorAdvice,
  556. DeleteGroupAdvice,
  557. EditDoctorAdvice,
  558. getAdviceConfig,
  559. getDoctorAdviceList,
  560. StopDoctorAdvice,
  561. SaveEditAdvices
  562. } from "@/api/advice";
  563. import { jsGetAge, uParseTime } from "@/utils/tools";
  564. import { getSelfMedicalList,getDrugDescByDrugName } from "@/api/drug/drug"
  565. export default {
  566. name: "AddGroupAdvice",
  567. data() {
  568. return {
  569. editRowKey: 0,
  570. oldTemplateFormVisible: false,
  571. templateFormVisible: false,
  572. groupEditFormVisible: false,
  573. nameFormVisible: false,
  574. groupSelectRow: null,
  575. nameFormTitle: "",
  576. isChild: false,
  577. isEdit: false,
  578. groupRules: {
  579. advice_type: [{ required: true, message: "请选择医嘱类型" }],
  580. advice_date: [{ required: true, message: "请选择医嘱时间" }],
  581. start_time: [{ required: true, message: "请选择开始时间" }],
  582. advice_name: [{ required: true, message: "请填写医嘱名称" }],
  583. advice_doctor: [{ required: true, message: "请选择开嘱医生" }]
  584. },
  585. nameRules: {
  586. advice_name: [{ required: true, message: "请填写医嘱内容" }]
  587. },
  588. templateRules: {
  589. id: [{ required: true, message: "请选择医嘱模板" }]
  590. },
  591. templateForm: { id: "" },
  592. nameForm: {
  593. advice_name: "",
  594. advice_desc: "",
  595. single_dose: "",
  596. single_dose_unit: "",
  597. drug_spec: "",
  598. drug_spec_unit: "",
  599. prescribing_number: "",
  600. prescribing_number_unit: "",
  601. delivery_way: "",
  602. execution_frequency: "",
  603. isEdit: 0,
  604. index: 0,
  605. id: 0,
  606. children: [],
  607. drug_id:"",
  608. way:"",
  609. drug_name_id:"",
  610. },
  611. submitGroupForm: {
  612. advice_type: "",
  613. advice_date: "",
  614. start_time: "",
  615. adviceNames: [],
  616. advice_doctor: "",
  617. remark: "",
  618. parent_id: 0,
  619. drug_name_id:"",
  620. drug_id:"",
  621. way:""
  622. },
  623. groupForm: {
  624. advice_type: "",
  625. advice_date: "",
  626. start_time: "",
  627. adviceNames: [],
  628. advice_doctor: "",
  629. remark: "",
  630. parent_id: 0,
  631. way:"",
  632. drug_id:"",
  633. drug_name_id:"",
  634. },
  635. adminusername: "",
  636. selectedTemp: { id: 0, name: "", org_id: 0, list: [], rows: [] },
  637. selectedTemplate: [],
  638. allSelectedTemplate: [],
  639. medicals:[],
  640. drugSpec:[],
  641. all_drug:[],
  642. current_drug_name:"",
  643. current_drug_spec: "",
  644. drug_id: 0,
  645. src_type:"",
  646. drug_name_id:0,
  647. };
  648. },
  649. props: {
  650. patientID: 0,
  651. adviceType: 0,
  652. rowKey: 0,
  653. groupNo: 0,
  654. adviceTemplates: {
  655. type: Array,
  656. default: function() {
  657. return [];
  658. }
  659. },
  660. recordDate: "",
  661. adviceTypeOptions: {
  662. type: Array,
  663. default: function() {
  664. return [];
  665. }
  666. },
  667. deliveryWayOptions: {
  668. type: Array,
  669. default: () => []
  670. },
  671. unitsOption: {
  672. type: Array,
  673. default: function() {
  674. return [];
  675. }
  676. },
  677. executionFrequencyOptions: {
  678. type: Array,
  679. default: function() {
  680. return [];
  681. }
  682. },
  683. adviceTemplateMaps: {
  684. type: Object,
  685. default: function() {
  686. return {};
  687. }
  688. },
  689. adviceTableData: {
  690. type: Array,
  691. default: function() {
  692. return [];
  693. }
  694. },
  695. admin_users: {
  696. // 系统用户列表
  697. type: Array,
  698. default: () => {
  699. return [];
  700. }
  701. }
  702. },
  703. methods: {
  704. getXuserName(id) {
  705. if (id <= 0) {
  706. return "";
  707. }
  708. var name = "";
  709. if (
  710. this.admin_users == null ||
  711. typeof this.admin_users.length === "undefined"
  712. ) {
  713. return name;
  714. }
  715. var leng = this.admin_users.length;
  716. if (leng == 0) {
  717. return name;
  718. }
  719. for (let index = 0; index < leng; index++) {
  720. if (this.admin_users[index].id == id) {
  721. name = this.admin_users[index].name;
  722. break;
  723. }
  724. }
  725. return name;
  726. },
  727. openDeleteGroupAdvice() {
  728. if (this.groupSelectRow === null) {
  729. this.$message.error("未选择要删除的医嘱内容");
  730. return;
  731. }
  732. console.log(this.groupSelectRow);
  733. var content = "";
  734. if (this.groupSelectRow.children.length > 0) {
  735. content = "确认删除此医嘱内容,包括它的子药?";
  736. } else {
  737. content = "确认删除此医嘱内容?";
  738. }
  739. var isChild = !!this.groupSelectRow.parent_row;
  740. var title = isChild ? "删除子药内容" : "删除医嘱内容";
  741. var msg = isChild ? "确认删除此子药内容?" : content;
  742. this.$confirm(msg, title, {
  743. confirmButtonText: "确定",
  744. cancelButtonText: "取消",
  745. type: "warning"
  746. })
  747. .then(() => {
  748. let mode = "4";
  749. if (
  750. this.groupSelectRow.advice_doctor !=
  751. this.$store.getters.xt_user.user.id
  752. ) {
  753. mode = "5";
  754. }
  755. DeleteDoctorAdvice(this.groupSelectRow.id, mode).then(response => {
  756. if (response.data.state == 0) {
  757. this.$message.error(response.data.msg);
  758. return false;
  759. } else {
  760. this.$notify({
  761. title: "成功",
  762. message: "医嘱已经删除",
  763. type: "success",
  764. duration: 2000
  765. });
  766. var ale = this.groupForm.adviceNames.length;
  767. var atle = this.adviceTableData.length;
  768. for (let index = atle - 1; index >= 0; index--) {
  769. if (
  770. this.adviceTableData[index].parent_id ===
  771. this.groupSelectRow.id ||
  772. this.adviceTableData[index].id === this.groupSelectRow.id
  773. ) {
  774. this.adviceTableData.splice(index, 1);
  775. }
  776. }
  777. if (isChild) {
  778. for (const index in this.groupForm.adviceNames) {
  779. if (
  780. this.groupForm.adviceNames[index].row_key ==
  781. this.groupSelectRow.parent_row
  782. ) {
  783. for (const j in this.groupForm.adviceNames[index]
  784. .children) {
  785. if (
  786. this.groupForm.adviceNames[index].children[j].row_key ==
  787. this.groupSelectRow.row_key
  788. ) {
  789. this.groupForm.adviceNames[index].children.splice(j, 1);
  790. this.$set(
  791. this.groupForm.adviceNames,
  792. index,
  793. this.groupForm.adviceNames[index]
  794. );
  795. break;
  796. }
  797. }
  798. }
  799. }
  800. } else {
  801. for (const index in this.groupForm.adviceNames) {
  802. if (
  803. this.groupForm.adviceNames[index].row_key ==
  804. this.groupSelectRow.row_key
  805. ) {
  806. this.groupForm.adviceNames.splice(index, 1);
  807. break;
  808. }
  809. }
  810. }
  811. if (isChild) {
  812. for (const index in this.groupForm.adviceNames) {
  813. if (
  814. this.groupForm.adviceNames[index].row_key ==
  815. this.groupSelectRow.parent_row
  816. ) {
  817. for (const j in this.groupForm.adviceNames[index]
  818. .children) {
  819. if (
  820. this.groupForm.adviceNames[index].children[j].row_key ==
  821. this.groupSelectRow.row_key
  822. ) {
  823. this.groupForm.adviceNames[index].children.splice(j, 1);
  824. this.$set(
  825. this.groupForm.adviceNames,
  826. index,
  827. this.groupForm.adviceNames[index]
  828. );
  829. this.toggleRowExpansion();
  830. break;
  831. }
  832. }
  833. }
  834. }
  835. } else {
  836. for (const index in this.groupForm.adviceNames) {
  837. if (
  838. this.groupForm.adviceNames[index].row_key ==
  839. this.groupSelectRow.row_key
  840. ) {
  841. this.groupForm.adviceNames.splice(index, 1);
  842. this.toggleRowExpansion();
  843. break;
  844. }
  845. }
  846. }
  847. }
  848. });
  849. })
  850. .catch(() => {});
  851. },
  852. submitNameForm(formName) {
  853. if(this.src_type == ""){
  854. this.nameForm.way = 0
  855. this.nameForm.drug_id = 0
  856. this.nameForm.drug_name_id = 0
  857. }
  858. if(this.src_type == 2){ //自备药
  859. var arr = this.nameForm.advice_name.split("(自备药)")
  860. this.nameForm.advice_name = arr[0]
  861. }
  862. var _this = this;
  863. this.$refs[formName].validate(valid => {
  864. if (valid) {
  865. if (_this.nameForm.isEdit) {
  866. var submitForm = {
  867. advice_type: _this.groupForm.advice_type,
  868. advice_date: _this.groupForm.advice_date,
  869. start_time: _this.groupForm.start_time,
  870. advice_name: _this.nameForm.advice_name,
  871. advice_desc: _this.nameForm.advice_desc,
  872. single_dose: "" + _this.nameForm.single_dose,
  873. single_dose_unit: _this.nameForm.single_dose_unit,
  874. drug_spec: "" + _this.nameForm.drug_spec,
  875. drug_spec_unit: _this.nameForm.drug_spec_unit,
  876. prescribing_number: "" + _this.nameForm.prescribing_number,
  877. prescribing_number_unit: _this.nameForm.prescribing_number_unit,
  878. delivery_way: _this.nameForm.delivery_way,
  879. execution_frequency: _this.nameForm.execution_frequency,
  880. isEdit: 0,
  881. id: 0,
  882. advice_doctor: "",
  883. remark: _this.groupForm.remark,
  884. parent_id: _this.groupSelectRow.parent_id,
  885. groupno: _this.groupForm.groupno,
  886. drug_name_id:_this.groupForm.drug_name_id,
  887. drug_id:_this.groupForm.drug_id,
  888. way:_this.groupForm.way,
  889. };
  890. let mode = "2";
  891. if (
  892. this.groupSelectRow.advice_doctor !=
  893. this.$store.getters.xt_user.user.id
  894. ) {
  895. mode = "3";
  896. }
  897. console.log("22222",submitForm)
  898. EditDoctorAdvice(
  899. this.patientID,
  900. this.groupSelectRow.id,
  901. submitForm,
  902. mode
  903. ).then(response => {
  904. if (response.data.state == 0) {
  905. this.$message.error(response.data.msg);
  906. return false;
  907. } else {
  908. this.$notify({
  909. title: "成功",
  910. message: "修改医嘱成功",
  911. type: "success",
  912. duration: 2000
  913. });
  914. var ale = _this.groupForm.adviceNames.length;
  915. var atle = _this.adviceTableData.length;
  916. for (let index = 0; index < atle; index++) {
  917. if (
  918. _this.groupSelectRow.id == _this.adviceTableData[index].id
  919. ) {
  920. var advice = response.data.data.advice;
  921. _this.adviceTableData[index].drug_spec = advice.drug_spec;
  922. _this.adviceTableData[index].drug_spec_unit =
  923. advice.drug_spec_unit;
  924. _this.adviceTableData[index].start_time = advice.start_time;
  925. _this.adviceTableData[index].advice_name =
  926. advice.advice_name;
  927. _this.adviceTableData[index].advice_desc =
  928. advice.advice_desc;
  929. _this.adviceTableData[index].single_dose =
  930. advice.single_dose;
  931. _this.adviceTableData[index].single_dose_unit =
  932. advice.single_dose_unit;
  933. _this.adviceTableData[index].delivery_way =
  934. advice.delivery_way;
  935. _this.adviceTableData[index].execution_frequency =
  936. advice.execution_frequency;
  937. _this.adviceTableData[index].prescribing_number =
  938. advice.prescribing_number;
  939. _this.adviceTableData[index].prescribing_number_unit =advice.prescribing_number_unit;
  940. _this.adviceTableData[index].drug_name_id = advice.drug_name_id;
  941. _this.adviceTableData[index].drug_id = advice.drug_id,
  942. _this.adviceTableData[index].way = advice.way
  943. break;
  944. }
  945. }
  946. if (_this.isChild) {
  947. for (let index = 0; index < ale; index++) {
  948. if (
  949. _this.groupSelectRow.parent_row ==
  950. _this.groupForm.adviceNames[index].row_key
  951. ) {
  952. var cle =
  953. _this.groupForm.adviceNames[index].children.length;
  954. var children =
  955. _this.groupForm.adviceNames[index].children;
  956. for (let j = 0; j < ale; j++) {
  957. if (
  958. _this.groupSelectRow.row_key == children[j].row_key
  959. ) {
  960. _this.groupForm.adviceNames[index].children[
  961. j
  962. ].advice_name = _this.nameForm.advice_name;
  963. _this.groupForm.adviceNames[index].children[
  964. j
  965. ].advice_desc = _this.nameForm.advice_desc;
  966. _this.groupForm.adviceNames[index].children[
  967. j
  968. ].single_dose = "" + _this.nameForm.single_dose;
  969. _this.groupForm.adviceNames[index].children[
  970. j
  971. ].single_dose_unit = _this.nameForm.single_dose_unit;
  972. _this.groupForm.adviceNames[index].children[
  973. j
  974. ].drug_spec = "" + _this.nameForm.drug_spec;
  975. _this.groupForm.adviceNames[index].children[
  976. j
  977. ].drug_spec_unit = _this.nameForm.drug_spec_unit;
  978. _this.groupForm.adviceNames[index].children[
  979. j
  980. ].prescribing_number =
  981. "" + _this.nameForm.prescribing_number;
  982. _this.groupForm.adviceNames[index].children[
  983. j
  984. ].prescribing_number_unit =
  985. _this.nameForm.prescribing_number_unit;
  986. _this.groupForm.adviceNames[index].children[j].delivery_way = _this.nameForm.delivery_way;
  987. _this.groupForm.adviceNames[index].children[j].execution_frequency =_this.nameForm.execution_frequency;
  988. _this.groupForm.adviceNames[index].children[j].drug_id =_this.nameForm.drug_id;
  989. _this.groupForm.adviceNames[index].children[j].drug_name_id =_this.nameForm.drug_name_id;
  990. _this.groupForm.adviceNames[index].children[j].way =_this.nameForm.way;
  991. _this.$set(
  992. _this.groupForm.adviceNames[index].children,
  993. j,
  994. _this.groupForm.adviceNames[index].children[j]
  995. );
  996. break;
  997. }
  998. }
  999. }
  1000. }
  1001. } else {
  1002. for (let index = 0; index < ale; index++) {
  1003. if (
  1004. _this.groupSelectRow.row_key ==
  1005. _this.groupForm.adviceNames[index].row_key
  1006. ) {
  1007. _this.groupForm.adviceNames[index].advice_name =
  1008. _this.nameForm.advice_name;
  1009. _this.groupForm.adviceNames[index].advice_desc =
  1010. _this.nameForm.advice_desc;
  1011. _this.groupForm.adviceNames[index].single_dose =
  1012. "" + _this.nameForm.single_dose;
  1013. _this.groupForm.adviceNames[index].single_dose_unit =
  1014. _this.nameForm.single_dose_unit;
  1015. _this.groupForm.adviceNames[index].drug_spec =
  1016. "" + _this.nameForm.drug_spec;
  1017. _this.groupForm.adviceNames[index].drug_spec_unit =
  1018. _this.nameForm.drug_spec_unit;
  1019. _this.groupForm.adviceNames[index].prescribing_number =
  1020. "" + _this.nameForm.prescribing_number;
  1021. _this.groupForm.adviceNames[
  1022. index
  1023. ].prescribing_number_unit =
  1024. _this.nameForm.prescribing_number_unit;
  1025. _this.groupForm.adviceNames[index].delivery_way =
  1026. _this.nameForm.delivery_way;
  1027. _this.groupForm.adviceNames[index].execution_frequency =_this.nameForm.execution_frequency;
  1028. _this.groupForm.adviceNames[index].drug_name_id =_this.nameForm.drug_name_id;
  1029. _this.groupForm.adviceNames[index].drug_id =_this.nameForm.drug_id;
  1030. _this.groupForm.adviceNames[index].way =_this.nameForm.way;
  1031. _this.$set(
  1032. _this.groupForm.adviceNames,
  1033. index,
  1034. _this.groupForm.adviceNames[index]
  1035. );
  1036. break;
  1037. }
  1038. }
  1039. }
  1040. }
  1041. });
  1042. } else {
  1043. if (_this.isChild) {
  1044. var submitForm = {
  1045. advice_type: _this.groupForm.advice_type,
  1046. advice_date: _this.groupForm.advice_date,
  1047. start_time: _this.groupForm.start_time,
  1048. advice_name: _this.nameForm.advice_name,
  1049. advice_desc: _this.nameForm.advice_desc,
  1050. single_dose: "" + _this.nameForm.single_dose,
  1051. single_dose_unit: _this.nameForm.single_dose_unit,
  1052. drug_spec: "" + _this.nameForm.drug_spec,
  1053. drug_spec_unit: _this.nameForm.drug_spec_unit,
  1054. prescribing_number: "" + _this.nameForm.prescribing_number,
  1055. prescribing_number_unit: _this.nameForm.prescribing_number_unit,
  1056. delivery_way: _this.nameForm.delivery_way,
  1057. execution_frequency: _this.nameForm.execution_frequency,
  1058. drug_name_id:_this.nameForm.drug_name_id,
  1059. drug_id:_this.nameForm.drug_id,
  1060. way:_this.nameForm.way,
  1061. isEdit: 0,
  1062. id: 0,
  1063. advice_doctor: "",
  1064. remark: _this.groupForm.remark,
  1065. parent_id: _this.groupSelectRow.id,
  1066. groupno: _this.groupForm.groupno
  1067. };
  1068. let mode = "1";
  1069. CreateDoctorAdvice(this.patientID, submitForm, mode).then(
  1070. response => {
  1071. if (response.data.state == 0) {
  1072. this.$message.error(response.data.msg);
  1073. return false;
  1074. } else {
  1075. this.$notify({
  1076. title: "成功",
  1077. message: "新增子药成功",
  1078. type: "success",
  1079. duration: 2000
  1080. });
  1081. var spliceIndex = -1;
  1082. for (
  1083. let index = _this.adviceTableData.length - 1;
  1084. ;
  1085. index--
  1086. ) {
  1087. if (
  1088. _this.adviceTableData[index].parent_id ===
  1089. _this.groupSelectRow.id
  1090. ) {
  1091. spliceIndex = index;
  1092. break;
  1093. } else if (
  1094. _this.adviceTableData[index].id ===
  1095. _this.groupSelectRow.id
  1096. ) {
  1097. spliceIndex = index;
  1098. break;
  1099. }
  1100. }
  1101. if (spliceIndex > -1) {
  1102. spliceIndex += 1;
  1103. if (spliceIndex === _this.adviceTableData.length) {
  1104. _this.adviceTableData.push(response.data.data.advice);
  1105. } else {
  1106. _this.adviceTableData.splice(
  1107. spliceIndex,
  1108. 0,
  1109. response.data.data.advice
  1110. );
  1111. }
  1112. }
  1113. var ale = _this.groupForm.adviceNames.length;
  1114. for (let index = 0; index < ale; index++) {
  1115. if (
  1116. _this.nameForm.parent_row ==
  1117. _this.groupForm.adviceNames[index].row_key
  1118. ) {
  1119. _this.editRowKey++;
  1120. _this.nameForm.row_key = _this.editRowKey;
  1121. _this.groupForm.adviceNames[index].children.push(
  1122. _this.nameForm
  1123. );
  1124. _this.$set(
  1125. _this.groupForm.adviceNames,
  1126. index,
  1127. _this.groupForm.adviceNames[index]
  1128. );
  1129. break;
  1130. }
  1131. }
  1132. // _this.resetForm(formName);
  1133. return false;
  1134. }
  1135. }
  1136. );
  1137. } else {
  1138. _this.submitGroupForm = {
  1139. advice_type: _this.groupForm.advice_type,
  1140. advice_date: _this.groupForm.advice_date,
  1141. start_time: _this.groupForm.start_time,
  1142. adviceNames: [
  1143. {
  1144. advice_name: _this.nameForm.advice_name,
  1145. advice_desc: _this.nameForm.advice_desc,
  1146. single_dose: "" + _this.nameForm.single_dose,
  1147. single_dose_unit: _this.nameForm.single_dose_unit,
  1148. drug_spec: "" + _this.nameForm.drug_spec,
  1149. drug_spec_unit: _this.nameForm.drug_spec_unit,
  1150. prescribing_number: "" + _this.nameForm.prescribing_number,
  1151. prescribing_number_unit:
  1152. _this.nameForm.prescribing_number_unit,
  1153. delivery_way: _this.nameForm.delivery_way,
  1154. execution_frequency: _this.nameForm.execution_frequency,
  1155. drug_name_id:_this.nameForm.drug_name_id,
  1156. drug_id:_this.nameForm.drug_id,
  1157. way:_this.nameForm.way,
  1158. isEdit: 0,
  1159. id: 0,
  1160. children: [],
  1161. parent_row: 0
  1162. }
  1163. ],
  1164. advice_doctor: "",
  1165. remark: _this.groupForm.remark,
  1166. parent_id: 0
  1167. };
  1168. let mode = "1";
  1169. CreateGroupAdvice(
  1170. _this.patientID,
  1171. _this.groupForm.groupno,
  1172. _this.submitGroupForm,
  1173. mode
  1174. ).then(response => {
  1175. if (response.data.state == 0) {
  1176. _this.$message.error(response.data.msg);
  1177. return false;
  1178. } else {
  1179. _this.$notify({
  1180. title: "成功",
  1181. message: "新增成功",
  1182. type: "success",
  1183. duration: 2000
  1184. });
  1185. // var alen = response.data.data.advices.length
  1186. // for (let index = alen-1; index >=0; index--) {
  1187. // _this.adviceTableData.unshift(response.data.data.advices[index]);
  1188. // }
  1189. // for (const index in response.data.data.advices) {
  1190. // _this.adviceTableData.unshift(response.data.data.advices[index]);
  1191. // }
  1192. var groups = response.data.data.advices;
  1193. var childMap = {};
  1194. for (const index in groups) {
  1195. if (groups[index].parent_id == 0) {
  1196. continue;
  1197. }
  1198. if (groups[index].parent_id in childMap === false) {
  1199. childMap[groups[index].parent_id] = [];
  1200. }
  1201. childMap[groups[index].parent_id].push(groups[index]);
  1202. }
  1203. var parentArr = [];
  1204. for (const index in groups) {
  1205. if (groups[index].parent_id > 0) {
  1206. continue;
  1207. }
  1208. parentArr.push(groups[index]);
  1209. }
  1210. var groupNo = groups[0].groupno;
  1211. var newData = { groupNo: parentArr };
  1212. for (const index in _this.adviceTableData) {
  1213. if (_this.adviceTableData[index].groupno == groupNo) {
  1214. for (const i in parentArr) {
  1215. if (parentArr[i].id in childMap) {
  1216. for (const j in childMap[parentArr[i].id]) {
  1217. _this.adviceTableData.splice(
  1218. index,
  1219. 0,
  1220. childMap[parentArr[i].id][j]
  1221. );
  1222. }
  1223. }
  1224. _this.adviceTableData.splice(index, 0, parentArr[i]);
  1225. }
  1226. break;
  1227. }
  1228. }
  1229. for (const index in groups) {
  1230. if (groups[index].parent_id > 0) {
  1231. continue;
  1232. }
  1233. _this.editRowKey++;
  1234. var item = {
  1235. advice_name: groups[index].advice_name,
  1236. advice_desc: groups[index].advice_desc,
  1237. single_dose: "" + groups[index].single_dose,
  1238. single_dose_unit: groups[index].single_dose_unit,
  1239. drug_spec: "" + groups[index].drug_spec,
  1240. drug_spec_unit: groups[index].drug_spec_unit,
  1241. prescribing_number: "" + groups[index].prescribing_number,
  1242. prescribing_number_unit:
  1243. groups[index].prescribing_number_unit,
  1244. delivery_way: groups[index].delivery_way,
  1245. execution_frequency: groups[index].execution_frequency,
  1246. drug_name_id:groups[index].drug_name_id,
  1247. drug_id:groups[index].drug_id,
  1248. way:groups[index].way,
  1249. isEdit: 0,
  1250. index: 0,
  1251. id: groups[index].id,
  1252. children: [],
  1253. parent_row: 0,
  1254. row_key: _this.editRowKey
  1255. };
  1256. if (item.id in childMap) {
  1257. for (const key in childMap[item.id]) {
  1258. _this.editRowKey++;
  1259. var child = {
  1260. advice_name: childMap[item.id][key].advice_name,
  1261. advice_desc: childMap[item.id][key].advice_desc,
  1262. single_dose: "" + childMap[item.id][key].single_dose,
  1263. single_dose_unit:
  1264. childMap[item.id][key].single_dose_unit,
  1265. drug_spec: "" + childMap[item.id][key].drug_spec,
  1266. drug_spec_unit: childMap[item.id][key].drug_spec_unit,
  1267. prescribing_number:
  1268. "" + childMap[item.id][key].prescribing_number,
  1269. prescribing_number_unit:
  1270. childMap[item.id][key].prescribing_number_unit,
  1271. delivery_way: childMap[item.id][key].delivery_way,
  1272. execution_frequency:childMap[item.id][key].execution_frequency,
  1273. drug_name_id:childMap[item.id][key].drug_name_id,
  1274. drug_id:childMap[item.id][key].drug_id,
  1275. way:childMap[item.id][key].way,
  1276. isEdit: 0,
  1277. index: 0,
  1278. id: childMap[item.id][key].id,
  1279. children: [],
  1280. parent_row: item.row_key,
  1281. row_key: _this.editRowKey
  1282. };
  1283. item.children.push(child);
  1284. }
  1285. _this.$set(item, "children", item.children);
  1286. }
  1287. _this.groupForm.adviceNames.unshift(item);
  1288. }
  1289. _this.resetForm(formName);
  1290. return false;
  1291. }
  1292. });
  1293. }
  1294. }
  1295. _this.nameFormVisible = false;
  1296. }
  1297. });
  1298. },
  1299. openGroupChild() {
  1300. if (this.groupSelectRow === null) {
  1301. this.$message.error("未选择医嘱内容,无法添加子药");
  1302. return;
  1303. } else if (this.groupSelectRow.parent_row > 0) {
  1304. this.$notify.error({
  1305. title: "错误",
  1306. message: "子药不能添加子药"
  1307. });
  1308. return;
  1309. }
  1310. this.nameForm = {
  1311. advice_name: "",
  1312. advice_desc: "",
  1313. single_dose: "",
  1314. single_dose_unit: "",
  1315. drug_spec: "",
  1316. drug_spec_unit: "",
  1317. prescribing_number: "",
  1318. prescribing_number_unit: "",
  1319. delivery_way: this.groupSelectRow.delivery_way,
  1320. execution_frequency: this.groupSelectRow.execution_frequency,
  1321. isEdit: 0,
  1322. index: 0,
  1323. children: [],
  1324. parent_row: this.groupSelectRow.row_key,
  1325. id: 0,
  1326. drug_name_id:"",
  1327. way:"",
  1328. drug_id:"",
  1329. };
  1330. this.isChild = true;
  1331. this.nameFormVisible = true;
  1332. this.nameFormTitle = "添加子药内容";
  1333. },
  1334. openGroupAdvice(isEdit) {
  1335. this.isChild = false;
  1336. if (isEdit) {
  1337. if (this.groupSelectRow === null) {
  1338. this.$message.error("未选择要修改的医嘱内容");
  1339. return;
  1340. }
  1341. if (this.groupSelectRow.parent_row) {
  1342. this.isChild = true;
  1343. }
  1344. this.nameForm = {
  1345. advice_name: this.groupSelectRow.advice_name,
  1346. advice_desc: this.groupSelectRow.advice_desc,
  1347. single_dose:
  1348. this.groupSelectRow.single_dose != 0
  1349. ? this.groupSelectRow.single_dose
  1350. : "",
  1351. single_dose_unit: this.groupSelectRow.single_dose_unit,
  1352. drug_spec:
  1353. this.groupSelectRow.drug_spec != 0
  1354. ? this.groupSelectRow.drug_spec
  1355. : "",
  1356. drug_spec_unit: this.groupSelectRow.drug_spec_unit,
  1357. prescribing_number:
  1358. this.groupSelectRow.prescribing_number != 0
  1359. ? this.groupSelectRow.prescribing_number
  1360. : "",
  1361. prescribing_number_unit: this.groupSelectRow.prescribing_number_unit,
  1362. delivery_way: this.isChild ? "" : this.groupSelectRow.delivery_way,
  1363. execution_frequency: this.isChild? "": this.groupSelectRow.execution_frequency,
  1364. drug_name_id:this.isChild?"":this.groupSelectRow.drug_name_id,
  1365. drug_id:this.isChild?"":this.groupSelectRow.drug_id,
  1366. way:this.isChild?"":this.groupSelectRow.way,
  1367. isEdit: 1,
  1368. index: this.groupSelectRow.index,
  1369. id: this.groupSelectRow.id,
  1370. children: [],
  1371. parent_row: this.groupSelectRow.parent_row,
  1372. // row_key:this.groupSelectRow.row_key,
  1373. };
  1374. this.nameFormTitle = "修改医嘱内容";
  1375. this.nameFormVisible = true;
  1376. } else {
  1377. this.nameForm = {
  1378. advice_name: "",
  1379. advice_desc: "",
  1380. single_dose: "",
  1381. single_dose_unit: "",
  1382. drug_spec: "",
  1383. drug_spec_unit: "",
  1384. prescribing_number: "",
  1385. prescribing_number_unit: "",
  1386. delivery_way: "",
  1387. execution_frequency: "",
  1388. drug_name_id:"",
  1389. drug_id:"",
  1390. way:"",
  1391. isEdit: 0,
  1392. index: 0,
  1393. id: 0,
  1394. children: [],
  1395. parent_row: 0
  1396. };
  1397. this.nameFormTitle = "新增医嘱内容";
  1398. }
  1399. this.nameFormVisible = true;
  1400. },
  1401. changeAdvice(selection) {
  1402. this.selectedTemplate = selection;
  1403. },
  1404. selectAllTemplateAdvice(selection) {
  1405. var adviceArray = this.adviceTemplateMaps[this.selectedTemp.id]
  1406. .DoctorAdviceTemplate;
  1407. for (let y = 0; y < adviceArray.length; y++) {
  1408. adviceArray[y].selection = false;
  1409. }
  1410. if (selection.length > 0) {
  1411. for (let y = 0; y < adviceArray.length; y++) {
  1412. for (let i = 0; i < selection.length; i++) {
  1413. if (adviceArray[y].id == selection[i].advice_id) {
  1414. adviceArray[y].selection = true;
  1415. }
  1416. }
  1417. }
  1418. }
  1419. },
  1420. selectAdvice(selection, row) {
  1421. // this.selectedTemplate = [];
  1422. var adviceArray = this.adviceTemplateMaps[this.selectedTemp.id]
  1423. .DoctorAdviceTemplate;
  1424. for (let y = 0; y < adviceArray.length; y++) {
  1425. adviceArray[y].selection = false;
  1426. }
  1427. if (selection.length > 0) {
  1428. for (let y = 0; y < adviceArray.length; y++) {
  1429. for (let i = 0; i < selection.length; i++) {
  1430. if (adviceArray[y].id == selection[i].advice_id) {
  1431. adviceArray[y].selection = true;
  1432. }
  1433. }
  1434. }
  1435. }
  1436. // this.selectedTemplate = [];
  1437. if (row.children.length > 0) {
  1438. for (const index in row.children) {
  1439. this.$refs.selecttemplatetable.toggleRowSelection(
  1440. row.children[index]
  1441. );
  1442. }
  1443. }
  1444. // 下面两步的作用是为了上选中的数据的输出顺序不变
  1445. for (const index in this.selectedTemp.list) {
  1446. this.$refs.selecttemplatetable.toggleRowSelection(
  1447. this.selectedTemp.list[index]
  1448. );
  1449. if (this.selectedTemp.list[index].children.length > 0) {
  1450. for (const j in this.selectedTemp.list[index].children) {
  1451. this.$refs.selecttemplatetable.toggleRowSelection(
  1452. this.selectedTemp.list[index].children[j]
  1453. );
  1454. }
  1455. }
  1456. }
  1457. for (const index in this.selectedTemp.list) {
  1458. this.$refs.selecttemplatetable.toggleRowSelection(
  1459. this.selectedTemp.list[index]
  1460. );
  1461. if (this.selectedTemp.list[index].children.length > 0) {
  1462. for (const j in this.selectedTemp.list[index].children) {
  1463. this.$refs.selecttemplatetable.toggleRowSelection(
  1464. this.selectedTemp.list[index].children[j]
  1465. );
  1466. }
  1467. }
  1468. }
  1469. },
  1470. cancleDialog() {
  1471. this.templateFormVisible = false;
  1472. for (const indexs in this.adviceTemplateMaps) {
  1473. const adviceTemplate = this.adviceTemplateMaps[indexs];
  1474. for (const index in adviceTemplate.DoctorAdviceTemplate) {
  1475. adviceTemplate.DoctorAdviceTemplate[index].selection = false;
  1476. }
  1477. }
  1478. },
  1479. spanselecttable({ row, column, rowIndex, columnIndex }) {
  1480. if (columnIndex == 0) {
  1481. const _row = this.selectedTemp.rows[rowIndex];
  1482. const _col = _row > 0 ? 1 : 0;
  1483. return {
  1484. rowspan: _row,
  1485. colspan: _col
  1486. };
  1487. }
  1488. },
  1489. calcselectedTemp() {
  1490. var rowKeys = 0;
  1491. for (const index in this.selectedTemp.list) {
  1492. var pkey = rowKeys;
  1493. this.selectedTemp.rows[rowKeys] = 1;
  1494. if (this.selectedTemp.list[index].children.length > 0) {
  1495. for (const childindex in this.selectedTemp.list[index].children) {
  1496. rowKeys++;
  1497. this.selectedTemp.rows[pkey] += 1;
  1498. this.selectedTemp.rows[rowKeys] = 0;
  1499. }
  1500. }
  1501. rowKeys++;
  1502. this.$nextTick(function() {
  1503. if (this.selectedTemp.list[index].selection) {
  1504. this.$refs.selecttemplatetable.toggleRowSelection(
  1505. this.selectedTemp.list[index]
  1506. );
  1507. }
  1508. });
  1509. }
  1510. },
  1511. templateTableChange(currentRow, oldCurrentRow) {
  1512. this.selectedTemp = { id: 0, name: "", org_id: 0, list: [], rows: [] };
  1513. if (currentRow == null) {
  1514. return false;
  1515. }
  1516. this.selectedTemp.id = currentRow.id;
  1517. this.selectedTemp.name = currentRow.name;
  1518. this.selectedTemp.org_id = currentRow.org_id;
  1519. if (this.selectedTemp.id in this.adviceTemplateMaps) {
  1520. var mapid = this.selectedTemp.id;
  1521. var thisRowKey = 0;
  1522. for (const index in this.adviceTemplateMaps[mapid]
  1523. .DoctorAdviceTemplate) {
  1524. thisRowKey++;
  1525. var item = {
  1526. advice_name: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1527. index
  1528. ].advice_name,
  1529. advice_desc: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1530. index
  1531. ].advice_desc,
  1532. single_dose:
  1533. "" +
  1534. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1535. .single_dose,
  1536. single_dose_unit: this.adviceTemplateMaps[mapid]
  1537. .DoctorAdviceTemplate[index].single_dose_unit,
  1538. drug_spec:
  1539. "" +
  1540. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1541. .drug_spec,
  1542. drug_spec_unit: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1543. index
  1544. ].drug_spec_unit,
  1545. prescribing_number:
  1546. "" +
  1547. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1548. .prescribing_number,
  1549. prescribing_number_unit: this.adviceTemplateMaps[mapid]
  1550. .DoctorAdviceTemplate[index].prescribing_number_unit,
  1551. delivery_way: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1552. index
  1553. ].delivery_way,
  1554. execution_frequency: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].execution_frequency,
  1555. drug_name_id: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_name_id,
  1556. way: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].way,
  1557. drug_id: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_id,
  1558. advice_id: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1559. index
  1560. ].id,
  1561. selection: this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1562. index
  1563. ].selection,
  1564. isEdit: 0,
  1565. id: 0,
  1566. children: [],
  1567. parent_row: 0,
  1568. row_key: thisRowKey
  1569. };
  1570. if (
  1571. "children" in
  1572. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index] &&
  1573. this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].children
  1574. .length > 0
  1575. ) {
  1576. var parentRow = thisRowKey;
  1577. var children = this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[
  1578. index
  1579. ].children;
  1580. for (const key in children) {
  1581. thisRowKey++;
  1582. var child = {
  1583. advice_id: children[key].id,
  1584. advice_name: children[key].advice_name,
  1585. advice_desc: children[key].advice_desc,
  1586. single_dose: "" + children[key].single_dose,
  1587. single_dose_unit: children[key].single_dose_unit,
  1588. drug_spec: "" + children[key].drug_spec,
  1589. drug_spec_unit: children[key].drug_spec_unit,
  1590. prescribing_number: "" + children[key].prescribing_number,
  1591. prescribing_number_unit: children[key].prescribing_number_unit,
  1592. delivery_way: children[key].delivery_way,
  1593. execution_frequency: children[key].execution_frequency,
  1594. drug_name_id:children[key].drug_name_id,
  1595. drug_id:children[key].drug_id,
  1596. way:children[key].way,
  1597. isEdit: 0,
  1598. id: 0,
  1599. children: [],
  1600. parent_row: parentRow,
  1601. row_key: thisRowKey
  1602. };
  1603. item.children.push(child);
  1604. }
  1605. this.$set(item, "children", item.children);
  1606. }
  1607. this.selectedTemp.list.unshift(item);
  1608. }
  1609. }
  1610. },
  1611. newAddTempForm() {
  1612. this.allSelectedTemplate = [];
  1613. var thisRowKey = 0;
  1614. for (const indexs in this.adviceTemplateMaps) {
  1615. const adviceTemplate = this.adviceTemplateMaps[indexs];
  1616. for (const index in adviceTemplate.DoctorAdviceTemplate) {
  1617. if (adviceTemplate.DoctorAdviceTemplate[index].selection) {
  1618. thisRowKey++;
  1619. var item = {
  1620. advice_name:
  1621. adviceTemplate.DoctorAdviceTemplate[index].advice_name,
  1622. advice_desc:
  1623. adviceTemplate.DoctorAdviceTemplate[index].advice_desc,
  1624. single_dose:
  1625. "" + adviceTemplate.DoctorAdviceTemplate[index].single_dose,
  1626. single_dose_unit:
  1627. adviceTemplate.DoctorAdviceTemplate[index].single_dose_unit,
  1628. drug_spec:
  1629. "" + adviceTemplate.DoctorAdviceTemplate[index].drug_spec,
  1630. drug_spec_unit:
  1631. adviceTemplate.DoctorAdviceTemplate[index].drug_spec_unit,
  1632. prescribing_number:
  1633. "" +
  1634. adviceTemplate.DoctorAdviceTemplate[index].prescribing_number,
  1635. prescribing_number_unit:
  1636. adviceTemplate.DoctorAdviceTemplate[index]
  1637. .prescribing_number_unit,
  1638. delivery_way:
  1639. adviceTemplate.DoctorAdviceTemplate[index].delivery_way,
  1640. execution_frequency:adviceTemplate.DoctorAdviceTemplate[index].execution_frequency,
  1641. drug_name_id:adviceTemplate.DoctorAdviceTemplate[index].drug_name_id,
  1642. drug_id:adviceTemplate.DoctorAdviceTemplate[index].drug_id,
  1643. way:adviceTemplate.DoctorAdviceTemplate[index].way,
  1644. advice_id: adviceTemplate.DoctorAdviceTemplate[index].id,
  1645. selection: adviceTemplate.DoctorAdviceTemplate[index].selection,
  1646. isEdit: 0,
  1647. id: 0,
  1648. children: [],
  1649. parent_row: 0,
  1650. row_key: thisRowKey
  1651. };
  1652. if (
  1653. "children" in adviceTemplate.DoctorAdviceTemplate[index] &&
  1654. adviceTemplate.DoctorAdviceTemplate[index].children.length > 0
  1655. ) {
  1656. var parentRow = thisRowKey;
  1657. var children =
  1658. adviceTemplate.DoctorAdviceTemplate[index].children;
  1659. for (const key in children) {
  1660. thisRowKey++;
  1661. var child = {
  1662. advice_id: children[key].id,
  1663. advice_name: children[key].advice_name,
  1664. advice_desc: children[key].advice_desc,
  1665. single_dose: "" + children[key].single_dose,
  1666. single_dose_unit: children[key].single_dose_unit,
  1667. drug_spec: "" + children[key].drug_spec,
  1668. drug_spec_unit: children[key].drug_spec_unit,
  1669. prescribing_number: "" + children[key].prescribing_number,
  1670. prescribing_number_unit:
  1671. children[key].prescribing_number_unit,
  1672. delivery_way: children[key].delivery_way,
  1673. execution_frequency: children[key].execution_frequency,
  1674. drug_name_id: children[key].drug_name_id,
  1675. drug_id:children[key].drug_id,
  1676. way:children[key].way,
  1677. isEdit: 0,
  1678. id: 0,
  1679. children: [],
  1680. parent_row: parentRow,
  1681. row_key: thisRowKey
  1682. };
  1683. item.children.push(child);
  1684. this.allSelectedTemplate.unshift(child);
  1685. }
  1686. this.$set(item, "children", item.children);
  1687. }
  1688. this.allSelectedTemplate.unshift(item);
  1689. adviceTemplate.DoctorAdviceTemplate[index].selection = false;
  1690. }
  1691. }
  1692. }
  1693. var childMap = {};
  1694. for (const index in this.allSelectedTemplate) {
  1695. if (this.allSelectedTemplate[index].parent_row > 0) {
  1696. if (!(this.allSelectedTemplate[index].parent_row in childMap)) {
  1697. childMap[this.allSelectedTemplate[index].parent_row] = [];
  1698. }
  1699. childMap[this.allSelectedTemplate[index].parent_row].push(
  1700. this.allSelectedTemplate[index]
  1701. );
  1702. }
  1703. }
  1704. this.submitGroupForm = {
  1705. advice_type: this.groupForm.advice_type,
  1706. advice_date: this.groupForm.advice_date,
  1707. start_time: this.groupForm.start_time,
  1708. adviceNames: [],
  1709. advice_doctor: "",
  1710. remark: this.groupForm.remark,
  1711. parent_id: 0
  1712. };
  1713. for (const index in this.allSelectedTemplate) {
  1714. if (this.allSelectedTemplate[index].parent_row > 0) {
  1715. continue;
  1716. }
  1717. this.editRowKey++;
  1718. var item = {
  1719. advice_name: this.allSelectedTemplate[index].advice_name,
  1720. advice_desc: this.allSelectedTemplate[index].advice_desc,
  1721. single_dose: "" + this.allSelectedTemplate[index].single_dose,
  1722. single_dose_unit: this.allSelectedTemplate[index].single_dose_unit,
  1723. drug_spec: "" + this.allSelectedTemplate[index].drug_spec,
  1724. drug_spec_unit: this.allSelectedTemplate[index].drug_spec_unit,
  1725. prescribing_number:
  1726. "" + this.allSelectedTemplate[index].prescribing_number,
  1727. prescribing_number_unit: this.allSelectedTemplate[index]
  1728. .prescribing_number_unit,
  1729. delivery_way: this.allSelectedTemplate[index].delivery_way,
  1730. execution_frequency: this.allSelectedTemplate[index].execution_frequency,
  1731. drug_name_id: this.allSelectedTemplate[index].drug_name_id,
  1732. way:this.allSelectedTemplate[index].way,
  1733. drug_id:this.allSelectedTemplate[index].drug_id,
  1734. isEdit: 0,
  1735. id: 0,
  1736. children: [],
  1737. parent_row: 0,
  1738. row_key: this.editRowKey
  1739. };
  1740. if (this.allSelectedTemplate[index].children.length > 0) {
  1741. if (this.allSelectedTemplate[index].row_key in childMap) {
  1742. var parentRow = this.editRowKey;
  1743. var children = childMap[this.allSelectedTemplate[index].row_key];
  1744. for (const key in children) {
  1745. this.editRowKey++;
  1746. var child = {
  1747. advice_name: children[key].advice_name,
  1748. advice_desc: children[key].advice_desc,
  1749. single_dose: "" + children[key].single_dose,
  1750. single_dose_unit: children[key].single_dose_unit,
  1751. drug_spec: "" + children[key].drug_spec,
  1752. drug_spec_unit: children[key].drug_spec_unit,
  1753. prescribing_number: "" + children[key].prescribing_number,
  1754. prescribing_number_unit: children[key].prescribing_number_unit,
  1755. delivery_way: children[key].delivery_way,
  1756. execution_frequency: children[key].execution_frequency,
  1757. drug_name_id: children[key].drug_name_id,
  1758. drug_id:children[key].drug_id,
  1759. way:children[key].way,
  1760. isEdit: 0,
  1761. id: 0,
  1762. children: [],
  1763. parent_row: parentRow,
  1764. row_key: this.editRowKey
  1765. };
  1766. item.children.push(child);
  1767. }
  1768. this.$set(item, "children", item.children);
  1769. }
  1770. }
  1771. this.submitGroupForm.adviceNames.unshift(item);
  1772. }
  1773. let mode = "1";
  1774. CreateGroupAdvice(
  1775. this.patientID,
  1776. this.groupForm.groupno,
  1777. this.submitGroupForm,
  1778. mode
  1779. ).then(response => {
  1780. if (response.data.state == 0) {
  1781. this.$message.error(response.data.msg);
  1782. return false;
  1783. } else {
  1784. this.$notify({
  1785. title: "成功",
  1786. message: "新增成功",
  1787. type: "success",
  1788. duration: 2000
  1789. });
  1790. var groups = response.data.data.advices;
  1791. var childMap = {};
  1792. for (const index in groups) {
  1793. if (groups[index].parent_id == 0) {
  1794. continue;
  1795. }
  1796. if (groups[index].parent_id in childMap === false) {
  1797. childMap[groups[index].parent_id] = [];
  1798. }
  1799. childMap[groups[index].parent_id].push(groups[index]);
  1800. }
  1801. var parentArr = [];
  1802. for (const index in groups) {
  1803. if (groups[index].parent_id > 0) {
  1804. continue;
  1805. }
  1806. parentArr.push(groups[index]);
  1807. }
  1808. var groupNo = groups[0].groupno;
  1809. var newData = { groupNo: parentArr };
  1810. for (const index in this.adviceTableData) {
  1811. if (this.adviceTableData[index].groupno == groupNo) {
  1812. for (const i in parentArr) {
  1813. if (parentArr[i].id in childMap) {
  1814. for (const j in childMap[parentArr[i].id]) {
  1815. this.adviceTableData.splice(
  1816. index,
  1817. 0,
  1818. childMap[parentArr[i].id][j]
  1819. );
  1820. }
  1821. }
  1822. this.adviceTableData.splice(index, 0, parentArr[i]);
  1823. }
  1824. break;
  1825. }
  1826. }
  1827. for (const index in groups) {
  1828. if (groups[index].parent_id > 0) {
  1829. continue;
  1830. }
  1831. this.editRowKey++;
  1832. var item = {
  1833. advice_name: groups[index].advice_name,
  1834. advice_desc: groups[index].advice_desc,
  1835. single_dose: "" + groups[index].single_dose,
  1836. single_dose_unit: groups[index].single_dose_unit,
  1837. drug_spec: "" + groups[index].drug_spec,
  1838. drug_spec_unit: groups[index].drug_spec_unit,
  1839. prescribing_number: "" + groups[index].prescribing_number,
  1840. prescribing_number_unit: groups[index].prescribing_number_unit,
  1841. delivery_way: groups[index].delivery_way,
  1842. execution_frequency: groups[index].execution_frequency,
  1843. drug_name_id: groups[index].drug_name_id,
  1844. drug_id:groups[index].drug_id,
  1845. way:groups[index].way,
  1846. isEdit: 0,
  1847. index: 0,
  1848. id: groups[index].id,
  1849. children: [],
  1850. parent_row: 0,
  1851. row_key: this.editRowKey
  1852. };
  1853. if (item.id in childMap) {
  1854. for (const key in childMap[item.id]) {
  1855. this.editRowKey++;
  1856. var child = {
  1857. advice_name: childMap[item.id][key].advice_name,
  1858. advice_desc: childMap[item.id][key].advice_desc,
  1859. single_dose: "" + childMap[item.id][key].single_dose,
  1860. single_dose_unit: childMap[item.id][key].single_dose_unit,
  1861. drug_spec: "" + childMap[item.id][key].drug_spec,
  1862. drug_spec_unit: childMap[item.id][key].drug_spec_unit,
  1863. prescribing_number:
  1864. "" + childMap[item.id][key].prescribing_number,
  1865. prescribing_number_unit:
  1866. childMap[item.id][key].prescribing_number_unit,
  1867. delivery_way: childMap[item.id][key].delivery_way,
  1868. execution_frequency:childMap[item.id][key].execution_frequency,
  1869. way:childMap[item.id][key].way,
  1870. drug_name_id:childMap[item.id][key].drug_name_id,
  1871. drug_id:childMap[item.id][key].drug_id,
  1872. isEdit: 0,
  1873. index: 0,
  1874. id: childMap[item.id][key].id,
  1875. children: [],
  1876. parent_row: item.row_key,
  1877. row_key: this.editRowKey
  1878. };
  1879. item.children.push(child);
  1880. }
  1881. this.$set(item, "children", item.children);
  1882. }
  1883. this.groupForm.adviceNames.unshift(item);
  1884. }
  1885. return false;
  1886. }
  1887. });
  1888. this.templateFormVisible = false;
  1889. },
  1890. addTempForm(formName) {
  1891. var _this = this;
  1892. this.$refs[formName].validate(valid => {
  1893. if (valid) {
  1894. if (_this.templateForm.id in _this.adviceTemplateMaps) {
  1895. _this.submitGroupForm = {
  1896. advice_type: _this.groupForm.advice_type,
  1897. advice_date: _this.groupForm.advice_date,
  1898. start_time: _this.groupForm.start_time,
  1899. adviceNames: [],
  1900. advice_doctor: "",
  1901. remark: _this.groupForm.remark,
  1902. parent_id: 0
  1903. };
  1904. var mapid = _this.templateForm.id;
  1905. for (const index in _this.adviceTemplateMaps[mapid]
  1906. .DoctorAdviceTemplate) {
  1907. _this.editRowKey++;
  1908. var item = {
  1909. advice_name:
  1910. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1911. .advice_name,
  1912. advice_desc:
  1913. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1914. .advice_desc,
  1915. single_dose:
  1916. "" +
  1917. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1918. .single_dose,
  1919. single_dose_unit:
  1920. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1921. .single_dose_unit,
  1922. drug_spec:
  1923. "" +
  1924. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1925. .drug_spec,
  1926. drug_spec_unit:
  1927. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1928. .drug_spec_unit,
  1929. prescribing_number:
  1930. "" +
  1931. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1932. .prescribing_number,
  1933. prescribing_number_unit:
  1934. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1935. .prescribing_number_unit,
  1936. delivery_way:
  1937. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1938. .delivery_way,
  1939. execution_frequency:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].execution_frequency,
  1940. drug_name_id: _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_name_id,
  1941. drug_id: _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].drug_id,
  1942. way:_this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index].way,
  1943. isEdit: 0,
  1944. id: 0,
  1945. children: [],
  1946. parent_row: 0,
  1947. row_key: _this.editRowKey
  1948. };
  1949. if (
  1950. "children" in
  1951. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index] &&
  1952. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1953. .children
  1954. ) {
  1955. var parentRow = _this.editRowKey;
  1956. var children =
  1957. _this.adviceTemplateMaps[mapid].DoctorAdviceTemplate[index]
  1958. .children;
  1959. for (const key in children) {
  1960. _this.editRowKey++;
  1961. var child = {
  1962. advice_name: children[key].advice_name,
  1963. advice_desc: children[key].advice_desc,
  1964. single_dose: "" + children[key].single_dose,
  1965. single_dose_unit: children[key].single_dose_unit,
  1966. drug_spec: "" + children[key].drug_spec,
  1967. drug_spec_unit: children[key].drug_spec_unit,
  1968. prescribing_number: "" + children[key].prescribing_number,
  1969. prescribing_number_unit:
  1970. children[key].prescribing_number_unit,
  1971. delivery_way: children[key].delivery_way,
  1972. execution_frequency: children[key].execution_frequency,
  1973. drug_name_id: children[key].drug_name_id,
  1974. drug_id: children[key].drug_id,
  1975. way:children[key].way,
  1976. isEdit: 0,
  1977. id: 0,
  1978. children: [],
  1979. parent_row: parentRow,
  1980. row_key: _this.editRowKey
  1981. };
  1982. item.children.push(child);
  1983. }
  1984. _this.$set(item, "children", item.children);
  1985. }
  1986. _this.submitGroupForm.adviceNames.push(item);
  1987. }
  1988. let mode = "1";
  1989. CreateGroupAdvice(
  1990. _this.patientID,
  1991. _this.groupForm.groupno,
  1992. _this.submitGroupForm,
  1993. mode
  1994. ).then(response => {
  1995. if (response.data.state == 0) {
  1996. _this.$message.error(response.data.msg);
  1997. return false;
  1998. } else {
  1999. _this.$notify({
  2000. title: "成功",
  2001. message: "新增成功",
  2002. type: "success",
  2003. duration: 2000
  2004. });
  2005. // var alen = response.data.data.advices.length
  2006. // for (let index = alen-1; index >=0; index--) {
  2007. // this.adviceTableData.unshift(response.data.data.advices[index]);
  2008. // }
  2009. var groups = response.data.data.advices;
  2010. var childMap = {};
  2011. for (const index in groups) {
  2012. if (groups[index].parent_id == 0) {
  2013. continue;
  2014. }
  2015. if (groups[index].parent_id in childMap === false) {
  2016. childMap[groups[index].parent_id] = [];
  2017. }
  2018. childMap[groups[index].parent_id].push(groups[index]);
  2019. }
  2020. var parentArr = [];
  2021. for (const index in groups) {
  2022. if (groups[index].parent_id > 0) {
  2023. continue;
  2024. }
  2025. parentArr.push(groups[index]);
  2026. }
  2027. var groupNo = groups[0].groupno;
  2028. var newData = { groupNo: parentArr };
  2029. for (const index in _this.adviceTableData) {
  2030. if (_this.adviceTableData[index].groupno == groupNo) {
  2031. for (const i in parentArr) {
  2032. if (parentArr[i].id in childMap) {
  2033. for (const j in childMap[parentArr[i].id]) {
  2034. _this.adviceTableData.splice(
  2035. index,
  2036. 0,
  2037. childMap[parentArr[i].id][j]
  2038. );
  2039. }
  2040. }
  2041. _this.adviceTableData.splice(index, 0, parentArr[i]);
  2042. }
  2043. break;
  2044. }
  2045. }
  2046. for (const index in groups) {
  2047. if (groups[index].parent_id > 0) {
  2048. continue;
  2049. }
  2050. _this.editRowKey++;
  2051. var item = {
  2052. advice_name: groups[index].advice_name,
  2053. advice_desc: groups[index].advice_desc,
  2054. single_dose: "" + groups[index].single_dose,
  2055. single_dose_unit: groups[index].single_dose_unit,
  2056. drug_spec: "" + groups[index].drug_spec,
  2057. drug_spec_unit: groups[index].drug_spec_unit,
  2058. prescribing_number: "" + groups[index].prescribing_number,
  2059. prescribing_number_unit:
  2060. groups[index].prescribing_number_unit,
  2061. delivery_way: groups[index].delivery_way,
  2062. execution_frequency: groups[index].execution_frequency,
  2063. drug_name_id:groups[index].drug_name_id,
  2064. drug_id:groups[index].drug_id,
  2065. way:groups[index].way,
  2066. isEdit: 0,
  2067. index: 0,
  2068. id: groups[index].id,
  2069. children: [],
  2070. parent_row: 0,
  2071. row_key: _this.editRowKey
  2072. };
  2073. if (item.id in childMap) {
  2074. for (const key in childMap[item.id]) {
  2075. _this.editRowKey++;
  2076. var child = {
  2077. advice_name: childMap[item.id][key].advice_name,
  2078. advice_desc: childMap[item.id][key].advice_desc,
  2079. single_dose: "" + childMap[item.id][key].single_dose,
  2080. single_dose_unit:
  2081. childMap[item.id][key].single_dose_unit,
  2082. drug_spec: "" + childMap[item.id][key].drug_spec,
  2083. drug_spec_unit: childMap[item.id][key].drug_spec_unit,
  2084. prescribing_number:
  2085. "" + childMap[item.id][key].prescribing_number,
  2086. prescribing_number_unit:
  2087. childMap[item.id][key].prescribing_number_unit,
  2088. delivery_way: childMap[item.id][key].delivery_way,
  2089. execution_frequency:childMap[item.id][key].execution_frequency,
  2090. drug_name_id:childMap[item.id][key].drug_name_id,
  2091. drug_id:childMap[item.id][key].drug_id,
  2092. way:childMap[item.id][key].way,
  2093. isEdit: 0,
  2094. index: 0,
  2095. id: childMap[item.id][key].id,
  2096. children: [],
  2097. parent_row: item.row_key,
  2098. row_key: _this.editRowKey
  2099. };
  2100. item.children.push(child);
  2101. }
  2102. _this.$set(item, "children", item.children);
  2103. }
  2104. _this.groupForm.adviceNames.unshift(item);
  2105. }
  2106. _this.resetForm(formName);
  2107. return false;
  2108. }
  2109. });
  2110. }
  2111. _this.templateFormVisible = false;
  2112. }
  2113. });
  2114. },
  2115. openAdviceTemplate() {
  2116. this.templateForm = { id: "" };
  2117. this.selectedTemp = { id: 0, name: "", org_id: 0, list: [], rows: [] };
  2118. this.selectedTemplate = [];
  2119. if (typeof this.$refs.templatetable !== "undefined") {
  2120. this.$refs.templatetable.setCurrentRow(null);
  2121. }
  2122. this.templateFormVisible = true;
  2123. },
  2124. selectGroupAdvice(row) {
  2125. console.log('row',row)
  2126. this.groupSelectRow = row;
  2127. },
  2128. groupClassName({ row, rowIndex }) {
  2129. row.index = rowIndex;
  2130. },
  2131. getRowKey(row) {
  2132. return row.row_key;
  2133. },
  2134. resetForm(formName) {
  2135. this.$refs[formName].resetFields();
  2136. },
  2137. open(groupNo) {
  2138. this.groupEditFormVisible = true;
  2139. this.groupSelectRow = null;
  2140. if (typeof this.$refs.advicenametable !== "undefined") {
  2141. this.$refs.advicenametable.setCurrentRow(null);
  2142. }
  2143. // groupNo
  2144. this.editRowKey = 0;
  2145. var groups = [];
  2146. for (const index in this.adviceTableData) {
  2147. if (groupNo == this.adviceTableData[index].groupno) {
  2148. groups.push(this.adviceTableData[index]);
  2149. }
  2150. }
  2151. if (groups.length == 0) {
  2152. return false;
  2153. }
  2154. console.log(groups[0].advice_doctor);
  2155. this.adminusername = this.getXuserName(groups[0].advice_doctor);
  2156. this.groupForm = {
  2157. advice_type: groups[0].advice_type,
  2158. advice_date: uParseTime(groups[0].advice_date, "{y}-{m}-{d}"),
  2159. start_time: uParseTime(groups[0].start_time, "{y}-{m}-{d} {h}:{i}"),
  2160. adviceNames: [],
  2161. advice_doctor: "",
  2162. remark: groups[0].remark,
  2163. groupno: groupNo
  2164. };
  2165. var childMap = {};
  2166. for (const index in groups) {
  2167. if (groups[index].parent_id == 0) {
  2168. continue;
  2169. }
  2170. if (groups[index].parent_id in childMap === false) {
  2171. childMap[groups[index].parent_id] = [];
  2172. }
  2173. childMap[groups[index].parent_id].push(groups[index]);
  2174. }
  2175. for (const index in groups) {
  2176. if (groups[index].parent_id > 0) {
  2177. continue;
  2178. }
  2179. this.editRowKey++;
  2180. var item = {
  2181. advice_doctor: groups[index].advice_doctor,
  2182. advice_name: groups[index].advice_name,
  2183. advice_desc: groups[index].advice_desc,
  2184. single_dose: "" + groups[index].single_dose,
  2185. single_dose_unit: groups[index].single_dose_unit,
  2186. drug_spec: "" + groups[index].drug_spec,
  2187. drug_spec_unit: groups[index].drug_spec_unit,
  2188. prescribing_number: "" + groups[index].prescribing_number,
  2189. prescribing_number_unit: groups[index].prescribing_number_unit,
  2190. delivery_way: groups[index].delivery_way,
  2191. execution_frequency: groups[index].execution_frequency,
  2192. drug_name_id:groups[index].drug_name_id,
  2193. drug_id:groups[index].drug_id,
  2194. way:groups[index].way,
  2195. isEdit: 0,
  2196. index: 0,
  2197. id: groups[index].id,
  2198. children: [],
  2199. parent_row: 0,
  2200. row_key: this.editRowKey
  2201. };
  2202. if (item.id in childMap) {
  2203. for (const key in childMap[item.id]) {
  2204. this.editRowKey++;
  2205. var child = {
  2206. advice_doctor: childMap[item.id][key].advice_doctor,
  2207. advice_name: childMap[item.id][key].advice_name,
  2208. advice_desc: childMap[item.id][key].advice_desc,
  2209. single_dose: "" + childMap[item.id][key].single_dose,
  2210. single_dose_unit: childMap[item.id][key].single_dose_unit,
  2211. drug_spec: "" + childMap[item.id][key].drug_spec,
  2212. drug_spec_unit: childMap[item.id][key].drug_spec_unit,
  2213. prescribing_number:
  2214. "" + childMap[item.id][key].prescribing_number,
  2215. prescribing_number_unit:
  2216. childMap[item.id][key].prescribing_number_unit,
  2217. delivery_way: childMap[item.id][key].delivery_way,
  2218. execution_frequency: childMap[item.id][key].execution_frequency,
  2219. drug_name_id: childMap[item.id][key].drug_name_id,
  2220. drug_id: childMap[item.id][key].drug_id,
  2221. way: childMap[item.id][key].way,
  2222. isEdit: 0,
  2223. index: 0,
  2224. id: childMap[item.id][key].id,
  2225. children: [],
  2226. parent_row: item.row_key,
  2227. row_key: this.editRowKey
  2228. };
  2229. item.children.push(child);
  2230. }
  2231. this.$set(item, "children", item.children);
  2232. }
  2233. this.groupForm.adviceNames.push(item);
  2234. }
  2235. },
  2236. SaveEditAdvices() {
  2237. console.log("aaa")
  2238. const params = {
  2239. start_time: this.groupForm.start_time,
  2240. groupno: this.groupForm.groupno,
  2241. date: this.$route.query.date,
  2242. patient_id: this.$route.query.patient_id
  2243. };
  2244. console.log("params", params);
  2245. SaveEditAdvices(params).then(response => {
  2246. if (response.data.state == 1) {
  2247. var advice = response.data.data.advice;
  2248. this.$message.success("保存成功!");
  2249. this.groupEditFormVisible = false;
  2250. }
  2251. });
  2252. },
  2253. getSelfMedicalList(){
  2254. const params = {
  2255. patient_id:this.$route.query.patient_id
  2256. }
  2257. getSelfMedicalList(params).then(response=>{
  2258. if (response.data.state == 1) {
  2259. this.arr_drug = []
  2260. var medicalList = response.data.data.private_drug_list
  2261. var base_drug_list = response.data.data.base_drug_list
  2262. var base_drug_cofig = response.data.data.base_drug_config
  2263. var private_drug_cofig = response.data.data.private_drug_config
  2264. if(private_drug_cofig != null&&private_drug_cofig.drug_start == 1) {
  2265. for (let i = 0; i < medicalList.length; i++) {
  2266. if(medicalList[i].drug_specs != null) {
  2267. for (let a = 0; a < medicalList[i].drug_specs.length; a++) {
  2268. medicalList[i].drug_specs[a]['type'] = 2
  2269. }
  2270. }
  2271. let obj = {
  2272. drug_name: "",
  2273. drug_desc: "",
  2274. delivery_way: "",
  2275. execution_frequency: "",
  2276. single_dose: "",
  2277. single_dose_unit: "",
  2278. prescribing_number: "",
  2279. prescribing_number_unit: "",
  2280. type_id: "",
  2281. type: "",
  2282. custom_id: "",
  2283. drug_specs: [],
  2284. }
  2285. medicalList[i].drug_name = medicalList[i].drug_name + "(自备药)"
  2286. obj.drug_name = medicalList[i].drug_name
  2287. obj.delivery_way = medicalList[i].delivery_way
  2288. obj.execution_frequency = medicalList[i].execution_frequency
  2289. obj.single_dose = medicalList[i].single_dose
  2290. obj.prescribing_number = medicalList[i].prescribing_number
  2291. obj.type_id = medicalList[i].id
  2292. obj.type = 2
  2293. obj.custom_id = this.rand(10000000, 99999999)
  2294. obj.drug_specs = medicalList[i].drug_specs
  2295. this.all_drug.push(obj)
  2296. }
  2297. }
  2298. for (let i = 0; i < base_drug_list.length; i++) {
  2299. if(base_drug_list[i].drug_specs != null) {
  2300. for (let a = 0; a < base_drug_list[i].drug_specs.length; a++) {
  2301. base_drug_list[i].drug_specs[a]['type'] = 1
  2302. }
  2303. }
  2304. let obj = {
  2305. drug_name: "",
  2306. drug_desc: "",
  2307. delivery_way: "",
  2308. execution_frequency: "",
  2309. single_dose: "",
  2310. single_dose_unit: "",
  2311. prescribing_number: "",
  2312. prescribing_number_unit: "",
  2313. type_id: "",
  2314. type: "",
  2315. custom_id: "",
  2316. drug_specs: [],
  2317. }
  2318. obj.drug_name = base_drug_list[i].drug_name
  2319. obj.delivery_way = base_drug_list[i].delivery_way
  2320. obj.execution_frequency = base_drug_list[i].execution_frequency
  2321. obj.single_dose = base_drug_list[i].single_dose
  2322. obj.prescribing_number = base_drug_list[i].prescribing_number
  2323. obj.type_id = base_drug_list[i].id
  2324. obj.type = 1
  2325. obj.custom_id = this.rand(10000000, 99999999)
  2326. obj.drug_specs = base_drug_list[i].drug_specs
  2327. this.all_drug.push(obj)
  2328. }
  2329. }
  2330. })
  2331. },
  2332. changeDrugName(name){
  2333. this.current_drug_name = name
  2334. this.nameForm.advice_desc = ''
  2335. this.drugSpec = []
  2336. for (let i = 0; i < this.all_drug.length; i++) {
  2337. if (this.all_drug[i].drug_name == name) {
  2338. this.drugSpec = this.all_drug[i].drug_specs
  2339. }
  2340. }
  2341. },
  2342. changeDrugDesc(name) {
  2343. this.current_drug_spec = name
  2344. for (let i = 0; i < this.drugSpec.length; i++) {
  2345. if (this.drugSpec[i].drug_spec == name) {
  2346. this.nameForm.advice_desc = this.drugSpec[i].drug_spec
  2347. this.nameForm.prescribing_number = this.drugSpec[i].prescribing_number.toString()
  2348. this.nameForm.single_dose = this.drugSpec[i].single_dose.toString()
  2349. this.nameForm.delivery_way = this.drugSpec[i].delivery_way.toString()
  2350. this.nameForm.execution_frequency = this.drugSpec[i].execution_frequency.toString()
  2351. this.drug_id = this.drugSpec[i].id
  2352. this.src_type = this.drugSpec[i].type
  2353. this.nameForm.drug_id = this.drugSpec[i].id
  2354. this.nameForm.way = this.drugSpec[i].type
  2355. this.drug_name_id = this.drugSpec[i].drug_name_id
  2356. this.nameForm.drug_name_id = this.drugSpec[i].drug_name_id
  2357. }
  2358. }
  2359. },
  2360. rand(min, max) {
  2361. return Math.floor(Math.random() * (max - min)) + min;
  2362. },
  2363. querySearch(queryString, cb) {
  2364. var restaurants = this.all_drug;
  2365. restaurants.map(item => {
  2366. item.value = item.drug_name
  2367. })
  2368. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
  2369. // 调用 callback 返回建议列表的数据
  2370. cb(results);
  2371. },
  2372. createFilter(queryString) {
  2373. return (restaurant) => {
  2374. return (restaurant.drug_name.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
  2375. };
  2376. },
  2377. querySearch1(queryString, cb) {
  2378. console.log('queryString',queryString)
  2379. var restaurants = this.drugSpec;
  2380. console.log(restaurants)
  2381. restaurants.map(item => {
  2382. item.value = item.drug_spec
  2383. })
  2384. var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
  2385. // 调用 callback 返回建议列表的数据
  2386. console.log('results',results)
  2387. cb(results);
  2388. },
  2389. },
  2390. watch: {
  2391. "selectedTemp.list": function() {
  2392. this.calcselectedTemp();
  2393. }
  2394. },
  2395. created(){
  2396. //获取自备药
  2397. this.getSelfMedicalList()
  2398. }
  2399. };
  2400. </script>
  2401. <style>
  2402. #user-edit-advice-name-table .el-table__row {
  2403. display: table-row !important;
  2404. }
  2405. #user-edit-advice-name-table .el-table__expand-icon {
  2406. -webkit-transform: rotate(90deg) !important;
  2407. transform: rotate(90deg) !important;
  2408. }
  2409. #dialysis-update-select-template-table .el-table__row {
  2410. display: table-row !important;
  2411. }
  2412. #dialysis-update-select-template-table .el-table__expand-icon {
  2413. -webkit-transform: rotate(90deg) !important;
  2414. transform: rotate(90deg) !important;
  2415. }
  2416. </style>