detail.js 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. isShowTabbar: true, //是否显示底部
  5. tabsActive: 1, //tabs 选中项
  6. sa_competitorid: 0,
  7. detail: {}, //详情数据
  8. briefs: [], //简介列表
  9. tabsList: [{
  10. label: "详细信息",
  11. icon: "icon-tabxiangxixinxi1"
  12. }, {
  13. label: "参与项目",
  14. icon: "icon-tabxiangmu"
  15. }, {
  16. label: "地址管理",
  17. icon: "icon-tabdizhi"
  18. }, {
  19. label: "联系人",
  20. icon: "icon-tablianxiren"
  21. }, {
  22. label: "跟进动态",
  23. icon: "icon-tabgenjinjilu"
  24. }, {
  25. label: "操作记录",
  26. icon: "icon-tabcaozuojilu1"
  27. }, {
  28. label: "附件",
  29. icon: "icon-tabfujian1"
  30. }, {
  31. label: "任务",
  32. icon: "icon-tabrenwu"
  33. }],
  34. list1: [], //基本信息
  35. list2: [], //系统信息
  36. tabbarList: [{
  37. icon: "icon-bianji",
  38. label: "编辑"
  39. }, {
  40. icon: "icon-shanchu",
  41. label: "作废"
  42. }]
  43. },
  44. onLoad(options) {
  45. this.setData({
  46. sa_competitorid: options.id,
  47. isAdmin: wx.getStorageSync('auth').wPublicCustomer.options.some(v => v == "admin"), //是否具有管理权限
  48. })
  49. this.getDetail();
  50. },
  51. //详情按钮回调
  52. tabbarOnClick({
  53. detail
  54. }) {
  55. let data = this.data.detail;
  56. switch (detail.label) {
  57. case "跟进":
  58. wx.navigateTo({
  59. url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_competitor&ownerid=${data.sa_competitorid}`,
  60. })
  61. break;
  62. case "编辑":
  63. wx.navigateTo({
  64. url: `/packageA/opponent/add?data=${JSON.stringify(data)}`,
  65. })
  66. break;
  67. case "作废":
  68. wx.navigateTo({
  69. url: `/packageA/setclient/delete?item=${JSON.stringify({
  70. "sa_competitorids": [this.data.detail.sa_competitorid],
  71. datastatus: 1, //(0:正常;1:作废;2:锁定)
  72. })}&id=20221018164202`,
  73. })
  74. break;
  75. default:
  76. console.log(detail)
  77. break;
  78. }
  79. },
  80. /* 获取详情 */
  81. getDetail() {
  82. /* 基本信息 */
  83. _Http.basic({
  84. "id": 20221019105802,
  85. "content": {
  86. nocache: true,
  87. sa_competitorid: this.data.sa_competitorid
  88. },
  89. }).then(res => {
  90. console.log("竞争对手详情", res)
  91. if (res.msg != '成功') return wx.showToast({
  92. title: res.data,
  93. icon: "none"
  94. })
  95. /* 摘要信息 */
  96. let briefs = [{
  97. label: "品牌",
  98. value: res.data.brandname
  99. }, {
  100. label: "优势信息",
  101. value: res.data.advantage
  102. }, {
  103. label: "劣势信息",
  104. value: res.data.inferiority
  105. }];
  106. /* 基本信息 */
  107. let list1 = [{
  108. label: "名称",
  109. value: res.data.enterprisename
  110. }, {
  111. label: "品牌",
  112. value: res.data.brandname
  113. }, {
  114. label: "优势信息",
  115. value: res.data.advantage
  116. }, {
  117. label: "劣势信息",
  118. value: res.data.inferiority
  119. }, {
  120. label: "备注信息",
  121. value: res.data.remarks
  122. }];
  123. /* 系统信息 */
  124. let list2 = [{
  125. label: "创建人",
  126. value: res.data.createby
  127. }, {
  128. label: "创建时间",
  129. value: res.data.createdate
  130. }, {
  131. label: "最近编辑人",
  132. value: res.data.changeby
  133. }, {
  134. label: "最近编辑时间",
  135. value: res.data.changedate
  136. }];
  137. this.setData({
  138. detail: res.data,
  139. briefs,
  140. list1,
  141. list2,
  142. isShowTabbar: this.data.isAdmin || res.data.createuserid == wx.getStorageSync('userMsg').userid
  143. });
  144. //获取标签
  145. this.getTags();
  146. this.partialRenewal();
  147. });
  148. },
  149. //tabs 切换
  150. tabsChange({
  151. detail
  152. }) {
  153. this.setData({
  154. tabsActive: detail
  155. });
  156. this.partialRenewal();
  157. },
  158. //局部数据更新 tabs
  159. partialRenewal(init = false) {
  160. let id = this.data.detail.sa_competitorid;
  161. let model = '';
  162. let name = this.data.tabsList[this.data.tabsActive].label;
  163. switch (name) {
  164. case "任务":
  165. model = "#Work"
  166. break;
  167. case "参与项目":
  168. model = "#Project"
  169. break;
  170. case "跟进动态":
  171. model = "#Trace"
  172. break;
  173. case "操作记录":
  174. model = "#Record"
  175. break;
  176. case "附件":
  177. model = "#Files"
  178. break;
  179. case "地址管理":
  180. id = this.data.detail.sys_enterpriseid;
  181. model = "#Address"
  182. break;
  183. case "联系人":
  184. id = this.data.detail.sys_enterpriseid;
  185. model = "#Contacts"
  186. break;
  187. };
  188. if (model) {
  189. // 确定好模块ID total = null 是第一次加载 加载数据
  190. // init是新增或修改需要清数据
  191. let Component = this.selectComponent(model);
  192. const {
  193. total,
  194. pageNumber,
  195. pageTotal
  196. } = Component.data.content;
  197. if (total == null || init) {
  198. console.log(1)
  199. Component.getList(id, init);
  200. } else if (pageNumber <= pageTotal) {
  201. console.log(2)
  202. Component.getList(id, false);
  203. } else {
  204. //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
  205. }
  206. }
  207. },
  208. //更新标签
  209. getTags() {
  210. this.selectComponent("#Tags").getTags();
  211. },
  212. onReachBottom() {
  213. this.partialRenewal();
  214. },
  215. onShareAppMessage() {}
  216. })