RegisteredDrug.vue 13 KB

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