detail.js 8.3 KB

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