incidentList.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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">
  42. <button @click="handler('changeUser', data.id)" type="default" class="primaryButton btn" v-if="data.state.value === 'pending' || data.state.value === 'handler' || (data.state.value === 'reassign' && assignFlag)">换人处理</button>
  43. <button @click="handler('handler', data.id)" type="default" class="primaryButton btn" v-if="data.state.value === 'handler'">处理</button>
  44. <button @click="handler('receive', data.id)" 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. const assignFlag = ref(false);//指派权限
  80. // 数据
  81. const dataInfo = reactive({
  82. tabs: [{id: 0, name: '全部', value: 'all', num: ''}],
  83. tabActiveId: 0,//当前选择的tab
  84. list: [],//事件列表
  85. idx: 0,//页码
  86. hasMore: true,//是否有更多数据
  87. isFilter: false,//筛选框开关
  88. isAttachment: false,//图片和录音开关
  89. incidentId: undefined,
  90. evtFilter: {
  91. hospital: {},
  92. selected: 'todoingAll',
  93. area: {id: 0, area: '全部'},
  94. category: {id: 0, category: '全部'},
  95. },//筛选框数据
  96. })
  97. // 获取tab选项
  98. function getTabs(){
  99. uni.showLoading({
  100. title: "加载中",
  101. mask: true,
  102. });
  103. api_getDictionary({
  104. "type": "list",
  105. "key": "incident_status"
  106. }).then(res => {
  107. uni.hideLoading();
  108. let incidentStatusList = res || [];
  109. let pending = incidentStatusList.find(v => v.value === 'pending');
  110. let handler = incidentStatusList.find(v => v.value === 'handler');
  111. dataInfo.tabs = [{id: 0, name: '全部', value: 'all', num: ''}];
  112. pending && dataInfo.tabs.push({...pending, ...{num: ''}});
  113. handler && dataInfo.tabs.push({...handler, ...{num: ''}});
  114. getList(0);
  115. })
  116. }
  117. // 点击tab
  118. function clickTab(tabId){
  119. dataInfo.tabActiveId = tabId;
  120. getList(0);
  121. }
  122. // 点击筛选
  123. function filterClick(){
  124. dataInfo.isFilter = true;
  125. }
  126. // 确认筛选
  127. function conformFilter(evtFilter){
  128. dataInfo.evtFilter = evtFilter;
  129. dataInfo.isFilter = false;
  130. getList(0);
  131. }
  132. // 关闭筛选
  133. function cancelFilter(){
  134. dataInfo.isFilter = false;
  135. }
  136. // 点击图片和录音
  137. function attachmentClick(incidentData){
  138. dataInfo.incidentData = incidentData;
  139. dataInfo.isAttachment = true;
  140. }
  141. // 知道了图片和录音
  142. function knowAttachment(){
  143. dataInfo.isAttachment = false;
  144. }
  145. // 处理按钮
  146. function handler(type, incidentId){
  147. uni.navigateTo({
  148. url: `/pages/${type}/${type}?incidentId=${incidentId}`
  149. })
  150. }
  151. // 获取列表信息
  152. function getList(idx){
  153. uni.showLoading({
  154. title: "加载中",
  155. mask: true,
  156. });
  157. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  158. if(dataInfo.idx === 0){
  159. dataInfo.list = [];
  160. }
  161. let postData = {
  162. "idx": dataInfo.idx,
  163. "sum": 10,
  164. "incident": {
  165. "queryTask": dataInfo.evtFilter.selected || undefined,
  166. "assignee": loginUserStore.loginUser.user.id,
  167. "statusId": dataInfo.tabActiveId || undefined,
  168. }
  169. }
  170. if(loginUserStore.loginUser.user.duty){
  171. // 当前的所属责任科室
  172. postData.incident.duty = loginUserStore.loginUser.user.duty;
  173. }else if(loginUserStore.loginUser.user.branch){
  174. // 当前的所属院区
  175. postData.incident.branch = loginUserStore.loginUser.user.branch.id;
  176. }
  177. if(dataInfo.evtFilter && dataInfo.evtFilter.category && dataInfo.evtFilter.category.id){
  178. postData.incident.levelCategory = dataInfo.evtFilter.category;
  179. }
  180. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  181. postData.incident.area = dataInfo.evtFilter.area;
  182. }
  183. api_incident(postData).then(res => {
  184. uni.hideLoading();
  185. uni.stopPullDownRefresh();
  186. if(res.status == 200){
  187. let list = res.list || [];
  188. list = list.map(v => ({...v, ...{callID:123}}))//模拟
  189. if(list.length){
  190. dataInfo.hasMore = true;
  191. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  192. }else{
  193. dataInfo.hasMore = false;
  194. }
  195. }else{
  196. uni.showToast({
  197. icon: 'none',
  198. title: res.msg || '请求数据失败!'
  199. });
  200. }
  201. })
  202. getCount(postData.incident);
  203. }
  204. // 获取列表数量
  205. function getCount(incident = {}){
  206. let postData = {
  207. wxCount: 'true',
  208. incidentList: [],
  209. }
  210. dataInfo.tabs.forEach(v => {
  211. postData.incidentList.push({...incident, ...{statusId: v.id || undefined}});
  212. })
  213. postData.incidentList.forEach(incident => {
  214. // 请求参数调整
  215. if(!incident){
  216. incident = {};
  217. }
  218. if(incident.queryTask === 'all' || incident.queryTask === 'callback'){
  219. if(loginUserStore.loginUser.user.duty){
  220. // 当前的所属责任科室
  221. incident.duty = loginUserStore.loginUser.user.duty;
  222. }else if(loginUserStore.loginUser.user.branch){
  223. // 当前的所属院区
  224. incident.branch = loginUserStore.loginUser.user.branch.id;
  225. }
  226. }else{
  227. delete incident.duty;
  228. delete incident.branch;
  229. }
  230. incident.assignee = loginUserStore.loginUser.user.id;
  231. if(incident.queryTask === 'todo' || incident.queryTask === 'owns'){
  232. incident.candidateGroups = loginUserStore.loginUser.user.group.map(v => v.id).toString();
  233. }else{
  234. delete incident.candidateGroups;
  235. }
  236. if(dataInfo.evtFilter && dataInfo.evtFilter.category && dataInfo.evtFilter.category.id){
  237. incident.levelCategory = dataInfo.evtFilter.category;
  238. }
  239. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  240. incident.place = {
  241. area: dataInfo.evtFilter.area
  242. }
  243. }
  244. })
  245. api_incident_count(postData).then(res => {
  246. if(res.state == 200){
  247. let myData = res.data || [];
  248. dataInfo.tabs.forEach((v, i) => {
  249. v.num = myData[i];
  250. })
  251. }else{
  252. uni.showToast({
  253. icon: 'none',
  254. title: res.msg || '请求数据失败!'
  255. });
  256. }
  257. })
  258. }
  259. onLoad((option) => {
  260. for (let i = 0; i < loginUserStore.loginUser.menu.length; i++) {
  261. if (loginUserStore.loginUser.menu[i].link == "shijianliebiao_assign") {
  262. assignFlag.value = true;
  263. }
  264. }
  265. getTabs();
  266. })
  267. onPullDownRefresh(() => {
  268. getList(0)
  269. })
  270. onReachBottom(() => {
  271. dataInfo.idx += 1;
  272. if (dataInfo.hasMore) {
  273. getList(); // 当触底时加载更多数据
  274. }
  275. })
  276. </script>
  277. <style lang="scss" scoped>
  278. .incidentList{
  279. display: flex;
  280. flex-direction: column;
  281. justify-content: space-between;
  282. .head{
  283. height: 88rpx;
  284. display: flex;
  285. position: fixed;
  286. z-index: 99;
  287. width: 100%;
  288. background-color: #fff;
  289. .tab{
  290. flex: 1;
  291. display: flex;
  292. justify-content: center;
  293. align-items: center;
  294. border-bottom: 4rpx solid transparent;
  295. &.active{
  296. color: $uni-primary;
  297. border-color: $uni-primary;
  298. }
  299. }
  300. .filter{
  301. width: 84rpx;
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. .newicon-shaixuan{
  306. font-size: 36rpx;
  307. color: #2C2C2C;
  308. }
  309. }
  310. }
  311. .body{
  312. margin-bottom: 50px;
  313. margin-top: 88rpx;
  314. border-top: 6rpx solid #EBEBEB;
  315. .body_item{
  316. border-bottom: 8rpx solid #EBEBEB;
  317. .body_item_head{
  318. word-break: break-all;
  319. text-align: justify;
  320. text-align: left;
  321. margin: 24rpx;
  322. }
  323. .body_item_content{
  324. border-top: 1rpx solid #D8D8D8;
  325. padding: 24rpx 24rpx 24rpx 48rpx;
  326. .body_item_content_p{
  327. color: #6A6A6A;
  328. font-size: 26rpx;
  329. display: flex;
  330. justify-content: space-between;
  331. align-items: center;
  332. margin-bottom: 24rpx;
  333. &:last-of-type{
  334. margin-bottom: 0;
  335. }
  336. .name{
  337. flex: 1;
  338. }
  339. .status{
  340. padding: 4rpx 10rpx;
  341. border-radius: 20rpx;
  342. background-color: #DBE8FE;
  343. font-size: 22rpx;
  344. color: #006CF9;
  345. }
  346. .icon_all{
  347. .mic-filled,
  348. .image-filled
  349. {
  350. margin-left: 16rpx;
  351. }
  352. }
  353. }
  354. }
  355. .body_item_foot{
  356. border-top: 1rpx solid #D8D8D8;
  357. font-size: 26rpx;
  358. padding: 24rpx;
  359. .foot_info{
  360. display: flex;
  361. justify-content: space-between;
  362. align-items: center;
  363. .phone-filled{
  364. margin-left: 5rpx;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. .zanwu{
  371. box-sizing: border-box;
  372. margin-bottom: 50px;
  373. margin-top: 88rpx;
  374. border-top: 6rpx solid #EBEBEB;
  375. height: calc(100vh - 50px - 88rpx);
  376. display: flex;
  377. justify-content: center;
  378. background-color: #F7F7F7;
  379. .newicon-zanwu{
  380. font-size: 256rpx;
  381. color: #D6D6D6;
  382. margin-top: 140rpx;
  383. }
  384. }
  385. }
  386. </style>