incidentList.vue 16 KB

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