Form_xuqiu.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. <!-- <div class="el-upload__tip" slot="tip">
  22. 拖拽或点击上
  23. </div> -->
  24. </el-upload>
  25. </el-form-item>
  26. <el-form-item size="large">
  27. <div class="form-submit-area">
  28. <el-button type="primary" @click="submitForm">确定</el-button>
  29. </div>
  30. </el-form-item>
  31. </el-form>
  32. </div>
  33. </template>
  34. <script>
  35. import uploadFile from "@/mixins/uploadFile";
  36. export default {
  37. components: {},
  38. props: [],
  39. data() {
  40. return {
  41. modalFormData: {
  42. pro_descrption: "",
  43. field103: false,
  44. field104: null
  45. },
  46. rules: {
  47. pro_descrption: [{
  48. required: true,
  49. message: "请输入您的需求",
  50. trigger: "blur"
  51. }]
  52. },
  53. field104Action: "",
  54. field104fileList: [],
  55. successUploadFileMap: {},
  56. tips: `可参考以下内容:\n1、您的产品/公司/业务的简短介绍\n2、需求的核心工作内容\n3、对开发者的其他需求`
  57. };
  58. },
  59. computed: {},
  60. watch: {
  61. modalFormData: {
  62. deep: true,
  63. handler: function (val) {
  64. if(!val.field103){
  65. this.field104fileList = []
  66. }
  67. this.$emit("formChange", 2, "process");
  68. }
  69. }
  70. },
  71. created() {},
  72. mounted() {
  73. this.$emit("formChange", 2, "process");
  74. },
  75. mixins: [uploadFile],
  76. methods: {
  77. submitForm() {
  78. this.$refs["modalForm"].validate(valid => {
  79. if (!valid) return;
  80. // TODO 提交表单
  81. this.requestSubmit();
  82. });
  83. },
  84. resetForm() {
  85. this.$refs["modalForm"].resetFields();
  86. },
  87. uploadFile(file, type) {
  88. this.uploading = true;
  89. this.apiPrepareUpload(
  90. file.file,
  91. res => {
  92. if (res.data && res.data.status === 1) {
  93. let uploadId = res.data.data._upload_id;
  94. let url = res.data.data.url;
  95. this.field104fileList.push({
  96. data: {
  97. ...res.data.data
  98. },
  99. name: res.data.data.name,
  100. url: url,
  101. uploadId: uploadId
  102. });
  103. this.$message.success("上传成功");
  104. } else {
  105. this.$message.error("上传失败");
  106. }
  107. },
  108. 4
  109. );
  110. return false;
  111. },
  112. remove(file, fileList) {
  113. this.field104fileList = [...fileList];
  114. // console.log(111,file, fileList)
  115. },
  116. async requestSubmit() {
  117. let params = {
  118. is_package: 1,
  119. // hotsale_id:0,
  120. pro_name: "需求梳理",
  121. // budget:0,
  122. pro_descrption: 0,
  123. projectfiles: []
  124. };
  125. if (this.field104fileList.length > 0) {
  126. let arr = this.field104fileList.map(item => {
  127. return {
  128. ...item.data
  129. };
  130. });
  131. params["projectfiles"] = JSON.stringify(arr);
  132. }
  133. params["pro_descrption"] = this.modalFormData.pro_descrption;
  134. let that = this;
  135. this.$axios
  136. .$post(
  137. "/api/project/publish", {
  138. ...params
  139. }
  140. )
  141. .then(res => {
  142. if (Number(res.status) === 1) {
  143. this.$message.success("提交成功");
  144. this.$emit('formSubmit', 2, res.data)
  145. } else {
  146. this.$message.error("提交失败");
  147. }
  148. });
  149. }
  150. }
  151. };
  152. </script>
  153. <style lang="scss">
  154. .form-xuqiu {
  155. margin: 80px 80px 0;
  156. }
  157. .form-title {
  158. font-size: 22px;
  159. font-weight: 500;
  160. color: #0b121a;
  161. line-height: 30px;
  162. margin-bottom: 40px;
  163. }
  164. .form-label {
  165. height: 30px;
  166. line-height: 30px;
  167. font-size: 13px;
  168. font-family: PingFangSC-Medium;
  169. font-weight: 500;
  170. color: #19222e;
  171. }
  172. .form-submit-area {
  173. text-align: center;
  174. }
  175. </style>