AddHospital.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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="16">
  12. <el-form ref="form" :model="form" label-width="110px" :rules="rules">
  13. <el-form-item label="医院名称" prop="hospitalName">
  14. <el-input v-model="form.hospitalName" placeholder="2-30位,可输入汉字、字母、数字和下划线" @blur="handlePinyin($event)"></el-input>
  15. </el-form-item>
  16. <el-form-item label="医院名称拼音" prop="spell">
  17. <el-input v-model="form.spell" placeholder="请输入医院名称拼音"></el-input>
  18. </el-form-item>
  19. <!-- <el-form-item label="医院编码" prop="hospitalCode">
  20. <el-input v-model="form.hospitalCode" placeholder="4-15位,可输入字母、数字和下划线"></el-input>
  21. </el-form-item> -->
  22. <el-form-item label="医院地址" prop="address">
  23. <el-input type="textarea" :rows="2" v-model="form.address" placeholder="请输入医院地址"></el-input>
  24. </el-form-item>
  25. <el-form-item>
  26. <el-button type="primary" @click="onSubmit" :disabled="saveDisable">确定</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </el-col>
  30. </el-row>
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import api from '@api/cdss.js';
  36. import pinyin from '../../../js/Convert_Pinyin.js';
  37. export default {
  38. name: 'AddHospital',
  39. data() {
  40. var numreg = /^[a-zA-Z0-9_\u4e00-\u9fa5]+$/;
  41. var numreg1 = /^[0-9a-zA-Z_]{1,}$/;
  42. var validatePass = (rule, value, callback) => {
  43. if (!numreg.test(value)) {
  44. callback(new Error('汉字、字母、数字和下划线'));
  45. } else {
  46. callback();
  47. }
  48. };
  49. var validatePass1 = (rule, value, callback) => {
  50. if (!numreg1.test(value)) {
  51. callback(new Error('字母、数字和下划线'));
  52. } else {
  53. callback();
  54. }
  55. };
  56. return {
  57. form: {
  58. hospitalName: '',
  59. spell: '',
  60. // hospitalCode: '',
  61. address: ''
  62. },
  63. rules: {
  64. hospitalName: [
  65. { required: true, message: '医院名称不能为空', trigger: 'change' },
  66. { min: 2, max: 30, message: '长度2-30位', trigger: 'blur' },
  67. { required: true, validator: validatePass, trigger: 'blur' }
  68. ],
  69. // hospitalCode: [
  70. // { required: true, message: '医院编码不能为空', trigger: 'change' },
  71. // { min: 4, max: 15, message: '长度4-15位', trigger: 'blur' },
  72. // { required: true, validator: validatePass1, trigger: 'blur' }
  73. // ],
  74. address:[
  75. { max: 200, message: '长度最多200字', trigger: 'change' },
  76. ],
  77. spell:[
  78. { max: 30, message: '医院名称拼音长度最多30位', trigger: 'change' },
  79. ],
  80. },
  81. hospitalId: '',
  82. isEdit: false,
  83. saveDisable: false
  84. };
  85. },
  86. created() {
  87. const { isEdit, data } = this.$route.params;
  88. this.isEdit = isEdit;
  89. if (isEdit) {
  90. this.form.hospitalName = data.name;
  91. this.form.spell = data.spell;
  92. // this.form.hospitalCode = data.code;
  93. this.form.address = data.address;
  94. this.hospitalId = data.id;
  95. }
  96. },
  97. methods: {
  98. onSubmit() {
  99. this.$refs.form.validate(valid => {
  100. if (valid) {
  101. this.saveDisable = true;
  102. let params = {
  103. connect: 1,
  104. address: this.form.address,
  105. name: this.form.hospitalName,
  106. spell: this.form.spell,
  107. // code: this.form.hospitalCode
  108. };
  109. if (this.isEdit) {
  110. params = Object.assign({}, params, {
  111. id: this.hospitalId
  112. });
  113. }
  114. api.saveOrUpdateHosRecordCDSS(params).then(res => {
  115. if (res.data.code === '0') {
  116. this.$message({
  117. showClose: true,
  118. message: '保存成功',
  119. type: 'success',
  120. duration: 1000
  121. });
  122. this.isSaveSuccess = true; // 保存成功,可正常退出
  123. this.$router.push({
  124. name: 'HospitalCDSS',
  125. params: Object.assign({}, this.$route.params, {
  126. currentPage: 1
  127. })
  128. });
  129. } else {
  130. this.$message({
  131. showClose: true,
  132. message: res.data.msg,
  133. type: 'error',
  134. duration: 1000
  135. });
  136. }
  137. this.saveDisable = false;
  138. });
  139. }
  140. });
  141. },
  142. // 处理拼音转换
  143. handlePinyin(e){
  144. // console.log(e.target.value,'==========');
  145. this.form.spell = pinyin.getCamelChars(e.target.value)
  146. }
  147. }
  148. };
  149. </script>
  150. <style lang="less" scoped>
  151. .AddPlanWrapper {
  152. min-width: 940px;
  153. .AddPlanBox {
  154. padding: 20px 60px 120px 60px;
  155. margin: 70px 20px 0 20px;
  156. background: #fff;
  157. }
  158. color: #606266;
  159. .topBack {
  160. top: 0;
  161. }
  162. .title {
  163. background-color: #f2f2f2;
  164. display: flex;
  165. .handleIcon {
  166. width: 30px;
  167. cursor: pointer;
  168. height: 40px;
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. img {
  173. width: 20px;
  174. height: 20px;
  175. }
  176. .open {
  177. transform: rotate(180deg);
  178. }
  179. .close {
  180. transform: rotate(0deg);
  181. }
  182. }
  183. .titlwSwitch {
  184. width: 120px;
  185. }
  186. h4 {
  187. flex: 1;
  188. }
  189. .titlwSwitchStatus {
  190. margin-left: 16px;
  191. }
  192. }
  193. .sub {
  194. .planItem {
  195. display: flex;
  196. .sort {
  197. width: 60px;
  198. display: flex;
  199. .top {
  200. display: flex;
  201. justify-content: center;
  202. align-items: center;
  203. width: 30px;
  204. cursor: pointer;
  205. img {
  206. width: 10px;
  207. height: 14px;
  208. }
  209. }
  210. .down {
  211. width: 30px;
  212. cursor: pointer;
  213. display: flex;
  214. justify-content: center;
  215. align-items: center;
  216. img {
  217. width: 10px;
  218. height: 14px;
  219. }
  220. }
  221. }
  222. .openOrClose {
  223. display: flex;
  224. flex: 1;
  225. .planInfo {
  226. width: 140px;
  227. }
  228. .switch {
  229. }
  230. .planStatus {
  231. margin-left: 16px;
  232. }
  233. }
  234. .showNum {
  235. display: flex;
  236. width: 160px;
  237. /deep/.el-input--small {
  238. width: 60px;
  239. }
  240. }
  241. }
  242. }
  243. .el-button {
  244. float: right;
  245. }
  246. .plus-icon-enter-active {
  247. transition: all 0.8s;
  248. }
  249. .plus-icon-enter {
  250. opacity: 0;
  251. margin-top: 12px;
  252. }
  253. .plus-icon-leave-active {
  254. transition: all 0.8s;
  255. }
  256. .plus-icon-leave-active {
  257. opacity: 0;
  258. margin-top: 12px;
  259. }
  260. }
  261. .leaveBox {
  262. /deep/ .leaveBtn {
  263. // margin-right: 46px;
  264. background-color: #d7d7d7 !important;
  265. border-color: transparent;
  266. }
  267. }
  268. </style>