MedicalName.vue 14 KB

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