AddDisease.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <div class="AddChemicalAndCommonMappingWrapper clearfix">
  3. <crumbs
  4. :title="isEdit ? '诊断关联维护--修改关联 | '+ hospitaiName : '诊断关联维护--添加关联 | ' + hospitaiName"
  5. class="topBack"
  6. :param="$route.params"
  7. linkTo="Disease"
  8. ></crumbs>
  9. <el-form
  10. :model="form"
  11. :rules="rules"
  12. label-position="right"
  13. label-width="120px"
  14. ref="relationForm"
  15. >
  16. <div class="AddChemicalAndCommonMappingBox clearfix">
  17. <div class="titleBox clearfix">
  18. <p class="title">医院术语</p>
  19. <p class="title">标准术语</p>
  20. </div>
  21. <div class="leftBox clearfix">
  22. <el-row>
  23. <el-col :span="16">
  24. <el-form-item label="诊断名称:" prop="hisName">
  25. <el-input v-model.trim="form.hisName" clearable style="minWidth: 240px"></el-input>
  26. </el-form-item>
  27. <el-form-item label="诊断名称预览:">
  28. <span class="previewInfo" style="minWidth: 240px">{{form.hisName}}</span>
  29. </el-form-item>
  30. </el-col>
  31. </el-row>
  32. </div>
  33. <div class="midBox">
  34. <img class="midLogo" src="../../../images/relation.png" alt />
  35. <p class="midTitle">相互关联</p>
  36. </div>
  37. <div class="rightBox">
  38. <el-row>
  39. <el-col :span="16">
  40. <el-form-item label="诊断名称:" prop="searchText">
  41. <el-select
  42. style="width:100%;minWidth: 240px"
  43. v-model="form.searchText"
  44. filterable
  45. remote
  46. clearable
  47. :loading="showDrop"
  48. loading-text="加载中..."
  49. @change="changeWord"
  50. @focus="handleFocus"
  51. @visible-change="handleVisible"
  52. placeholder="搜索"
  53. :remote-method="searchTerms"
  54. reserve-keyword
  55. >
  56. <el-option
  57. v-for="item in uniqueNameList"
  58. :key="item.icd10Code"
  59. :label="item.name"
  60. :value="item"
  61. :title="item.name"
  62. ></el-option>
  63. </el-select>
  64. </el-form-item>
  65. <el-form-item label="诊断名称预览:">
  66. <!-- <span class="previewInfo">{{!isEdit ? form.searchText.name : form.searchText}}</span> -->
  67. <span class="previewInfo" style="minWidth: 240px">{{form.searchText}}</span>
  68. </el-form-item>
  69. <el-form-item label="ICD编码:">
  70. <span class="previewInfo" style="minWidth: 240px">{{form.icdCode}}</span>
  71. </el-form-item>
  72. </el-col>
  73. </el-row>
  74. </div>
  75. </div>
  76. <div class="btn">
  77. <el-form-item>
  78. <el-button type="primary" :disabled="saveDisable" @click="submitForm">确定</el-button>
  79. </el-form-item>
  80. </div>
  81. </el-form>
  82. </div>
  83. </template>
  84. <script>
  85. import api from '@api/cdss.js';
  86. export default {
  87. name: 'AddDisease',
  88. data() {
  89. return {
  90. isEdit: false,
  91. hospitaiName: '',
  92. editId: '',
  93. uniqueNameList: [],
  94. form: {
  95. searchText: '', //搜索字段
  96. hisName: '',
  97. icdCode: ''
  98. },
  99. rules: {
  100. hisName: [
  101. { required: true, message: '请输入诊断名称', trigger: 'change' },
  102. { max: 80, message: '诊断名称最多80字', trigger: 'change' }
  103. ],
  104. searchText: [
  105. { required: true, message: '请选择诊断名称', trigger: 'change' }
  106. ]
  107. },
  108. saveDisable: false, //保存按钮禁止点击
  109. showDrop: false, //下拉框显示文字
  110. hospitalId: ''
  111. };
  112. },
  113. created() {
  114. //修改
  115. const { isEdit, data, hospitaiName } = this.$route.params;
  116. // console.log(data, 'data===================');
  117. this.hospitalId = data && data.hospitalId;
  118. this.hospitaiName = hospitaiName;
  119. if (isEdit) {
  120. this.isEdit = isEdit;
  121. this.editId = data.id;
  122. this.form.hisName = data.hisName;
  123. this.form.searchText = data.uniqueName;
  124. this.form.icdCode = data.icdCode;
  125. }
  126. },
  127. methods: {
  128. // 搜索列表
  129. searchTerms(query) {
  130. if (!query) {
  131. this.uniqueNameList = [];
  132. return;
  133. }
  134. this.showDrop = true;
  135. let params = {
  136. type: 4, //诊断
  137. inputStr: query,
  138. sex: 3,
  139. age: 0
  140. };
  141. api.retrievalSearch(params).then(res => {
  142. this.showDrop = false;
  143. if (res.data.code === '0') {
  144. this.uniqueNameList = res.data.data.diseaseNames;
  145. }
  146. });
  147. },
  148. changeWord(newValue) {
  149. this.form.searchText = newValue.name;
  150. this.form.icdCode = newValue.icd10Code;
  151. },
  152. handleVisible(flag) {
  153. if (!flag) {
  154. this.uniqueNameList = [];
  155. }
  156. },
  157. // 获取焦点
  158. handleFocus() {},
  159. // 初始化表单数据
  160. initForm() {
  161. this.form.hisName = '';
  162. this.form.searchText = '';
  163. this.form.icdCode = '';
  164. },
  165. // 建立关联-参数处理
  166. submitForm() {
  167. this.$refs.relationForm.validate(valid => {
  168. if (valid) {
  169. const { searchText, hisName, icdCode } = this.form;
  170. let params = {
  171. hisName: hisName,
  172. uniqueName: searchText,
  173. icdCode: icdCode,
  174. hospitalId: this.hospitalId
  175. };
  176. this.showSaveDialog(params);
  177. } else {
  178. console.log('error submit!!');
  179. return false;
  180. }
  181. });
  182. },
  183. // 建立关联-映射关系是否已存在
  184. showSaveDialog(params) {
  185. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  186. api
  187. .diseaseIsExistRecord(params)
  188. .then(res => {
  189. if (!res.data.data) {
  190. // 不存在,创建新的关联
  191. // 如果是编辑时,需要携带id
  192. if (this.isEdit) {
  193. params = { ...params, id: this.editId };
  194. }
  195. this.saveLisMapping(params, '保存成功', 'success');
  196. } else {
  197. // 已存在,提示修改
  198. this.warning('该条关联已存在,无法添加');
  199. this.saveDisable = false;
  200. }
  201. })
  202. .catch(err => {
  203. if (err.code === '900010001') {
  204. return false;
  205. }
  206. this.warning(err);
  207. });
  208. },
  209. // 映射关系不存在-建立关联
  210. saveLisMapping(params, msg, type) {
  211. api.saveOrUpdateDiseaseRecord(params).then(res => {
  212. if (res.data.code === '0') {
  213. this.warning(res.data.msg || msg, type);
  214. this.initForm();
  215. this.$router.push({
  216. name: 'Disease',
  217. params: Object.assign({}, this.$route.params, {
  218. currentPage: 1
  219. })
  220. });
  221. } else {
  222. this.warning(res.data.msg);
  223. }
  224. this.saveDisable = false;
  225. });
  226. },
  227. warning(msg, type) {
  228. this.$message({
  229. showClose: true,
  230. message: msg,
  231. type: type || 'warning'
  232. });
  233. }
  234. }
  235. };
  236. </script>
  237. <style lang="less" scoped>
  238. .AddChemicalAndCommonMappingWrapper {
  239. .AddChemicalAndCommonMappingBox {
  240. min-width: 940px;
  241. }
  242. color: #606266;
  243. .topBack {
  244. top: 0;
  245. }
  246. .titleBox {
  247. padding: 0 0 10px 0px;
  248. }
  249. .title {
  250. width: 50%;
  251. float: left;
  252. font-size: 14px;
  253. }
  254. .AddChemicalAndCommonMappingBox {
  255. padding: 20px 30px 20px 30px;
  256. margin: 70px 20px 0 20px;
  257. background: #fff;
  258. }
  259. .leftBox,
  260. .midBox,
  261. .rightBox {
  262. width: 40%;
  263. float: left;
  264. min-height: 200px;
  265. font-size: 14px;
  266. }
  267. .midBox {
  268. width: 6%;
  269. padding: 50px 0 0 0;
  270. text-align: center;
  271. }
  272. .midTitle {
  273. width: 40px;
  274. margin: 0 auto;
  275. }
  276. .midLogo {
  277. margin: 0 auto;
  278. }
  279. .leftBox,
  280. .rightBox {
  281. border: 1px solid #dcdfe6;
  282. padding: 20px 20px;
  283. }
  284. .itemLabel {
  285. width: 100%;
  286. min-height: 50px;
  287. line-height: 50px;
  288. position: relative;
  289. }
  290. .itemLabelName,
  291. .searchInput,
  292. .searchName {
  293. float: left;
  294. color: #606266;
  295. }
  296. .itemLabelName {
  297. width: 150px;
  298. }
  299. .isRequired::before {
  300. content: '*';
  301. color: red;
  302. }
  303. .searchInput,
  304. .mealNameItem {
  305. padding: 0 5px;
  306. }
  307. .searchInput,
  308. .searchName {
  309. display: inline-block;
  310. height: 32px;
  311. line-height: 32px;
  312. border: 1px solid #a9a9a9;
  313. margin: 8px 0 0 0;
  314. }
  315. .searchName {
  316. text-align: center;
  317. border-left: none;
  318. cursor: pointer;
  319. padding: 0 12px;
  320. font-size: 16px;
  321. }
  322. .itemList {
  323. position: absolute;
  324. background: #fff;
  325. width: 162px;
  326. max-height: 150px;
  327. border: 1px solid #a9a9a9;
  328. left: 150px;
  329. top: 42px;
  330. z-index: 2;
  331. overflow-y: auto;
  332. }
  333. .itemList {
  334. width: calc(100% - 131px);
  335. }
  336. .mealNameItem {
  337. height: 30px;
  338. line-height: 30px;
  339. font-size: 14px;
  340. cursor: pointer;
  341. }
  342. .mealNameItem:hover {
  343. background: #f5f7fa;
  344. }
  345. // .selectItemName {
  346. // padding-left: 4px;
  347. // display: inline-block;
  348. // margin-top: 8px;
  349. // // width: calc(100% - 160px);s
  350. // line-height: 24px;
  351. // overflow: hidden;
  352. // word-wrap: break-word;
  353. // word-break: break-all;
  354. // }
  355. .previewInfo {
  356. padding-left: 4px;
  357. display: inline-block;
  358. margin-top: 8px;
  359. // width: calc(100% - 160px);s
  360. line-height: 24px;
  361. overflow: hidden;
  362. word-wrap: break-word;
  363. word-break: break-all;
  364. }
  365. .btn {
  366. position: relative;
  367. background-color: #fff;
  368. margin: 0px 20px;
  369. padding: 20px;
  370. min-width: 960px;
  371. height: 80px;
  372. .el-button {
  373. position: absolute;
  374. right: 80px;
  375. top: 20px;
  376. }
  377. }
  378. .sumbit {
  379. position: absolute;
  380. display: inline-block;
  381. width: 80px;
  382. height: 30px;
  383. line-height: 30px;
  384. border: 1px solid #a9a9a9;
  385. text-align: center;
  386. right: 100px;
  387. }
  388. }
  389. .confirmRealation {
  390. .cancelButton {
  391. border: 1px solid #a9a9a9;
  392. span {
  393. color: #606266;
  394. }
  395. }
  396. }
  397. // body {
  398. // .el-select-dropdown {
  399. // /deep/ .el-select-dropdown__item {
  400. // span {
  401. // color: #333;
  402. // }
  403. // }
  404. // ul {
  405. // max-width: 200px;
  406. // }
  407. // }
  408. // }
  409. </style>