RuleManager.vue 15 KB

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