DiagBase.vue 13 KB

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