EquipmentManager.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div>
  3. <div class="operation">
  4. <el-button type="primary" @click="goEdit({id:0})" size="mini">添加</el-button>
  5. </div>
  6. <el-table :data="items">
  7. <el-table-column label="名称" prop="name"></el-table-column>
  8. <el-table-column label="图片" width="110px">
  9. <template slot-scope="scope">
  10. <img :src="scope.row.icon" style="width:100px;" />
  11. </template>
  12. </el-table-column>
  13. <el-table-column label="标题" prop="title"></el-table-column>
  14. <el-table-column label="状态">
  15. <template slot-scope="scope">
  16. <template v-if="scope.row.status === 1">
  17. <p class="online">启用</p>
  18. </template>
  19. <template v-else>
  20. <p class="offline">禁用</p>
  21. </template>
  22. </template>
  23. </el-table-column>
  24. <el-table-column label="操作">
  25. <template slot-scope="scope">
  26. <template v-if="scope.row.status == 0">
  27. <el-button type="success" @click="setStatus(scope.row)" size="mini">启用</el-button>
  28. </template>
  29. <template v-else>
  30. <el-button type="danger" @click="setStatus(scope.row)" size="mini">禁用</el-button>
  31. </template>
  32. <el-button type="text" size="small" @click="goEdit(scope.row)">编辑</el-button>
  33. </template>
  34. </el-table-column>
  35. </el-table>
  36. </div>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. items: []
  43. };
  44. },
  45. methods: {
  46. getItems: function() {
  47. this.$http.equipmentList({}, this).then(res => {
  48. if (res.code === 0) {
  49. this.items = res.obj;
  50. }
  51. });
  52. },
  53. setStatus: function(row) {
  54. var status = row.status === 1 ? 0 : 1;
  55. var msg = status === 1 ? "启用" : "禁用";
  56. this.$confirm(
  57. '您确定要将此医生设置为 "' + msg + '" , 是否继续?',
  58. "提示",
  59. {
  60. confirmButtonText: "确定",
  61. cancelButtonText: "取消",
  62. type: "warning"
  63. }
  64. ).then(() => {
  65. this.$http
  66. .equipmentSetStatus({ id: row.id, status: status }, this)
  67. .then(res => {
  68. if (res.code === 0) {
  69. this.$message({
  70. message: "操作成功",
  71. type: "success"
  72. });
  73. row.status = status;
  74. }
  75. });
  76. });
  77. },
  78. goEdit: function(row) {
  79. this.$router.push({ path: "/editEquipment", query: { id: row.id } });
  80. }
  81. },
  82. mounted: function() {
  83. this.getItems();
  84. }
  85. };
  86. </script>
  87. <style scoped>
  88. .online {
  89. color: #67c23a;
  90. }
  91. .offline {
  92. color: #f56c6c;
  93. }
  94. .operation {
  95. height: 50px;
  96. border-bottom: 1px solid #e6e6e6;
  97. margin-bottom: 10px;
  98. }
  99. </style>