incidentList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  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">
  14. <text :style="priorityStyle(data.priority)">{{data.priority ? data.priority.name + ' ' : ''}}</text>{{data.description}}
  15. </view>
  16. <view class="body_item_content">
  17. <view class="body_item_content_p" v-if="data.department">
  18. <text class="name ellipsis">报修科室:{{data.department.dept}}</text>
  19. <view class="status" :style="stateStyle(data.state)">{{data.state ? data.state.name : ''}}</view>
  20. </view>
  21. <view class="body_item_content_p" v-if="data.place || data.houseNumber">
  22. <text class="name ellipsis">详细地址:{{data.place ? data.place.area.area : ''}}{{data.place ? data.place.place : ''}}{{data.houseNumber}}</text>
  23. </view>
  24. <view class="body_item_content_p" v-if="data.currentLog && data.currentLog.extra1DTO && data.currentLog.extra2 && data.currentLog.startTime">
  25. <text class="name ellipsis">延期处理:{{currentLogOverTime(data.currentLog)}}</text>
  26. </view>
  27. <view class="body_item_content_p">
  28. <text class="name"><template v-if="data.assigneeName">处理人:{{data.assigneeName}}</template></text>
  29. <text class="name"><template v-if="data.candidateGroupsName">处理组:{{data.candidateGroupsName}}</template></text>
  30. <view class="icon_all" @click="attachmentClick(data)">
  31. <uni-icons type="mic-filled" class="mic-filled" :size="22" color="#949494" v-if="data.callID"></uni-icons>
  32. <uni-icons type="image-filled" class="image-filled" :size="22" color="#949494" v-if="data.reqAttachment"></uni-icons>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="body_item_foot">
  37. <view class="foot_info">
  38. <view class="name" @click="makePhoneCall(data.contactsInformation)">联系电话:{{data.contactsInformation}}<uni-icons type="phone-filled" class="phone-filled" :size="18" :color="primaryColor"></uni-icons></view>
  39. <text class="date">{{formatDate(data.startDate, 'MM-dd HH:mm')}}</text>
  40. </view>
  41. <view class="btns" v-if="data.state.value === 'pending' || data.state.value === 'handler'">
  42. <button @click="handler('changeUser')" type="default" class="primaryButton btn">换人处理</button>
  43. <button @click="handler('handler')" type="default" class="primaryButton btn" v-if="data.state.value === 'handler'">处理</button>
  44. <button @click="handler('receive')" type="default" class="primaryButton btn" v-if="data.state.value === 'pending'">接单</button>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="zanwu" v-else>
  50. <text class="newicon newicon-zanwu"></text>
  51. </view>
  52. </view>
  53. <incidentListFilter v-if="dataInfo.isFilter" @cancelEmit="cancelFilter" @confirmEmit="conformFilter" :evt="dataInfo.evtFilter"></incidentListFilter>
  54. <IncidentAttachment v-if="dataInfo.isAttachment" @knowEmit="knowAttachment" :incidentData="dataInfo.incidentData"></IncidentAttachment>
  55. </template>
  56. <script setup>
  57. import IncidentListFilter from '@/components/IncidentListFilter.vue';
  58. import IncidentAttachment from '@/components/IncidentAttachment.vue';
  59. import { ref, reactive } from 'vue'
  60. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  61. import { api_getDictionary, api_incident, api_incident_count } from "@/http/api.js"
  62. import { filterFormatDate } from '@/filters/filterFormatDate.js'
  63. import { computedPriorityStyle } from '@/filters/computedPriorityStyle.js'
  64. import { computedStateStyle } from '@/filters/computedStateStyle.js'
  65. import { computedCurrentLogOverTime } from '@/filters/computedCurrentLogOverTime.js'
  66. import { defaultColor } from '@/static/js/theme.js'
  67. import { useSetTitle } from '@/share/useSetTitle.js'
  68. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  69. import { useLoginUserStore } from '@/stores/loginUser'
  70. useSetTitle();
  71. const loginUserStore = useLoginUserStore();
  72. const { formatDate } = filterFormatDate();
  73. const { priorityStyle } = computedPriorityStyle();
  74. const { stateStyle } = computedStateStyle();
  75. const { currentLogOverTime } = computedCurrentLogOverTime();
  76. const { makePhoneCall } = useMakePhoneCall();
  77. // 主题颜色
  78. const primaryColor = ref(defaultColor)
  79. // 数据
  80. const dataInfo = reactive({
  81. tabs: [{id: 0, name: '全部', value: 'all', num: ''}],
  82. tabActiveId: 0,//当前选择的tab
  83. list: [],//事件列表
  84. idx: 0,//页码
  85. hasMore: true,//是否有更多数据
  86. isFilter: false,//筛选框开关
  87. isAttachment: false,//图片和录音开关
  88. incidentId: undefined,
  89. evtFilter: {
  90. hospital: {},
  91. selected: 'todoingAll',
  92. area: {id: 0, area: '全部'},
  93. category: {id: 0, category: '全部'},
  94. },//筛选框数据
  95. })
  96. // 获取tab选项
  97. function getTabs(){
  98. uni.showLoading({
  99. title: "加载中",
  100. mask: true,
  101. });
  102. api_getDictionary({
  103. "type": "list",
  104. "key": "incident_status"
  105. }).then(res => {
  106. uni.hideLoading();
  107. let incidentStatusList = res || [];
  108. let pending = incidentStatusList.find(v => v.value === 'pending');
  109. let handler = incidentStatusList.find(v => v.value === 'handler');
  110. dataInfo.tabs = [{id: 0, name: '全部', value: 'all', num: ''}];
  111. pending && dataInfo.tabs.push({...pending, ...{num: ''}});
  112. handler && dataInfo.tabs.push({...handler, ...{num: ''}});
  113. getList(0);
  114. })
  115. }
  116. // 点击tab
  117. function clickTab(tabId){
  118. dataInfo.tabActiveId = tabId;
  119. getList(0);
  120. }
  121. // 点击筛选
  122. function filterClick(){
  123. dataInfo.isFilter = true;
  124. }
  125. // 确认筛选
  126. function conformFilter(evtFilter){
  127. dataInfo.evtFilter = evtFilter;
  128. dataInfo.isFilter = false;
  129. getList(0);
  130. }
  131. // 关闭筛选
  132. function cancelFilter(){
  133. dataInfo.isFilter = false;
  134. }
  135. // 点击图片和录音
  136. function attachmentClick(incidentData){
  137. dataInfo.incidentData = incidentData;
  138. dataInfo.isAttachment = true;
  139. }
  140. // 知道了图片和录音
  141. function knowAttachment(){
  142. dataInfo.isAttachment = false;
  143. }
  144. // 处理按钮
  145. function handler(type){
  146. uni.navigateTo({
  147. url: `/pages/${type}/${type}`
  148. })
  149. }
  150. // 获取列表信息
  151. function getList(idx){
  152. uni.showLoading({
  153. title: "加载中",
  154. mask: true,
  155. });
  156. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  157. if(dataInfo.idx === 0){
  158. dataInfo.list = [];
  159. }
  160. let postData = {
  161. "idx": dataInfo.idx,
  162. "sum": 10,
  163. "incident": {
  164. "queryTask": dataInfo.evtFilter.selected || undefined,
  165. "assignee": loginUserStore.loginUser.user.id,
  166. "statusId": dataInfo.tabActiveId || undefined,
  167. }
  168. }
  169. if(loginUserStore.loginUser.user.duty){
  170. // 当前的所属责任科室
  171. postData.incident.duty = loginUserStore.loginUser.user.duty;
  172. }else if(loginUserStore.loginUser.user.branch){
  173. // 当前的所属院区
  174. postData.incident.branch = loginUserStore.loginUser.user.branch.id;
  175. }
  176. if(dataInfo.evtFilter && dataInfo.evtFilter.category && dataInfo.evtFilter.category.id){
  177. postData.incident.levelCategory = dataInfo.evtFilter.category;
  178. }
  179. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  180. postData.incident.area = dataInfo.evtFilter.area;
  181. }
  182. api_incident(postData).then(res => {
  183. uni.hideLoading();
  184. uni.stopPullDownRefresh();
  185. if(res.status == 200){
  186. let list = res.list || [];
  187. list = list.map(v => ({...v, ...{reqAttachment: true, callID:123}}))//模拟
  188. if(list.length){
  189. dataInfo.hasMore = true;
  190. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  191. }else{
  192. dataInfo.hasMore = false;
  193. }
  194. }else{
  195. uni.showToast({
  196. icon: 'none',
  197. title: res.msg || '请求数据失败!'
  198. });
  199. }
  200. })
  201. getCount(postData.incident);
  202. }
  203. // 获取列表数量
  204. function getCount(incident = {}){
  205. let postData = {
  206. wxCount: 'true',
  207. incidentList: [],
  208. }
  209. dataInfo.tabs.forEach(v => {
  210. postData.incidentList.push({...incident, ...{statusId: v.id || undefined}});
  211. })
  212. postData.incidentList.forEach(incident => {
  213. // 请求参数调整
  214. if(!incident){
  215. incident = {};
  216. }
  217. if(incident.queryTask === 'all' || incident.queryTask === 'callback'){
  218. if(loginUserStore.loginUser.user.duty){
  219. // 当前的所属责任科室
  220. incident.duty = loginUserStore.loginUser.user.duty;
  221. }else if(loginUserStore.loginUser.user.branch){
  222. // 当前的所属院区
  223. incident.branch = loginUserStore.loginUser.user.branch.id;
  224. }
  225. }else{
  226. delete incident.duty;
  227. delete incident.branch;
  228. }
  229. incident.assignee = loginUserStore.loginUser.user.id;
  230. if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
  231. incident.candidateGroups = loginUserStore.loginUser.user.group.map(v => v.id).toString();
  232. }else{
  233. delete incident.candidateGroups;
  234. }
  235. if(dataInfo.evtFilter && dataInfo.evtFilter.category && dataInfo.evtFilter.category.id){
  236. incident.levelCategory = dataInfo.evtFilter.category;
  237. }
  238. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  239. incident.place = {
  240. area: dataInfo.evtFilter.area
  241. }
  242. }
  243. })
  244. api_incident_count(postData).then(res => {
  245. if(res.state == 200){
  246. let myData = res.data || [];
  247. dataInfo.tabs.forEach((v, i) => {
  248. v.num = myData[i];
  249. })
  250. }else{
  251. uni.showToast({
  252. icon: 'none',
  253. title: res.msg || '请求数据失败!'
  254. });
  255. }
  256. })
  257. }
  258. onLoad((option) => {
  259. getTabs();
  260. })
  261. onPullDownRefresh(() => {
  262. getList(0)
  263. })
  264. onReachBottom(() => {
  265. dataInfo.idx += 1;
  266. if (dataInfo.hasMore) {
  267. getList(); // 当触底时加载更多数据
  268. }
  269. })
  270. </script>
  271. <style lang="scss" scoped>
  272. .incidentList{
  273. display: flex;
  274. flex-direction: column;
  275. justify-content: space-between;
  276. .head{
  277. height: 88rpx;
  278. display: flex;
  279. position: fixed;
  280. z-index: 99;
  281. width: 100%;
  282. background-color: #fff;
  283. .tab{
  284. flex: 1;
  285. display: flex;
  286. justify-content: center;
  287. align-items: center;
  288. border-bottom: 4rpx solid transparent;
  289. &.active{
  290. color: $uni-primary;
  291. border-color: $uni-primary;
  292. }
  293. }
  294. .filter{
  295. width: 84rpx;
  296. display: flex;
  297. justify-content: center;
  298. align-items: center;
  299. .newicon-shaixuan{
  300. font-size: 36rpx;
  301. color: #2C2C2C;
  302. }
  303. }
  304. }
  305. .body{
  306. margin-bottom: 50px;
  307. margin-top: 88rpx;
  308. border-top: 6rpx solid #EBEBEB;
  309. .body_item{
  310. border-bottom: 8rpx solid #EBEBEB;
  311. .body_item_head{
  312. word-break: break-all;
  313. text-align: justify;
  314. text-align: left;
  315. margin: 24rpx;
  316. }
  317. .body_item_content{
  318. border-top: 1rpx solid #D8D8D8;
  319. padding: 24rpx 24rpx 24rpx 48rpx;
  320. .body_item_content_p{
  321. color: #6A6A6A;
  322. font-size: 26rpx;
  323. display: flex;
  324. justify-content: space-between;
  325. align-items: center;
  326. margin-bottom: 24rpx;
  327. &:last-of-type{
  328. margin-bottom: 0;
  329. }
  330. .name{
  331. flex: 1;
  332. }
  333. .status{
  334. padding: 4rpx 10rpx;
  335. border-radius: 20rpx;
  336. background-color: #DBE8FE;
  337. font-size: 22rpx;
  338. color: #006CF9;
  339. }
  340. .icon_all{
  341. .mic-filled,
  342. .image-filled
  343. {
  344. margin-left: 16rpx;
  345. }
  346. }
  347. }
  348. }
  349. .body_item_foot{
  350. border-top: 1rpx solid #D8D8D8;
  351. font-size: 26rpx;
  352. padding: 24rpx;
  353. .foot_info{
  354. display: flex;
  355. justify-content: space-between;
  356. align-items: center;
  357. .phone-filled{
  358. margin-left: 5rpx;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. .zanwu{
  365. box-sizing: border-box;
  366. margin-bottom: 50px;
  367. margin-top: 88rpx;
  368. border-top: 6rpx solid #EBEBEB;
  369. height: calc(100vh - 50px - 88rpx);
  370. display: flex;
  371. justify-content: center;
  372. background-color: #F7F7F7;
  373. .newicon-zanwu{
  374. font-size: 256rpx;
  375. color: #D6D6D6;
  376. margin-top: 140rpx;
  377. }
  378. }
  379. }
  380. </style>