follow.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <!--
  2. * @Author: wanglj 471442253@qq.com
  3. * @Date: 2022-12-15 15:38:21
  4. * @LastEditors: wanglj
  5. * @LastEditTime: 2022-12-30 14:36:03
  6. * @Description: file content
  7. * @FilePath: \opms_frontend\src\views\customer\follow.vue
  8. -->
  9. <template>
  10. <div class="follow-container">
  11. <el-row :gutter="10" style="margin-bottom: 10px">
  12. <el-col :span="4">
  13. <el-input v-model="queryForm.custId" placeholder="客户" />
  14. </el-col>
  15. <!-- <el-col :span="4">
  16. <el-date-picker
  17. v-model="queryForm.date"
  18. end-placeholder="结束日期"
  19. placeholder="时间范围"
  20. start-placeholder="开始日期"
  21. style="width: 100%"
  22. type="daterange" />
  23. </el-col> -->
  24. <el-col :span="4">
  25. <el-input v-model="queryForm.daysBeforeToday" placeholder="查询天数">
  26. <template slot="append">天</template>
  27. </el-input>
  28. </el-col>
  29. <el-col :span="4">
  30. <el-input v-model="queryForm.targetType" placeholder="跟进类型" />
  31. </el-col>
  32. <el-col :span="4">
  33. <el-input v-model="queryForm.indusTry" placeholder="跟进人员" />
  34. </el-col>
  35. <el-col :span="4">
  36. <el-input v-model="queryForm.managerId" placeholder="创建者" />
  37. </el-col>
  38. <el-col :span="4">
  39. <el-button icon="el-icon-plus" type="primary" @click="search">
  40. 查询
  41. </el-button>
  42. <el-button @click="addFollowUp">添加</el-button>
  43. <el-button icon="el-icon-refresh-right" @click="reset">重置</el-button>
  44. </el-col>
  45. </el-row>
  46. <div class="follow">
  47. <ul
  48. v-infinite-scroll="load"
  49. class="records infinite-list"
  50. :infinite-scroll-disabled="loadFlag"
  51. :infinite-scroll-immediate-check="false">
  52. <li v-for="(date, index) in records" :key="index">
  53. <div class="date">
  54. <h2>{{ date.followDay.split('-')[2] }}</h2>
  55. <h3>{{ date.followDay.split('-').splice(0, 2).join('.') }}</h3>
  56. </div>
  57. <ul class="content">
  58. <li v-for="(item, idx) in date.followupList" :key="idx">
  59. <!-- <el-avatar class="user-avatar"
  60. :src="avatar" />-->
  61. <vab-icon class="user-avatar" icon="account-circle-fill" />
  62. <div class="text">
  63. <p class="action">
  64. <span>
  65. {{ item.contactsName }} 跟进({{
  66. formatType(item.followType)
  67. }})
  68. </span>
  69. <span>
  70. <vab-icon icon="time-line" />
  71. {{ item.followDate }}
  72. </span>
  73. </p>
  74. <p>{{ item.followContent }}</p>
  75. <div class="footer">
  76. <p>
  77. 来自客户:
  78. <span>{{ item.custName }}</span>
  79. </p>
  80. <div>
  81. <el-button size="mini" @click="showDetail(item)">
  82. <vab-icon icon="arrow-right-circle-fill" />
  83. 详情
  84. </el-button>
  85. <el-button size="mini" @click="showComment(item.id)">
  86. <!-- <vab-icon icon="chat-3-fill" /> -->
  87. 评论({{ item.commentNumber }})
  88. </el-button>
  89. </div>
  90. </div>
  91. </div>
  92. </li>
  93. </ul>
  94. </li>
  95. </ul>
  96. <div class="comment">
  97. <ul>
  98. <li v-for="item in comments" :key="item.id">
  99. <vab-icon class="user-avatar" icon="account-circle-fill" />
  100. <div class="text">
  101. <p>{{ item.createdName }}</p>
  102. <p>{{ item.content }}</p>
  103. <p>{{ item.createdTime }}</p>
  104. </div>
  105. </li>
  106. </ul>
  107. <div class="form">
  108. <el-input
  109. v-model="comment"
  110. maxlength="300"
  111. resize="none"
  112. :rows="5"
  113. show-word-limit
  114. type="textarea" />
  115. <el-button size="mini" type="primary" @click="handleComment">
  116. 评论
  117. </el-button>
  118. </div>
  119. </div>
  120. </div>
  121. <!-- 跟进详情 -->
  122. <FollowDetail ref="followDetail" />
  123. </div>
  124. </template>
  125. <script>
  126. import to from 'await-to-js'
  127. import api from '@/api/customer/follow'
  128. import FollowDetail from './components/FollowDetail.vue'
  129. export default {
  130. name: 'Follow',
  131. components: {
  132. FollowDetail,
  133. },
  134. data() {
  135. return {
  136. listLoading: false,
  137. queryForm: {
  138. custId: '',
  139. targetType: '',
  140. targetId: '',
  141. managerId: '',
  142. daysBeforeToday: 20,
  143. date: [],
  144. },
  145. loadFlag: true,
  146. records: [],
  147. followId: '',
  148. comment: '',
  149. comments: [],
  150. visible: false,
  151. form: {
  152. id: '',
  153. followType: '',
  154. followDate: '',
  155. followContent: '',
  156. targetId: '',
  157. targetType: '',
  158. targetName: '',
  159. custId: '',
  160. custName: '',
  161. contactsId: 0,
  162. contactsName: '',
  163. reminders: '',
  164. nextTime: '',
  165. remark: '',
  166. createdBy: '',
  167. createdName: '',
  168. createdTime: '',
  169. updatedBy: '',
  170. updatedName: '',
  171. updatedTime: '',
  172. deletedTime: '',
  173. },
  174. }
  175. },
  176. mounted() {
  177. this.fetchData()
  178. this.getOptions()
  179. },
  180. methods: {
  181. getOptions() {},
  182. search() {
  183. this.queryForm.daysBeforeToday = 20
  184. this.fetchData()
  185. },
  186. async fetchData() {
  187. let params = { ...this.queryForm }
  188. const [err, res] = await to(api.getListByDay(params))
  189. if (err) return console.log(err, 'err')
  190. this.records = res.data.list || []
  191. await this.$nextTick()
  192. this.loadFlag = false
  193. },
  194. load() {
  195. this.queryForm.daysBeforeToday += 20
  196. console.log('到底了', this.queryForm.daysBeforeToday)
  197. this.fetchData()
  198. },
  199. reset() {
  200. this.queryForm = {
  201. custId: '',
  202. targetType: '',
  203. targetId: '',
  204. managerId: '',
  205. daysBeforeToday: '',
  206. date: [],
  207. }
  208. this.fetchData()
  209. },
  210. // 详情
  211. showDetail(row) {
  212. this.$refs.followDetail.init({ ...row })
  213. },
  214. async showComment(id) {
  215. this.followId = id
  216. const [err, res] = await to(api.getComment({ followId: id + '' }))
  217. if (err) return
  218. this.comments = res.data.list || []
  219. },
  220. formatType(val) {
  221. let str = ''
  222. if (val == 10) str = '电话'
  223. else if (val == 20) str = '邮件'
  224. else if (val == 30) str = '拜访'
  225. return str
  226. },
  227. // 评论
  228. async handleComment() {
  229. let str = ''
  230. if (!this.followId) str = '请选择跟进记录'
  231. else if (!this.comment) str = '请输入评论'
  232. if (str) return this.$message.warning(str)
  233. let params = {
  234. followId: this.followId + '',
  235. content: this.comment,
  236. remark: '',
  237. }
  238. const [err, res] = await to(api.addComment(params))
  239. if (err) return
  240. this.$message.success(res.msg)
  241. this.showComment(this.followId)
  242. this.comment = ''
  243. this.fetchData()
  244. },
  245. addFollowUp() {
  246. let params = {
  247. followType: '20',
  248. followDate: '2022-10-29',
  249. followContent: '跟进内容',
  250. targetId: 1,
  251. targetType: '20',
  252. targetName: 'dashoo',
  253. custId: 26,
  254. custName: '测试客户1348',
  255. contactsId: 55,
  256. contactsName: 'wanglj',
  257. reminders: '',
  258. nextTime: this.parseTime(new Date()),
  259. remark: '',
  260. }
  261. api.addFollowUp(params)
  262. },
  263. },
  264. }
  265. </script>
  266. <style lang="scss" scoped>
  267. $base: '.follow';
  268. .follow {
  269. height: calc(100vh - 240px);
  270. display: flex;
  271. .comment {
  272. width: 300px;
  273. display: flex;
  274. flex-direction: column;
  275. border-radius: 4px;
  276. border: 1px solid rgb(215, 232, 244);
  277. ul {
  278. flex: 1;
  279. overflow-y: auto;
  280. padding: 10px;
  281. li {
  282. display: flex;
  283. border-bottom: 1px solid #e3e5e7;
  284. .text {
  285. flex: 1;
  286. padding: 0 10px;
  287. p {
  288. font-weight: 500;
  289. margin: 0;
  290. line-height: 32px;
  291. }
  292. p:first-child {
  293. line-height: 30px;
  294. font-weight: bold;
  295. }
  296. p:last-child {
  297. font-size: 12px;
  298. color: #9499a0;
  299. text-align: right;
  300. }
  301. }
  302. }
  303. .user-avatar {
  304. font-size: 30px;
  305. }
  306. }
  307. .form {
  308. padding: 4px;
  309. text-align: right;
  310. .el-textarea {
  311. margin-bottom: 4px;
  312. }
  313. }
  314. }
  315. .records {
  316. flex: 1;
  317. margin: 0;
  318. height: 100%;
  319. padding: 10px 20px;
  320. list-style: none;
  321. overflow: auto;
  322. > li {
  323. display: flex;
  324. + li {
  325. margin-top: 10px;
  326. }
  327. }
  328. .date {
  329. width: 100px;
  330. display: flex;
  331. flex-direction: column;
  332. align-items: center;
  333. h2,
  334. h3 {
  335. margin: 0;
  336. }
  337. h2 {
  338. font-size: 26px;
  339. line-height: 32px;
  340. }
  341. }
  342. .content {
  343. flex: 1;
  344. list-style: none;
  345. li {
  346. display: flex;
  347. border: 1px solid rgb(215, 232, 244);
  348. background: rgb(247, 251, 254);
  349. border-radius: 4px;
  350. padding: 8px;
  351. + li {
  352. margin-top: 10px;
  353. }
  354. }
  355. .user-avatar {
  356. font-size: 40px;
  357. }
  358. .text {
  359. flex: 1;
  360. padding-left: 20px;
  361. padding-right: 10px;
  362. p {
  363. font-weight: 500;
  364. margin: 0;
  365. line-height: 32px;
  366. span {
  367. color: #1d66dc;
  368. }
  369. }
  370. .action {
  371. display: flex;
  372. justify-content: space-between;
  373. span:first-child {
  374. font-weight: bold;
  375. color: #333;
  376. }
  377. }
  378. .footer {
  379. display: flex;
  380. justify-content: space-between;
  381. align-items: center;
  382. }
  383. }
  384. }
  385. }
  386. }
  387. </style>