123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- year: new Date().getFullYear(),
- content: {
- "year": new Date().getFullYear(),
- "hrid": wx.getStorageSync('userMsg').hrid,
- "pageNumber": 1,
- "pageTotal": 1,
- "pageSize": 20,
- "where": {
- "condition": ""
- },
- },
- projectList: []
- },
- onLoad(options) {
- this.setData({
- year: options.year,
- 'content.year': options.year
- })
- this.getList();
- this.getProjectList();
- },
- /* 添加项目 */
- getResult({
- detail
- }) {
- let project = [];
- detail.forEach(v => {
- let data = this.data.projectList.find(value => value.sa_projectid == v);
- project.push({
- "target_l": '',
- "target_h": '',
- "month": '',
- ...data
- })
- });
- wx.navigateTo({
- url: './addProject?data=' + JSON.stringify(project) + '&year=' + this.data.year,
- })
- },
- /* 选择年份 */
- bindDateChange({
- detail
- }) {
- if (this.data.year == detail.value) return;
- this.setData({
- "year": detail.value,
- "content.year": detail.value
- });
- this.getList(true);
- },
- getList(init = false) {
- //init 用于初始化分页
- if (init.detail != undefined) init = init.detail;
- if (init) this.setData({
- ['content.pageNumber']: 1
- })
- if (this.data.content.pageNumber > this.data.content.pageTotal) return;
- _Http.basic({
- "id": 20220906104002,
- "content": this.data.content
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setData({
- list: res.data,
- 'content.pageNumber': res.pageNumber + 1,
- 'content.pageTotal': res.pageTotal,
- total: res.total
- })
- })
- },
- getProjectList() {
- _Http.basic({
- "id": 20220905151902,
- "content": {
- pageSize: 99999,
- "where": {
- "condition": ""
- }
- },
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setData({
- projectList: res.data
- })
- })
- },
- /* 删除项目 */
- deleteItem(e) {
- const {
- item
- } = e.currentTarget.dataset,
- that = this;
- wx.showModal({
- title: '提示',
- content: `是否确认删除${item.projectname}`,
- success({
- confirm
- }) {
- if (confirm) {
- _Http.basic({
- "id": 20220905165302,
- "content": {
- "sa_salestargetid": [
- item.sa_salestargetid
- ]
- },
- }).then(res => {
- if (res.msg != '成功') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- that.setData({
- list: that.data.list.filter(v => v.sa_salestargetid != item.sa_salestargetid)
- })
- wx.showToast({
- title: '删除成功',
- icon: "none"
- })
- })
- }
- }
- })
- },
- /* 开启添加项目 */
- addProject() {
- this.selectComponent("#Plist").setData({
- show: true
- })
- },
- onReachBottom() {
- this.getList();
- },
- onShareAppMessage() {}
- })
|