AddGroupAdvice.vue 63KB

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