PubTemplateGroup.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <div class="PubTagGroupWrapper">
  3. <el-button class="copyTmpt" type="primary" @click="copyTmpt" v-if="editData.id && this.form.region3 != 0">复制该内容</el-button>
  4. <el-form
  5. class="groups"
  6. :rules="rules"
  7. ref="groups"
  8. :model="form"
  9. label-width="150px"
  10. >
  11. <el-form-item
  12. label="模板名称:"
  13. prop="region2"
  14. >
  15. <el-input
  16. v-model="form.region2"
  17. maxLength="120"
  18. placeholder="请输入模板名称"
  19. ></el-input>
  20. </el-form-item>
  21. <el-form-item
  22. label="模板类型:"
  23. prop="region3"
  24. >
  25. <span class="changeTips">改变模板类型后,模板内容将会恢复到默认状态</span>
  26. <el-select
  27. :disabled="form.isCopy || !!editData.id"
  28. v-model="form.region3"
  29. placeholder="模板类型"
  30. @change="sendData"
  31. >
  32. <el-option
  33. v-for="item in AdscriptionsType"
  34. :label="item.name"
  35. :value="item.key+''"
  36. :key="item.key"
  37. ></el-option>
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item
  41. :label="form.region3 == 1?'属于科室:':'属于慢病:'"
  42. prop="region4"
  43. v-if="form.region3 != 0"
  44. >
  45. <span class="changeTips">改变属于类别后,模板内容将会恢复到默认状态</span>
  46. <el-select
  47. :disabled="!!editData.id"
  48. v-model="form.region4"
  49. :placeholder="form.region3 == 1?'属于科室':'属于慢病'"
  50. @change="sendData"
  51. >
  52. <el-option
  53. v-for="item in sonLis"
  54. :label="item.name"
  55. :value="item.id+''"
  56. :key="item.id"
  57. v-if="!!item.name"
  58. ></el-option>
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item
  62. label="模板归属:"
  63. prop="region1"
  64. >
  65. <span class="changeTips">改变模板归属后,模板内容将会恢复到默认状态</span>
  66. <el-select
  67. :disabled="form.isCopy || !!editData.id || (form.region3 == '') || (form.region3 != '0' && form.region4 == '')"
  68. v-model="form.region1"
  69. placeholder="模板归属"
  70. @change="sendData"
  71. >
  72. <el-option
  73. v-for="item in Adscriptions"
  74. :label="item.name"
  75. :value="item.type+''"
  76. :key="item.type"
  77. ></el-option>
  78. </el-select>
  79. </el-form-item>
  80. </el-form>
  81. </div>
  82. </template>
  83. <script>
  84. import api from '@api/icss.js';
  85. import utils from '@api/utils.js';
  86. /**
  87. * 归属type
  88. * 1:主诉模板 2:现病史模板 3:现病史空模板 4 : 其他史模板 5:嵌套模板 6:慢病模板
  89. */
  90. export default {
  91. props:['editData'],
  92. data() {
  93. var validatePass2 = (rule, value, callback) => {
  94. this.validateSystomName(value,callback)
  95. };
  96. return {
  97. numWord:0,
  98. Adscriptions:[],
  99. sonLis:[],
  100. form: {
  101. region1: '', //归属
  102. region2: '', //模板名称
  103. region3: '', //类型
  104. region4: '', //所属科室慢病
  105. isCopy:false
  106. },
  107. rules: {
  108. region1: [
  109. { required: true, message: '请选择模板归属', trigger: 'change' }
  110. ],
  111. region2: [
  112. { required: true, message: '请输入模板名称', trigger: 'change' },
  113. { validator: validatePass2, trigger: 'blur' },
  114. ],
  115. region3: [
  116. { required: true, message: '请选择模板类型', trigger: 'change' },
  117. ],
  118. region4: [
  119. { required: true, message: '请选择所属', trigger: 'change' },
  120. ],
  121. },
  122. AdscriptionsType:[],
  123. deptDis:{}
  124. }
  125. },
  126. beforeMount:function(){
  127. let templateType = localStorage.getItem('icssEnumsData') ? JSON.parse(localStorage.getItem('icssEnumsData')).moduleInfoTypeEnum : []
  128. let templateOwn = localStorage.getItem('typeLis') ? JSON.parse(localStorage.getItem('typeLis')) : []
  129. this.deptDis = localStorage.getItem('deptDis') ? JSON.parse(localStorage.getItem('deptDis')) : {}
  130. for(let i = 0;i < templateOwn.length;i++){
  131. templateOwn[i].type = templateOwn[i].val
  132. }
  133. this.Adscriptions = templateOwn
  134. this.AdscriptionsType = templateType
  135. },
  136. computed:{
  137. tmpType(){
  138. return this.form.region3
  139. },
  140. tmpOwnTo(){
  141. return this.form.region4
  142. }
  143. },
  144. watch: {
  145. tmpType(newVal, preVal){
  146. if(newVal != preVal){
  147. if(newVal == 1){
  148. let tmpDeptDTOS = this.deptDis.deptDTOS
  149. // let obj = {id:-1,name:'通用'}
  150. // if(tmpDeptDTOS[0].id != 0){
  151. // tmpDeptDTOS.unshift(obj)
  152. // }
  153. this.sonLis = tmpDeptDTOS
  154. if(!this.form.id){
  155. this.form.region4 = ''
  156. this.form.region1 = ''
  157. }
  158. }else if(newVal == 2){
  159. let tmpDisDTOS = this.deptDis.disDTOS
  160. // let obj = {id:-1,name:'通用'}
  161. // if(tmpDisDTOS[0].id != 0){
  162. // tmpDisDTOS.unshift(obj)
  163. // }
  164. this.sonLis = tmpDisDTOS
  165. if(!this.form.id){
  166. this.form.region4 = ''
  167. this.form.region1 = ''
  168. }
  169. }else{
  170. this.sonLis = []
  171. if(!this.form.id){
  172. this.getTypes()
  173. this.form.region4 = ''
  174. this.form.region1 = ''
  175. }
  176. }
  177. }
  178. },
  179. tmpOwnTo(newVal, preVal){
  180. if(newVal != preVal){
  181. if(!this.form.id){
  182. this.getTypes()
  183. this.form.region1 = ''
  184. }
  185. if(this.form.isCopy){
  186. this.getTypes('copy')
  187. }
  188. }
  189. }
  190. },
  191. mounted() {
  192. const editData = this.$props.editData;
  193. if(editData.id){ //修改
  194. this.form = Object.assign({},this.form,editData);
  195. this.form.region1 = editData.type
  196. this.form.region2 = editData.name
  197. this.form.region3 = editData.moduleType+''
  198. this.form.region4 = editData.relationId+''
  199. }
  200. this.$emit('changeVal', this.form, false)
  201. },
  202. methods:{
  203. copyTmpt(){
  204. this.editData.id = ''
  205. this.form.isCopy = true
  206. this.$emit('staticOwn', this.form.region4, false)
  207. this.$emit('changeVal', this.form, false)
  208. },
  209. getTypes(type){
  210. let param = {
  211. "moduleType": this.form.region3,
  212. "relationId": this.form.region4
  213. }
  214. api.getModuleType(param).then((res) => {
  215. if (res.data.code === '0') {//获取模板归属
  216. let result = res.data.data
  217. if(type){
  218. let num = 0;
  219. for(let i = 0;i < result.length;i++){
  220. if(result[i].type == this.form.region1){
  221. ++num
  222. }
  223. }
  224. if(num == 0){
  225. this.$message({
  226. message:'该归属下的模板已添加',
  227. type:'warning'
  228. })
  229. this.$emit('staticOwn', this.form.region4, false)
  230. return
  231. }
  232. }else{
  233. this.Adscriptions = result
  234. }
  235. }
  236. })
  237. },
  238. sendData(val){
  239. this.$emit('changeVal', this.form, false)
  240. },
  241. submitForm(formName) {
  242. this.$refs[formName].validate((valid) => {
  243. if (valid) {
  244. this.$emit('validatePass', this.form, false)
  245. } else {
  246. console.log('error submit!!');
  247. return false;
  248. }
  249. });
  250. },
  251. validateSystomName(name,callback,flg) {
  252. let tmpVal = this.form.region2
  253. if(tmpVal.trim() == ''){
  254. callback(new Error('模板名称不能为空'));
  255. }else{
  256. this.form.region2 = tmpVal.trim()
  257. callback();
  258. }
  259. },
  260. }
  261. }
  262. </script>
  263. <style lang="less">
  264. .PubTagGroupWrapper {
  265. position: relative;
  266. .copyTmpt {
  267. position: absolute;
  268. right: 40px;
  269. top: 20px;
  270. }
  271. .groups {
  272. background-color: #fff;
  273. padding: 20px;
  274. margin: 20px 20px -20px 20px;
  275. .el-form-item__content,
  276. .el-input__inner {
  277. height: 30px;
  278. line-height: 30px;
  279. width: 200px;
  280. }
  281. .el-form-item {
  282. margin-bottom: 20px;
  283. }
  284. .el-form-item__error {
  285. top: 28px;
  286. }
  287. .el-form-item__label {
  288. line-height: 30px;
  289. text-align: left;
  290. }
  291. .el-input__icon {
  292. line-height: 30px;
  293. }
  294. .verticalMiddle .el-form-item__content {
  295. position: relative;
  296. top: 16px;
  297. }
  298. .maxAges {
  299. margin-left: -125px;
  300. }
  301. .ages {
  302. display: inline-block;
  303. .el-form-item__content {
  304. width: auto;
  305. }
  306. .el-input {
  307. display: inline-block;
  308. width: auto;
  309. .el-input__inner {
  310. width: 60px;
  311. padding: 0 5px;
  312. margin-right: 25px;
  313. text-align: center;
  314. }
  315. .el-input__inner::-webkit-outer-spin-button,
  316. .el-input__inner::-webkit-inner-spin-button {
  317. -webkit-appearance: none;
  318. }
  319. .el-input__inner[type="number"] {
  320. -moz-appearance: textfield;
  321. }
  322. }
  323. }
  324. .el-message-box__btns .el-button--default {
  325. color: #606266 !important;
  326. }
  327. .cancelColor {
  328. color: #22ccc8 !important;
  329. }
  330. .changeTips {
  331. position: absolute;
  332. left: 220px;
  333. min-width: 300px;
  334. color: #22ccc8;
  335. font-size: 12px;
  336. }
  337. }
  338. }
  339. </style>