AddDiagBase.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <div>
  3. <crumbs :title="title" :param="$route.params" linkTo="ZskDiagBase"></crumbs>
  4. <div class="contents">
  5. <div class="content">
  6. <el-form ref="form" :label-position="labelPosition" class="add-new-form" label-width="150px" :model="form" :rules="rules">
  7. <el-form-item label="疾病名称:" prop="conceptId">
  8. <el-select clearable remote filterable :remote-method="searchDiag" v-model.trim="form.conceptId">
  9. <el-option
  10. v-for="item in conceptList"
  11. :key="item.conceptId"
  12. :label="item.conceptName"
  13. :value="item.conceptId">
  14. </el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="诊断依据描述:" class="description">
  18. <el-input type="textarea" :rows="3" placeholder="请输入诊断依据描述" v-model.trim="form.description"></el-input>
  19. </el-form-item>
  20. <el-form-item label="诊断依据内容:" prop="remind" class="discDesc is-required">
  21. <DiagBaseType v-for="(group,i) in form.klDiagnoseTypeVO"
  22. ref="groups"
  23. :data="group"
  24. :inx="i"
  25. :isLast="form.klDiagnoseTypeVO.length===1"
  26. @setRules="setRules"
  27. @addDiag="addDiag"
  28. @copyDiag="copyDiag"
  29. @delDiag="delDiag"></DiagBaseType>
  30. </el-form-item>
  31. <el-button class="disclButn" size="small" type="primary" @click="confirm">保存</el-button>
  32. </el-form>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script type="text/javascript">
  38. import api from '@api/zskDiagBase.js';
  39. import DiagBaseType from './DiagBaseType'
  40. export default {
  41. name:'AddZskDiagBase',
  42. data(){
  43. return{
  44. labelPosition:'left',
  45. isCopy:false,
  46. title:'诊断依据维护-添加诊断依据',
  47. conceptName:'',
  48. conceptList:[],
  49. form:{
  50. description:'',
  51. conceptId:'',
  52. klDiagnoseTypeVO:[{conditionType:'',groupVO:[{
  53. "baseGroup": '',
  54. "conditionGroup": '',
  55. "fitNo": '',
  56. "klDiagnoseDetail": [{
  57. "basConceptId": '',
  58. "basDescription": "",
  59. "basLename": "",
  60. "basLibName": "",
  61. "basLibType":null,
  62. "basType": '',
  63. "eqOperator": "",
  64. "eqUnit": "",
  65. "eqValue": "",
  66. "maxOperator": "",
  67. "maxUnit": "",
  68. "maxVal": "",
  69. "minOperator": "",
  70. "minUnit": "",
  71. "minVal": ""
  72. }]
  73. }]}],
  74. },
  75. id:null,
  76. rules:{
  77. conceptId:[{ required: true, message: '请输入疾病名称',trigger: ['change'] }],
  78. description:[{
  79. validator: (rule,value,callback)=>{
  80. if(value&&value.length>100){
  81. callback(new Error('诊断依据描述不能超过100字'));
  82. }else{
  83. callback();
  84. }}, trigger: 'change'
  85. }],
  86. }
  87. }
  88. },
  89. created(){
  90. const param = this.$route.params;
  91. let info = param.data;
  92. if(info){
  93. this.id = info.id;
  94. this.isCopy=param.copy;
  95. this.title = "诊断依据维护-"+(this.isCopy?'复制':'修改')+"诊断依据";
  96. this.conceptList = [{conceptId:info.conceptId,conceptName:info.conceptName}];
  97. this.form=Object.assign({},this.form,this.formatData(info));
  98. if(this.isCopy){
  99. this.conceptList =[];
  100. delete this.form.conceptName;
  101. delete this.form.conceptId;
  102. delete this.form.description;
  103. delete this.form.id;
  104. }
  105. console.log(info)
  106. }
  107. this.setRules()
  108. },
  109. components:{
  110. DiagBaseType
  111. },
  112. methods:{
  113. formatData(data){ //转换字段名
  114. let str = JSON.stringify(data).replace(/byIdDTO/g,"groupVO").replace(/klDiagnoseByIdDTO/g,"klDiagnoseDetail");
  115. //console.log(JSON.parse(str))
  116. return JSON.parse(str);
  117. },
  118. setRules(){
  119. let that=this;
  120. let list=this.form.klDiagnoseTypeVO;
  121. if(list&&list.length>0){
  122. list.forEach((item,i)=>{
  123. let list1=list[i].groupVO;
  124. that.rules['klDiagnoseTypeVO.'+i+'.conditionType']=[{required: true, message: '请选择诊断依据类型',trigger: ['change'] }];
  125. list1.forEach((it,x)=>{
  126. that.rules['klDiagnoseTypeVO.'+i+'.groupVO.'+x+'.fitNo']=[{required: true, message: '请选择符合条件的数量',trigger: ['change'] }];
  127. let list2=list1[x].klDiagnoseDetail;
  128. list2.forEach((t,j)=>{
  129. let grandeObj = this.form.klDiagnoseTypeVO[i].groupVO[x].klDiagnoseDetail[j];
  130. if(grandeObj) {
  131. const keyTxt='klDiagnoseTypeVO.' + i + '.groupVO.' + x + '.klDiagnoseDetail.' + j;
  132. that.rules[keyTxt + '.basDescription'] = [{
  133. required: true,
  134. message: '请输入基础依据名称',
  135. trigger: ['blur']
  136. }];
  137. that.rules[keyTxt + '.basType'] = [{
  138. required: true,
  139. message: '请选择基础依据类型',
  140. trigger: ['change']
  141. }];
  142. that.rules[keyTxt + '.basLibType'] = [{
  143. required: true,
  144. message: '请选择基础依据术语类型',
  145. trigger: ['change']
  146. }];
  147. that.rules[keyTxt + '.basConceptId'] = [{
  148. required: true,
  149. message: '请输入医学标准术语',
  150. trigger: ['change']
  151. }];
  152. that.rules[keyTxt + '.dataType'] = [{
  153. required: true,
  154. message: '请选择类型',
  155. trigger: ['change']
  156. }];
  157. that.rules[keyTxt + '.maxOperator'] = [{
  158. validator: (rule, value, callback) => {
  159. const {maxVal, minOperator, minVal} = grandeObj;
  160. const val = value + minOperator + minVal + maxVal;
  161. if (!val || (!value && maxVal !== '')) {
  162. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  163. } else {
  164. callback();
  165. }
  166. }, trigger: 'blur'
  167. }];
  168. that.rules[keyTxt + '.minOperator'] = [{
  169. validator: (rule, value, callback) => {
  170. const {maxVal, maxOperator, minVal} = grandeObj;
  171. const val = value + maxOperator + minVal + maxVal;
  172. if (!val || (!value && minVal !== '')) {
  173. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  174. } else {
  175. callback();
  176. }
  177. }, trigger: 'blur'
  178. }];
  179. that.rules[keyTxt + '.maxVal'] = [{
  180. validator: (rule, value, callback) => {
  181. const {maxOperator, minOperator, minVal} = grandeObj;
  182. const val = value + maxOperator + minVal + minOperator;
  183. const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
  184. if (!val || (value === '' && maxOperator)) {
  185. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  186. } else if (value !== '' && !isNum) {
  187. callback(new Error('只能输入数字'));
  188. } else {
  189. callback();
  190. }
  191. }, trigger: 'blur'
  192. }]
  193. that.rules[keyTxt + '.minVal'] = [{
  194. validator: (rule, value, callback) => {
  195. const {maxVal, minOperator, maxOperator} = grandeObj;
  196. const val = value + maxOperator + maxVal + minOperator;
  197. const isNum = /^(\-|\+)?\d+(\.\d+)?$/.test(value);
  198. console.log(val, value, minOperator)
  199. if (!val || (value === '' && minOperator)) {
  200. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  201. } else if (value !== '' && !isNum) {
  202. callback(new Error('只能输入数字'));
  203. } else {
  204. callback();
  205. }
  206. }, trigger: 'blur'
  207. }];
  208. that.rules[keyTxt + '.eqValue'] = [{required: true, message: '不能为空~',trigger: 'blur'},{
  209. validator: (rule, value, callback) => {console.log(112,value)
  210. if (value&&value.length > 200) {
  211. callback(new Error('不能超过200字'));
  212. } else {
  213. callback();
  214. }
  215. }, trigger: 'blur'
  216. }];
  217. }
  218. });
  219. });
  220. })
  221. }
  222. },
  223. formatGroupDatas(data){
  224. let arr=[];
  225. return arr;
  226. },
  227. searchDiag(val){
  228. const param = {
  229. diseaseName:val,
  230. };
  231. api.searchDiag(param).then((res) => {
  232. if (res.data.code == '0') {
  233. const data = res.data.data;
  234. this.conceptList = data;
  235. }
  236. }).catch((error) => {
  237. console.log(error);
  238. });
  239. },
  240. getInitData(){
  241. return {conditionType:'',groupVO:[{
  242. "baseGroup": '',
  243. "conditionGroup": '',
  244. "fitNo": '',
  245. "klDiagnoseDetail": [{
  246. "basConceptId": '',
  247. "basDescription": "",
  248. "basLename": "",
  249. "basLibName": "",
  250. "basLibType": null,
  251. "basType": '',
  252. "eqOperator": "",
  253. "eqUnit": "",
  254. "eqValue": "",
  255. "maxOperator": "",
  256. "maxUnit": "",
  257. "maxVal": "",
  258. "minOperator": "",
  259. "minUnit": "",
  260. "minVal": ""
  261. }]
  262. }]}
  263. },
  264. setInitGroupData(){
  265. let temp = this.getInitData();
  266. this.form.klDiagnoseTypeVO = [temp];
  267. },
  268. addDiag(i){
  269. let temp = this.getInitData();
  270. this.form.klDiagnoseTypeVO.splice(i+1,0,temp);
  271. this.setRules();
  272. },
  273. copyDiag(i){
  274. let temp = JSON.parse(JSON.stringify(this.form.klDiagnoseTypeVO[i]));
  275. this.form.klDiagnoseTypeVO.splice(i,0,temp);
  276. this.setRules();
  277. },
  278. delDiag(i){
  279. this.form.klDiagnoseTypeVO.splice(i,1);
  280. },
  281. saveDiagBase(params){
  282. api.saveDiagBase(params).then((res)=>{
  283. if(res.data.code==0){
  284. this.$message({
  285. message:"操作成功",
  286. type:'success'
  287. });
  288. this.$router.push({name: 'ZskDiagBase'});
  289. }else{
  290. this.$message({
  291. message:res.data.msg,
  292. type:'warning'
  293. });
  294. }
  295. })
  296. },
  297. validateForms(callBack){
  298. this.$refs['form'].validate((valid) => {
  299. if (valid) {
  300. callBack();
  301. } else {
  302. return false;
  303. }
  304. });
  305. },
  306. confirm(){
  307. const _this=this;
  308. this.validateForms(function(){
  309. let params = _this.form;
  310. _this.saveDiagBase(params);
  311. });
  312. },
  313. }
  314. }
  315. </script>
  316. <style lang="less">
  317. @import "../../less/admin.less";
  318. .content{
  319. background: #fff;
  320. // padding: 20px 20px 30px;
  321. padding: 20px 20px 50px;
  322. color: #545455;
  323. min-width: 980px;
  324. position: relative;
  325. .tip-text{
  326. color:#F56C6C;
  327. margin-left: 10px;
  328. }
  329. .conceptItem{
  330. padding: 0 10px;
  331. cursor: pointer;
  332. height: 32px;
  333. line-height: 32px;
  334. &:hover{
  335. background: #ebedf1;
  336. }
  337. }
  338. .discDesc{
  339. margin-bottom: 20px;
  340. .el-form-item__error{
  341. top: 9px;
  342. left:200px;
  343. white-space: nowrap;
  344. background: #fff;
  345. }
  346. }
  347. .disclButn{
  348. position: absolute;
  349. right: calc(50% - 60px);
  350. bottom: 10px;
  351. }
  352. }
  353. .description .el-form-item__error{
  354. top:auto;
  355. }
  356. .add-new-form{
  357. .el-form-item__label{
  358. text-align: right;
  359. }
  360. .addDepartFormItem {
  361. position: relative;
  362. }
  363. .itemList {
  364. position: absolute;
  365. // display: none;
  366. background: #fff;
  367. width: 188px;
  368. max-height: 160px;
  369. border: 1px solid #DCDFE6;
  370. left: 0;
  371. top: 37px;
  372. z-index: 2;
  373. overflow-y: auto;
  374. }
  375. .indexList {
  376. left: 42px;
  377. top: 78px;
  378. }
  379. .el-input__prefix, .el-input__suffix{
  380. /*top:-2px;*/
  381. right: 3px;
  382. }
  383. .el-input--suffix .el-input__inner{
  384. padding-right: 22px;
  385. }
  386. .el-input,.el-input__inner{
  387. width: 190px;
  388. line-height: 32px;
  389. height: 32px;
  390. }
  391. .el-input__icon{
  392. line-height: 32px;
  393. }
  394. }
  395. </style>