repairsList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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.stop="toIncidentDetail(data)">
  13. <view class="body_item_head ellipsis-multiline">
  14. {{data.description}}
  15. </view>
  16. <view class="body_item_content">
  17. <view class="body_item_content_p" v-if="data.place || data.houseNumber">
  18. <text class="name ellipsis">详细地址:{{data.place ? data.place.building.buildingName : ''}}{{data.place ? data.place.floorName : ''}}<text v-if="data.place && data.place.floorName">层</text> {{data.houseNumber}}</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.rsPrice">
  22. <text class="name ellipsis">维修总价:{{data.rsPrice}}</text>
  23. </view>
  24. <view class="body_item_content_p">
  25. <view class="name ellipsis" @click.stop="makePhoneCall(data.contactsInformation)">维修人员电话:{{data.contactsInformation || '暂无'}}<uni-icons v-if="data.contactsInformation" type="phone-filled" class="phone-filled" :size="18" :color="primaryColor"></uni-icons></view>
  26. </view>
  27. <view class="body_item_content_p" v-if="data.currentLog && data.currentLog.logType.value=='overtime'">
  28. <text class="name ellipsis">维修说明:{{data.overtimeRemark}}</text>
  29. </view>
  30. </view>
  31. <view class="body_item_foot">
  32. <view class="foot_info">
  33. <view class="name">维修人员:{{data.assigneeName || '暂无'}}</view>
  34. <text class="date">{{formatDate(data.startDate, 'yyyy-MM-dd HH:mm')}}</text>
  35. </view>
  36. <view class="btns">
  37. <button v-if="!data.wxdegree && (data.state.name=='待评价'|| data.state.name=='已关闭')" @click.stop="handler('changeUser', data)" type="default" class="primaryButton btn">评价</button>
  38. </view>
  39. </view>
  40. <div class="sign-style" v-if="deptRepair && publicRepair">
  41. <view class="img-box" v-if="data.repairIncidentType && data.repairIncidentType.name=='科室报修'">
  42. <view class="img-url1"></view>
  43. <view class="img-name">科</view>
  44. </view>
  45. <view class="img-box" v-if="data.repairIncidentType && data.repairIncidentType.name=='公共报修'">
  46. <view class="img-url2"></view>
  47. <view class="img-name">公</view>
  48. </view>
  49. </div>
  50. </view>
  51. </view>
  52. <view class="zanwu" v-else>
  53. <text class="newicon newicon-zanwu"></text>
  54. </view>
  55. <repairsFilter v-if="dataInfo.isFilter" @cancelEmit="cancelFilter" @confirmEmit="conformFilter" :evt="dataInfo.evtFilter"></repairsFilter>
  56. <IncidentAttachment v-if="dataInfo.isAttachment" @knowEmit="knowAttachment" :incidentData="dataInfo.incidentData"></IncidentAttachment>
  57. <uni-popup ref="popup" background-color="#fff" type="center" :before-close="true">
  58. <view class="popup-content">
  59. <view class="form_item column">
  60. <view class="title"><text class="required newicon newicon-bitian"></text>星级:</view>
  61. <uni-rate class="value" v-model="rate" />
  62. </view>
  63. <view class="form_item column">
  64. <view class="title"><text class="required newicon newicon-bitian"></text>内容:</view>
  65. <uni-easyinput class="value" type="textarea" v-model="wxdegreeremark" placeholder="请输入评价内容"/>
  66. </view>
  67. </view>
  68. <view class="foot_common_btns">
  69. <button @click="closePop" type="default" class="cancelButton btn">取消</button>
  70. <button @click="submit" type="default" class="primaryButton btn">提交</button>
  71. </view>
  72. </uni-popup>
  73. </view>
  74. </template>
  75. <script setup>
  76. import repairsFilter from '@/components/repairsFilter.vue';
  77. import IncidentAttachment from '@/components/IncidentAttachment.vue';
  78. import { startOfDay, endOfDay, format, add } from 'date-fns'
  79. import { ref, reactive, computed } from 'vue'
  80. import { onLoad, onShow, onHide, onPullDownRefresh, onReachBottom, onTabItemTap } from '@dcloudio/uni-app'
  81. import { api_getDictionary, api_incident, api_incident_count, api_incidentTask, api_taskresolve } from "@/http/api.js"
  82. import { filterFormatDate } from '@/filters/filterFormatDate.js'
  83. import { computedPriorityStyle } from '@/filters/computedPriorityStyle.js'
  84. import { computedStateStyle } from '@/filters/computedStateStyle.js'
  85. import { computedCurrentLogOverTime } from '@/filters/computedCurrentLogOverTime.js'
  86. import { defaultColor } from '@/static/js/theme.js'
  87. import { useSetTitle } from '@/share/useSetTitle.js'
  88. import { useMakePhoneCall } from '@/share/useMakePhoneCall.js'
  89. import { useLoginUserStore } from '@/stores/loginUser'
  90. import { useIncidentNumStore } from '@/stores/incidentNum'
  91. import { useIncidentListSearchStore } from '@/stores/incidentListSearch'
  92. import { repositoryListSearchStore } from '@/stores/repositorySearch'
  93. useSetTitle();
  94. const repositorySearchStore = repositoryListSearchStore();
  95. const loginUserStore = useLoginUserStore();
  96. const incidentNumStore = useIncidentNumStore();
  97. const incidentListSearchStore = useIncidentListSearchStore();
  98. const { formatDate } = filterFormatDate();
  99. const { priorityStyle } = computedPriorityStyle();
  100. const { stateStyle } = computedStateStyle();
  101. const { currentLogOverTime } = computedCurrentLogOverTime();
  102. const { makePhoneCall } = useMakePhoneCall();
  103. // 主题颜色
  104. const primaryColor = ref(defaultColor)
  105. const popup = ref(null);//弹框
  106. const assignFlag = ref(false);//指派权限
  107. const qiangdan = ref(false);//接单权限
  108. const deptRepair = ref({});//科内报修
  109. const publicRepair = ref({});//公共报修
  110. const degreeDictionary = ref(null); //星级字典
  111. const rowData = ref(null); //选择的数据
  112. const isSubmit = ref(false);
  113. const rate = ref(3);//星级
  114. const wxdegreeremark = ref(null);//评价内容
  115. // 判断是否显示接单按钮
  116. const computedReceive = computed(() => (data) => {
  117. let inUser = data.currentLog && data.currentLog.workerId == loginUserStore.loginUser.user.id;
  118. let inGroup = false;
  119. loginUserStore.loginUser.user.group.forEach(item => {
  120. if(data.currentLog){
  121. if (item.id == data.currentLog.groupId) {
  122. inGroup = true;
  123. }
  124. }
  125. })
  126. return data.state.value === 'pending' && (inUser || inGroup) && qiangdan.value;
  127. })
  128. // 转换协同人
  129. const computedSynergetic = computed(() => (synergetic) => {
  130. return (synergetic && synergetic.length) ? synergetic.map(v => v.name).join(',') : ''
  131. })
  132. const repairIncident = ref(null);
  133. // 数据
  134. const dataInfo = reactive({
  135. tabs: [{id: 0, name: '我的报修', value: 'all', num: ''},],
  136. tabActiveId: 0,//当前选择的tab
  137. list: [],//工单列表
  138. idx: 0,//页码
  139. hasMore: true,//是否有更多数据
  140. isFilter: false,//筛选框开关
  141. isAttachment: false,//图片和录音开关
  142. incidentId: undefined,
  143. stateValue:0,
  144. evtFilter: {
  145. hospital: {},
  146. selected: 'todoingAll',
  147. area: {id: 0, area: '全部'},
  148. category: {id: 0, category: '全部'},
  149. acceptDate: [],
  150. },//筛选框数据
  151. })
  152. // 工单详情
  153. function toIncidentDetail(data){
  154. uni.navigateTo({
  155. url: `/pages/repair/repairsDetail?incidentId=${data.id}`
  156. })
  157. }
  158. // 获取tab选项
  159. function getTabs(){
  160. if(uni.getStorageSync('sysData')){
  161. uni.showLoading({
  162. title: "加载中",
  163. mask: true,
  164. });
  165. let data = JSON.parse(uni.getStorageSync('sysData'))
  166. deptRepair.value = data.find(i=>i.keyconfig=='deptRepair')
  167. publicRepair.value = data.find(i=>i.keyconfig=='publicRepair')
  168. let postData = {
  169. "key": 'repair_incident_type',
  170. "type": "list",
  171. };
  172. if(deptRepair.value.valueconfig==1){
  173. api_getDictionary(postData).then(res => {
  174. res = res || [];
  175. repairIncident.value = res.find(i=>i.value=='dept')
  176. getList(0);
  177. })
  178. dataInfo.tabs = [
  179. {id: 0, name: '我的报修', value: 'all', num: ''},
  180. {id: 1, name: '科内报修', value: '2', num: ''}
  181. ]
  182. }else{
  183. getList(0);
  184. dataInfo.tabs = [
  185. {id: 0, name: '我的报修', value: 'all', num: ''},
  186. ]
  187. }
  188. }else{
  189. getList(0);
  190. dataInfo.tabs = [
  191. {id: 0, name: '我的报修', value: 'all', num: ''},
  192. ]
  193. }
  194. }
  195. // 点击tab
  196. function clickTab(tabId){
  197. dataInfo.tabActiveId = tabId;
  198. getList(0);
  199. }
  200. // 点击筛选
  201. function filterClick(){
  202. dataInfo.isFilter = true;
  203. }
  204. // 确认筛选
  205. function conformFilter(evtFilter){
  206. dataInfo.stateValue = evtFilter.category;
  207. dataInfo.isFilter = false;
  208. getList(0);
  209. }
  210. // 关闭筛选
  211. function cancelFilter(){
  212. dataInfo.isFilter = false;
  213. }
  214. // 点击图片和录音
  215. function attachmentClick(incidentData){
  216. dataInfo.incidentData = incidentData;
  217. dataInfo.isAttachment = true;
  218. }
  219. // 返回图片和录音
  220. function knowAttachment(){
  221. dataInfo.isAttachment = false;
  222. }
  223. // 评价
  224. function handler(type, data){
  225. rowData.value = data
  226. popup.value.open()
  227. let postData = {
  228. key: "incident_degree",
  229. type: "list"
  230. };
  231. api_getDictionary(postData).then(res => {
  232. res = res || [];
  233. degreeDictionary.value = res
  234. })
  235. }
  236. function closePop(){
  237. rate.value = 3
  238. wxdegreeremark.value = null
  239. popup.value.close()
  240. }
  241. function submit(){
  242. if(!rate.value){
  243. uni.showToast({
  244. icon: 'none',
  245. title: '请选择星级'
  246. });
  247. return;
  248. }
  249. if(!wxdegreeremark.value){
  250. uni.showToast({
  251. icon: 'none',
  252. title: '请输入评价内容'
  253. });
  254. return;
  255. }
  256. let rateData = null
  257. if(rate.value==0){
  258. rateData=degreeDictionary.value[0].id
  259. }else if(rate.value==1){
  260. rateData=degreeDictionary.value[4].id
  261. }else if(rate.value==2){
  262. rateData=degreeDictionary.value[3].id
  263. }else if(rate.value==3){
  264. rateData=degreeDictionary.value[2].id
  265. }else if(rate.value==4){
  266. rateData=degreeDictionary.value[1].id
  267. }else if(rate.value==5){
  268. rateData=degreeDictionary.value[0].id
  269. }
  270. let postData = {
  271. ...rowData.value,
  272. wxdegree: rateData==0?degreeDictionary.value[0]:{id: rateData},
  273. wxdegreeremark: wxdegreeremark.value
  274. }
  275. api_taskresolve({incident:postData}).then(res => {
  276. uni.hideLoading();
  277. if(res.state == 200){
  278. getList(0);
  279. uni.showToast({
  280. icon: 'none',
  281. title: '评价成功',
  282. });
  283. }else{
  284. uni.showToast({
  285. icon: 'none',
  286. title: res.msg || '请求数据失败!'
  287. });
  288. }
  289. })
  290. closePop()
  291. }
  292. // 获取列表信息
  293. function getList(idx){
  294. uni.showLoading({
  295. title: "加载中",
  296. mask: true,
  297. });
  298. dataInfo.idx = idx === undefined ? dataInfo.idx : idx;
  299. if(dataInfo.idx === 0){
  300. dataInfo.list = [];
  301. }
  302. let postData = {
  303. "idx": dataInfo.idx,
  304. "sum": 20,
  305. incident: {
  306. requester: dataInfo.tabActiveId == 0 ? { id: loginUserStore.loginUser.user.id } : undefined,
  307. department: dataInfo.tabActiveId == 1 ? { id: loginUserStore.loginUser.user.dept.id } : undefined,
  308. statesValues: (dataInfo.stateValue === 'close0' || dataInfo.stateValue === 'close1') ? 'close' : (dataInfo.stateValue || undefined),
  309. hasWxdegree: dataInfo.stateValue === 'close0' ? 0 : (dataInfo.stateValue === 'close1' ? 1 : undefined),
  310. repairIncidentType:{
  311. id:''
  312. }
  313. }
  314. }
  315. if(dataInfo.tabActiveId == 1){
  316. postData.incident.repairIncidentType.id = repairIncident.value.id
  317. }
  318. if(JSON.stringify(postData.incident.statesValues) === '{}'){
  319. delete postData.incident.statesValues
  320. }
  321. api_incident(postData).then(res => {
  322. uni.hideLoading();
  323. uni.stopPullDownRefresh();
  324. if(res.status == 200){
  325. let list = res.list || [];
  326. if(list.length){
  327. dataInfo.hasMore = true;
  328. dataInfo.list = dataInfo.idx === 0 ? list : dataInfo.list.concat(list);
  329. }else{
  330. dataInfo.hasMore = false;
  331. }
  332. }else{
  333. uni.showToast({
  334. icon: 'none',
  335. title: res.msg || '请求数据失败!'
  336. });
  337. }
  338. })
  339. // getCount(postData.incident);
  340. }
  341. // 获取列表数量
  342. function getCount(incident = {}){
  343. let postData = {
  344. wxCount: 'true',
  345. incidentList: [],
  346. }
  347. dataInfo.tabs.forEach(v => {
  348. postData.incidentList.push({...incident, ...{statusId: v.id || undefined}});
  349. })
  350. api_incident_count(postData).then(res => {
  351. if(res.state == 200){
  352. let myData = res.data || [];
  353. dataInfo.tabs.forEach((v, i) => {
  354. v.num = myData[i];
  355. })
  356. }else{
  357. uni.showToast({
  358. icon: 'none',
  359. title: res.msg || '请求数据失败!'
  360. });
  361. }
  362. })
  363. }
  364. // 初始化
  365. function onLoadFn(){
  366. getTabs();
  367. }
  368. onLoad((option) => {
  369. dataInfo.tabActiveId = Number(option.type)
  370. dataInfo.stateValue = option.value
  371. dataInfo.evtFilter.category = option.value
  372. repositorySearchStore.setRepositoryListSearchData(dataInfo.evtFilter)
  373. onLoadFn();
  374. })
  375. onShow((option) =>{
  376. })
  377. onHide(()=>{
  378. repositorySearchStore.clearRepositoryListSearchData()
  379. })
  380. onTabItemTap(e => {
  381. // onLoadFn();
  382. })
  383. onPullDownRefresh(() => {
  384. // getList(0)
  385. })
  386. onReachBottom(() => {
  387. dataInfo.idx += 1;
  388. if (dataInfo.hasMore) {
  389. getList(); // 当触底时加载更多数据
  390. }
  391. })
  392. </script>
  393. <style scoped>
  394. >>> .uni-popup__wrapper{
  395. width: 80%;
  396. padding: 40rpx;
  397. }
  398. </style>
  399. <style lang="scss" scoped>
  400. page{
  401. height: calc(100vh - var(--window-bottom));
  402. }
  403. .incidentList{
  404. display: flex;
  405. flex-direction: column;
  406. justify-content: space-between;
  407. .head{
  408. height: 88rpx;
  409. display: flex;
  410. position: fixed;
  411. z-index: 99;
  412. width: 100%;
  413. background-color: #fff;
  414. font-size: 30rpx;
  415. .tab{
  416. flex: 1;
  417. display: flex;
  418. justify-content: center;
  419. align-items: center;
  420. border-bottom: 4rpx solid transparent;
  421. &.active{
  422. color: $uni-primary;
  423. border-color: $uni-primary;
  424. }
  425. }
  426. .filter{
  427. width: 84rpx;
  428. display: flex;
  429. justify-content: center;
  430. align-items: center;
  431. .newicon-shaixuan{
  432. font-size: 36rpx;
  433. color: #2C2C2C;
  434. }
  435. }
  436. }
  437. .body{
  438. margin-bottom: var(--window-bottom);
  439. margin-top: 88rpx;
  440. border-top: 6rpx solid #EBEBEB;
  441. .body_item{
  442. border-bottom: 8rpx solid #EBEBEB;
  443. position: relative;
  444. .sign-style{
  445. position: absolute;
  446. right: 0;
  447. top: -25rpx;
  448. .img-box{
  449. position: relative;
  450. .img-url1{
  451. width: 70rpx;
  452. height: 70rpx;
  453. background-image: url('../../static/img/jiaobiao1.png');
  454. }
  455. .img-url2{
  456. width: 70rpx;
  457. height: 70rpx;
  458. background-image: url('../../static/img/jiaobiao2.png');
  459. }
  460. .img-name{
  461. position: absolute;
  462. right: 8rpx;
  463. top: 0;
  464. color: #fff;
  465. font-size: 24rpx;
  466. }
  467. }
  468. }
  469. .body_item_head{
  470. word-break: break-all;
  471. text-align: justify;
  472. text-align: left;
  473. margin: 24rpx;
  474. font-size: 30rpx;
  475. }
  476. .body_item_content{
  477. border-top: 1rpx solid #D8D8D8;
  478. padding: 24rpx 24rpx 24rpx 48rpx;
  479. .body_item_content_p{
  480. color: #6A6A6A;
  481. font-size: 26rpx;
  482. display: flex;
  483. justify-content: space-between;
  484. align-items: center;
  485. margin-bottom: 24rpx;
  486. &:last-of-type{
  487. margin-bottom: 0;
  488. }
  489. .name{
  490. flex: 1;
  491. }
  492. .status{
  493. padding: 4rpx 10rpx;
  494. border-radius: 20rpx;
  495. background-color: #DBE8FE;
  496. font-size: 22rpx;
  497. color: #006CF9;
  498. }
  499. .icon_all{
  500. .mic-filled,
  501. .image-filled
  502. {
  503. margin-left: 16rpx;
  504. }
  505. }
  506. }
  507. }
  508. .body_item_foot{
  509. border-top: 1rpx solid #D8D8D8;
  510. font-size: 26rpx;
  511. padding: 24rpx;
  512. .foot_info{
  513. display: flex;
  514. justify-content: space-between;
  515. align-items: center;
  516. .phone-filled{
  517. margin-left: 5rpx;
  518. }
  519. }
  520. }
  521. }
  522. }
  523. .zanwu{
  524. box-sizing: border-box;
  525. margin-bottom: var(--window-bottom);
  526. margin-top: 88rpx;
  527. border-top: 6rpx solid #EBEBEB;
  528. height: calc(100vh - var(--window-bottom) - 88rpx);
  529. display: flex;
  530. justify-content: center;
  531. background-color: #F7F7F7;
  532. .newicon-zanwu{
  533. font-size: 256rpx;
  534. color: #D6D6D6;
  535. margin-top: 140rpx;
  536. }
  537. }
  538. .popup-content{
  539. .form_item{
  540. display: flex;
  541. align-items: center;
  542. padding-top: 24rpx;
  543. min-height: 86rpx;
  544. position: relative;
  545. .chunk{
  546. width: 100%;
  547. height: 70rpx;
  548. line-height: 70rpx;
  549. text-align: center;
  550. background: #F7F8FA;
  551. box-shadow: 0px 3px 6px 1px rgba(0,0,0,0.16);
  552. border-radius: 10rpx;
  553. }
  554. &.column{
  555. height: auto;
  556. flex-direction: column;
  557. align-items: flex-start;
  558. .import-rep{
  559. padding: 5rpx 10rpx;
  560. border-radius: 50rpx;
  561. background: #d1fcd5;
  562. color: #49b856;
  563. font-size: 24rpx;
  564. }
  565. .title{
  566. margin-right: 0;
  567. }
  568. .title-width{
  569. width: 100%;
  570. }
  571. .title-fl-sb{
  572. display: flex;
  573. justify-content: space-between;
  574. width: 100%;
  575. }
  576. .value{
  577. margin-top: 10rpx;
  578. // padding-left: 20rpx;
  579. box-sizing: border-box;
  580. }
  581. .tips{
  582. padding: 24rpx;
  583. text-align: center;
  584. font-size: 22rpx;
  585. color: #909399;
  586. width: 100%;
  587. box-sizing: border-box;
  588. }
  589. }
  590. .title{
  591. font-size: 26rpx;
  592. display: flex;
  593. align-items: center;
  594. margin-right: 12rpx;
  595. flex-shrink: 0;
  596. &.select{
  597. width: calc(5em + 20rpx);
  598. }
  599. }
  600. .value{
  601. width: 100%;
  602. &.category{
  603. width: 100%;
  604. display: flex;
  605. justify-content: space-between;
  606. align-items: center;
  607. .categoryName{
  608. font-size: 26rpx;
  609. color: #555;
  610. flex: 1;
  611. }
  612. .newicon-weibiaoti2010104{
  613. color: $uni-primary;
  614. margin-left: 24rpx;
  615. }
  616. }
  617. .imgTips{
  618. color: #909399;
  619. font-size: 22rpx;
  620. margin-top: 10rpx;
  621. }
  622. }
  623. .item-input{
  624. border: 1px solid #DBDBDB;
  625. height: 70rpx;
  626. line-height: 70rpx;
  627. padding: 0 10rpx;
  628. border-radius: 4rpx;
  629. width: 100%;
  630. font-size: 14px;
  631. }
  632. .icon{
  633. position: absolute;
  634. right: 20rpx;
  635. color: #49b856;
  636. }
  637. }
  638. }
  639. }
  640. </style>