hazardRecord.vue 9.3 KB

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