SubConditions.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  1. <template>
  2. <div class="groups-cont">
  3. <el-form ref="groupData" label-width="150px" class="sub-condition-form" :model="groupData" :rules="rules">
  4. <span v-if="!disabled&&!isLast" class="del-btn" @click="delRule">删除</span><!--:class="isLast?'disable del-btn':'del-btn'"-->
  5. <el-form-item label="基础规则名称:" prop="subDescription">
  6. <el-input v-model.trim = "groupData.subDescription" :disabled="disabled"></el-input>
  7. </el-form-item>
  8. <el-form-item label="基础规则类型:" prop="subType">
  9. <el-select v-model="groupData.subType"
  10. :disabled="disabled"
  11. placeholder="请选择"
  12. size="small"
  13. @change="subTypeChange">
  14. <el-option
  15. v-for="item in baseTypes"
  16. :key="item.id"
  17. :label="item.name"
  18. :value="item.type">
  19. </el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="基础规则术语类型:" prop="subLenCode">
  23. <el-select v-model="groupData.subLenCode"
  24. :disabled="disabled"
  25. placeholder="请选择"
  26. size="small" @change="subCodeChange">
  27. <el-option
  28. v-for="item in baseTermTypeList"
  29. :key="item.id"
  30. :label="item.name"
  31. :value="item.code">
  32. </el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item class="addDepartFormItem" label="医学标准术语:" prop="subConceptId">
  36. <el-select clearable remote filterable :disabled="disabled" :remote-method="searchConcept" v-model="groupData.subConceptId">
  37. <el-option
  38. v-for="item in conceptList"
  39. :key="item.conceptId"
  40. :label="item.conceptName"
  41. :value="item.conceptId">
  42. </el-option>
  43. </el-select>
  44. </el-form-item>
  45. <el-form-item v-if="groupData.subType===2" label="选择类型:" prop="dataType">
  46. <el-select v-model="groupData.dataType"
  47. placeholder="请选择"
  48. size="small" @change="dataTypeChange">
  49. <el-option
  50. v-for="item in dataTypes"
  51. :key="item.id"
  52. :label="item.name"
  53. :value="item.id">
  54. </el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item class="min-margin" v-if="groupData.dataType==='1'" label="最大值:">
  58. <div class="select-item clearfix">
  59. <el-col :span="2">
  60. <el-form-item prop="subMaxOperator">
  61. <el-select v-model="groupData.subMaxOperator"
  62. placeholder="请选择"
  63. size="small" clearable>
  64. <el-option
  65. v-for="item in operMaxList"
  66. :key="item.key"
  67. :label="item.name"
  68. :value="item.key">
  69. </el-option>
  70. </el-select>
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="2">
  74. <el-form-item prop="subMaxValue">
  75. <el-input type="text" v-model="groupData.subMaxValue" placeholder="填写数值"/>
  76. </el-form-item>
  77. </el-col>
  78. <el-col :span="2">
  79. <el-form-item prop="subMaxUnit">
  80. <el-input type="text" v-model="groupData.subMaxUnit" placeholder="填写单位"/>
  81. </el-form-item>
  82. </el-col>
  83. </div>
  84. </el-form-item>
  85. <el-form-item class="min-margin" v-if="groupData.dataType==='1'" label="最小值:">
  86. <div class="select-item clearfix">
  87. <el-col :span="2">
  88. <el-form-item prop="subMinOperator">
  89. <el-select v-model="groupData.subMinOperator"
  90. placeholder="请选择"
  91. size="small" clearable>
  92. <el-option
  93. v-for="item in operMinList"
  94. :key="item.name"
  95. :label="item.name"
  96. :value="item.name">
  97. </el-option>
  98. </el-select>
  99. </el-form-item>
  100. </el-col>
  101. <el-col :span="2">
  102. <el-form-item prop="subMinValue">
  103. <el-input type="text" v-model="groupData.subMinValue" placeholder="填写数值"/>
  104. </el-form-item>
  105. </el-col>
  106. <el-col :span="2">
  107. <el-form-item prop="subMinUnit">
  108. <el-input type="text" v-model="groupData.subMinUnit" placeholder="填写单位"/>
  109. </el-form-item>
  110. </el-col>
  111. </div>
  112. </el-form-item>
  113. <el-form-item v-if="groupData.subType!==6&&groupData.dataType==='2'" label="医学内容:" prop="subEqValue" class="discDesc">
  114. <el-input type="textarea" rows="3" placeholder="请输入医学内容" v-model="groupData.subEqValue"></el-input>
  115. </el-form-item>
  116. <el-form-item v-if="groupData.subType===6" label="正则表达式:" prop="subEqValue" class="discDesc">
  117. <el-input type="textarea" rows="3" placeholder="请输入正则表达式" v-model="groupData.subEqValue"></el-input>
  118. </el-form-item>
  119. </el-form>
  120. <div class="inner-oper" v-if="showAdd">
  121. <span>新增规则:</span>
  122. <span class="add-btn" @click="addRule"><img src="../../images/add.png" alt="新增规则"></span>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import api from '@api/knowledgeLib.js';
  128. export default {
  129. name:'subCondititons',
  130. props:['groupData','ind','isLast','baseTypes','firstPlace','disabled','showAdd'],
  131. data(){
  132. return {
  133. baseTermTypeList:[],
  134. typeList:[],
  135. operMaxList:[
  136. {name:'<=',key:'<='},
  137. {name:'<',key:'<'},
  138. ],
  139. operMinList:[{name:'>',key:'>'},
  140. {name:'>=',key:'>='},
  141. ],
  142. dataTypes:[{id:'1',name:'数值类型'},{id:'2',name:'文本类型'}],
  143. conceptList:[],
  144. rules:{
  145. subDescription:[{ required: true, message: '请输入基础规则名称',trigger: ['blur'] },{
  146. validator: (rule,value,callback)=>{
  147. if(value.length>100){
  148. callback(new Error('规则名称不能超过100字'));
  149. }else{
  150. callback();
  151. }}, trigger: 'change'
  152. }],
  153. subType:[{ required: true, message: '请选择基础规则类型',trigger: ['change'] }],
  154. subLenCode:[{ required: true, message: '请选择基础规则术语类型',trigger: ['change'] }],
  155. subConceptId:[{ required: true, message: '请输入医学标准术语',trigger: ['blur'] }],
  156. dataType:[{ required: true, message: '请选择类型',trigger: ['change'] }],
  157. subMaxOperator:[{
  158. validator: (rule,value,callback)=>{
  159. const {subMaxValue,subMinOperator,subMinValue}=this.groupData;
  160. const val=value+subMinOperator+subMinValue+subMaxValue;
  161. if(!val||(!value&&subMaxValue!=='')){
  162. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  163. }else{
  164. callback();
  165. }}, trigger: 'blur'
  166. }],
  167. subMinOperator:[{
  168. validator: (rule,value,callback)=>{
  169. const {subMaxValue,subMaxOperator,subMinValue}=this.groupData;
  170. const val=value+subMaxOperator+subMinValue+subMaxValue;
  171. if(!val||(!value&&subMinValue!=='')){
  172. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  173. }else{
  174. callback();
  175. }}, trigger: 'blur'
  176. }],
  177. subMaxValue:[{
  178. validator: (rule,value,callback)=>{
  179. const {subMaxOperator,subMinOperator,subMinValue}=this.groupData;
  180. const val=value+subMaxOperator+subMinValue+subMinOperator;
  181. const isNum=/^\d+$/.test(value);
  182. if(!val){
  183. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  184. }else if(value!==''&&!isNum){
  185. callback(new Error('只能输入数字'));
  186. }else{
  187. callback();
  188. }}, trigger: 'blur'
  189. }],
  190. subMinValue:[{
  191. validator: (rule,value,callback)=>{
  192. const {subMaxValue,subMinOperator,subMaxOperator}=this.groupData;
  193. const val=value+subMaxOperator+subMaxValue+subMinOperator;
  194. const isNum=/^\d+$/.test(value);
  195. if(!val){
  196. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  197. }else if(value!==''&&!isNum){
  198. callback(new Error('只能输入数字'));
  199. }else{
  200. callback();
  201. }}, trigger: 'blur'
  202. }],
  203. subEqValue:[{ required: true, message: '请输入'+this.groupData.subType===6?"正则表达式":"医学内容",trigger: ['blur'] }],
  204. },
  205. }
  206. },
  207. watch:{
  208. 'groupData':{
  209. handler:function(val){
  210. this.$emit("changeVal",val,this.ind);
  211. },
  212. deep:true
  213. },
  214. 'baseTypes':{
  215. handler:function(val){
  216. if(!this.groupData.subType){
  217. this.baseTermTypeList =[];
  218. return;
  219. }
  220. const obj = val.find((it)=>it.type===this.groupData.subType);
  221. this.baseTermTypeList = obj.subMenuList;
  222. },
  223. deep:true
  224. },
  225. 'firstPlace':{
  226. handler:function(val) {
  227. if (!val) return;
  228. const dict = localStorage.getItem("zskDicts").match(new RegExp(val.checkedType+'-\\d+','g'))||[];
  229. const types = dict[0].split("-");
  230. const sub = this.baseTypes.find((it) => it.ruleType === +types[0] && it.type === +types[2]);
  231. this.groupData.subType = sub.type;
  232. this.baseTermTypeList = sub.subMenuList;
  233. this.groupData.subLenCode = this.baseTermTypeList.find((it) => it.ruleType === +types[0]).code;
  234. this.conceptList = [val];
  235. this.groupData.subDescription = val.conceptName;
  236. this.groupData.subConceptId = val.conceptId;
  237. this.groupData.subConceptName = val.conceptName;
  238. },
  239. deep:true
  240. }
  241. },
  242. created(){
  243. this.conceptList=[{conceptName:this.groupData.subLibName||this.groupData.subConceptName,conceptId:this.groupData.subConceptId}];
  244. if(this.groupData.subLenCode){
  245. this.baseTermTypeList=[{name:this.groupData.subLenName,code:this.groupData.subLenCode}];
  246. }
  247. },
  248. methods:{
  249. dataTypeChange(val){
  250. this.groupData.subEqOperator=val==='2'?'=':undefined;
  251. this.groupData.dataType=val;
  252. this.clearNumText();
  253. },
  254. subTypeChange(val){ //基础规则类型修改
  255. this.groupData.subLenCode='';
  256. this.groupData.dataType='';
  257. this.clearConcept();
  258. this.clearNumText();
  259. if(!val){
  260. this.baseTermTypeList =[];
  261. return;
  262. }
  263. const obj = this.baseTypes.find((it)=>it.type===val);
  264. this.baseTermTypeList = obj.subMenuList;
  265. },
  266. subCodeChange(val){ //基础规则术语类型修改
  267. this.groupData.subLenCode=val;
  268. this.groupData.dataType='';
  269. this.clearConcept();
  270. this.clearNumText();
  271. },
  272. clearConcept(){
  273. this.groupData.subConceptId='';
  274. this.conceptList=[];
  275. },
  276. clearNumText(){
  277. this.groupData.subMaxOperator='';
  278. this.groupData.subMaxValue='';
  279. this.groupData.subMaxUnit='';
  280. this.groupData.subMinOperator='';
  281. this.groupData.subMinValue='';
  282. this.groupData.subMinUnit='';
  283. this.groupData.subEqValue='';
  284. },
  285. searchConcept(val){
  286. const param = {
  287. excludedConceptIds:[this.groupData.subType],
  288. libType:this.groupData.subLenCode,
  289. name:val,
  290. };
  291. api.searchConcept(param).then((res) => {
  292. if (res.data.code == '0') {
  293. const data = res.data.data;
  294. this.conceptList = data;
  295. }
  296. }).catch((error) => {
  297. console.log(error);
  298. });
  299. },
  300. addRule(){
  301. this.$emit("addRule");
  302. },
  303. delRule(){
  304. if(this.isLast){
  305. this.warning("初始状态规则不能删除~");
  306. return;
  307. }
  308. //this.showConfirmDialog("是否删除该条规则,可能对现有系统会造成影响",()=>{
  309. this.$emit("delRule",this.ind);
  310. //});
  311. },
  312. warning(msg,type){
  313. this.$message({
  314. showClose: true,
  315. message:msg,
  316. type:type||'warning'
  317. })
  318. },
  319. showConfirmDialog(msg,resolve){
  320. this.$alert(msg, '提示', {
  321. confirmButtonText: '确定',
  322. type: 'warning'
  323. }).then(() => {
  324. resolve();
  325. }).catch(() => {});
  326. },
  327. }
  328. }
  329. </script>
  330. <style lang="less">
  331. .groups-cont{
  332. background: #fff;
  333. .conceptItem{
  334. padding: 0 10px;
  335. cursor: pointer;
  336. height: 32px;
  337. line-height: 32px;
  338. &:hover{
  339. background: #ebedf1;
  340. }
  341. }
  342. .inner-oper{
  343. padding: 15px 0 15px 21px;
  344. .add-btn {
  345. cursor: pointer;
  346. img {
  347. vertical-align: middle;
  348. }
  349. }
  350. }
  351. .sub-condition-form{
  352. padding: 20px;
  353. position: relative;
  354. border-bottom:2px solid #F5F5F5;
  355. .del-btn{
  356. color: #FF5B5B;
  357. cursor: pointer;
  358. position: absolute;
  359. right: 20px;
  360. top:20px;
  361. z-index: 1;
  362. &.disable{
  363. color: #B8B8B8;
  364. }
  365. }
  366. }
  367. .el-input__icon{
  368. line-height: 32px;
  369. }
  370. .select-item{
  371. &>div{
  372. float: left;
  373. margin-right: 10px;
  374. }
  375. .el-input{
  376. width: auto;
  377. }
  378. input{
  379. width: 95px;
  380. line-height: 32px;
  381. height: 32px;
  382. }
  383. }
  384. .el-input,.el-input__inner{
  385. width: 190px;
  386. line-height: 32px;
  387. height: 32px;
  388. }
  389. .el-button--danger.is-plain{
  390. background: none;
  391. }
  392. .itemList {
  393. position: absolute;
  394. // display: none;
  395. background: #fff;
  396. width: 188px;
  397. max-height: 160px;
  398. border: 1px solid #DCDFE6;
  399. left: 0;
  400. top: 37px;
  401. z-index: 2;
  402. overflow-y: auto;
  403. }
  404. .el-form-item{
  405. margin-bottom: 22px;
  406. &.min-margin{
  407. margin-bottom: 0;
  408. }
  409. }
  410. .el-form-item__error{
  411. top: auto;
  412. white-space: nowrap;
  413. }
  414. .el-input-number{
  415. width: 95px;
  416. }
  417. .el-input-number.is-controls-right .el-input-number__decrease, .el-input-number.is-controls-right .el-input-number__increase{
  418. width: 25px;
  419. height: 15px;
  420. line-height: 16px;
  421. }
  422. }
  423. </style>