product-file.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 编辑履历:
  6. * 作者 日期 版本 修改内容
  7. * 王英杰 2024-1-23 1.00 商品档案
  8. *******************************************************************************/
  9. const Constants = require('@/utils/Constants.js');
  10. const util = require('@/utils/util.js')
  11. const mixins = require('@/mixins/index.js')
  12. const app = getApp()
  13. Page({
  14. mixins: [mixins],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. commonService: app.globalData['commonService'],
  20. flgValidList: null,
  21. buttonList: [{
  22. name: 'merge',
  23. title: mixins.$t("add"), //'保存'
  24. }],
  25. //接口
  26. goodsSeriesService: app.globalData['goodsSeriesService'],
  27. routeObjName: 'goodsSku',
  28. tableData: [],
  29. // 查询条件
  30. searchContent: [{
  31. code: 'flgValid',
  32. title: mixins.$t('flagV'),
  33. key: 'valueList',
  34. searchType: Constants.searchType.switch,
  35. list: [{
  36. code: 1,
  37. title: mixins.$t('valid'),
  38. value: true,
  39. checked: true
  40. },
  41. {
  42. code: 2,
  43. title: mixins.$t('invalid'),
  44. value: false
  45. }
  46. ]
  47. }, ],
  48. sidebarList: [], //左边系列名字
  49. contentList: [{ //内容
  50. name: 'skuName',
  51. title: mixins.$t('skuName')
  52. },
  53. {
  54. name: 'brandName',
  55. title: mixins.$t('goodsBrand')
  56. },
  57. {
  58. name: 'seriesName',
  59. title: mixins.$t('goodsSeries')
  60. },
  61. {
  62. name: 'skuSpec',
  63. title: mixins.$t('sukSpec')
  64. }
  65. ],
  66. sideKey: 0,
  67. // 商品品牌
  68. sidebarList: [{ //增加全部标头
  69. brandName: mixins.$t('all'),
  70. brandId: ''
  71. }],
  72. // 主键Id
  73. primaryKey: 'skuId',
  74. },
  75. /**
  76. * @desc : 初始页面加载数据
  77. * @author : 王英杰
  78. * @date : 2024/1/23 9:16
  79. */
  80. onShow() {
  81. // 获取品牌
  82. this.getGoodsBrandNoPage().then(res=>{
  83. let item = this.data.item
  84. if(item && item.brandId){
  85. let sidebarList = this.data.sidebarList;
  86. let index = sidebarList.findIndex(it=>it.brandId == item.brandId)
  87. this.setData({
  88. sideKey:index,
  89. brandId:item.brandId
  90. })
  91. // 重新根据品牌进行查询
  92. this.searchData();
  93. }
  94. })
  95. },
  96. /**
  97. * @desc : 获取品牌
  98. * @author : 王英杰
  99. * @date : 2024/1/23 9:16
  100. */
  101. getGoodsBrandNoPage() {
  102. let excute = this.excute(this.data.commonService, this.data.commonService.getGoodsBrandNoPage, {flgValid:true});
  103. excute.then(res => {
  104. if (res.data.code === Constants.SUCESS_CODE) {
  105. let sidebarList = []
  106. let List = [{ //增加全部标头
  107. brandName: mixins.$t('all'),
  108. brandId: ''
  109. }]
  110. sidebarList = List.concat(res.data.data);
  111. this.setData({
  112. sidebarList: sidebarList
  113. })
  114. }
  115. })
  116. return excute;
  117. },
  118. /**
  119. * @desc : 设置查询参数
  120. * @author : 王英杰
  121. * @date : 2024/1/23 9:16
  122. */
  123. setSearchParams(params) {
  124. params.brandId = this.data.brandId
  125. //有效标识
  126. params.flgValidList = params.flgValidList ? params.flgValidList : [true]
  127. params.brandIds = (params.brandIds && params.brandIds.length > 0) ? params.brandIds.join(',') : undefined
  128. return params
  129. },
  130. /**
  131. * @desc : 加载数据
  132. * @author : 王英杰
  133. * @date : 2024/1/23 9:16
  134. */
  135. getData(params) {
  136. return this.excute(this.data.service, this.data.service.selectByCond, params);
  137. },
  138. /**
  139. * @desc : 启用停用
  140. * @date : 2024/2/1 15:49
  141. * @author : 王英杰
  142. */
  143. deactivateEnable(e) {
  144. let item = e.detail.item
  145. //执行接口
  146. this.handleMoreDataIsValid(this.data.service, item, 'skuId')
  147. },
  148. /**
  149. * @desc : 分类切换
  150. * @author : 王英杰
  151. * @date : 2022/5/26 20:16
  152. */
  153. changeSidebar(e) {
  154. let id = this.data.sidebarList[e.detail].brandId
  155. this.setData({
  156. brandId: id,
  157. sideKey: e.detail
  158. })
  159. this.searchData()
  160. },
  161. onLoad(){
  162. let _this = this;
  163. this.getStickyHeight()
  164. wx.getSystemInfo({
  165. success: function (res) {
  166. _this.setData({
  167. windowHeight: res.windowHeight,
  168. windowWidth: res.windowWidth
  169. })
  170. }
  171. })
  172. }
  173. })