血透系统PC前端

druguse.vue 33KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965
  1. <template>
  2. <div class="main-contain">
  3. <div class="position">
  4. <bread-crumb></bread-crumb>
  5. </div>
  6. <div class="tab-container">
  7. <el-tabs >
  8. <el-tab-pane label="医嘱模板">
  9. <div >
  10. <div class="filter-container">
  11. <el-button
  12. class="filter-item"
  13. style="margin-left: 10px;"
  14. @click="handleCreateTemplate"
  15. type="primary"
  16. size="small"
  17. icon="el-icon-circle-plus-outline"
  18. >{{$t('table.add')}}</el-button>
  19. </div>
  20. <el-table
  21. :data="adviceTemplates"
  22. v-loading="listLoading"
  23. border
  24. fit
  25. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  26. highlight-current-row
  27. style="width: 100%;min-height:500px;"
  28. >
  29. <el-table-column align="center" label="医嘱名称">
  30. <template slot-scope="scope">
  31. <span>{{scope.row.advice_name}}</span>
  32. </template>
  33. </el-table-column>
  34. <!-- <el-table-column align="center" label="医嘱内容">
  35. <template slot-scope="scope">
  36. <span>{{scope.row.advice_desc}}</span>
  37. </template>
  38. </el-table-column> -->
  39. <el-table-column align="center" label="单次用量">
  40. <template slot-scope="scope">
  41. <span>{{scope.row.single_dose}} {{scope.row.single_dose_unit}}</span>
  42. </template>
  43. </el-table-column>
  44. <el-table-column align="center" label="开药数量">
  45. <template slot-scope="scope">
  46. <span>{{scope.row.prescribing_number}} {{scope.row.prescribing_number_unit}}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" label="给药途径">
  50. <template slot-scope="scope">
  51. <span>{{scope.row.delivery_way}}</span>
  52. </template>
  53. </el-table-column>
  54. <el-table-column align="center" label="执行频率">
  55. <template slot-scope="scope">
  56. <span>{{scope.row.execution_frequency}}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. align="center"
  61. :label="$t('table.actions')"
  62. width="230"
  63. class-name="small-padding fixed-width"
  64. >
  65. <template slot-scope="scope">
  66. <el-button
  67. type="primary"
  68. size="small"
  69. icon="el-icon-edit-outline"
  70. @click="handleUpdateAdviceTemplate(scope.row, scope.$index)"
  71. ></el-button>
  72. <el-button
  73. v-if="scope.row.status!='deleted'"
  74. size="small"
  75. type="danger"
  76. icon="el-icon-delete"
  77. @click="handleDeleteAdviceTemplate(scope.row, scope.$index)"
  78. ></el-button>
  79. </template>
  80. </el-table-column>
  81. </el-table>
  82. <el-dialog :title="dialogTitle" :visible.sync="templateFormVisible" width="700px">
  83. <el-form
  84. ref="templateForm"
  85. :rules="templateRules"
  86. :model="templateForm"
  87. label-width="90px"
  88. >
  89. <el-form-item label="医嘱名称 :" required prop="advice_name">
  90. <el-input v-model="templateForm.advice_name" style="width:50%"></el-input>
  91. </el-form-item>
  92. <!-- <el-form-item label="医嘱内容 :" prop="advice_desc">
  93. <el-input v-model="templateForm.advice_desc" style="width:50%"></el-input>
  94. </el-form-item> -->
  95. <el-row>
  96. <el-col :span="12">
  97. <el-form-item label="单次用量 :" prop="single_dose">
  98. <el-col :span="8">
  99. <el-input v-model="templateForm.single_dose"></el-input>
  100. </el-col>
  101. <el-col class="line" :span="2">&nbsp;</el-col>
  102. <el-col :span="14">
  103. <el-select
  104. v-model="templateForm.single_dose_unit"
  105. filterable
  106. clearable
  107. allow-create
  108. placeholder="选择"
  109. >
  110. <el-option
  111. v-for="item in unitsOption"
  112. :key="item.id"
  113. :label="item.name "
  114. :value="item.name"
  115. ></el-option>
  116. </el-select>
  117. </el-col>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="12">
  121. <el-form-item label="开药数量 :" prop="prescribing_number">
  122. <el-col :span="8">
  123. <el-input v-model="templateForm.prescribing_number"></el-input>
  124. </el-col>
  125. <el-col class="line" :span="2">&nbsp;</el-col>
  126. <el-col :span="14">
  127. <el-select
  128. v-model="templateForm.prescribing_number_unit"
  129. filterable
  130. clearable
  131. allow-create
  132. placeholder="选择"
  133. >
  134. <el-option
  135. v-for="item in unitsOption"
  136. :key="item.id"
  137. :label="item.name "
  138. :value="item.name"
  139. ></el-option>
  140. </el-select>
  141. </el-col>
  142. </el-form-item>
  143. </el-col>
  144. </el-row>
  145. <el-row>
  146. <el-col :span="12">
  147. <el-form-item label="给药途径 :" prop="delivery_way">
  148. <el-select
  149. v-model="templateForm.delivery_way"
  150. filterable
  151. clearable
  152. allow-create
  153. placeholder="请选择(输入可搜索)"
  154. style="width:90%"
  155. >
  156. <el-option
  157. v-for="item in drugways"
  158. :key="item.id"
  159. :label="item.name "
  160. :value="item.name"
  161. ></el-option>
  162. </el-select>
  163. </el-form-item>
  164. </el-col>
  165. <el-col :span="12">
  166. <el-form-item label="执行频率 :" prop="execution_frequency">
  167. <el-select
  168. v-model="templateForm.execution_frequency"
  169. clearable
  170. allow-create
  171. filterable
  172. placeholder="请选择(输入可搜索)"
  173. style="width:90%"
  174. >
  175. <el-option
  176. v-for="item in executionFrequencyOptions"
  177. :key="item.id"
  178. :label="item.name"
  179. :value="item.name"
  180. ></el-option>
  181. </el-select>
  182. </el-form-item>
  183. </el-col>
  184. </el-row>
  185. </el-form>
  186. <div slot="footer" class="dialog-footer">
  187. <el-button @click="templateFormVisible = false">取消</el-button>
  188. <el-button type="primary" @click="submitTemplate('templateForm')">保 存</el-button>
  189. </div>
  190. </el-dialog>
  191. <el-dialog :title="dialogTitle" :visible.sync="drugdicFormVisible" width="700px">
  192. <el-form
  193. ref="drugdicForm"
  194. :rules="drugdicRules"
  195. :model="drugdicForm"
  196. label-width="90px"
  197. >
  198. <el-form-item label="医嘱名称 :" required prop="name">
  199. <el-input v-model="drugdicForm.name" style="width:50%" placeholder="如:阿莫西林"></el-input>
  200. </el-form-item>
  201. <el-form-item label="医嘱内容 :" prop="spec">
  202. <el-input v-model="drugdicForm.spec" style="width:50%" placeholder="如:10克x9袋"></el-input>
  203. </el-form-item>
  204. <el-form-item label="医嘱类型 :" prop="form">
  205. <el-select
  206. v-model="drugdicForm.form"
  207. clearable
  208. allow-create
  209. filterable
  210. placeholder="请选择(输入可搜索)"
  211. >
  212. <el-option
  213. :label="item.name"
  214. :key="item.label"
  215. :value="item.name"
  216. v-for="item in drugforms"
  217. ></el-option>
  218. </el-select>
  219. </el-form-item>
  220. <el-row>
  221. <el-col :span="12">
  222. <el-form-item label="单次单位 :" prop="spec_unit">
  223. <el-select
  224. v-model="drugdicForm.spec_unit"
  225. clearable
  226. allow-create
  227. filterable
  228. placeholder="选择(输入可搜索)"
  229. >
  230. <el-option
  231. v-for="item in unitsOption"
  232. :key="item.label"
  233. :label="item.name "
  234. :value="item.name"
  235. ></el-option>
  236. </el-select>
  237. </el-form-item>
  238. </el-col>
  239. <el-col :span="12">
  240. <el-form-item label="开药单位 :" prop="form_unit">
  241. <el-select
  242. v-model="drugdicForm.form_unit"
  243. clearable
  244. allow-create
  245. filterable
  246. placeholder="选择(输入可搜索)"
  247. >
  248. <el-option
  249. v-for="item in unitsOption"
  250. :key="item.label"
  251. :label="item.name "
  252. :value="item.name"
  253. ></el-option>
  254. </el-select>
  255. </el-form-item>
  256. </el-col>
  257. </el-row>
  258. </el-form>
  259. <div slot="footer" class="dialog-footer">
  260. <el-button @click="drugdicFormVisible = false">取消</el-button>
  261. <el-button type="primary" @click="submitDrugDic('drugdicForm')">保 存</el-button>
  262. </div>
  263. </el-dialog>
  264. </div>
  265. </el-tab-pane>
  266. <el-tab-pane label="给药途径">
  267. <div class="app-container">
  268. <div class="filter-container">
  269. <el-button
  270. class="filter-item"
  271. style="margin-left: 10px;"
  272. @click="handleCreateDrugWay"
  273. type="primary"
  274. size="small"
  275. icon="el-icon-circle-plus-outline"
  276. >{{$t('table.add')}}</el-button>
  277. </div>
  278. <el-table
  279. :data="drugways"
  280. v-loading="listLoading"
  281. border
  282. fit
  283. highlight-current-row
  284. style="width: 100%;min-height:500px;"
  285. >
  286. <el-table-column align="center" label="名称">
  287. <template slot-scope="scope">
  288. <span>{{scope.row.name}}</span>
  289. </template>
  290. </el-table-column>
  291. <el-table-column
  292. align="center"
  293. :label="$t('table.actions')"
  294. width="230"
  295. class-name="small-padding fixed-width"
  296. >
  297. <template slot-scope="scope">
  298. <el-button type="text" size="mini" v-show="scope.row.org_id==0" disabled>系统设定</el-button>
  299. <el-button
  300. v-show="scope.row.org_id!=0"
  301. type="primary"
  302. size="small"
  303. icon="el-icon-edit-outline"
  304. @click="handleUpdateDrugWay(scope.row, scope.$index)"
  305. ></el-button>
  306. <el-button
  307. v-show="scope.row.org_id!=0"
  308. size="small"
  309. type="danger"
  310. icon="el-icon-delete"
  311. @click="handleDeleteDrugWay(scope.row, scope.$index)"
  312. ></el-button>
  313. </template>
  314. </el-table-column>
  315. </el-table>
  316. <el-dialog :title="dialogTitle" :visible.sync="drugwayFormVisible" width="700px">
  317. <el-form
  318. ref="drugwayForm"
  319. :rules="drugwayRules"
  320. :model="drugwayForm"
  321. label-width="90px"
  322. >
  323. <el-form-item label="给药途径 :" required prop="name">
  324. <el-input v-model="drugwayForm.name" placeholder="给药途径"></el-input>
  325. </el-form-item>
  326. </el-form>
  327. <div slot="footer" class="dialog-footer">
  328. <el-button @click="drugwayFormVisible = false">取消</el-button>
  329. <el-button type="primary" @click="submitDrugWay('drugwayForm')">保 存</el-button>
  330. </div>
  331. </el-dialog>
  332. </div>
  333. </el-tab-pane>
  334. <el-tab-pane label="执行频率">
  335. <div class="">
  336. <div class="filter-container">
  337. <el-button
  338. class="filter-item"
  339. style="margin-left: 10px;"
  340. @click="handleCreateEF"
  341. type="primary"
  342. size="small"
  343. icon="el-icon-circle-plus-outline"
  344. >{{$t('table.add')}}</el-button>
  345. </div>
  346. <el-table
  347. :data="executionFrequencyOptions"
  348. v-loading="listLoading"
  349. border
  350. fit
  351. highlight-current-row
  352. style="width: 100%;min-height:500px;"
  353. :header-cell-style="{ backgroundColor: 'rgb(245, 247, 250)'}"
  354. >
  355. <el-table-column align="center" label="名称">
  356. <template slot-scope="scope">
  357. <span>{{scope.row.name}}</span>
  358. </template>
  359. </el-table-column>
  360. <el-table-column
  361. align="center"
  362. :label="$t('table.actions')"
  363. width="230"
  364. class-name="small-padding fixed-width"
  365. >
  366. <template slot-scope="scope">
  367. <el-button type="text" size="mini" v-show="scope.row.org_id==0" disabled>系统设定</el-button>
  368. <el-button
  369. v-show="scope.row.org_id!=0"
  370. type="primary"
  371. size="small"
  372. icon="el-icon-edit-outline"
  373. @click="handleUpdateEF(scope.row, scope.$index)"
  374. ></el-button>
  375. <el-button
  376. v-show="scope.row.org_id!=0"
  377. size="small"
  378. type="danger"
  379. icon="el-icon-delete"
  380. @click="handleDeleteEF(scope.row, scope.$index)"
  381. ></el-button>
  382. </template>
  383. </el-table-column>
  384. </el-table>
  385. <el-dialog :title="dialogTitle" :visible.sync="efFormVisible" width="700px">
  386. <el-form ref="efForm" :rules="efRules" :model="efForm" label-width="90px">
  387. <el-form-item label="执行频率 :" required prop="name">
  388. <el-input v-model="efForm.name" placeholder="执行频率"></el-input>
  389. </el-form-item>
  390. </el-form>
  391. <div slot="footer" class="dialog-footer">
  392. <el-button @click="efFormVisible = false">取消</el-button>
  393. <el-button type="primary" @click="submitEF('efForm')">保 存</el-button>
  394. </div>
  395. </el-dialog>
  396. </div>
  397. </el-tab-pane>
  398. </el-tabs>
  399. </div>
  400. </template>
  401. <script>
  402. import {
  403. getAdviceConfig,
  404. CreateDrugDic,
  405. UpdateDrugDic,
  406. DeleteDrugDic,
  407. CreateDrugWay,
  408. UpdateDrugWay,
  409. DeleteDrugWay,
  410. CreateExecutionFrequency,
  411. UpdateExecutionFrequency,
  412. DeleteExecutionFrequency,
  413. CreateAdviceTemplate,
  414. UpdateAdviceTemplate,
  415. DeleteAdviceTemplate
  416. } from "@/api/advice";
  417. import BreadCrumb from "@/xt_pages/components/bread-crumb";
  418. export default {
  419. name: "tab",
  420. components: {BreadCrumb},
  421. data() {
  422. return {
  423. currentIndex: -1,
  424. isEdit: false,
  425. dialogTitle: "",
  426. drugdicFormVisible: false,
  427. drugwayFormVisible: false,
  428. templateFormVisible: false,
  429. efFormVisible: false,
  430. listLoading: true,
  431. activeName: "drugdic",
  432. createdTimes: 0,
  433. drugdics: [],
  434. adviceTemplates:[],
  435. drugways: [],
  436. executionFrequencyOptions: [],
  437. drugdicRules: {
  438. name: [{ required: true, message: "请填写医嘱名称" }]
  439. },
  440. drugwayRules: {
  441. name: [{ required: true, message: "请填写给药途径" }]
  442. },
  443. efRules: {
  444. name: [{ required: true, message: "请填写执行频率" }]
  445. },
  446. templateRules: {
  447. advice_name: [{ required: true, message: "请填写医嘱名称" }]
  448. },
  449. templateForm: {
  450. advice_name: "",
  451. advice_desc: "",
  452. single_dose: "",
  453. single_dose_unit: "",
  454. prescribing_number: "",
  455. prescribing_number_unit: "",
  456. delivery_way: "",
  457. execution_frequency: "",
  458. id: 0
  459. },
  460. drugdicForm: {
  461. name: "",
  462. spec: "",
  463. spec_unit: "",
  464. form: "",
  465. form_unit: "",
  466. id: 0
  467. },
  468. drugwayForm: {
  469. name: "",
  470. id: 0
  471. },
  472. efForm: {
  473. name: "",
  474. id: 0
  475. },
  476. unitsOption: [
  477. { lable: 1, name: "盒" },
  478. { lable: 2, name: "支" },
  479. { lable: 3, name: "瓶" },
  480. { lable: 4, name: "片" },
  481. { lable: 5, name: "袋" },
  482. { lable: 6, name: "g" },
  483. { lable: 7, name: "mg" },
  484. { lable: 8, name: "u" },
  485. { lable: 9, name: "ml" },
  486. { lable: 10, name: "枚" },
  487. { lable: 11, name: "粒" },
  488. { lable: 12, name: "μg" },
  489. { lable: 13, name: "iu" },
  490. { lable: 14, name: "包" },
  491. { lable: 15, name: "丸" }
  492. ],
  493. drugforms: [
  494. { lable: 1, name: "胶囊" },
  495. { lable: 2, name: "注射剂" },
  496. { lable: 3, name: "片剂" },
  497. { lable: 4, name: "注射液" },
  498. { lable: 5, name: "栓剂" },
  499. { lable: 6, name: "膏" },
  500. { lable: 7, name: "颗粒剂" },
  501. { lable: 8, name: "粉剂" },
  502. { lable: 9, name: "口服液" },
  503. { lable: 10, name: "干混悬剂" },
  504. { lable: 11, name: "丸剂" },
  505. { lable: 12, name: "气雾剂" },
  506. { lable: 13, name: "内服溶液" },
  507. { lable: 14, name: "外用溶液" },
  508. { lable: 15, name: "软膏剂" },
  509. { lable: 16, name: "胶剂" }
  510. ]
  511. };
  512. },
  513. created() {
  514. this.getAdviceConfig();
  515. },
  516. methods: {
  517. showCreatedTimes() {
  518. this.createdTimes = this.createdTimes + 1;
  519. },
  520. handleUpdateDrugDic(row, index) {
  521. this.currentIndex = index;
  522. this.drugdicForm = {
  523. name: row.name,
  524. spec: row.spec,
  525. spec_unit: row.spec_unit,
  526. form: row.form,
  527. form_unit: row.form_unit,
  528. id: row.id
  529. };
  530. this.drugdicFormVisible = true;
  531. this.dialogTitle = "编辑医嘱模版";
  532. this.isEdit = true;
  533. },
  534. handleCreateDrugDic() {
  535. this.drugdicForm = {
  536. name: "",
  537. spec: "",
  538. spec_unit: "",
  539. form: "",
  540. form_unit: "",
  541. id: 0
  542. };
  543. this.drugdicFormVisible = true;
  544. this.dialogTitle = "新增医嘱模版";
  545. this.isEdit = false;
  546. },
  547. handleCreateTemplate() {
  548. this.templateForm = {
  549. advice_name: "",
  550. advice_desc: "",
  551. single_dose: "",
  552. single_dose_unit: "",
  553. prescribing_number: "",
  554. prescribing_number_unit: "",
  555. delivery_way: "",
  556. execution_frequency: "",
  557. id: 0
  558. };
  559. this.templateFormVisible = true;
  560. this.dialogTitle = "新增医嘱模版";
  561. this.isEdit = false;
  562. },
  563. handleUpdateAdviceTemplate(row, index){
  564. this.templateForm = {
  565. advice_name: row.advice_name,
  566. advice_desc: row.advice_desc,
  567. single_dose: row.single_dose,
  568. single_dose_unit: row.single_dose_unit,
  569. prescribing_number: row.prescribing_number,
  570. prescribing_number_unit: row.prescribing_number_unit,
  571. delivery_way: row.delivery_way,
  572. execution_frequency: row.execution_frequency,
  573. id: row.id,
  574. };
  575. this.templateFormVisible = true;
  576. this.dialogTitle = "编辑医嘱模版";
  577. this.isEdit = true;
  578. this.currentIndex = index;
  579. },
  580. resetForm(formName) {
  581. this.$refs[formName].resetFields();
  582. },
  583. handleDeleteDrugDic(row, index) {
  584. this.$confirm("确认删除此医嘱模板?", "删除", {
  585. confirmButtonText: "确 定",
  586. cancelButtonText: "取 消",
  587. type: "warning"
  588. })
  589. .then(() => {
  590. DeleteDrugDic(row.id).then(response => {
  591. if (response.data.state == 0) {
  592. this.$message.error(response.data.msg);
  593. return false;
  594. } else {
  595. this.$notify({
  596. title: "成功",
  597. message: "医嘱模板已经删除",
  598. type: "success",
  599. duration: 2000
  600. });
  601. this.drugdics.splice(index, 1);
  602. }
  603. });
  604. })
  605. .catch(() => {});
  606. },
  607. handleDeleteAdviceTemplate(row, index) {
  608. this.$confirm("确认删除此医嘱模板?", "删除", {
  609. confirmButtonText: "确 定",
  610. cancelButtonText: "取 消",
  611. type: "warning"
  612. })
  613. .then(() => {
  614. DeleteAdviceTemplate(row.id).then(response => {
  615. if (response.data.state == 0) {
  616. this.$message.error(response.data.msg);
  617. return false;
  618. } else {
  619. this.$notify({
  620. title: "成功",
  621. message: "医嘱模板已经删除",
  622. type: "success",
  623. duration: 2000
  624. });
  625. this.adviceTemplates.splice(index, 1);
  626. }
  627. });
  628. })
  629. .catch(() => {});
  630. },
  631. submitDrugDic(formName) {
  632. this.$refs[formName].validate(valid => {
  633. if (valid) {
  634. if (this.isEdit) {
  635. UpdateDrugDic(this.drugdicForm.id, this.drugdicForm).then(
  636. response => {
  637. if (response.data.state == 0) {
  638. this.$message.error(response.data.msg);
  639. return false;
  640. } else {
  641. this.$notify({
  642. title: "成功",
  643. message: "修改成功",
  644. type: "success",
  645. duration: 2000
  646. });
  647. this.drugdicFormVisible = false;
  648. this.resetForm(formName);
  649. var drugdic = response.data.data.drugdic;
  650. this.drugdics[this.currentIndex].name = drugdic.name;
  651. this.drugdics[this.currentIndex].spec = drugdic.spec;
  652. this.drugdics[this.currentIndex].spec_unit =
  653. drugdic.spec_unit;
  654. this.drugdics[this.currentIndex].form = drugdic.form;
  655. this.drugdics[this.currentIndex].form_unit =
  656. drugdic.form_unit;
  657. this.drugdics[this.currentIndex].updated_time =
  658. drugdic.updated_time;
  659. this.currentIndex = -1;
  660. return false;
  661. }
  662. }
  663. );
  664. } else {
  665. CreateDrugDic(this.drugdicForm).then(response => {
  666. if (response.data.state == 0) {
  667. this.$message.error(response.data.msg);
  668. return false;
  669. } else {
  670. this.$notify({
  671. title: "成功",
  672. message: "添加成功",
  673. type: "success",
  674. duration: 2000
  675. });
  676. this.drugdicFormVisible = false;
  677. this.resetForm(formName);
  678. this.drugdics.unshift(response.data.data.drugdic);
  679. return false;
  680. }
  681. });
  682. }
  683. }
  684. });
  685. },
  686. submitTemplate(formName){
  687. this.$refs[formName].validate(valid => {
  688. this.templateForm.single_dose = parseFloat(this.templateForm.single_dose);
  689. this.templateForm.prescribing_number = parseFloat(this.templateForm.prescribing_number);
  690. if(isNaN(this.templateForm.single_dose)) {
  691. this.templateForm.single_dose = 0;
  692. }
  693. if(isNaN(this.templateForm.prescribing_number)) {
  694. this.templateForm.prescribing_number = 0;
  695. }
  696. if (valid) {
  697. if (this.isEdit) {
  698. UpdateAdviceTemplate(this.templateForm.id, this.templateForm).then(
  699. response => {
  700. if (response.data.state == 0) {
  701. this.$message.error(response.data.msg);
  702. return false;
  703. } else {
  704. this.$notify({
  705. title: "成功",
  706. message: "修改成功",
  707. type: "success",
  708. duration: 2000
  709. });
  710. this.templateFormVisible = false;
  711. this.resetForm(formName);
  712. var template = response.data.data.template;
  713. this.adviceTemplates[this.currentIndex].advice_name = template.advice_name;
  714. this.adviceTemplates[this.currentIndex].advice_desc = template.advice_desc;
  715. this.adviceTemplates[this.currentIndex].single_dose = template.single_dose;
  716. this.adviceTemplates[this.currentIndex].single_dose_unit = template.single_dose_unit;
  717. this.adviceTemplates[this.currentIndex].delivery_way = template.delivery_way;
  718. this.adviceTemplates[this.currentIndex].execution_frequency = template.execution_frequency;
  719. this.adviceTemplates[this.currentIndex].prescribing_number = template.prescribing_number;
  720. this.adviceTemplates[this.currentIndex].prescribing_number_unit = template.prescribing_number_unit;
  721. this.currentIndex = -1;
  722. return false;
  723. }
  724. }
  725. );
  726. } else {
  727. CreateAdviceTemplate(this.templateForm).then(response => {
  728. if (response.data.state == 0) {
  729. this.$message.error(response.data.msg);
  730. return false;
  731. } else {
  732. this.$notify({
  733. title: "成功",
  734. message: "添加成功",
  735. type: "success",
  736. duration: 2000
  737. });
  738. this.templateFormVisible = false;
  739. this.resetForm(formName);
  740. this.adviceTemplates.unshift(response.data.data.template);
  741. return false;
  742. }
  743. });
  744. }
  745. }
  746. });
  747. },
  748. handleCreateDrugWay() {
  749. this.drugwayForm = {
  750. name: "",
  751. id: 0
  752. };
  753. this.drugwayFormVisible = true;
  754. this.dialogTitle = "新增给药途径";
  755. this.isEdit = false;
  756. },
  757. handleUpdateDrugWay(row, index) {
  758. this.currentIndex = index;
  759. this.drugwayForm = {
  760. name: row.name,
  761. id: row.id
  762. };
  763. this.drugwayFormVisible = true;
  764. this.dialogTitle = "编辑给药途径";
  765. this.isEdit = true;
  766. },
  767. submitDrugWay(formName) {
  768. this.$refs[formName].validate(valid => {
  769. if (valid) {
  770. if (this.isEdit) {
  771. UpdateDrugWay(this.drugwayForm.id, this.drugwayForm).then(
  772. response => {
  773. if (response.data.state == 0) {
  774. this.$message.error(response.data.msg);
  775. return false;
  776. } else {
  777. this.$notify({
  778. title: "成功",
  779. message: "修改成功",
  780. type: "success",
  781. duration: 2000
  782. });
  783. this.drugwayFormVisible = false;
  784. this.resetForm(formName);
  785. var drugway = response.data.data.drugway;
  786. this.drugways[this.currentIndex].name = drugway.name;
  787. this.drugways[this.currentIndex].updated_time =
  788. drugway.updated_time;
  789. this.currentIndex = -1;
  790. return false;
  791. }
  792. }
  793. );
  794. } else {
  795. CreateDrugWay(this.drugwayForm).then(response => {
  796. if (response.data.state == 0) {
  797. this.$message.error(response.data.msg);
  798. return false;
  799. } else {
  800. this.$notify({
  801. title: "成功",
  802. message: "添加成功",
  803. type: "success",
  804. duration: 2000
  805. });
  806. this.drugwayFormVisible = false;
  807. this.resetForm(formName);
  808. this.drugways.unshift(response.data.data.drugway);
  809. return false;
  810. }
  811. });
  812. }
  813. }
  814. });
  815. },
  816. handleDeleteDrugWay(row, index) {
  817. this.$confirm("确认删除此给药途径?", "删除", {
  818. confirmButtonText: "确 定",
  819. cancelButtonText: "取 消",
  820. type: "warning"
  821. })
  822. .then(() => {
  823. DeleteDrugWay(row.id).then(response => {
  824. if (response.data.state == 0) {
  825. this.$message.error(response.data.msg);
  826. return false;
  827. } else {
  828. this.$notify({
  829. title: "成功",
  830. message: "给药途径已经删除",
  831. type: "success",
  832. duration: 2000
  833. });
  834. this.drugways.splice(index, 1);
  835. }
  836. });
  837. })
  838. .catch(() => {});
  839. },
  840. handleCreateEF() {
  841. this.efForm = {
  842. name: "",
  843. id: 0
  844. };
  845. this.efFormVisible = true;
  846. this.dialogTitle = "新增执行频率";
  847. this.isEdit = false;
  848. },
  849. handleUpdateEF(row, index) {
  850. this.currentIndex = index;
  851. this.efForm = {
  852. name: row.name,
  853. id: row.id
  854. };
  855. this.efFormVisible = true;
  856. this.dialogTitle = "编辑执行频率";
  857. this.isEdit = true;
  858. },
  859. submitEF(formName) {
  860. this.$refs[formName].validate(valid => {
  861. if (valid) {
  862. if (this.isEdit) {
  863. UpdateExecutionFrequency(this.efForm.id, this.efForm).then(
  864. response => {
  865. if (response.data.state == 0) {
  866. this.$message.error(response.data.msg);
  867. return false;
  868. } else {
  869. this.$notify({
  870. title: "成功",
  871. message: "修改成功",
  872. type: "success",
  873. duration: 2000
  874. });
  875. this.efFormVisible = false;
  876. this.resetForm(formName);
  877. var ef = response.data.data.ef;
  878. this.executionFrequencyOptions[this.currentIndex].name =
  879. ef.name;
  880. this.executionFrequencyOptions[
  881. this.currentIndex
  882. ].updated_time = ef.updated_time;
  883. this.currentIndex = -1;
  884. return false;
  885. }
  886. }
  887. );
  888. } else {
  889. CreateExecutionFrequency(this.efForm).then(response => {
  890. if (response.data.state == 0) {
  891. this.$message.error(response.data.msg);
  892. return false;
  893. } else {
  894. this.$notify({
  895. title: "成功",
  896. message: "添加成功",
  897. type: "success",
  898. duration: 2000
  899. });
  900. this.efFormVisible = false;
  901. this.resetForm(formName);
  902. this.executionFrequencyOptions.unshift(response.data.data.ef);
  903. return false;
  904. }
  905. });
  906. }
  907. }
  908. });
  909. },
  910. handleDeleteEF(row, index) {
  911. this.$confirm("确认删除此执行频率?", "删除", {
  912. confirmButtonText: "确 定",
  913. cancelButtonText: "取 消",
  914. type: "warning"
  915. })
  916. .then(() => {
  917. DeleteExecutionFrequency(row.id).then(response => {
  918. if (response.data.state == 0) {
  919. this.$message.error(response.data.msg);
  920. return false;
  921. } else {
  922. this.$notify({
  923. title: "成功",
  924. message: "执行频率已经删除",
  925. type: "success",
  926. duration: 2000
  927. });
  928. this.executionFrequencyOptions.splice(index, 1);
  929. }
  930. });
  931. })
  932. .catch(() => {});
  933. },
  934. getAdviceConfig() {
  935. getAdviceConfig().then(response => {
  936. if (response.data.state == 1) {
  937. this.drugways = response.data.data.drugways;
  938. this.executionFrequencyOptions = response.data.data.efs;
  939. this.drugdics = response.data.data.drugs;
  940. this.adviceTemplates = response.data.data.advice_templates;
  941. this.listLoading = false;
  942. }
  943. });
  944. }
  945. }
  946. };
  947. </script>
  948. <style scoped>
  949. .tab-container {
  950. margin: 30px;
  951. }
  952. </style>