task.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <template>
  2. <view class="page">
  3. <!-- <view class="page-head">
  4. <view class="handle" @click="handleSubmit(1)">全部通过</view>
  5. <view class="handle" @click="handleSubmit(2)">全不通过</view>
  6. </view> -->
  7. <view class="wrap">
  8. <template v-if="itemList.length>0">
  9. <view class="checklist" v-for="(checklist,idx) in itemList" :key="idx">
  10. <view class="title more">{{checklist.itemTitle}}</view>
  11. <view class="item-cont" v-if="checklist.children&&checklist.children.length>0">
  12. <view class="checklistItem" v-for="(checklistItem,itemIdx) in checklist.children" :key="itemIdx">
  13. <view class="itemTitle more">{{checklistItem.itemTitle}}</view>
  14. <view class="point-cont" v-if="checklistItem.recordList&&checklistItem.recordList.length>0">
  15. <view class="point" v-for="(point,pointIdx) in checklistItem.recordList" :key="pointIdx" @click="check(point)">
  16. <view class="pointContent">{{point.pointContent}}</view>
  17. <view class="status" v-if="point.checkResult===1">【<span class="text">通过</span>】</view>
  18. <view class="status" v-if="point.checkResult===-1">【<span class="text">不通过</span>】</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="item-cont" v-if="checklist.recordList&&checklist.recordList.length>0">
  24. <view class="checklistItem" v-for="(checklistItem,itemIdx) in checklist.recordList" :key="itemIdx">
  25. <view class="point-cont">
  26. <view class="point" @click="check(checklistItem)">
  27. <view class="pointContent">{{checklistItem.pointContent}}</view>
  28. <view class="status" v-if="checklistItem.checkResult===1">【<span class="text">通过</span>】</view>
  29. <view class="status" v-if="checklistItem.checkResult===-1">【<span class="text">不通过</span>】</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="handle-container" v-if="handleVisiable">
  36. <view class="handle" @click="handleSubmit(1)">全部通过</view>
  37. <view class="handle" @click="handleSubmit(2)">全不通过</view>
  38. <view class="handle submit" @click="handleSubmit(3)" v-if="submit_bt_state">提交</view>
  39. <!-- <view class="handle danger" @click="handleSubmit('danger')">登记隐患</view> -->
  40. <view class="more" @mouseenter="hover(1)" @mouseleave="hover">
  41. <text class="text">更多</text>
  42. <view class="list" v-if="showMore">
  43. <view class="hand-item-box">
  44. <view class="handle-item" @click="handleSubmit(4)">撤销</view>
  45. <view class="handle-item" @click="handleSubmit(5)">转交</view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <template v-else>没有可处理的清单^-_-^</template>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. getchecklistRecord,
  58. checklistComplete,
  59. checklistCancel,
  60. checklistBatchUpdate,
  61. } from '@/api/aqpt/checklistPoint.js'
  62. import {cancelCheckTask,completeCheckTask} from '@/api/aqpt/task.js'
  63. export default {
  64. data() {
  65. return {
  66. defaultProps: {
  67. id: 'itemId',
  68. children: 'children',
  69. label: 'itemTitle'
  70. },
  71. danger_bt_state:false,
  72. submit_bt_state:false,
  73. accountInfo:{},
  74. divider: false,
  75. edit: true,
  76. itemList:[],
  77. recordId:undefined,
  78. checklistId:undefined,
  79. handleVisiable:false,
  80. type:undefined,
  81. status:undefined,
  82. taskTitle:"",
  83. showMore:false
  84. }
  85. },
  86. onLoad({rid,cid,title}) {
  87. this.checklistId=cid
  88. this.recordId=rid
  89. let accountInfo=uni.getStorageSync('accountInfo')
  90. this.accountInfo=accountInfo
  91. this.taskTitle=title
  92. this.getchecklistRecord(cid,rid)
  93. },
  94. methods: {
  95. getchecklistRecord(checklistId,recordId){
  96. getchecklistRecord(checklistId,recordId).then((res)=>{
  97. if(!res.data.itemList)return
  98. this.itemList=res.data.itemList
  99. this.status=res.data.status
  100. this.handleVisiable=(res.data.status===0||res.data.status===1)&&(res.data.accountId===this.accountInfo.userId)
  101. let items=[]
  102. for(let i=0;i<itemList.length;i++){
  103. if(itemList[i].children){
  104. itemList[i].children.map(child=>{
  105. child.recordList.map(pointitem=>{
  106. items.push(point)
  107. })
  108. })
  109. }else{
  110. itemList[i].recordList.map(pointitem=>{
  111. items.push(pointitem)
  112. })
  113. }
  114. }
  115. let index=items.findIndex(item=>item.checkResult===-1)
  116. let _index=items.findIndex(item=>item.checkResult===0)
  117. this.submit_bt_state=_index<0
  118. this.danger_bt_state=index>-1?true:false
  119. })
  120. },
  121. check(point){
  122. if(!this.handleVisiable) return
  123. uni.setStorageSync("point",point)
  124. uni.navigateTo({
  125. url:"/pages/index/handle/task/checkList/form/form"
  126. })
  127. },
  128. handleSubmit(type){
  129. let recordId=this.recordId;
  130. let checklistId=this.checklistId;
  131. const self=this;
  132. if(type===1){
  133. checklistBatchUpdate(recordId,1).then(()=>{
  134. this.getchecklistRecord(checklistId,recordId)
  135. })
  136. }
  137. if(type===2){
  138. checklistBatchUpdate(recordId,-1).then(()=>{
  139. this.getchecklistRecord(checklistId,recordId)
  140. })
  141. }
  142. if(type===3){//完成
  143. if(this.danger_bt_state){
  144. uni.showModal({
  145. title: '提示',
  146. content: '本次检查有未通过项,是否需要登记隐患?',
  147. success: function (res) {
  148. if (res.confirm) {
  149. self.submitDanger(recordId)
  150. } else if (res.cancel) {
  151. self.completeTask(recordId)
  152. }
  153. }
  154. });
  155. }else{
  156. this.completeTask(recordId)
  157. }
  158. }
  159. if(type===4){//放弃
  160. cancelCheckTask(recordId).then(()=>{
  161. uni.switchTab({
  162. url:'/pages/index/index'
  163. })
  164. }).catch(()=>{
  165. uni.showToast({
  166. icon:"none",
  167. title:"操作失败"
  168. })
  169. })
  170. }
  171. if(type===5){//转交
  172. let taskTitle=this.taskTitle;
  173. uni.navigateTo({
  174. url:`/pages/index/handle/task/checkList/form/transferCheckTask?tid=${recordId}&title=${taskTitle}`
  175. })
  176. }
  177. if(type==="danger"){
  178. this.submitDanger(recordId)
  179. }
  180. },
  181. completeTask(recordId){
  182. completeCheckTask(recordId).then(()=>{
  183. uni.reLaunch({
  184. url:'/pages/index/index'
  185. })
  186. }).catch(()=>{
  187. uni.reLaunch({
  188. url:`/pages/webview/webview?href=${href}&name=${name}`
  189. })
  190. uni.showToast({
  191. icon:"none",
  192. title:"操作失败"
  193. })
  194. })
  195. },
  196. submitDanger(recordId){
  197. let href=`${this.$h5}/danger/views/create.html`;
  198. let name= '登记隐患'
  199. uni.reLaunch({
  200. url:`/pages/webview/webview?href=${href}&name=${name}`
  201. })
  202. completeCheckTask(recordId)
  203. },
  204. hover(state){
  205. this.showMore=state===1
  206. }
  207. }
  208. }
  209. </script>
  210. <style lang="scss" scoped>
  211. .page{
  212. background-color: #F5F6F8;
  213. padding: 20rpx;
  214. min-height: 100vh;
  215. box-sizing: border-box;
  216. margin-bottom: 100rpx;
  217. .page-head{
  218. text-align: right;
  219. padding-bottom: 10rpx;
  220. .handle{
  221. display: inline-block;
  222. background-color: #3384FF;
  223. color: #fff;
  224. padding: 10rpx 15rpx;
  225. box-sizing: border-box;
  226. border-right: 1rpx solid #eaeaea;
  227. font-size: 30rpx;
  228. text-align: center;
  229. &:nth-child(4){
  230. border: 0;
  231. }
  232. }
  233. }
  234. }
  235. .wrap{
  236. padding: 20rpx;
  237. background-color: #fff;
  238. .checklist{
  239. .title{
  240. color: #222222;
  241. font-size: 32rpx;
  242. height: 98rpx;
  243. line-height: 98rpx;
  244. overflow: hidden;
  245. text-overflow: ellipsis;
  246. border-bottom: 1px dashed #E8E8E8;
  247. }
  248. .more{
  249. background-image: url('/static/tree_more.png');
  250. background-size: 30rpx 30rpx;
  251. padding-left: 40rpx;
  252. background-position: center left;
  253. background-repeat: no-repeat;
  254. }
  255. .item-cont{
  256. padding-left: 20rpx;
  257. border-bottom: 1px dashed #E8E8E8;
  258. .checklistItem{
  259. .itemTitle{
  260. color: #222222;
  261. font-size: 32rpx;
  262. height: 98rpx;
  263. line-height: 98rpx;
  264. }
  265. }
  266. .point-cont{
  267. padding-left: 30rpx;
  268. .point{
  269. display: flex;
  270. color: #666;
  271. font-size: 28rpx;
  272. height: 98rpx;
  273. line-height: 98rpx;
  274. .pointContent{
  275. flex: 1;
  276. }
  277. .status{
  278. .text{
  279. color: #3384FF;
  280. font-weight: 800;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. .handle-container{
  288. position: fixed;
  289. width: 100%;
  290. left: 0;
  291. bottom: 0;
  292. background-color: #fff;
  293. display: flex;
  294. justify-content: center;
  295. align-items: center;
  296. border-top: 1rpx solid #eaeaea;
  297. padding: 15rpx 0;
  298. .handle{
  299. display:inline-block;
  300. color: #222;
  301. padding: 15rpx 20rpx;
  302. box-sizing: border-box;
  303. border: 1rpx solid #eaeaea;
  304. font-size: 26rpx;
  305. text-align: center;
  306. border-radius: 50rpx;
  307. margin: 0 10rpx;
  308. &.danger{
  309. background-color: #FA5B41;
  310. color: #fff;
  311. }
  312. &.submit{
  313. background-color: #3384FF;
  314. color: #fff;
  315. }
  316. }
  317. .more{
  318. position: relative;
  319. padding: 15rpx 20rpx;
  320. .text:hover{
  321. &+.list>.hand-item-box{
  322. display: block;
  323. }
  324. }
  325. .list{
  326. position: absolute;
  327. bottom: 100rpx;
  328. right: 0;
  329. box-shadow: 0px 2px 12px 0px #0000001F;
  330. padding:0 20rpx;
  331. background-color: #fff;
  332. .hand-item-box{
  333. position: relative;
  334. display: none;
  335. &.show{
  336. display: block;
  337. }
  338. &::after{
  339. width: 0;
  340. height: 0;
  341. content: "";
  342. display: block;
  343. border-width: 26rpx 26rpx 0 0;
  344. border-color: #fff transparent;
  345. border-style: solid;
  346. position: absolute;
  347. bottom: -20rpx;
  348. right: -20rpx;
  349. }
  350. .handle-item{
  351. width: 180rpx;
  352. height: 50rpx;
  353. font-size: 26rpx;
  354. line-height: 50rpx;
  355. background-color: #fff;
  356. text-align: center;
  357. border-bottom: 1px solid #ccc;
  358. padding:10rpx 0;
  359. &:last-child{
  360. border: 0;
  361. }
  362. }
  363. }
  364. }
  365. }
  366. }
  367. }
  368. </style>