dynamic.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. teamId: String,
  7. eduStuId: String,
  8. eduStuName: String,
  9. },
  10. data: {
  11. msg: '',
  12. attachmentType: '',
  13. attachmentUrl: '',
  14. uploadPath: Config.UPLOAD_PATH.TEAM_INTERACTION
  15. },
  16. methods: {
  17. onChange(e) {
  18. const field = getDataSet(e, "field");
  19. this.setData({
  20. [field]: getEventParam(e)
  21. })
  22. },
  23. handleUpload(e) {
  24. const fileType = getEventParam(e, "fileType");
  25. const fileList = getEventParam(e, "fileList");
  26. const urls = fileList.map(item => item.url);
  27. const attachmentUrl = JSON.stringify(urls);
  28. this.setData({
  29. attachmentType: fileType, attachmentUrl
  30. })
  31. },
  32. publish: throttle(async function (e) {
  33. if (!this.data.msg.trim()) {
  34. toast('请输入内容')
  35. return;
  36. }
  37. const params = {
  38. issues: this.data.msg,
  39. attachmentType: this.data.attachmentType,
  40. attachmentUrl: this.data.attachmentUrl,
  41. stuId: this.data.eduStuId,
  42. teamId: this.data.teamId,
  43. stuName: this.data.eduStuName
  44. }
  45. await Api.publishTeamInteraction(params, true);
  46. this.triggerEvent("postFinish");
  47. })
  48. }
  49. })