detail.js 8.7 KB

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