task.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view>
  3. <scroll-view scroll-x class="bg-white nav ">
  4. <cu-custom bgColor="bg-blue" :isBack="false">
  5. <block slot="backText">我的任务</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class=" flex justify-center">
  9. <button class="margin-top-ssm cu-btn round line-blue text-white" v-if="manage" @tap="manage = false">
  10. <text>取消多选</text>
  11. </button>
  12. <button @click="addTask()" v-else class="cu-btn round line-blue text-white" style="height: 66rpx;padding: 0 20rpx;"><text class="cuIcon-add"></text>新建任务</button>
  13. </view>
  14. </block>
  15. </cu-custom>
  16. <view class="nav_b">
  17. <view style="height:90rpx ;"></view>
  18. <view class="nav_b_1">
  19. <view :class="index==TabCur?'nav_one':'nav_1'" v-for="(item,index) in menuList" :key="index" @tap="tabSelect" :data-id="index">
  20. {{item.name}}
  21. <text v-if='index==0'>({{taskList.length}})</text>
  22. <text v-if='index==1'>({{taskInitiateList.length}})</text>
  23. <view :class="index==TabCur?'nav_zwf':''"></view>
  24. </view>
  25. </view>
  26. <!-- <view class="cu-item flex-sub" :class="index==TabCur?'text-blue':'text-no'" v-for="(item,index) in menuList" :key="index"
  27. @tap="tabSelect" :data-id="index">
  28. {{item.name}}
  29. <text v-if='index==0'>({{taskList.length}})</text>
  30. <text v-if='index==1'>({{taskInitiateList.length}})</text>
  31. <view :class="index==TabCur?'bottom_solid':''"></view>
  32. </view> -->
  33. </view>
  34. <view v-if="TabCur==0" @longtap="manage = true" class="cu-list menu-avatar list_b">
  35. <view class="cu-item_1" v-for="(item,index) in taskList" :key="item.id" @click="navToTaskDetails(item,0)">
  36. <view class="cu-item_left">
  37. <image v-if="item.task_category=='2'" src="../../static/task/report.png"></image>
  38. <image v-else-if="item.task_category=='3'|| item.task_category=='1'" src="../../static/task/audit.png"></image>
  39. <image v-else src="../../static/task/diy.png"></image>
  40. </view>
  41. <view :class="manage?'cu-item_right_sm':'cu-item_right'">
  42. <view class="cu-item_name">{{item.name}}</view>
  43. <view class="cu-item_start">
  44. <view class="cu-item_text"> 发起人:{{item.userName}}</view>
  45. <view class="cu-item_text">
  46. {{ item.start_date | timeStamp }}
  47. </view>
  48. </view>
  49. </view>
  50. <checkbox-group @change="CheckboxChange" @tap.stop :data-index="index" class="padding-left-sm">
  51. <checkbox class="sc75 blue" v-show="manage" :class="item.checked?'checked':''" :checked="item.checked?true:false"></checkbox>
  52. </checkbox-group>
  53. </view>
  54. <view v-if="taskList.length==0" class="bg-white text-center">
  55. <view>
  56. <image class="menuImageNoTask" src="../../static/task/noTask.png"></image>
  57. </view>
  58. <view style="padding:28rpx 0 132rpx;font-size: 26rpx;color: #8A8A8A;">暂时没有待办任务~</view>
  59. </view>
  60. <view v-if="taskList.length!=0" style="padding: 60rpx 0 160rpx;text-align: center;font-size: 26rpx;color: #AEAEAE;">没有更多内容了~</view>
  61. </view>
  62. <view v-else @longtap="manage = true" class="cu-list menu-avatar list_b">
  63. <view class="cu-item_1" v-for="(item,index) in taskInitiateList" :key="item.id" @click="navToTaskDetails(item,1)">
  64. <view class="cu-item_left">
  65. <image v-if="item.task_category=='2'" src="../../static/task/report.png"></image>
  66. <image v-else-if="item.task_category=='3' || item.task_category=='1'" src="../../static/task/audit.png"></image>
  67. <image v-else src="../../static/task/diy.png"></image>
  68. </view>
  69. <view :class="manage?'cu-item_right_sm':'cu-item_right'">
  70. <view class="cu-item_name">{{item.name}}</view>
  71. <view class="cu-item_start">
  72. <view v-if="item.task_status==0" class="cu-item_text"> 任务进度: 未完成</view>
  73. <view v-if="item.task_status==1" class="cu-item_text"> 任务进度: 已完成</view>
  74. <view v-if="item.task_status==-1" class="cu-item_text"> 任务进度: 审核未通过</view>
  75. <view v-if="item.task_status==2" class="cu-item_text"> 任务进度: 已废除</view>
  76. <view class="cu-item_text">{{ item.start_date | timeStamp }}</view>
  77. </view>
  78. </view>
  79. <checkbox-group @change="CheckboxChange" @tap.stop :data-index="index" class="padding-left-sm">
  80. <checkbox class="sc75 blue" v-show="manage" :class="item.checked?'checked':''" :checked="item.checked?true:false"></checkbox>
  81. </checkbox-group>
  82. </view>
  83. <view v-if="taskInitiateList.length==0" class="bg-white text-center">
  84. <view>
  85. <image class="menuImageNoTask" src="../../static/task/noTask.png"></image>
  86. </view>
  87. <view style="padding:28rpx 0 132rpx;font-size: 26rpx;color: #8A8A8A;">暂时没有发起任务~</view>
  88. </view>
  89. <view v-if="taskInitiateList.length!=0" style="padding: 60rpx 0 160rpx;text-align: center;font-size: 26rpx;color: #AEAEAE;">没有更多内容了~</view>
  90. </view>
  91. </scroll-view>
  92. <view class="botm padding bg-white flex justify-between" v-if="manage">
  93. <view>
  94. <checkbox-group @change="allChange">
  95. <checkbox class="sc75 blue" :class="isAll?'checked':''" :checked="isAll?true:false" value="all"></checkbox>
  96. <text class="padding-left-sm">全选</text>
  97. </checkbox-group>
  98. </view>
  99. <view>
  100. <button class="cu-btn round margin-right-sm bg-red" @tap="batchRepeal">批量废除</button>
  101. <button class="cu-btn round margin-right-sm" @tap="batchHandle">批量审批</button>
  102. <!-- <button class="cu-btn round bg-blue" ></button> -->
  103. </view>
  104. </view>
  105. <!-- 引入底部导航栏 -->
  106. <tabBar v-if="show" :pagePath="'/pages/task/task'"></tabBar>
  107. </view>
  108. </template>
  109. <script>
  110. export default {
  111. data() {
  112. return {
  113. menuList: [{
  114. name: '待办任务'
  115. }, {
  116. name: '我发起的'
  117. }],
  118. title: "待办任务",
  119. taskList: [],
  120. taskInitiateList: [],
  121. TabCur: 0,
  122. scrollLeft: 0,
  123. show:false,//用于待办任务的数据统计才显示组件
  124. manage:false,
  125. isAll:false,
  126. checkList:[],
  127. signType:{
  128. isOpenSign:0,//合同是否开启电签,0关闭,1开启
  129. isPfxFile:'',//是否有证书文件,1有
  130. isPhone:'',//绑定的手机号,没有则没绑定
  131. },
  132. }
  133. },
  134. onLoad() {
  135. },
  136. onShow() {
  137. this.findTask();
  138. this.findTaskMyMission();
  139. },
  140. methods: {
  141. navToTaskDetails(item, value) {
  142. var type;
  143. if (item.task_category == 2) {
  144. type = 2 //填报任务类型
  145. } else if (item.task_category == 3) {
  146. type = 3 //审核任务类型
  147. } else if (item.task_category == 1) {
  148. type = 1 //上报类型
  149. }else{
  150. type=4 //自定义
  151. }
  152. uni.navigateTo({
  153. url: "/pages/task/details/details?type=" + type + "&value=" + value + "&taskId=" + item.id+ "&contractid=" +item.contract_info_id
  154. })
  155. },
  156. tabSelect(e) {
  157. if(this.manage){
  158. this.$prompt.none("多选状态中,请勿切换");
  159. return;
  160. }
  161. this.TabCur = e.currentTarget.dataset.id;
  162. this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  163. },
  164. navTo(index) {
  165. if (index == 0) { //待办任务
  166. this.showValue = true;
  167. this.title = "待办任务";
  168. } else if (index == 1) { //发起任务
  169. this.showValue = false;
  170. this.title = "我发起的";
  171. } else if (index == 2) { //新建任务
  172. }
  173. },
  174. /* 查询待办任务 */
  175. findTask() {
  176. var that = this;
  177. var userInfo = uni.getStorageSync("userInfo");
  178. var project = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  179. that.http.request('/app/task/findTaskComing', {
  180. userId: userInfo.id,
  181. contractId: project.contractId,
  182. projectid: project.id
  183. }).then((result) => {
  184. that.taskList = result.datas;
  185. that.tabberData.taskNum = that.taskList.length;
  186. that.show=true;
  187. if (!that.taskList) {
  188. that.taskList = []
  189. }
  190. })
  191. },
  192. /* 查询我发起的任务 */
  193. findTaskMyMission() {
  194. var that = this;
  195. var userInfo = uni.getStorageSync("userInfo")
  196. var porject = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id);
  197. that.http.request('/app/task/findTaskMyMission', {
  198. userId: userInfo.id,
  199. contractId: porject.contractId,
  200. projectid: porject.id
  201. }).then((result) => {
  202. that.taskInitiateList = result.datas;
  203. if (!that.taskInitiateList) {
  204. that.taskInitiateList = []
  205. }
  206. })
  207. },
  208. addTask() {
  209. uni.navigateTo({
  210. url: "createTask/createTask"
  211. })
  212. },
  213. //全选
  214. allChange(e){
  215. let values = e.detail.value;
  216. if(values.length>0){
  217. this.isAll = true;
  218. }else{
  219. this.isAll = false;
  220. }
  221. let list = [];
  222. if(this.TabCur == 0){
  223. list = this.taskList;
  224. }else if(this.TabCur == 1){
  225. list = this.taskInitiateList;
  226. }
  227. list.forEach((item)=>{
  228. this.$set(item,'checked',this.isAll);
  229. })
  230. },
  231. //点击单选
  232. CheckboxChange(e){
  233. let values = e.detail.value;
  234. let list = [];
  235. if(this.TabCur == 0){
  236. list = this.taskList;
  237. }else if(this.TabCur == 1){
  238. list = this.taskInitiateList;
  239. }
  240. let item = list[e.currentTarget.dataset.index];
  241. // console.log(e)
  242. // console.log(item)
  243. if(values.length>0){
  244. this.$set(item,'checked',true);
  245. }else{
  246. this.$set(item,'checked',false);
  247. }
  248. },
  249. //批量处理
  250. batchHandle() {
  251. if (!this.checkBatch()) {
  252. return;
  253. }
  254. let formDataIds = [];
  255. let contractIdList = [];
  256. this.checkList.forEach((item)=>{
  257. formDataIds.push(item.id);
  258. contractIdList.push(item.contract_info_id);
  259. })
  260. uni.navigateTo({
  261. url:"/pages/task/approvalTasks/approvalTasks?formDataIds="+formDataIds.join(',')+"&contractIdList="+contractIdList.join(',')+"&task_flow="+this.checkList[0].task_flow
  262. })
  263. },
  264. checkBatch() {
  265. let list = [];
  266. if(this.TabCur == 0){
  267. list = this.taskList;
  268. }else if(this.TabCur == 1){
  269. list = this.taskInitiateList;
  270. }
  271. this.checkList = [];
  272. list.forEach((item)=>{
  273. if(item.checked){
  274. this.checkList.push(item);
  275. }
  276. })
  277. if (this.checkList.length < 1) {
  278. this.$prompt.none("请至少勾选一条任务");
  279. return false;
  280. };
  281. let type = this.checkList[0].type;
  282. let flow = this.checkList[0].task_flow;
  283. let isCustom = false;//是否自定义流程
  284. if (flow == 1) {
  285. isCustom = true;
  286. }
  287. let isAll = true;
  288. for (let i = 0; i < this.checkList.length; i++) {
  289. if (this.checkList[i].sign_status == 1) {
  290. this.$prompt.none("选择的第" + (i + 1) + "条任务电签中,请检查");
  291. isAll = false;
  292. break;
  293. }
  294. if (this.checkList[i].task_category == 2) {
  295. this.$prompt.none("选择的第" + (i + 1) + "条任务为填报任务,无法审批");
  296. isAll = false;
  297. break;
  298. }
  299. if (this.checkList[i].type != type) {
  300. this.$prompt.none("只能批量处理任务类型相同的任务!");
  301. isAll = false;
  302. break;
  303. } else if (this.checkList[i].task_status != 0) {
  304. this.$prompt.none("选择的第" + (i + 1) + "条任务状态不正确,请检查");
  305. isAll = false;
  306. break;
  307. }
  308. if (isCustom) {
  309. if (this.checkList[i].task_flow != 1) {
  310. this.$prompt.none("只能批量处理流程类型相同的任务!");
  311. isAll = false;
  312. break;
  313. }
  314. } else {
  315. if (this.checkList[i].task_flow == 1) {
  316. this.$prompt.none("只能批量处理流程类型相同的任务!");
  317. isAll = false;
  318. break;
  319. }
  320. }
  321. }
  322. if (isAll) {
  323. return true;
  324. } else {
  325. return false;
  326. }
  327. },
  328. //批量废除任务
  329. batchRepeal(){
  330. let { account } = uni.getStorageSync('userInfo')
  331. if (!this.checkBatchRepeal()) {
  332. return;
  333. }
  334. let ids = [];
  335. this.checkList.forEach((item)=>{
  336. ids.push(item.id);
  337. })
  338. this.http.request('/app/task/batchRepeal', {
  339. opUserName: account ? account : '',
  340. taskId:ids.join(','),
  341. processId:"",
  342. cs:0,
  343. }).then((result) => {
  344. this.$prompt.none("废除成功");
  345. this.manage = false;
  346. this.isAll = false;
  347. this.checkList = [];
  348. this.findTask();
  349. this.findTaskMyMission();
  350. })
  351. },
  352. checkBatchRepeal(){
  353. let list = [];
  354. if(this.TabCur == 0){
  355. list = this.taskList;
  356. }else if(this.TabCur == 1){
  357. list = this.taskInitiateList;
  358. }
  359. this.checkList = [];
  360. list.forEach((item)=>{
  361. if(item.checked){
  362. this.checkList.push(item);
  363. }
  364. })
  365. if (this.checkList.length < 1) {
  366. this.$prompt.none("请至少勾选一条任务");
  367. return false;
  368. };
  369. let isAll = true;
  370. for (let i = 0; i < this.checkList.length; i++) {
  371. if (this.checkList[i].task_status != 0) {
  372. this.$prompt.none("选择的第" + (i + 1) + "条任务状态已完成,无法废除");
  373. isAll = false;
  374. break;
  375. }
  376. }
  377. if (isAll) {
  378. return true;
  379. } else {
  380. return false;
  381. }
  382. }
  383. },
  384. filters: {
  385. timeStamp: function(value) {
  386. if (!value) return '';
  387. var now = new Date(value);
  388. var year = now.getFullYear();
  389. var month = now.getMonth() + 1;
  390. if (month < 10) {
  391. month = '0' + month
  392. }
  393. var date = now.getDate();
  394. if (date < 10) {
  395. date = '0' + date
  396. }
  397. return year + "-" + month + "-" + date
  398. },
  399. },
  400. onHide() {
  401. this.show=false
  402. }
  403. }
  404. </script>
  405. <style lang="scss">
  406. .nav_b{z-index: 5;background: #fff;position: fixed;left: 0;top:var(--status-bar-height);width: 750rpx; padding: 0 130rpx;}
  407. .nav_b_1{display: flex;align-items: center;justify-content: space-between;height: 100rpx;width: 490rpx;}
  408. .nav_one{font-size: 30rpx;color: #0A8CD5;font-weight: bold;position: relative;width: 170rpx;text-align: center;}
  409. .nav_1{font-size: 30rpx;color: #101010;font-weight: bold;width: 170rpx;text-align: center;}
  410. .nav_zwf{width: 170rpx;height: 4rpx;background-color: #0A8CD5;position: absolute;bottom: -24rpx;left: 0;border-radius: 20rpx;}
  411. .list_b{padding-top: 100rpx;}
  412. page {
  413. background-color: white;
  414. }
  415. .box {
  416. margin-top: -20rpx;
  417. }
  418. .box view.cu-bar {
  419. margin-top: 20upx;
  420. }
  421. .page {
  422. height: 100Vh;
  423. width: 100vw;
  424. }
  425. .page.show {
  426. overflow: hidden;
  427. }
  428. .menuImage {
  429. height: 90rpx;
  430. width: 90rpx;
  431. }
  432. .cu-list.grid>.cu-item uni-text {
  433. display: block;
  434. margin-top: 4px;
  435. color: black;
  436. font-size: 14px;
  437. line-height: 17px;
  438. }
  439. .margin-bottom-big {
  440. margin-bottom: 150rpx;
  441. }
  442. .text-blue {
  443. position: relative;
  444. font-size: 30rpx;
  445. color: #0A8CD5;
  446. }
  447. .text-no {
  448. font-size: 30rpx;
  449. color: #101010;
  450. }
  451. .bottom_solid {
  452. height: 4rpx;
  453. background-color: #0A8CD5;
  454. position: absolute;
  455. bottom: 0;
  456. left: 96rpx;
  457. right: 96rpx;
  458. }
  459. .cu-item_1{display: flex;align-items: center;padding: 22rpx 24rpx;border-bottom: 2rpx solid #E3e1e1;}
  460. .cu-item_left{margin-right: 10rpx;}
  461. .cu-item_left image{width: 100rpx;height: 100rpx;}
  462. .cu-item_right{width: 592rpx;}
  463. .cu-item_right_sm{width: 530rpx;}
  464. .cu-item_name{font-size: 30rpx;color: #101010;overflow: hidden;text-overflow: ellipsis; -o-text-overflow: ellipsis;white-space:nowrap;}
  465. .cu-item_start{display: flex;align-items: center;justify-content: space-between;padding-top: 8rpx;}
  466. .cu-item_text{color: #8A8A8A;font-size: 26rpx;}
  467. .menuImageNoTask{width:162rpx;height: 105rpx;margin-top: 60rpx;}
  468. .botm{
  469. position: fixed;
  470. left: 0;
  471. bottom: 100rpx;
  472. width: 100%;
  473. box-shadow: 2px 2px 10px;
  474. }
  475. .sc75{
  476. transform: scale(0.75, 0.75);
  477. }
  478. </style>