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