AddTcmdrome.vue 11 KB

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