| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- const _Http = getApp().globalData.http;
- Component({
- options: {
- addGlobalClass: true
- },
- properties: {
- disabled: {
- type: Boolean,
- value: true
- }
- },
- lifetimes: {
- attached: function () {
- getApp().globalData.Language.getLanguagePackage(this)
- },
- },
- data: {
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 10,
- pageTotal: 1,
- total: null,
- where: {
- condition: ""
- }
- },
- list: [],
- showSearch: false,
- focus: false,
- condition: "",
- sa_competitor_advid: 0
- },
- methods: {
- toSearch() {
- if (this.data.showSearch && this.data.content.where.condition) {
- this.data.content.where.condition = '';
- this.getList("", true);
- } else if (this.data.condition) {
- this.data.content.where.condition = this.data.condition;
- this.setData({
- condition: this.data.condition
- })
- this.getList("", true);
- }
- this.setData({
- showSearch: !this.data.showSearch
- })
- setTimeout(() => {
- this.setData({
- focus: this.data.showSearch
- })
- }, 300)
- },
- onChange({
- detail
- }) {
- this.data.condition = detail;
- },
- onSearch({
- detail
- }) {
- this.data.content.where.condition = detail;
- this.getList("", true)
- },
- getList(id, init = false) {
- let content = this.data.content
- content.sa_competitorid = id || content.sa_competitorid;
- if (init) {
- content.pageNumber = 1
- content.pageTotal = 1
- }
- _Http.basic({
- "id": 2025031809222102,
- content
- }).then(res => {
- console.log("优劣势列表", res)
- if (res.code != '1') return wx.showToast({
- title: res.data,
- icon: "none"
- });
- content.pageNumber = res.pageNumber + 1
- content.pageTotal = res.pageTotal
- content.total = res.total
- let defaultItem = res.data.find(v => v.isdefault)
- if (defaultItem) this.setData({
- sa_competitor_advid: defaultItem.sa_competitor_advid
- })
- this.setData({
- list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
- content
- })
- })
- },
- /* 去添加 */
- toAdd() {
- wx.navigateTo({
- url: `/packageA/opponent/modules/aAD/insert?id=` + this.data.content.sa_competitorid,
- })
- },
- handleDelete(item) {
- let that = this;
- return new Promise((resolve) => {
- wx.showModal({
- title: getApp().globalData.Language.getMapText('提示'),
- content: getApp().globalData.Language.getMapText('是否确定删除该跟进动态'),
- complete: ({
- confirm
- }) => {
- if (confirm) {
- _Http.basic({
- "id": 20220930121701,
- "content": {
- "sys_datafollowupid": item.sys_datafollowupid,
- "ownertable": that.data.ownertable,
- "ownerid": that.data.ownerid,
- deletereason: ""
- }
- }).then(res => {
- console.log("删除", res);
- getApp().globalData.Language.showToast(res.code != 1 ? res.msg : "删除成功")
- resolve(res.code)
- if (res.msg != '成功') return;
- that.setData({
- list: that.data.list.filter(v => v.sys_datafollowupid != item.sys_datafollowupid),
- 'content.total': that.data.content.total - 1
- })
- })
- } else {
- resolve(0)
- }
- }
- })
- })
- },
- changeDefault({
- detail
- }) {
- _Http.basic({
- "content": {
- "sa_competitor_advid": detail
- },
- "id": 2025031809224302,
- }).then(res => {
- console.log("切换默认", res)
- this.updataDetail()
- })
- },
- handleItem(e) {
- console.log(e)
- const {
- item,
- name
- } = e.target.dataset,
- that = this;
- if (name == 'delete') {
- wx.showModal({
- content: getApp().globalData.Language.getMapText('是否确定删除') + '?',
- cancelText: getApp().globalData.Language.getMapText('取消'),
- confirmText: getApp().globalData.Language.getMapText('确定'),
- complete: ({
- confirm
- }) => {
- if (confirm) _Http.basic({
- "content": {
- "sa_competitor_advid": item.sa_competitor_advid
- },
- "id": 2025031809214002,
- }).then(res => {
- console.log("删除", res)
- getApp().globalData.Language.showToast(res.code != 1 ? res.msg : "删除成功")
- if (res.code == 1) {
- that.setData({
- list: that.data.list.filter(v => v.sa_competitor_advid != item.sa_competitor_advid),
- "content.total": that.data.content.total - 1
- })
- if (item.isdefault) this.updataDetail()
- }
- })
- }
- })
- } else {
- wx.navigateTo({
- url: `/packageA/opponent/modules/aAD/insert?id=` + that.data.content.sa_competitorid + '&data=' + JSON.stringify(item),
- })
- }
- },
- updataDetail() {
- getCurrentPages().find(v => v.__route__ == 'packageA/opponent/detail').getDetail()
- }
- }
- })
|