serviceInfo.jsp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <html>
  3. <head>
  4. <jsp:include page="head.jsp"/>
  5. <script type="text/javascript" src="${pageContext.request.contextPath}/ueditor/ueditor.config.js"></script>
  6. <script type="text/javascript" src="${pageContext.request.contextPath}/ueditor/ueditor.all.js"></script>
  7. <title>领先共享汽车</title>
  8. <style>.avatar-uploader .el-upload {
  9. border: 1px dashed #d9d9d9;
  10. border-radius: 6px;
  11. cursor: pointer;
  12. position: relative;
  13. overflow: hidden;
  14. }
  15. .avatar-uploader .el-upload:hover {
  16. border-color: #20a0ff;
  17. }
  18. .avatar-uploader-icon {
  19. font-size: 28px;
  20. color: #8c939d;
  21. width: 178px;
  22. height: 178px;
  23. line-height: 178px;
  24. text-align: center;
  25. }
  26. .avatar {
  27. width: 178px;
  28. height: 178px;
  29. display: block;
  30. }
  31. </style>
  32. </head>
  33. <body>
  34. <jsp:include page="contentBefore.jsp"/>
  35. <template>
  36. <el-form ref="form" :model="row_info" label-width="80px">
  37. <el-form-item label="图片">
  38. <el-upload
  39. class="avatar-uploader"
  40. action="../assets/uploadFile"
  41. :show-file-list="false"
  42. :on-success="contactAvatarSuccess">
  43. <img v-if="avatar" :src="avatar" class="avatar">
  44. <i v-else class="el-icon-plus avatar-uploader-icon"></i>
  45. </el-upload>
  46. </el-form-item>
  47. <el-form-item label="标题">
  48. <el-input v-model="row_info.title"></el-input>
  49. </el-form-item>
  50. <el-form-item
  51. label="服务">
  52. <el-select v-model="row_info.serviceType" clearable filterable placeholder="请选择服务">
  53. <el-option
  54. v-for="item in serviceTypes"
  55. :key="item.id"
  56. :label="item.typeName"
  57. :value="item.id">
  58. </el-option>
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="价格">
  62. <el-input v-model="row_info.price"></el-input>
  63. </el-form-item>
  64. <el-form-item label="工作时长">
  65. <el-input v-model="row_info.workMinute"></el-input>
  66. </el-form-item>
  67. <el-form-item label="摘要">
  68. <el-input v-model="row_info.abstractText" type="textarea" :rows="2"></el-input>
  69. </el-form-item>
  70. <el-form-item label="服务内容">
  71. <el-input v-model="row_info.preface" type="textarea" :rows="2"></el-input>
  72. </el-form-item>
  73. <el-form-item label="内容">
  74. <script id="container" name="content" type="text/plain"></script>
  75. </el-form-item>
  76. <el-form-item>
  77. <el-button type="primary" @click="onSubmit">{{edit?'保存':'立即创建'}}</el-button>
  78. <el-button>取消</el-button>
  79. </el-form-item>
  80. </el-form>
  81. </template>
  82. <jsp:include page="contentAfter.jsp"/>
  83. </body>
  84. <script>
  85. function getQueryString(name) {
  86. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  87. var r = window.location.search.substr(1).match(reg);
  88. if (r != null) return unescape(r[2]);
  89. return null;
  90. }
  91. new Vue({
  92. el: '#app',
  93. created: function () {
  94. $.get({
  95. url: '../serviceType/all'
  96. }).then(function (res) {
  97. this.serviceTypes = res.data;
  98. }.bind(this));
  99. var id = getQueryString('id');
  100. if (id) {
  101. $.get({
  102. url: '../serviceInfo/getServiceInfo',
  103. data: {
  104. id: id
  105. }
  106. }).then(function (res) {
  107. if (res.success) {
  108. this.edit = true;
  109. this.row_info = res.data;
  110. if (res.data.realImage) {
  111. this.avatar = res.data.realImage;
  112. }
  113. var ue = this.editor;
  114. ue.addListener("ready", function () {
  115. //var arr = [];
  116. //arr.push("使用editor.setContent('欢迎使用ueditor')方法可以设置编辑器的内容");
  117. ue.setContent(res.data.content, false);
  118. });
  119. }
  120. }.bind(this));
  121. }
  122. },
  123. data: function () {
  124. return {
  125. menu: '8-1',
  126. user: {
  127. id: '',
  128. username: 'admin',
  129. avatar: ''
  130. },
  131. loading: false,
  132. edit: false,
  133. tab: 1,
  134. row_info : {
  135. realImage:'',
  136. serviceType :''
  137. },
  138. serviceTypes : [],
  139. dialogImageUrl: '',
  140. dialogVisible: false,
  141. avatar: '',
  142. editor: null,
  143. };
  144. },
  145. mounted: function () {
  146. this.editor = UE.getEditor('container', {
  147. toolbars: [[
  148. 'fullscreen',
  149. 'source',
  150. 'undo',
  151. 'redo',
  152. 'bold',
  153. 'insertimage',
  154. 'justify',
  155. 'justifyleft', //居左对齐
  156. 'justifyright', //居右对齐
  157. 'justifycenter', //居中对齐
  158. 'justifyjustify' //两端对齐
  159. ]],
  160. pasteplain: true,
  161. retainOnlyLabelPasted: true
  162. });
  163. },
  164. methods: {
  165. logout: function () {
  166. this.$confirm('确定要注销吗?', '提示', {
  167. confirmButtonText: '确定',
  168. cancelButtonText: '取消',
  169. type: 'info'
  170. }).then(function () {
  171. localStorage.removeItem('user');
  172. this.$router.push({path: '/login'});
  173. }.bind(this)).catch(function (e) {
  174. });
  175. },
  176. onSubmit: function () {
  177. if (!this.row_info.title) {
  178. this.$message.warning('请填写标题');
  179. } else {
  180. var data = JSON.parse(JSON.stringify(this.row_info));
  181. data.content = this.editor.getContent();
  182. delete data.realImage;
  183. $.post({
  184. url: this.edit ? '../serviceInfo/update' : '../serviceInfo/save',
  185. data: data
  186. }).then(function (res) {
  187. if (res.success) {
  188. if (!this.edit) {
  189. this.row_info.id = res.data;
  190. }
  191. this.edit = true;
  192. this.$message.success(this.edit ? '保存成功' : '创建成功');
  193. } else {
  194. this.$message.error(this.edit ? '保存失败' : '创建失败');
  195. }
  196. }.bind(this))
  197. }
  198. },
  199. handlePictureCardPreview: function (file) {
  200. this.dialogImageUrl = file.url;
  201. this.dialogVisible = true;
  202. },
  203. contactAvatarSuccess: function (res, file, fileList) {
  204. if (res.success) {
  205. this.row_info.image = res.data[0];
  206. }
  207. this.avatar = URL.createObjectURL(file.raw);
  208. },
  209. }
  210. })
  211. </script>
  212. </html>