AddHospital.vue 16 KB

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