| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- const _Http = getApp().globalData.http;
- Component({
- properties: {
- disabled: {
- type: Boolean
- },
- },
- options: {
- addGlobalClass: true,
- },
- data: {
- yearArr: [],
- pickerIndex: 0,
- domainList: null, //领域列表
- createYear: null,
- "content": {
- nocache: true,
- "sys_enterpriseid": 1, //企业id
- "sa_contractid": 1,
- total: null,
- "where": {
- year: "",
- tradefield: ""
- }
- },
- domainList: ['全部'],
- domainIndex: 0,
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- }
- },
- methods: {
- /* 获取产品列表 */
- getList(id, init = false) {
- let sys_enterpriseid = getCurrentPages()[getCurrentPages().length - 1].data.detail.sys_enterpriseid;
- _Http.basic({
- "id": 20230103102302,
- "content": {
- sys_enterpriseid,
- pageSize: 9999
- }
- }).then(res => {
- console.log("获取开启年度", res)
- this.setData({
- yearArr: res.data.length == 0 ? [new Date().getFullYear()] : res.data.map(v => v.year),
- pickerIndex: res.data.length == 0 ? 0 : res.data.length - 1,
- "content.sys_enterpriseid": sys_enterpriseid,
- "content.sa_contractid": sys_enterpriseid,
- "content.where.year": res.data.length == 0 ? new Date().getFullYear() : res.data[res.data.length - 1].year,
- "content.total": res.total
- });
- this.getList1(init)
- });
- /* 获取领域 */
- _Http.basic({
- "id": 20221223141802,
- "content": {
- "pageNumber": 1,
- "pageSize": 9999,
- "where": {
- "condition": ""
- }
- }
- }, false).then(res => {
- console.log("获取领域", res)
- let domainList = []
- if (res.code == '1') domainList = res.data.map(v => {
- return {
- name: getApp().globalData.Language.getMapText(v.tradefield),
- tradefield: v.tradefield
- }
- });
- domainList.unshift({
- name: getApp().globalData.Language.getMapText("全部"),
- tradefield: "全部"
- })
- this.setData({
- domainList
- });
- })
- },
- getList1(init = false, isEdit = false) {
- let content = this.data.content;
- if (init) content.pageNumber = 1
- _Http.basic({
- "id": "20221209150102",
- content
- }).then(res => {
- console.log("业绩目标", res)
- if (res.code != '1') return wx.showToast({
- title: res.data,
- icon: "none"
- })
- this.setData({
- list: res.data,
- "content.total": res.total,
- })
- if (isEdit) this.editObjective();
- })
- },
- bindDateChange(e) {
- this.setData({
- "content.where.year": this.data.yearArr[e.detail.value]
- });
- this.getList1(true)
- },
- domainChange(e) {
- let tradefield = this.data.domainList[e.detail.value].tradefield;
- this.setData({
- "content.where.tradefield": tradefield == '全部' ? "" : tradefield,
- domainIndex: e.detail.value
- });
- this.getList1(true)
- },
- /* 编辑年度 */
- editObjective() {
- if (this.data.list.length == 0) return wx.showToast({
- title: getApp().globalData.Language.getMapText('当前年度还未开启'),
- icon: "none"
- });
- wx.navigateTo({
- url: '/packageA/contract/modules/objective/add?params=' + JSON.stringify(this.data.list[0]),
- fail(err) {
- console.log(err)
- }
- })
- },
- submit(e) {
- let that = this;
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.joint([{
- t: 1,
- v: '是否确认保存',
- r: " "
- }, {
- v: e.year,
- r: " "
- }, {
- t: 1,
- v: '年度目标'
- }]),
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- complete: (res) => {
- if (res.confirm) _Http.basic({
- id: "20221229111502",
- content: {
- ...e,
- sa_contractid: that.data.content.sa_contractid
- }
- }).then(res => {
- console.log('保存年度目标', res)
- wx.showToast({
- title: res.code == '1' ? getApp().globalData.Language.getMapText('保存成功') : res.msg,
- icon: "none"
- })
- if (res.code == '1') {
- that.setData({
- ['list[0]']: e
- })
- setTimeout(wx.navigateBack, 500)
- }
- })
- }
- })
- },
- }
- })
|