incidentList.vue 15 KB

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