positionEdit.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div class="app-container">
  3. <el-form ref="form" :model="cooperationsForm" :rules="rules" label-width="100px">
  4. <el-form-item label="职位名称" prop="title">
  5. <el-input v-model="cooperationsForm.title" placeholder="请输入客户名称" clearable></el-input>
  6. </el-form-item>
  7. <el-form-item label="职位图片" prop="image">
  8. <el-upload ref="upload" action="customize" :http-request="uploadDiscardFile" :limit="1" :before-remove="beforeRemove">
  9. <el-button size="small" type="primary" :loading="loading">上传一张图片</el-button>
  10. </el-upload>
  11. </el-form-item>
  12. <el-form-item label="职位信息" prop="introduction">
  13. <tinymce v-model="cooperationsForm.introduction" :height="300" />
  14. </el-form-item>
  15. </el-form>
  16. <span slot="footer" class="dialog-footer" style="float:right;">
  17. <el-button @click="$router.go(-1);">取消</el-button>
  18. <el-button type="primary" @click="addCooperation()" :loading="loading">提交</el-button>
  19. </span>
  20. </div>
  21. </template>
  22. <script>
  23. import request from "@/utils/request";
  24. import Tinymce from "@/components/Tinymce";
  25. export default {
  26. name: "TinymceDemo",
  27. components: { Tinymce },
  28. data() {
  29. return {
  30. id: this.$route.params.id,
  31. loading: false,
  32. cooperations: [],
  33. cooperationsForm: {
  34. id: null,
  35. title: null,
  36. introduction: null,
  37. image: null,
  38. },
  39. rules: {
  40. title: [{ required: true, message: "请输入职位名称", trigger: "blur" }],
  41. introduction: [{ required: true, message: "请输入职位信息", trigger: "blur"}],
  42. },
  43. };
  44. },
  45. methods: {
  46. //打开对话框
  47. openDialog(isEdit, index) {
  48. this.editing = isEdit;
  49. if (this.editing) {
  50. this.cooperationsForm.id = this.cooperations[index].id;
  51. this.cooperationsForm.title = this.cooperations[index].companyName;
  52. this.cooperationsForm.title1 = this.cooperations[index].companyName;
  53. this.cooperationsForm.introduction = this.cooperations[index].description;
  54. this.cooperationsForm.image = null;
  55. } else {
  56. this.cooperationsForm.id = null;
  57. this.cooperationsForm.title = "";
  58. this.cooperationsForm.title1 = "";
  59. this.cooperationsForm.introduction = "";
  60. this.cooperationsForm.image = null;
  61. }
  62. },
  63. //获取合作信息
  64. getCooperations() {
  65. this.loading = true;
  66. request({
  67. url: "/feedback/listFeedback",
  68. method: "post",
  69. params: {pageIndex:1,pageSize: 9999999}
  70. })
  71. .then(response => {
  72. this.cooperations = response.data;
  73. this.loading = false;
  74. })
  75. .catch(error => {
  76. this.$message({
  77. message: error,
  78. type: "error"
  79. });
  80. this.loading = false;
  81. });
  82. },
  83. //添加/编辑合作信息
  84. addCooperation() {
  85. this.$refs.form.validate(valid => {
  86. if (valid) {
  87. this.loading = true;
  88. var form = new FormData();
  89. form.append("title", this.cooperationsForm.title);
  90. form.append("content", this.cooperationsForm.introduction);
  91. if (this.cooperationsForm.image == null && this.editing == false) {
  92. this.loading =false;
  93. this.$message({
  94. message: "尚未上传图片",
  95. type: "error"
  96. });
  97. return;
  98. } else if (this.cooperationsForm.image != null) {
  99. form.append("file", this.cooperationsForm.image);
  100. }
  101. if (this.cooperationsForm.id != null) {
  102. form.append("id", this.cooperationsForm.id);
  103. }
  104. request({
  105. url: "/feedback/insertOrUpdateFeedback",
  106. method: "post",
  107. data: form
  108. })
  109. .then(response => {
  110. this.$refs.upload.clearFiles();
  111. this.loading = false;
  112. this.$message({
  113. message: this.cooperationsForm.id != null?"修改成功":"添加成功",
  114. type: "success"
  115. });
  116. this.$router.go(-1);
  117. })
  118. .catch(error => {
  119. this.$message({
  120. message: error,
  121. type: "error"
  122. });
  123. this.loading = false;
  124. });
  125. }
  126. });
  127. },
  128. //文件上传的部分操作
  129. uploadDiscardFile(params) {
  130. this.cooperationsForm.image = params.file;
  131. return false;
  132. },
  133. //文件上传的移除操作
  134. beforeRemove(params) {
  135. this.cooperationsForm.image = null;
  136. }
  137. },
  138. mounted() {
  139. if(this.id != 0) {
  140. this.getCooperations();
  141. }
  142. }
  143. };
  144. </script>
  145. <style scoped>
  146. </style>