quickComment.jsp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <html>
  3. <head>
  4. <jsp:include page="head.jsp"/>
  5. <title>领先共享汽车</title>
  6. <style>.avatar-uploader .el-upload {
  7. border: 1px dashed #d9d9d9;
  8. border-radius: 6px;
  9. cursor: pointer;
  10. position: relative;
  11. overflow: hidden;
  12. }
  13. .avatar-uploader .el-upload:hover {
  14. border-color: #20a0ff;
  15. }
  16. .avatar-uploader-icon {
  17. font-size: 28px;
  18. color: #8c939d;
  19. width: 178px;
  20. height: 178px;
  21. line-height: 178px;
  22. text-align: center;
  23. }
  24. .avatar {
  25. width: 178px;
  26. height: 178px;
  27. display: block;
  28. }
  29. </style>
  30. </head>
  31. <body>
  32. <jsp:include page="contentBefore.jsp"/>
  33. <template>
  34. <el-form ref="form" :model="row_info" label-width="80px">
  35. <el-form-item label="评论">
  36. <el-input v-model="row_info.comment"></el-input>
  37. </el-form-item>
  38. <el-form-item label="星级">
  39. <el-input v-model="row_info.starLevel"></el-input>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" @click="onSubmit">{{edit?'保存':'立即创建'}}</el-button>
  43. <el-button>取消</el-button>
  44. </el-form-item>
  45. </el-form>
  46. </template>
  47. <jsp:include page="contentAfter.jsp"/>
  48. </body>
  49. <script>
  50. function getQueryString(name) {
  51. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  52. var r = window.location.search.substr(1).match(reg);
  53. if (r != null) return unescape(r[2]);
  54. return null;
  55. }
  56. new Vue({
  57. el: '#app',
  58. created: function () {
  59. var id = getQueryString('id');
  60. if (id) {
  61. $.get({
  62. url: '../quickComment/getQuickComment',
  63. data: {
  64. id: id
  65. }
  66. }).then(function (res) {
  67. if (res.success) {
  68. this.edit = true;
  69. this.row_info = res.data;
  70. }
  71. }.bind(this));
  72. }
  73. },
  74. data: function () {
  75. return {
  76. menu: '7-1',
  77. user: {
  78. id: '',
  79. username: 'admin',
  80. avatar: ''
  81. },
  82. loading: false,
  83. edit: false,
  84. tab: 1,
  85. row_info : {
  86. starLevel : 5
  87. },
  88. };
  89. },
  90. methods: {
  91. logout: function () {
  92. this.$confirm('确定要注销吗?', '提示', {
  93. confirmButtonText: '确定',
  94. cancelButtonText: '取消',
  95. type: 'info'
  96. }).then(function () {
  97. localStorage.removeItem('user');
  98. this.$router.push({path: '/login'});
  99. }.bind(this)).catch(function (e) {
  100. });
  101. },
  102. onSubmit: function () {
  103. if (!this.row_info.comment) {
  104. this.$message.warning('请填写评论');
  105. } else {
  106. var data = JSON.parse(JSON.stringify(this.row_info));
  107. $.post({
  108. url: this.edit ? '../quickComment/update' : '../quickComment/save',
  109. data: data
  110. }).then(function (res) {
  111. if (res.success) {
  112. if (!this.edit) {
  113. this.row_info.id = res.data;
  114. }
  115. this.edit = true;
  116. this.$message.success(this.edit ? '保存成功' : '创建成功');
  117. } else {
  118. this.$message.error(this.edit ? '保存失败' : '创建失败');
  119. }
  120. }.bind(this))
  121. }
  122. },
  123. }
  124. })
  125. </script>
  126. </html>