Form_zhengbao.vue 7.7 KB

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