AddScale.vue 10.0 KB

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