private void DgContents_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var fieldInfo = (FieldInfo)e.Item.DataItem; var settings = new FieldSettings(fieldInfo.Settings); var ltlTitle = (Literal)e.Item.FindControl("ltlTitle"); var ltlDescription = (Literal)e.Item.FindControl("ltlDescription"); var ltlFieldType = (Literal)e.Item.FindControl("ltlFieldType"); var ltlValidate = (Literal)e.Item.FindControl("ltlValidate"); var ltlActions = (Literal)e.Item.FindControl("ltlActions"); ltlTitle.Text = fieldInfo.Title; ltlDescription.Text = fieldInfo.Description; ltlFieldType.Text = FieldTypeUtils.GetText(FieldTypeUtils.GetEnumType(fieldInfo.FieldType)); ltlValidate.Text = ValidateTypeUtils.GetValidateInfo(settings.IsRequired, settings.MinNum, settings.MaxNum, settings.ValidateType); ltlActions.Text = $@" <a class=""m-r-10"" href=""{PageFieldsUrl}&taxis={true}&direction=Up&fieldId={fieldInfo.Id}"">上升</a> <a class=""m-r-10"" href=""{PageFieldsUrl}&taxis={true}&direction=Down&fieldId={fieldInfo.Id}"">下降</a> <a class=""m-r-10"" href=""javascript:;"" onclick=""{ModalFieldAdd.GetOpenScript(SiteId, FormInfo.Id, fieldInfo.Id)}"">编辑</a> <a class=""m-r-10"" href=""javascript:;"" onclick=""{ModalFieldValidate.GetOpenScript(SiteId, FormInfo.Id, fieldInfo.Id)}"">验证规则</a> <a class=""m-r-10"" href=""{PageFieldsUrl}&delete={true}&fieldId={fieldInfo.Id}"">删除</a>"; }
private void RptItems_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var item = (FieldItemInfo)e.Item.DataItem; var fieldType = FieldTypeUtils.GetEnumType(DdlFieldType.SelectedValue); var cbIsSelected = (CheckBox)e.Item.FindControl("CbIsSelected"); var cbIsExtras = (CheckBox)e.Item.FindControl("CbIsExtras"); if (fieldType == FieldType.CheckBox || fieldType == FieldType.Radio) { cbIsExtras.Visible = true; } else { cbIsExtras.Visible = false; } cbIsSelected.Checked = item.IsSelected; cbIsExtras.Checked = item.IsExtras; }
private void DgContents_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem) { return; } var fieldInfo = (FieldInfo)e.Item.DataItem; var settings = new FieldSettings(fieldInfo.FieldSettings); var ltlAttributeName = (Literal)e.Item.FindControl("ltlAttributeName"); var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName"); var ltlFieldType = (Literal)e.Item.FindControl("ltlFieldType"); var ltlIsDisabled = (Literal)e.Item.FindControl("ltlIsDisabled"); var ltlValidate = (Literal)e.Item.FindControl("ltlValidate"); var ltlActions = (Literal)e.Item.FindControl("ltlActions"); ltlAttributeName.Text = fieldInfo.AttributeName; ltlDisplayName.Text = fieldInfo.DisplayName; ltlFieldType.Text = FieldTypeUtils.GetText(FieldTypeUtils.GetEnumType(fieldInfo.FieldType)); ltlIsDisabled.Text = fieldInfo.IsDisabled ? @"<span class=""label label-danger"">已禁用</span>" : @"<span class=""label label-primary"">已启用</span>"; ltlValidate.Text = ValidateTypeUtils.GetValidateInfo(settings.IsRequired, settings.MinNum, settings.MaxNum, settings.ValidateType); ltlActions.Text = $@" <a class=""m-r-10"" href=""{PageUrl}&taxis={true}&direction=Up&fieldId={fieldInfo .Id}"">上升</a> <a class=""m-r-10"" href=""{PageUrl}&taxis={true}&direction=Down&fieldId={fieldInfo .Id}"">下降</a> <a class=""m-r-10"" href=""{PageUrl}&addField={true}&fieldId={fieldInfo.Id}"">编辑</a> <a class=""m-r-10"" href=""{PageUrl}&validateField={true}&fieldId={fieldInfo.Id}"">验证规则</a> <a class=""m-r-10"" href=""{PageUrl}&delete={true}&fieldId={fieldInfo.Id}"">删除</a>"; }
public static void RegisterFormCode(IParseContext context, string vueId, FormInfo formInfo, FormSettings formSettings) { var fieldInfoList = Main.Instance.FieldDao.GetFieldInfoList(formInfo.Id, true); var imgUrl = Main.Instance.PluginApi.GetPluginApiUrl(nameof(ApiUtils.Captcha), formInfo.Id.ToString()); var apiUrlSubmit = Main.Instance.PluginApi.GetPluginApiUrl(nameof(ApiUtils.Submit), formInfo.Id.ToString()); var schemas = new List <object>(); var values = new StringBuilder(); foreach (var fieldInfo in fieldInfoList) { var fieldType = FieldTypeUtils.GetEnumType(fieldInfo.FieldType); var attributeName = FieldManager.GetAttributeId(fieldInfo.Id); var settings = new FieldSettings(fieldInfo.Settings); schemas.Add(new { AttributeName = attributeName, fieldInfo.Title, fieldInfo.Description, fieldInfo.FieldType, settings.IsRequired, Items = fieldInfo.Items ?? new List <FieldItemInfo>() }); if (fieldType == FieldType.SelectMultiple || fieldType == FieldType.CheckBox) { values.Append($"{attributeName}: [],"); } else { values.Append($"{attributeName}: '',"); } } context.StlPageFoot["SS.Form.Parse.Foot." + vueId] = $@" <script type=""text/javascript""> Vue.use(VeeValidate); var {vueId} = new Vue({{ el: '#{vueId}', data: {{ title: {Utils.JsonSerialize(formInfo.Title)}, description: {Utils.JsonSerialize(formInfo.Description)}, isEnabled: {(formInfo.IsTimeout ? $"new Date() > new Date('{formInfo.TimeToStart:yyyy-MM-dd HH:mm}') && new Date() < new Date('{formInfo.TimeToEnd:yyyy-MM-dd HH:mm}')" : true.ToString().ToLower())}, isCaptcha: {formSettings.IsCaptcha.ToString().ToLower()}, attributes: {{{values.ToString().Trim()}}}, code: '', imgUrl: '', isSuccess: false, errorMessage: '', schemas: {Utils.JsonSerialize(schemas)} }}, methods: {{ load: function (event) {{ this.imgUrl = '{imgUrl}?' + new Date().getTime(); }}, submit: function (event) {{ this.errorMessage = ''; var $this = this; var data = {{ code: this.code, attributes: this.attributes }}; this.$validator.validateAll().then(function (result) {{ if (result) {{ $.ajax({{ url : ""{apiUrlSubmit}"", xhrFields: {{ withCredentials: true }}, type: ""POST"", data: JSON.stringify(data), contentType: ""application/json; charset=utf-8"", dataType: ""json"", success: function(data) {{ $this.isSuccess = true; }}, error: function (err) {{ var err = JSON.parse(err.responseText); $this.isSuccess = false; $this.errorMessage = err.message; }} }}); }} }}); }} }} }}); {vueId}.load(); </script>"; }