| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- tabsActive: 1, //tabs 选中项
- sa_competitorid: 0,
- detail: {}, //详情数据
- briefs: [], //简介列表
- tabsList: [{
- label: "详细信息",
- icon: "icon-tabxiangxixinxi1"
- }, {
- label: "参与项目",
- icon: "icon-tabxiangmu"
- }, {
- label: "地址管理",
- icon: "icon-tabdizhi"
- }, {
- label: "联系人",
- icon: "icon-tablianxiren"
- }, {
- label: "跟进动态",
- icon: "icon-tabgenjinjilu"
- }, {
- label: "操作记录",
- icon: "icon-tabcaozuojilu1"
- }, {
- label: "附件",
- icon: "icon-tabfujian1"
- }, {
- label: "任务",
- icon: "icon-tabrenwu"
- }],
- list1: [], //基本信息
- list2: [], //系统信息
- },
- onLoad(options) {
- this.setData({
- sa_competitorid: options.id,
- isAdmin: wx.getStorageSync('auth').wPublicCustomer.options.some(v => v == "admin"), //是否具有管理权限
- })
- this.getDetail();
- },
- //详情按钮回调
- tabbarOnClick({
- detail
- }) {
- let data = this.data.detail;
- switch (detail.label) {
- case "跟进":
- wx.navigateTo({
- url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_competitor&ownerid=${data.sa_competitorid}`,
- })
- break;
- case "编辑":
- wx.navigateTo({
- url: `/packageA/opponent/add?data=${JSON.stringify(data)}`,
- })
- break;
- case "作废":
- wx.navigateTo({
- url: `/packageA/setclient/delete?item=${JSON.stringify({
- "sa_competitorids": [this.data.detail.sa_competitorid],
- datastatus: 1, //(0:正常;1:作废;2:锁定)
- })}&id=20221018164202`,
- })
- break;
- case "查看重复":
- _Http.basic({
- "id": 20230324132602,
- "content": data
- }).then(res => {
- console.log("查看重复", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- this.setData({
- repetitionList: res.data,
- repetitionShow: true
- })
- })
- break;
- default:
- console.log(detail)
- break;
- }
- },
- /* 前去重复项详情 */
- toRepDetail(e) {
- const {
- item
- } = e.currentTarget.dataset;
- wx.navigateTo({
- url: '/packageA/opponent/detail?id=' + item.sa_competitorid,
- })
- this.repClose()
- },
- /* 关闭查重 */
- repClose() {
- this.setData({
- repetitionShow: false
- })
- },
- /* 获取详情 */
- getDetail() {
- /* 基本信息 */
- _Http.basic({
- "id": 20221019105802,
- "content": {
- nocache: true,
- sa_competitorid: this.data.sa_competitorid
- },
- }).then(res => {
- console.log("竞争对手详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- /* 摘要信息 */
- let briefs = [{
- label: "品牌",
- value: res.data.brandname
- }, {
- label: "优势信息",
- value: res.data.advantage
- }, {
- label: "劣势信息",
- value: res.data.inferiority
- }];
- /* 基本信息 */
- let list1 = [{
- label: "名称",
- value: res.data.enterprisename
- }, {
- label: "品牌",
- value: res.data.brandname
- }, {
- label: "优势信息",
- value: res.data.advantage
- }, {
- label: "劣势信息",
- value: res.data.inferiority
- }, {
- label: "备注信息",
- value: res.data.remarks
- }];
- /* 系统信息 */
- let list2 = [{
- label: "创建人",
- value: res.data.createby
- }, {
- label: "创建时间",
- value: res.data.createdate
- }, {
- label: "最近编辑人",
- value: res.data.changeby
- }, {
- label: "最近编辑时间",
- value: res.data.changedate
- }];
- let tabbarList = [];
- if (this.data.isAdmin || res.data.createuserid == wx.getStorageSync('userMsg').userid) tabbarList = [{
- icon: "icon-bianji",
- label: "编辑"
- }, {
- icon: "icon-shanchu",
- label: "作废"
- }]
- if (wx.getStorageSync('auth').wPublicCustomer.options.some(v => v == "viewRepetition")) tabbarList.push({
- icon: "icon-a-shouyejingangquhehuoren",
- label: "查看重复"
- });
- this.setData({
- detail: res.data,
- briefs,
- list1,
- list2,
- tabbarList
- });
- //获取标签
- this.getTags();
- this.partialRenewal();
- });
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- //局部数据更新 tabs
- partialRenewal(init = false) {
- let id = this.data.detail.sa_competitorid;
- let model = '';
- let name = this.data.tabsList[this.data.tabsActive].label;
- switch (name) {
- case "任务":
- model = "#Work"
- break;
- case "参与项目":
- model = "#Project"
- break;
- case "跟进动态":
- model = "#Trace"
- break;
- case "操作记录":
- model = "#Record"
- break;
- case "附件":
- model = "#Files"
- break;
- case "地址管理":
- id = this.data.detail.sys_enterpriseid;
- model = "#Address"
- break;
- case "联系人":
- id = this.data.detail.sys_enterpriseid;
- model = "#Contacts"
- break;
- };
- if (model) {
- // 确定好模块ID total = null 是第一次加载 加载数据
- // init是新增或修改需要清数据
- let Component = this.selectComponent(model);
- const {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content;
- if (total == null || init) {
- console.log(1)
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- console.log(2)
- Component.getList(id, false);
- } else {
- //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
- }
- }
- },
- //更新标签
- getTags() {
- this.selectComponent("#Tags").getTags();
- },
- onReachBottom() {
- this.partialRenewal();
- },
- onUnload() {
- const page = getCurrentPages().find(v => v.__route__ == 'packageA/opponent/index');
- if (!page) return;
- let content = JSON.parse(JSON.stringify(page.data.content));
- content.pageSize = (content.pageNumber - 1) * content.pageSize;
- content.pageNumber = 1;
- _Http.basic({
- id: 20221018164302,
- content
- }).then(res => {
- console.log("更新竞争对手列表", res);
- if (res.msg == '成功') {
- page.data.content.total = res.total;
- page.getTags();
- }
- })
- }
- })
|