123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- const getHeight = require("../../utils/getRheRemainingHeight"),
- _Http = getApp().globalData.http;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- myProject: false,
- list: [],
- total: null,
- projectList: null,
- sa_salesforecastmodelid: null,
- "content": {
- "nocache": true,
- "sa_salesforecastbillid": null,
- "pageNumber": 1,
- "pageSize": 20,
- "pageTotal": 1,
- "where": {
- "condition": ""
- }
- },
- },
- onLoad(options) {
- this.setData({
- 'content.sa_salesforecastbillid': options.id,
- 'sa_salesforecastmodelid': options.mId
- })
- this.getList();
- if (options.my) this.setData({
- myProject: true
- })
- },
- /* 添加项目 */
- addProjece() {
- _Http.basic({
- "id": 20220906154803,
- "version": 1,
- "content": {
- "nocache": true,
- pageSize: 9999,
- "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
- "where": {
- "condition": ""
- }
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setData({
- projectList: res.data
- });
- this.selectComponent("#Plist").setData({
- show: true
- })
- })
- },
- getList(init = false) {
- if (init.detail != undefined) init = init.detail;
- if (init) this.setData({
- ['content.pageNumber']: 1
- })
- if (this.data.content.pageNumber > this.data.content.pageTotal) return;
- return _Http.basic({
- "id": 20220916115203,
- "version": 1,
- content: this.data.content
- }).then(res => {
- console.log("列表", res)
- this.selectComponent('#ListBox').RefreshToComplete();
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- const list = res.data.filter(v => v.sa_projectid != 0);
- this.setData({
- 'content.pageNumber': res.pageNumber + 1,
- 'content.pageTotal': res.pageTotal,
- list: res.pageNumber == 1 ? list : this.data.list.concat(list),
- total: res.total
- })
- })
- },
- /* 得到结果创建项目 */
- getResult({
- detail
- }) {
- _Http.basic({
- "id": 20220916134103,
- "version": 1,
- "content": {
- "sa_salesforecastmodelid": this.data.sa_salesforecastmodelid,
- "sa_salesforecastbillid": this.data.content.sa_salesforecastbillid,
- "sa_projectids": detail
- }
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.getList(true)
- })
- },
- /* 开始搜索 */
- startSearch({
- detail
- }) {
- this.setData({
- 'content.where.condition': detail.trim()
- });
- this.getList(true);
- },
- cancelSearch() {
- this.setData({
- 'content.where.condition': ""
- });
- this.getList(true);
- },
- onReady() {
- //滚动区域高度
- getHeight.getHeight('#Search', this).then(res => this.setData({
- scrollHeight: res
- }))
- },
- onClose(event) {
- const {
- instance
- } = event.detail;
- instance.close();
- },
- /* 删除提报 */
- deleteProject(e) {
- const {
- item
- } = e.currentTarget.dataset, that = this;
- wx.showModal({
- title: "提示",
- content: `是否确认删除${item.projectname}`,
- success({
- confirm
- }) {
- if (confirm) _Http.basic({
- "id": 20220908134803,
- "version": 1,
- "content": {
- "sa_salesforecastbillid": item.sa_salesforecastbillid
- }
- }).then(res => {
- console.log(res)
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- let arr = that.data.list.filter(v => v.sa_salesforecastbillid != item.sa_salesforecastbillid);
- that.setData({
- list: arr
- })
- wx.showToast({
- title: '删除成功',
- icon: 'none'
- })
- })
- }
- })
- },
- toReportForms(e) {
- const {
- item
- } = e.currentTarget.dataset;
- let isEdit = this.data.myProject;
- item.sa_salesforecastmodelid = this.data.sa_salesforecastmodelid;
- wx.navigateTo({
- url: `./reportForms?item=${JSON.stringify(item)}&isEdit=${isEdit}`,
- })
- },
- onShareAppMessage() {}
- })
|