StockInEdit.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. function validChoose() {
  2. var d = [];
  3. $.each($("#dgStockInTMSelectList").cmsXDataTable("getSelections"), function (index) {
  4. d.push(this);
  5. });
  6. return d;
  7. }
  8. //删除
  9. function ET06_05_01_StockIn_Delete_ViewGrid() {
  10. var d = validChoose();
  11. var roleViewList = $("#dgStockInTMSelectList").cmsXDataTable("getRows");
  12. var i, j;
  13. var len = roleViewList.length;
  14. for (i = len - 1; i >= 0; i--) {
  15. for (j = 0; j < d.length; j++) {
  16. if (roleViewList[i].TeachingMaterialPoolID == d[j].TeachingMaterialPoolID) {
  17. roleViewList.splice(i, 1);
  18. break;
  19. }
  20. }
  21. }
  22. $("#dgStockInTMSelectList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  23. }
  24. //添加教材
  25. function ET06_05_01_StockIn_Add_ViewGrid() {
  26. var schoolyearID = $("#SchoolyearID").combobox('getValue');
  27. if (schoolyearID == null || schoolyearID == nonSelect) {
  28. $.messager.alert("系统提示", "请选择学年学期。");
  29. return;
  30. }
  31. var supplierID = $("#SupplierID").combogridX("getValue");
  32. $.popupTopWindow('添加教材', CMS_SystemConfig.VirtualDirectoryPath + '/StockIn/TeachingMaterial?SchoolyearID=' +
  33. schoolyearID + '&SupplierID=' + supplierID , 720, 480, StockIn_Add_Confirm);
  34. }
  35. //roleList 选中的对象
  36. function StockIn_Add_Confirm(roleList) {
  37. if (roleList == undefined)
  38. return;
  39. var supplierID = $("#SupplierID").combogridX("getValue");
  40. var dataList = [{ "Text": "请选择", "Value": -1 }];
  41. // var discount = 0;
  42. // $.ajaxSettings.async = false
  43. // $.post(CMS_SystemConfig.VirtualDirectoryPath + '/StockInSet/GetDiscountByID', { supplierID: supplierID }, function (data) {
  44. // discount = data;
  45. // });
  46. // $.ajaxSettings.async = true
  47. var roleViewList = $("#dgStockInTMSelectList").cmsXDataTable("getRows");
  48. $.each(roleList, function (index, value) {
  49. if ($.grep(roleViewList, function (row, index) { return value.TeachingMaterialPoolID == roleViewList[index].TeachingMaterialPoolID; }).length == 0) {
  50. roleViewList.push({
  51. TeachingMaterialPoolID: value.TeachingMaterialPoolID,
  52. TeachingMaterialCode: value.TeachingMaterialCode,
  53. TeachingMaterialName: value.TeachingMaterialName,
  54. CoursematerialCode: value.CoursematerialCode,
  55. CoursematerialName: value.CoursematerialName,
  56. Price: value.Price,
  57. OrderQty: value.OrderQty,
  58. Discount: value.Discount,
  59. DiscountPrice: value.DiscountPrice,
  60. MaYang: value.MaYang,
  61. ZongJia: value.ZongJia,
  62. IsLateName: value.IsLateName,
  63. });
  64. }
  65. });
  66. $("#dgStockInTMSelectList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  67. }
  68. function reload() {
  69. $("#dgStockInTMSelectList").cmsXDataTable("load", $.getDataGridParams("dgStockInTMSelectList"));
  70. }
  71. function QueryPublishDropdownList() {
  72. reload();
  73. }
  74. function PublishChange(){
  75. var supplierID = $("#SupplierID").combogridX("getValue");
  76. var discount = 0;
  77. $.ajaxSettings.async = false
  78. $.post(CMS_SystemConfig.VirtualDirectoryPath + '/StockInSet/GetDiscountByID', { supplierID: supplierID }, function (data) {
  79. discount = data;
  80. });
  81. $.ajaxSettings.async = true
  82. var all = $("#dgStockInTMSelectList").cmsXDataTable("getRows");
  83. var roleViewList = [];
  84. $.each(all, function (index, value) {
  85. roleViewList.push({
  86. TeachingMaterialPoolID: value.TeachingMaterialPoolID,
  87. TeachingMaterialCode: value.TeachingMaterialCode,
  88. TeachingMaterialName: value.TeachingMaterialName,
  89. CoursematerialCode: value.CoursematerialCode,
  90. CoursematerialName: value.CoursematerialName,
  91. Price: value.Price,
  92. OrderQty: value.OrderQty,
  93. Discount: discount,
  94. DiscountPrice: (value.Price * (discount*100))/100,
  95. MaYang: value.MaYang,
  96. ZongJia: ((value.Price * (discount*100)) * value.OrderQty)/100,
  97. IsLateName: value.IsLateName,
  98. });
  99. });
  100. $("#dgStockInTMSelectList").cmsXDataTable("loadData", { rows: roleViewList, total: roleViewList.length });
  101. }