SysLabelManager.vue 2.6 KB

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