| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- loading: true,
- isLeader: false, //是否为负责人
- tabsActive: 1, //tabs 选中项
- sat_campaignid: 0
- },
- onLoad(options) {
- const appAuth = wx.getStorageSync('auth').wmarketing_activity;
- this.setData({
- sat_campaignid: options.id,
- appAuth
- })
- this.getDetail();
- },
- /* 获取详情 */
- getDetail() {
- _Http.basic({
- "classname": "webmanage.saletool.orderclue.ordercluecampaign",
- "method": "queryCampaignMain",
- "content": {
- sat_campaignid: this.data.sat_campaignid
- }
- }).then(res => {
- console.log("详情", res)
- if (res.code != '1') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setPreview(res);
- this.setData({
- loading: false,
- detail: res.data,
- })
- //获取标签
- if (this.data.appAuth.isdatatag) this.getTags();
- if (this.data.appAuth.isdatateam) this.getGroup()
- this.setTabbar();
- this.partialRenewal();
- });
- },
- setPreview(res) {
- /* 摘要信息 */
- let briefs = [{
- label: "活动类型",
- value: res.data.type
- }, {
- label: "承办医院",
- value: res.data.hospitalname
- }, {
- label: "科室",
- value: res.data.hospitaldepname
- }, {
- label: "申请金额",
- value: _Http.formatMoney(res.data.amount),
- style: `color:#FF3B30`
- }, {
- label: "实际发生金额",
- value: _Http.formatMoney(res.data.actualAmount),
- style: `color:#FF3B30`
- }, {
- label: "活动地址",
- value: res.data.province + res.data.city + res.data.county + res.data.address
- }, {
- label: "创建人",
- value: res.data.createby
- }];
- /* 基本信息 */
- let list1 = [{
- label: "活动名称",
- value: res.data.name
- }, {
- label: "承办医院",
- value: res.data.hospitalname
- }, {
- label: "科室",
- value: res.data.hospitaldepname
- }, {
- label: "活动类型",
- value: res.data.type
- }, {
- label: "活动性质",
- value: res.data.activitytype
- }, {
- label: "活动地址",
- value: res.data.province + res.data.city + res.data.county + res.data.address
- }, {
- label: "开始日期",
- value: res.data.begdate
- }, {
- label: "结束日期",
- value: res.data.enddate
- }, {
- label: "申请金额",
- value: _Http.formatMoney(res.data.amount)
- }, {
- label: "实际发生金额",
- value: _Http.formatMoney(res.data.actualAmount)
- }, {
- label: "产品总培训费",
- value: _Http.formatMoney(res.data.doctorAmount)
- }, {
- label: "负责人",
- value: res.data.leader ? res.data.leader[0].name : '--'
- }];
- /* 系统信息 */
- let list2 = [{
- label: "创建人",
- value: res.data.createby
- }, {
- label: "创建时间",
- value: res.data.createdate
- }, {
- label: "最近编辑人",
- value: res.data.changeby
- }, {
- label: "最近编辑时间",
- value: res.data.changedate
- }, {
- label: "转手次数",
- value: res.data.leader ? res.data.leader[0].leadernum : 0
- }];
- this.setData({
- briefs,
- list1,
- list2
- });
- },
- //详情按钮回调
- tabbarOnClick({
- detail
- }) {
- let data = this.data.detail,
- that = this;
- switch (detail.label) {
- case "编辑":
- wx.navigateTo({
- url: `/prsx/activity/insert?data=${JSON.stringify(data)}`,
- })
- break;
- case "跟进":
- that.selectComponent("#Trace").toAdd()
- break;
- default:
- console.log(detail)
- break;
- }
- },
- /* 底部功能 */
- async setTabbar() {
- let detail = this.data.detail,
- isAdmin = this.data.isAdmin,
- isLeader = detail.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
- editdataleader = isLeader ? 1 : 0,
- tabbarList = [],
- appAuth = this.data.appAuth,
- tabsList = [{
- label: "详细信息",
- icon: "icon-tabxiangxixinxi1"
- }, {
- label: "参与医生",
- icon: "icon-yisheng",
- model: "#Doctors"
- }];
- if (!isLeader) {
- let res = await getApp().agentOrNot("sat_campaign", this.data.sat_campaignid),
- data = res.code == '1' ? res.data : {
- editable: 0,
- editdataleader: 0
- }
- if (appAuth.isdatateam) isLeader = this.selectComponent("#Group").data.editable == 1;
- if (!isLeader) isLeader = data.editable == 1;
- editdataleader = data.editdataleader;
- }
- if (appAuth.isdatafollowup) {
- tabsList.push({
- label: "跟进动态",
- icon: "icon-tabgenjinjilu",
- model: "#Trace"
- })
- if (detail.status != '已终止') tabbarList.push({
- icon: "color-genjin",
- label: "跟进"
- });
- }
- tabsList = tabsList.concat([{
- label: "附件",
- icon: "icon-tabfujian1",
- model: "#Files"
- }, {
- label: "操作",
- icon: "icon-tabcaozuojilu1",
- model: "#Record"
- }])
- if (isLeader || isAdmin) {
- tabbarList.push({
- icon: "color-bianji",
- label: "编辑"
- })
- }
- this.setData({
- tabbarList,
- isLeader,
- tabsList
- })
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- //局部数据更新 tabs
- partialRenewal(init = false) {
- try {
- let model = this.data.tabsList[this.data.tabsActive].model;
- if (model) {
- let Component = this.selectComponent(model),
- {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content,
- id = this.data.detail.sat_campaignid;
- if (model == "#Files") init = true;
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- Component.getList(id, false);
- }
- }
- } catch (error) {
- }
- },
- //更新标签
- getTags() {
- this.selectComponent("#Tags").getTags()
- },
- //更新团队成员
- getGroup() {
- this.selectComponent("#Group").getList().then(this.setTabbarList)
- },
- onReachBottom() {
- this.partialRenewal();
- },
- onUnload() {
- const page = getCurrentPages().find(v => v.__route__ == 'prsx/activity/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: '20221101095102',
- content
- }).then(res => {
- console.log("更新列表", res);
- if (res.code == '1') {
- res.data = res.data.map(v => {
- v.amount = _Http.formatMoney(v.amount)
- v.actualAmount = _Http.formatMoney(v.actualAmount)
- return v
- })
- page.setData({
- list: res.data,
- "content.total": res.total
- })
- }
- })
- }
- })
|