上海市委.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* 控件接口说明:
  2. * 1. 读取控件: this.***,*号输入控件编码;
  3. * 2. 读取控件的值: this.***.GetValue();
  4. * 3. 设置控件的值: this.***.SetValue(???);
  5. * 4. 绑定控件值变化事件: this.***.BindChange(key,function(){}),key是定义唯一的方法名;
  6. * 5. 解除控件值变化事件: this.***.UnbindChange(key);
  7. * 6. CheckboxList、DropDownList、RadioButtonList: $.***.AddItem(value,text),$.***.ClearItems();
  8. */
  9. /* 公共接口:
  10. * 1. ajax:$.SmartForm.PostForm(actionName,data,callBack,errorBack,async),
  11. * actionName:提交的ActionName;data:提交后台的数据;callback:回调函数;errorBack:错误回调函数;async:是否异步;
  12. * 2. 打开表单:$.IShowForm(schemaCode, objectId, checkIsChange),
  13. * schemaCode:表单编码;objectId;表单数据Id;checkIsChange:关闭时,是否感知变化;
  14. * 3. 定位接口:$.ILocation();
  15. */
  16. // 表单插件代码
  17. $.extend($.JForm, {
  18. // 加载事件
  19. OnLoad: function () {
  20. // 页面状态:0为审批/办理 1为办理完结 2为创建 4为查阅
  21. if ($.SmartForm.ResponseContext.FormMode == 2) {
  22. // 合同类型
  23. this.typeName.ClearItems()
  24. $.SmartForm.PostForm("types", {}, rsp => {
  25. JSON.parse(rsp.ReturnData.types).forEach(item => {
  26. if (!item.typeName.includes("测试")) {
  27. this.typeName.AddItem(item.typeName)
  28. }
  29. })
  30. });
  31. // 所属部门【仅一个部门,直接赋值;多个部门,下拉框手动选择】
  32. this.purchaseDepart.ClearItems()
  33. $.SmartForm.PostForm("purchaseDepart", {}, rsp => {
  34. const depts = JSON.parse(rsp.ReturnData.purchaseDepart);
  35. console.log(depts)
  36. depts.forEach(item => {
  37. this.purchaseDepart.AddItem(item.Name)
  38. })
  39. if (depts.length == 1) {
  40. this.purchaseDepart.SetValue(depts[0].Name)
  41. }
  42. });
  43. // 代理人姓名
  44. this.cAgentPerson.BindChange("cAgentPerson", () => {
  45. const agentPerson = this.cAgentPerson.GetValue()
  46. if (agentPerson.length) {
  47. $.SmartForm.PostForm("agentPerson", {agentId: agentPerson[0]}, rsp => {
  48. console.log(JSON.parse(rsp.ReturnData.agentPerson))
  49. this.agentPerson.SetValue(JSON.parse(rsp.ReturnData.agentPerson)[0].Name)
  50. });
  51. }
  52. })
  53. }
  54. },
  55. // 按钮事件
  56. OnLoadActions: function (actions) {
  57. },
  58. // 提交校验
  59. OnValidate: function (actionControl) {
  60. return true;
  61. },
  62. // 提交前事件
  63. BeforeSubmit: function (action, postValue) {
  64. },
  65. // 提交后事件
  66. AfterSubmit: function (action, responseValue) {
  67. }
  68. });