EditorBody.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <script setup lang="tsx">
  2. import {
  3. clinicalPathwayType,
  4. key,
  5. keyName,
  6. execute,
  7. execType,
  8. } from "@/views/dictionary/clinical-pathway/index";
  9. import { ViewPathwayStage, WorkType } from "@/ts-type/clinical-pathway";
  10. import { CyMessageBox } from "@/utils/cy-message-box";
  11. import {
  12. addWorkItem,
  13. deleteWorkItem,
  14. getOrderTemplateByWorkId,
  15. updateDay,
  16. updateWorkItem,
  17. } from "@/api/dictionary/clinical-pathway/clinical-pathway";
  18. import { useDialog } from "@/components/cy/CyDialog/index";
  19. import YzTable from "./compoents/YzTable.vue";
  20. import XEUtils from "xe-utils";
  21. const { store, mutation } = inject(key) as clinicalPathwayType;
  22. const tmpData = computed<ViewPathwayStage["execute"]>(() => {
  23. const json = store.stageJson[store.currentDay];
  24. return json?.execute;
  25. });
  26. function handleEditorWork(row) {
  27. row._isEditor = true;
  28. }
  29. function handleSaveWork(row) {
  30. updateWorkItem(row).then(res => {
  31. mutation.renderingData();
  32. row._isEditor = false;
  33. });
  34. }
  35. async function handleDeleteWork(exec: any[], index, row) {
  36. await CyMessageBox.confirm({
  37. type: "delete",
  38. message: "是否删除删除后无法找回",
  39. });
  40. deleteWorkItem(row.id).then(() => {
  41. exec.splice(index, 1);
  42. mutation.renderingData();
  43. });
  44. }
  45. async function addType(value) {
  46. CyMessageBox.prompt({
  47. message: "项目名称",
  48. }).then(res => {
  49. const json = store.stageJson[store.currentDay];
  50. addWorkItem(json.id, res.value, value).then(res => {
  51. if (!json.execute[execute[value]]) {
  52. json.execute[execute[value]] = [];
  53. }
  54. json.execute[execute[value]].push(res);
  55. mutation.renderingData();
  56. });
  57. });
  58. }
  59. async function addWorkContent(value, type) {
  60. if (type === "zhenliao" || type === "huli") {
  61. return;
  62. }
  63. const orderTemplate = await getOrderTemplateByWorkId(value.id);
  64. useDialog(YzTable, {
  65. dialogProps: {
  66. title: "编辑医嘱",
  67. fullscreen: true,
  68. },
  69. params: {
  70. wordId: value.id,
  71. wordType: type,
  72. defaultOrder: orderTemplate,
  73. },
  74. }).catch(XEUtils.noop);
  75. }
  76. function updateDayExecutionDays() {
  77. const json = store.currentDayJson;
  78. if (store.tmpExecutionDay === json.executionDay) {
  79. return;
  80. }
  81. updateDay({
  82. id: json.id,
  83. executionDay: store.tmpExecutionDay,
  84. })
  85. .then(() => {
  86. store.currentDayJson.executionDay = store.tmpExecutionDay;
  87. mutation.renderingData();
  88. })
  89. .catch(() => {
  90. store.tmpExecutionDay = json.executionDay;
  91. });
  92. }
  93. </script>
  94. <template>
  95. <div v-if="store.currentDay !== -1">
  96. <el-button type="danger" @click="mutation.delDay()">删除天</el-button>
  97. <el-divider direction="vertical" />
  98. <el-button @click="addType(WorkType.MAIN_DIAGNOSIS)"
  99. >新增主要诊疗
  100. </el-button>
  101. <el-button @click="addType(WorkType.LONG_TERM_ORDER)">长期医嘱</el-button>
  102. <el-button @click="addType(WorkType.TEMPORARY_ORDER)">临时医嘱</el-button>
  103. <el-button @click="addType(WorkType.MAIN_NURSING)">主要护理</el-button>
  104. <el-divider direction="vertical" />
  105. 执行天数:
  106. <el-input-number
  107. :min="1"
  108. :controls="false"
  109. v-model="store.tmpExecutionDay"
  110. @blur="updateDayExecutionDays"
  111. />
  112. <hr />
  113. <table class="pathway_editor-table">
  114. <colgroup>
  115. <col style="width: 90px" />
  116. <col style="width: 400px" />
  117. <col style="width: 170px" />
  118. <col style="width: 170px" />
  119. </colgroup>
  120. <thead>
  121. <tr>
  122. <th>分类</th>
  123. <th>内容</th>
  124. <th>执行方式</th>
  125. <th>操作</th>
  126. </tr>
  127. </thead>
  128. <template v-for="item in execute">
  129. <tr v-if="tmpData[item]">
  130. <td
  131. :rowspan="tmpData[item].length + 1"
  132. style="text-align: center; vertical-align: middle"
  133. >
  134. {{ keyName[item] }}
  135. </td>
  136. </tr>
  137. <tr v-for="(value, index) in tmpData?.[item] ?? []" :key="key">
  138. <td>
  139. <el-input v-model="value.workContent" v-if="value._isEditor" />
  140. <el-button
  141. v-else
  142. @click="addWorkContent(value, item)"
  143. text
  144. type="primary"
  145. >
  146. {{ value.workContent }}
  147. </el-button>
  148. </td>
  149. <td>
  150. <select v-if="value._isEditor" v-model="value.execType">
  151. <option v-for="(optitem, optIndex) in execType" :value="optIndex">
  152. {{ optitem }}
  153. </option>
  154. </select>
  155. <span v-else>
  156. {{ execType[value.execType] }}
  157. </span>
  158. </td>
  159. <td>
  160. <el-button
  161. v-if="value._isEditor"
  162. type="success"
  163. @click="handleSaveWork(value)"
  164. >
  165. 保存
  166. </el-button>
  167. <el-button v-else @click="handleEditorWork(value)" type="primary"
  168. >编辑
  169. </el-button>
  170. <el-button
  171. type="danger"
  172. @click="handleDeleteWork(tmpData[item], index, value)"
  173. >删除
  174. </el-button>
  175. </td>
  176. </tr>
  177. </template>
  178. </table>
  179. </div>
  180. </template>
  181. <style lang="scss">
  182. .pathway_editor-table {
  183. letter-spacing: 1px;
  184. width: max-content;
  185. word-break: break-all;
  186. margin: 0;
  187. padding: 0;
  188. text-align: start;
  189. border-collapse: collapse;
  190. border-spacing: 0;
  191. border: 1px solid #000;
  192. td {
  193. border: 1px black solid;
  194. margin: 0;
  195. vertical-align: top;
  196. padding: 10px;
  197. }
  198. tr {
  199. padding: 0;
  200. margin: 0;
  201. }
  202. }
  203. </style>