Form_zhengbao.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="form-xuqiu">
  3. <div class="form-title">当前类型:项目整包</div>
  4. <el-form ref="modalForm" :model="modalFormData" :rules="rules" size="medium" label-width="100px">
  5. <div class="form-label">1.简短描述您的需求</div>
  6. <el-form-item label-width="0" prop="pro_descrption">
  7. <el-input v-model="modalFormData.pro_descrption" type="textarea" :placeholder="tips" show-word-limit :autosize="{ minRows: 10, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
  8. </el-form-item>
  9. <el-form-item label-width="0" prop="field103">
  10. <div class="form-label">
  11. <span style="margin-right:10px">我有附件要上传</span>
  12. <el-switch v-model="modalFormData.field103"></el-switch>
  13. </div>
  14. </el-form-item>
  15. <el-form-item label-width="0" prop="field104" v-show="modalFormData.field103">
  16. <el-upload class="upload-demo" :file-list="field104fileList" drag :show-file-list="true" action="/file/prepareUpload" :multiple="false" :http-request="uploadFile" :on-remove="remove">
  17. <i class="el-icon-upload"></i>
  18. <div class="el-upload__text">
  19. 将文件拖到此处,或<em>点击上传</em>传需求文档
  20. </div>
  21. </el-upload>
  22. </el-form-item>
  23. <div class="form-label">2.您的预算大概多少?</div>
  24. <el-row :gutter="15">
  25. <el-col :span="6">
  26. <el-form-item label-width="0" prop="budget">
  27. <el-input v-model="modalFormData.budget" placeholder="请输入预算" clearable :style="{width: '100%'}">
  28. <template slot="append">元</template>
  29. </el-input>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. <el-form-item label-width="0" prop="is_need_manager">
  34. <div class="form-label">
  35. <span style="margin-right:10px">我需要项目经理</span>
  36. <el-switch v-model="modalFormData.is_need_manager"></el-switch>
  37. <el-popover placement="right" width="250" trigger="hover">
  38. <div class="form-tooltip">
  39. 合理的项目分析和规划将提高34.7%的项目成功率<br /><br />
  40. 预计将支出5-10%项目费用,具体费用将由客户经理和您沟通
  41. </div>
  42. <i class="el-icon-info form-info-icon" slot="reference"></i>
  43. </el-popover>
  44. </div>
  45. </el-form-item>
  46. <el-form-item size="large">
  47. <div class="form-submit-area">
  48. <el-button type="primary" @click="submitForm">确定</el-button>
  49. </div>
  50. </el-form-item>
  51. </el-form>
  52. </div>
  53. </template>
  54. <script>
  55. import uploadFile from "@/mixins/uploadFile";
  56. export default {
  57. components: {},
  58. props: [],
  59. data() {
  60. return {
  61. modalFormData: {
  62. pro_descrption: "",
  63. field103: false,
  64. field104: null,
  65. is_need_manager: false,
  66. budget: ""
  67. },
  68. rules: {
  69. pro_descrption: [{
  70. required: true,
  71. message: "请输入您的需求",
  72. trigger: "blur"
  73. }]
  74. },
  75. field104Action: "",
  76. field104fileList: [],
  77. successUploadFileMap: {},
  78. tips: `可参考以下内容:\n1、您的产品/公司/业务的简短介绍\n2、需求的核心工作内容\n3、对开发者的其他需求`
  79. };
  80. },
  81. computed: {},
  82. watch: {
  83. modalFormData: {
  84. deep: true,
  85. handler: function (val) {
  86. if (!val.field103) {
  87. this.field104fileList = []
  88. }
  89. this.$emit("formChange", 2, "process");
  90. }
  91. }
  92. },
  93. created() {},
  94. mounted() {
  95. this.$emit("formChange", 2, "process");
  96. },
  97. mixins: [uploadFile],
  98. methods: {
  99. submitForm() {
  100. this.$refs["modalForm"].validate(valid => {
  101. if (!valid) return;
  102. // TODO 提交表单
  103. this.requestSubmit();
  104. });
  105. },
  106. resetForm() {
  107. this.$refs["modalForm"].resetFields();
  108. },
  109. uploadFile(file, type) {
  110. this.uploading = true;
  111. this.apiPrepareUpload(
  112. file.file,
  113. res => {
  114. if (res.data && res.data.status === 1) {
  115. let uploadId = res.data.data._upload_id;
  116. let url = res.data.data.url;
  117. this.field104fileList.push({
  118. data: {
  119. ...res.data.data
  120. },
  121. name: res.data.data.name,
  122. url: url,
  123. uploadId: uploadId
  124. });
  125. this.$message.success("上传成功");
  126. } else {
  127. this.$message.error("上传失败");
  128. }
  129. },
  130. 4
  131. );
  132. return false;
  133. },
  134. remove(file, fileList) {
  135. this.field104fileList = [...fileList];
  136. // console.log(111,file, fileList)
  137. },
  138. async requestSubmit() {
  139. let params = {
  140. is_package: 1,
  141. // hotsale_id:0,
  142. pro_name: "项目整包",
  143. // budget:0,
  144. pro_descrption: "",
  145. budget: 0,
  146. projectfiles: []
  147. };
  148. if (this.field104fileList.length > 0) {
  149. let arr = this.field104fileList.map(item => {
  150. return {
  151. ...item.data
  152. };
  153. });
  154. params["projectfiles"] = JSON.stringify(arr);
  155. }
  156. params["pro_descrption"] = this.modalFormData.pro_descrption;
  157. params["budget"] = this.modalFormData.budget;
  158. params["is_need_manager"] = this.modalFormData.is_need_manager == 1 ? 1 : 0;
  159. let that = this;
  160. this.$axios
  161. .$post(
  162. "/api/project/publish", {
  163. ...params
  164. }
  165. )
  166. .then(res => {
  167. if (Number(res.status) === 1) {
  168. this.$message.success("提交成功");
  169. this.$emit('formSubmit', 2, res.data)
  170. } else {
  171. this.$message.error("提交失败");
  172. }
  173. });
  174. }
  175. }
  176. };
  177. </script>
  178. <style lang="scss">
  179. .form-xuqiu {
  180. margin: 80px 80px 0;
  181. }
  182. .form-title {
  183. font-size: 22px;
  184. font-weight: 500;
  185. color: #0b121a;
  186. line-height: 30px;
  187. margin-bottom: 40px;
  188. }
  189. .form-label {
  190. height: 30px;
  191. line-height: 30px;
  192. font-size: 13px;
  193. font-family: PingFangSC-Medium;
  194. font-weight: 500;
  195. color: #19222e;
  196. }
  197. .form-submit-area {
  198. text-align: center;
  199. }
  200. .form-info-icon {
  201. color: #409EFF;
  202. font-size: 18px;
  203. cursor: pointer;
  204. position: relative;
  205. top: 5px;
  206. }
  207. .form-tooltip {
  208. width: 200px;
  209. line-height: 2em;
  210. }
  211. </style>