Form_yunduan.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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="match_directions">
  7. <el-cascader :options="directionData" clearable @change="directionChange"></el-cascader>
  8. </el-form-item>
  9. <div class="form-label">2.开发者需要具备哪些核心技能标签? (1-5个)</div>
  10. <el-form-item label-width="0" prop="skills">
  11. <el-select v-model="modalFormData.skills" @change="skillChange" multiple filterable remote :reserve-keyword="false" placeholder="输入后根据提示选择关键词" :remote-method="remoteMethod" :loading="loading" :style="{width: '50%'}">
  12. <el-option v-for="item in skills" :key="item.value" :label="item.label" :value="item.value">
  13. </el-option>
  14. </el-select>
  15. </el-form-item>
  16. <div class="form-label">3.您需要全职开发者吗?</div>
  17. <el-form-item label-width="0" prop="full">
  18. <el-radio-group v-model="modalFormData.full" size="medium">
  19. <el-radio v-for="(item, index) in fullOptions" :key="index" :label="item.value" :disabled="item.disabled">{{item.label}}</el-radio>
  20. </el-radio-group>
  21. <div v-if="modalFormData.full == 2" class="form-tips">会导致可选开发者变少</div>
  22. </el-form-item>
  23. <div class="form-label">4.您需要开发者驻场开发吗?</div>
  24. <el-form-item label-width="0" prop="is_incompany">
  25. <el-radio-group v-model="modalFormData.is_incompany" size="medium">
  26. <el-radio v-for="(item, index) in fullOptions" :key="index" :label="item.value" :disabled="item.disabled">{{item.label}}</el-radio>
  27. </el-radio-group>
  28. <div v-if="modalFormData.is_incompany == 1" class="form-tips">会导致可选开发者变少</div>
  29. <template v-if="modalFormData.is_incompany == 1">
  30. <div class="">我需要开发者来自以下地区</div>
  31. <el-cascader :options="cityData" clearable @change="cityChange"></el-cascader>
  32. </template>
  33. </el-form-item>
  34. <!-- <el-form-item label-width="0" prop="city">
  35. </el-form-item> -->
  36. <div class="form-label">5.简短描述您的需求</div>
  37. <el-form-item label-width="0" prop="description">
  38. <el-input v-model="modalFormData.description" type="textarea" :placeholder="tips" show-word-limit :autosize="{ minRows: 10, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
  39. </el-form-item>
  40. <el-form-item label-width="0" prop="field103">
  41. <div class="form-label">
  42. <span style="margin-right:10px">我有附件要上传</span>
  43. <el-switch v-model="modalFormData.field103"></el-switch>
  44. </div>
  45. </el-form-item>
  46. <el-form-item label-width="0" prop="field104" v-show="modalFormData.field103">
  47. <el-upload class="upload-demo" :file-list="field104fileList" drag :show-file-list="true" action="/file/prepareUpload" :multiple="false" :http-request="uploadFile" :on-remove="remove">
  48. <i class="el-icon-upload"></i>
  49. <div class="el-upload__text">
  50. 将文件拖到此处,或<em>点击上传</em>传需求文档
  51. </div>
  52. </el-upload>
  53. </el-form-item>
  54. <div class="form-label">6.您每月的预算大概多少?</div>
  55. <el-form-item label-width="0" prop="ys_money_type">
  56. <el-select v-model="modalFormData.ys_money_type" placeholder="请选择计划合作的预算" clearable :style="{width: '100%'}">
  57. <el-option v-for="(item, index) in ys_money_typeOptions" :key="index" :label="item.label" :value="item.value" :disabled="item.disabled"></el-option>
  58. </el-select>
  59. </el-form-item>
  60. <el-form-item label-width="0" prop="is_need_manager">
  61. <div class="form-label">
  62. <span style="margin-right:10px">我需要项目经理</span>
  63. <el-switch v-model="modalFormData.is_need_manager"></el-switch>
  64. <el-popover placement="right" width="250" trigger="hover">
  65. <div class="form-tooltip">
  66. 合理的项目分析和规划将提高34.7%的项目成功率<br /><br />
  67. 预计将支出5-10%项目费用,具体费用将由客户经理和您沟通
  68. </div>
  69. <i class="el-icon-info form-info-icon" slot="reference"></i>
  70. </el-popover>
  71. </div>
  72. </el-form-item>
  73. <el-form-item size="large">
  74. <div class="form-submit-area">
  75. <el-button type="primary" @click="submitForm">确定</el-button>
  76. </div>
  77. </el-form-item>
  78. </el-form>
  79. <Loading ref='loading'></Loading>
  80. </div>
  81. </template>
  82. <script>
  83. import uploadFile from "@/mixins/uploadFile";
  84. import Loading from './Loading.vue'
  85. function directionDataParse(arr) {
  86. arr = arr.sort(function (a, b) {
  87. return Number(a.display_order) - Number(b.display_order) > 0
  88. })
  89. let result = [];
  90. let len = arr.length
  91. for (let i = 0; i < len; i++) {
  92. let {
  93. children,
  94. ...other
  95. } = arr[i]
  96. let label = arr[i].occupation_name || arr[i].direction_name
  97. let value = arr[i].occupation_id || arr[i].direction_id
  98. let item
  99. if (children) {
  100. children = directionDataParse(children)
  101. item = {
  102. ...other,
  103. label,
  104. value,
  105. children
  106. }
  107. } else {
  108. item = {
  109. ...other,
  110. label,
  111. value
  112. }
  113. }
  114. result.push(item)
  115. }
  116. return result
  117. }
  118. function cityDataParse(arr) {
  119. let result = [];
  120. let len = arr.length
  121. for (let i = 0; i < len; i++) {
  122. let {
  123. child,
  124. ...other
  125. } = arr[i]
  126. let label = arr[i].name
  127. let value = arr[i].id || arr[i].id
  128. let item
  129. if (child && child.length > 0) {
  130. let children = cityDataParse(child)
  131. item = {
  132. ...other,
  133. label,
  134. value,
  135. children
  136. }
  137. } else {
  138. item = {
  139. ...other,
  140. label,
  141. value
  142. }
  143. }
  144. result.push(item)
  145. }
  146. return result
  147. }
  148. export default {
  149. components: {
  150. Loading
  151. },
  152. props: [],
  153. data() {
  154. return {
  155. modalFormData: {
  156. match_directions: "",
  157. direction_id: "",
  158. skills: [],
  159. description: "",
  160. field103: false,
  161. field104: null,
  162. is_need_manager: false,
  163. budget: "",
  164. full: 0,
  165. is_incompany: 0,
  166. city: "",
  167. province_id: "",
  168. city_id: "",
  169. ys_money_type: "",
  170. },
  171. rules: {
  172. description: [{
  173. required: true,
  174. message: "请输入您的需求",
  175. trigger: "blur"
  176. }],
  177. ys_money_type: [{
  178. required: true,
  179. message: "请选择您的预算",
  180. trigger: "blur"
  181. }],
  182. match_directions: [{
  183. required: true,
  184. message: "请选择开发者的技术栈",
  185. trigger: "blur"
  186. }],
  187. skills: [{
  188. required: false,
  189. message: "请选择核心技能标签",
  190. trigger: "blur"
  191. }],
  192. },
  193. field104Action: "",
  194. field104fileList: [],
  195. fullOptions: [{
  196. "label": "不需要",
  197. "value": 0
  198. }, {
  199. "label": "需要",
  200. "value": 1
  201. }],
  202. ys_money_typeOptions: [{
  203. "label": "1-6K",
  204. "value": 1
  205. }, {
  206. "label": "6-12K",
  207. "value": 2
  208. }, {
  209. "label": "12-18K",
  210. "value": 3
  211. }, {
  212. "label": "18K以上",
  213. "value": 4
  214. }],
  215. directionData: [],
  216. cityData: [],
  217. skills: [],
  218. loading: false,
  219. tips: `可参考以下内容:\n1、您的产品/公司/业务的简短介绍\n2、需求的核心工作内容\n3、对开发者的其他需求`,
  220. };
  221. },
  222. computed: {},
  223. watch: {
  224. modalFormData: {
  225. deep: true,
  226. handler: function (val) {
  227. if (!val.field103) {
  228. this.field104fileList = []
  229. }
  230. this.$emit("formChange", 2, "process");
  231. }
  232. }
  233. },
  234. created() {},
  235. mounted() {
  236. this.$emit("formChange", 2, "process");
  237. this.fetchDirectionData()
  238. this.fetchCityData()
  239. },
  240. mixins: [uploadFile],
  241. methods: {
  242. submitForm() {
  243. this.$refs["modalForm"].validate(valid => {
  244. if (!valid) return;
  245. // TODO 提交表单
  246. this.requestSubmit();
  247. });
  248. },
  249. resetForm() {
  250. this.$refs["modalForm"].resetFields();
  251. },
  252. uploadFile(file, type) {
  253. this.uploading = true;
  254. this.apiPrepareUpload(
  255. file.file,
  256. res => {
  257. if (res.data && res.data.status === 1) {
  258. let uploadId = res.data.data._upload_id;
  259. let url = res.data.data.url;
  260. this.field104fileList.push({
  261. data: {
  262. ...res.data.data
  263. },
  264. name: res.data.data.name,
  265. url: url,
  266. uploadId: uploadId
  267. });
  268. this.$message.success("上传成功");
  269. } else {
  270. this.$message.error("上传失败");
  271. }
  272. },
  273. 4
  274. );
  275. return false;
  276. },
  277. remove(file, fileList) {
  278. this.field104fileList = [...fileList];
  279. },
  280. fetchDirectionData() {
  281. this.$axios
  282. .$post(
  283. "/api/direction/get_all_data"
  284. )
  285. .then(res => {
  286. // console.log(res)
  287. let aa = directionDataParse(res.data);
  288. this.directionData = [...aa]
  289. })
  290. },
  291. directionChange(selectedOption) {
  292. this.modalFormData.match_directions = selectedOption[0]
  293. this.modalFormData.direction_id = selectedOption[1]
  294. },
  295. fetchCityData() {
  296. this.$axios
  297. .$post(
  298. "/wapi/pub/getAllCity"
  299. )
  300. .then(res => {
  301. // console.log(res)
  302. let aa = cityDataParse(res.data.list);
  303. this.cityData = [...aa]
  304. })
  305. },
  306. cityChange(selectedOption) {
  307. this.modalFormData.province_id = selectedOption[0]
  308. this.modalFormData.city_id = selectedOption[1]
  309. },
  310. remoteMethod(query) {
  311. if (query !== '') {
  312. this.loading = true;
  313. this.$axios.$post("/wapi/work/getSkill", {
  314. keyword: query
  315. }).then(res => {
  316. this.loading = false;
  317. let list = res.data;
  318. this.skills = list.map((item) => {
  319. return {
  320. ...item,
  321. value: item.id,
  322. label: item.name,
  323. }
  324. })
  325. })
  326. } else {
  327. this.skills = [];
  328. }
  329. },
  330. skillChange(a, b) {
  331. console.log(111, a, b)
  332. },
  333. async requestSubmit() {
  334. let form = this.modalFormData
  335. let params = {
  336. match_directions: form.match_directions,
  337. direction_id: form.direction_id,
  338. match_skills: form.skills.join(','),
  339. description: form.description,
  340. ys_money_type: form.ys_money_type,
  341. province_id: form.province_id,
  342. city_id: form.city_id,
  343. is_appoint_freelance:form.full,
  344. publish_present_hire:form.is_incompany,
  345. is_need_manager: form.is_need_manager ? 1 : 0
  346. };
  347. if (this.field104fileList.length > 0) {
  348. let arr = this.field104fileList.map(item => {
  349. return {
  350. ...item.data
  351. };
  352. });
  353. params["job_files"] = JSON.stringify(arr);
  354. }
  355. this.$axios
  356. .$post(
  357. "/api/job/publish3", {
  358. ...params
  359. }
  360. )
  361. .then(async (res) => {
  362. if (Number(res.status) === 1) {
  363. this.$message.success("提交成功");
  364. let id = res.data.id
  365. await this.$refs['loading'].start()
  366. this.$emit('formSubmit', 2, id)
  367. } else {
  368. this.$message.error("提交失败");
  369. }
  370. })
  371. }
  372. }
  373. };
  374. </script>
  375. <style lang="scss">
  376. .form-xuqiu {
  377. margin: 80px 80px 0;
  378. }
  379. .form-title {
  380. font-size: 22px;
  381. font-weight: 500;
  382. color: #0b121a;
  383. line-height: 30px;
  384. margin-bottom: 40px;
  385. }
  386. .form-label {
  387. height: 30px;
  388. line-height: 30px;
  389. font-size: 13px;
  390. font-family: PingFangSC-Medium;
  391. font-weight: 500;
  392. color: #19222e;
  393. }
  394. .form-submit-area {
  395. text-align: center;
  396. }
  397. .form-info-icon {
  398. color: #409EFF;
  399. font-size: 18px;
  400. cursor: pointer;
  401. position: relative;
  402. top: 5px;
  403. }
  404. .form-tooltip {
  405. // width: 200px;
  406. line-height: 2em;
  407. }
  408. .form-tips {
  409. font-size: 12px;
  410. font-family: PingFangSC-Regular, PingFang SC;
  411. font-weight: 400;
  412. color: #E6A23C;
  413. line-height: 17px;
  414. display: inline-block;
  415. }
  416. </style>