AddLis.vue 12 KB

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