inform_details.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. <!-- 消防巡检去完成2.28的代码信息 -->
  2. <template>
  3. <view>
  4. <view>
  5. <u-list @scrolltolower="scrolltolower" v-if="tableData.length!=0">
  6. <u-list-item @click="goDetail" v-for="(item, index) in tableData" :key="index">
  7. <view>
  8. <!-- <uni-card > -->
  9. <view class="titles">{{item.insp_name}}</view>
  10. <uni-grid :column="4" :showBorder="false">
  11. <uni-grid-item>
  12. <view class="grid-item-box">
  13. <image :src="item.isdenger==0?zhengchang:moren" class="tupian"
  14. @click="normal(item)">
  15. </image>
  16. <text class="text">正常</text>
  17. </view>
  18. </uni-grid-item>
  19. <uni-grid-item>
  20. <view class="grid-item-box">
  21. <image :src="item.isdenger==1?danger:moren" class="tupian" @click="yinHuan(item)">
  22. </image>
  23. <text class="text">存在隐患</text>
  24. </view>
  25. </uni-grid-item>
  26. <uni-grid-item>
  27. <view class="grid-item-box">
  28. <image :src="scan" class="tupian" @click="erWeiMa"></image>
  29. <text class="text">扫二维码</text>
  30. </view>
  31. </uni-grid-item>
  32. <uni-grid-item>
  33. <view class="grid-item-box" @click="photoUpload(item.id)">
  34. <image :src="photograph" class="tupian"></image>
  35. <text class="text">拍照上传</text>
  36. </view>
  37. </uni-grid-item>
  38. </uni-grid>
  39. <!-- 线 -->
  40. <!-- <view style="width: 80%;height: 2rpx;background-color: #f8f8f8;margin-left: 10%;"></view> -->
  41. <view class="uni-grid-wraps">
  42. <view style="position: relative;width: 180rpx;float: left;margin: 40rpx 15rpx 0 0rpx;"
  43. v-for="(items,indexs) in item.attUrl" :key="indexs">
  44. <image :src="items"
  45. style="width: 160rpx;height: 160rpx;border-radius: 30rpx;float: left;">
  46. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(indexs,index)">
  47. </u-icon>
  48. </view>
  49. <!-- </uni-card> -->
  50. </view>
  51. </view>
  52. </u-list-item>
  53. </u-list>
  54. </view>
  55. <view style="width: 60%;position: absolute;left:150rpx;;bottom:60rpx;z-index: 9999;">
  56. <div class="btnList" v-if="tableData.length!=0">
  57. <u-button shape="circle" type="primary" color="#4CB2B6" text="批量保存" customStyle="margin-right:20%"
  58. @click="checkImplementConfirm">
  59. </u-button>
  60. <u-button shape="circle" type="primary" color="#4CB2B6" text="提交发布" @click="checkImplementRelease">
  61. </u-button>
  62. </div>
  63. </view>
  64. <view style="text-align: center;" v-if="tableData.length==0">
  65. <view class="text-gray" style="padding-top: 20px;font-size: 40rpx;"> 暂无任务 </view>
  66. </view>
  67. <u-modal :show="show" :title="title" :content='content' @confirm="show = false"></u-modal>
  68. <u-modal :show="show2" title="隐患描述" @confirm="descript" @cancel="show2 = false">
  69. <view class="slot-content">
  70. <textarea v-model="description" placeholder="请输入描述内容" />
  71. </view>
  72. </u-modal>
  73. </view>
  74. </template>
  75. <script>
  76. let that = null
  77. import {
  78. CheckActiveImplement, //每日巡查扫码界面
  79. saveCheckImplement, //保存检查项
  80. checkSubmitRelease //提交发布检查下
  81. } from "@/api/check_active";
  82. // import danger from '@/static/images/checkActive/danger.png'
  83. import {
  84. getAccessToken
  85. } from '@/utils/auth'
  86. import config from '@/config'
  87. import store from "@/store"
  88. import loadImage from 'blueimp-load-image';
  89. const baseUrl = config.baseUrl
  90. const baseUrlImg = config.baseUrlImg
  91. export default {
  92. data() {
  93. return {
  94. // danger: danger, //有隐患图片
  95. moren: `${baseUrlImg}/checkActive/moren.png`, //默认图片
  96. zhengchang: `${baseUrlImg}/checkActive/zhengchang.png`,
  97. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  98. scan: `${baseUrlImg}/checkActive/scan.png`,
  99. tableData: [],
  100. // 每页数据量
  101. // 当前页
  102. // 数据总量
  103. total: 0,
  104. loading: false,
  105. formData: {
  106. id: 0,
  107. pageNo: 1,
  108. pageSize: 10,
  109. status: 0,
  110. taskStatus: 1,
  111. broadId: 0,
  112. },
  113. saveImplement: {
  114. inspectList: [],
  115. inspectTime: "", //传的当前事件
  116. orgId: 0,
  117. taskId: 0, //待完成列表所点击的id
  118. broadId: 0,
  119. },
  120. isZhengChang: false, //是否正常
  121. isYinHuan: false, //是否隐患
  122. show: false, //未巡查提示框
  123. show2: false, //隐患描述提示框
  124. title: '注意',
  125. content: '巡查未完成',
  126. contents: '',
  127. description: '', //隐患描述内容
  128. id: '',
  129. FinalTime: '',
  130. options: ''
  131. }
  132. },
  133. // 在 vue页面,向起始页通过事件传递数据
  134. onLoad: function(option) {
  135. that = this;
  136. const eventChannel = this.getOpenerEventChannel();
  137. eventChannel.on('acceptDataFromOpenerPage', function(val) {
  138. // that.formData = val
  139. if (val.taskInfo) {
  140. that.options = val.taskInfo
  141. } else {
  142. that.options = val
  143. }
  144. that.formData.id = parseInt(that.options.id)
  145. that.contents = that.options.taskContent
  146. that.formData.broadId = parseInt(option.broadId)
  147. that.saveImplement.broadId = parseInt(option.broadId)
  148. that.tableData = []
  149. that.getData(that.formData.pageNo)
  150. })
  151. },
  152. methods: {
  153. descript() { //隐患描述点击确认
  154. this.show2 = false
  155. this.tableData.map(i => {
  156. if (this.id == i.id) {
  157. i.description = this.description
  158. }
  159. })
  160. },
  161. closeImage(val, k) { //删除图片
  162. this.tableData[k].attUrl.splice(val, 1)
  163. that.$forceUpdate();
  164. },
  165. goDetail() { //去详情
  166. uni.navigateTo({
  167. url: '/pagesA/fire/check_active/check_implement_detail/check_implement_detail',
  168. })
  169. },
  170. checkImplementConfirm() { //确认保存检查项
  171. this.shuJu()
  172. this.tableData.map(i => {
  173. if (i.isdenger == undefined) {
  174. this.show = true
  175. }
  176. }) //判断是否完成巡查
  177. //批量保存
  178. // console.log(this.show,'Confirmthis.show');
  179. if (!this.show) {
  180. saveCheckImplement(JSON.stringify(this.saveImplement)).then(response => {
  181. if (response.data) {
  182. uni.showToast({
  183. title: '保存成功',
  184. icon: 'none',
  185. duration: 2000
  186. })
  187. uni.navigateBack()
  188. } else {
  189. this.$modal.msgError('保存失败')
  190. }
  191. });
  192. }
  193. },
  194. checkImplementRelease() { //提交发布
  195. this.shuJu()
  196. this.tableData.map(i => {
  197. if (i.isdenger == undefined) {
  198. this.show = true
  199. }
  200. }) //判断是否完成巡查
  201. if (!this.show) {
  202. checkSubmitRelease(JSON.stringify(this.saveImplement)).then(response => {
  203. if (response.data) {
  204. uni.showToast({
  205. title: '提交成功',
  206. icon: 'none',
  207. duration: 2000
  208. })
  209. setTimeout(() => {
  210. uni.redirectTo({
  211. url: `/pagesA/fire/check_active/index?current=1`
  212. });
  213. }, 1000)
  214. } else {
  215. this.$modal.msgError('提交失败')
  216. }
  217. })
  218. }
  219. },
  220. shuJu() {
  221. // let inspectList = []
  222. // this.tableData.map(i => {
  223. // inspectList.push({
  224. // inspCode: i.insp_code
  225. // })
  226. // })
  227. // console.log('inspectList', inspectList);
  228. // this.saveImplement.inspectList = inspectList
  229. this.saveImplement.inspectList = this.tableData
  230. this.saveImplement.orgId = this.$store.state.user.orgId
  231. this.saveImplement.taskId = this.formData.id
  232. },
  233. // 获取数据
  234. getData(pageNo, value = '') {
  235. this.loading = true
  236. this.formData.pageNo = pageNo
  237. CheckActiveImplement(JSON.stringify(this.formData)).then(response => {
  238. this.total = response.data.total;
  239. this.loading = false;
  240. this.tableData = response.data
  241. this.tableData.map(i => {
  242. i.inspId = i.id,
  243. i.inspName = i.insp_name,
  244. i.inspCode = i.insp_code,
  245. i.isdenger = i.isdenger,
  246. i.isreport = 0,
  247. i.status = 0,
  248. i.attUrl = []
  249. })
  250. // console.log(this.tableData, 'this.tableData');
  251. });
  252. },
  253. // 触底的事件
  254. scrolltolower() {
  255. // 判断是否还有下一页数据
  256. if (this.formData.pageNo * this.formData.pageSize >= this.total) return uni.showToast({
  257. title: `数据加载完毕`
  258. })
  259. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  260. if (this.loading) return
  261. this.formData.pageNo += 1
  262. },
  263. //点击了隐患的勾选
  264. normal(val) {
  265. this.id = val.id
  266. this.tableData.map(i => {
  267. if (i.id == val.id) {
  268. i.isdenger = 0
  269. }
  270. })
  271. this.$forceUpdate();
  272. this.tableData.map(i => {
  273. if (this.id == i.id) {
  274. i.inspContent = this.contents
  275. }
  276. })
  277. },
  278. //点击隐患
  279. yinHuan(val) {
  280. this.description = ''
  281. this.id = val.id
  282. this.tableData.map(i => {
  283. if (i.id == val.id) {
  284. i.isdenger = 1
  285. this.description = i.description ? i.description : ''
  286. i.description = this.description
  287. }
  288. })
  289. this.$forceUpdate();
  290. this.show2 = true
  291. },
  292. //扫码
  293. erWeiMa() {
  294. // 只允许从相机扫码
  295. uni.scanCode({
  296. onlyFromCamera: true,
  297. success: function(res) {
  298. }
  299. })
  300. },
  301. //拍照上传
  302. photoUpload(val) {
  303. let pictures = [];
  304. let that = this;
  305. uni.chooseImage({
  306. sourceType: ['camera'], //实现拍照
  307. count: 3,
  308. sourceType: ['album'], //打开系统相册
  309. success(res) {
  310. if (Array.isArray(res.tempFilePaths)) { //从相册选择有三张的情况
  311. // if (res.tempFilePaths.length === 3) {
  312. // pictures.length = 0
  313. // } else if (res.tempFilePaths.length == 2 && pictures.length == 2) {
  314. // pictures.splice(0, 1)
  315. // }
  316. res.tempFilePaths.forEach(item => {
  317. loadImage(
  318. item,
  319. function(canvas) {
  320. canvas.toBlob(function(blob) {
  321. // 压缩后的 Blob 对象
  322. const compressedFile = blob;
  323. // 将压缩后的文件 `compressedFile` 转换为临时URL
  324. const fileUrl = URL.createObjectURL(
  325. compressedFile);
  326. // let picture = {
  327. // url: item,
  328. // show: false
  329. // }
  330. // pictures.push(picture)
  331. uni.uploadFile({
  332. url: baseUrl +
  333. '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址的接口
  334. filePath: item,
  335. name: 'file',
  336. header: {
  337. "Authorization": 'Bearer ' +
  338. getAccessToken(),
  339. }, //请求token
  340. success: (res) => {
  341. let imgUrl = JSON.parse(res
  342. .data)
  343. // that.imageList.push(imgUrl.data)
  344. that.tableData.map((i,
  345. index) => {
  346. if (val == i.id) {
  347. i.attUrl.push(
  348. imgUrl
  349. .data)
  350. }
  351. })
  352. that.$forceUpdate();
  353. // // 返回的url
  354. },
  355. fail: () => {
  356. }
  357. })
  358. // // 保存到本地
  359. // uni.saveImageToPhotosAlbum({
  360. // filePath: item,
  361. // })
  362. URL.revokeObjectURL(fileUrl);
  363. }, 'image/jpeg', 0.6); // 设置压缩后的图片格式为 JPEG,压缩质量为 0.6
  364. }, {
  365. canvas: true,
  366. maxWidth: 800
  367. } // 设置最大宽度为 800px
  368. );
  369. })
  370. }
  371. }
  372. })
  373. },
  374. // // 将拍的照片的base64转成文件格式然后再转成FormData,就可以使用上传图片的接口了
  375. // base64ToFile(base64){
  376. // const dataArr = base64.split(',');
  377. // const byteString = atob(dataArr[1]);
  378. // const options = {
  379. // type:'image/jpeg',
  380. // endings:'native'
  381. // };
  382. // const u8Arr = new Uint8Array(byteString.length)
  383. // for(let i=0;i<byteString.length;i++){
  384. // u8Arr[i]=byteString.charCodeAt(i);
  385. // }
  386. // return new File([u8Arr],'phone.png',options)
  387. // },
  388. //methode结束
  389. }
  390. }
  391. </script>
  392. <style lang="scss" scoped>
  393. page {
  394. background-color: rgb(245, 247, 249) !important;
  395. }
  396. .container {
  397. // height: 100vh;
  398. position: relative;
  399. background-color: rgb(245, 247, 249);
  400. }
  401. /deep/.uni-card {
  402. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  403. border-radius: 20rpx;
  404. }
  405. .tupian {
  406. width: 48rpx;
  407. height: 48rpx;
  408. }
  409. .text {
  410. text-align: center;
  411. color: #000;
  412. font-size: 26rpx;
  413. margin-top: 20rpx;
  414. }
  415. .titles {
  416. padding: 20rpx 0;
  417. color: #383838;
  418. }
  419. .grid-item-box {
  420. flex: 1;
  421. display: flex;
  422. flex-direction: column;
  423. align-items: center;
  424. justify-content: center;
  425. padding: 15px 0;
  426. }
  427. /deep/ .uni-grid-item {
  428. height: 140rpx !important;
  429. }
  430. /deep/.uni-textarea-textarea {
  431. border: 1px solid #4CB2B6;
  432. }
  433. .btnList {
  434. display: flex
  435. }
  436. /deep/.u-icon--right[data-v-172979f2],
  437. /deep/.u-icon--right.data-v-172979f2,
  438. /deep/.u-icon--right {
  439. background-color: #f8f8f8;
  440. border-radius: 5rpx;
  441. position: absolute;
  442. top: -14rpx;
  443. right: 20rpx;
  444. }
  445. .uni-grid-wraps {
  446. margin-left: 60rpx;
  447. margin-bottom: 480rpx !important;
  448. }
  449. </style>