workbench.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="container">
  3. <!-- 顶部自定义导航栏 -->
  4. <cu-custom bgColor="bg-blue">
  5. <block slot="content"> 工作台</block>
  6. </cu-custom>
  7. <!-- 信息区域 -->
  8. <view class="col-1 no-border fixed" style="margin:5px 10px 5px 10px;">
  9. <view :style="dynamicStyle">
  10. <view class="col-1 no-border fixed" style="padding:20px 40px 20px 40px;">
  11. <!-- 个人信息 -->
  12. <view class="ellipsis-description" style="font-size: 16px">
  13. <span style="padding:5px;display: inline-block; width: 80px">
  14. <span style="font-weight: bold">{{userInfo.roleNames}}</span>
  15. </span>
  16. <span style="padding-left: 30px;display: inline-block;">
  17. <span class="cuIcon-locationfill" style="color: #FFFFFF;margin-right: 5px;"></span>
  18. <span style="color: #FFFFFF;font-weight: bold">{{userInfo.officeDTO.name}}</span>
  19. </span>
  20. </view>
  21. <view class="ellipsis-description" style="font-size: 16px">
  22. <span style="padding:5px;display: inline-block; width: 80px">
  23. <span style="color: #FFFFFF;font-weight: bold">姓名</span>
  24. </span>
  25. <span style="padding-left: 30px;display: inline-block;">
  26. <span style="color: #FFFFFF;font-weight: bold">{{userInfo.name}}</span>
  27. </span>
  28. </view>
  29. <view class="ellipsis-description" style="font-size: 16px">
  30. <span style="padding:5px;display: inline-block; width: 80px">
  31. <span style="color: #FFFFFF;font-weight: bold">联系方式</span>
  32. </span>
  33. <span style="padding-left: 30px;display: inline-block;">
  34. <span style="color: #FFFFFF;font-weight: bold">{{userInfo.mobile}}</span>
  35. </span>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <!-- 功能按钮区域 -->
  41. <view class="cu-list grid col-4 no-border fixed">
  42. <view @tap="toTodoList" class="circle-button-box">
  43. <view class="cuIcon-time text-blue circle-button font-size-35"></view>
  44. <text>待办事项</text>
  45. </view>
  46. <view @tap="toHistoryList" class="circle-button-box">
  47. <view class="cuIcon-roundcheck text-blue circle-button font-size-35"></view>
  48. <text>已办事项</text>
  49. </view>
  50. <view @tap="toApplyList" class="circle-button-box">
  51. <view class="cuIcon-peoplelist text-blue circle-button font-size-35"></view>
  52. <text>我发起的</text>
  53. </view>
  54. <view @tap="toFlowCopyList" class="circle-button-box">
  55. <view class="cuIcon-copy text-blue circle-button font-size-35"></view>
  56. <text>抄送给我</text>
  57. </view>
  58. </view>
  59. <!-- 标签切换区域 -->
  60. <view>
  61. <u-subsection
  62. :list="['待处理', '已处理']"
  63. mode="button"
  64. :fontSize="16"
  65. :current="tabIndex"
  66. @change="tabSelect"
  67. ></u-subsection>
  68. </view>
  69. <!-- 过磅记录 -->
  70. <view style="margin: 11px 28px;">
  71. <view class="ellipsis-description" style="font-size: 20px">
  72. <span style="margin-right: 10px;">
  73. <span class="cuIcon-title" style="color: #f67e1f;margin-right: 5px;"></span>
  74. <span v-if="userInfo.roleNames == '过磅专员' " style="font-weight: bold">过磅记录</span>
  75. <span v-if="userInfo.roleNames == '村负责人' " style="font-weight: bold">清运记录</span>
  76. <span v-if="userInfo.roleNames == '巡视员' " style="font-weight: bold">垃圾巡视</span>
  77. </span>
  78. </view>
  79. </view>
  80. <!-- 可滚动内容区域 -->
  81. <scroll-view scroll-y class="page">
  82. <!-- 其他可滚动内容 -->
  83. <u-swipe-action>
  84. <view v-for="(row, index) in dataList" :key="index">
  85. <u-swipe-action-item @click="todo(row)" :key="row.id" :threshold="60" duration="500"
  86. :options="[{ text: '办理', style: { backgroundColor: '#3c9cff' } }]">
  87. <u-cell-group>
  88. <u-cell @click="todo(row)">
  89. <view slot="title" class="content" style="line-height: 1.5;">
  90. <view class="text-bold text-grey">
  91. <view class="ellipsis-description" style="font-size: 16px">
  92. <span style="margin-right: 10px;">
  93. <span class="cuIcon-timefill" style="color: #3c9cff;margin-right: 5px;"></span>
  94. <span>08-20</span>
  95. </span>
  96. <span style="margin-right: 10px;">
  97. <span class="cuIcon-locationfill" style="color: #f67e1f;margin-right: 5px;"></span>
  98. <span>前进村</span>
  99. </span>
  100. </view>
  101. </view>
  102. <view class="text-grey text-sm" style="font-size: 16px">
  103. <div style="margin-right: 20px; float: left">
  104. <u-tag-small text="进行中" plain shape="circle" type="error"></u-tag-small>
  105. </div>
  106. <div style="margin-right: 10px; float: left">
  107. <span class="cuIcon-deliver" style="color: #d95141;margin-right: 5px;"></span>
  108. <span>12.5km</span>
  109. </div>
  110. <div style="margin-right: 10px;">
  111. <span class="cuIcon-deletefill" style="color: #38b64b;margin-right: 5px;"></span>
  112. <span>2.2t</span>
  113. </div>
  114. </view>
  115. </view>
  116. <view slot="right-icon" class="action">
  117. <u-tag text="处理" plain bgColor="#38b64b" color="white" plainFill shape="circle" type="success" @click="todo(row)"></u-tag>
  118. </view>
  119. </u-cell>
  120. </u-cell-group>
  121. </u-swipe-action-item>
  122. </view>
  123. </u-swipe-action>
  124. <!-- 加载更多 -->
  125. <u-loadmore :status="status" @loadmore="loadmore" :line="true" />
  126. <u-back-top :scrollTop="0" mode="square"></u-back-top>
  127. </scroll-view>
  128. <!-- 页脚区域 -->
  129. <view class="footer-div">
  130. <u-button v-if="userInfo.roleNames == '巡视员' " type="primary" text="巡视工单" @click="openPatrolWorkOrderForm()"></u-button>
  131. <u-button v-if="userInfo.roleNames == '村负责人' " type="primary" text="清运工单" @click="openPatrolWorkOrderForm()"></u-button>
  132. </view>
  133. </view>
  134. </template>
  135. <style scoped>
  136. .container {
  137. display: flex;
  138. flex-direction: column;
  139. height: 100vh;
  140. position: relative; /* 为 footer-div 提供定位上下文 */
  141. }
  142. .page {
  143. flex: 1;
  144. padding-bottom: 130px; /* 留出空间给 footer-div 和额外的 20px 间距 */
  145. overflow-y: auto;
  146. }
  147. .footer-div {
  148. height: 50px; /* 页脚高度 */
  149. text-align: center;
  150. line-height: 50px; /* 垂直居中内容 */
  151. position: fixed; /* 固定在视口底部 */
  152. bottom: 70px; /* 距离底部 100px */
  153. left: 0;
  154. width: 100%;
  155. }
  156. </style>
  157. <script>
  158. import userSelect from '@/components/user-select/user-select.vue'
  159. import pick from 'lodash.pick'
  160. import moment from 'moment'
  161. import {mapState, mapMutations, mapActions} from 'vuex'
  162. import actCategoryService from "@/api/flowable/actCategoryService"
  163. import processService from "@/api/flowable/processService"
  164. import taskService from "@/api/flowable/taskService"
  165. import notifyService from "@/api/notify/notifyService";
  166. import userService from "@/api/sys/userService"
  167. import { EventBus } from '@/store/eventBus.js';
  168. export default {
  169. components:{
  170. userSelect
  171. },
  172. data() {
  173. return {
  174. tabIndex: 0,
  175. status: 'loadmore',
  176. searchForm: {
  177. title: ''
  178. },
  179. tablePage: {
  180. pages: 0,
  181. currentPage: 0,
  182. pageSize: 10,
  183. orders: [{ column: "a.create_time", asc: false }],
  184. },
  185. loading: false,
  186. cardCur: 0,
  187. dataList: [],
  188. categoryList: [],
  189. processMap: new Map(),
  190. swiperList: [/*{
  191. id: 0,
  192. type: 'image',
  193. url: '/static/swiper/1.svg'
  194. }, {
  195. id: 1,
  196. type: 'image',
  197. url: '/static/swiper/2.svg'
  198. }, {
  199. id: 2,
  200. type: 'image',
  201. url: '/static/swiper/3.svg'
  202. }, {
  203. id: 3,
  204. type: 'image',
  205. url: '/static/swiper/4.svg'
  206. }, {
  207. id: 4,
  208. type: 'image',
  209. url: '/static/swiper/5.svg'
  210. }, {
  211. id: 5,
  212. type: 'image',
  213. url: '/static/swiper/6.svg'
  214. }, {
  215. id: 6,
  216. type: 'image',
  217. url: '/static/swiper/7.svg'
  218. }*/],
  219. dotStyle: false,
  220. towerStart: 0,
  221. direction: ''
  222. };
  223. },
  224. onLoad() {
  225. console.log('onLoad')
  226. this.loadmore()
  227. },
  228. computed:{
  229. ...mapState({
  230. username: (state) => state.user.username,
  231. userInfo: (state) => state.user.userInfo,
  232. userId: (state) => state.user.id
  233. }),
  234. dynamicStyle() {
  235. // 增加空值检查
  236. if (!this.userInfo || !this.userInfo.roleNames) {
  237. // 如果 userInfo 或 roleNames 不存在,返回一个默认样式
  238. return {
  239. height: '130px',
  240. borderRadius: '15px',
  241. backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
  242. };
  243. }
  244. // 直接通过 this.userInfo 访问 userInfo 中的属性
  245. // 如果 userInfo 存在,继续执行原来的逻辑
  246. const roleNames = this.userInfo.roleNames;
  247. // 根据从 Vuex 获取的状态来判断样式
  248. switch (roleNames) {
  249. case '过磅专员':
  250. return {
  251. height: '130px',
  252. borderRadius: '15px',
  253. backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
  254. };
  255. case '村负责人':
  256. return {
  257. height: '130px',
  258. borderRadius: '15px',
  259. backgroundImage: 'linear-gradient(to right, #0285f7 0%, #19b3bd 100%)'
  260. };
  261. case '巡视员':
  262. case '镇巡视员':
  263. return {
  264. height: '130px',
  265. borderRadius: '15px',
  266. backgroundImage: 'linear-gradient(to right, #fd8e03 0%, #f02d1f 100%)'
  267. };
  268. default:
  269. return {
  270. height: '130px',
  271. borderRadius: '15px',
  272. backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
  273. };
  274. }
  275. },
  276. },
  277. async mounted() {
  278. this.loadmore()
  279. //获取当前人对应的负责流程的信息
  280. this.fetchUserInfo(); // 模拟获取用户信息
  281. /*let res = await actCategoryService.treeData()
  282. let data = await processService.list({current: 1, size: -1})
  283. this.processMap = new Map()
  284. res.forEach((item)=>{
  285. this.processMap.set(item.name, [])
  286. })
  287. let list = data.records
  288. list.forEach((item)=>{
  289. if(this.processMap.has(item.category)){
  290. let list = this.processMap.get(item.category)
  291. list.push(item)
  292. }else{
  293. this.processMap.set(item.category, [item])
  294. }
  295. })
  296. for(let [key,value] of this.processMap){
  297. console.log(key,value);
  298. }*/
  299. },
  300. created() {
  301. if(!this.username) {
  302. this.refreshUserInfo()
  303. }
  304. },
  305. methods: {
  306. async fetchUserInfo() {
  307. try {
  308. // 这里调用获取数据的 API 或者 Vuex action
  309. await this.$store.dispatch('fetchUserInfo'); // 示例
  310. this.isLoading = false; // 数据加载完成,关闭加载状态
  311. } catch (error) {
  312. console.error('获取用户信息失败:', error);
  313. this.isLoading = false; // 即使加载失败也需要关闭加载状态
  314. }
  315. },
  316. tabSelect(index) {
  317. this.tabIndex = index;
  318. },
  319. openPatrolWorkOrderForm () {
  320. uni.navigateTo({
  321. url: '/pages/edt/PatrolWorkOrderForm',
  322. //url: '/pages/test/mobile/TestMobileForm',
  323. success: function(res) {
  324. // 跳转成功后的处理
  325. console.log('跳转成功');
  326. },
  327. fail: function(err) {
  328. // 跳转失败后的处理
  329. console.log('跳转失败', err);
  330. },
  331. complete: function() {
  332. // 无论跳转成功还是失败都会执行
  333. console.log('跳转完成');
  334. }
  335. })
  336. },
  337. // 跳转到详细页面
  338. todo (row) {
  339. taskService.getTaskDef({
  340. taskId: row.task.id,
  341. taskName: row.task.name,
  342. taskDefKey: row.task.taskDefinitionKey,
  343. procInsId: row.task.processInstanceId,
  344. procDefId: row.task.processDefinitionId,
  345. procDefKey: row.task.processDefKey,
  346. status: row.status
  347. }).then((data) => {
  348. let query = {formTitle: `${row.vars.title}`, title: `审批【${row.task.name || ''}】`, ...pick(data, 'formType', 'formReadOnly', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId')};
  349. uni.navigateTo({
  350. url: '/pages/workbench/task/TaskForm?flow='+JSON.stringify(query)
  351. })
  352. })
  353. },
  354. // 输入监听
  355. inputWord(e){
  356. this.searchTimer && clearTimeout(this.searchTimer)
  357. this.searchTimer = setTimeout(()=>{
  358. this.doSearch()
  359. },300)
  360. },
  361. // 搜索
  362. doSearch(){
  363. this.dataList = [];
  364. this.tablePage.currentPage = 0;
  365. this.tablePage.pageSize = 10;
  366. this.tablePage.pages = 0;
  367. this.loadmore()
  368. },
  369. onReachBottom() {
  370. this.loadmore()
  371. },
  372. loadmore() {
  373. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  374. this.status = 'nomore';
  375. return;
  376. }
  377. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  378. //联网加载数据
  379. this.status = 'loading';
  380. taskService.todoList({
  381. current: this.tablePage.currentPage,
  382. size: this.tablePage.pageSize,
  383. orders: this.tablePage.orders,
  384. ...this.searchForm
  385. }).then((data)=>{
  386. //追加新数据
  387. this.dataList=this.dataList.concat(data.records);
  388. this.tablePage.pages = data.pages;
  389. if(this.tablePage.pages <= this.tablePage.currentPage){
  390. this.status = 'nomore'
  391. } else {
  392. this.status = 'loadmore'
  393. }
  394. })
  395. notifyService.getUnreadCountByIsSelf({
  396. isSelf: true,
  397. ...this.searchForm
  398. }).then((data)=>{
  399. EventBus.$emit('dataFromMessage', data); // 触发事件,传递参数
  400. })
  401. },
  402. ...mapActions(['refreshUserInfo']),
  403. toApplyList (mail) {
  404. uni.navigateTo({
  405. url: '/pages/workbench/task/ApplyList'
  406. })
  407. },
  408. toTodoList (mail) {
  409. uni.navigateTo({
  410. url: '/pages/workbench/task/TodoList'
  411. })
  412. },
  413. toHistoryList (mail) {
  414. uni.navigateTo({
  415. url: '/pages/workbench/task/HistoryList'
  416. })
  417. },
  418. toFlowCopyList (mail) {
  419. uni.navigateTo({
  420. url: '/pages/workbench/task/FlowCopyList'
  421. })
  422. },
  423. start (row) {
  424. // 读取流程表单
  425. taskService.getTaskDef({
  426. procDefId: row.id,
  427. status: 'start'
  428. }).then((data) => {
  429. let processTitle = `${this.username} 在 ${moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [${row.name}]`
  430. let query = {procDefId: row.id, procDefKey: row.key, status: 'start', title: `发起流程【${row.name}】`, formType: data.formType, formUrl: data.formUrl, formTitle: processTitle}
  431. uni.navigateTo({
  432. url: '/pages/workbench/task/TaskForm?flow='+JSON.stringify(query)
  433. })
  434. })
  435. }
  436. }
  437. }
  438. </script>
  439. <style>
  440. .cu-list.card-menu {
  441. overflow: hidden;
  442. margin-right: 5px;
  443. margin-left: 5px;
  444. border-radius: 7px;
  445. }
  446. .cu-list.card-menu.margin-top-20 {
  447. margin-top: -20px;
  448. }
  449. .cu-list.menu>.cu-item .content>uni-view:first-child {
  450. display: -webkit-box;
  451. display: -webkit-flex;
  452. display: flex;
  453. -webkit-box-align: center;
  454. /* -webkit-align-items: center; */
  455. /* align-items: center; */
  456. display: inline-block;
  457. margin-right: 5px;
  458. width: 1.6em;
  459. text-align: center;
  460. }
  461. .font-size-35{
  462. font-size: 35px!important;
  463. }
  464. .circle-button{
  465. width: 44px;
  466. height: 44px;
  467. border-radius: 18px;
  468. padding-top: 4px;
  469. }
  470. .circle-button-box{
  471. width: 25%;
  472. margin-top: 10px;
  473. display: -webkit-box;
  474. display: -webkit-flex;
  475. display: flex;
  476. -webkit-box-orient: vertical;
  477. -webkit-box-direction: normal;
  478. -webkit-flex-direction: column;
  479. flex-direction: column;
  480. -webkit-box-align: center;
  481. -webkit-align-items: center;
  482. align-items: center;
  483. -webkit-box-pack: center;
  484. -webkit-justify-content: center;
  485. justify-content: center;
  486. box-sizing: border-box;
  487. }
  488. .font-b {
  489. vertical-align: middle;
  490. font-size: 18px;
  491. font-weight: 500;
  492. color: #3a3a3a;
  493. }
  494. </style>