RuleManager.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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.ruleName" placeholder="输入规则名称"></el-input>
  7. </el-form-item>
  8. <el-form-item label="规则类型:">
  9. <el-select v-model="filter.type" clearable placeholder="请选择" size="mini">
  10. <el-option
  11. v-for="item in typeList"
  12. :key="item.key"
  13. :label="item.name"
  14. :value="item.key">
  15. </el-option>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="术语名称:">
  19. <el-input size="mini" v-model="filter.termName" placeholder="输入术语名称"></el-input>
  20. </el-form-item>
  21. <el-form-item label="状态:">
  22. <el-select v-model="filter.isState" 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. <input type="file" name="uploadfile " id="upFile" @change="uploadFile($event)" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
  39. <el-button size="mini" @click="uploadClick">加载词库</el-button>
  40. </el-form-item>
  41. </el-form>
  42. </crumbs>
  43. <div class="contents knowledgeContents">
  44. <el-table :data="list"
  45. border
  46. style="width: 100%">
  47. <el-table-column
  48. type="index"
  49. :index="indexMethod"
  50. label="编号"
  51. width="60">
  52. </el-table-column>
  53. <el-table-column
  54. prop="ruleName"
  55. label="规则名称">
  56. </el-table-column>
  57. <el-table-column
  58. prop="ruleType"
  59. label="规则类型">
  60. </el-table-column>
  61. <el-table-column
  62. prop="conceptName"
  63. label="术语名称">
  64. </el-table-column>
  65. <el-table-column
  66. prop="libTypeName"
  67. label="医学标准术语"
  68. width="160">
  69. </el-table-column>
  70. <el-table-column
  71. prop="hasSubCond"
  72. label="有无子条件"
  73. width="100">
  74. <template slot-scope="scope">
  75. {{scope.row.hasSubCond === '0'?'无':'有'}}
  76. </template>
  77. </el-table-column>
  78. <el-table-column
  79. prop="msg"
  80. label="附加信息"
  81. width="160">
  82. </el-table-column>
  83. <el-table-column
  84. label="状态">
  85. <template slot-scope="scope">
  86. <span>
  87. {{scope.row.status === '0'?'禁用':'启用'}}
  88. </span>
  89. </template>
  90. </el-table-column>
  91. <el-table-column
  92. prop="modifier"
  93. label="操作人">
  94. </el-table-column>
  95. <el-table-column
  96. prop="gmtModified"
  97. label="操作时间"
  98. width="150">
  99. </el-table-column>
  100. <el-table-column
  101. label="操作"
  102. width="180">
  103. <template slot-scope="scope">
  104. <el-button type="text" size="small" @click="editData(scope.row)">修改</el-button>
  105. <span style="margin:0 3px;">|</span>
  106. <el-button type="text" size="small" @click="copyData(scope.row)">复制</el-button>
  107. <span style="margin:0 3px;">|</span>
  108. <el-button type="text" size="small" :class="scope.row.status === '0'?'':'delete'" @click="showDelDialog(scope.row)">{{scope.row.status === '0'?'启用':'禁用'}}</el-button>
  109. <span style="margin:0 3px;">|</span>
  110. <el-button type="text" size="small" class="delete" @click="showDelDialog(scope.row)">删除</el-button>
  111. </template>
  112. </el-table-column>
  113. </el-table>
  114. <el-pagination :current-page.sync="currentPage"
  115. @current-change="currentChange"
  116. background
  117. :page-size="pageSize"
  118. :page-sizes="pageSizeArr"
  119. @size-change="handleSizeChange"
  120. :layout="pageLayout"
  121. :total="total">
  122. </el-pagination>
  123. </div>
  124. </div>
  125. </template>
  126. <script>
  127. import api from '@api/knowledgeLib.js';
  128. import config from '@api/config.js';
  129. import utils from '@api/utils.js';
  130. export default {
  131. name: 'ZskRuleManager',
  132. data: function () {
  133. return {
  134. list: [],
  135. stateSelect:[
  136. {id:'1',name:'启用'},
  137. {id:'0',name:'禁用'},
  138. ],
  139. searched: false,
  140. filter:{
  141. isState:'',
  142. ruleName:'',
  143. termName:'',
  144. type:'',
  145. },
  146. cacheData: {},
  147. currentPage: 1,
  148. pageSize: config.pageSize,
  149. pageSizeArr:config.pageSizeArr,
  150. pageLayout:config.pageLayout,
  151. total: 0,
  152. typeList:[],
  153. titleWidth:'1070px' //头部最小宽度
  154. }
  155. },
  156. created() {
  157. const typeList = JSON.parse(localStorage.getItem("knowledgeEnumsData"));
  158. if(typeList){
  159. this.typeList = typeList.lexiconRSTypeEnum;
  160. }
  161. const that = this;
  162. //返回时避免参数未赋值就获取列表
  163. setTimeout(function(){
  164. that.getDataList();
  165. });
  166. },
  167. watch: {
  168. 'filter': {
  169. handler: function () {
  170. this.searched = false;
  171. },
  172. deep: true
  173. }
  174. },
  175. beforeRouteEnter(to, from, next) {
  176. next(vm => {
  177. //const pm = to.param;
  178. Object.assign(vm, to.params);
  179. vm.inCurrentPage=to.params.currentPage;
  180. })
  181. },
  182. methods: {
  183. handleSizeChange(val){
  184. this.pageSize = val;
  185. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  186. this.getDataList();
  187. },
  188. addRule(){
  189. const pam = this.searched ? {
  190. currentPage: this.currentPage,
  191. pageSize:this.pageSize,
  192. filter: this.filter
  193. } : {currentPage: this.currentPage,
  194. pageSize:this.pageSize};
  195. this.$router.push({name: 'AddZskRule', params: pam});
  196. },
  197. filterDatas(){
  198. this.currentPage = 1;
  199. this.getDataList(1);
  200. },
  201. getDataList(flag,isTurnPage) {
  202. const params = this.getFilterItems(isTurnPage);
  203. this.searched = true;
  204. const loading = this.$loading({
  205. lock: true,
  206. text: 'Loading',
  207. spinner: 'el-icon-loading',
  208. background: 'rgba(0, 0, 0, 0.7)'
  209. });loading.close()
  210. /*api.getRulesList(params).then((res) => {
  211. if (res.data.code == '0') {*/
  212. const data={pages:1,size: 10,total: 1,records:[{id:'0',gmtModified:'5001-220',modifier:'32',conceptName:'单独',description:"ee",ruleType:'1',hasSubCond:'1',status:'1',msg:'ff'}]};
  213. //const data = res.data.data;
  214. for(let j = 0;j < data.records.length;j++){
  215. data.records[j].condition = (data.records[j].isDeleted == '1'?'启用':'禁用')
  216. }
  217. this.list = data.records;
  218. if(!flag){//搜索时不缓存
  219. this.cacheData[params.current] = data.records;
  220. }else{
  221. this.cacheData = {}
  222. }
  223. this.total = data.total;
  224. if(this.inCurrentPage!==undefined){
  225. this.currentPage=this.inCurrentPage;
  226. this.inCurrentPage = undefined;
  227. }
  228. /* }
  229. }).catch((error) => {
  230. loading.close()
  231. console.log(error);
  232. });*/
  233. },
  234. getFilterItems(isTurnPage) {
  235. //翻页时筛选条件没点确定则清空
  236. if(isTurnPage&&!this.searched){
  237. this.clearFilter();
  238. };
  239. const param = {
  240. current: this.inCurrentPage||this.currentPage,
  241. size: this.pageSize,
  242. relationId: this.filter.type,
  243. startName: this.filter.ruleName.trim(),
  244. endName: this.filter.termName.trim(),
  245. isDeleted:this.filter.isState
  246. };
  247. return param;
  248. },
  249. indexMethod(index) {
  250. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  251. },
  252. currentChange(next) {
  253. this.currentPage = next;
  254. /*if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  255. this.list = this.cacheData[next];
  256. } else {*/
  257. this.getDataList(1,true);
  258. //}
  259. },
  260. warning(msg,type){
  261. this.$message({
  262. showClose: true,
  263. message:msg,
  264. type:type||'warning'
  265. })
  266. },
  267. showConfirmDialog(msg,resolve){
  268. this.$alert(msg, '提示', {
  269. confirmButtonText: '确定',
  270. type: 'warning'
  271. }).then(() => {
  272. resolve();
  273. }).catch(() => {});
  274. },
  275. copyData(){
  276. },
  277. editData(){
  278. },
  279. showDelDialog(item){
  280. const params = {
  281. id:item.id,
  282. isDeleted:item.isDeleted === 'N'?'Y':'N'
  283. }
  284. let warningTxt = item.isDeleted === 'N'?'是否删除该关系?可能对现有系统造成影响':'是否重新启用该条数据?'
  285. this.showConfirmDialog(warningTxt,()=>{
  286. api.delKnowledgeRelation(params).then((res)=>{
  287. if(res.data.code=='0'){
  288. if(!this.searched){
  289. //未点确认时清空搜索条件
  290. this.clearFilter();
  291. }
  292. if(item.isDeleted !== 'N'){ //恢复成功后跳转到筛选条件的首页
  293. this.currentPage = 1;
  294. } else {
  295. if (this.filter.isState!==''&&this.list.length === 1){
  296. //有启用状态筛选条件且当前页只有最后一条数据删除时,删除成功后跳转到前一页
  297. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  298. }
  299. }
  300. this.warning(res.data.msg||'操作成功','success');
  301. this.getDataList();
  302. }else{
  303. this.warning(res.data.msg);
  304. }
  305. }).catch((error)=>{
  306. this.warning(error);
  307. })
  308. });
  309. },
  310. clearFilter(){
  311. this.filter={
  312. isState:'',
  313. startName:'',
  314. endName:'',
  315. type:'',
  316. };
  317. },
  318. uploadClick(){
  319. let inp = document.getElementById("upFile");
  320. inp.click();
  321. },
  322. uploadFile(e){
  323. let fileInfo = e.target.files[0];
  324. e.preventDefault();
  325. let formData = new FormData();
  326. formData.append('uploadfile', fileInfo);
  327. const header = {
  328. headers:{
  329. 'Content-Type': 'multipart/form-data'
  330. }
  331. }
  332. api.RelationUpload(formData,header).then((res)=>{
  333. if(res.data.code==0){
  334. this.$message({
  335. message: '上传成功',
  336. type: 'success',
  337. });
  338. this.getDataList()
  339. }else{
  340. this.$alert(res.data.msg,'错误信息',{
  341. dangerouslyUseHTMLString: true,
  342. confirmButtonText: '确定',
  343. callback: action => {
  344. /*this.$message({
  345. type: 'info',
  346. message: `action: ${ action }`
  347. });*/
  348. }
  349. });
  350. }
  351. })
  352. this.getDataList();
  353. //解决上传相同文件不触发change
  354. let inp = document.getElementById("upFile");
  355. inp.value = "";
  356. }
  357. }
  358. }
  359. </script>
  360. <style lang="less" scoped>
  361. @import "../../less/admin.less";
  362. /deep/ .container.knowledgeTitle {
  363. height: 80px;
  364. }
  365. /deep/ .contents.knowledgeContents {
  366. padding: 104px 20px 0;
  367. }
  368. /deep/ .secLine.el-form {
  369. float: right;
  370. display: block;
  371. position: relative;
  372. top: -5px;
  373. }
  374. .delete{
  375. color: red;
  376. }
  377. .review{
  378. color: #22ccc8;
  379. }
  380. .el-table .cell{
  381. overflow: hidden;
  382. white-space: nowrap;
  383. }
  384. #upFile{
  385. display: none !important;
  386. }
  387. </style>