AddChemicalAndCommonMapping.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <template>
  2. <div class="AddChemicalAndCommonMappingWrapper clearfix" @click="close">
  3. <crumbs
  4. title="化验大小项与公表项对应维护-添加关联"
  5. class="topBack"
  6. :param="$route.params"
  7. linkTo="ChemicalAndCommonMapping"
  8. ></crumbs>
  9. <div class="AddChemicalAndCommonMappingBox clearfix">
  10. <div class="titleBox clearfix">
  11. <p class="title">关联化验项</p>
  12. <p class="title">关联公表项</p>
  13. </div>
  14. <div class="leftBox clearfix" >
  15. <div class="itemLabel clearfix">
  16. <label class="itemLabelName">选择化验大项:</label>
  17. <input class="searchInput" @focus="focuInput" type="text" v-model = "mealText">
  18. <span class="searchName" @click="searchMealItem(1)">搜索</span>
  19. <ul
  20. v-if="showMealNameList&&mealNameList.length >0"
  21. class="itemList mealNameList"
  22. ref="mealNameList"
  23. >
  24. <li
  25. v-for="item in mealNameList"
  26. class="mealNameItem ellipsis"
  27. :title="item.conceptName"
  28. @click="selectMealName(item)"
  29. :key="item.conceptId">
  30. {{item.conceptName}}
  31. </li>
  32. </ul>
  33. </div>
  34. <div class="itemLabel clearfix">
  35. <label class="itemLabelName isRequired">已选择化验大项:</label>
  36. <span class="selectItemName">{{form.mealName}}</span>
  37. </div>
  38. <div class="itemLabel clearfix">
  39. <label class="itemLabelName">选择化验小项:</label>
  40. <input class="searchInput" @focus="focuInput" type="text" v-model = "itemText">
  41. <span class="searchName" @click="searchMealItem(2)">搜索</span>
  42. <ul
  43. v-if="showItemNameList&&itemNameList.length >0"
  44. class="itemList itemNameList"
  45. ref="itemNameList"
  46. >
  47. <li
  48. v-for="item in itemNameList"
  49. class="mealNameItem ellipsis"
  50. :title="item.conceptName"
  51. @click="selectItemName(item)"
  52. :key="item.conceptId">
  53. {{item.conceptName}}
  54. </li>
  55. </ul>
  56. </div>
  57. <div class="itemLabel">
  58. <label class="itemLabelName">已选择化验小项:</label>
  59. <span class="selectItemName">{{form.itemName}}</span>
  60. </div>
  61. </div>
  62. <div class="midBox">
  63. <img class="midLogo" src="../../images/relation.png" alt="">
  64. <p class="midTitle">相互关联</p>
  65. </div>
  66. <div class="rightBox">
  67. <div class="itemLabel">
  68. <label class="itemLabelName">选择公表项:</label>
  69. <input class="searchInput" @focus="focuInput" type="text" v-model = "uniqueText">
  70. <span class="searchName" @click="searchMealItem(3)">搜索</span>
  71. <ul
  72. v-if="showUniqueNameList&&uniqueNameList.length >0"
  73. class="itemList uniqueNameList"
  74. ref="uniqueNameList"
  75. >
  76. <li
  77. v-for="item in uniqueNameList"
  78. class="mealNameItem ellipsis"
  79. :title="item.conceptName"
  80. @click="selectUniqueName(item)"
  81. :key="item.conceptName">
  82. {{item.conceptName}}
  83. </li>
  84. </ul>
  85. </div>
  86. <div class="itemLabel">
  87. <label class="itemLabelName isRequired">已选择公表项:</label>
  88. <span class="selectItemName">{{form.uniqueName}}</span>
  89. </div>
  90. </div>
  91. </div>
  92. <div class="btn">
  93. <!-- <span class="sumbit" @click="submitForm">建立关联</span> -->
  94. <el-button
  95. type="primary"
  96. :disabled = 'saveDisable'
  97. @click="submitForm"
  98. >建立关联</el-button>
  99. </div>
  100. </div>
  101. </template>
  102. <script>
  103. import api from '@api/icss.js';
  104. export default {
  105. name: 'AddChemicalAndCommonMapping',
  106. data() {
  107. return {
  108. mealText: '', //化验大项搜索文字内容
  109. itemText: '', //化验小项搜索文字内容
  110. uniqueText: '', //公表项搜索文字内容
  111. isEdit: false,
  112. mealNameList:[],
  113. itemNameList: [],
  114. uniqueNameList:[],
  115. showMealNameList: false,
  116. showItemNameList: false,
  117. showUniqueNameList: false,
  118. form: {
  119. mealName: '', //大项名称
  120. mealId: '', //大项Id
  121. itemName: '', //小项名称
  122. itemId: '', //小项Id
  123. uniqueName: '', //公表名称,必填
  124. uniqueId:'' //公表项Id
  125. },
  126. saveDisable: false //保存按钮禁止点击
  127. }
  128. },
  129. created() {
  130. //修改(不需要)
  131. // const { isEdit, data } = this.$route.params
  132. // if(isEdit) {
  133. // this.isEdit = isEdit;
  134. // this.form.mealName = data.mealName
  135. // this.form.itemName = data.itemName
  136. // this.form.uniqueName = data.uniqueName
  137. // }
  138. },
  139. methods: {
  140. close() {
  141. this.mealNameList = [];
  142. this.itemNameList =[];
  143. this.uniqueNameList = [];
  144. this.showSearchList()
  145. },
  146. searchMealItem(type) {
  147. if( type == '1' || type == '2') {
  148. this.getTagList(type)
  149. } else if ( type == '3') {
  150. this.getAllLisConcept()
  151. }
  152. },
  153. getTagList(type) {
  154. let param = {
  155. relationPosition: 3
  156. }
  157. if (type == 1) {
  158. param.name = this.mealText.trim();
  159. param.typeId = 12
  160. } else if (type == 2) {
  161. param.name = this.itemText.trim();
  162. param.typeId = 13
  163. }
  164. if(!param.name) {
  165. return
  166. }
  167. api.getConceptInfoAssay(param).then((res) => {
  168. if (res.data.code === '0') {
  169. if (type == 1) {
  170. this.mealNameList = res.data.data;
  171. this.showSearchList('showMealNameList')
  172. } else if (type == 2) {
  173. this.itemNameList = res.data.data;
  174. this.showSearchList('showItemNameList')
  175. }
  176. }
  177. })
  178. },
  179. getAllLisConcept() {
  180. const param = {
  181. conceptName: this.uniqueText
  182. }
  183. if(!param.conceptName) {
  184. return
  185. }
  186. api.getAllLisConcept(param).then((res) => {
  187. if(res.data.code === '0') {
  188. this.uniqueNameList = res.data.data
  189. this.showSearchList('showUniqueNameList')
  190. }
  191. })
  192. },
  193. focuInput() {
  194. this.showSearchList()
  195. },
  196. showSearchList(type) {
  197. this.showMealNameList = false
  198. this.showItemNameList = false
  199. this.showUniqueNameList = false
  200. if(type === 'showMealNameList') {
  201. this.showMealNameList = true
  202. } else if (type === 'showItemNameList') {
  203. this.showItemNameList = true
  204. } else if (type === 'showUniqueNameList'){
  205. this.showUniqueNameList = true
  206. }
  207. },
  208. selectMealName(item) {
  209. this.form.mealName = item.conceptName
  210. this.form.mealId = item.conceptId
  211. // this.$refs['mealNameList'].style.display='none'
  212. this.mealText = ''
  213. this.mealNameList = []
  214. },
  215. selectItemName(item) {
  216. this.form.itemName = item.conceptName
  217. this.form.itemId = item.conceptId
  218. this.itemText = ''
  219. this.itemNameList = []
  220. },
  221. selectUniqueName(item) {
  222. this.form.uniqueName = item.conceptName
  223. this.form.uniqueId = item.conceptId
  224. //搜索公表项自动填充大小项(目前暂时不需要)
  225. // let nameArr = item.conceptName.split('--');
  226. // this.form.mealName = nameArr[0]
  227. // this.form.itemName = nameArr[1]
  228. // this.$refs['uniqueNameList'].style.display='none'
  229. this.uniqueText = ''
  230. this.uniqueNameList = []
  231. },
  232. initForm() {
  233. this.form.mealName = ''
  234. this.form.mealId = ''
  235. this.form.itemName = ''
  236. this.form.itemId = ''
  237. this.form.uniqueName = ''
  238. this.form.uniqueId = ''
  239. },
  240. submitForm() {
  241. const { itemId, mealId, uniqueId } = this.form
  242. if (!mealId || !uniqueId) {
  243. this.warning('请填写相关数据')
  244. return
  245. }
  246. //通过必填验证,提交保存
  247. const param = {
  248. "itemId": itemId,
  249. "mealId": mealId,
  250. "uniqueId": uniqueId
  251. }
  252. this.showSaveDialog(param);
  253. },
  254. saveLisMapping(param, msg, type) {
  255. api.saveLisMapping(param).then((res) => {
  256. if (res.data.code === '0') {
  257. this.warning(res.data.msg || msg, type);
  258. // this.$router.push({name: 'ChemicalAndCommonMapping'});
  259. this.initForm();
  260. } else {
  261. this.warning(res.data.msg)
  262. }
  263. this.saveDisable = false
  264. })
  265. },
  266. showSaveDialog(param) {
  267. // 修改(不需要)
  268. // if(this.isEdit) {
  269. // this.saveLisMapping(param)
  270. // } else {
  271. this.saveDisable = true //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  272. api.hasLisMapping(param).then((res) => {
  273. if (!res.data.data) {
  274. this.saveLisMapping(param, '关联建立成功', 'success' )
  275. } else {
  276. this.showConfirmDialog('该关联已存在是否替换旧的关系信息', () => {
  277. this.saveLisMapping(param, '关联建立成功', 'success' )
  278. });
  279. }
  280. }).catch((err) => {
  281. this.warning(err);
  282. })
  283. // }
  284. },
  285. showConfirmDialog(msg, resolve) {
  286. this.$confirm(msg, '提示', {
  287. customClass: 'confirmRealation',
  288. confirmButtonText: '是',
  289. cancelButtonText: '否',
  290. cancelButtonClass: 'cancelButton',
  291. type: 'warning'
  292. }).then(() => {
  293. resolve();
  294. }).catch(() => {
  295. this.saveDisable = false
  296. this.warning('建立失败','error')
  297. });
  298. },
  299. warning(msg, type) {
  300. this.$message({
  301. showClose: true,
  302. message: msg,
  303. type: type || 'warning'
  304. })
  305. },
  306. }
  307. }
  308. </script>
  309. <style lang="less">
  310. .AddChemicalAndCommonMappingWrapper {
  311. .AddChemicalAndCommonMappingBox {
  312. min-width: 940px;
  313. }
  314. color: #606266;
  315. .topBack {
  316. top: 0;
  317. }
  318. // .groupTitle {
  319. // width: calc(100% - 50px);
  320. // height: 40px;
  321. // background: #fff;
  322. // padding: 0 20px 0 30px;
  323. // margin-bottom: 20px;
  324. // line-height: 40px;
  325. // position: relative;
  326. // z-index: 5;
  327. // }
  328. .titleBox {
  329. padding: 0 0 10px 0px;
  330. }
  331. .title {
  332. width: 50%;
  333. float: left;
  334. font-size: 14px;
  335. }
  336. .AddChemicalAndCommonMappingBox {
  337. padding: 20px 30px 20px 30px;
  338. margin: 70px 20px 0 20px;
  339. background: #fff;
  340. }
  341. .leftBox , .midBox, .rightBox{
  342. width: 40%;
  343. float: left;
  344. min-height: 200px;
  345. font-size: 14px;
  346. }
  347. .midBox {
  348. width: 6%;
  349. padding: 50px 0 0 0;
  350. text-align: center;
  351. }
  352. .midTitle {
  353. width: 40px;
  354. margin: 0 auto;
  355. }
  356. .midLogo {
  357. margin: 0 auto;
  358. }
  359. .leftBox, .rightBox {
  360. border: 1px solid #a9a9a9;
  361. padding: 20px 20px;
  362. }
  363. .itemLabel {
  364. width: 100%;
  365. min-height: 50px;
  366. line-height: 50px;
  367. position: relative;
  368. }
  369. .itemLabelName, .searchInput, .searchName{
  370. float: left;
  371. color: #606266;
  372. }
  373. .itemLabelName {
  374. width: 150px;
  375. }
  376. .isRequired::before {
  377. content: '*';
  378. color: red;
  379. }
  380. .searchInput, .mealNameItem {
  381. padding: 0 5px;
  382. }
  383. .searchInput, .searchName {
  384. display: inline-block;
  385. height: 32px;
  386. line-height: 32px;
  387. border: 1px solid #a9a9a9;
  388. margin: 8px 0 0 0;
  389. }
  390. .searchName {
  391. text-align: center;
  392. border-left: none;
  393. cursor: pointer;
  394. padding: 0 12px;
  395. font-size: 16px;
  396. }
  397. .itemList {
  398. position: absolute;
  399. background: #fff;
  400. width: 162px;
  401. max-height: 150px;
  402. border: 1px solid #a9a9a9;
  403. left: 150px;
  404. top: 42px;
  405. z-index: 2;
  406. overflow-y: auto;
  407. }
  408. .itemList {
  409. width: calc(100% - 131px);
  410. }
  411. .mealNameItem {
  412. height: 30px;
  413. line-height: 30px;
  414. font-size: 14px;
  415. cursor: pointer;
  416. }
  417. .mealNameItem:hover {
  418. background: #f5f7fa;
  419. }
  420. .selectItemName {
  421. display: inline-block;
  422. width: calc(100% - 160px);
  423. }
  424. .btn {
  425. position: relative;
  426. background-color: #fff;
  427. margin: 0px 20px;
  428. padding: 20px;
  429. min-width: 960px;
  430. height: 80px;
  431. .el-button {
  432. position: absolute;
  433. right: 80px;
  434. top: 20px;
  435. }
  436. }
  437. .sumbit {
  438. position: absolute;
  439. display: inline-block;
  440. width: 80px;
  441. height: 30px;
  442. line-height: 30px;
  443. border: 1px solid #a9a9a9;
  444. text-align: center;
  445. right: 100px;
  446. }
  447. }
  448. .confirmRealation {
  449. .cancelButton{
  450. border: 1px solid #a9a9a9;
  451. span {
  452. color: #606266;
  453. }
  454. }
  455. }
  456. </style>