|
@@ -1,9 +1,10 @@
|
|
-import MonitorApiBase from './base'
|
|
|
|
import {
|
|
import {
|
|
- ajaxFollowEntInfo,
|
|
|
|
ajaxFollowEntAdd,
|
|
ajaxFollowEntAdd,
|
|
- ajaxFollowEntCancel
|
|
|
|
|
|
+ ajaxFollowEntCancel,
|
|
|
|
+ ajaxFollowEntInfo,
|
|
|
|
+ ajaxMonitorGroup
|
|
} from '../api/follow-ent'
|
|
} from '../api/follow-ent'
|
|
|
|
+import MonitorApiBase from './base'
|
|
|
|
|
|
export default class MonitorEntApi extends MonitorApiBase {
|
|
export default class MonitorEntApi extends MonitorApiBase {
|
|
constructor({ id }) {
|
|
constructor({ id }) {
|
|
@@ -20,6 +21,7 @@ export default class MonitorEntApi extends MonitorApiBase {
|
|
const result = this.createModel()
|
|
const result = this.createModel()
|
|
result.canFollow = res?.data?.isShow || false
|
|
result.canFollow = res?.data?.isShow || false
|
|
result.follow = res?.data?.followed || false
|
|
result.follow = res?.data?.followed || false
|
|
|
|
+ result.followedGroup = res?.data?.followedGroup || ''
|
|
|
|
|
|
if (res?.data?.info) {
|
|
if (res?.data?.info) {
|
|
result.expands = res.data.info
|
|
result.expands = res.data.info
|
|
@@ -27,42 +29,77 @@ export default class MonitorEntApi extends MonitorApiBase {
|
|
return result
|
|
return result
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
async ajaxAdd() {
|
|
async ajaxAdd() {
|
|
- return ajaxFollowEntAdd({ entId: this.id }).then((res) => {
|
|
|
|
|
|
+ return ajaxFollowEntAdd({ entId: this.id, groups: this.groupId }).then(
|
|
|
|
+ (res) => {
|
|
|
|
+ const result = {
|
|
|
|
+ success: false,
|
|
|
|
+ msg: '',
|
|
|
|
+ data: {}
|
|
|
|
+ }
|
|
|
|
+ result.success = res?.error_code === 0 && res?.data?.status
|
|
|
|
+ result.data = res?.data
|
|
|
|
+ if (result.success) {
|
|
|
|
+ this.model.expands.used += 1
|
|
|
|
+ this.model.expands.surplus = Math.max(
|
|
|
|
+ this.model.expands.surplus - 1,
|
|
|
|
+ 0
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ result.msg = res?.error_msg || '抱歉,操作失败'
|
|
|
|
+ }
|
|
|
|
+ return result
|
|
|
|
+ }
|
|
|
|
+ )
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ async ajaxRemove() {
|
|
|
|
+ return ajaxFollowEntCancel({ entId: this.id }).then((res) => {
|
|
const result = {
|
|
const result = {
|
|
success: false,
|
|
success: false,
|
|
msg: '',
|
|
msg: '',
|
|
data: {}
|
|
data: {}
|
|
}
|
|
}
|
|
- result.success = res?.error_code === 0 && res?.data?.status
|
|
|
|
|
|
+ result.success = res?.error_code === 0 && res?.data === 'success'
|
|
result.data = res?.data
|
|
result.data = res?.data
|
|
if (result.success) {
|
|
if (result.success) {
|
|
- this.model.expands.used += 1
|
|
|
|
- this.model.expands.surplus = Math.max(this.model.expands.surplus - 1, 0)
|
|
|
|
- } else {
|
|
|
|
|
|
+ this.model.expands.surplus += 1
|
|
|
|
+ this.model.expands.used = Math.max(this.model.expands.used - 1, 0)
|
|
|
|
+ this.model.followedGroup = ''
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
result.msg = res?.error_msg || '抱歉,操作失败'
|
|
result.msg = res?.error_msg || '抱歉,操作失败'
|
|
}
|
|
}
|
|
return result
|
|
return result
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- async ajaxRemove() {
|
|
|
|
- return ajaxFollowEntCancel({ entId: this.id }).then(
|
|
|
|
- (res) => {
|
|
|
|
- const result = {
|
|
|
|
- success: false,
|
|
|
|
- msg: '',
|
|
|
|
- data: {}
|
|
|
|
|
|
+
|
|
|
|
+ async ajaxGroup(params = {}) {
|
|
|
|
+ const { type, name, groupId, callback } = params
|
|
|
|
+ return ajaxMonitorGroup({ type, name, groupId }).then((res) => {
|
|
|
|
+ const result = {
|
|
|
|
+ success: false,
|
|
|
|
+ msg: '',
|
|
|
|
+ data: {}
|
|
|
|
+ }
|
|
|
|
+ result.success = res?.error_code === 0
|
|
|
|
+ result.data = res?.data
|
|
|
|
+ if (result.success) {
|
|
|
|
+ // 非获取(新增、修改、删除)成功后再次获取分组列表
|
|
|
|
+ if (type !== 'get') {
|
|
|
|
+ this.ajaxGroup({ type: 'get' })
|
|
}
|
|
}
|
|
- result.success = res?.error_code === 0 && res?.data === 'success'
|
|
|
|
- result.data = res?.data
|
|
|
|
- if (result.success) {
|
|
|
|
- this.model.expands.surplus += 1
|
|
|
|
- this.model.expands.used = Math.max(this.model.expands.used - 1, 0)
|
|
|
|
- } else {
|
|
|
|
- result.msg = res?.error_msg || '抱歉,操作失败'
|
|
|
|
|
|
+ else {
|
|
|
|
+ this.groupList = res?.data
|
|
}
|
|
}
|
|
- return result
|
|
|
|
|
|
+ callback && callback()
|
|
}
|
|
}
|
|
- )
|
|
|
|
|
|
+ else {
|
|
|
|
+ result.msg = res?.error_msg || '抱歉,操作失败'
|
|
|
|
+ }
|
|
|
|
+ return result
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|