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