incidentList.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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 } 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. onLoad((option) => {
  306. // 我的-数量跳转
  307. if(incidentNumStore.incidentNum.data){
  308. dataInfo.evtFilter.selected = incidentNumStore.incidentNum.data.queryTask;
  309. dataInfo.tabActiveId = incidentNumStore.incidentNum.data.statusId;
  310. incidentNumStore.clearIncidentNumData();
  311. }else if(incidentListSearchStore.incidentListSearch.data){
  312. // 缓存的搜索条件
  313. Object.assign(dataInfo, incidentListSearchStore.incidentListSearch.data);
  314. }
  315. for (let i = 0; i < loginUserStore.loginUser.menu.length; i++) {
  316. if (loginUserStore.loginUser.menu[i].link == "shijianliebiao_assign") {
  317. assignFlag.value = true;
  318. }
  319. if (loginUserStore.loginUser.menu[i].link == "shijianliebiao_qiangdan") {
  320. qiangdan.value = true
  321. }
  322. }
  323. getTabs();
  324. })
  325. onPullDownRefresh(() => {
  326. getList(0)
  327. })
  328. onReachBottom(() => {
  329. dataInfo.idx += 1;
  330. if (dataInfo.hasMore) {
  331. getList(); // 当触底时加载更多数据
  332. }
  333. })
  334. </script>
  335. <style lang="scss" scoped>
  336. page{
  337. height: calc(100vh - var(--window-bottom));
  338. }
  339. .incidentList{
  340. display: flex;
  341. flex-direction: column;
  342. justify-content: space-between;
  343. .head{
  344. height: 88rpx;
  345. display: flex;
  346. position: fixed;
  347. z-index: 99;
  348. width: 100%;
  349. background-color: #fff;
  350. font-size: 30rpx;
  351. .tab{
  352. flex: 1;
  353. display: flex;
  354. justify-content: center;
  355. align-items: center;
  356. border-bottom: 4rpx solid transparent;
  357. &.active{
  358. color: $uni-primary;
  359. border-color: $uni-primary;
  360. }
  361. }
  362. .filter{
  363. width: 84rpx;
  364. display: flex;
  365. justify-content: center;
  366. align-items: center;
  367. .newicon-shaixuan{
  368. font-size: 36rpx;
  369. color: #2C2C2C;
  370. }
  371. }
  372. }
  373. .body{
  374. margin-bottom: var(--window-bottom);
  375. margin-top: 88rpx;
  376. border-top: 6rpx solid #EBEBEB;
  377. .body_item{
  378. border-bottom: 8rpx solid #EBEBEB;
  379. .body_item_head{
  380. word-break: break-all;
  381. text-align: justify;
  382. text-align: left;
  383. margin: 24rpx;
  384. font-size: 30rpx;
  385. }
  386. .body_item_content{
  387. border-top: 1rpx solid #D8D8D8;
  388. padding: 24rpx 24rpx 24rpx 48rpx;
  389. .body_item_content_p{
  390. color: #6A6A6A;
  391. font-size: 26rpx;
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. margin-bottom: 24rpx;
  396. &:last-of-type{
  397. margin-bottom: 0;
  398. }
  399. .name{
  400. flex: 1;
  401. }
  402. .status{
  403. padding: 4rpx 10rpx;
  404. border-radius: 20rpx;
  405. background-color: #DBE8FE;
  406. font-size: 22rpx;
  407. color: #006CF9;
  408. }
  409. .icon_all{
  410. .mic-filled,
  411. .image-filled
  412. {
  413. margin-left: 16rpx;
  414. }
  415. }
  416. }
  417. }
  418. .body_item_foot{
  419. border-top: 1rpx solid #D8D8D8;
  420. font-size: 26rpx;
  421. padding: 24rpx;
  422. .foot_info{
  423. display: flex;
  424. justify-content: space-between;
  425. align-items: center;
  426. .phone-filled{
  427. margin-left: 5rpx;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. .zanwu{
  434. box-sizing: border-box;
  435. margin-bottom: var(--window-bottom);
  436. margin-top: 88rpx;
  437. border-top: 6rpx solid #EBEBEB;
  438. height: calc(100vh - var(--window-bottom) - 88rpx);
  439. display: flex;
  440. justify-content: center;
  441. background-color: #F7F7F7;
  442. .newicon-zanwu{
  443. font-size: 256rpx;
  444. color: #D6D6D6;
  445. margin-top: 140rpx;
  446. }
  447. }
  448. }
  449. </style>