home.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <view class="container">
  3. <view class="top_bg"></view>
  4. <!-- 状态统计区域 后勤管理端 -->
  5. <view class="top_types2" v-if="btns.includes('首页分段器')">
  6. <view class="top">
  7. <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text" activeColor="#6FB6B8"></uni-segmented-control>
  8. </view>
  9. <view class="bottom">
  10. <view class="bottom_box">
  11. <view class="box_num">100</view>
  12. <view class="box_info">工单数</view>
  13. </view>
  14. <view class="bottom_box">
  15. <view class="box_num">10</view>
  16. <view class="box_info">处理中</view>
  17. </view>
  18. <view class="bottom_box">
  19. <view class="box_num">50</view>
  20. <view class="box_info">已完成</view>
  21. </view>
  22. <view class="bottom_box">
  23. <view class="box_num">60</view>
  24. <view class="box_info">已超时</view>
  25. </view>
  26. </view>
  27. </view>
  28. <!-- 状态统计区域 维修师傅端 -->
  29. <view class="top_types" v-else>
  30. <view class="types_box">
  31. <view class="box_num">100</view>
  32. <view class="box_info">工单数</view>
  33. </view>
  34. <view class="types_box">
  35. <view class="box_num">10</view>
  36. <view class="box_info">处理中</view>
  37. </view>
  38. <view class="types_box">
  39. <view class="box_num">50</view>
  40. <view class="box_info">已完成</view>
  41. </view>
  42. <view class="types_box">
  43. <view class="box_num">60</view>
  44. <view class="box_info">已超时</view>
  45. </view>
  46. </view>
  47. <!-- 排班区域 -->
  48. <view class="watch">
  49. <view class="watch_title">
  50. <img src="../../static/images/repairsImg/watch.png" />
  51. 排班
  52. </view>
  53. <!-- 表格区域 -->
  54. <uni-table stripe emptyText="暂无更多数据">
  55. <!-- 表头行 -->
  56. <uni-tr>
  57. <uni-th width="80" align="center">姓名</uni-th>
  58. <uni-th width="50" align="center">工种</uni-th>
  59. <uni-th width="80" align="center">接单状态</uni-th>
  60. <uni-th width="70" align="center">值班班次</uni-th>
  61. </uni-tr>
  62. <!-- 表格数据行 -->
  63. <uni-tr v-for="(item, index) in tableData" :key="index">
  64. <!-- 姓名区域 -->
  65. <uni-td align="center">{{ item.name }}</uni-td>
  66. <!-- 工种区域 -->
  67. <uni-td align="center">{{ item.type }}</uni-td>
  68. <!-- 状态区域 -->
  69. <uni-td align="center">
  70. <picker :disabled="!btns.includes('表格编辑')" @change="bindPickerChange($event, item)" :range="typeArray">
  71. <view class="watch_color" v-if="item.status == '0'">{{ typeArray[item.status] }}</view>
  72. <view class="watch_color2" v-if="item.status == '1'">{{ typeArray[item.status] }}</view>
  73. <view class="watch_color3" v-if="item.status == '2'">{{ typeArray[item.status] }}</view>
  74. </picker>
  75. </uni-td>
  76. <!-- 是否值班 -->
  77. <uni-td align="center">
  78. <view @click="handleChange(item, index)">{{ getCutting(item.work) }}</view>
  79. </uni-td>
  80. </uni-tr>
  81. </uni-table>
  82. <!-- 是否值班弹窗区域 -->
  83. <uni-popup ref="popup_work" background-color="#fff">
  84. <view class="watch_pop">
  85. <view class="poop_title">
  86. <view class="cancel" @click="$refs.popup_work.close()">取消</view>
  87. <view class="confirm" @click="handlePopConfirm">确定</view>
  88. </view>
  89. <view class="poop_body">
  90. <view class="body_item" v-for="item in workArray" :key="item.id" @click="handleChangeWork(item)">
  91. <view class="body_item_info">
  92. {{ item.text }}
  93. </view>
  94. <view class="body_item_icon" v-if="defaultList.some((ele) => ele.text == item.text)">✔</view>
  95. </view>
  96. </view>
  97. </view>
  98. </uni-popup>
  99. </view>
  100. <!-- 排行榜区域 -->
  101. <view class="rank">
  102. <view class="rank_title">
  103. <img src="../../static/images/repairsImg/rank.png" />
  104. 工单完成排行榜
  105. </view>
  106. <!-- 排行榜柱状图 -->
  107. <view class="rank_charts">
  108. <!-- 加上canvas2d属性后 模拟器上图表显示异常,真机调试没有问题,开发时不添加canvas2d属性,发布时添加canvas2d属性 -->
  109. <qiun-data-charts canvas2d type="bar" :opts="opts" :chartData="chartData" />
  110. </view>
  111. </view>
  112. <!-- 悬浮按钮区域 -->
  113. <view class="fixed">
  114. <img src="../../static/images/repairsImg/add.png" @click="handleGoRepairs" />
  115. <uni-badge :offset="[5, 5]" absolute="rightTop" text="8">
  116. <img class="img" src="../../static/images/repairsImg/message.png" @click="handleGoMsg" />
  117. </uni-badge>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. export default {
  123. data() {
  124. return {
  125. // 按钮权限
  126. btns: [],
  127. // 是否值班弹窗默认选中数组
  128. defaultList: [],
  129. // 改变的是第几个索引
  130. changeIndex: 0,
  131. // 排班状态数组
  132. typeArray: ['接单中', '订单饱和', '停止接单'],
  133. // 值班状态数组
  134. workArray: [
  135. {
  136. id: 0,
  137. text: '正常班次'
  138. },
  139. {
  140. id: 1,
  141. text: '值班班次'
  142. }
  143. ],
  144. // 分段器数组数据
  145. items: ['团队数据统计', '个人数据统计'],
  146. // 分段器当前索引
  147. current: 0,
  148. // 柱状图数据
  149. chartData: {
  150. categories: ['张三', '李四', '王五', '老六', '刘八'],
  151. series: [
  152. {
  153. name: '好评数',
  154. data: [35, 36, 31, 33, 13]
  155. },
  156. {
  157. name: '完成数',
  158. data: [18, 27, 21, 24, 6]
  159. }
  160. ]
  161. },
  162. opts: {
  163. color: ['#1890FF', '#91CB74', '#FAC858', '#EE6666', '#73C0DE', '#3CA272', '#FC8452', '#9A60B4', '#ea7ccc'],
  164. padding: [15, 30, 0, 5],
  165. enableScroll: false,
  166. legend: {},
  167. xAxis: {
  168. boundaryGap: 'justify',
  169. disableGrid: false,
  170. gridType: 'dash',
  171. gridColor: '#E5E5E5',
  172. min: 0,
  173. axisLine: false,
  174. max: 40
  175. },
  176. yAxis: {},
  177. extra: {
  178. bar: {
  179. type: 'group',
  180. width: 15,
  181. meterBorde: 1,
  182. meterFillColor: '#FFFFFF',
  183. activeBgColor: '#000000',
  184. activeBgOpacity: 0.08,
  185. linearType: 'custom',
  186. barBorderCircle: true,
  187. seriesGap: 2,
  188. categoryGap: 2
  189. }
  190. }
  191. },
  192. // 表格数据
  193. // status状态: 0 接单中 1 订单饱和 2 停止接单
  194. // work状态: 0 正常班次 1 值班班次
  195. tableData: [
  196. {
  197. name: '张三',
  198. type: '电工',
  199. status: 0,
  200. work: [
  201. {
  202. id: 0,
  203. text: '正常班次'
  204. },
  205. {
  206. id: 1,
  207. text: '值班班次'
  208. }
  209. ]
  210. },
  211. {
  212. name: '张三三',
  213. type: '泥工',
  214. status: 1,
  215. work: [
  216. {
  217. id: 1,
  218. text: '值班班次'
  219. }
  220. ]
  221. },
  222. {
  223. name: '张三',
  224. type: '电工',
  225. status: 2,
  226. work: [
  227. {
  228. id: 0,
  229. text: '正常班次'
  230. }
  231. ]
  232. },
  233. {
  234. name: '张三三',
  235. type: '泥工',
  236. status: 0,
  237. work: [
  238. {
  239. id: 1,
  240. text: '值班班次'
  241. }
  242. ]
  243. },
  244. {
  245. name: '张三',
  246. type: '电工',
  247. status: 1,
  248. work: [
  249. {
  250. id: 0,
  251. text: '正常班次'
  252. }
  253. ]
  254. },
  255. {
  256. name: '张三三',
  257. type: '泥工',
  258. status: 2,
  259. work: [
  260. {
  261. id: 0,
  262. text: '正常班次'
  263. }
  264. ]
  265. }
  266. ]
  267. }
  268. },
  269. mounted() {
  270. console.log('主页页面加载')
  271. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  272. this.btns = repairsUserInfo.btns
  273. console.log(this.btns)
  274. },
  275. methods: {
  276. // 是否值班弹窗确定按钮回调
  277. handlePopConfirm() {
  278. uni.showModal({
  279. title: '提示',
  280. content: '确定修改是否值班状态吗?',
  281. success: (res) => {
  282. if (res.confirm) {
  283. this.tableData[this.changeIndex].work = this.defaultList
  284. console.log('用户点击确定')
  285. } else if (res.cancel) {
  286. console.log('用户点击取消')
  287. }
  288. }
  289. })
  290. this.$refs.popup_work.close()
  291. },
  292. // 点击值班状态回调
  293. handleChange(item, index) {
  294. if (this.btns.includes('表格编辑')) {
  295. this.$refs.popup_work.open('bottom')
  296. this.changeIndex = index
  297. this.defaultList = JSON.parse(JSON.stringify(item.work))
  298. }
  299. },
  300. // 切换值班状态回调
  301. handleChangeWork(item) {
  302. let temIndex
  303. let flag = this.defaultList.some((ele, index) => {
  304. if (ele.text == item.text) {
  305. temIndex = index
  306. }
  307. return ele.text == item.text
  308. })
  309. if (flag) {
  310. this.defaultList.splice(temIndex, 1)
  311. } else {
  312. this.defaultList.push(item)
  313. }
  314. // 修改数组的排序,id小的在前面
  315. this.defaultList.sort((a, b) => a.id - b.id)
  316. },
  317. // 切换接单状态回调
  318. bindPickerChange(e, item) {
  319. uni.showModal({
  320. title: '提示',
  321. content: '确定修改接单状态吗?',
  322. success: (res) => {
  323. if (res.confirm) {
  324. item.status = e.detail.value
  325. console.log('用户点击确定')
  326. } else if (res.cancel) {
  327. console.log('用户点击取消')
  328. }
  329. }
  330. })
  331. },
  332. // 点击悬浮消息按钮回调
  333. handleGoMsg() {
  334. uni.navigateTo({
  335. url: '/pagesRepairs/message/message'
  336. })
  337. },
  338. // 点击悬浮加号按钮回调
  339. handleGoRepairs() {
  340. uni.$emit('goToRepairs', {
  341. show: 'repairs',
  342. title: '报修'
  343. })
  344. },
  345. // 顶部分段器切换回调
  346. onClickItem(e) {
  347. if (this.current != e.currentIndex) {
  348. this.current = e.currentIndex
  349. console.log(this.current)
  350. }
  351. },
  352. // 把数组每一项的第一个文字切割出来
  353. getCutting(list) {
  354. let str = ''
  355. list.forEach((ele, index) => {
  356. if (index + 1 == list.length && list.length > 1) {
  357. str += '、' + ele.text.substring(0, 1)
  358. } else {
  359. str += ele.text.substring(0, 1)
  360. }
  361. })
  362. return str
  363. }
  364. }
  365. }
  366. </script>
  367. <style lang="scss" scoped>
  368. .container {
  369. width: 100vw;
  370. height: calc(100vh - 152rpx);
  371. font-size: 32rpx;
  372. overflow-y: auto;
  373. .top_bg {
  374. height: 165rpx;
  375. background-color: #6fb6b8;
  376. }
  377. .top_types {
  378. display: flex;
  379. justify-content: space-evenly;
  380. margin: auto;
  381. margin-top: -100rpx;
  382. width: 690rpx;
  383. height: 188rpx;
  384. border-radius: 10rpx;
  385. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  386. background-color: #fff;
  387. .types_box {
  388. flex: 1;
  389. display: flex;
  390. flex-direction: column;
  391. justify-content: center;
  392. align-items: center;
  393. .box_num {
  394. font-size: 46rpx;
  395. color: #ff5733;
  396. }
  397. .box_info {
  398. margin-top: 10rpx;
  399. font-size: 34rpx;
  400. }
  401. }
  402. }
  403. .top_types2 {
  404. box-sizing: border-box;
  405. margin: auto;
  406. margin-top: -100rpx;
  407. padding: 0 30rpx;
  408. width: 690rpx;
  409. height: 282rpx;
  410. border-radius: 10rpx;
  411. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  412. background-color: #fff;
  413. .top {
  414. height: 112rpx;
  415. border-bottom: 1rpx solid #e6e6e6;
  416. }
  417. .bottom {
  418. display: flex;
  419. justify-content: space-evenly;
  420. height: 170rpx;
  421. .bottom_box {
  422. flex: 1;
  423. display: flex;
  424. flex-direction: column;
  425. justify-content: center;
  426. align-items: center;
  427. .box_num {
  428. font-size: 46rpx;
  429. color: #ff5733;
  430. }
  431. .box_info {
  432. margin-top: 10rpx;
  433. font-size: 34rpx;
  434. }
  435. }
  436. }
  437. }
  438. .watch {
  439. box-sizing: border-box;
  440. margin: 20rpx auto;
  441. padding: 0 30rpx;
  442. width: 690rpx;
  443. border-radius: 10rpx;
  444. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  445. .watch_title {
  446. display: flex;
  447. align-items: center;
  448. height: 95rpx;
  449. font-size: 36rpx;
  450. border-bottom: 1rpx solid #e6e6e6;
  451. img {
  452. margin-right: 14rpx;
  453. width: 44rpx;
  454. height: 44rpx;
  455. }
  456. }
  457. .watch_color {
  458. color: #6fb6b8;
  459. }
  460. .watch_color2 {
  461. color: #1e7dfb;
  462. }
  463. .watch_color3 {
  464. color: #ff5733;
  465. }
  466. .watch_td {
  467. display: flex;
  468. }
  469. .watch_pop {
  470. width: 100%;
  471. height: 575rpx;
  472. overflow-y: auto;
  473. background-color: #fff;
  474. .poop_title {
  475. box-sizing: border-box;
  476. padding: 0 30rpx;
  477. display: flex;
  478. align-items: center;
  479. justify-content: space-between;
  480. height: 100rpx;
  481. font-size: 34rpx;
  482. border-bottom: 1rpx solid #f5f5f5;
  483. .cancel {
  484. color: #888888;
  485. }
  486. .confirm {
  487. color: #1e7dfb;
  488. }
  489. }
  490. .poop_body {
  491. margin-top: 50rpx;
  492. .body_item {
  493. position: relative;
  494. display: flex;
  495. justify-content: center;
  496. align-items: center;
  497. height: 100rpx;
  498. border-bottom: 1rpx solid #f5f5f5;
  499. .body_item_info {
  500. }
  501. .body_item_icon {
  502. position: absolute;
  503. top: 30rpx;
  504. right: 85rpx;
  505. color: #1e7dfb;
  506. }
  507. }
  508. }
  509. }
  510. }
  511. .rank {
  512. position: relative;
  513. box-sizing: border-box;
  514. margin: 0 auto 100rpx;
  515. padding: 0 30rpx;
  516. width: 690rpx;
  517. height: 745rpx;
  518. border-radius: 10rpx;
  519. box-shadow: 0px 0px 4rpx rgba(0, 0, 0, 0.25);
  520. .rank_title {
  521. display: flex;
  522. align-items: center;
  523. height: 95rpx;
  524. font-size: 36rpx;
  525. border-bottom: 1rpx solid #e6e6e6;
  526. img {
  527. margin-right: 14rpx;
  528. width: 41rpx;
  529. height: 41rpx;
  530. }
  531. }
  532. .rank_charts {
  533. position: absolute;
  534. bottom: 0;
  535. width: 100%;
  536. height: 650rpx;
  537. }
  538. }
  539. .fixed {
  540. z-index: 2;
  541. position: fixed;
  542. right: 0;
  543. bottom: 155rpx;
  544. display: flex;
  545. justify-content: space-evenly;
  546. align-items: center;
  547. width: 252rpx;
  548. height: 123rpx;
  549. border-radius: 150rpx 0 0 150rpx;
  550. box-shadow: 0px 0px 7rpx rgba(0, 0, 0, 0.15);
  551. background-color: #fff;
  552. img {
  553. width: 76rpx;
  554. height: 76rpx;
  555. }
  556. .img {
  557. width: 88rpx;
  558. height: 88rpx;
  559. }
  560. }
  561. }
  562. </style>