RuleManager.vue 15 KB

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