company-setting.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /*******************************************************************************
  2. * Copyright(c) 2022 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:
  5. * 2.功能描述:商户设置画面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 姜永辉 2022-11-22 1.00 新建
  9. *******************************************************************************/
  10. const mixins = require('@/mixins/index.js')
  11. const Constants = require('@/utils/Constants.js');
  12. const app = getApp()
  13. Page({
  14. mixins: [mixins],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data: {
  19. // 路由
  20. routeObjName: 'company',
  21. cardList: ['main'],
  22. contentObj: {
  23. main: [{
  24. code: 'cpName',
  25. type: 'str',
  26. readonly: 'true',
  27. required: 'true',
  28. title: mixins.$t('cpName')
  29. },
  30. {
  31. code: 'cpManager',
  32. type: 'str',
  33. readonly: 'true',
  34. required: 'true',
  35. title: mixins.$t('cpManager')
  36. },
  37. {
  38. code: 'cpPhone',
  39. type: 'phone',
  40. readonly: 'true',
  41. required: 'true',
  42. title: mixins.$t('cpPhone')
  43. },
  44. {
  45. code: 'cpSize',
  46. type: 'str',
  47. readonly: 'true',
  48. title: mixins.$t('cpSize')
  49. },
  50. {
  51. code: 'shopSize',
  52. type: 'str',
  53. readonly: 'true',
  54. title: mixins.$t('shopSize')
  55. },
  56. {
  57. code: 'feedback',
  58. type: 'textarea',
  59. readonly: 'true',
  60. title: mixins.$t('feedback')
  61. },
  62. ],
  63. },
  64. buttonFootList: [{
  65. code: 'close',
  66. title: mixins.$t('close')
  67. }],
  68. companyService: app.globalData['companyService'],
  69. },
  70. /**
  71. * @desc : 参数设置
  72. * @date : 2024/2/1 15:49
  73. * @author : 姜永辉
  74. */
  75. paramSetting(e) {
  76. let _this = this
  77. wx.navigateTo({
  78. url: this.data.route.companyParamSetting.url,
  79. events: {
  80. // 回调后,在这里给页面赋值
  81. bandData: function (e) {}
  82. },
  83. success: function (res) {
  84. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  85. res.eventChannel.emit('params', {})
  86. }
  87. })
  88. },
  89. /**
  90. * @desc : 打印设置
  91. * @date : 2024/2/1 15:49
  92. * @author : 王英杰
  93. */
  94. printRmarkes() {
  95. let _this = this
  96. wx.navigateTo({
  97. url: this.data.route.printRmarkes.url,
  98. events: {
  99. // 回调后,在这里给页面赋值
  100. bandData: function (e) {}
  101. },
  102. success: function (res) {
  103. // 通过eventChannel向被打开页面传送数据 TODO 测试例子url是写死的,实际中,需要从route中读取
  104. res.eventChannel.emit('params', {})
  105. }
  106. })
  107. },
  108. /**
  109. * @desc : 页面初始信息加载
  110. * @param {*} e
  111. * @date : 2024/06/21 09:23
  112. * @author : 刘尧
  113. */
  114. loadInit(e) {
  115. if (app.globalData.user.flgInit) {
  116. const buttonFootList = [{
  117. code: 'updateCommanyOwner',
  118. title: mixins.$t('updateCommanyOwner')
  119. }]
  120. this.setData({
  121. buttonFootList: buttonFootList
  122. })
  123. }
  124. },
  125. /**
  126. * @desc : 底部按钮回调
  127. * @date : 2024/6/21 13:35
  128. * @author : 刘尧
  129. */
  130. openFormEdit(e) {
  131. switch (e.detail.name) {
  132. case "updateCommanyOwner":
  133. const contentObj = this.data.contentObj
  134. const index = contentObj.main.findIndex(res => res.code === "cpManager")
  135. contentObj.main[index].type = 'choose'
  136. contentObj.main[index].urlKey = 'updateCommanyOwner'
  137. contentObj.main[index].name = contentObj.main[index].code
  138. contentObj.main[index].required = true
  139. contentObj.main[index].readonly = false
  140. this.setData({
  141. contentObj: contentObj
  142. })
  143. break;
  144. case "save":
  145. this.save(e)
  146. break;
  147. case "close":
  148. this.close(e)
  149. break;
  150. }
  151. },
  152. /**
  153. * @desc : 参数设置
  154. * @author : 刘尧
  155. * @date : 2024/6/18 17:12
  156. */
  157. setParams(params) {
  158. params = JSON.parse(this.data.formData)
  159. params.svcIp = app.globalData.company.svcIp
  160. params.svcPort = app.globalData.company.svcPort
  161. return params
  162. },
  163. /**
  164. * @desc : 数据保存
  165. * @author : 刘尧
  166. * @date : 2024/6/18 17:12
  167. */
  168. saveData(params) {
  169. return this.excute(this.data.companyService, this.data.companyService.transferHead, params);
  170. },
  171. /**
  172. * @desc : 选择用户回调
  173. * @date : 2024/6/21 14:03
  174. * @author : 刘尧
  175. */
  176. chooseData(e) {
  177. const data = e.detail.data.data
  178. const formData = JSON.parse(this.data.formData)
  179. formData.owner = data.id
  180. formData.cpManager = data.name
  181. formData.cpPhone = data.staffPhone
  182. const contentObj = this.data.contentObj
  183. const index = contentObj.main.findIndex(res => res.code === "cpManager")
  184. contentObj.main[index].type = 'str'
  185. contentObj.main[index].urlKey = ''
  186. contentObj.main[index].required = true
  187. contentObj.main[index].readonly = true
  188. const buttonList = [{
  189. code: 'save',
  190. title: mixins.$t('save')
  191. }]
  192. this.setData({
  193. contentObj: contentObj,
  194. formData: JSON.stringify(formData),
  195. buttonFootList: buttonList
  196. })
  197. },
  198. /**
  199. * @desc : 加载数据
  200. * @date : 2024/2/1 15:49
  201. * @author : 姜永辉
  202. */
  203. close(e) {
  204. wx.navigateBack({
  205. data: 1
  206. })
  207. },
  208. /**
  209. * @desc : 给表单赋值
  210. * @date : 2024/2/1 15:49
  211. * @author : 姜永辉
  212. */
  213. setValuesByEdit(data) {
  214. let contentObj = this.data.contentObj
  215. this.setData({
  216. formData: JSON.stringify(data)
  217. })
  218. if (data.gradeCode == Constants.gradeCode.PRO) {
  219. contentObj.main.unshift({
  220. code: 'gradeName',
  221. type: 'str',
  222. readonly: 'true',
  223. title: mixins.$t('professionalVersion')
  224. })
  225. } else {
  226. contentObj.main.unshift({
  227. code: 'gradeName',
  228. type: 'str',
  229. readonly: 'true',
  230. title: mixins.$t('standardVersion')
  231. })
  232. }
  233. this.setData({
  234. contentObj: contentObj
  235. })
  236. },
  237. })