RuleManager.vue 15 KB

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