form.ftl 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>展商</title>
  5. <#include "../../include/head-file.ftl">
  6. </head>
  7. <body>
  8. <div id="form" v-cloak>
  9. <el-header class="ms-header ms-tr" height="50px">
  10. <el-button type="primary" class="iconfont icon-baocun" size="default" @click="save()" :loading="saveDisabled">保存</el-button>
  11. <el-button size="default" class="iconfont icon-fanhui" plain @click="back()">返回</el-button>
  12. </el-header>
  13. <el-main class="ms-container" v-loading="loading">
  14. <el-form ref="form" :model="form" :rules="rules" label-width="120px" label-position="right" size="default">
  15. <!--公司名称-->
  16. <el-form-item label="公司名称" prop="exhibitorName">
  17. <el-input
  18. v-model="form.exhibitorName"
  19. :disabled="false"
  20. :readonly="false"
  21. :style="{width: '100%'}"
  22. :clearable="true"
  23. placeholder="请输入公司名称">
  24. </el-input>
  25. </el-form-item>
  26. <!--展位号-->
  27. <el-form-item label="展位号" prop="exhibitorBooth">
  28. <el-input
  29. v-model="form.exhibitorBooth"
  30. :disabled="false"
  31. :readonly="false"
  32. :style="{width: '100%'}"
  33. :clearable="true"
  34. placeholder="请输入展位号">
  35. </el-input>
  36. </el-form-item>
  37. <!--联系人-->
  38. <el-form-item label="联系人" prop="exhibitorContact">
  39. <el-input
  40. v-model="form.exhibitorContact"
  41. :disabled="false"
  42. :readonly="false"
  43. :style="{width: '100%'}"
  44. :clearable="true"
  45. placeholder="请输入联系人">
  46. </el-input>
  47. </el-form-item>
  48. <!--联系电话-->
  49. <el-form-item label="联系电话" prop="exhibitorPhone">
  50. <el-input
  51. v-model="form.exhibitorPhone"
  52. :disabled="false"
  53. :readonly="false"
  54. :style="{width: '100%'}"
  55. :clearable="true"
  56. placeholder="请输入联系电话">
  57. </el-input>
  58. </el-form-item>
  59. <!--公司LOGO-->
  60. <el-form-item label="公司LOGO" prop="exhibitorLogo">
  61. <el-upload
  62. :file-list="form.exhibitorLogo"
  63. :action="ms.manager+'/file/upload.do'"
  64. :limit="1"
  65. multiple
  66. :disabled="false"
  67. :data="{uploadPath:'/tf/','isRename':true,'appId':true}"
  68. :on-remove="exhibitorLogoHandleRemove"
  69. :on-exceed="exhibitorLogoHandleExceed"
  70. :on-preview="exhibitorLogoHandlePreview"
  71. :before-upload="exhibitorLogoBeforeUpload"
  72. :on-success="exhibitorLogoSuccess"
  73. :on-error="exhibitorLogoError"
  74. accept="image/*"
  75. list-type="picture-card">
  76. <i class="el-icon-plus"></i>
  77. <template #tip>
  78. <div class="el-upload__tip">最多上传1张图片</div>
  79. </template>
  80. </el-upload>
  81. </el-form-item>
  82. <!--公司简介-->
  83. <el-form-item label="公司简介" prop="exhibitorIntroduction">
  84. <el-input
  85. type="textarea" :rows="5"
  86. :disabled="false"
  87. v-model="form.exhibitorIntroduction"
  88. :style="{width: '100%'}"
  89. placeholder="请输入公司简介">
  90. </el-input>
  91. </el-form-item>
  92. <!--用户ID-->
  93. <!--展会ID-->
  94. <!--邀请码-->
  95. </el-form>
  96. </el-main>
  97. </div>
  98. </body>
  99. </html>
  100. <script>
  101. var formVue = new _Vue({
  102. el: '#form',
  103. data:function() {
  104. return {
  105. loading:false,
  106. saveDisabled: false,
  107. //表单数据
  108. form: {
  109. // 公司名称
  110. exhibitorName:'',
  111. // 展位号
  112. exhibitorBooth:'',
  113. // 联系人
  114. exhibitorContact:'',
  115. // 联系电话
  116. exhibitorPhone:'',
  117. // 公司LOGO
  118. exhibitorLogo: [],
  119. // 公司简介
  120. exhibitorIntroduction:'',
  121. // 用户ID
  122. exhibitorUser:'',
  123. // 展会ID
  124. exhibitorActivities:'',
  125. // 邀请码
  126. exhibitorCode:'',
  127. },
  128. rules:{
  129. // 公司名称
  130. exhibitorName: [{"required":true,"message":"公司名称不能为空"},{"min":0,"max":255,"message":"公司名称长度必须为0-255"}],
  131. // 展位号
  132. exhibitorBooth: [{"required":true,"message":"展位号不能为空"},{"min":0,"max":255,"message":"展位号长度必须为0-255"}],
  133. // 联系人
  134. exhibitorContact: [{"min":0,"max":255,"message":"联系人长度必须为0-255"}],
  135. // 联系电话
  136. exhibitorPhone: [{"min":0,"max":255,"message":"联系电话长度必须为0-255"}],
  137. // 用户ID
  138. exhibitorUser: [{"min":0,"max":255,"message":"用户ID长度必须为0-255"}],
  139. // 展会ID
  140. exhibitorActivities: [{"min":0,"max":255,"message":"展会ID长度必须为0-255"}],
  141. // 邀请码
  142. exhibitorCode: [{"min":0,"max":255,"message":"邀请码长度必须为0-255"}],
  143. },
  144. }
  145. },
  146. watch:{
  147. },
  148. components:{
  149. },
  150. computed:{
  151. },
  152. methods: {
  153. back: function (){
  154. ms.util.openSystemUrl("/tf/exhibitor/index.do",true);
  155. },
  156. save:function() {
  157. var that = this;
  158. var url = ms.manager + "/tf/exhibitor/save.do"
  159. if (that.form.id > 0) {
  160. url = ms.manager + "/tf/exhibitor/update.do";
  161. }
  162. this.$refs.form.validate(function(valid) {
  163. if (valid) {
  164. that.saveDisabled = true;
  165. var form = JSON.parse(JSON.stringify(that.form));
  166. if (form.exhibitorLogo.length>0) {
  167. form.exhibitorLogo.forEach(function (value) {
  168. value.url = value.url.replace(new RegExp('^'+ms.contextpath), "");
  169. });
  170. form.exhibitorLogo = JSON.stringify(form.exhibitorLogo);
  171. } else {
  172. form.exhibitorLogo = '';
  173. }
  174. ms.http.post(url, form).then(function (res) {
  175. if (res.result) {
  176. that.$notify({
  177. title: "成功",
  178. message: "保存成功",
  179. type: 'success'
  180. });
  181. ms.util.openSystemUrl("/tf/exhibitor/index.do",that.form.id > 0);
  182. } else {
  183. that.$notify({
  184. title: "错误",
  185. message: res.msg,
  186. type: 'warning'
  187. });
  188. }
  189. that.saveDisabled = false;
  190. }).catch(function (err) {
  191. console.log(err);
  192. that.saveDisabled = false;
  193. });
  194. } else {
  195. return false;
  196. }
  197. })
  198. },
  199. //获取当前展商
  200. get:function(id) {
  201. var that = this;
  202. this.loading = true
  203. ms.http.get(ms.manager + "/tf/exhibitor/get.do", {"id":id}).then(function (res) {
  204. that.loading = false
  205. if(res.result&&res.data) {
  206. if (res.data.exhibitorLogo) {
  207. res.data.exhibitorLogo = JSON.parse(res.data.exhibitorLogo);
  208. res.data.exhibitorLogo.forEach(function (value) {
  209. if(!value.url.startsWith("http://") && !value.url.startsWith("https://")){
  210. value.url = ms.contextpath + value.url;
  211. }
  212. });
  213. } else {
  214. res.data.exhibitorLogo = [];
  215. }
  216. that.form = res.data;
  217. }
  218. });
  219. },
  220. // exhibitorLogo删除
  221. exhibitorLogoHandleRemove: function (file, files) {
  222. var index = -1;
  223. index = this.form.exhibitorLogo.findIndex(function (text) {
  224. return text.uid == file.uid;
  225. });
  226. if (index != -1) {
  227. this.form.exhibitorLogo.splice(index, 1);
  228. }
  229. },
  230. //exhibitorLogo上传超过限制
  231. exhibitorLogoHandleExceed: function (files, fileList) {
  232. this.$notify({
  233. title: '失败',
  234. message: '当前最多上传1个文件',
  235. type: 'warning'
  236. });
  237. },
  238. //exhibitorLogo预览
  239. exhibitorLogoHandlePreview: function (file){
  240. window.open(file.url);
  241. },
  242. //exhibitorLogo上传前
  243. exhibitorLogoBeforeUpload: function (file) {
  244. var type = file.type;
  245. if (type) {
  246. var isImage = type.startsWith('image/');
  247. if (!isImage) {
  248. this.$notify({
  249. title: '提示',
  250. message: '请上传图片类型文件',
  251. type: 'warning'
  252. });
  253. }
  254. return isImage;
  255. }
  256. return false;
  257. },
  258. //exhibitorLogo上传成功
  259. exhibitorLogoSuccess: function (response, file, fileList) {
  260. if (response.result) {
  261. if(!response.data.startsWith("http://") && !response.data.startsWith("https://")) {
  262. file.url = ms.contextpath + response.data;
  263. }else{
  264. file.url = response.data;
  265. }
  266. this.form.exhibitorLogo.push({
  267. url: response.data,
  268. name: file.name,
  269. uid: file.uid
  270. });
  271. } else {
  272. // 移除上传图片
  273. var index = fileList.indexOf(file);
  274. if (index > -1) {
  275. fileList.splice(index, 1);
  276. }
  277. this.$notify({
  278. title: '失败',
  279. message: response.msg,
  280. type: 'warning'
  281. });
  282. }
  283. },
  284. //exhibitorLogo上传失败
  285. exhibitorLogoError: function (response, file, fileList) {
  286. response = JSON.parse(response.message);
  287. this.$notify({
  288. title: '失败',
  289. message: response.msg,
  290. type: 'warning'
  291. });
  292. }, },
  293. created:function() {
  294. var that = this;
  295. this.form.id = ms.util.getParameter("id");
  296. if (this.form.id) {
  297. this.get(this.form.id);
  298. }
  299. }
  300. });
  301. </script>
  302. <style scoped>
  303. </style>