import {getDataSet, getEventParam, throttle, toast} from "../../../../utils/utils"; import Api from "../../../../model/api"; import Config from "../../../../model/config"; Component({ properties: { directionData: Array, modelData: Array, typeData: Array, }, data: { trainDirect:'', trainForm: '', lessonType: '', time: 1, count: 1, msg: '', attachmentType: '', attachmentUrl: '', uploadPath: Config.UPLOAD_PATH.COMMUNITY_MANAGEMENT }, methods: { changeInfo(e) { let eventParam = getEventParam(e); this.setData({ ...eventParam }) }, onChange(e) { const field = getDataSet(e, "field"); this.setData({ [field]: getEventParam(e) }) }, handleUpload(e) { const fileType = getEventParam(e, "fileType"); const fileList = getEventParam(e, "fileList"); const urls = fileList.map(item => item.url); const attachmentUrl = JSON.stringify(urls); this.setData({ attachmentType: fileType, attachmentUrl }) }, publish: throttle(async function (e) { if (!this.data.trainDirect.trim()) { toast('请选择培训方向') return; } if (!this.data.trainForm.trim()) { toast('请选择培训形式') return; } if (!this.data.lessonType.trim()) { toast('请选择课程类型') return; } if (!this.data.msg.trim()) { toast('请输入内容') return; } const params = { trainDirect: this.data.trainDirect, trainForm: this.data.trainForm, lessonType: this.data.lessonType, trainTime: this.data.time, trainRate: this.data.count, imgDesc: this.data.msg, attachmentType: this.data.attachmentType, attachmentUrl: this.data.attachmentUrl } await Api.ReleaseNeeds(params, true); this.triggerEvent("postFinish"); }) } })