callRecord.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view class="incidentList">
  3. <view class="head">
  4. <!-- <view class="tab" :class="{active: tab.id === dataInfo.tabActiveId}" v-for="tab in dataInfo.tabs" :key="tab.id" @click="clickTab(tab.id)">
  5. {{tab.name}}<text v-if="tab.num !== ''">({{tab.num}})</text>
  6. </view> -->
  7. <view class="filter" @click="filterClick">
  8. <text class="newicon newicon-shaixuan"></text>
  9. </view>
  10. </view>
  11. <view class="body" v-if="dataInfo.list.length">
  12. <view class="body_item" v-for="data in dataInfo.list" :key="data.id">
  13. <view class="body_item_head ellipsis-multiline" @click="attachmentClick(data)">
  14. {{data.dTMFA}}
  15. <uni-icons v-if="data.dTMFA && data.dTMFB" type="arrow-right" class="arrow-right" :size="18" :color="primaryColor"></uni-icons>
  16. {{data.dTMFB}}
  17. <uni-icons v-if="data.path" type="mic-filled" class="mic-filled" :size="18" :color="primaryColor"></uni-icons>
  18. </view>
  19. <view class="body_item_content">
  20. <view class="body_item_content_p">
  21. <text class="name ellipsis">开始时间:{{data.responseTime}}</text>
  22. </view>
  23. <view class="body_item_content_p">
  24. <text class="name ellipsis">结束时间:{{data.overTime}}</text>
  25. </view>
  26. <view class="body_item_content_p">
  27. <text class="name ellipsis">通话时长:{{data.longTime || 0}} 秒</text>
  28. <view class="type">
  29. {{data.callState == 1?'已接':'未接'}}/
  30. {{data.callType == 1?'呼入':'呼出'}}
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="zanwu" v-else>
  37. <text class="newicon newicon-zanwu"></text>
  38. </view>
  39. <callFilter v-if="dataInfo.isFilter" @cancelEmit="cancelFilter" @confirmEmit="conformFilter" :evt="dataInfo.evtFilter"></callFilter>
  40. <IncidentAttachment v-if="dataInfo.isAttachment" @knowEmit="knowAttachment" :incidentData="dataInfo.incidentData"></IncidentAttachment>
  41. <RequireAttachment v-if="dataInfo.isRequireAttachment" @knowEmit="knowRequireAttachment" :incidentData="dataInfo.incidentData"></RequireAttachment>
  42. </view>
  43. </template>
  44. <script setup>
  45. import callFilter from '@/components/callFilter.vue';
  46. import IncidentAttachment from '@/components/IncidentAttachment.vue';
  47. import RequireAttachment from '@/components/RequireAttachment.vue';
  48. import { subMonths, startOfMonth, endOfMonth, format, add, setDate } from 'date-fns'
  49. import { ref, reactive, computed } from 'vue'
  50. import { onLoad, onUnload, onHide, onPullDownRefresh, onReachBottom, onTabItemTap } from '@dcloudio/uni-app'
  51. import { api_callLog, api_getDictionary, api_incident, api_incident_count, api_incidentTask } from "@/http/api.js"
  52. import { filterFormatDate } from '@/filters/filterFormatDate.js'
  53. import { computedPriorityStyle } from '@/filters/computedPriorityStyle.js'
  54. import { computedStateStyle } from '@/filters/computedStateStyle.js'
  55. import { computedCurrentLogOverTime } from '@/filters/computedCurrentLogOverTime.js'
  56. import { defaultColor } from '@/static/js/theme.js'
  57. import { useSetTitle } from '@/share/useSetTitle.js'
  58. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  59. import { useSetTabbar } from '@/share/useSetTabbar.js'
  60. import { useLoginUserStore } from '@/stores/loginUser'
  61. import { useIncidentNumStore } from '@/stores/incidentNum'
  62. import { useIncidentListSearchStore } from '@/stores/incidentListSearch'
  63. import { useHandlerStore } from '@/stores/handler'
  64. useSetTitle();
  65. const loginUserStore = useLoginUserStore();
  66. const incidentNumStore = useIncidentNumStore();
  67. const incidentListSearchStore = useIncidentListSearchStore();
  68. const { formatDate } = filterFormatDate();
  69. const { priorityStyle } = computedPriorityStyle();
  70. const { stateStyle } = computedStateStyle();
  71. const { currentLogOverTime } = computedCurrentLogOverTime();
  72. const { makePhoneCall } = useMakePhoneCall();
  73. const { setTabbar } = useSetTabbar();
  74. const handlerStore = useHandlerStore();
  75. // 主题颜色
  76. const primaryColor = ref(defaultColor)
  77. // 数据
  78. const dataInfo = reactive({
  79. tabs: [{id: 0, name: '全部', value: 'all', num: ''}],
  80. tabActiveId: 0,//当前选择的tab
  81. list: [],//工单列表
  82. idx: 0,//页码
  83. hasMore: true,//是否有更多数据
  84. isFilter: false,//筛选框开关
  85. isAttachment: false,//图片和通话录音开关
  86. isRequireAttachment: false,//报修录音开关
  87. incidentId: undefined,
  88. evtFilter: {
  89. called: null,
  90. dialing: null,
  91. datetimerange:[],
  92. selected1: 'all',
  93. selected2: 'all'
  94. },//筛选框数据
  95. })
  96. // 设置默认时间
  97. function setDefaultDate(){
  98. // 获取当前日期
  99. const today = new Date();
  100. // 获取上个月的第一天
  101. const startOfLastMonth = startOfMonth(subMonths(today, 1));
  102. // 获取上个月的最后一天
  103. const endOfLastMonth = endOfMonth(subMonths(today, 1));
  104. dataInfo.evtFilter.datetimerange = [format(startOfLastMonth, 'yyyy-MM-dd HH:mm:ss'),format(endOfLastMonth, 'yyyy-MM-dd HH:mm:ss')]
  105. }
  106. // 点击筛选
  107. function filterClick(){
  108. dataInfo.isFilter = true;
  109. }
  110. // 确认筛选
  111. function conformFilter(evtFilter){
  112. console.log(444, evtFilter)
  113. dataInfo.evtFilter = evtFilter;
  114. dataInfo.isFilter = false;
  115. getList(0);
  116. }
  117. // 关闭筛选
  118. function cancelFilter(){
  119. dataInfo.isFilter = false;
  120. }
  121. // 点击图片和录音
  122. function attachmentClick(incidentData){
  123. dataInfo.incidentData = incidentData;
  124. dataInfo.incidentData.type = 'call'
  125. dataInfo.isAttachment = true;
  126. }
  127. // 返回图片和录音
  128. function knowAttachment(){
  129. dataInfo.isAttachment = false;
  130. }
  131. // 点击报修录音
  132. function attachmentRequireClick(incidentData){
  133. dataInfo.incidentData = incidentData;
  134. dataInfo.isRequireAttachment = true;
  135. }
  136. // 返回报修录音
  137. function knowRequireAttachment(){
  138. dataInfo.isRequireAttachment = false;
  139. }
  140. // 获取列表信息
  141. function getList(idx){
  142. uni.showLoading({
  143. title: "加载中",
  144. mask: true,
  145. });
  146. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  147. if(dataInfo.idx === 0){
  148. dataInfo.list = [];
  149. }
  150. let postData = {
  151. "idx": dataInfo.idx,
  152. "sum": 10,
  153. "callLog": {
  154. dTMFA: dataInfo.evtFilter.dialing || undefined,
  155. dTMFB: dataInfo.evtFilter.called || undefined,
  156. callState: dataInfo.evtFilter.selected1 || undefined,
  157. callType: dataInfo.evtFilter.selected2 || undefined,
  158. startTime: dataInfo.evtFilter.datetimerange[0] || undefined,
  159. endTime: dataInfo.evtFilter.datetimerange[1] || undefined,
  160. }
  161. }
  162. if(dataInfo.evtFilter.selected1!='all'){
  163. postData.callLog.callState = dataInfo.evtFilter.selected1
  164. }else{
  165. delete postData.callLog.callState
  166. }
  167. if(dataInfo.evtFilter.selected2!='all'){
  168. postData.callLog.callType = dataInfo.evtFilter.selected2
  169. }else{
  170. delete postData.callLog.callType
  171. }
  172. api_callLog(postData).then(res => {
  173. uni.hideLoading();
  174. uni.stopPullDownRefresh();
  175. if(res.status == 200){
  176. let list = res.list || [];
  177. if(list.length){
  178. dataInfo.hasMore = true;
  179. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  180. }else{
  181. dataInfo.hasMore = false;
  182. }
  183. }else{
  184. uni.showToast({
  185. icon: 'none',
  186. title: res.msg || '请求数据失败!'
  187. });
  188. }
  189. })
  190. }
  191. onLoad((option) => {
  192. setDefaultDate();
  193. getList(0);
  194. })
  195. onUnload(() => {
  196. dataInfo.isFilter = false;
  197. })
  198. onHide(() => {
  199. dataInfo.isFilter = false;
  200. })
  201. onTabItemTap(e => {
  202. // onLoadFn();
  203. })
  204. onPullDownRefresh(() => {
  205. getList(0)
  206. })
  207. onReachBottom(() => {
  208. dataInfo.idx += 1;
  209. if (dataInfo.hasMore) {
  210. getList(); // 当触底时加载更多数据
  211. }
  212. })
  213. </script>
  214. <style lang="scss" scoped>
  215. page{
  216. height: calc(100vh - var(--window-bottom));
  217. }
  218. .incidentList{
  219. display: flex;
  220. flex-direction: column;
  221. justify-content: space-between;
  222. .head{
  223. height: 88rpx;
  224. display: flex;
  225. position: fixed;
  226. z-index: 99;
  227. width: 100%;
  228. background-color: #fff;
  229. font-size: 30rpx;
  230. .tab{
  231. flex: 1;
  232. display: flex;
  233. justify-content: center;
  234. align-items: center;
  235. border-bottom: 4rpx solid transparent;
  236. &.active{
  237. color: $uni-primary;
  238. border-color: $uni-primary;
  239. }
  240. }
  241. .filter{
  242. width: 84rpx;
  243. display: flex;
  244. justify-content: center;
  245. align-items: center;
  246. position: absolute;
  247. right: 0;
  248. top: 30rpx;
  249. .newicon-shaixuan{
  250. font-size: 36rpx;
  251. color: #2C2C2C;
  252. }
  253. }
  254. }
  255. .body{
  256. margin-bottom: var(--window-bottom);
  257. margin-top: 88rpx;
  258. border-top: 6rpx solid #EBEBEB;
  259. .body_item{
  260. border-bottom: 8rpx solid #EBEBEB;
  261. .body_item_head{
  262. word-break: break-all;
  263. text-align: justify;
  264. text-align: left;
  265. margin: 24rpx;
  266. font-size: 30rpx;
  267. }
  268. .body_item_content{
  269. // display: flex;
  270. border-top: 1rpx solid #D8D8D8;
  271. padding: 24rpx;
  272. .type{
  273. margin-left: 40rpx;
  274. }
  275. .body_item_content_p{
  276. color: #6A6A6A;
  277. font-size: 26rpx;
  278. display: flex;
  279. // justify-content: space-between;
  280. align-items: center;
  281. margin-bottom: 24rpx;
  282. &:last-of-type{
  283. margin-bottom: 0;
  284. }
  285. .name{
  286. // flex: 1;
  287. }
  288. .status{
  289. padding: 4rpx 10rpx;
  290. border-radius: 20rpx;
  291. background-color: #DBE8FE;
  292. font-size: 22rpx;
  293. color: #006CF9;
  294. }
  295. .icon_all{
  296. .mic-filled,
  297. .image-filled
  298. {
  299. margin-left: 16rpx;
  300. }
  301. }
  302. }
  303. }
  304. .body_item_foot{
  305. border-top: 1rpx solid #D8D8D8;
  306. font-size: 26rpx;
  307. padding: 24rpx;
  308. .foot_info{
  309. display: flex;
  310. justify-content: space-between;
  311. align-items: center;
  312. .phone-filled{
  313. margin-left: 5rpx;
  314. }
  315. }
  316. }
  317. }
  318. }
  319. .zanwu{
  320. box-sizing: border-box;
  321. margin-bottom: var(--window-bottom);
  322. margin-top: 88rpx;
  323. border-top: 6rpx solid #EBEBEB;
  324. height: calc(100vh - var(--window-bottom) - 88rpx);
  325. display: flex;
  326. justify-content: center;
  327. background-color: #F7F7F7;
  328. .newicon-zanwu{
  329. font-size: 256rpx;
  330. color: #D6D6D6;
  331. margin-top: 140rpx;
  332. }
  333. }
  334. }
  335. </style>