AddDrug.vue 11 KB

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