MedicalName.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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 v-if="total>pageSize"
  106. :current-page.sync="currentPage"
  107. @current-change="currentChange"
  108. background
  109. :page-size="pageSize"
  110. layout="total,prev, pager, next, jumper"
  111. :total="total">
  112. </el-pagination>
  113. </div>
  114. </div>
  115. </template>
  116. <script>
  117. import api from '@api/icss.js';
  118. export default {
  119. name: 'MedicalName',
  120. data: function () {
  121. return {
  122. list: [],
  123. stateSelect:[
  124. {id:'N',name:'启用中'},
  125. {id:'Y',name:'已删除'},
  126. ],
  127. // isState:'',
  128. cacheData: {}, //因为删除和恢复要及时更新,所以不做缓存
  129. currentPage: 1,
  130. pageSize: 10,
  131. total: 0,
  132. searched:false,
  133. filter: {
  134. term:'',
  135. type:'',
  136. libName:'',
  137. isState:'',
  138. },
  139. typeList:[],
  140. reloadFlag:true
  141. }
  142. },
  143. created() {
  144. // this.getDataList();
  145. this.getTypeList();
  146. const that = this;
  147. //返回时避免参数未赋值就获取列表
  148. setTimeout(function(){
  149. that.getDataList();
  150. });
  151. },
  152. watch:{
  153. 'filter':{
  154. handler:function(){
  155. this.searched = false;
  156. },
  157. deep:true
  158. }
  159. },
  160. beforeRouteEnter(to, from, next){
  161. next(vm => {
  162. //const pm = to.param;
  163. Object.assign(vm,to.params);
  164. })
  165. },
  166. methods: {
  167. reloadLib(){
  168. if(this.reloadFlag){
  169. this.reloadFlag = false;
  170. api.reloadLib().then((res)=>{
  171. if (res.data.code == 0) {
  172. this.reloadFlag = true;
  173. }
  174. })
  175. }
  176. },
  177. addMedicalName(){
  178. const pam = this.searched?{currentPage:this.currentPage,
  179. filter:this.filter}:{currentPage:this.currentPage};
  180. this.$router.push({name:'AddMedicalName',
  181. params:pam});
  182. },
  183. toEditProduct(row,copy){
  184. const pam = this.searched?{currentPage:this.currentPage,
  185. filter:this.filter}:{currentPage:this.currentPage};
  186. this.$router.push({
  187. name:'AddMedicalName',
  188. // params: {info:row}
  189. params: Object.assign(pam,{id:row.conceptId,copy:copy})
  190. })
  191. },
  192. filterDatas(){
  193. this.currentPage = 1;
  194. this.getDataList();
  195. },
  196. getDataList(isTurnPage) {
  197. const param = this.getFilterItems(isTurnPage);
  198. this.searched = true;
  199. api.knowledgeName(param).then((res) => {
  200. if (res.data.code == '0') {
  201. const data = res.data.data;
  202. this.list = data.records;
  203. // this.cacheData[param.current] = data.records;
  204. this.total = data.total;
  205. }
  206. }).catch((error) => {
  207. console.log(error);
  208. });
  209. },
  210. getTypeList(){
  211. api.allKnowledgeType({'name':''}).then((res)=>{
  212. const data = res.data;
  213. if(data.code==0){
  214. this.typeList = data.data;
  215. }else{
  216. console.log(res.msg);
  217. }
  218. }).catch((error) => {
  219. console.log(error);
  220. });
  221. },
  222. /*getDetailList(id) {
  223. this.$router.push({name:'DeptInfoDetail', params:{id: id}})
  224. },*/
  225. getFilterItems(isTurnPage) {
  226. //翻页时筛选条件没点确定则清空
  227. if(isTurnPage&&!this.searched){
  228. this.clearFilter();
  229. };
  230. const param = {
  231. name: this.filter.term,
  232. current: this.currentPage,
  233. size: this.pageSize,
  234. type:this.filter.type,
  235. libName:this.filter.libName,
  236. isDeleted:this.filter.isState
  237. };
  238. return param;
  239. },
  240. indexMethod(index) {
  241. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  242. },
  243. currentChange(next) {
  244. this.currentPage = next;
  245. // if (this.cacheData[next]) { //如果已请求过该页数据,则使用缓存不重复请求
  246. // this.list = this.cacheData[next];
  247. // } else {
  248. this.getDataList(true);
  249. // }
  250. },
  251. warning(msg,type){
  252. this.$message({
  253. showClose: true,
  254. message:msg,
  255. type:type||'warning'
  256. })
  257. },
  258. showConfirmDialog(msg,resolve){
  259. this.$alert(msg, '提示', {
  260. confirmButtonText: '确定',
  261. type: 'warning'
  262. }).then(() => {
  263. resolve();
  264. }).catch(() => {});
  265. },
  266. showDelDialog(item){
  267. /*const param = {
  268. term:item.term,
  269. type:item.type,
  270. id:item.id
  271. }*/
  272. const param = {
  273. conceptId:item.conceptId,
  274. isDeleted:item.isDeleted === 'N'?'Y':'N'
  275. }
  276. let waringTxt = (item.isDeleted === 'N'?'是否删除该标准术语?':'是否重新启用该条数据?')
  277. this.showConfirmDialog(waringTxt,()=>{
  278. api.deletMedicalName(param).then((res)=>{
  279. if(res.data.code=='0') {
  280. if (!this.searched) {
  281. //未点确认时清空搜索条件
  282. this.clearFilter();
  283. }
  284. if (item.isDeleted !== 'N') { //恢复成功后跳转到筛选条件的首页
  285. this.currentPage = 1;
  286. } else {
  287. if (this.filter.isState!==''&&this.list.length === 1){
  288. //有启用状态筛选条件且当前页只有最后一条数据删除时,删除成功后跳转到前一页
  289. this.currentPage = this.currentPage===1?1:this.currentPage-1;
  290. }
  291. }
  292. this.warning(res.data.msg||'操作成功','success');
  293. this.getDataList();
  294. }else{
  295. this.warning(res.data.msg);
  296. }
  297. }).catch((error)=>{
  298. this.warning(error);
  299. })
  300. });
  301. },
  302. clearFilter(){
  303. this.filter = {
  304. term:'',
  305. type:'',
  306. libName:'',
  307. isState:'',
  308. };
  309. },
  310. uploadClick(){
  311. let inp = document.getElementById("upFile");
  312. inp.click();
  313. },
  314. uploadFile(e){
  315. let fileInfo = e.target.files[0];
  316. e.preventDefault();
  317. let formData = new FormData();
  318. formData.append('uploadfile', fileInfo);
  319. const header = {
  320. headers:{
  321. 'Content-Type': 'multipart/form-data'
  322. }
  323. }
  324. api.knowledgeUpload(formData,header).then((res)=>{
  325. if(res.data.code==0){
  326. this.$message({
  327. message: '上传成功',
  328. type: 'success',
  329. });
  330. this.getDataList();
  331. }else{
  332. /*this.$message({
  333. dangerouslyUseHTMLString: true,
  334. message:res.data.msg,
  335. type:'warning'
  336. });*/
  337. this.$alert(res.data.msg,'错误信息',{
  338. dangerouslyUseHTMLString: true,
  339. confirmButtonText: '确定',
  340. callback: action => {
  341. /*this.$message({
  342. type: 'info',
  343. message: `action: ${ action }`
  344. });*/
  345. }
  346. });
  347. }
  348. })
  349. //解决上传相同文件不触发change
  350. let inp = document.getElementById("upFile");
  351. inp.value = "";
  352. },
  353. }
  354. }
  355. </script>
  356. <style lang="less" scoped>
  357. @import "../../less/admin.less";
  358. /deep/ .container.knowledgeTitle {
  359. height: 80px;
  360. }
  361. /deep/ .contents.knowledgeContents {
  362. padding: 104px 20px 0;
  363. }
  364. /deep/ .secLine.el-form {
  365. float: right;
  366. display: block;
  367. position: relative;
  368. top: -5px;
  369. }
  370. .delete{
  371. color: red;
  372. }
  373. .review{
  374. color: #22ccc8;
  375. }
  376. .el-table .cell{
  377. overflow: hidden;
  378. white-space: nowrap;
  379. }
  380. #upFile{
  381. display: none !important;
  382. }
  383. </style>