hazardRecord.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  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.reLaunch({
  176. url:`/pages/webview/webview?href=${href}&name=${name}`
  177. })
  178. }).catch(()=>{
  179. uni.reLaunch({
  180. url:`/pages/webview/webview?href=${href}&name=${name}`
  181. })
  182. uni.showToast({
  183. icon:"none",
  184. title:"操作失败"
  185. })
  186. })
  187. }
  188. },
  189. completeTask(recordId){
  190. completeCheckTask(recordId).then(()=>{
  191. uni.reLaunch({
  192. url:'/pages/index/index'
  193. })
  194. }).catch(()=>{
  195. uni.showToast({
  196. icon:"none",
  197. title:"操作失败"
  198. })
  199. })
  200. },
  201. submitDanger(recordId){
  202. let href=`${this.$h5}/danger/views/create.html`;
  203. let name= '登记隐患'
  204. uni.reLaunch({
  205. url:`/pages/webview/webview?href=${href}&name=${name}`
  206. })
  207. completeCheckTask(recordId)
  208. },
  209. hover(state){
  210. this.showMore=state===1
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. .page{
  217. background-color: #F5F6F8;
  218. padding: 20rpx;
  219. min-height: 100vh;
  220. box-sizing: border-box;
  221. margin-bottom: 100rpx;
  222. .page-head{
  223. text-align: right;
  224. padding-bottom: 10rpx;
  225. .handle{
  226. display: inline-block;
  227. background-color: #3384FF;
  228. color: #fff;
  229. padding: 10rpx 15rpx;
  230. box-sizing: border-box;
  231. border-right: 1rpx solid #eaeaea;
  232. font-size: 30rpx;
  233. text-align: center;
  234. &:nth-child(4){
  235. border: 0;
  236. }
  237. }
  238. }
  239. }
  240. .wrap{
  241. padding: 20rpx;
  242. background-color: #fff;
  243. .checklist{
  244. .title{
  245. color: #222222;
  246. font-size: 32rpx;
  247. height: 98rpx;
  248. line-height: 98rpx;
  249. overflow: hidden;
  250. text-overflow: ellipsis;
  251. border-bottom: 1px dashed #E8E8E8;
  252. }
  253. .more{
  254. background-image: url('/static/tree_more.png');
  255. background-size: 30rpx 30rpx;
  256. padding-left: 40rpx;
  257. background-position: center left;
  258. background-repeat: no-repeat;
  259. }
  260. .item-cont{
  261. padding-left: 20rpx;
  262. border-bottom: 1px dashed #E8E8E8;
  263. .checklistItem{
  264. .itemTitle{
  265. color: #222222;
  266. font-size: 32rpx;
  267. height: 98rpx;
  268. line-height: 98rpx;
  269. }
  270. }
  271. .point-cont{
  272. padding-left: 30rpx;
  273. .point{
  274. display: flex;
  275. color: #666;
  276. font-size: 28rpx;
  277. // height: 98rpx;
  278. // line-height: 98rpx;
  279. .pointContent{
  280. flex: 1;
  281. }
  282. .status{
  283. .text{
  284. color: #3384FF;
  285. font-weight: 800;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. .handle-container{
  293. position: fixed;
  294. width: 100%;
  295. left: 0;
  296. bottom: 0;
  297. background-color: #fff;
  298. display: flex;
  299. justify-content: center;
  300. align-items: center;
  301. border-top: 1rpx solid #eaeaea;
  302. padding: 15rpx 0;
  303. .handle{
  304. display:inline-block;
  305. color: #222;
  306. padding: 15rpx 20rpx;
  307. box-sizing: border-box;
  308. border: 1rpx solid #eaeaea;
  309. font-size: 26rpx;
  310. text-align: center;
  311. border-radius: 50rpx;
  312. margin: 0 10rpx;
  313. &.danger{
  314. background-color: #FA5B41;
  315. color: #fff;
  316. }
  317. &.submit{
  318. background-color: #3384FF;
  319. color: #fff;
  320. padding: 18rpx 38rpx;
  321. }
  322. }
  323. .more{
  324. position: relative;
  325. padding: 15rpx 20rpx;
  326. .text:hover{
  327. &+.list>.hand-item-box{
  328. display: block;
  329. }
  330. }
  331. .list{
  332. position: absolute;
  333. bottom: 100rpx;
  334. right: 0;
  335. box-shadow: 0px 2px 12px 0px #0000001F;
  336. padding:0 20rpx;
  337. background-color: #fff;
  338. .hand-item-box{
  339. position: relative;
  340. display: none;
  341. &.show{
  342. display: block;
  343. }
  344. &::after{
  345. width: 0;
  346. height: 0;
  347. content: "";
  348. display: block;
  349. border-width: 26rpx 26rpx 0 0;
  350. border-color: #fff transparent;
  351. border-style: solid;
  352. position: absolute;
  353. bottom: -20rpx;
  354. right: -20rpx;
  355. }
  356. .handle-item{
  357. width: 180rpx;
  358. height: 50rpx;
  359. font-size: 26rpx;
  360. line-height: 50rpx;
  361. background-color: #fff;
  362. text-align: center;
  363. border-bottom: 1px solid #ccc;
  364. padding:10rpx 0;
  365. &:last-child{
  366. border: 0;
  367. }
  368. }
  369. }
  370. }
  371. }
  372. }
  373. }
  374. </style>