inform_details.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. console.log(val, 'valval');
  140. if (val.taskInfo) {
  141. that.options = val.taskInfo
  142. } else {
  143. that.options = val
  144. }
  145. that.formData.id = parseInt(that.options.id)
  146. that.contents = that.options.taskContent
  147. that.formData.broadId = parseInt(option.broadId)
  148. that.saveImplement.broadId = parseInt(option.broadId)
  149. that.tableData = []
  150. that.getData(that.formData.pageNo)
  151. })
  152. },
  153. methods: {
  154. descript() { //隐患描述点击确认
  155. this.show2 = false
  156. console.log(this.tableData, this.id, 'this.tableDataafafa');
  157. this.tableData.map(i => {
  158. if (this.id == i.id) {
  159. i.description = this.description
  160. }
  161. })
  162. },
  163. closeImage(val, k) { //删除图片
  164. this.tableData[k].attUrl.splice(val, 1)
  165. that.$forceUpdate();
  166. },
  167. goDetail() { //去详情
  168. uni.navigateTo({
  169. url: '/pagesA/fire/check_active/check_implement_detail/check_implement_detail',
  170. })
  171. },
  172. checkImplementConfirm() { //确认保存检查项
  173. this.shuJu()
  174. this.tableData.map(i => {
  175. if (i.isdenger == undefined) {
  176. this.show = true
  177. }
  178. }) //判断是否完成巡查
  179. //批量保存
  180. // console.log(this.show,'Confirmthis.show');
  181. if (!this.show) {
  182. saveCheckImplement(JSON.stringify(this.saveImplement)).then(response => {
  183. if (response.data) {
  184. uni.showToast({
  185. title: '保存成功',
  186. icon: 'none',
  187. duration: 2000
  188. })
  189. uni.navigateBack()
  190. } else {
  191. this.$modal.msgError('保存失败')
  192. }
  193. });
  194. }
  195. },
  196. checkImplementRelease() { //提交发布
  197. this.shuJu()
  198. this.tableData.map(i => {
  199. if (i.isdenger == undefined) {
  200. this.show = true
  201. }
  202. }) //判断是否完成巡查
  203. if (!this.show) {
  204. checkSubmitRelease(JSON.stringify(this.saveImplement)).then(response => {
  205. if (response.data) {
  206. uni.showToast({
  207. title: '提交成功',
  208. icon: 'none',
  209. duration: 2000
  210. })
  211. setTimeout(() => {
  212. uni.redirectTo({
  213. url: `/pagesA/fire/check_active/index?current=1`
  214. });
  215. }, 1000)
  216. } else {
  217. this.$modal.msgError('提交失败')
  218. }
  219. })
  220. }
  221. },
  222. shuJu() {
  223. // let inspectList = []
  224. // this.tableData.map(i => {
  225. // inspectList.push({
  226. // inspCode: i.insp_code
  227. // })
  228. // })
  229. // console.log('inspectList', inspectList);
  230. // this.saveImplement.inspectList = inspectList
  231. this.saveImplement.inspectList = this.tableData
  232. this.saveImplement.orgId = this.$store.state.user.orgId
  233. this.saveImplement.taskId = this.formData.id
  234. console.log(this.saveImplement, 'this.saveImplementthis.saveImplement');
  235. },
  236. // 获取数据
  237. getData(pageNo, value = '') {
  238. this.loading = true
  239. this.formData.pageNo = pageNo
  240. CheckActiveImplement(JSON.stringify(this.formData)).then(response => {
  241. this.total = response.data.total;
  242. this.loading = false;
  243. this.tableData = response.data
  244. this.tableData.map(i => {
  245. i.inspId = i.id,
  246. i.inspName = i.insp_name,
  247. i.inspCode = i.insp_code,
  248. i.isdenger = i.isdenger,
  249. i.isreport = 0,
  250. i.status = 0,
  251. i.attUrl = []
  252. })
  253. // console.log(this.tableData, 'this.tableData');
  254. });
  255. },
  256. // 触底的事件
  257. scrolltolower() {
  258. // 判断是否还有下一页数据
  259. if (this.formData.pageNo * this.formData.pageSize >= this.total) return uni.showToast({
  260. title: `数据加载完毕`
  261. })
  262. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  263. if (this.loading) return
  264. this.formData.pageNo += 1
  265. },
  266. //点击了隐患的勾选
  267. normal(val) {
  268. this.id = val.id
  269. this.tableData.map(i => {
  270. if (i.id == val.id) {
  271. i.isdenger = 0
  272. }
  273. })
  274. this.$forceUpdate();
  275. this.tableData.map(i => {
  276. if (this.id == i.id) {
  277. i.inspContent = this.contents
  278. }
  279. })
  280. console.log(this.tableData, 'this.tableData-----------');
  281. },
  282. //点击隐患
  283. yinHuan(val) {
  284. this.description = ''
  285. this.id = val.id
  286. this.tableData.map(i => {
  287. if (i.id == val.id) {
  288. i.isdenger = 1
  289. this.description = i.description ? i.description : ''
  290. i.description = this.description
  291. }
  292. })
  293. this.$forceUpdate();
  294. this.show2 = true
  295. },
  296. //扫码
  297. erWeiMa() {
  298. // 只允许从相机扫码
  299. uni.scanCode({
  300. onlyFromCamera: true,
  301. success: function(res) {
  302. console.log('条码类型:' + res.scanType);
  303. console.log('条码内容:**' + res.result);
  304. }
  305. })
  306. },
  307. //拍照上传
  308. photoUpload(val) {
  309. let pictures = [];
  310. let that = this;
  311. uni.chooseImage({
  312. sourceType: ['camera'], //实现拍照
  313. count: 3,
  314. sourceType: ['album'], //打开系统相册
  315. success(res) {
  316. if (Array.isArray(res.tempFilePaths)) { //从相册选择有三张的情况
  317. // if (res.tempFilePaths.length === 3) {
  318. // pictures.length = 0
  319. // } else if (res.tempFilePaths.length == 2 && pictures.length == 2) {
  320. // pictures.splice(0, 1)
  321. // }
  322. res.tempFilePaths.forEach(item => {
  323. loadImage(
  324. item,
  325. function(canvas) {
  326. canvas.toBlob(function(blob) {
  327. // 压缩后的 Blob 对象
  328. const compressedFile = blob;
  329. // 将压缩后的文件 `compressedFile` 转换为临时URL
  330. const fileUrl = URL.createObjectURL(
  331. compressedFile);
  332. // let picture = {
  333. // url: item,
  334. // show: false
  335. // }
  336. // pictures.push(picture)
  337. uni.uploadFile({
  338. url: baseUrl +
  339. '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址的接口
  340. filePath: item,
  341. name: 'file',
  342. header: {
  343. "Authorization": 'Bearer ' +
  344. getAccessToken(),
  345. }, //请求token
  346. success: (res) => {
  347. let imgUrl = JSON.parse(res
  348. .data)
  349. // that.imageList.push(imgUrl.data)
  350. that.tableData.map((i,
  351. index) => {
  352. if (val == i.id) {
  353. i.attUrl.push(
  354. imgUrl
  355. .data)
  356. }
  357. })
  358. console.log(that.tableData,
  359. 'this.imageList');
  360. that.$forceUpdate();
  361. // // 返回的url
  362. },
  363. fail: () => {
  364. console.log("err");
  365. }
  366. })
  367. // // 保存到本地
  368. // uni.saveImageToPhotosAlbum({
  369. // filePath: item,
  370. // })
  371. URL.revokeObjectURL(fileUrl);
  372. }, 'image/jpeg', 0.6); // 设置压缩后的图片格式为 JPEG,压缩质量为 0.6
  373. }, {
  374. canvas: true,
  375. maxWidth: 800
  376. } // 设置最大宽度为 800px
  377. );
  378. })
  379. }
  380. }
  381. })
  382. },
  383. // // 将拍的照片的base64转成文件格式然后再转成FormData,就可以使用上传图片的接口了
  384. // base64ToFile(base64){
  385. // const dataArr = base64.split(',');
  386. // const byteString = atob(dataArr[1]);
  387. // const options = {
  388. // type:'image/jpeg',
  389. // endings:'native'
  390. // };
  391. // const u8Arr = new Uint8Array(byteString.length)
  392. // for(let i=0;i<byteString.length;i++){
  393. // u8Arr[i]=byteString.charCodeAt(i);
  394. // }
  395. // return new File([u8Arr],'phone.png',options)
  396. // },
  397. //methode结束
  398. }
  399. }
  400. </script>
  401. <style lang="scss" scoped>
  402. page {
  403. background-color: rgb(245, 247, 249) !important;
  404. }
  405. .container {
  406. // height: 100vh;
  407. position: relative;
  408. background-color: rgb(245, 247, 249);
  409. }
  410. /deep/.uni-card {
  411. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  412. border-radius: 20rpx;
  413. }
  414. .tupian {
  415. width: 48rpx;
  416. height: 48rpx;
  417. }
  418. .text {
  419. text-align: center;
  420. color: #000;
  421. font-size: 26rpx;
  422. margin-top: 20rpx;
  423. }
  424. .titles {
  425. padding: 20rpx 0;
  426. color: #383838;
  427. }
  428. .grid-item-box {
  429. flex: 1;
  430. display: flex;
  431. flex-direction: column;
  432. align-items: center;
  433. justify-content: center;
  434. padding: 15px 0;
  435. }
  436. /deep/ .uni-grid-item {
  437. height: 140rpx !important;
  438. }
  439. /deep/.uni-textarea-textarea {
  440. border: 1px solid #4CB2B6;
  441. }
  442. .btnList {
  443. display: flex
  444. }
  445. /deep/.u-icon--right[data-v-172979f2],
  446. /deep/.u-icon--right.data-v-172979f2,
  447. /deep/.u-icon--right {
  448. background-color: #f8f8f8;
  449. border-radius: 5rpx;
  450. position: absolute;
  451. top: -14rpx;
  452. right: 20rpx;
  453. }
  454. .uni-grid-wraps {
  455. margin-left: 60rpx;
  456. }
  457. </style>