AddChemicalAndCommonMapping.vue 9.7 KB

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