editItemNumberStore.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. (function (vc, vm) {
  2. vc.extends({
  3. data: {
  4. editResourceStoreInfo: {
  5. resId: '',
  6. resName: '',
  7. resCode: '',
  8. price: '',
  9. description: '',
  10. stock: ''
  11. }
  12. },
  13. _initMethod: function () {
  14. },
  15. _initEvent: function () {
  16. vc.on('editItemNumberStore', 'openEditItemNumberStoreModal', function (_params) {
  17. vc.component.refreshEditResourceStoreInfo();
  18. $('#editItemNumberStoreModel').modal('show');
  19. vc.copyObject(_params, vc.component.editResourceStoreInfo);
  20. vc.component.editResourceStoreInfo.stock = _params.stock;
  21. vc.component.editResourceStoreInfo.communityId = vc.getCurrentCommunity().communityId;
  22. });
  23. },
  24. methods: {
  25. editResourceStoreValidate: function () {
  26. return vc.validate.validate({
  27. editResourceStoreInfo: vc.component.editResourceStoreInfo
  28. }, {
  29. 'editResourceStoreInfo.resName': [
  30. {
  31. limit: "required",
  32. param: "",
  33. errInfo: "物品名称不能为空"
  34. },
  35. {
  36. limit: "maxin",
  37. param: "2,100",
  38. errInfo: "物品名称长度为2至100"
  39. },
  40. ],
  41. 'editResourceStoreInfo.resCode': [
  42. {
  43. limit: "maxLength",
  44. param: "50",
  45. errInfo: "物品编码不能超过50位"
  46. },
  47. ],
  48. 'editResourceStoreInfo.price': [
  49. {
  50. limit: "required",
  51. param: "",
  52. errInfo: "物品价格不能为空"
  53. },
  54. {
  55. limit: "money",
  56. param: "",
  57. errInfo: "物品价格格式错误"
  58. },
  59. ],
  60. 'editResourceStoreInfo.description': [
  61. {
  62. limit: "maxLength",
  63. param: "200",
  64. errInfo: "描述不能为空"
  65. },
  66. ],
  67. 'editResourceStoreInfo.resId': [
  68. {
  69. limit: "required",
  70. param: "",
  71. errInfo: "物品ID不能为空"
  72. }]
  73. });
  74. },
  75. editResourceStore: function () {
  76. if (!vc.component.editResourceStoreValidate()) {
  77. vc.message(vc.validate.errInfo);
  78. return;
  79. }
  80. console.log("开始向后台发送请求!");
  81. vc.http.post(
  82. 'editResourceStore',
  83. 'update',
  84. JSON.stringify(vc.component.editResourceStoreInfo),
  85. {
  86. emulateJSON: true
  87. },
  88. function (json, res) {
  89. //vm.menus = vm.refreshMenuActive(JSON.parse(json),0);
  90. console.log("请求结果为:");
  91. console.log(res);
  92. console.log(json);
  93. if (res.status == 200) {
  94. //关闭model
  95. $('#editItemNumberStoreModel').modal('hide');
  96. vc.emit('resourceStoreManage', 'listResourceStore', {});
  97. return;
  98. }
  99. vc.message(json);
  100. },
  101. function (errInfo, error) {
  102. console.log('请求失败处理');
  103. vc.message(errInfo);
  104. });
  105. },
  106. refreshEditResourceStoreInfo: function () {
  107. vc.component.editResourceStoreInfo = {
  108. resId: '',
  109. resName: '',
  110. resCode: '',
  111. price: '',
  112. description: '',
  113. stock: ''
  114. }
  115. }
  116. }
  117. });
  118. })(window.vc, window.vc.component);