const app = getApp() const api = require("../../../utils/request.js"); Page({ data: { formData: [ { type: 'input', id:'name', lable:'考试名称', isRequired: true,//是否必填 maxLength: 20,//最大长度 defaultValue:'',//初始值 rules:[//规则验证数组 { regular: '^\\S*$',//正则字符串 tips: '不能有空格'//错误提示 }, ] }, { type: 'input', id:'place', lable:'考试地点', isRequired: true,//是否必填 maxLength: 50,//最大长度 defaultValue:'',//初始值 rules:[//规则验证数组 { regular: '^\\S*$',//正则字符串 tips: '不能有空格'//错误提示 }, ] }, { type: 'input', id: 'chance', lable: '考试机会', defaultValue: 3, inputType: 'digit', //对应input组件type值(text,number) placeholder: '请填写数字', isRequired: true,//是否必填 //disabled:true, rules: [ ] }, { type: 'picker', id: 'workscope', lable: '工作类别', defaultIdx:0,//默认选择索引 // disabled:true, isRequired:true, range:[ { id: 0, name: '正常' }, { id: 1, name: '异常' }, ] }, { type: 'date', id: 'daterange', lable: '开关时间', isRequired: true, /* 显示完整时间包含时分秒;当使用endDate的时候关闭,不要同时打开, 否则日期将会换行; 与config中的colum属性共同设置 */ completeTime:true, //显示完整时间, 包含时分秒 config: { endDate: true, dateLimit: true, // initStartTime: "2020-01-01 12:32:44", // initEndTime: "2020-12-01 12:32:44", column: "minute",//day、hour、minute、secend limitStartTime: "2000-01-01 00:00:59", limitEndTime: "2100-01-01 00:00:59" } }, { type: 'input', id:'proctor_name', lable:'监考人姓名', isRequired: true,//是否必填 maxLength: 50,//最大长度 defaultValue:'',//初始值 rules:[//规则验证数组 { regular: '^\\S*$',//正则字符串 tips: '不能有空格'//错误提示 }, ] }, { type: 'input', id:'proctor_phone', lable:'监考人联系方式', isRequired: true,//是否必填 maxLength: 50,//最大长度 defaultValue:'',//初始值 rules:[//规则验证数组 { regular: '^\\S*$',//正则字符串 tips: '不能有空格'//错误提示 }, ] }, ], toSubmit: Math.random() }, onFormSubmit(e){ console.log('表单提交: ', e); let x = {}; x.opentime = e.daterange.startDate; x.endtime = e.daterange.endDate; x.name = e.name x.place = e.place x.chance = e.chance x.workscope = e.workscope x.proctor_name = e.proctor_name x.proctor_phone = e.proctor_phone console.log(x) }, onFormChange(e){ console.log('表单变化: ',e); }, //变更数值, 触发表单提交事件 toSubmitChange(){ this.setData({ toSubmit: Math.random() }) }, onLoad: function () { api.requesta('/examtest/workscope/?can_exam=true', 'GET').then(res=>{ this.data.formData[3].range=res.data this.setData({ formData: this.data.formData }) }) }, })