incidentList.vue 15 KB

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