BasicTermsMaintenance.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div>
  3. <crumbs title="基础术语维护" minWidth="995px" class="knowledgeTitle">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="医学标准术语:">
  6. <el-input
  7. size="mini"
  8. v-model="filter.term"
  9. placeholder="请输入术语"
  10. ></el-input>
  11. </el-form-item>
  12. <el-form-item label="术语类型:">
  13. <el-select
  14. v-model="filter.type"
  15. clearable
  16. filterable
  17. placeholder="请选择"
  18. size="mini"
  19. >
  20. <el-option
  21. v-for="item in typeList"
  22. :key="item.id"
  23. :label="item.name"
  24. :value="item.code"
  25. ></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="同义词:">
  29. <el-input
  30. size="mini"
  31. v-model="filter.libName"
  32. placeholder="输入同义词"
  33. ></el-input>
  34. </el-form-item>
  35. <el-form-item label="状态:">
  36. <el-select
  37. v-model="filter.isState"
  38. clearable
  39. placeholder="请选择"
  40. size="mini"
  41. >
  42. <el-option
  43. v-for="item in stateSelect"
  44. :key="item.id"
  45. :label="item.name"
  46. :value="item.id"
  47. ></el-option>
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button size="mini" @click="filterDatas">确认</el-button>
  52. </el-form-item>
  53. </el-form>
  54. <el-form class="secLine">
  55. <el-form-item>
  56. <span @click="handleDownLoad" class="link_to_downLoad"
  57. >导入模板下载</span
  58. >
  59. <el-button
  60. :disabled="uploadLodding"
  61. @click="handleUploadBtn"
  62. size="mini"
  63. >{{ uploadLodding ? "导入中..." : "导入" }}</el-button
  64. >
  65. <input
  66. style="display: none"
  67. type="file"
  68. name="uploadfile "
  69. id="upFileInp"
  70. @change="uploadFile($event)"
  71. />
  72. <el-button
  73. size="mini"
  74. type="warning"
  75. @click="addMedicalName"
  76. style="margin: 0 10px"
  77. >+ 新增术语</el-button
  78. >
  79. <el-button size="mini" @click="reloadLib">更新数据</el-button>
  80. </el-form-item>
  81. </el-form>
  82. </crumbs>
  83. <div class="contents knowledgeContents">
  84. <el-table :data="list" border style="width: 100%">
  85. <el-table-column
  86. type="index"
  87. :index="indexMethod"
  88. label="编号"
  89. width="60"
  90. ></el-table-column>
  91. <el-table-column
  92. prop="libName"
  93. label="医学标准术语"
  94. show-overflow-tooltip
  95. ></el-table-column>
  96. <el-table-column prop="typeName" label="术语类型"></el-table-column>
  97. <el-table-column
  98. prop="synonymName"
  99. label="同义词"
  100. show-overflow-tooltip
  101. ></el-table-column>
  102. <el-table-column label="状态" width="100">
  103. <template slot-scope="scope">
  104. <span>{{ scope.row.isDeleted == "N" ? "启用" : "禁用" }}</span>
  105. </template>
  106. </el-table-column>
  107. <el-table-column prop="modifierName" label="操作人"></el-table-column>
  108. <el-table-column
  109. prop="gmtModified"
  110. label="操作时间"
  111. :show-overflow-tooltip="true"
  112. ></el-table-column>
  113. <el-table-column label="操作" width="160">
  114. <template slot-scope="scope">
  115. <el-button
  116. type="text"
  117. size="small"
  118. @click="toEditProduct(scope.row)"
  119. >修改</el-button
  120. >
  121. <span style="margin: 0 3px">|</span>
  122. <el-button
  123. type="text"
  124. size="small"
  125. @click="toEditProduct(scope.row, true)"
  126. >复制</el-button
  127. >
  128. <span style="margin: 0 3px">|</span>
  129. <el-button
  130. type="text"
  131. size="small"
  132. :class="scope.row.isDeleted == 'N' ? 'delete' : 'review'"
  133. @click="showDelDialog(scope.row)"
  134. >{{ scope.row.isDeleted == "Y" ? "启用" : "禁用" }}</el-button
  135. >
  136. </template>
  137. </el-table-column>
  138. </el-table>
  139. <el-pagination
  140. :current-page.sync="currentPage"
  141. @current-change="currentChange"
  142. background
  143. :page-size="pageSize"
  144. :page-sizes="pageSizeArr"
  145. @size-change="handleSizeChange"
  146. :layout="pageLayout"
  147. :total="total"
  148. ></el-pagination>
  149. </div>
  150. </div>
  151. </template>
  152. <script>
  153. import api from "@api/knowledgeTree.js";
  154. import config from "@api/config.js";
  155. import utils from "@api/utils.js";
  156. export default {
  157. name: "BasicTermsMaintenance",
  158. data: function () {
  159. return {
  160. list: [],
  161. stateSelect: [
  162. { id: "N", name: "启用" },
  163. { id: "Y", name: "禁用" }
  164. ],
  165. // isState:'',
  166. cacheData: {}, //因为删除和恢复要及时更新,所以不做缓存
  167. currentPage: 1,
  168. pageSize: config.pageSize,
  169. pageSizeArr: config.pageSizeArr,
  170. pageLayout: config.pageLayout,
  171. total: 0,
  172. searched: false,
  173. filter: {
  174. term: "",
  175. type: "",
  176. libName: ""
  177. },
  178. typeList: [],
  179. reloadFlag: true,
  180. uploadLodding: false
  181. };
  182. },
  183. created() {
  184. const param = this.$route.params;
  185. if (param.currentPage) {
  186. this.inCurrentPage = param.currentPage;
  187. }
  188. if (param.filter) {
  189. this.filter = param.filter;
  190. }
  191. this.getTypeList();
  192. //返回时避免参数未赋值就获取列表
  193. this.$nextTick(() => {
  194. this.getDataList();
  195. });
  196. },
  197. watch: {
  198. filter: {
  199. handler: function () {
  200. this.searched = false;
  201. },
  202. deep: true
  203. }
  204. },
  205. // beforeRouteEnter(to, from, next) {
  206. // next(vm => {
  207. // //const pm = to.param;
  208. // Object.assign(vm, to.params);
  209. // vm.inCurrentPage = to.params.currentPage;
  210. // });
  211. // },
  212. methods: {
  213. handleUploadBtn() {
  214. let inp = document.getElementById("upFileInp");
  215. inp.click();
  216. },
  217. // 导入数据
  218. uploadFile(e) {
  219. let that = this;
  220. this.uploadLodding = true;
  221. let fileInfo = e.target.files[0];
  222. e.preventDefault();
  223. let formData = new FormData();
  224. formData.append("termfile", fileInfo);
  225. this.uploadText = "导入中...";
  226. api
  227. .exportTermExcel(formData)
  228. .then((res) => {
  229. let r = new FileReader();
  230. r.onload = function () {
  231. const exsetCode = this.result.indexOf("code") !== -1;
  232. if (!exsetCode) {
  233. utils.downloadExportedData(res.data, "基础术语导入模板.xls");
  234. that.getDataList();
  235. } else {
  236. const code = JSON.parse(this.result);
  237. if (code.code === "00000001") {
  238. that
  239. .$alert(`数据存在异常,导入失败,请修改后再试`, "提示1", {
  240. confirmButtonText: "确定",
  241. type: "warning"
  242. })
  243. .then(() => {})
  244. .catch(() => {});
  245. } else {
  246. that
  247. .$alert(`${code.msg}`, "提示2", {
  248. confirmButtonText: "确定",
  249. type: "warning"
  250. })
  251. .then(() => {})
  252. .catch(() => {});
  253. }
  254. }
  255. setTimeout(() => {
  256. that.uploadLodding = false;
  257. }, 300);
  258. };
  259. r.readAsText(res.data);
  260. })
  261. .catch((error) => {
  262. console.error(error);
  263. that.uploadLodding = false;
  264. });
  265. //解决上传相同文件不触发change
  266. let inp = document.getElementById("upFileInp");
  267. inp.value = "";
  268. },
  269. handleDownLoad() {
  270. api.exportExcelTemplates().then((res) => {
  271. if (res.status === 200) {
  272. setTimeout(() => {
  273. utils.downloadExportedData(res.data, "基础术语导入模板.xls");
  274. }, 1500);
  275. }
  276. });
  277. },
  278. handleSizeChange(val) {
  279. this.pageSize = val;
  280. this.currentPage = utils.getCurrentPage(
  281. this.currentPage,
  282. this.total,
  283. this.pageSize
  284. );
  285. this.getDataList();
  286. },
  287. reloadLib() {
  288. const loading = this.$loading({
  289. lock: true,
  290. text: "Loading",
  291. spinner: "el-icon-loading",
  292. background: "rgba(0, 0, 0, 0.7)"
  293. });
  294. if (this.reloadFlag) {
  295. this.reloadFlag = false;
  296. api.clearStandRuleDrug().then((res) => {
  297. this.getDataList();
  298. if (res.data.code == 0) {
  299. this.reloadFlag = true;
  300. this.warning("更新成功", "success");
  301. } else {
  302. this.warning(res.data.msg || "更新失败,请重试");
  303. }
  304. });
  305. }
  306. },
  307. addMedicalName() {
  308. const pam = this.searched
  309. ? {
  310. currentPage: this.currentPage,
  311. pageSize: this.pageSize,
  312. filter: this.filter
  313. }
  314. : { currentPage: this.currentPage, pageSize: this.pageSize };
  315. this.$router.push({ name: "AddTerm", params: pam });
  316. },
  317. toEditProduct(row, copy) {
  318. const pam = this.searched
  319. ? {
  320. currentPage: this.currentPage,
  321. pageSize: this.pageSize,
  322. filter: this.filter
  323. }
  324. : { currentPage: this.currentPage, pageSize: this.pageSize };
  325. this.$router.push({
  326. name: "AddTerm",
  327. // params: {info:row}
  328. params: Object.assign(pam, {
  329. id: row.conceptId,
  330. libType: row.libType,
  331. copy: copy
  332. })
  333. });
  334. },
  335. filterDatas() {
  336. this.currentPage = 1;
  337. this.getDataList();
  338. },
  339. getDataList(isTurnPage) {
  340. const param = this.getFilterItems(isTurnPage);
  341. this.searched = true;
  342. const loading = this.$loading({
  343. lock: true,
  344. text: "Loading",
  345. spinner: "el-icon-loading",
  346. background: "rgba(0, 0, 0, 0.7)"
  347. });
  348. api
  349. .getBaseConceptInfoPage(param)
  350. .then((res) => {
  351. loading.close();
  352. if (res.data.code == "0") {
  353. const data = res.data.data;
  354. const templis = data.records;
  355. for (let i = 0; i < templis.length; i++) {
  356. templis[i].isDeleted = templis[i].status == "1" ? "N" : "Y";
  357. }
  358. this.list = templis;
  359. // this.cacheData[param.current] = data.records;
  360. this.total = data.total;
  361. if (this.inCurrentPage !== undefined) {
  362. this.currentPage = this.inCurrentPage;
  363. this.inCurrentPage = undefined;
  364. }
  365. }
  366. })
  367. .catch((error) => {
  368. console.log(error);
  369. });
  370. },
  371. getTypeList() {
  372. api
  373. .baseTypeGetPage({ name: "", size: 1000 })
  374. .then((res) => {
  375. const data = res.data;
  376. if (data.code == 0) {
  377. this.typeList = data.data.records || [];
  378. } else {
  379. console.log(res.msg);
  380. }
  381. })
  382. .catch((error) => {
  383. console.log(error);
  384. });
  385. },
  386. /*getDetailList(id) {
  387. this.$router.push({name:'DeptInfoDetail', params:{id: id}})
  388. },*/
  389. getFilterItems(isTurnPage) {
  390. //翻页时筛选条件没点确定则清空
  391. if (isTurnPage && !this.searched) {
  392. this.clearFilter();
  393. }
  394. const param = {
  395. libName: this.filter.term.trim(),
  396. libType: this.filter.type,
  397. status:
  398. this.filter.isState == "N"
  399. ? "1"
  400. : this.filter.isState == "Y"
  401. ? "0"
  402. : "",
  403. synonymName: this.filter.libName.trim(),
  404. current: this.inCurrentPage || this.currentPage,
  405. size: this.pageSize,
  406. isDeleted: this.filter.isState
  407. };
  408. return param;
  409. },
  410. indexMethod(index) {
  411. return (this.currentPage - 1) * this.pageSize + index + 1;
  412. },
  413. currentChange(next) {
  414. this.currentPage = next;
  415. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  416. // this.list = this.cacheData[next];
  417. // } else {
  418. this.getDataList(true);
  419. // }
  420. },
  421. warning(msg, type) {
  422. this.$message({
  423. showClose: true,
  424. message: msg,
  425. type: type || "warning"
  426. });
  427. },
  428. showConfirmDialog(msg, resolve) {
  429. this.$alert(msg, "提示", {
  430. confirmButtonText: "确定",
  431. type: "warning"
  432. })
  433. .then(() => {
  434. resolve();
  435. })
  436. .catch(() => {});
  437. },
  438. showDelDialog(item) {
  439. /*const param = {
  440. term:item.term,
  441. type:item.type,
  442. id:item.id
  443. }*/
  444. const param = {
  445. conceptId: item.conceptId
  446. };
  447. let url = item.isDeleted === "N" ? "disableConcept" : "startConcept";
  448. let waringTxt =
  449. item.isDeleted === "N"
  450. ? "是否禁用该标准术语?"
  451. : "是否重新启用该条数据?";
  452. this.showConfirmDialog(waringTxt, () => {
  453. api[url](param)
  454. .then((res) => {
  455. if (res.data.code == "0") {
  456. if (!this.searched) {
  457. //未点确认时清空搜索条件
  458. this.clearFilter();
  459. }
  460. if (item.isDeleted !== "N") {
  461. //恢复成功后跳转到筛选条件的首页
  462. this.currentPage = 1;
  463. } else {
  464. if (this.filter.isState !== "" && this.list.length === 1) {
  465. //有启用状态筛选条件且当前页只有最后一条数据删除时,删除成功后跳转到前一页
  466. this.currentPage =
  467. this.currentPage === 1 ? 1 : this.currentPage - 1;
  468. }
  469. }
  470. this.warning(res.data.msg || "操作成功", "success");
  471. this.getDataList();
  472. } else {
  473. this.warning(res.data.msg);
  474. }
  475. })
  476. .catch((error) => {
  477. this.warning(error);
  478. });
  479. });
  480. },
  481. clearFilter() {
  482. this.filter = {
  483. term: "",
  484. type: "",
  485. libName: "",
  486. isState: ""
  487. };
  488. }
  489. }
  490. };
  491. </script>
  492. <style lang="less" scoped>
  493. @import "../../less/admin.less";
  494. /deep/ .container.knowledgeTitle {
  495. height: 80px;
  496. }
  497. /deep/ .contents.knowledgeContents {
  498. padding: 104px 20px 0;
  499. }
  500. /deep/ .secLine.el-form {
  501. float: right;
  502. display: block;
  503. position: relative;
  504. top: -5px;
  505. }
  506. .delete {
  507. color: red;
  508. }
  509. .review {
  510. color: #22ccc8;
  511. }
  512. .deletes {
  513. cursor: default;
  514. color: red;
  515. }
  516. .reviews {
  517. color: #606266;
  518. cursor: default;
  519. }
  520. .el-table .cell {
  521. overflow: hidden;
  522. white-space: nowrap;
  523. }
  524. #upFileInp {
  525. display: none !important;
  526. }
  527. .link_to_downLoad {
  528. color: #02a7f0;
  529. cursor: pointer;
  530. margin-right: 10px;
  531. }
  532. </style>