add.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <div class="p-2">
  3. <el-card>
  4. <!-- 新增顶部操作栏 -->
  5. <el-row>
  6. <el-col :span="4">
  7. <el-button type="primary" plain @click="close"
  8. style="margin-right: 20px;margin-left: 30px;">返回</el-button>
  9. <span style="font-size: 14px; vertical-align: middle;">{{ screeningName }}</span>
  10. </el-col>
  11. </el-row>
  12. </el-card>
  13. <el-card>
  14. <template v-for="item,idx in form.otherInfo">
  15. <template v-if="item.questionChildType == 'singleChoice'">
  16. <template v-if="item.arrangement == '2'">
  17. <div style="margin-bottom: 20px;padding-top: 20px;"
  18. :style="{'border-top':idx==0?'none':'1px dashed #e5e7eb'}" class="zebra-row">
  19. <el-row>
  20. <el-col :span="24">
  21. <span style="color: #f56c6c; margin-right: 4px;" v-show="item.required">*</span>
  22. <span style="font-weight: bold;">{{ item.title }}</span>
  23. </el-col>
  24. </el-row>
  25. <el-row style="margin-bottom: 20px;">
  26. <el-col :span="24">
  27. <div class="radio-card">
  28. <el-radio-group v-model="item.value" style="margin-top: 8px;">
  29. <template v-for="ctl,i in item.contentList">
  30. <el-radio :label="ctl.label" :value="i" :disabled="isView">
  31. <span class="option-content">
  32. <span v-if="ctl.img" class="option-img">
  33. <miniImageUpload :limit="1" v-model="ctl.img"
  34. :disabled="true" />
  35. </span>
  36. <span>{{ ctl.label }}</span>
  37. </span>
  38. </el-radio>
  39. </template>
  40. </el-radio-group>
  41. </div>
  42. </el-col>
  43. </el-row>
  44. </div>
  45. </template>
  46. <template v-else>
  47. <div style="margin-bottom: 10px; padding-top: 20px;"
  48. :style="{'border-top':idx==0?'none':'1px dashed #e5e7eb'}" class="zebra-row">
  49. <el-row>
  50. <el-col :span="24">
  51. <span style="color: #f56c6c; margin-right: 4px;" v-show="item.required">*</span>
  52. <span style="font-weight: bold;">{{ item.title }}</span>
  53. <el-radio-group v-model="item.value" class="horizontal-radio-group"
  54. style="margin-top: 8px;">
  55. <template v-for="ctl,i in item.contentList">
  56. <el-radio :label="ctl.label" :value="i" :disabled="isView">
  57. <span class="option-content">
  58. <span v-if="ctl.img" class="option-img">
  59. <miniImageUpload :limit="1" v-model="ctl.img"
  60. :disabled="true" />
  61. </span>
  62. <span>{{ ctl.label }}</span>
  63. </span>
  64. </el-radio>
  65. </template>
  66. </el-radio-group>
  67. </el-col>
  68. </el-row>
  69. </div>
  70. </template>
  71. </template>
  72. <template v-if="item.questionChildType == 'multipleChoice'">
  73. <template v-if="item.arrangement == '2'">
  74. <div style="margin-bottom: 10px; padding-top: 20px;"
  75. :style="{'border-top':idx==0?'none':'1px dashed #e5e7eb'}" class="zebra-row">
  76. <el-row>
  77. <el-col :span="24">
  78. <span style="color: #f56c6c; margin-right: 4px;" v-show="item.required">*</span>
  79. <span style="font-weight: bold;">{{ item.title }}</span>
  80. </el-col>
  81. </el-row>
  82. <el-row style="margin-bottom: 20px;">
  83. <el-col :span="24">
  84. <div class="checkbox-vertical-card">
  85. <el-checkbox-group v-model="item.value" style="margin-top: 8px;">
  86. <template v-for="ctl,i in item.contentList">
  87. <el-checkbox :label="ctl.label" :value="i" :disabled="isView">
  88. <span class="option-content">
  89. <span v-if="ctl.img" class="option-img">
  90. <miniImageUpload :limit="1" v-model="ctl.img"
  91. :disabled="true" />
  92. </span>
  93. <span>{{ ctl.label }}</span>
  94. </span>
  95. </el-checkbox>
  96. </template>
  97. </el-checkbox-group>
  98. </div>
  99. </el-col>
  100. </el-row>
  101. </div>
  102. </template>
  103. <template v-else>
  104. <div style="margin-bottom: 10px; padding-top: 20px;"
  105. :style="{'border-top':idx==0?'none':'1px dashed #e5e7eb'}" class="zebra-row">
  106. <el-row>
  107. <el-col :span="24">
  108. <span style="color: #f56c6c; margin-right: 4px;" v-show="item.required">*</span>
  109. <span style="font-weight: bold;">{{ item.title }}</span>
  110. <el-checkbox-group v-model="item.value" class="horizontal-checkbox-group"
  111. style="margin-top: 8px;">
  112. <template v-for="ctl,i in item.contentList">
  113. <el-checkbox :label="ctl.label" :value="i" :disabled="isView">
  114. <span class="option-content">
  115. <span v-if="ctl.img" class="option-img">
  116. <miniImageUpload :limit="1" v-model="ctl.img"
  117. :disabled="true" />
  118. </span>
  119. <span>{{ ctl.label }}</span>
  120. </span>
  121. </el-checkbox>
  122. </template>
  123. </el-checkbox-group>
  124. </el-col>
  125. </el-row>
  126. </div>
  127. </template>
  128. </template>
  129. <template v-if="item.questionChildType == 'scaleQuestions'">
  130. <div style="margin-bottom: 10px; padding-top: 20px;"
  131. :style="{ 'border-top': idx == 0 ? 'none' : '1px dashed #e5e7eb' }" class="zebra-row">
  132. <el-row>
  133. <el-col :span="24">
  134. <span style="color: #f56c6c; margin-right: 4px;" v-show="item.required">*</span>
  135. <span style="font-weight: bold;">{{ item.title }}</span>
  136. <div style="overflow-x: scroll;margin-top: 8px;margin-left: 30px;">
  137. <div class="custom-radio-grid">
  138. <div v-for="ctl,n in item.contentList" :key="n"
  139. @click="selectScaleQuestions(idx,n)"
  140. :class="['custom-radio-cell', {'is-selected':ctl.value!=null,'cell': item.contentList.length === n+1, 'is-last': n+1 > 1 }]">
  141. {{ n+1 }}
  142. </div>
  143. </div>
  144. <div class="custom-radio-grid">
  145. <div v-for="ctl, n in item.contentList" :key="ctl.nameEn" style="border: none;"
  146. :class="['custom-radio-cell']">
  147. {{ ctl.label }}
  148. </div>
  149. </div>
  150. </div>
  151. </el-col>
  152. </el-row>
  153. </div>
  154. </template>
  155. <template v-if="item.questionChildType == 'matrixScale'">
  156. <div style="margin-bottom: 10px; padding-top: 20px;"
  157. :style="{ 'border-top': idx == 0 ? 'none' : '1px dashed #e5e7eb' }" class="zebra-row">
  158. <el-row>
  159. <el-col :span="24">
  160. <span style="color: #f56c6c; margin-right: 4px;" v-show="item.required">*</span>
  161. <span style="font-weight: bold;">{{ item.title }}</span>
  162. <div style="border-bottom: 1px solid #e5e7eb;width: 98%;margin-left: 30px;">
  163. <el-row :gutter="10" class="mb8">
  164. <el-col :span="3" style="margin-top: 30px;">
  165. </el-col>
  166. <template v-for="clt in item.contentList">
  167. <template v-if="clt.optionFlag">
  168. <el-col :span="1" align="center"
  169. style="margin-top: 30px;margin-left: 15px;">
  170. {{ clt.optionContent }}
  171. </el-col>
  172. </template>
  173. </template>
  174. </el-row>
  175. <template v-for="clt, i1 in item.contentList">
  176. <el-row :gutter="10" class="mb8">
  177. <el-col :span="3" style="margin-top: 10px;">
  178. <template v-if="clt.labelFlag">
  179. 标题{{ i1 + 1 }}:{{ clt.label }}
  180. </template>
  181. </el-col>
  182. <template v-for="clt2, i2 in item.contentList">
  183. <el-col :span="1" align="center" style="margin-left: 15px;">
  184. <template v-if="clt2.optionFlag && clt.labelFlag">
  185. <el-radio-group v-model="clt.value" :disabled="isView">
  186. <el-radio :value="(i1+1)*1000+i2" size="large" />
  187. </el-radio-group>
  188. </template>
  189. </el-col>
  190. </template>
  191. </el-row>
  192. </template>
  193. </div>
  194. </el-col>
  195. </el-row>
  196. </div>
  197. </template>
  198. </template>
  199. </el-card>
  200. <el-card shadow="always" class="card-footer" v-if="!isView">
  201. <div>
  202. <el-button type="primary" size="large" @click="submitForm" :loading="buttonLoading"
  203. v-hasPermi="['system:hospital:add']">
  204. &nbsp;&nbsp;&nbsp;提交&nbsp;&nbsp;&nbsp;
  205. </el-button>
  206. </div>
  207. </el-card>
  208. </div>
  209. </template>
  210. <script setup name="Screening" lang="ts">
  211. import { listScreening, getScreening, delScreening, addScreening, updateScreening } from '@/api/patients/screening';
  212. import { ScreeningVO, ScreeningQuery, ScreeningForm } from '@/api/patients/screening/types';
  213. import { getScreeningAssessmentConfig } from '@/api/system/screeningAssessmentConfig';
  214. import {ScreeningAssessmentConfigForm} from '@/api/system/screeningAssessmentConfig/types';
  215. import { ref } from 'vue'
  216. let paramForm = ref<ScreeningForm>({});
  217. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  218. const screeningName = ref('');
  219. const { patientInfo } = defineProps<{ patientInfo: any }>()
  220. const emit = defineEmits(['change'])
  221. let form=ref<ScreeningAssessmentConfigForm>({});
  222. const buttonLoading = ref(false);
  223. let isView=ref(false);
  224. /** 查询营养筛查列表 */
  225. const getList = async () => {
  226. let id = patientInfo.other;
  227. let reg=/^[0-9]*$/;
  228. if (!reg.test(id.toString())) {
  229. id = window.atob(id);
  230. isView.value = true;
  231. const res =await getScreening(id as string);
  232. const content =JSON.parse(res.data.content);
  233. screeningName.value = content.name;
  234. Object.assign(form.value, content);
  235. } else {
  236. isView.value = false;
  237. const res = await getScreeningAssessmentConfig(id as string);
  238. screeningName.value = res.data.name;
  239. Object.assign(form.value, res.data);
  240. }
  241. }
  242. const close = async () => {
  243. emit('change', 'nutritionScreening');
  244. };
  245. /** 提交按钮 */
  246. const submitForm = async () => {
  247. for (let i = 0, len = form.value.otherInfo.length; i < len; i++) {
  248. let item = form.value.otherInfo[i];
  249. if (item.required && (item.value == null || item.value == undefined)) {
  250. proxy?.$modal.msgError("请确保必填项(第" + (i + 1) + "题)不为空");
  251. return;
  252. }
  253. }
  254. buttonLoading.value = true;
  255. paramForm.value.content = JSON.stringify(form.value);
  256. if (paramForm.value.id) {
  257. await updateScreening(paramForm.value).finally(() => buttonLoading.value = false);
  258. } else {
  259. await addScreening(paramForm.value).finally(() => buttonLoading.value = false);
  260. }
  261. proxy?.$modal.msgSuccess("操作成功");
  262. close();
  263. }
  264. const selectScaleQuestions = async (idx:number, n:number) => {
  265. if(isView.value){
  266. return;
  267. }
  268. let other = form.value.otherInfo[idx];
  269. if (!other.value) {
  270. other.value = [];
  271. }
  272. let ctl = other.contentList[n];
  273. if (ctl.value!=null) {
  274. ctl.value = null;
  275. let newList=[];
  276. for (let i = 0, len = other.value.length; i < len; i++) {
  277. if (other.value[i] != n) {
  278. newList.push(other.value[i]);
  279. }
  280. }
  281. other.value=newList;
  282. } else {
  283. ctl.value = n;
  284. other.value.push(n);
  285. }
  286. }
  287. onMounted(() => {
  288. paramForm.value.patientId=patientInfo.id;
  289. paramForm.value.patientNo=patientInfo.outpatientNo;
  290. paramForm.value.visitType=patientInfo.type;
  291. paramForm.value.configId=patientInfo.other;
  292. getList();
  293. });
  294. </script>
  295. <style scoped>
  296. .screening-type-grid {
  297. display: flex;
  298. flex-wrap: wrap;
  299. gap: 8px;
  300. }
  301. .screening-type-btn {
  302. font-weight: bold;
  303. font-size: 16px;
  304. height: 48px;
  305. border-radius: 8px;
  306. }
  307. .radio-card {
  308. display: inline-block;
  309. }
  310. .radio-card .el-radio-group {
  311. display: flex;
  312. flex-direction: column;
  313. align-items: flex-start;
  314. }
  315. .radio-card .el-radio {
  316. margin-bottom: 3px;
  317. margin-left: 30px;
  318. }
  319. .radio-card el-radio:last-child {
  320. margin-bottom: 0;
  321. }
  322. .horizontal-radio-group {
  323. display: flex;
  324. flex-direction: row;
  325. align-items: center;
  326. margin-left: 16px;
  327. }
  328. .horizontal-radio-group .el-radio {
  329. margin-right: 32px;
  330. margin-bottom: 0;
  331. margin-left: 14px;
  332. }
  333. .horizontal-checkbox-group {
  334. display: flex;
  335. flex-wrap: wrap;
  336. align-items: center;
  337. margin-left: 30px;
  338. }
  339. .horizontal-checkbox-group .el-checkbox {
  340. margin-right: 32px;
  341. margin-bottom: 8px;
  342. }
  343. .checkbox-vertical-card .el-checkbox-group {
  344. display: flex;
  345. flex-direction: column;
  346. align-items: flex-start;
  347. }
  348. .checkbox-vertical-card .el-checkbox {
  349. margin-bottom: 10px;
  350. margin-left: 30px;
  351. }
  352. .checkbox-vertical-card .el-checkbox:last-child {
  353. margin-bottom: 0;
  354. }
  355. /* 斑马色:偶数题背景色 */
  356. .zebra-row:nth-child(even) {
  357. background: #fafafa;
  358. }
  359. /* 斑马色:奇数题背景色 */
  360. .zebra-row:nth-child(odd) {
  361. background: #fff;
  362. }
  363. .card-footer{
  364. z-index: 99;
  365. bottom: 0px;
  366. left: calc(var(--left-menu-max-width) + var(--app-content-padding));
  367. right: 0px;
  368. height: 90px;
  369. display: flex;
  370. justify-content: center;
  371. align-items: center;
  372. }
  373. .custom-radio-grid {
  374. display: flex;
  375. /* border: 1px solid #bfc4cc; */
  376. border-radius: 4px;
  377. background: #fff;
  378. margin-bottom: 16px;
  379. }
  380. .custom-radio-cell {
  381. width: 100px;
  382. flex: none;
  383. text-align: center;
  384. border: 1px solid #bfc4cc;
  385. margin: 0 !important;
  386. height: 40px;
  387. line-height: 20px;
  388. font-size: 18px;
  389. font-weight: normal;
  390. background: #fff;
  391. border-radius: 0 !important;
  392. cursor: pointer;
  393. user-select: none;
  394. transition: background 0.2s;
  395. word-break: break-all;
  396. white-space: normal;
  397. overflow-wrap: break-word;
  398. display: flex;
  399. align-items: center;
  400. justify-content: center;
  401. padding: 0 5px;
  402. }
  403. .custom-radio-cell:last-child {
  404. border-right: none;
  405. }
  406. .custom-radio-cell .el-radio__input {
  407. display: none !important;
  408. }
  409. .custom-radio-cell .el-radio__label {
  410. padding: 0;
  411. width: 100%;
  412. display: block;
  413. text-align: center;
  414. cursor: pointer;
  415. }
  416. .custom-radio-cell .cell {
  417. border-right: 1px solid #bfc4cc;
  418. }
  419. .is-selected {
  420. background-color: #ccf0a4; /* Element Plus 主色 */
  421. color: #fff;
  422. border-radius: 6px;
  423. box-shadow: 0 2px 8px rgba(64,158,255,0.08);
  424. transition: background 0.2s, color 0.2s, border 0.2s;
  425. }
  426. .custom-radio-cell.is-last {
  427. border-right: 1px solid #bfc4cc;
  428. border-left: none;
  429. }
  430. </style>