AddChemicalAndCommonMapping.vue 14 KB

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