AddOperation.vue 10.0 KB

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