AddChemicalAndCommonMapping.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <div class="AddChemicalAndCommonMappingWrapper clearfix">
  3. <crumbs
  4. :title="isEdit ? '诊断关联维护--修改关联' : '诊断关联维护--添加关联'"
  5. class="topBack"
  6. :param="$route.params"
  7. linkTo="ChemicalAndCommonMapping"
  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="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. @clear="handleClear"
  54. :remote-method="searchTerms"
  55. reserve-keyword
  56. >
  57. <el-option
  58. v-for="item in uniqueNameList"
  59. :key="item.icd10Code"
  60. :label="item.name"
  61. class="searchListNone"
  62. :value="item.name"
  63. :title="item.name"
  64. ></el-option>
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="诊断名称预览:">
  68. <!-- <span class="previewInfo">{{!isEdit ? form.searchText.name : form.searchText}}</span> -->
  69. <span class="previewInfo" style="minWidth: 240px">{{form.searchText}}</span>
  70. </el-form-item>
  71. <el-form-item label="ICD编码:">
  72. <span class="previewInfo" style="minWidth: 240px">{{form.icdCode}}</span>
  73. </el-form-item>
  74. </el-col>
  75. </el-row>
  76. </div>
  77. </div>
  78. <div class="btn">
  79. <el-form-item>
  80. <el-button type="primary" :disabled="saveDisable" @click="submitForm">确定</el-button>
  81. </el-form-item>
  82. </div>
  83. </el-form>
  84. </div>
  85. </template>
  86. <script>
  87. import api from '@api/icss.js';
  88. export default {
  89. name: 'AddChemicalAndCommonMapping',
  90. data() {
  91. return {
  92. isEdit: false,
  93. editId: '',
  94. uniqueNameList: [],
  95. form: {
  96. searchText: '', //搜索字段
  97. hisName: '',
  98. icdCode: ''
  99. },
  100. rules: {
  101. hisName: [
  102. { required: true, message: '请输入诊断名称', trigger: 'change' },
  103. { max: 80, message: '诊断名称最多80字', trigger: 'change' }
  104. ],
  105. searchText: [
  106. { required: true, message: '请选择诊断名称', trigger: 'change' }
  107. ]
  108. },
  109. saveDisable: false, //保存按钮禁止点击
  110. showDrop: false //下拉框显示文字
  111. };
  112. },
  113. created() {
  114. //修改
  115. const { isEdit, data } = this.$route.params;
  116. if (isEdit) {
  117. this.isEdit = isEdit;
  118. this.editId = data.id;
  119. this.form.hisName = data.hisName;
  120. this.form.searchText = data.uniqueName;
  121. this.form.icdCode = data.icdCode;
  122. }
  123. },
  124. methods: {
  125. handleClear() {
  126. this.form.searchText = '';
  127. },
  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. };
  175. this.showSaveDialog(params);
  176. } else {
  177. console.log('error submit!!');
  178. return false;
  179. }
  180. });
  181. },
  182. // 建立关联-映射关系是否已存在
  183. showSaveDialog(params) {
  184. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  185. api
  186. .diseaseIsExistRecord(params)
  187. .then(res => {
  188. if (!res.data.data) {
  189. // 不存在,创建新的关联
  190. // 如果是编辑时,需要携带id
  191. if (this.isEdit) {
  192. params = { ...params, id: this.editId };
  193. }
  194. this.saveLisMapping(params, '保存成功', 'success');
  195. } else {
  196. // 已存在,提示修改
  197. this.warning('该条关联已存在,无法添加');
  198. this.saveDisable = false;
  199. }
  200. })
  201. .catch(err => {
  202. if (err.code === '900010001') {
  203. return false;
  204. }
  205. this.warning(err);
  206. });
  207. },
  208. // 映射关系不存在-建立关联
  209. saveLisMapping(params, msg, type) {
  210. api.saveOrUpdateDiseaseRecord(params).then(res => {
  211. if (res.data.code === '0') {
  212. this.warning(res.data.msg || msg, type);
  213. this.initForm();
  214. this.$router.push({
  215. name: 'ChemicalAndCommonMapping',
  216. params: Object.assign({}, this.$route.params, {
  217. currentPage: 1
  218. })
  219. });
  220. } else {
  221. this.warning(res.data.msg);
  222. }
  223. this.saveDisable = false;
  224. });
  225. },
  226. // 关联已存在模态框
  227. showConfirmDialog(msg, resolve) {
  228. this.$confirm(msg, '提示', {
  229. customClass: 'confirmRealation',
  230. confirmButtonText: '是',
  231. cancelButtonText: '否',
  232. cancelButtonClass: 'cancelButton',
  233. type: 'warning'
  234. })
  235. .then(() => {
  236. resolve();
  237. })
  238. .catch(() => {
  239. this.saveDisable = false;
  240. this.warning('建立失败', 'error');
  241. });
  242. },
  243. warning(msg, type) {
  244. this.$message({
  245. showClose: true,
  246. message: msg,
  247. type: type || 'warning'
  248. });
  249. }
  250. }
  251. };
  252. </script>
  253. <style lang="less">
  254. .AddChemicalAndCommonMappingWrapper {
  255. .AddChemicalAndCommonMappingBox {
  256. min-width: 940px;
  257. }
  258. color: #606266;
  259. .topBack {
  260. top: 0;
  261. }
  262. .titleBox {
  263. padding: 0 0 10px 0px;
  264. }
  265. .title {
  266. width: 50%;
  267. float: left;
  268. font-size: 14px;
  269. }
  270. .AddChemicalAndCommonMappingBox {
  271. padding: 20px 30px 20px 30px;
  272. margin: 70px 20px 0 20px;
  273. background: #fff;
  274. }
  275. .leftBox,
  276. .midBox,
  277. .rightBox {
  278. width: 40%;
  279. float: left;
  280. min-height: 200px;
  281. font-size: 14px;
  282. }
  283. .midBox {
  284. width: 6%;
  285. padding: 50px 0 0 0;
  286. text-align: center;
  287. }
  288. .midTitle {
  289. width: 40px;
  290. margin: 0 auto;
  291. }
  292. .midLogo {
  293. margin: 0 auto;
  294. }
  295. .leftBox,
  296. .rightBox {
  297. border: 1px solid #dcdfe6;
  298. padding: 20px 20px;
  299. }
  300. .itemLabel {
  301. width: 100%;
  302. min-height: 50px;
  303. line-height: 50px;
  304. position: relative;
  305. }
  306. .itemLabelName,
  307. .searchInput,
  308. .searchName {
  309. float: left;
  310. color: #606266;
  311. }
  312. .itemLabelName {
  313. width: 150px;
  314. }
  315. .isRequired::before {
  316. content: '*';
  317. color: red;
  318. }
  319. .searchInput,
  320. .mealNameItem {
  321. padding: 0 5px;
  322. }
  323. .searchInput,
  324. .searchName {
  325. display: inline-block;
  326. height: 32px;
  327. line-height: 32px;
  328. border: 1px solid #a9a9a9;
  329. margin: 8px 0 0 0;
  330. }
  331. .searchName {
  332. text-align: center;
  333. border-left: none;
  334. cursor: pointer;
  335. padding: 0 12px;
  336. font-size: 16px;
  337. }
  338. .itemList {
  339. position: absolute;
  340. background: #fff;
  341. width: 162px;
  342. max-height: 150px;
  343. border: 1px solid #a9a9a9;
  344. left: 150px;
  345. top: 42px;
  346. z-index: 2;
  347. overflow-y: auto;
  348. }
  349. .itemList {
  350. width: calc(100% - 131px);
  351. }
  352. .mealNameItem {
  353. height: 30px;
  354. line-height: 30px;
  355. font-size: 14px;
  356. cursor: pointer;
  357. }
  358. .mealNameItem:hover {
  359. background: #f5f7fa;
  360. }
  361. // .selectItemName {
  362. // padding-left: 4px;
  363. // display: inline-block;
  364. // margin-top: 8px;
  365. // // width: calc(100% - 160px);s
  366. // line-height: 24px;
  367. // overflow: hidden;
  368. // word-wrap: break-word;
  369. // word-break: break-all;
  370. // }
  371. .previewInfo {
  372. padding-left: 4px;
  373. display: inline-block;
  374. margin-top: 8px;
  375. // width: calc(100% - 160px);s
  376. line-height: 24px;
  377. overflow: hidden;
  378. word-wrap: break-word;
  379. word-break: break-all;
  380. }
  381. .btn {
  382. position: relative;
  383. background-color: #fff;
  384. margin: 0px 20px;
  385. padding: 20px;
  386. min-width: 960px;
  387. height: 80px;
  388. .el-button {
  389. position: absolute;
  390. right: 80px;
  391. top: 20px;
  392. }
  393. }
  394. .sumbit {
  395. position: absolute;
  396. display: inline-block;
  397. width: 80px;
  398. height: 30px;
  399. line-height: 30px;
  400. border: 1px solid #a9a9a9;
  401. text-align: center;
  402. right: 100px;
  403. }
  404. }
  405. .confirmRealation {
  406. .cancelButton {
  407. border: 1px solid #a9a9a9;
  408. span {
  409. color: #606266;
  410. }
  411. }
  412. }
  413. // body {
  414. // .el-select-dropdown {
  415. // /deep/ .el-select-dropdown__item {
  416. // span {
  417. // color: #333;
  418. // }
  419. // }
  420. // ul {
  421. // max-width: 200px;
  422. // }
  423. // }
  424. // }
  425. </style>