/* 控件接口说明: * 1. 读取控件: this.***,*号输入控件编码; * 2. 读取控件的值: this.***.GetValue(); * 3. 设置控件的值: this.***.SetValue(???); * 4. 绑定控件值变化事件: this.***.BindChange(key,function(){}),key是定义唯一的方法名; * 5. 解除控件值变化事件: this.***.UnbindChange(key); * 6. CheckboxList、DropDownList、RadioButtonList: $.***.AddItem(value,text),$.***.ClearItems(); */ /* 公共接口: * 1. ajax:$.SmartForm.PostForm(actionName,data,callBack,errorBack,async), * actionName:提交的ActionName;data:提交后台的数据;callback:回调函数;errorBack:错误回调函数;async:是否异步; * 2. 打开表单:$.IShowForm(schemaCode, objectId, checkIsChange), * schemaCode:表单编码;objectId;表单数据Id;checkIsChange:关闭时,是否感知变化; * 3. 定位接口:$.ILocation(); */ // 表单插件代码 $.extend($.JForm, { // 加载事件 OnLoad: function () { // 页面状态:0为审批/办理 1为办理完结 2为创建 4为查阅 if ($.SmartForm.ResponseContext.FormMode == 2) { // 合同类型 this.typeName.ClearItems() $.SmartForm.PostForm("types", {}, rsp => { JSON.parse(rsp.ReturnData.types).forEach(item => { if (!item.typeName.includes("测试")) { this.typeName.AddItem(item.typeName) } }) }); // 所属部门【仅一个部门,直接赋值;多个部门,下拉框手动选择】 this.purchaseDepart.ClearItems() $.SmartForm.PostForm("purchaseDepart", {}, rsp => { const depts = JSON.parse(rsp.ReturnData.purchaseDepart); console.log(depts) depts.forEach(item => { this.purchaseDepart.AddItem(item.Name) }) if (depts.length == 1) { this.purchaseDepart.SetValue(depts[0].Name) } }); // 代理人姓名 this.cAgentPerson.BindChange("cAgentPerson", () => { const agentPerson = this.cAgentPerson.GetValue() if (agentPerson.length) { $.SmartForm.PostForm("agentPerson", {agentId: agentPerson[0]}, rsp => { console.log(JSON.parse(rsp.ReturnData.agentPerson)) this.agentPerson.SetValue(JSON.parse(rsp.ReturnData.agentPerson)[0].Name) }); } }) } }, // 按钮事件 OnLoadActions: function (actions) { }, // 提交校验 OnValidate: function (actionControl) { return true; }, // 提交前事件 BeforeSubmit: function (action, postValue) { }, // 提交后事件 AfterSubmit: function (action, responseValue) { } });