EditGroupAdvice.vue 102KB

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