| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- isAdmin: getApp().globalData.auth.wcontract.options.some(v => v == "admin"), //是否具有管理权限
- isLeader: false, //是否为负责人
- options: getApp().globalData.auth.wcontract.options, //权限列表
- tabsActive: 0, //tabs 选中项
- sa_contractid: "",
- tabsList: [{
- label: "详细信息",
- num: 132
- }],
- tabbarList: [{
- icon: "icon-genjin",
- label: "跟进"
- }],
- },
- onLoad(options) {
- this.setData({
- sa_contractid: options.sa_contractid
- });
- this.getDetail();
- },
- getDetail() {
- _Http.basic({
- "id": 20221121195102,
- "content": {
- nocache: true,
- "sa_contractid": this.data.sa_contractid
- },
- }).then(res => {
- console.log("合同详情", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- let isLeader = res.data.leader.some(some => some.userid == wx.getStorageSync('userMsg').userid),
- tabbarList = this.data.tabbarList;
- if (this.data.isAdmin) tabbarList = [{
- icon: "icon-genjin",
- label: "审核"
- }, {
- icon: "icon-genjin",
- label: "反审核"
- }].concat(tabbarList);
- if (isLeader || this.data.isAdmin) tabbarList = tabbarList.concat([{
- icon: "icon-genjin",
- label: "提交"
- }, {
- icon: "icon-genjin",
- label: "终止"
- }, {
- icon: "icon-zhuanyi",
- label: "更换负责人"
- }, {
- icon: "icon-shanchu",
- label: "作废"
- }])
- let data = res.data,
- tabsList = this.data.tabsList,
- tabsActive = 0;
- switch (data.type) {
- case "框架":
- data.type = '经销商合作协议'
- tabsList = tabsList.concat([{
- label: "产品明细折扣",
- num: 132
- }, {
- label: "产品类型折扣",
- num: 132
- }, {
- label: "跟进动态",
- num: 132
- }]);
- tabsActive = 1;
- break;
- case "工具借用":
- data.type = '工具使用(借出)协议'
- tabsList = tabsList.concat([{
- label: "工具清单",
- num: 132
- }, {
- label: "跟进动态",
- num: 132
- }]);
- tabsActive = 1;
- break;
- case "居间":
- data.type = '居间协议'
- break;
- case "项目":
- /* {
- label: "合同条款",
- num: 132
- }, */
- data.type = data.typemx + '项目协议'
- tabsList = tabsList.concat([{
- label: "产品清单",
- num: 132
- }, {
- label: "跟进动态",
- num: 132
- }]);
- tabsActive = 1;
- break;
- default:
- result = '--'
- break;
- };
- this.setDetail(data);
- this.setData({
- isLeader,
- tabbarList,
- detail: data,
- list2: [{
- label: "创建人",
- value: data.createby
- }, {
- label: "创建时间",
- value: data.createdate
- }, {
- label: "最近编辑人",
- value: data.changeby
- }, {
- label: "最近编辑时间",
- value: data.changedate
- }, {
- label: "最近跟进人",
- value: data.followby
- }, {
- label: "最近跟进时间",
- value: data.followdate
- }],
- tabsList,
- tabsActive
- });
- /* 更新列表数据 */
- let page = getCurrentPages().find(v => v.__route__ == 'packageA/contract/index');
- if (page) {
- let i = page.data.list.findIndex(v => v.sa_contractid == this.data.sa_contractid);
- if (i != -1) page.setData({
- [`list[${i}].status`]: res.data.status
- })
- }
- this.getTags();
- this.getGroup();
- this.partialRenewal();
- })
- },
- /* 设置详情信息 */
- setDetail(data) {
- let briefs = [{
- label: "合同编号",
- value: data.billno
- }, {
- label: "合同类型",
- value: data.type
- }, {
- label: "经销商",
- value: data.enterprisename
- }, {
- label: "整体折扣",
- value: data.discountrate
- }, {
- label: "签约时间",
- value: data.signdate
- }, {
- label: "状态",
- value: data.status
- }],
- list1 = [{
- label: "合同标题",
- value: data.title
- }, {
- label: "合同编号",
- value: data.billno
- }, {
- label: "合同类型",
- value: data.type
- }, {
- label: "合同模板",
- value: data.type
- }, {
- label: "负责人",
- value: data.leader[0].name
- },
- {
- label: "合同有效期",
- value: data.begdate + ' 至 ' + data.enddate
- }, {
- label: "签约时间",
- value: data.signdate
- }, {
- label: "合同描述",
- value: data.remarks
- }
- ];
- if (data.typemx) {
- briefs.splice(5, 0, {
- label: "签约金额",
- value: data.signamount
- })
- briefs.splice(4, 0, {
- label: "关联项目",
- value: data.projectname
- })
- list1.splice(4, 0, {
- label: "关联项目",
- value: data.projectname
- })
- list1.splice(7, 0, {
- label: "签约金额",
- value: data.signamount
- })
- } else {
- switch (data.type) {
- case "居间协议":
- briefs.splice(2, 1, {
- label: "居间服务商",
- value: data.enterprisename
- })
- briefs.splice(3, 0, {
- label: "关联项目",
- value: data.projectname
- })
- briefs.splice(5, 0, {
- label: "佣金比例",
- value: data.kickback + '%'
- })
- list1.splice(4, 0, {
- label: "居间服务商",
- value: data.enterprisename
- })
- list1.splice(5, 0, {
- label: "关联项目",
- value: data.projectname
- })
- list1.splice(8, 0, {
- label: "佣金比例",
- value: data.kickback + '%'
- })
- break;
- case "工具使用(借出)协议":
- briefs.splice(2, 1, {
- label: "客户",
- value: data.enterprisename
- })
- briefs.splice(3, 1)
- briefs.splice(4, 0, {
- label: "单套价格",
- value: data.signamount
- })
- list1.splice(5, 0, {
- label: "客户",
- value: data.enterprisename
- })
- list1.splice(8, 0, {
- label: "单套价格",
- value: data.signamount
- })
- break;
- }
- }
- this.setData({
- briefs,
- list1
- })
- },
- //tabs 切换
- tabsChange({
- detail
- }) {
- this.setData({
- tabsActive: detail
- });
- this.partialRenewal();
- },
- //更新标签
- getTags() {
- this.selectComponent("#Tags").getTags();
- },
- //更新团队成员
- getGroup() {
- this.selectComponent("#Group").getList();
- },
- //局部数据更新 tabs
- partialRenewal(init = false) {
- let id = this.data.detail.sa_contractid;
- let model = '';
- let name = this.data.tabsList[this.data.tabsActive].label;
- console.log(name)
- switch (name) {
- case "跟进动态":
- model = '#Trace'
- break;
- case "产品清单":
- model = '#Product'
- break;
- case "工具清单":
- model = '#Product'
- break;
- case "产品明细折扣":
- model = '#PiscountProduct'
- break;
- case "产品类型折扣":
- model = '#PiscountType'
- break;
- };
- if (model) {
- // 确定好模块ID total = null 是第一次加载 加载数据
- // init是新增或修改需要清数据
- let Component = this.selectComponent(model);
- const {
- total,
- pageNumber,
- pageTotal
- } = Component.data.content;
- if (total == null || init) {
- Component.getList(id, init);
- } else if (pageNumber <= pageTotal) {
- Component.getList(id, false);
- } else {
- //用来判断 在搜索页面修改,与tabs选项不一致 但是切换到该选项 重置数据
- }
- }
- },
- onReachBottom() {
- this.partialRenewal();
- },
- //详情按钮回调
- tabbarOnClick({
- detail
- }) {
- let data = this.data.detail,
- that = this;
- switch (detail.label) {
- case "终止":
- wx.showModal({
- title: '提示',
- content: `是否确定终止当前协议`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20221212102802,
- "content": {
- "sa_contractid": that.data.sa_contractid
- }
- }).then(res => {
- console.log("提交报价单", res)
- wx.showToast({
- title: res.msg == '成功' ? "已终止" : res.msg,
- icon: "none"
- })
- if (res.msg == '成功') setTimeout(() => {
- that.getDetail();
- }, 300)
- })
- }
- })
- break;
- case "提交":
- if (data.status != '新建') return wx.showToast({
- title: '当前状态不可提交!',
- icon: "none"
- })
- wx.showModal({
- title: '提示',
- content: `是否确定提交当前协议,提交后禁止使用部分功能`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20221121202802,
- "content": {
- "sa_contractids": [that.data.sa_contractid]
- }
- }).then(res => {
- console.log("提交报价单", res)
- wx.showToast({
- title: res.msg == '成功' ? "提交成功" : res.msg,
- icon: "none"
- })
- if (res.msg == '成功') setTimeout(() => {
- that.getDetail();
- }, 300)
- })
- }
- })
- break;
- case "审核":
- if (data.status != '已提交') return wx.showToast({
- title: '当前状态不可审核!',
- icon: "none"
- })
- wx.showModal({
- title: '提示',
- content: `是否通过当前协议`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20221121203102,
- "version": 1,
- "content": {
- "type": 1, //0:不通过,1:通过
- "sa_contractids": [that.data.sa_contractid]
- }
- }).then(res => {
- console.log("审核合同", res)
- wx.showToast({
- title: res.msg == '成功' ? "审核成功" : res.msg,
- icon: "none"
- })
- if (res.msg == '成功') setTimeout(() => {
- that.getDetail();
- }, 300)
- })
- }
- })
- break;
- case "反审核":
- if (data.status == '新建') return wx.showToast({
- title: '当前状态不可反审核!',
- icon: "none"
- })
- wx.showModal({
- title: '提示',
- content: `是否退回当前协议`,
- complete: (res) => {
- if (res.confirm) _Http.basic({
- "id": 20221212135402,
- "content": {
- "sa_contractid": that.data.sa_contractid,
- }
- }).then(res => {
- console.log("反审核合同", res)
- wx.showToast({
- title: res.msg == '成功' ? "反审核成功" : res.msg,
- icon: "none"
- })
- if (res.msg == '成功') setTimeout(() => {
- that.getDetail();
- }, 300)
- })
- }
- })
- break;
- case "跟进":
- wx.navigateTo({
- url: `/packageA/setclient/modules/trace/add/index?ownertable=sa_contract&ownerid=${data.sa_contractid}`,
- })
- break;
- case "作废":
- wx.showModal({
- title: '提示',
- content: '是否确认作废该协议?',
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 20221121202502,
- "version": 1,
- "content": {
- "sa_contractids": [this.data.detail.sa_contractid]
- }
- }).then(res => {
- wx.showToast({
- title: res.msg == '成功' ? '已作废协议' : res.msg,
- icon: "none"
- });
- if (res.msg == '成功') {
- setTimeout(() => {
- getCurrentPages().forEach(v => {
- if (v.__route__ == 'packageA/contract/index') {
- v.setData({
- list: v.data.list.filter(value => value.sa_contractid != this.data.detail.sa_contractid),
- 'content.total': v.data.content.total - 1
- })
- }
- })
- wx.navigateBack();
- }, 300)
- }
- })
- }
- })
- break;
- case "更换负责人":
- wx.navigateTo({
- url: `/pages/group/select?data=${JSON.stringify({
- ownertable:"sa_contract",
- ownerid:data.sa_contractid,
- })}&radio=true&principal=true`,
- })
- break;
- }
- },
- /* 更换负责人 */
- handelSubmit(arr) {
- const that = this;
- wx.showModal({
- title: '提示',
- content: '是否确认更换负责人',
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "id": 20220930103701,
- "content": {
- ownertable: "sa_contract",
- ownerid: that.data.detail.sa_contractid,
- userid: arr[0]
- }
- }).then(res => {
- console.log("更换负责人", res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- wx.showToast({
- title: '更换成功!',
- icon: "none"
- });
- setTimeout(() => {
- that.getDetail();
- wx.navigateBack();
- }, 300)
- })
- }
- })
- },
- onShareAppMessage() {}
- })
|