SubConditions.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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.trim="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&&showDataType" 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="3">
  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="3">
  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="3">
  79. <el-form-item prop="subMaxUnit">
  80. <el-input type="text" v-model.trim="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="3">
  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="3">
  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="3">
  107. <el-form-item prop="subMinUnit">
  108. <el-input type="text" v-model.trim="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 is-required">
  114. <el-input type="textarea" rows="3" placeholder="请输入医学内容" v-model.trim="groupData.subEqValue"></el-input>
  115. </el-form-item>
  116. <el-form-item v-if="groupData.subType===6" label="正则表达式:" prop="subEqValue" class="discDesc is-required">
  117. <el-input type="textarea" rows="3" placeholder="请输入正则表达式" v-model.trim="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. numTypes:'', //只有数值类型的类型id
  136. operMaxList:[
  137. {name:'<=',key:'<='},
  138. {name:'<',key:'<'},
  139. ],
  140. operMinList:[{name:'>',key:'>'},
  141. {name:'>=',key:'>='},
  142. ],
  143. dataTypes:[{id:'1',name:'数值类型'},{id:'2',name:'文本类型'}],
  144. conceptList:[],
  145. rules:{
  146. subDescription:[{ required: true, message: '请输入基础规则名称',trigger: ['blur'] },{
  147. validator: (rule,value,callback)=>{
  148. if(value&&value.length>100){
  149. callback(new Error('规则名称不能超过100字'));
  150. }else{
  151. callback();
  152. }}, trigger: 'change'
  153. }],
  154. subType:[{ required: true, message: '请选择基础规则类型',trigger: ['change'] }],
  155. subLenCode:[{ required: true, message: '请选择基础规则术语类型',trigger: ['change'] }],
  156. subConceptId:[{ required: true, message: '请输入医学标准术语',trigger: ['blur'] }],
  157. dataType:[{ required: true, message: '请选择类型',trigger: ['change'] }],
  158. subMaxOperator:[{
  159. validator: (rule,value,callback)=>{
  160. const {subMaxValue,subMinOperator,subMinValue}=this.groupData;
  161. const val=value+subMinOperator+subMinValue+subMaxValue;
  162. if(!val||(!value&&subMaxValue!=='')){
  163. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  164. }else{
  165. callback();
  166. }}, trigger: 'blur'
  167. }],
  168. subMinOperator:[{
  169. validator: (rule,value,callback)=>{
  170. const {subMaxValue,subMaxOperator,subMinValue}=this.groupData;
  171. const val=value+subMaxOperator+subMinValue+subMaxValue;
  172. if(!val||(!value&&subMinValue!=='')){
  173. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  174. }else{
  175. callback();
  176. }}, trigger: 'blur'
  177. }],
  178. subMaxValue:[{
  179. validator: (rule,value,callback)=>{
  180. const {subMaxOperator,subMinOperator,subMinValue}=this.groupData;
  181. const val=value+subMaxOperator+subMinValue+subMinOperator;
  182. const isNum=/^(\-|\+)?\d+(\.\d+)?$/.test(value);
  183. if(!val||(value==''&&subMaxOperator)){
  184. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  185. }else if(value!==''&&!isNum){
  186. callback(new Error('只能输入数字'));
  187. }else{
  188. callback();
  189. }}, trigger: 'blur'
  190. }],
  191. subMinValue:[{
  192. validator: (rule,value,callback)=>{
  193. const {subMaxValue,subMinOperator,subMaxOperator}=this.groupData;
  194. const val=value+subMaxOperator+subMaxValue+subMinOperator;
  195. const isNum=/^(\-|\+)?\d+(\.\d+)?$/.test(value);
  196. if(!val||(value==''&&subMinOperator)){
  197. callback(new Error('最大值和最小值至少完整填写一个,单位不必填'));
  198. }else if(value!==''&&!isNum){
  199. callback(new Error('只能输入数字'));
  200. }else{
  201. callback();
  202. }}, trigger: 'blur'
  203. }],
  204. subEqValue:[{
  205. validator: (rule,value,callback)=>{
  206. if(value===''){
  207. callback(new Error('请输入'+this.textName));
  208. }else if(value.length>200){
  209. callback(new Error(this.textName+'不能超过200字'));
  210. }else{
  211. callback();
  212. }}, trigger: 'blur'
  213. }],
  214. },
  215. }
  216. },
  217. watch:{
  218. 'groupData':{
  219. handler:function(val){
  220. this.$emit("changeVal",val,this.ind);
  221. },
  222. deep:true
  223. },
  224. /*'baseTypes':{
  225. handler:function(val){
  226. if(!this.groupData.subType){
  227. this.baseTermTypeList =[];
  228. return;
  229. }
  230. const obj = val.find((it)=>it.type===this.groupData.subType);
  231. this.baseTermTypeList = obj.subMenuList;
  232. },
  233. deep:true
  234. },*/
  235. 'firstPlace':{
  236. handler:function(val) {
  237. if (this.ind!==0||!val) return;
  238. const dict = localStorage.getItem("zskDicts").match(new RegExp(val.checkedType+'-\\d+','g'))||[];
  239. const types = dict[0].split("-");
  240. this.groupData.subType = +types[2];
  241. this.groupData.subLenCode = types[1];
  242. this.conceptList = [val];
  243. this.groupData.subDescription = val.conceptName;
  244. this.groupData.subConceptId = val.conceptId;
  245. this.groupData.subConceptName = val.conceptName;
  246. },
  247. deep:true
  248. }
  249. },
  250. created(){
  251. this.numTypes = localStorage.getItem("zskNumDict");
  252. this.conceptList=[{conceptName:this.groupData.subLibName||this.groupData.subConceptName,conceptId:this.groupData.subConceptId}];
  253. },
  254. computed:{
  255. baseTermTypeList:function(){
  256. if(!this.baseTypes.length){
  257. return [];
  258. }
  259. const sub = this.baseTypes.find((it) => it.type === this.groupData.subType)||{};
  260. return sub.subMenuList;
  261. },
  262. showDataType:function(){
  263. return (this.numTypes+',').indexOf(this.groupData.subLenCode+',')===-1;
  264. },
  265. textName:function(){
  266. return this.groupData.subType!==6&&this.groupData.dataType==='2'?'医学内容':'正则表达式';
  267. }
  268. },
  269. methods:{
  270. dataTypeChange(val){
  271. this.groupData.subEqOperator=(val==='2'?'=':'');
  272. this.clearNumText();
  273. delete this.groupData.dataType; //触发更新
  274. this.$set(this.groupData,'dataType',val);
  275. },
  276. subTypeChange(val){ //基础规则类型修改
  277. this.groupData.subLenCode='';
  278. this.groupData.dataType='';
  279. this.clearConcept();
  280. this.clearNumText();
  281. },
  282. subCodeChange(val){ //基础规则术语类型修改
  283. this.groupData.subLenCode=val;
  284. if((this.numTypes+',').indexOf(val+',')>-1){
  285. this.groupData.dataType='1';
  286. }else{
  287. this.groupData.dataType='';
  288. }
  289. this.clearConcept();
  290. this.clearNumText();
  291. },
  292. clearConcept(){
  293. this.groupData.subConceptId='';
  294. this.conceptList=[];
  295. },
  296. clearNumText(){
  297. this.groupData.subMaxOperator='';
  298. this.groupData.subMaxValue='';
  299. this.groupData.subMaxUnit='';
  300. this.groupData.subMinOperator='';
  301. this.groupData.subMinValue='';
  302. this.groupData.subMinUnit='';
  303. this.groupData.subEqValue='';
  304. this.groupData.subEqOperator='';
  305. },
  306. searchConcept(val){
  307. const param = {
  308. excludedConceptIds:[this.groupData.subType],
  309. libType:this.groupData.subLenCode,
  310. name:val,
  311. };
  312. api.searchConcept(param).then((res) => {
  313. if (res.data.code == '0') {
  314. const data = res.data.data;
  315. this.conceptList = data;
  316. }
  317. }).catch((error) => {
  318. console.log(error);
  319. });
  320. },
  321. addRule(){
  322. this.$emit("addRule");
  323. },
  324. delRule(){
  325. if(this.isLast){
  326. this.warning("初始状态规则不能删除~");
  327. return;
  328. }
  329. //this.showConfirmDialog("是否删除该条规则,可能对现有系统会造成影响",()=>{
  330. this.$emit("delRule",this.ind);
  331. //});
  332. },
  333. warning(msg,type){
  334. this.$message({
  335. showClose: true,
  336. message:msg,
  337. type:type||'warning'
  338. })
  339. },
  340. showConfirmDialog(msg,resolve){
  341. this.$alert(msg, '提示', {
  342. confirmButtonText: '确定',
  343. type: 'warning'
  344. }).then(() => {
  345. resolve();
  346. }).catch(() => {});
  347. },
  348. }
  349. }
  350. </script>
  351. <style lang="less">
  352. .groups-cont{
  353. background: #fff;
  354. .conceptItem{
  355. padding: 0 10px;
  356. cursor: pointer;
  357. height: 32px;
  358. line-height: 32px;
  359. &:hover{
  360. background: #ebedf1;
  361. }
  362. }
  363. .inner-oper{
  364. padding: 15px 0 15px 21px;
  365. .add-btn {
  366. cursor: pointer;
  367. img {
  368. vertical-align: middle;
  369. }
  370. }
  371. }
  372. .sub-condition-form{
  373. padding: 20px;
  374. position: relative;
  375. border-bottom:2px solid #F5F5F5;
  376. .del-btn{
  377. color: #FF5B5B;
  378. cursor: pointer;
  379. position: absolute;
  380. right: 20px;
  381. top:20px;
  382. z-index: 1;
  383. &.disable{
  384. color: #B8B8B8;
  385. }
  386. }
  387. }
  388. .el-input__icon{
  389. line-height: 32px;
  390. }
  391. .select-item{
  392. &>div{
  393. float: left;
  394. margin-right: 10px;
  395. }
  396. .el-input{
  397. width: auto;
  398. }
  399. input{
  400. width: 95px;
  401. line-height: 32px;
  402. height: 32px;
  403. }
  404. }
  405. .el-input,.el-input__inner{
  406. width: 190px;
  407. line-height: 32px;
  408. height: 32px;
  409. }
  410. .el-button--danger.is-plain{
  411. background: none;
  412. }
  413. .itemList {
  414. position: absolute;
  415. // display: none;
  416. background: #fff;
  417. width: 188px;
  418. max-height: 160px;
  419. border: 1px solid #DCDFE6;
  420. left: 0;
  421. top: 37px;
  422. z-index: 2;
  423. overflow-y: auto;
  424. }
  425. .el-form-item{
  426. margin-bottom: 22px;
  427. &.min-margin{
  428. margin-bottom: 0;
  429. }
  430. }
  431. .el-form-item__error{
  432. top: auto;
  433. white-space: nowrap;
  434. background: #fff;
  435. }
  436. .el-input-number{
  437. width: 95px;
  438. }
  439. .el-input-number.is-controls-right .el-input-number__decrease, .el-input-number.is-controls-right .el-input-number__increase{
  440. width: 25px;
  441. height: 15px;
  442. line-height: 16px;
  443. }
  444. .el-col-3 {
  445. width: 94px;
  446. }
  447. }
  448. </style>