MedicalName.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. })
  170. },
  171. methods: {
  172. handleSizeChange(val){
  173. this.pageSize = val;
  174. this.currentPage = utils.getCurrentPage(this.currentPage, this.total, this.pageSize);
  175. this.getDataList();
  176. },
  177. reloadLib(){
  178. if(this.reloadFlag){
  179. this.reloadFlag = false;
  180. api.reloadLib().then((res)=>{
  181. if (res.data.code == 0) {
  182. this.reloadFlag = true;
  183. }
  184. })
  185. }
  186. },
  187. addMedicalName(){
  188. const pam = this.searched?{currentPage:this.currentPage,
  189. pageSize:this.pageSize,
  190. filter:this.filter}:{currentPage:this.currentPage,
  191. pageSize:this.pageSize};
  192. this.$router.push({name:'AddMedicalName',
  193. params:pam});
  194. },
  195. toEditProduct(row,copy){
  196. const pam = this.searched?{currentPage:this.currentPage,
  197. pageSize:this.pageSize,
  198. filter:this.filter}:{currentPage:this.currentPage,
  199. pageSize:this.pageSize};
  200. this.$router.push({
  201. name:'AddMedicalName',
  202. // params: {info:row}
  203. params: Object.assign(pam,{id:row.conceptId,copy:copy})
  204. })
  205. },
  206. filterDatas(){
  207. this.currentPage = 1;
  208. this.getDataList();
  209. },
  210. getDataList(isTurnPage) {
  211. const param = this.getFilterItems(isTurnPage);
  212. this.searched = true;
  213. const loading = this.$loading({
  214. lock: true,
  215. text: 'Loading',
  216. spinner: 'el-icon-loading',
  217. background: 'rgba(0, 0, 0, 0.7)'
  218. });
  219. api.knowledgeName(param).then((res) => {
  220. loading.close()
  221. if (res.data.code == '0') {
  222. const data = res.data.data;
  223. this.list = data.records;
  224. // this.cacheData[param.current] = data.records;
  225. this.total = data.total;
  226. }
  227. }).catch((error) => {
  228. console.log(error);
  229. });
  230. },
  231. getTypeList(){
  232. api.allKnowledgeType({'name':''}).then((res)=>{
  233. const data = res.data;
  234. if(data.code==0){
  235. this.typeList = data.data;
  236. }else{
  237. console.log(res.msg);
  238. }
  239. }).catch((error) => {
  240. console.log(error);
  241. });
  242. },
  243. /*getDetailList(id) {
  244. this.$router.push({name:'DeptInfoDetail', params:{id: id}})
  245. },*/
  246. getFilterItems(isTurnPage) {
  247. //翻页时筛选条件没点确定则清空
  248. if(isTurnPage&&!this.searched){
  249. this.clearFilter();
  250. };
  251. const param = {
  252. name: this.filter.term.trim(),
  253. current: this.currentPage,
  254. size: this.pageSize,
  255. type:this.filter.type,
  256. libName:this.filter.libName.trim(),
  257. isDeleted:this.filter.isState
  258. };
  259. return param;
  260. },
  261. indexMethod(index) {
  262. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  263. },
  264. currentChange(next) {
  265. this.currentPage = next;
  266. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  267. // this.list = this.cacheData[next];
  268. // } else {
  269. this.getDataList(true);
  270. // }
  271. },
  272. warning(msg,type){
  273. this.$message({
  274. showClose: true,
  275. message:msg,
  276. type:type||'warning'
  277. })
  278. },
  279. showConfirmDialog(msg,resolve){
  280. this.$alert(msg, '提示', {
  281. confirmButtonText: '确定',
  282. type: 'warning'
  283. }).then(() => {
  284. resolve();
  285. }).catch(() => {});
  286. },
  287. showDelDialog(item){
  288. /*const param = {
  289. term:item.term,
  290. type:item.type,
  291. id:item.id
  292. }*/
  293. const param = {
  294. conceptId:item.conceptId,
  295. isDeleted:item.isDeleted === 'N'?'Y':'N'
  296. }
  297. let waringTxt = (item.isDeleted === 'N'?'是否删除该标准术语?':'是否重新启用该条数据?')
  298. this.showConfirmDialog(waringTxt,()=>{
  299. api.deletMedicalName(param).then((res)=>{
  300. if(res.data.code=='0') {
  301. if (!this.searched) {
  302. //未点确认时清空搜索条件
  303. this.clearFilter();
  304. }
  305. if (item.isDeleted !== 'N') { //恢复成功后跳转到筛选条件的首页
  306. this.currentPage = 1;
  307. } else {
  308. if (this.filter.isState!==''&&this.list.length === 1){
  309. //有启用状态筛选条件且当前页只有最后一条数据删除时,删除成功后跳转到前一页
  310. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  311. }
  312. }
  313. this.warning(res.data.msg||'操作成功','success');
  314. this.getDataList();
  315. }else{
  316. this.warning(res.data.msg);
  317. }
  318. }).catch((error)=>{
  319. this.warning(error);
  320. })
  321. });
  322. },
  323. clearFilter(){
  324. this.filter = {
  325. term:'',
  326. type:'',
  327. libName:'',
  328. isState:'',
  329. };
  330. },
  331. uploadClick(){
  332. let inp = document.getElementById("upFile");
  333. inp.click();
  334. },
  335. uploadFile(e){
  336. let fileInfo = e.target.files[0];
  337. e.preventDefault();
  338. let formData = new FormData();
  339. formData.append('uploadfile', fileInfo);
  340. const header = {
  341. headers:{
  342. 'Content-Type': 'multipart/form-data'
  343. }
  344. }
  345. api.knowledgeUpload(formData,header).then((res)=>{
  346. if(res.data.code==0){
  347. this.$message({
  348. message: '上传成功',
  349. type: 'success',
  350. });
  351. this.getDataList();
  352. }else{
  353. /*this.$message({
  354. dangerouslyUseHTMLString: true,
  355. message:res.data.msg,
  356. type:'warning'
  357. });*/
  358. this.$alert(res.data.msg,'错误信息',{
  359. dangerouslyUseHTMLString: true,
  360. confirmButtonText: '确定',
  361. callback: action => {
  362. /*this.$message({
  363. type: 'info',
  364. message: `action: ${ action }`
  365. });*/
  366. }
  367. });
  368. }
  369. })
  370. //解决上传相同文件不触发change
  371. let inp = document.getElementById("upFile");
  372. inp.value = "";
  373. },
  374. }
  375. }
  376. </script>
  377. <style lang="less" scoped>
  378. @import "../../less/admin.less";
  379. /deep/ .container.knowledgeTitle {
  380. height: 80px;
  381. }
  382. /deep/ .contents.knowledgeContents {
  383. padding: 104px 20px 0;
  384. }
  385. /deep/ .secLine.el-form {
  386. float: right;
  387. display: block;
  388. position: relative;
  389. top: -5px;
  390. }
  391. .delete{
  392. color: red;
  393. }
  394. .review{
  395. color: #22ccc8;
  396. }
  397. .el-table .cell{
  398. overflow: hidden;
  399. white-space: nowrap;
  400. }
  401. #upFile{
  402. display: none !important;
  403. }
  404. </style>