add.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 王英杰 2024-1-24 1.00 新建商品档案
  8. *******************************************************************************/
  9. const mixins = require('@/mixins/index.js')
  10. const app = getApp()
  11. const Constants = require('@/utils/Constants')
  12. Page({
  13. mixins: [mixins],
  14. /**
  15. * 页面的初始数据
  16. */
  17. data: {
  18. cardList: ['main', 'goods', "warehouse", 'price', 'other'],
  19. contentObj: {
  20. main: [{ //唯一编码
  21. code: 'onlyCode',
  22. type: 'textarea',
  23. title: mixins.$t("onlyCode"),
  24. readonly: true
  25. }, { //商品型号
  26. code: 'skuModel',
  27. type: 'textarea',
  28. title: mixins.$t("skuModel"),
  29. required: true,
  30. }, { //商品名称
  31. code: 'skuName',
  32. type: 'textarea',
  33. title: mixins.$t("skuName"),
  34. required: true,
  35. }, {
  36. code: 'file',
  37. type: 'uploader',
  38. title: '商品图片'
  39. },
  40. ],
  41. goods: [{ //商品品牌
  42. code: 'brandId',
  43. name: 'brandName',
  44. title: mixins.$t("goodsBrand"),
  45. type: 'choose',
  46. urlKey:'goodsBrand' ,
  47. required: true,
  48. // changeObj: {
  49. // pur: {
  50. // hide: ['serviceCategories'],
  51. // visible: ['brandId']
  52. // },
  53. // service: {
  54. // hide: ['brandId'],
  55. // visible: ['serviceCategories']
  56. // }
  57. },
  58. { //商品种类
  59. code: 'categoryId',
  60. name: 'catName',
  61. title: mixins.$t("goodsCategory"),
  62. type: 'choose',
  63. urlKey:'goodsCategory' ,
  64. required: true,
  65. }, { //计量单位
  66. code: 'unitId',
  67. name: 'unitName',
  68. title: mixins.$t("unit"),
  69. type: 'choose',
  70. urlKey: 'unit',
  71. required: true,
  72. }, { //辅助计量单位
  73. code: 'subUnitId',
  74. name: 'subUnitName',
  75. title: mixins.$t("subUnitId"),
  76. type: 'choose',
  77. urlKey: 'unit',
  78. }, { //商品系列
  79. code: 'seriesId',
  80. name: 'seriesName',
  81. title: mixins.$t("goodsSeries"),
  82. type: 'choose',
  83. urlKey: 'goodsSeries',
  84. }, { //商品规格
  85. code: 'skuSpec',
  86. name: 'skuSpec',
  87. type: 'textarea',
  88. title: mixins.$t("sukSpec"),
  89. }
  90. ],
  91. warehouse: [{ //仓库名称
  92. code: 'whId',
  93. name: 'whName',
  94. title: mixins.$t("whName"),
  95. type: 'choose',
  96. urlKey: 'openingInventory',
  97. },
  98. { //库存批号
  99. code: 'iinventoryBatchNumber',
  100. type: 'textarea',
  101. title: mixins.$t("iinventoryBatchNumber"),
  102. },
  103. { //期初数量
  104. code: 'openingInventoryQty',
  105. type: 'number',
  106. sign:"",
  107. digits:0,
  108. title: mixins.$t("openingInventoryQty"),
  109. },
  110. { //期初成本价
  111. code: 'iinitialCostPrice',
  112. type: 'textarea',
  113. title: mixins.$t("iinitialCostPrice"),
  114. },
  115. ],
  116. price: [{ //采购价
  117. code: 'pricePurchase',
  118. type: 'number',
  119. title: mixins.$t("purchasePrice"),
  120. }, { //零售价
  121. code: 'priceStandard',
  122. type: 'number',
  123. title: mixins.$t("retailPrice"),
  124. }, { //批发价
  125. code: 'priceWholesale',
  126. type: 'number',
  127. title: mixins.$t("wholesalePrice"),
  128. }, { //销售限价
  129. code: 'priceLimited',
  130. type: 'number',
  131. title: mixins.$t("SaleSPriceLimit"),
  132. }, ],
  133. other: [{
  134. code: 'remarks',
  135. type: 'textarea',
  136. title: mixins.$t("remarks"),
  137. }]
  138. },
  139. // 路由
  140. routeObjName: 'goodsSku',
  141. },
  142. chooseData(e){
  143. console.log("t",e,this.data.formData);
  144. let formData = JSON.parse(this.data.formData)
  145. let code = e.detail.code
  146. let data = e.detail.data.data
  147. if(code == "brandId"){ //商品品牌
  148. formData.brandId = data.id
  149. formData.brandName = data.name
  150. }
  151. if(code == "categoryId"){ //商品种类
  152. formData.categoryId = data.id
  153. formData.catName = data.name
  154. }
  155. if(code == "unitId"){ //计量单位
  156. formData.unitId = data.id
  157. formData.unitName = data.name
  158. }
  159. if(code == "subUnitId"){ //补助计量单位
  160. formData.subUnitId = data.id
  161. formData.subUnitName = data.name
  162. }
  163. if(code == "seriesId"){ //补助计量单位
  164. formData.seriesId = data.id
  165. formData.seriesName = data.name
  166. }
  167. if(code == "whId"){ //补助计量单位
  168. formData.whId = data.id
  169. formData.whName = data.name
  170. }
  171. this.setData({
  172. formData: JSON.stringify(formData)
  173. })
  174. },
  175. // 设置保存参数
  176. setParams(params) {
  177. let saveData = JSON.parse(this.data.formData)
  178. // 修改之后的 值
  179. params = Object.assign({}, params, saveData);
  180. params.serviceCategories = (params.serviceCategories && params.serviceCategories.length > 0) ? params.serviceCategories.split(',') : []
  181. return params
  182. },
  183. /**
  184. * @desc : 保存数据服务
  185. * @date : 2024/2/1 15:49
  186. * @author : 王英杰
  187. */
  188. saveData() {
  189. console.log("参数",this.data.params);
  190. if (this.data.formMode == Constants.formMode.edit) { //编辑接口
  191. return this.excute(this.data.service, this.data.service.update, this.data.params)
  192. } else { //新建接口
  193. return this.excute(this.data.service, this.data.service.insert, this.data.params);
  194. }
  195. },
  196. /**
  197. * @desc : 保存接口的 后续处理方法
  198. * @date : 2024/2/1 15:49
  199. * @author : 王英杰
  200. */
  201. handleData(data) {
  202. wx.navigateBack({
  203. delta: 1
  204. })
  205. },
  206. /**
  207. * @desc : 页面加载数据方法
  208. * @date : 2024/2/1 15:49
  209. * @author : 王英杰
  210. */
  211. loadInit() {
  212. if (this.data.formMode == Constants.formMode.edit) {
  213. wx.setNavigationBarTitle({
  214. title: mixins.$t('编辑商品档案'),
  215. })
  216. } else {
  217. wx.setNavigationBarTitle({
  218. title: mixins.$t('新建商品档案'),
  219. })
  220. }
  221. },
  222. /**
  223. * @desc : 给表单赋值
  224. * @date : 2024/2/1 15:49
  225. * @author : 王英杰
  226. */
  227. setValuesByEdit(data) {
  228. // data.serviceCategories = (data.serviceCategories && data.serviceCategories.length > 0) ? data.serviceCategories.join(',') : undefined
  229. this.setData({
  230. formData: JSON.stringify(data)
  231. })
  232. },
  233. })