RuleManager.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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. }
  204. })
  205. .catch(error => {
  206. console.log(error);
  207. });
  208. },
  209. statusTrans(type) {
  210. const obj = this.ruleTypeList.find(it => it.type === type);
  211. return obj && obj.name;
  212. },
  213. getTypeList() {
  214. api
  215. .getTypesList({ planCode: 'rule'})
  216. .then(res => {
  217. if (res.data.code == '0') {
  218. const data = res.data.data;
  219. this.ruleTypeList = data;
  220. localStorage.setItem('zskTypesList', JSON.stringify(data));
  221. }
  222. })
  223. .catch(error => {
  224. console.log(error);
  225. });
  226. },
  227. handleSizeChange(val) {
  228. this.pageSize = val;
  229. this.currentPage = utils.getCurrentPage(
  230. this.currentPage,
  231. this.total,
  232. this.pageSize
  233. );
  234. this.getDataList();
  235. },
  236. addRule() {
  237. const pam = this.searched
  238. ? {
  239. currentPage: this.currentPage,
  240. pageSize: this.pageSize,
  241. filter: this.filter
  242. }
  243. : { currentPage: this.currentPage, pageSize: this.pageSize };
  244. this.$router.push({ name: 'AddZskRule', params: pam });
  245. },
  246. filterDatas() {
  247. this.currentPage = 1;
  248. this.getDataList(1);
  249. },
  250. getDataList(flag, isTurnPage) {
  251. const params = this.getFilterItems(isTurnPage);
  252. this.searched = true;
  253. const loading = this.$loading({
  254. lock: true,
  255. text: 'Loading',
  256. spinner: 'el-icon-loading',
  257. background: 'rgba(0, 0, 0, 0.7)'
  258. });
  259. api
  260. .getRulesList(params)
  261. .then(res => {
  262. loading.close();
  263. if (res.data.code == '0') {
  264. const data = res.data.data;
  265. for (let j = 0; j < data.records.length; j++) {
  266. data.records[j].condition =
  267. data.records[j].parStatus == '1' ? '启用' : '禁用';
  268. }
  269. this.list = data.records;
  270. if (!flag) {
  271. //搜索时不缓存
  272. this.cacheData[params.current] = data.records;
  273. } else {
  274. this.cacheData = {};
  275. }
  276. this.total = data.total;
  277. if (this.inCurrentPage !== undefined) {
  278. this.currentPage = this.inCurrentPage;
  279. this.inCurrentPage = undefined;
  280. }
  281. } else {
  282. this.warning(res.data.msg || '获取列表数据失败');
  283. }
  284. })
  285. .catch(error => {
  286. loading.close();
  287. console.log(error);
  288. });
  289. },
  290. getFilterItems(isTurnPage) {
  291. //翻页时筛选条件没点确定则清空
  292. if (isTurnPage && !this.searched) {
  293. this.clearFilter();
  294. }
  295. const param = {
  296. current: this.inCurrentPage || this.currentPage,
  297. size: this.pageSize,
  298. parRuleType: this.filter.parRuleType,
  299. parDescription: this.filter.parDescription.trim(),
  300. parConceptName: this.filter.parConceptName.trim(),
  301. parStatus: this.filter.parStatus
  302. };
  303. return param;
  304. },
  305. indexMethod(index) {
  306. return (this.currentPage - 1) * this.pageSize + index + 1;
  307. },
  308. currentChange(next) {
  309. this.currentPage = next;
  310. /*if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  311. this.list = this.cacheData[next];
  312. } else {*/
  313. this.getDataList(1, true);
  314. //}
  315. },
  316. warning(msg, type) {
  317. this.$message({
  318. showClose: true,
  319. message: msg,
  320. type: type || 'warning'
  321. });
  322. },
  323. showConfirmDialog(msg, resolve) {
  324. this.$alert(msg, '提示', {
  325. confirmButtonText: '确定',
  326. type: 'warning'
  327. })
  328. .then(() => {
  329. resolve();
  330. })
  331. .catch(() => {});
  332. },
  333. editData(id, isCopy) {
  334. this.sign = 2
  335. this.getTypeList()
  336. const pam = this.searched
  337. ? {
  338. currentPage: this.currentPage,
  339. pageSize: this.pageSize,
  340. filter: this.filter
  341. }
  342. : { currentPage: this.currentPage, pageSize: this.pageSize };
  343. api
  344. .ruleDetail({ id })
  345. .then(res => {
  346. if (res.data.code == '0') {
  347. const data = res.data.data;
  348. this.$router.push({
  349. name: 'AddZskRule',
  350. params: { ...pam, data, copy: isCopy }
  351. });
  352. }
  353. })
  354. .catch(error => {
  355. this.warning('获取详情失败,请重试');
  356. });
  357. },
  358. showDelDialog(row, isDelete) {
  359. const params = {
  360. id: row.parId
  361. };
  362. const txt = row.parStatus === 0 ? '重新启用' : '禁用';
  363. const warningTxt = isDelete
  364. ? '是否删除该规则?可能对现有系统造成影响'
  365. : '是否' + txt + '该条数据?';
  366. const handleFn = isDelete
  367. ? api.deleteRule
  368. : row.parStatus === 0
  369. ? api.saveRuleApply
  370. : api.deleteRuleApply;
  371. this.showConfirmDialog(warningTxt, () => {
  372. handleFn(params)
  373. .then(res => {
  374. if (res.data.code == '0') {
  375. if (!this.searched) {
  376. //未点确认时清空搜索条件
  377. this.clearFilter();
  378. }
  379. if (isDelete) {
  380. //恢复成功后跳转到筛选条件的首页
  381. this.currentPage = 1;
  382. } else {
  383. if (this.filter.parStatus !== '' && this.list.length === 1) {
  384. //有启用状态筛选条件且当前页只有最后一条数据删除时,删除成功后跳转到前一页
  385. this.currentPage =
  386. this.currentPage === 1 ? 1 : this.currentPage - 1;
  387. }
  388. }
  389. this.warning(res.data.msg || '操作成功', 'success');
  390. this.getDataList();
  391. } else {
  392. this.warning(res.data.msg);
  393. }
  394. })
  395. .catch(error => {
  396. this.warning(error);
  397. });
  398. });
  399. },
  400. clearFilter() {
  401. this.filter = {
  402. parStatus: '',
  403. parConceptName: '',
  404. parDescription: '',
  405. parRuleType: ''
  406. };
  407. },
  408. update() {
  409. const loading = this.$loading({
  410. lock: true,
  411. text: 'Loading',
  412. spinner: 'el-icon-loading',
  413. background: 'rgba(0, 0, 0, 0.7)'
  414. });
  415. api
  416. .zskUpdateAll()
  417. .then(res => {
  418. loading.close();
  419. if (res.data.code == '0') {
  420. this.warning('更新成功', 'success');
  421. this.getDataList();
  422. } else {
  423. this.warning(res.data.msg || '更新失败,请重试');
  424. }
  425. })
  426. .catch(error => {
  427. loading.close();
  428. this.warning('更新失败,请重试');
  429. });
  430. }
  431. }
  432. };
  433. </script>
  434. <style lang="less" scoped>
  435. @import '../../less/admin.less';
  436. /deep/ .container.knowledgeTitle {
  437. height: 80px;
  438. }
  439. /deep/ .contents.knowledgeContents {
  440. padding: 104px 20px 0;
  441. }
  442. /deep/ .secLine.el-form {
  443. float: right;
  444. display: block;
  445. position: relative;
  446. top: -5px;
  447. }
  448. .delete {
  449. color: red;
  450. }
  451. .review {
  452. color: #22ccc8;
  453. }
  454. .el-table .cell {
  455. overflow: hidden;
  456. white-space: nowrap;
  457. }
  458. #upFile {
  459. display: none !important;
  460. }
  461. .unvailable {
  462. color: #fe7d3d;
  463. &:hover {
  464. color: #f19061;
  465. }
  466. }
  467. </style>