AddHospital.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <template>
  2. <div class="AddPlanWrapper clearfix">
  3. <crumbs
  4. :title="!isEdit ? '医院管理-添加医院' : '医院管理-修改医院'"
  5. class="topBack"
  6. :param="$route.params"
  7. linkTo="HospitalCDSS"
  8. ></crumbs>
  9. <div class="AddPlanBox">
  10. <el-row :gutter="20">
  11. <el-col :span="24">
  12. <el-form ref="form" :model="form" label-width="110px" :rules="rules">
  13. <el-row :gutter="20">
  14. <el-col :span="12">
  15. <el-form-item label="医院名称" prop="hospitalName" style="width:100%">
  16. <el-input
  17. v-model="form.hospitalName"
  18. placeholder="2-30位,可输入汉字、字母、数字和下划线"
  19. @blur="handlePinyin($event)"
  20. ></el-input>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item label="医院名称拼音" prop="spell" style="width:100%">
  25. <el-input v-model="form.spell" placeholder="请输入医院名称拼音"></el-input>
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. <!-- <el-form-item label="医院编码" prop="hospitalCode">
  30. <el-input v-model="form.hospitalCode" placeholder="4-15位,可输入字母、数字和下划线"></el-input>
  31. </el-form-item>-->
  32. <el-form-item label="医院地址">
  33. <el-input v-model="form.address" placeholder="请输入医院地址" maxlength="100"></el-input>
  34. </el-form-item>
  35. <p
  36. style="text-align: center;padding-bottom: 14px;width: 100%;font-size:16px;font-weight: bold;"
  37. >关联子医院</p>
  38. <el-form-item>
  39. <el-table
  40. size="mini"
  41. :data="form.hospitalRelationVOList"
  42. border
  43. :style="form.hospitalRelationVOList.length > 0?'min-height: 200px':'60px'"
  44. :height="form.hospitalRelationVOList.length > 0?'calc(100vh - 390px)':'60px'"
  45. class="tabs"
  46. ref="tableList"
  47. :header-row-style="{height:'40px',cursor: 'pointer',fontSize:'14px'}"
  48. :row-style="{height:'40px',cursor: 'pointer',fontSize:'14px'}"
  49. :header-cell-style="{height:'40px',borderColor:'#DCDFE6',fontSize:'14px'}"
  50. >
  51. <el-table-column label="序号" type="index" width="80">
  52. <template slot="header" slot-scope="scope">
  53. <span class="name">序号</span>
  54. </template>
  55. <template slot-scope="scope">
  56. <el-form-item>
  57. <i
  58. class="el-icon-warning"
  59. style="color:#e6a23c;margin-right:3px"
  60. v-if="form.hospitalRelationVOList[scope.$index].errorCurrent"
  61. ></i>
  62. <i
  63. class="el-icon-warning"
  64. style="color:#fe6c6f;margin-right:3px"
  65. v-if="form.hospitalRelationVOList[scope.$index].errorOther"
  66. ></i>
  67. <span>{{scope.$index+1}}</span>
  68. </el-form-item>
  69. </template>
  70. </el-table-column>
  71. <el-table-column label="医院名称">
  72. <template slot="header" slot-scope="scope">
  73. <span class="star">*</span>
  74. <span class="name">医院名称</span>
  75. </template>
  76. <template slot-scope="scope">
  77. <el-form-item
  78. class="is-request"
  79. :prop="'hospitalRelationVOList.' + scope.$index + '.name'"
  80. :rules="{
  81. required: true,message: '请输入医院名称', trigger: 'blur'
  82. }"
  83. >
  84. <el-input
  85. class="inp-name"
  86. placeholder="请输入医院名称"
  87. maxlength="50"
  88. v-model.trim="form.hospitalRelationVOList[scope.$index].name"
  89. ></el-input>
  90. </el-form-item>
  91. </template>
  92. </el-table-column>
  93. <el-table-column label="编码">
  94. <template slot="header" slot-scope="scope">
  95. <span class="star">*</span>
  96. <span class="name">编码</span>
  97. </template>
  98. <template slot-scope="scope">
  99. <el-form-item
  100. :prop="'hospitalRelationVOList.' + scope.$index + '.code'"
  101. :rules="{
  102. required: true,message: '请输入编码', trigger: 'blur'
  103. }"
  104. >
  105. <el-input
  106. class="inp-name"
  107. placeholder="请输入编码"
  108. maxlength="50"
  109. v-model.trim="form.hospitalRelationVOList[scope.$index].code"
  110. ></el-input>
  111. </el-form-item>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="操作" width="150" align="center">
  115. <template slot-scope="scope">
  116. <div class="operation">
  117. <el-button @click="addIndex(scope.$index)" type="text" size="small">
  118. <img src="../../../images/icon-add.png" alt="新增" />
  119. </el-button>
  120. <el-button @click="delIndex(scope.$index)" type="text" size="small">
  121. <img src="../../../images/icon-delete.png" alt="删除" />
  122. </el-button>
  123. </div>
  124. </template>
  125. </el-table-column>
  126. </el-table>
  127. <div class="add" v-if="form.hospitalRelationVOList.length == 0">
  128. <!--<el-button icon="el-icon-plus"></el-button>-->
  129. <p class="add-border" @click="add"></p>
  130. </div>
  131. </el-form-item>
  132. <el-form-item>
  133. <el-button type="primary" @click="onSubmit" :disabled="saveDisable">确定</el-button>
  134. </el-form-item>
  135. </el-form>
  136. </el-col>
  137. </el-row>
  138. </div>
  139. <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
  140. <div class="diag-center">
  141. <p class="diag-title">操作失败,请检查“医院名称+医院编码”重复项</p>
  142. <p class="title-warning">
  143. <i class="el-icon-warning" style="color:#e6a23c"></i>标记为当前父医院的“子医院+子医院编码”重复项
  144. </p>
  145. <p class="title-warning title-warning-2">
  146. <i class="el-icon-warning" style="color:#fe6c6f"></i>标记为与其它父医院的“子医院+子医院编码”重复项
  147. </p>
  148. </div>
  149. <span slot="footer" class="dialog-footer">
  150. <el-button @click="dialogVisible = false">关闭</el-button>
  151. </span>
  152. </el-dialog>
  153. </div>
  154. </template>
  155. <script>
  156. import api from '@api/cdss.js';
  157. import pinyin from '../../../js/Convert_Pinyin.js';
  158. export default {
  159. name: 'AddHospital',
  160. data() {
  161. var numreg = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
  162. var numreg1 = /^[0-9a-zA-Z_]{1,}$/;
  163. var validatePass = (rule, value, callback) => {
  164. if (!numreg.test(value)) {
  165. callback(new Error('汉字、字母、数字和下划线'));
  166. } else {
  167. callback();
  168. }
  169. };
  170. var validatePass1 = (rule, value, callback) => {
  171. if (!numreg1.test(value)) {
  172. callback(new Error('字母、数字和下划线'));
  173. } else {
  174. callback();
  175. }
  176. };
  177. return {
  178. form: {
  179. hospitalName: '',
  180. spell: '',
  181. // hospitalCode: '',
  182. address: '',
  183. hospitalRelationVOList: []
  184. },
  185. tableData: [],
  186. rules: {
  187. hospitalName: [
  188. { required: true, message: '医院名称不能为空', trigger: 'change' },
  189. { min: 2, max: 30, message: '长度2-30位', trigger: 'blur' },
  190. { required: true, validator: validatePass, trigger: 'blur' }
  191. ],
  192. // hospitalCode: [
  193. // { required: true, message: '医院编码不能为空', trigger: 'change' },
  194. // { min: 4, max: 15, message: '长度4-15位', trigger: 'blur' },
  195. // { required: true, validator: validatePass1, trigger: 'blur' }
  196. // ],
  197. address: [{ max: 200, message: '长度最多200字', trigger: 'change' }],
  198. spell: [
  199. { max: 30, message: '医院名称拼音长度最多30位', trigger: 'change' }
  200. ]
  201. },
  202. hospitalId: '',
  203. isEdit: false,
  204. saveDisable: false,
  205. dialogVisible: false,
  206. list: []
  207. };
  208. },
  209. created() {
  210. const { isEdit, data } = this.$route.params;
  211. this.isEdit = isEdit;
  212. if (isEdit) {
  213. this.form.hospitalName = data.name;
  214. this.form.spell = data.spell;
  215. // this.form.hospitalCode = data.code;
  216. this.form.address = data.address;
  217. this.hospitalId = data.id;
  218. this.getByhospitalInfoId(data.id);
  219. }
  220. },
  221. methods: {
  222. getByhospitalInfoId(id) {
  223. api.getByhospitalInfoId({ id: id }).then(res => {
  224. if (res.data.code === '0') {
  225. const data = res.data.data;
  226. data.hospitalRelationDTOList.forEach((item, index) => {
  227. item.errorOther = false;
  228. item.errorCurrent = false;
  229. });
  230. this.form.hospitalRelationVOList = data.hospitalRelationDTOList;
  231. }
  232. });
  233. },
  234. onSubmit() {
  235. this.$refs.form.validate(valid => {
  236. if (valid) {
  237. this.saveDisable = true;
  238. let params = {
  239. connect: 1,
  240. address: this.form.address,
  241. name: this.form.hospitalName,
  242. spell: this.form.spell,
  243. hospitalRelationVOList: this.form.hospitalRelationVOList
  244. // code: this.form.hospitalCode
  245. };
  246. this.form.hospitalRelationVOList.forEach((item, index) => {
  247. item.errorOther = false;
  248. item.errorCurrent = false;
  249. });
  250. if (this.isEdit) {
  251. params = Object.assign({}, params, {
  252. id: this.hospitalId
  253. });
  254. }
  255. api.saveOrUpdateHosRecordCDSS(params).then(res => {
  256. if (res.data.code === '0') {
  257. this.$message({
  258. showClose: true,
  259. message: '保存成功',
  260. type: 'success',
  261. duration: 1000
  262. });
  263. this.isSaveSuccess = true; // 保存成功,可正常退出
  264. this.$router.push({
  265. name: 'HospitalCDSS',
  266. params: Object.assign({}, this.$route.params, {
  267. currentPage: 1
  268. })
  269. });
  270. } else if (res.data.code === '20020009') {
  271. const data = res.data.data;
  272. this.dialogVisible = true;
  273. let errorOtherList = [];
  274. let errorCurrentList = [];
  275. this.getIndex(data.errorOther, errorOtherList);
  276. this.getIndex(data.errorCurrent, errorCurrentList);
  277. errorOtherList.forEach(i => {
  278. this.form.hospitalRelationVOList[i].errorOther = true;
  279. });
  280. errorCurrentList.forEach(i => {
  281. this.form.hospitalRelationVOList[i].errorCurrent = true;
  282. });
  283. } else {
  284. this.$message({
  285. showClose: true,
  286. message: res.data.msg,
  287. type: 'error',
  288. duration: 1000
  289. });
  290. }
  291. this.saveDisable = false;
  292. });
  293. } else {
  294. this.locateToErr();
  295. return false;
  296. }
  297. });
  298. },
  299. locateToErr() {
  300. setTimeout(() => {
  301. const errorDiv = document.getElementsByClassName('is-error');
  302. errorDiv[0].scrollIntoView();
  303. }, 0);
  304. },
  305. getIndex(data, list) {
  306. let hospitalRelationVOList = JSON.parse(
  307. JSON.stringify(this.form.hospitalRelationVOList)
  308. );
  309. hospitalRelationVOList.forEach(it => {
  310. delete it.errorOther;
  311. delete it.errorCurrent;
  312. });
  313. hospitalRelationVOList.forEach((item, index) => {
  314. data.forEach((it, i) => {
  315. if (item.name == it.name && item.code == it.code) {
  316. list.push(index);
  317. }
  318. });
  319. });
  320. },
  321. // 处理拼音转换
  322. handlePinyin(e) {
  323. // console.log(e.target.value,'==========');
  324. this.form.spell = pinyin.getCamelChars(e.target.value);
  325. },
  326. add() {
  327. this.form.hospitalRelationVOList.push({
  328. name: '',
  329. code: '',
  330. errorOther: false,
  331. errorCurrent: false
  332. });
  333. },
  334. addIndex(i) {
  335. this.form.hospitalRelationVOList.splice(i + 1, 0, {
  336. name: '',
  337. code: '',
  338. errorOther: false,
  339. errorCurrent: false
  340. });
  341. this.$nextTick(() => {
  342. this.$refs.tableList.bodyWrapper.scrollTop += 55;
  343. });
  344. },
  345. delIndex(i) {
  346. this.form.hospitalRelationVOList.splice(i, 1);
  347. }
  348. }
  349. };
  350. </script>
  351. <style lang="less" scoped>
  352. .AddPlanWrapper {
  353. min-width: 940px;
  354. .AddPlanBox {
  355. padding: 20px 60px 120px 60px;
  356. margin: 70px 20px 0 20px;
  357. background: #fff;
  358. }
  359. color: #606266;
  360. .topBack {
  361. top: 0;
  362. }
  363. .title {
  364. background-color: #f2f2f2;
  365. display: flex;
  366. .handleIcon {
  367. width: 30px;
  368. cursor: pointer;
  369. height: 40px;
  370. display: flex;
  371. justify-content: center;
  372. align-items: center;
  373. img {
  374. width: 20px;
  375. height: 20px;
  376. }
  377. .open {
  378. transform: rotate(180deg);
  379. }
  380. .close {
  381. transform: rotate(0deg);
  382. }
  383. }
  384. .titlwSwitch {
  385. width: 120px;
  386. }
  387. h4 {
  388. flex: 1;
  389. }
  390. .titlwSwitchStatus {
  391. margin-left: 16px;
  392. }
  393. }
  394. .sub {
  395. .planItem {
  396. display: flex;
  397. .sort {
  398. width: 60px;
  399. display: flex;
  400. .top {
  401. display: flex;
  402. justify-content: center;
  403. align-items: center;
  404. width: 30px;
  405. cursor: pointer;
  406. img {
  407. width: 10px;
  408. height: 14px;
  409. }
  410. }
  411. .down {
  412. width: 30px;
  413. cursor: pointer;
  414. display: flex;
  415. justify-content: center;
  416. align-items: center;
  417. img {
  418. width: 10px;
  419. height: 14px;
  420. }
  421. }
  422. }
  423. .openOrClose {
  424. display: flex;
  425. flex: 1;
  426. .planInfo {
  427. width: 140px;
  428. }
  429. .switch {
  430. }
  431. .planStatus {
  432. margin-left: 16px;
  433. }
  434. }
  435. .showNum {
  436. display: flex;
  437. width: 160px;
  438. /deep/.el-input--small {
  439. width: 60px;
  440. }
  441. }
  442. }
  443. }
  444. .el-button {
  445. float: right;
  446. }
  447. .plus-icon-enter-active {
  448. transition: all 0.8s;
  449. }
  450. .plus-icon-enter {
  451. opacity: 0;
  452. margin-top: 12px;
  453. }
  454. .plus-icon-leave-active {
  455. transition: all 0.8s;
  456. }
  457. .plus-icon-leave-active {
  458. opacity: 0;
  459. margin-top: 12px;
  460. }
  461. }
  462. .leaveBox {
  463. /deep/ .leaveBtn {
  464. // margin-right: 46px;
  465. background-color: #d7d7d7 !important;
  466. border-color: transparent;
  467. }
  468. }
  469. .tabs {
  470. max-width: 100%;
  471. min-width: 100%;
  472. border-bottom:1px solid #dcdfe6;
  473. .star {
  474. color: #ff545b;
  475. }
  476. /deep/.el-input__inner {
  477. height: 32px;
  478. margin-bottom: 18px;
  479. font-size: 12px;
  480. }
  481. /deep/ .is-error .el-form-item__error {
  482. top: 34px;
  483. }
  484. .operation {
  485. display: flex;
  486. justify-content: center;
  487. }
  488. }
  489. .add-border {
  490. border: 1px #48c5d7 dashed;
  491. width: 96%;
  492. height: 30px;
  493. text-align: center;
  494. line-height: 30px;
  495. cursor: pointer;
  496. background: url('../../../images/add-nob.png') no-repeat center center;
  497. background-size: 16px 16px;
  498. }
  499. .add {
  500. width: 100%;
  501. height: 80px;
  502. display: flex;
  503. justify-content: center;
  504. align-items: center;
  505. border: 1px solid #ebeef5;
  506. border-top: none;
  507. box-sizing: border-box;
  508. }
  509. .diag-center {
  510. text-align: center;
  511. .diag-title {
  512. font-size: 16px;
  513. margin-bottom: 5px;
  514. color: #ff545b;
  515. }
  516. .title-warning {
  517. display: block;
  518. margin: 10px 0;
  519. }
  520. .title-warning-2 {
  521. padding-left: 13px;
  522. }
  523. }
  524. .dialog-footer {
  525. display: flex;
  526. overflow: hidden;
  527. justify-content: center;
  528. }
  529. /deep/.el-form-item.is-success .el-input__inner,
  530. .el-form-item.is-success .el-input__inner:focus,
  531. .el-form-item.is-success .el-textarea__inner,
  532. .el-form-item.is-success .el-textarea__inner:focus {
  533. border-color: #ccc;
  534. }
  535. </style>