index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <div class="hospital">
  3. <el-row type="flex" class="row-bg" justify="space-between">
  4. <el-form ref="queryParams" :model="queryParams" label-width="130px">
  5. <el-col :span="5" style="width: 100%">
  6. <el-form-item label="项目/医院名称">
  7. <el-input v-model="queryParams.projectSource"></el-input>
  8. </el-form-item>
  9. </el-col>
  10. </el-form>
  11. <el-col :span="2">
  12. <el-button type="primary" @click="queryBtn">搜索</el-button>
  13. </el-col>
  14. </el-row>
  15. <el-row type="flex" class="row-bg" justify="end">
  16. <el-col :span="2">
  17. <el-button @click="addBtn">新增</el-button>
  18. </el-col>
  19. </el-row>
  20. <el-table
  21. v-loading="loading"
  22. :data="dataList"
  23. :height="tableHeight"
  24. :header-cell-style="{'text-align':'center'}"
  25. :cell-style="{'text-align':'center'}"
  26. border
  27. style="width: 100%;margin-top: 20px">
  28. <el-table-column
  29. prop="id"
  30. label="序号"
  31. width="100">
  32. </el-table-column>
  33. <el-table-column
  34. prop="projectSource"
  35. label="项目/医院名称"
  36. width="240">
  37. </el-table-column>
  38. <el-table-column
  39. prop="remark"
  40. label="备注"
  41. width="240">
  42. </el-table-column>
  43. <el-table-column
  44. fixed="right"
  45. label="操作">
  46. <template #default="scope">
  47. <el-button type="text">编辑</el-button>|
  48. <el-button type="text" @click="routerBtn(scope.row)">权限分配</el-button>|
  49. <el-button type="text" @click="delBtn(scope.row)">删除</el-button>
  50. </template>
  51. </el-table-column>
  52. </el-table>
  53. <el-pagination
  54. @size-change="handleSizeChange"
  55. @current-change="handleCurrentChange"
  56. :current-page=this.queryParams.pageNum
  57. :page-sizes="[10,20,50,100]"
  58. :page-size=this.queryParams.pageSize
  59. layout="total, sizes, prev, pager, next, jumper"
  60. :total=this.total>
  61. </el-pagination>
  62. <el-dialog
  63. :title="this.title"
  64. :visible.sync="dialogVisible"
  65. width="30%"
  66. :before-close="handleClose">
  67. <el-form ref="form" :model="form" label-width="130px">
  68. <el-form-item label="项目/医院名称">
  69. <el-input v-model="form.projectSource"></el-input>
  70. </el-form-item>
  71. </el-form>
  72. <span slot="footer" class="dialog-footer">
  73. <el-button @click="dialogVisible = false">取 消</el-button>
  74. <el-button type="primary" @click="submitForm">确 定</el-button>
  75. </span>
  76. </el-dialog>
  77. </div>
  78. </template>
  79. <script>
  80. import {add,edit,list,remove} from '@/api/business/as/hospital'
  81. export default {
  82. mounted() {
  83. //挂载window.onresize事件(动态设置table高度)
  84. let _this = this;
  85. window.onresize = () => {
  86. if (_this.resizeFlag) {
  87. clearTimeout(_this.resizeFlag);
  88. }
  89. _this.resizeFlag = setTimeout(() => {
  90. _this.getTableHeight();
  91. _this.resizeFlag = null;
  92. }, 100);
  93. };
  94. },
  95. created() {
  96. this.getData()
  97. this.getTableHeight();
  98. },
  99. methods:{
  100. routerBtn(row,event,colum) {
  101. let resolve = this.$router.push({path:'/business/as/hospital/assignAuthority',query:{id:row.id}});
  102. },
  103. //计算table高度(动态设置table高度)
  104. getTableHeight() {
  105. let tableH = 150; //距离页面下方的高度
  106. let tableHeightDetil = window.innerHeight - tableH;
  107. if (tableHeightDetil <= 300) {
  108. this.tableHeight = 300;
  109. } else {
  110. this.tableHeight = window.innerHeight - tableH;
  111. }
  112. },
  113. queryBtn(){
  114. this.getData()
  115. },
  116. getData(){
  117. list(this.queryParams).then(res =>{
  118. if(res.code == 200){
  119. this.dataList = res.rows
  120. this.total = res.total
  121. }
  122. })
  123. },
  124. handleSizeChange(val) {
  125. console.log(`每页 ${val} 条`);
  126. this.queryParams.pageSize = val
  127. },
  128. handleCurrentChange(val) {
  129. console.log(`当前页: ${val}`);
  130. this.queryParams.pageNum = val
  131. },
  132. handleClose(done) {
  133. this.$confirm('确认关闭?')
  134. .then(_ => {
  135. done();
  136. })
  137. .catch(_ => {});
  138. },
  139. addBtn() {
  140. this.dialogVisible=true
  141. this.title="新增"
  142. },
  143. delBtn(scope){
  144. this.$confirm('确认删除?')
  145. .then(_ => {
  146. remove(scope.id).then(res =>{
  147. if(res.code == 200){
  148. this.$modal.msgSuccess("删除成功");
  149. this.getData()
  150. }
  151. })
  152. })
  153. .catch(_ => {});
  154. },
  155. cancal(){
  156. this.form={
  157. id:undefined,
  158. projectSource:''
  159. }
  160. },
  161. submitForm(){
  162. this.$refs["form"].validate( valid => {
  163. if (valid) {
  164. if (this.form.id == undefined) {
  165. add(this.form).then(res =>{
  166. if(res.code == 200){
  167. this.$modal.msgSuccess("新增成功");
  168. this.dialogVisible = false
  169. this.cancal()
  170. this.getData()
  171. }
  172. })
  173. }else {
  174. edit().then(res =>{
  175. if(res.code == 200){
  176. this.$modal.msgSuccess("修改成功");
  177. this.dialogVisible = false
  178. }
  179. })
  180. }
  181. }
  182. })
  183. }
  184. },
  185. data() {
  186. return {
  187. dialogVisible:false,
  188. loading:false,
  189. tableHeight:'', //表格高度
  190. title:'',
  191. total:'',
  192. dataList:[],
  193. queryParams:{
  194. pageNum:1,
  195. pageSize:10,
  196. projectSource:''
  197. },
  198. form:{
  199. id:undefined,
  200. projectSource:''
  201. }
  202. }
  203. }
  204. }
  205. </script>
  206. <style lang="scss" scoped>
  207. </style>