AddChemicalAndCommonMapping.vue 14 KB

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