incidentList.vue 17 KB

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