CombineFeildList.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <div>
  3. <crumbs title="组合字段维护">
  4. <el-form :inline="true" class="demo-form-inline">
  5. <el-form-item label="所属医院:">
  6. <el-select size="mini" v-model="filter.hospitalId" placeholder="所属医院" clearable>
  7. <el-option v-for="item in hisTypes" :label="item.name" :value="item.val" :key="item.val"></el-option>
  8. </el-select>
  9. </el-form-item>
  10. <el-form-item label="所属模块:">
  11. <el-select size="mini" v-model="filter.modeId" placeholder="所属模块" clearable>
  12. <el-option v-for="item in fieldTypes" :label="item.name" :value="item.val" :key="item.val"></el-option>
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="备注:">
  16. <el-input size="mini" v-model="filter.tagName" placeholder="备注"></el-input>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button size="mini" @click="filterDatas">确认</el-button>
  20. <el-button size="mini" type="warning" @click="addCombineField">添加组合字段</el-button>
  21. </el-form-item>
  22. </el-form>
  23. </crumbs>
  24. <div class="contents">
  25. <el-table :data="list"
  26. border
  27. style="width: 100%">
  28. <el-table-column
  29. type="index"
  30. :index="indexMethod"
  31. label="编号"
  32. width="60">
  33. </el-table-column>
  34. <el-table-column
  35. prop="hospitalId"
  36. label="所属医院"
  37. width="150"
  38. :formatter="hisFormatter"
  39. :show-overflow-tooltip="true">
  40. </el-table-column>
  41. <el-table-column
  42. prop="moduleName"
  43. :formatter="moduleFormatter"
  44. label="所属模块">
  45. </el-table-column>
  46. <el-table-column
  47. prop="name"
  48. label="显示名称">
  49. </el-table-column>
  50. <!--<el-table-column
  51. prop="name"
  52. label="包含字段">
  53. </el-table-column>-->
  54. <el-table-column
  55. prop="tagName"
  56. label="备注">
  57. </el-table-column>
  58. <el-table-column
  59. label="操作" width="150">
  60. <template slot-scope="scope">
  61. <el-button type="text" size="small" @click="toEditField(scope.row, 'modify')">修改</el-button>
  62. <span style="margin:0 3px;">|</span>
  63. <el-button type="text" size="small" @click="toEditField(scope.row, 'copy')">复制</el-button>
  64. <span style="margin:0 3px;">|</span>
  65. <el-button type="text" size="small" class="delete" @click="showDelDialog(scope.row.id)">删除</el-button>
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <el-pagination v-if="total>pageSize"
  70. :current-page.sync="currentPage"
  71. @current-change="currentChange"
  72. background
  73. :page-size="pageSize"
  74. layout="total,prev, pager, next, jumper"
  75. :total="total">
  76. </el-pagination>
  77. </div>
  78. </div>
  79. </template>
  80. <script>
  81. import api from '@api/qualityControl.js';
  82. export default {
  83. name: 'CombineFeild',
  84. data: function () {
  85. return {
  86. list: [],
  87. searched:false,
  88. tagType:[4],
  89. currentPage: 1,
  90. pageSize: 10,
  91. total: 0,
  92. fieldTypes:[],
  93. hisTypes:[],
  94. filter: {
  95. hospitalId:'',
  96. modeId:'',
  97. tagName: ''
  98. }
  99. }
  100. },
  101. created() {
  102. this.getAllTypes();
  103. /*const _this=this;
  104. setTimeout(function() {
  105. _this.getDataList();
  106. },100);*/
  107. },
  108. watch:{
  109. 'filter':{
  110. handler:function(){
  111. this.searched = false;
  112. },
  113. deep:true
  114. }
  115. },
  116. beforeRouteEnter(to, from, next){
  117. next(vm => {
  118. //const pm = to.param;
  119. Object.assign(vm,to.params);
  120. vm.inCurrentPage=to.params.currentPage;
  121. })
  122. },
  123. methods: {
  124. moduleFormatter(item){
  125. const field = this.fieldTypes.filter((it)=>it.val==item.modeId);
  126. return field[0]?field[0].name:'';
  127. },
  128. hisFormatter(item){
  129. const field = this.hisTypes.filter((it)=>it.val==item.hospitalId);
  130. return field[0]?field[0].name:'';
  131. },
  132. getAllTypes(){
  133. if(localStorage.getItem("qcModuleTypes")){
  134. this.hisTypes = JSON.parse(localStorage.getItem("qcHospitalTypes"));
  135. this.fieldTypes = JSON.parse(localStorage.getItem("qcModuleTypes"));
  136. this.getDataList();
  137. return ;
  138. }
  139. //获取枚举信息
  140. api.getQcTypes().then((res)=>{
  141. if(res.data.code==="0"){
  142. const data = res.data.data;
  143. localStorage.setItem("qcModuleTypes",JSON.stringify(data[12]));
  144. localStorage.setItem("qcHospitalTypes",JSON.stringify(data[13]));
  145. this.hisTypes =data[13];
  146. this.fieldTypes =data[12];
  147. this.getDataList();
  148. }else{
  149. this.warning("获取枚举信息失败");
  150. }
  151. });
  152. },
  153. addCombineField(){
  154. const pam = this.searched ? {
  155. currentPage: this.currentPage,
  156. filter: this.filter
  157. } : {currentPage: this.currentPage};
  158. this.$router.push({name: 'AddCombineFeild', params: pam});
  159. },
  160. toEditField(row,type){
  161. api.getFieldDetail({id:row.id}).then((res)=>{
  162. const {code,data,msg} = res.data;
  163. if(code=='0'){
  164. const item = Object.assign({},row,data);
  165. const pam = this.searched ? {
  166. currentPage: this.currentPage,
  167. filter: this.filter
  168. } : {currentPage: this.currentPage};
  169. if(type == 'modify') {
  170. this.$router.push({name: 'AddCombineFeild', params: Object.assign(pam, {isEdit: true, data: item})});
  171. } else if( type == 'copy') {
  172. this.$router.push({name: 'AddCombineFeild', params: Object.assign(pam, {isCopy: true, data: item})});
  173. } else {
  174. return
  175. }
  176. }else{
  177. this.$message({
  178. message: msg,
  179. type: 'warning'
  180. });
  181. }
  182. });
  183. // this.$router.push({
  184. // name:'AddCombineFeild',
  185. // params: {info:row}
  186. // })
  187. },
  188. filterDatas(){
  189. this.currentPage = 1;
  190. this.getDataList();
  191. },
  192. getDataList() {
  193. const param = this.getFilterItems();
  194. this.searched = true;
  195. api.getFieldList(param).then((res) => {
  196. if (res.data.code == '0') {
  197. const data = res.data.data;
  198. this.list = data.records;
  199. this.total = data.total;
  200. }
  201. }).catch((error) => {
  202. console.log(error);
  203. });
  204. },
  205. getFilterItems() {
  206. const param = Object.assign({
  207. current: this.currentPage,
  208. size: this.pageSize,
  209. tagTypeList:[4]
  210. },this.filter);
  211. return param;
  212. },
  213. indexMethod(index) {
  214. return ((this.currentPage - 1) * this.pageSize) + index + 1;
  215. },
  216. currentChange(next) {
  217. this.currentPage = next;
  218. this.getDataList();
  219. },
  220. warning(msg,type){
  221. this.$message({
  222. showClose: true,
  223. message:msg,
  224. type:type||'warning'
  225. })
  226. },
  227. showConfirmDialog(msg,resolve){
  228. this.$alert(msg, '提示', {
  229. confirmButtonText: '确定',
  230. type: 'warning'
  231. }).then(() => {
  232. resolve();
  233. }).catch(() => {});
  234. },
  235. showDelDialog(id){
  236. this.showConfirmDialog('是否删除该组合字段?',()=>{
  237. api.delFieldMatch({ids:id}).then((res)=>{
  238. if(res.data.code=='0'){
  239. this.warning(res.data.msg||'操作成功','success');
  240. this.getDataList();
  241. }else{
  242. this.warning(res.data.msg);
  243. }
  244. }).catch((error)=>{
  245. this.warning(error);
  246. })
  247. });
  248. }
  249. }
  250. }
  251. </script>
  252. <style lang="less">
  253. @import "../../less/admin.less";
  254. .delete{
  255. color: red !important;
  256. }
  257. </style>