RuleManager.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <div>
  3. <crumbs title="规则维护" :minWidth="titleWidth" class="knowledgeTitle">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="规则名称:">
  6. <el-input size="mini" v-model="filter.parDescription" placeholder="输入规则名称" clearable></el-input>
  7. </el-form-item>
  8. <el-form-item label="规则类型:">
  9. <el-select v-model="filter.parRuleType" clearable placeholder="请选择" size="mini">
  10. <el-option
  11. v-for="item in ruleTypeList"
  12. :key="item.id"
  13. :label="item.name"
  14. :value="item.id">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="医学标准术语:">
  19. <el-input size="mini" v-model="filter.parConceptName" placeholder="输入医学标准术语" clearable></el-input>
  20. </el-form-item>
  21. <el-form-item label="状态:">
  22. <el-select v-model="filter.parStatus" clearable placeholder="请选择" size="mini">
  23. <el-option
  24. v-for="item in stateSelect"
  25. :key="item.id"
  26. :label="item.name"
  27. :value="item.id">
  28. </el-option>
  29. </el-select>
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button size="mini" @click="filterDatas">确认</el-button>
  33. </el-form-item>
  34. </el-form>
  35. <el-form class="secLine">
  36. <el-form-item>
  37. <el-button size="mini" @click="addRule" type="warning" style="margin:0 10px">+ 新增规则</el-button>
  38. <el-button size="mini" @click="update">更新数据</el-button>
  39. </el-form-item>
  40. </el-form>
  41. </crumbs>
  42. <div class="contents knowledgeContents">
  43. <el-table :data="list"
  44. border
  45. style="width: 100%">
  46. <el-table-column
  47. type="index"
  48. :index="indexMethod"
  49. label="编号"
  50. width="60">
  51. </el-table-column>
  52. <el-table-column
  53. prop="parDescription"
  54. label="规则名称"
  55. width="160">
  56. <template slot-scope="scope">
  57. <el-tooltip v-if="scope.row.parDescription.length>8" class="item" effect="dark" :content="scope.row.parDescription" placement="top">
  58. <span>{{scope.row.parDescription.slice(0,8)+'...'}}</span>
  59. </el-tooltip>
  60. <span v-if="scope.row.parDescription.length<9">{{scope.row.parDescription}}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column
  64. prop="parRuleType"
  65. label="规则类型"
  66. width="150">
  67. <template slot-scope="scope">
  68. {{statusTrans(scope.row.parRuleType)}}
  69. </template>
  70. </el-table-column>
  71. <el-table-column
  72. prop="parConceptName"
  73. label="医学标准术语"
  74. width="160">
  75. <template slot-scope="scope">
  76. <el-tooltip v-if="scope.row.parConceptName.length>8" class="item" effect="dark" :content="scope.row.parConceptName" placement="top">
  77. <span>{{scope.row.parConceptName.slice(0,8)+'...'}}</span>
  78. </el-tooltip>
  79. <span v-if="scope.row.parConceptName.length<9">{{scope.row.parConceptName}}</span>
  80. </template>
  81. </el-table-column>
  82. <el-table-column
  83. prop="parLibTypeName"
  84. label="术语类型"
  85. width="150">
  86. </el-table-column>
  87. <el-table-column
  88. prop="parHasSub"
  89. label="有无子条件"
  90. width="100">
  91. <template slot-scope="scope">
  92. {{scope.row.parHasSub == '0'?'无':'有'}}
  93. </template>
  94. </el-table-column>
  95. <el-table-column
  96. label="状态">
  97. <template slot-scope="scope">
  98. <span>
  99. {{scope.row.parStatus === 0?'禁用':'启用'}}
  100. </span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column
  104. prop="modifierName"
  105. label="操作人">
  106. <template slot-scope="scope">
  107. <el-tooltip v-if="scope.row.modifierName&&scope.row.modifierName.length>8" class="item" effect="dark" :content="scope.row.modifierName" placement="top">
  108. <span>{{(scope.row.modifierName||'').slice(0,8)+'...'}}</span>
  109. </el-tooltip>
  110. <span v-if="scope.row.modifierName&&scope.row.modifierName.length<9">{{scope.row.modifierName}}</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column
  114. prop="gmtModified"
  115. label="操作时间"
  116. width="180">
  117. </el-table-column>
  118. <el-table-column
  119. label="操作"
  120. width="180" fixed="right">
  121. <template slot-scope="scope">
  122. <el-button type="text" size="small" @click="editData(scope.row.parId)">修改</el-button>
  123. <span style="margin:0 3px;">|</span>
  124. <el-button type="text" size="small" @click="editData(scope.row.parId,true)">复制</el-button>
  125. <span style="margin:0 3px;">|</span>
  126. <el-button type="text" size="small" :class="scope.row.parStatus === 0?'':'unvailable'" @click="showDelDialog(scope.row)">{{scope.row.parStatus === 0?'启用':'禁用'}}</el-button>
  127. <span style="margin:0 3px;">|</span>
  128. <el-button type="text" size="small" class="delete" @click="showDelDialog(scope.row,1)">删除</el-button>
  129. </template>
  130. </el-table-column>
  131. </el-table>
  132. <el-pagination :current-page.sync="currentPage"
  133. @current-change="currentChange"
  134. background
  135. :page-size="pageSize"
  136. :page-sizes="pageSizeArr"
  137. @size-change="handleSizeChange"
  138. :layout="pageLayout"
  139. :total="total">
  140. </el-pagination>
  141. </div>
  142. </div>
  143. </template>
  144. <script>
  145. import api from '@api/knowledgeLib.js';
  146. import config from '@api/config.js';
  147. import utils from '@api/utils.js';
  148. export default {
  149. name: 'ZskRuleManager',
  150. data: function () {
  151. return {
  152. list: [],
  153. stateSelect:[
  154. {id:1,name:'启用'},
  155. {id:0,name:'禁用'},
  156. ],
  157. ruleTypeList:[],
  158. searched: false,
  159. filter:{
  160. parStatus:'',
  161. parDescription:'',
  162. parConceptName:'',
  163. parRuleType:'',
  164. },
  165. cacheData: {},
  166. currentPage: 1,
  167. pageSize: config.pageSize,
  168. pageSizeArr:config.pageSizeArr,
  169. pageLayout:config.pageLayout,
  170. total: 0,
  171. titleWidth:'970px' //头部最小宽度
  172. }
  173. },
  174. created() {
  175. const param = this.$route.params;
  176. if(param.currentPage){
  177. this.inCurrentPage = param.currentPage
  178. this.filter = param.filter
  179. }
  180. this.getTypeList();
  181. const that = this;
  182. //返回时避免参数未赋值就获取列表
  183. setTimeout(function(){
  184. that.getDataList();
  185. });
  186. this.getDict();
  187. },
  188. watch: {
  189. 'filter': {
  190. handler: function () {
  191. this.searched = false;
  192. },
  193. deep: true
  194. }
  195. },
  196. // beforeRouteEnter(to, from, next) {
  197. // next(vm => {
  198. // //const pm = to.param;
  199. // Object.assign(vm, to.params);
  200. // vm.inCurrentPage=to.params.currentPage;
  201. // })
  202. // },
  203. methods: {
  204. getDict(){
  205. api.zskgetDict().then((res) => {
  206. if (res.data.code == '0') {
  207. const data = res.data.data;
  208. const arr =data['20'].map((it)=>it.val);
  209. //this.dict = arr.join(",");
  210. //this.msgDict=(data['21'].map((it)=>it.val)||[]).join(",");
  211. localStorage.setItem("zskDicts",arr.join(","));
  212. localStorage.setItem("zskMsgDict",(data['21'].map((it)=>it.val)||[]).join(","));
  213. localStorage.setItem("zskNumDict",data['22'][0].val);
  214. localStorage.setItem("zskSubDict",data['23'][0].val);
  215. }
  216. }).catch((error) => {
  217. console.log(error);
  218. });
  219. },
  220. statusTrans(type){
  221. const obj = this.ruleTypeList.find((it)=>it.type===type);
  222. return obj&&obj.name;
  223. },
  224. getTypeList(){
  225. const typeListData = JSON.parse(localStorage.getItem("zskTypesList"));
  226. if(typeListData){
  227. this.ruleTypeList = typeListData;
  228. return;
  229. }
  230. api.getTypesList({planCode:'rule'}).then((res) => {
  231. if (res.data.code == '0') {
  232. const data = res.data.data;
  233. this.ruleTypeList = data;
  234. localStorage.setItem("zskTypesList",JSON.stringify(data));
  235. }
  236. }).catch((error) => {
  237. console.log(error);
  238. });
  239. },
  240. handleSizeChange(val){
  241. this.pageSize = val;
  242. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  243. this.getDataList();
  244. },
  245. addRule(){
  246. const pam = this.searched ? {
  247. currentPage: this.currentPage,
  248. pageSize:this.pageSize,
  249. filter: this.filter
  250. } : {currentPage: this.currentPage,
  251. pageSize:this.pageSize};
  252. this.$router.push({name: 'AddZskRule', params: pam});
  253. },
  254. filterDatas(){
  255. this.currentPage = 1;
  256. this.getDataList(1);
  257. },
  258. getDataList(flag,isTurnPage) {
  259. const params = this.getFilterItems(isTurnPage);
  260. this.searched = true;
  261. const loading = this.$loading({
  262. lock: true,
  263. text: 'Loading',
  264. spinner: 'el-icon-loading',
  265. background: 'rgba(0, 0, 0, 0.7)'
  266. });
  267. api.getRulesList(params).then((res) => {
  268. loading.close();
  269. if (res.data.code == '0') {
  270. const data = res.data.data;
  271. for(let j = 0;j < data.records.length;j++){
  272. data.records[j].condition = (data.records[j].parStatus == '1'?'启用':'禁用')
  273. }
  274. this.list = data.records;
  275. if(!flag){//搜索时不缓存
  276. this.cacheData[params.current] = data.records;
  277. }else{
  278. this.cacheData = {}
  279. }
  280. this.total = data.total;
  281. if(this.inCurrentPage!==undefined){
  282. this.currentPage=this.inCurrentPage;
  283. this.inCurrentPage = undefined;
  284. }
  285. }else{
  286. this.warning(res.data.msg||'获取列表数据失败');
  287. }
  288. }).catch((error) => {
  289. loading.close();
  290. console.log(error);
  291. });
  292. },
  293. getFilterItems(isTurnPage) {
  294. //翻页时筛选条件没点确定则清空
  295. if(isTurnPage&&!this.searched){
  296. this.clearFilter();
  297. };
  298. const param = {
  299. current: this.inCurrentPage||this.currentPage,
  300. size: this.pageSize,
  301. parRuleType: this.filter.parRuleType,
  302. parDescription: this.filter.parDescription.trim(),
  303. parConceptName: this.filter.parConceptName.trim(),
  304. parStatus:this.filter.parStatus
  305. };
  306. return param;
  307. },
  308. indexMethod(index) {
  309. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  310. },
  311. currentChange(next) {
  312. this.currentPage = next;
  313. /*if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  314. this.list = this.cacheData[next];
  315. } else {*/
  316. this.getDataList(1,true);
  317. //}
  318. },
  319. warning(msg,type){
  320. this.$message({
  321. showClose: true,
  322. message:msg,
  323. type:type||'warning'
  324. })
  325. },
  326. showConfirmDialog(msg,resolve){
  327. this.$alert(msg, '提示', {
  328. confirmButtonText: '确定',
  329. type: 'warning'
  330. }).then(() => {
  331. resolve();
  332. }).catch(() => {});
  333. },
  334. editData(id,isCopy){
  335. const pam = this.searched ? {
  336. currentPage: this.currentPage,
  337. pageSize:this.pageSize,
  338. filter: this.filter
  339. } : {currentPage: this.currentPage,
  340. pageSize:this.pageSize};
  341. api.ruleDetail({id}).then((res) => {
  342. if (res.data.code == '0') {
  343. const data = res.data.data;
  344. this.$router.push({name:'AddZskRule',params:{...pam,data,copy:isCopy}});
  345. }
  346. }).catch((error) => {
  347. this.warning('获取详情失败,请重试')
  348. });
  349. },
  350. showDelDialog(row,isDelete){
  351. const params = {
  352. id:row.parId
  353. };
  354. const txt=row.parStatus===0?'重新启用':'禁用';
  355. const warningTxt = isDelete?'是否删除该规则?可能对现有系统造成影响':'是否'+txt+'该条数据?';
  356. const handleFn = isDelete?api.deleteRule:(row.parStatus===0?api.saveRuleApply:api.deleteRuleApply);
  357. this.showConfirmDialog(warningTxt,()=>{
  358. handleFn(params).then((res)=>{
  359. if(res.data.code=='0'){
  360. if(!this.searched){
  361. //未点确认时清空搜索条件
  362. this.clearFilter();
  363. }
  364. if(isDelete){ //恢复成功后跳转到筛选条件的首页
  365. this.currentPage = 1;
  366. } else {
  367. if (this.filter.parStatus!==''&&this.list.length === 1){
  368. //有启用状态筛选条件且当前页只有最后一条数据删除时,删除成功后跳转到前一页
  369. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  370. }
  371. }
  372. this.warning(res.data.msg||'操作成功','success');
  373. this.getDataList();
  374. }else{
  375. this.warning(res.data.msg);
  376. }
  377. }).catch((error)=>{
  378. this.warning(error);
  379. })
  380. });
  381. },
  382. clearFilter(){
  383. this.filter={
  384. parStatus:'',
  385. parConceptName:'',
  386. parDescription:'',
  387. parRuleType:'',
  388. };
  389. },
  390. update(){
  391. const loading = this.$loading({
  392. lock: true,
  393. text: 'Loading',
  394. spinner: 'el-icon-loading',
  395. background: 'rgba(0, 0, 0, 0.7)'
  396. });
  397. api.zskUpdateAll().then((res) => {
  398. loading.close();
  399. if (res.data.code == '0') {
  400. this.warning('更新成功','success');
  401. this.getDataList();
  402. }else{
  403. this.warning(res.data.msg||'更新失败,请重试');
  404. }
  405. }).catch((error) => {
  406. loading.close();
  407. this.warning('更新失败,请重试')
  408. });
  409. },
  410. }
  411. }
  412. </script>
  413. <style lang="less" scoped>
  414. @import "../../less/admin.less";
  415. /deep/ .container.knowledgeTitle {
  416. height: 80px;
  417. }
  418. /deep/ .contents.knowledgeContents {
  419. padding: 104px 20px 0;
  420. }
  421. /deep/ .secLine.el-form {
  422. float: right;
  423. display: block;
  424. position: relative;
  425. top: -5px;
  426. }
  427. .delete{
  428. color: red;
  429. }
  430. .review{
  431. color: #22ccc8;
  432. }
  433. .el-table .cell{
  434. overflow: hidden;
  435. white-space: nowrap;
  436. }
  437. #upFile{
  438. display: none !important;
  439. }
  440. .unvailable{
  441. color: #FE7D3D;
  442. &:hover{
  443. color: #f19061;
  444. }
  445. }
  446. </style>