workbench.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  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="start()"></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. sprocessForm: {
  180. filterText: ''
  181. },
  182. tablePage: {
  183. pages: 0,
  184. currentPage: 0,
  185. pageSize: 10,
  186. orders: [{ column: "a.create_time", asc: false }],
  187. },
  188. loading: false,
  189. cardCur: 0,
  190. dataList: [],
  191. categoryList: [],
  192. processMap: new Map(),
  193. swiperList: [/*{
  194. id: 0,
  195. type: 'image',
  196. url: '/static/swiper/1.svg'
  197. }, {
  198. id: 1,
  199. type: 'image',
  200. url: '/static/swiper/2.svg'
  201. }, {
  202. id: 2,
  203. type: 'image',
  204. url: '/static/swiper/3.svg'
  205. }, {
  206. id: 3,
  207. type: 'image',
  208. url: '/static/swiper/4.svg'
  209. }, {
  210. id: 4,
  211. type: 'image',
  212. url: '/static/swiper/5.svg'
  213. }, {
  214. id: 5,
  215. type: 'image',
  216. url: '/static/swiper/6.svg'
  217. }, {
  218. id: 6,
  219. type: 'image',
  220. url: '/static/swiper/7.svg'
  221. }*/],
  222. dotStyle: false,
  223. towerStart: 0,
  224. direction: ''
  225. };
  226. },
  227. onLoad() {
  228. console.log('onLoad')
  229. this.loadmore()
  230. },
  231. computed:{
  232. ...mapState({
  233. username: (state) => state.user.username,
  234. userInfo: (state) => state.user.userInfo,
  235. userId: (state) => state.user.id
  236. }),
  237. dynamicStyle() {
  238. // 增加空值检查
  239. if (!this.userInfo || !this.userInfo.roleNames) {
  240. // 如果 userInfo 或 roleNames 不存在,返回一个默认样式
  241. return {
  242. height: '130px',
  243. borderRadius: '15px',
  244. backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
  245. };
  246. }
  247. // 直接通过 this.userInfo 访问 userInfo 中的属性
  248. // 如果 userInfo 存在,继续执行原来的逻辑
  249. const roleNames = this.userInfo.roleNames;
  250. // 根据从 Vuex 获取的状态来判断样式
  251. switch (roleNames) {
  252. case '过磅专员':
  253. return {
  254. height: '130px',
  255. borderRadius: '15px',
  256. backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
  257. };
  258. case '村负责人':
  259. return {
  260. height: '130px',
  261. borderRadius: '15px',
  262. backgroundImage: 'linear-gradient(to right, #0285f7 0%, #19b3bd 100%)'
  263. };
  264. case '巡视员':
  265. case '镇巡视员':
  266. return {
  267. height: '130px',
  268. borderRadius: '15px',
  269. backgroundImage: 'linear-gradient(to right, #fd8e03 0%, #f02d1f 100%)'
  270. };
  271. default:
  272. return {
  273. height: '130px',
  274. borderRadius: '15px',
  275. backgroundImage: 'linear-gradient(to right, #3cb54b 0%, #88c546 100%)'
  276. };
  277. }
  278. },
  279. },
  280. async mounted() {
  281. this.loadmore()
  282. //获取当前人对应的负责流程的信息
  283. this.fetchUserInfo(); // 模拟获取用户信息
  284. /*let res = await actCategoryService.treeData()
  285. let data = await processService.list({current: 1, size: -1})
  286. this.processMap = new Map()
  287. res.forEach((item)=>{
  288. this.processMap.set(item.name, [])
  289. })
  290. let list = data.records
  291. list.forEach((item)=>{
  292. if(this.processMap.has(item.category)){
  293. let list = this.processMap.get(item.category)
  294. list.push(item)
  295. }else{
  296. this.processMap.set(item.category, [item])
  297. }
  298. })
  299. for(let [key,value] of this.processMap){
  300. console.log(key,value);
  301. }*/
  302. },
  303. created() {
  304. if(!this.username) {
  305. this.refreshUserInfo()
  306. }
  307. },
  308. methods: {
  309. async fetchUserInfo() {
  310. try {
  311. // 这里调用获取数据的 API 或者 Vuex action
  312. await this.$store.dispatch('fetchUserInfo'); // 示例
  313. this.isLoading = false; // 数据加载完成,关闭加载状态
  314. } catch (error) {
  315. console.error('获取用户信息失败:', error);
  316. this.isLoading = false; // 即使加载失败也需要关闭加载状态
  317. }
  318. },
  319. tabSelect(index) {
  320. this.tabIndex = index;
  321. },
  322. openPatrolWorkOrderForm () {
  323. uni.navigateTo({
  324. url: '/pages/edt/PatrolWorkOrderForm',
  325. //url: '/pages/test/mobile/TestMobileForm',
  326. success: function(res) {
  327. // 跳转成功后的处理
  328. console.log('跳转成功');
  329. },
  330. fail: function(err) {
  331. // 跳转失败后的处理
  332. console.log('跳转失败', err);
  333. },
  334. complete: function() {
  335. // 无论跳转成功还是失败都会执行
  336. console.log('跳转完成');
  337. }
  338. })
  339. },
  340. // 跳转到详细页面
  341. todo (row) {
  342. taskService.getTaskDef({
  343. taskId: row.task.id,
  344. taskName: row.task.name,
  345. taskDefKey: row.task.taskDefinitionKey,
  346. procInsId: row.task.processInstanceId,
  347. procDefId: row.task.processDefinitionId,
  348. procDefKey: row.task.processDefKey,
  349. status: row.status
  350. }).then((data) => {
  351. let query = {formTitle: `${row.vars.title}`, title: `审批【${row.task.name || ''}】`, ...pick(data, 'formType', 'formReadOnly', 'formUrl', 'procDefKey', 'taskDefKey', 'procInsId', 'procDefId', 'taskId', 'status', 'title', 'businessId')};
  352. uni.navigateTo({
  353. url: '/pages/workbench/task/TaskForm?flow='+JSON.stringify(query)
  354. })
  355. })
  356. },
  357. // 输入监听
  358. inputWord(e){
  359. this.searchTimer && clearTimeout(this.searchTimer)
  360. this.searchTimer = setTimeout(()=>{
  361. this.doSearch()
  362. },300)
  363. },
  364. // 搜索
  365. doSearch(){
  366. this.dataList = [];
  367. this.tablePage.currentPage = 0;
  368. this.tablePage.pageSize = 10;
  369. this.tablePage.pages = 0;
  370. this.loadmore()
  371. },
  372. onReachBottom() {
  373. this.loadmore()
  374. },
  375. loadmore() {
  376. if(this.tablePage.currentPage!==0 && this.tablePage.pages <= this.tablePage.currentPage ) {
  377. this.status = 'nomore';
  378. return;
  379. }
  380. this.tablePage.currentPage = ++ this.tablePage.currentPage;
  381. //联网加载数据
  382. this.status = 'loading';
  383. taskService.todoList({
  384. current: this.tablePage.currentPage,
  385. size: this.tablePage.pageSize,
  386. orders: this.tablePage.orders,
  387. ...this.searchForm
  388. }).then((data)=>{
  389. //追加新数据
  390. this.dataList=this.dataList.concat(data.records);
  391. this.tablePage.pages = data.pages;
  392. if(this.tablePage.pages <= this.tablePage.currentPage){
  393. this.status = 'nomore'
  394. } else {
  395. this.status = 'loadmore'
  396. }
  397. })
  398. notifyService.getUnreadCountByIsSelf({
  399. isSelf: true,
  400. ...this.searchForm
  401. }).then((data)=>{
  402. EventBus.$emit('dataFromMessage', data); // 触发事件,传递参数
  403. })
  404. },
  405. ...mapActions(['refreshUserInfo']),
  406. toApplyList (mail) {
  407. uni.navigateTo({
  408. url: '/pages/workbench/task/ApplyList'
  409. })
  410. },
  411. toTodoList (mail) {
  412. uni.navigateTo({
  413. url: '/pages/workbench/task/TodoList'
  414. })
  415. },
  416. toHistoryList (mail) {
  417. uni.navigateTo({
  418. url: '/pages/workbench/task/HistoryList'
  419. })
  420. },
  421. toFlowCopyList (mail) {
  422. uni.navigateTo({
  423. url: '/pages/workbench/task/FlowCopyList'
  424. })
  425. },
  426. async start () {
  427. var row = null;
  428. //根据当前人的权限获取对应的流程信息
  429. const roleNames = this.userInfo.roleNames;
  430. // 根据从 Vuex 获取的状态来判断样式
  431. switch (roleNames) {
  432. case '村负责人':
  433. this.sprocessForm.filterText = '垃圾处理流程'
  434. //根据用户id查询流程id
  435. await taskService.getProcessDefIdByRoleName({
  436. filter: "processes",
  437. modelType: 0,
  438. ...this.sprocessForm,
  439. }).then((data) => {
  440. row = data.records[0].procDef
  441. });
  442. break;
  443. }
  444. // 读取流程表单
  445. taskService.getTaskDef({
  446. procDefId: row.id,
  447. status: 'start'
  448. }).then((data) => {
  449. console.log(data)
  450. let processTitle = `${this.username} 在 ${moment(new Date()).format('YYYY-MM-DD HH:mm')} 发起了 [${row.name}]`
  451. let query = {procDefId: row.id, procDefKey: row.key, status: 'start', title: `发起流程【${row.name}】`, formType: data.formType, formUrl: data.formUrl, formTitle: processTitle}
  452. uni.navigateTo({
  453. url: '/pages/workbench/task/TaskForm?flow='+JSON.stringify(query)
  454. })
  455. })
  456. }
  457. }
  458. }
  459. </script>
  460. <style>
  461. .cu-list.card-menu {
  462. overflow: hidden;
  463. margin-right: 5px;
  464. margin-left: 5px;
  465. border-radius: 7px;
  466. }
  467. .cu-list.card-menu.margin-top-20 {
  468. margin-top: -20px;
  469. }
  470. .cu-list.menu>.cu-item .content>uni-view:first-child {
  471. display: -webkit-box;
  472. display: -webkit-flex;
  473. display: flex;
  474. -webkit-box-align: center;
  475. /* -webkit-align-items: center; */
  476. /* align-items: center; */
  477. display: inline-block;
  478. margin-right: 5px;
  479. width: 1.6em;
  480. text-align: center;
  481. }
  482. .font-size-35{
  483. font-size: 35px!important;
  484. }
  485. .circle-button{
  486. width: 44px;
  487. height: 44px;
  488. border-radius: 18px;
  489. padding-top: 4px;
  490. }
  491. .circle-button-box{
  492. width: 25%;
  493. margin-top: 10px;
  494. display: -webkit-box;
  495. display: -webkit-flex;
  496. display: flex;
  497. -webkit-box-orient: vertical;
  498. -webkit-box-direction: normal;
  499. -webkit-flex-direction: column;
  500. flex-direction: column;
  501. -webkit-box-align: center;
  502. -webkit-align-items: center;
  503. align-items: center;
  504. -webkit-box-pack: center;
  505. -webkit-justify-content: center;
  506. justify-content: center;
  507. box-sizing: border-box;
  508. }
  509. .font-b {
  510. vertical-align: middle;
  511. font-size: 18px;
  512. font-weight: 500;
  513. color: #3a3a3a;
  514. }
  515. </style>