AddOperation.vue 9.3 KB

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