Addnursing.vue 10 KB

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