list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <scroll-view scroll-y="true" :scroll-into-view="scrollViewId" @scrolltoupper="onScrollTop" style="height: 100vh;">
  3. <view class="message-list-page">
  4. <view class="list">
  5. <view class="message-item" v-for="item in list" :key="item.Id" :id="`msg${item.Id}`">
  6. <view class="top-time-box white-wrap">{{item.msgTime}}</view>
  7. <view class="flex">
  8. <image :src="avatar" mode="aspectFill" style="width: 88rpx;height: 88rpx;"></image>
  9. <view class="message-content">
  10. <view style="color:#666;font-size: 12px;">小助手</view>
  11. <view class="message-card white-wrap" @click="handleGoDetail(item)">
  12. <!-- 问答 -->
  13. <template v-if="type === 5">
  14. <view class="title">{{item.ApprovalInfo.Title}}</view>
  15. <view class="info">提问人:{{item.ApprovalInfo.ApplyName}}</view>
  16. <view class="info">提问时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  17. <image src="@/static/icon-distribute.png" mode="aspectFill" class="new-status" v-if="item.ApprovalStatus === 1"></image>
  18. </template>
  19. <!-- 评论 -->
  20. <!-- 由于问答评论和视频社区的评论都在一个入口所以根据list返回数据的sourceType来区分 6:问答社区 7:视频社区 -->
  21. <template v-else-if="type === 6">
  22. <template v-if="item.SourceType===6">
  23. <view class="title">{{item.ApprovalInfo.Title}}</view>
  24. <view class="info">所属提问:{{item.ApprovalInfo.Content}}</view>
  25. <view class="info">评论人:{{item.ApprovalInfo.ApplyName}}</view>
  26. <view class="info">客户信息:{{item.ApprovalInfo.CompanyName}}</view>
  27. <view class="info">评论时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  28. <image src="@/static/icon-look.png" mode="aspectFill" class="new-status" v-if="item.ApprovalStatus === 1"></image>
  29. </template>
  30. <template v-if="[7,8].includes(item.SourceType)">
  31. <view class="title">{{item.ApprovalInfo.Title}}</view>
  32. <view class="info">视频分类:{{item.ApprovalInfo.MessageSource}}</view>
  33. <view class="info">视频标题:{{item.ApprovalInfo.Content}}</view>
  34. <view class="info">所属{{item.SourceType==7?'标签':'品种'}}:{{item.ApprovalInfo.Extra}}</view>
  35. <view class="info">评论人:{{item.ApprovalInfo.ApplyName}}</view>
  36. <view class="info">客户信息:{{item.ApprovalInfo.CompanyName}}</view>
  37. <view class="info">评论时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  38. <image src="@/static/icon-look.png" mode="aspectFill" class="new-status" v-if="item.ApprovalStatus === 1"></image>
  39. </template>
  40. </template>
  41. <!-- 出差申请 -->
  42. <template v-else-if="type === 10">
  43. <view class="businessTrip-type">出差申请</view>
  44. <view class="info">目的地: {{item.BusinessTripInfo.Province}}{{item.BusinessTripInfo.City}}</view>
  45. <view class="info">出差事由: {{item.BusinessTripInfo.Reason}}</view>
  46. <template v-if="item.BusinessTripInfo">
  47. <view class="info" v-if="item.BusinessTripInfo.Status==='待审批'">提交时间:{{item.BusinessTripInfo.CreateTime|formatTime}}</view>
  48. <view class="info" v-else>审批时间:{{item.BusinessTripInfo.ApproveTime|formatTime}}</view>
  49. </template>
  50. <image :src="item.statusImg" mode="aspectFill" class="status-img"></image>
  51. </template>
  52. <template v-else>
  53. <view class="type">{{item.ApprovalInfo.Type}}</view>
  54. <view class="title">{{item.CompanyName}}</view>
  55. <view v-if="item.MessageType===3">
  56. <view class="info">{{item.Content}}</view>
  57. <view class="info">修改时间:{{item.CreateTime|formatTime}}</view>
  58. </view>
  59. <view v-else>
  60. <view class="info" v-if="type===3">归属公司:{{item.AffiliatedCompany}}</view>
  61. <view class="info">申请销售:{{item.ApprovalInfo.ApplyName}}</view>
  62. <view class="info" v-if="item.statusName==='待审批'">提交时间:{{item.ApprovalInfo.ApplyTime|formatTime}}</view>
  63. <view class="info" v-else>审批时间:{{item.ApprovalInfo.ApprovalTime|formatTime}}</view>
  64. </view>
  65. <image :src="item.statusImg" mode="aspectFill" class="status-img"></image>
  66. </template>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </scroll-view>
  74. </template>
  75. <script>
  76. import {apiMessageList} from '@/api/message.js'
  77. export default {
  78. filters:{
  79. formatTime(e){
  80. if(e==='0001-01-01T00:00:00Z'){
  81. return ''
  82. }else{
  83. return e.replace(/T/g,' ').replace(/\+08:00/g,' ').replace(/-/g,'.')
  84. }
  85. }
  86. },
  87. data() {
  88. return {
  89. scrollViewId:'',
  90. type: null, //类型对应的数字: 1客户(custome)、2合同(contract)、3用印(seal) 5问答 6问答评论 10 出差申请
  91. typeName:null,//类型对应的英文 客户(custome)、合同(contract)、用印(seal) question questionComment
  92. page: 1, //页码
  93. list: [],
  94. finished: false, //是否列表为最后一页
  95. avatar:'',// 头像
  96. }
  97. },
  98. onLoad(options) {
  99. this.initPage(options.type)
  100. this.getList()
  101. },
  102. // onPullDownRefresh() {
  103. // this.page=1
  104. // this.finished=false
  105. // this.list=[]
  106. // this.getList()
  107. // setTimeout(()=>{
  108. // uni.stopPullDownRefresh()
  109. // },1500)
  110. // },
  111. // onReachBottom() {
  112. // if(this.finished) return
  113. // this.page++
  114. // this.getList()
  115. // },
  116. methods: {
  117. onScrollTop(){
  118. if(this.finished) return
  119. this.page++
  120. this.getList()
  121. },
  122. handleGoDetail(e){
  123. const urlMap = {
  124. 'custome': '/pages-approve/custome/detail?id='+e.CompanyApprovalId,
  125. 'contract': `/pages-approve/contract/detail?ContractApprovalId=0&ContractId=0&ContractApprovalRecordId=${e.CompanyApprovalId}`,
  126. 'seal': `/pages-approve/seal/detail?ContractApprovalId=0&ContractApprovalRecordId=${e.CompanyApprovalId}`,
  127. 'question':`/pages-question/detail/index?type=question&id=${e.CompanyApprovalId}`,
  128. 'questionComment':`/pages-question/detail/index?type=comment&id=${e.CompanyApprovalId}`,
  129. 'businessTrip':'/pages-approve/businessTrip/detail?id='+e.CompanyApprovalId,
  130. }
  131. // 如果是questionComment 则如果是视频则跳转到视频
  132. if(this.typeName=='questionComment'&&[7,8].includes(e.SourceType)){
  133. uni.navigateTo({url:`/pages-video/comment/list?id=${e.CompanyApprovalId}&source=${e.SourceType===7?2:3}`})
  134. return
  135. }
  136. uni.navigateTo({url:urlMap[this.typeName]})
  137. },
  138. //获取列表数据
  139. async getList() {
  140. const res = await apiMessageList({
  141. SourceType: this.type,
  142. CurrentIndex: this.page
  143. })
  144. if (res.code === 200) {
  145. if(!res.data.List){
  146. this.finished=true
  147. }else{
  148. let arr=res.data.List.map(item=>{
  149. let statusImg='',statusName='';
  150. if(item.SourceType==10&&item.BusinessTripInfo){
  151. switch(item.BusinessTripInfo.Status){
  152. case '待审批':
  153. statusImg=require('../static/icon-2.png')
  154. statusName='待审批'
  155. break;
  156. case '已审批':
  157. statusImg=require('../static/icon-3.png')
  158. statusName='已审批'
  159. break;
  160. case '已驳回':
  161. statusImg=require('../static/icon-4.png')
  162. statusName='已驳回'
  163. break
  164. }
  165. }else{
  166. switch(item.ApprovalStatus){
  167. case 1:
  168. statusImg=require('../static/icon-2.png')
  169. statusName='待审批'
  170. break;
  171. case 2:
  172. statusImg=require('../static/icon-3.png')
  173. statusName='已审批'
  174. break;
  175. case 3:
  176. statusImg=require('../static/icon-4.png')
  177. statusName='已驳回'
  178. break
  179. }
  180. }
  181. // 处理消息时间
  182. let msgTime=this.handleMsgTime(item.CreateTime)
  183. return {
  184. statusImg,
  185. statusName,
  186. ...item,
  187. msgTime:msgTime
  188. }
  189. })
  190. this.$nextTick(()=>{
  191. this.scrollViewId=`msg${res.data.List[0].Id}`
  192. })
  193. let reArr=arr.reverse()
  194. this.list = [...reArr,...this.list]
  195. }
  196. }
  197. },
  198. handleMsgTime(e){
  199. let timeStr=''
  200. // 获取今日
  201. const todayTime=new Date()
  202. const time=new Date(e)
  203. const year=time.getFullYear()
  204. const month = time.getMonth() + 1 > 9 ? time.getMonth()+1 : '0'+(time.getMonth()+1);
  205. const day = time.getDate() > 9 ? time.getDate() : "0" + time.getDate();
  206. const hours=time.getHours() > 9 ? time.getHours():'0'+time.getHours()
  207. const minutes=time.getMinutes()>9 ?time.getMinutes():'0'+time.getMinutes()
  208. const seconds=time.getSeconds()>9?time.getSeconds():'0'+time.getSeconds()
  209. if(year!=todayTime.getFullYear()||(time.getMonth()!=todayTime.getMonth())){
  210. timeStr=`${year}.${month}.${day} ${hours}:${minutes}:${seconds}`
  211. }else if(time.getDate()+1==todayTime.getDate()){
  212. //昨天
  213. timeStr=`昨天 ${hours}:${minutes}:${seconds}`
  214. }else if(time.getDate()==todayTime.getDate()){
  215. timeStr=`今天 ${hours}:${minutes}:${seconds}`
  216. }else{
  217. timeStr=`${year}.${month}.${day} ${hours}:${minutes}:${seconds}`
  218. }
  219. return timeStr
  220. },
  221. // 初始化界面
  222. initPage(type) {
  223. let navBarTitle = ''
  224. const _this = this
  225. switch (type) {
  226. case '1':
  227. navBarTitle = '客户待审批'
  228. _this.type = 1
  229. _this.typeName='custome'
  230. _this.avatar=require('../../static/icon-1.png')
  231. break;
  232. case '2':
  233. navBarTitle = '合同待审批'
  234. _this.type = 2
  235. _this.typeName='contract'
  236. _this.avatar=require('../../static/icon-2.png')
  237. break;
  238. case '3':
  239. navBarTitle = '用印待审批'
  240. _this.type = 3
  241. _this.typeName='seal'
  242. _this.avatar=require('../../static/icon-3.png')
  243. break;
  244. case '5':
  245. navBarTitle = '待查看问答'
  246. _this.type = 5
  247. _this.typeName='question'
  248. _this.avatar=require('../../static/icon-question.png')
  249. break;
  250. case '6':
  251. navBarTitle = '待查看评论'
  252. _this.type = 6
  253. _this.typeName='questionComment'
  254. _this.avatar=require('../../static/icon-comment.png')
  255. break;
  256. case '10':
  257. navBarTitle = '出差审批'
  258. _this.type = 10
  259. _this.typeName='businessTrip'
  260. _this.avatar=require('../../static/icon-2.png')
  261. break;
  262. }
  263. uni.setNavigationBarTitle({
  264. title: navBarTitle
  265. })
  266. }
  267. }
  268. }
  269. </script>
  270. <style lang="scss">
  271. .message-list-page {
  272. padding: 20rpx;
  273. }
  274. .list{
  275. padding: 0 36rpx 0 19rpx;
  276. .message-item{
  277. margin-top: 50rpx;
  278. }
  279. .top-time-box{
  280. display: inline-block;
  281. padding: 0 20rpx;
  282. min-width: 200rpx;
  283. height: 50rpx;
  284. line-height: 50rpx;
  285. font-size: 12px;
  286. text-align: center;
  287. border-radius: 25rpx;
  288. position: relative;
  289. left: 50%;
  290. transform: translateX(-50%);
  291. margin-bottom: 40rpx;
  292. }
  293. .message-content{
  294. margin-left: 20rpx;
  295. flex: 1;
  296. }
  297. .message-card{
  298. margin-top: 20rpx;
  299. padding: 20rpx;
  300. border: 1px solid #EFEFEF;
  301. box-shadow: 0px 3rpx 12rpx rgba(175, 175, 175, 0.08);
  302. border-radius: 6px;
  303. position: relative;
  304. .type{
  305. color: #FFB005;
  306. font-weight: bold;
  307. &::before{
  308. content: '';
  309. display: inline-block;
  310. width: 28rpx;
  311. height: 28rpx;
  312. background-image: url(../static/icon-1.png);
  313. background-size: cover;
  314. margin-right: 20rpx;
  315. position: relative;
  316. top: 4rpx;
  317. }
  318. }
  319. .businessTrip-type{
  320. color: #3385FF;
  321. font-size: 32rpx;
  322. &::before{
  323. content: '';
  324. display: inline-block;
  325. width: 32rpx;
  326. height: 22rpx;
  327. background-image: url(../static/icon-7.png);
  328. background-size: cover;
  329. margin-right: 20rpx;
  330. position: relative;
  331. top: 4rpx;
  332. }
  333. }
  334. .title{
  335. font-size: 16px;
  336. font-weight: bold;
  337. margin-top: 20rpx;
  338. }
  339. .info{
  340. margin-top: 20rpx;
  341. }
  342. .status-img,.new-status{
  343. position: absolute;
  344. right: 0;
  345. width: 145rpx;
  346. height: 145rpx;
  347. &.status-img {
  348. top: 0;
  349. }
  350. &.new-status {
  351. bottom: 0;
  352. }
  353. }
  354. }
  355. }
  356. </style>