zjf
2023-03-03 bafa9dff4d9880c562f4d3a7b83bd4c1129240c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<template>
  <div v-loading="loading">
    <div v-empty="list.length === 0">
      <div class="log-items">
        <journal-cell
          v-for="(item, index) in list"
          :key="index"
          :data="item"
          class="list-cell"
          @on-handle="jourecallCellHandle"/>
        <div class="load">
          <el-button
            :loading="loadMoreLoading"
            type="text">{{ loadMoreLoading ? '加载更多' : '没有更多了' }}</el-button>
        </div>
      </div>
    </div>
    <c-r-m-full-screen-detail
      :visible.sync="showFullDetail"
      :crm-type="detailCRMType"
      :id="rowID"/>
    <new-dialog
      v-if="showNewDialog"
      :form-data="formData"
      :dialog-title="dialogTitle"
      :img-file-list="imgFileList"
      :accessory-file-list="accessoryFileList"
      :new-loading="newLoading"
      @close="showNewDialog=false"
      @submitBtn="submitBtn"/>
  </div>
</template>
 
<script>
// API
// import { journalDelete, journalEdit } from '@/api/oamanagement/journal'
import JournalCell from '@/views/OAManagement/journal/journalCell' // 办公日志
// import { crmQueryLogRelation } from '@/api/clients/common'
 
export default {
  /** 日志 跟进记录 */
  name: 'JournalLog',
  components: {
    JournalCell,
    CRMFullScreenDetail: () =>
      import('@/views/clients/components/CRMFullScreenDetail.vue'),
    NewDialog: () => import('@/views/OAManagement/journal/newDialog')
  },
  props: {
    /** 模块ID */
    id: [String, Number],
    /** 没有值就是全部类型 有值就是当个类型 */
    crmType: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      loading: false,
      loadMoreLoading: true,
      isPost: false,
      page: 1,
      list: [], // 跟进记录列表
      rowID: '', // 行信息
      // 详情
      showFullDetail: false,
      detailCRMType: '',
      // 编辑
      // 显示新建页面
      showNewDialog: false,
      // 新建数据
      formData: {},
      // 弹出框标题
      dialogTitle: '',
      // 图片数组
      imgFileList: [],
      // 附件数组
      accessoryFileList: [],
      newLoading: false
    }
  },
  computed: {},
  watch: {
    id: function (val) {
      this.refreshList()
    }
  },
  mounted () {
    // 分批次加载
    const dom = document.getElementById('follow-log-content')
    dom.onscroll = () => {
      const scrollOff = dom.scrollTop + dom.clientHeight - dom.scrollHeight
      // 滚动条到底部的条件
      if (Math.abs(scrollOff) < 10 && this.loadMoreLoading === true) {
        if (!this.isPost) {
          this.isPost = true
          this.page++
          this.getList()
        } else {
          this.loadMoreLoading = false
        }
      }
    }
 
    this.getList()
  },
  activated: function () {},
  deactivated: function () {},
  methods: {
    getList () {
      this.loading = true
      const params = { page: this.page, limit: 10 }
      params[this.crmType + 'Ids'] = this.id
      // crmQueryLogRelation(params)
      //   .then(res => {
      //     this.list = this.list.concat(res.data.list)
      //     if (res.data.list.length < 10) {
      //       this.loadMoreLoading = false
      //     } else {
      //       this.loadMoreLoading = true
      //     }
      //     this.loading = false
      //     this.isPost = false
      //   })
      //   .catch(() => {
      //     this.isPost = false
      //     this.loading = false
      //   })
    },
    refreshList () {
      this.page = 1
      this.list = []
      this.getList()
    },
    jourecallCellHandle (data) {
      // 编辑按钮
      if (data.type === 'edit') {
        const val = data.data.item
        this.showNewDialog = true
        this.dialogTitle = '编辑日志'
        this.formData = val
        this.imgFileList = []
        if (val.imgList) {
          for (const item of val.imgList) {
            item.url = item.filePath
            this.imgFileList.push(item)
          }
        }
        // 附件
        this.accessoryFileList = []
        if (val.fileList) {
          for (const item of val.fileList) {
            item.url = item.filePath
            this.accessoryFileList.push(item)
          }
        }
        // 员工部门赋值
        this.formData.depData = val.sendStructList ? val.sendStructList : []
        this.formData.sentWhoList = val.sendUserList ? val.sendUserList : []
        // 删除按钮
      } else if (data.type === 'delete') {
        this.$confirm('确定删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            // journalDelete({ logId: data.data.item.logId }).then(res => {
            //   this.$message({
            //     type: 'success',
            //     message: '删除成功!'
            //   })
            //   for (const i in this.list) {
            //     if (this.list[i].logId === data.data.item.logId) {
            //       this.list.splice(i, 1)
            //       break
            //     }
            //   }
            // })
          })
          .catch(() => {
            this.$message({
              type: 'info',
              message: '已取消删除'
            })
          })
        // 相关详情
      } else if (data.type === 'related-detail') {
        // this.rowID = data.data.item.key
        // this.detailCRMType = data.data.type
        // this.showFullDetail = true
      }
    },
    // 新建提交
    submitBtn (key, file, img, relevanceAll) {
      this.newLoading = true
      console.log(relevanceAll, '==relevanceAll==')
      const imgList = []
      const fileList = []
      // 获取部门
      const dep = []
      if (this.formData.depData) {
        for (const j of this.formData.depData) {
          dep.push(j.id)
        }
      }
      // 获取员工
      const staff = []
      if (this.formData.sentWhoList) {
        for (const h of this.formData.sentWhoList) {
          staff.push(h.id)
        }
      }
      for (const item of this.imgFileList) {
        imgList.push(item.fileId)
      }
      for (const item of this.accessoryFileList) {
        fileList.push(item.fileId)
      }
      // let obj = {}
      // if (!relevanceAll) {
      //   obj = {}
      // } else {
      //   obj = relevanceAll
      // }
      // const pramas = {
      //   logId: this.formData.logId,
      //   categoryId: key,
      //   content: this.formData.content,
      //   tomorrow: this.formData.tomorrow,
      //   question: this.formData.question,
      //   file: fileList.concat(imgList),
      //   sendUserIds: staff.join(','),
      //   sendStructureIds: dep.join(','),
      //   customerIds: obj.customerIds.join(','),
      //   contactsIds: obj.contactsIds.join(','),
      //   businessIds: obj.businessIds.join(','),
      //   contractIds: obj.contractIds.join(',')
      // }
      // journalEdit(pramas)
      // .then(res => {
      //   this.refreshList()
      //   this.showNewDialog = false
      //   this.$message.success('编辑成功')
      //   this.newLoading = false
      // })
      // .catch(() => {
      //   this.newLoading = false
      //   this.$message.error('编辑失败')
      // })
    }
  }
}
</script>
 
<style lang="less" scoped>
.log-items {
  min-height: 400px;
  position: relative;
}
 
.load {
  color: #999;
  font-size: 13px;
  margin: 0 auto 15px;
  text-align: center;
  .el-button,
  .el-button:focus {
    color: #ccc;
    cursor: auto;
  }
}
 
.list-cell {
  margin-bottom: 20px;
  border-radius: 4px;
}
</style>