needs.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {getDataSet, getEventParam, throttle, toast} from "../../../../utils/utils";
  2. import Api from "../../../../model/api";
  3. import Config from "../../../../model/config";
  4. Component({
  5. properties: {
  6. directionData: Array,
  7. modelData: Array,
  8. typeData: Array,
  9. },
  10. data: {
  11. trainDirect:'',
  12. trainForm: '',
  13. lessonType: '',
  14. time: 1,
  15. count: 1,
  16. msg: '',
  17. attachmentType: '',
  18. attachmentUrl: '',
  19. uploadPath: Config.UPLOAD_PATH.COMMUNITY_MANAGEMENT
  20. },
  21. methods: {
  22. changeInfo(e) {
  23. let eventParam = getEventParam(e);
  24. this.setData({
  25. ...eventParam
  26. })
  27. },
  28. onChange(e) {
  29. const field = getDataSet(e, "field");
  30. this.setData({
  31. [field]: getEventParam(e)
  32. })
  33. },
  34. handleUpload(e) {
  35. const fileType = getEventParam(e, "fileType");
  36. const fileList = getEventParam(e, "fileList");
  37. const urls = fileList.map(item => item.url);
  38. const attachmentUrl = JSON.stringify(urls);
  39. this.setData({
  40. attachmentType: fileType, attachmentUrl
  41. })
  42. },
  43. publish: throttle(async function (e) {
  44. if (!this.data.trainDirect.trim()) {
  45. toast('请选择培训方向')
  46. return;
  47. }
  48. if (!this.data.trainForm.trim()) {
  49. toast('请选择培训形式')
  50. return;
  51. }
  52. if (!this.data.lessonType.trim()) {
  53. toast('请选择课程类型')
  54. return;
  55. }
  56. if (!this.data.msg.trim()) {
  57. toast('请输入内容')
  58. return;
  59. }
  60. const params = {
  61. trainDirect: this.data.trainDirect,
  62. trainForm: this.data.trainForm,
  63. lessonType: this.data.lessonType,
  64. trainTime: this.data.time,
  65. trainRate: this.data.count,
  66. imgDesc: this.data.msg,
  67. attachmentType: this.data.attachmentType,
  68. attachmentUrl: this.data.attachmentUrl
  69. }
  70. await Api.ReleaseNeeds(params, true);
  71. this.triggerEvent("postFinish");
  72. })
  73. }
  74. })