detail.js 9.3 KB

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