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"><template v-if="data.assigneeName">处理人:{{data.assigneeName}}</template></text>
  29. <text class="name"><template v-if="data.candidateGroupsName">处理组:{{data.candidateGroupsName}}</template></text>
  30. <view class="icon_all" @click.stop="attachmentClick(data)">
  31. <uni-icons type="mic-filled" class="mic-filled" :size="22" color="#949494" v-if="data.callID"></uni-icons>
  32. <uni-icons type="image-filled" class="image-filled" :size="22" color="#949494" v-if="data.reqAttachment"></uni-icons>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="body_item_foot">
  37. <view class="foot_info">
  38. <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>
  39. <text class="date">{{formatDate(data.startDate, 'MM-dd HH:mm')}}</text>
  40. </view>
  41. <view class="btns">
  42. <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>
  43. <button @click.stop="handler('handler', data.id)" type="default" class="primaryButton btn" v-if="data.state.value === 'handler'">处理</button>
  44. <button @click.stop="receive(data)" type="default" class="primaryButton btn" v-if="computedReceive(data)">接单</button>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="zanwu" v-else>
  50. <text class="newicon newicon-zanwu"></text>
  51. </view>
  52. <IncidentListFilter v-if="dataInfo.isFilter" @cancelEmit="cancelFilter" @confirmEmit="conformFilter" :evt="dataInfo.evtFilter"></IncidentListFilter>
  53. <IncidentAttachment v-if="dataInfo.isAttachment" @knowEmit="knowAttachment" :incidentData="dataInfo.incidentData"></IncidentAttachment>
  54. </view>
  55. </template>
  56. <script setup>
  57. import IncidentListFilter from '@/components/IncidentListFilter.vue';
  58. import IncidentAttachment from '@/components/IncidentAttachment.vue';
  59. import { ref, reactive, computed } from 'vue'
  60. import { onLoad, onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app'
  61. import { api_getDictionary, api_incident, api_incident_count, api_incidentTask } from "@/http/api.js"
  62. import { filterFormatDate } from '@/filters/filterFormatDate.js'
  63. import { computedPriorityStyle } from '@/filters/computedPriorityStyle.js'
  64. import { computedStateStyle } from '@/filters/computedStateStyle.js'
  65. import { computedCurrentLogOverTime } from '@/filters/computedCurrentLogOverTime.js'
  66. import { defaultColor } from '@/static/js/theme.js'
  67. import { useSetTitle } from '@/share/useSetTitle.js'
  68. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  69. import { useLoginUserStore } from '@/stores/loginUser'
  70. import { useIncidentNumStore } from '@/stores/incidentNum'
  71. useSetTitle();
  72. const loginUserStore = useLoginUserStore();
  73. const incidentNumStore = useIncidentNumStore();
  74. const { formatDate } = filterFormatDate();
  75. const { priorityStyle } = computedPriorityStyle();
  76. const { stateStyle } = computedStateStyle();
  77. const { currentLogOverTime } = computedCurrentLogOverTime();
  78. const { makePhoneCall } = useMakePhoneCall();
  79. // 主题颜色
  80. const primaryColor = ref(defaultColor)
  81. const assignFlag = ref(false);//指派权限
  82. const qiangdan = ref(false);//接单权限
  83. // 判断是否显示接单按钮
  84. const computedReceive = computed(() => (data) => {
  85. let inUser = data.currentLog && data.currentLog.workerId == loginUserStore.loginUser.user.id;
  86. let inGroup = false;
  87. loginUserStore.loginUser.user.group.forEach(item => {
  88. if(data.currentLog){
  89. if (item.id == data.currentLog.groupId) {
  90. inGroup = true;
  91. }
  92. }
  93. })
  94. return data.state.value === 'pending' && (inUser || inGroup) && qiangdan.value;
  95. })
  96. // 数据
  97. const dataInfo = reactive({
  98. tabs: [{id: 0, name: '全部', value: 'all', num: ''}],
  99. tabActiveId: 0,//当前选择的tab
  100. list: [],//工单列表
  101. idx: 0,//页码
  102. hasMore: true,//是否有更多数据
  103. isFilter: false,//筛选框开关
  104. isAttachment: false,//图片和录音开关
  105. incidentId: undefined,
  106. evtFilter: {
  107. hospital: {},
  108. selected: 'todoingAll',
  109. area: {id: 0, area: '全部'},
  110. category: {id: 0, category: '全部'},
  111. },//筛选框数据
  112. })
  113. // 工单详情
  114. function toIncidentDetail(data){
  115. uni.navigateTo({
  116. url: `/pages/incidentDetail/incidentDetail?incidentId=${data.id}`
  117. })
  118. }
  119. // 获取tab选项
  120. function getTabs(){
  121. uni.showLoading({
  122. title: "加载中",
  123. mask: true,
  124. });
  125. api_getDictionary({
  126. "type": "list",
  127. "key": "incident_status"
  128. }).then(res => {
  129. uni.hideLoading();
  130. let incidentStatusList = res || [];
  131. let pending = incidentStatusList.find(v => v.value === 'pending');
  132. let handler = incidentStatusList.find(v => v.value === 'handler');
  133. dataInfo.tabs = [{id: 0, name: '全部', value: 'all', num: ''}];
  134. pending && dataInfo.tabs.push({...pending, ...{num: ''}});
  135. handler && dataInfo.tabs.push({...handler, ...{num: ''}});
  136. getList(0);
  137. })
  138. }
  139. // 点击tab
  140. function clickTab(tabId){
  141. dataInfo.tabActiveId = tabId;
  142. getList(0);
  143. }
  144. // 点击筛选
  145. function filterClick(){
  146. dataInfo.isFilter = true;
  147. }
  148. // 确认筛选
  149. function conformFilter(evtFilter){
  150. dataInfo.evtFilter = evtFilter;
  151. dataInfo.isFilter = false;
  152. getList(0);
  153. }
  154. // 关闭筛选
  155. function cancelFilter(){
  156. dataInfo.isFilter = false;
  157. }
  158. // 点击图片和录音
  159. function attachmentClick(incidentData){
  160. dataInfo.incidentData = incidentData;
  161. dataInfo.isAttachment = true;
  162. }
  163. // 知道了图片和录音
  164. function knowAttachment(){
  165. dataInfo.isAttachment = false;
  166. }
  167. // 处理按钮
  168. function handler(type, incidentId){
  169. uni.navigateTo({
  170. url: `/pages/${type}/${type}?incidentId=${incidentId}`
  171. })
  172. }
  173. // 接单调用方案
  174. function receiveFn(incidentData){
  175. uni.showLoading({
  176. title: "加载中",
  177. mask: true,
  178. });
  179. let postData = {
  180. incident: incidentData,
  181. }
  182. api_incidentTask('receive', postData).then(res => {
  183. uni.hideLoading();
  184. if(res.state == 200){
  185. getList(0);
  186. uni.showToast({
  187. icon: 'none',
  188. title: '接单成功',
  189. });
  190. }else{
  191. uni.showToast({
  192. icon: 'none',
  193. title: res.msg || '请求数据失败!'
  194. });
  195. }
  196. })
  197. }
  198. // 接单按钮
  199. function receive(incidentData){
  200. uni.showModal({
  201. title: '提示',
  202. content: `您确认要接单吗?`,
  203. confirmColor: defaultColor,
  204. confirmText: '确认',
  205. success: function(res) {
  206. if (res.confirm) {
  207. receiveFn(incidentData);
  208. }
  209. }
  210. });
  211. }
  212. // 获取列表信息
  213. function getList(idx){
  214. uni.showLoading({
  215. title: "加载中",
  216. mask: true,
  217. });
  218. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  219. if(dataInfo.idx === 0){
  220. dataInfo.list = [];
  221. }
  222. let postData = {
  223. "idx": dataInfo.idx,
  224. "sum": 10,
  225. "incident": {
  226. "queryTask": dataInfo.evtFilter.selected || undefined,
  227. "assignee": loginUserStore.loginUser.user.id,
  228. "statusId": dataInfo.tabActiveId || undefined,
  229. }
  230. }
  231. // 请求参数调整
  232. if(!postData.incident){
  233. postData.incident = {};
  234. }
  235. if(postData.incident.queryTask === 'all' || postData.incident.queryTask === 'callback'){
  236. if(loginUserStore.loginUser.user.duty){
  237. // 当前的所属责任科室
  238. postData.incident.duty = loginUserStore.loginUser.user.duty;
  239. }else if(loginUserStore.loginUser.user.branch){
  240. // 当前的所属院区
  241. postData.incident.branch = loginUserStore.loginUser.user.branch.id;
  242. }
  243. }else{
  244. delete postData.incident.duty;
  245. delete postData.incident.branch;
  246. }
  247. if(postData.incident.queryTask === 'todo' || postData.incident.queryTask === 'owns' || postData.incident.queryTask === 'todoingAll'){
  248. postData.incident.candidateGroups = loginUserStore.loginUser.user.group.map(v => v.id).toString();
  249. }else{
  250. delete postData.incident.candidateGroups;
  251. }
  252. if(dataInfo.evtFilter && dataInfo.evtFilter.category && dataInfo.evtFilter.category.id){
  253. postData.incident.levelCategory = { id: dataInfo.evtFilter.category.id };
  254. }
  255. if(dataInfo.evtFilter && dataInfo.evtFilter.area && dataInfo.evtFilter.area.id){
  256. postData.incident.area = dataInfo.evtFilter.area
  257. }
  258. api_incident(postData).then(res => {
  259. uni.hideLoading();
  260. uni.stopPullDownRefresh();
  261. if(res.status == 200){
  262. let list = res.list || [];
  263. list = list.map(v => ({...v, ...{callID:123}}))//模拟
  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 - 50px);
  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: 50px;
  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: 50px;
  430. margin-top: 88rpx;
  431. border-top: 6rpx solid #EBEBEB;
  432. height: calc(100vh - 50px - 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>