check_implement.vue 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106
  1. <template>
  2. <view>
  3. <view>
  4. <!-- 数据类型为消防设备 --比如一个灭火器 -->
  5. <u-list @scrolltolower="scrolltolower" v-if="!getqrcode">
  6. <u-list-item @click="goDetail" v-for="(item, index) in tableData" :key="index">
  7. <view>
  8. <view class="titles">{{item.inspName}}:{{item.inspContent}}</view>
  9. <!-- 消防设备 -->
  10. <view v-if="item.inspType=='fpd'">
  11. <view style="display: flex;flex-direction: column;margin-left: 40rpx;">
  12. <image :src="scan" class="tupian" @click="erWeiMa(item.id,index)"
  13. style="margin-left: 25rpx;"></image>
  14. <view style="margin-top: 20rpx;">扫二维码</view>
  15. <!-- <view>扫码结果 :{{qrcodeResault}}</view> -->
  16. </view>
  17. <!-- #ifdef H5 -->
  18. <view class="qrcode" v-if="item.qrcodeShow">
  19. <qrcode-stream @decode="onDecode" />
  20. </view>
  21. <!-- #endif -->
  22. </view>
  23. <!-- 数据类型不为消防设备 -->
  24. <uni-grid :column="3" :showBorder="false" v-else>
  25. <!-- <view v-if="item.inspType!='fpd'"> -->
  26. <uni-grid-item v-for="(items,indexs) in item.inspectResultList" :key="indexs">
  27. <!-- 不是消防设施 -->
  28. <view class="grid-item-box">
  29. <image :src="items.subValue==1?zhengchang:moren" class="tupian"
  30. @click="normal(items,indexs,index,item)">
  31. </image>
  32. <text class="text">{{items.subLable}}</text>
  33. </view>
  34. <!-- 是消防设施,点击事件只是弹框 -->
  35. <!-- <view class="grid-item-box" v-else>
  36. <image :src="items.subValue==1?zhengchang:hidden" class="tupian" @click="noNormal">
  37. </image>
  38. <text class="text">{{items.subLable}}</text>
  39. </view> -->
  40. </uni-grid-item>
  41. <!-- </view> -->
  42. <uni-grid-item>
  43. <view class="grid-item-box" @click="photoUpload(item)">
  44. <image :src="photograph" class="tupian"></image>
  45. <text class="text">拍照上传</text>
  46. </view>
  47. </uni-grid-item>
  48. </uni-grid>
  49. <!-- 线 -->
  50. <!-- <view style="width: 80%;height: 2rpx;background-color: #f8f8f8;margin-left: 10%;"></view> -->
  51. <!-- v-if="item.attUrl!=[] -->
  52. <view class="uni-grid-wrap" v-if="item.attUrl.length!=0">
  53. <view style="color: #8C8C8C;">设备图片</view>
  54. <view style="position: relative;width: 180rpx;float: left;margin: 40rpx;"
  55. v-for="(items,indexs) in item.attUrl" :key="indexs">
  56. <image :src="items"
  57. style="width: 160rpx;height: 160rpx;border-radius: 30rpx;float: left;">
  58. </image>
  59. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(item,indexs,index)">
  60. </u-icon>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="slot-contents" v-if="item.showDescription&&item.inspType!='fpd'"
  65. @click="descript(index)">
  66. <textarea v-model="item.description" placeholder="请输入隐患描述内容"></textarea>
  67. </view>
  68. <!-- <u-modal :show="show2" title="隐患描述" @confirm="descript(index)" @cancel="show2 = false">
  69. <view class="slot-content">
  70. <textarea v-model="description" placeholder="请输入描述内容" />
  71. </view>
  72. </u-modal> -->
  73. <!-- 扫码点击确定后每个设备的信息push到了新的数组里,显示在扫一扫下方的数据-->
  74. <view v-for="(items, indexs) in item.hisFpdCreateReqVOList" :key="indexs" class="child"
  75. style="background-color: aliceblue;">
  76. <view>
  77. <view class="child-new">
  78. <view class="child-new-item">
  79. <u-avatar shape="square" size="80" :src="items.attUrl[0]"
  80. customStyle="margin: -3px 5px -3px 20rpx"></u-avatar>
  81. </view>
  82. <view style="flex:1">
  83. <view>
  84. <view style="margin:40rpx 0 0 40rpx;">设备序列号:{{items.fpdCode}}
  85. </view>
  86. </view>
  87. <view class="child-result">
  88. <uni-grid :column="3" :showBorder="false">
  89. <uni-grid-item v-for="(items2,indexs2) in items.inspectResultList"
  90. :key="indexs2">
  91. <!-- 是消防设施,点击事件只是弹框 -->
  92. <view class="grid-item-box">
  93. <image :src="items2.subValue==1?zhengchang:hidden" class="tupian2"
  94. @click="noNormal">
  95. </image>
  96. <text class="text2">{{items2.subLable}}</text>
  97. </view>
  98. </uni-grid-item>
  99. </uni-grid>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- popup拍照的数据 -->
  104. <!-- <view class="uni-grid-wraps" style="padding-bottom: 20rpx;">
  105. <view style="position: relative;width: 180rpx;float: left;"
  106. v-for="(items3,indexs3) in items.attUrl" :key="indexs3">
  107. <image :src="items3"
  108. style="width: 120rpx;height: 120rpx;border-radius: 30rpx;float: left;margin:0 20rpx 20rpx 0;">
  109. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(indexs,index)">
  110. </u-icon>
  111. </view>
  112. </view> -->
  113. <!---->
  114. </view>
  115. </view>
  116. </u-list-item>
  117. </u-list>
  118. </view>
  119. <view style="width: 60%;position: fixed;bottom:60rpx;z-index: 9999;left: 50%;transform: translate(-50%);"
  120. v-if="!getqrcode">
  121. <div class="btnList" v-if="tableData.length!=0">
  122. <u-button shape="circle" type="primary" color="#4CB2B6" text="暂存" customStyle="margin-right:20%"
  123. @click="checkImplementConfirm">
  124. <!-- 立即处理改为暂存了 -->
  125. </u-button>
  126. <u-button shape="circle" type="primary" color="#4CB2B6" text="生成隐患" @click="checkImplementRelease">
  127. </u-button>
  128. </div>
  129. </view>
  130. <view style="text-align: center;" v-if="tableData.length==0&&!getqrcode">
  131. <view class="text-gray" style="padding-top: 20px;font-size: 40rpx;"> 暂无任务 </view>
  132. </view>
  133. <!-- //"show巡查未完成判断--可能需要打开 -->
  134. <u-modal :show="show" :title="title" :content='content' @confirm="show = false"></u-modal>
  135. <u-modal :show="show3" :title="title" content='未完成有问题检查项拍照' @confirm="show3= false"></u-modal>
  136. <u-modal :show="show4" :title="title" content='未对消防设备进行扫码检查' @confirm="show4= false"></u-modal>
  137. <!-- 弹出层 -->
  138. <u-popup :show="maShow" :round="10" @close="maShow=false">
  139. <view v-if="insTypeData!=''">
  140. <view class="springFarm" v-for="(item,index) in insTypeData" :key="index">
  141. <view class="show-title">设备名称:{{item.fpdName}}</view>
  142. <view class="show-title">设备序列号:{{item.fpdCode}}</view>
  143. <view>
  144. <view class="show-title">设备检查项:</view>
  145. </view>
  146. <view class="" v-if="item.inspectResultList!=''">
  147. <uni-grid :column="3" :showBorder="false">
  148. <uni-grid-item v-for="(items,indexs) in item.inspectResultList" :key="indexs">
  149. <view class="grid-item-box">
  150. <image :src="items.subValue==1?zhengchang:moren" class="tupian"
  151. @click="normalPopup(items,indexs,index)">
  152. </image>
  153. <text class="text">{{items.subLable}}</text>
  154. </view>
  155. </uni-grid-item>
  156. </uni-grid>
  157. </view>
  158. <view class="show-title">
  159. <view class="">巡检拍照:<text style="color:#822e2e;"></text></view>
  160. <view class="">
  161. <image :src="photograph" @click="photoUpload(item)" class="tiantupian"></image> <!-- 加载中 -->
  162. <!-- <isLodingModel></isLodingModel> -->
  163. </view>
  164. </view>
  165. <view class="uni-grid-wraps">
  166. <view style="position: relative;width: 180rpx;float: left;margin: 10rpx 15rpx 0 0rpx;"
  167. v-for="(items,indexs) in item.attUrl" :key="indexs">
  168. <image :src="items" style="width: 160rpx;height: 160rpx;border-radius: 30rpx;float: left;">
  169. <u-icon name="close" color="#4CB2B6" size="19" @click="closeImage(item,indexs,index)">
  170. </u-icon>
  171. </view>
  172. </view>
  173. <view style="width: 60%;position: absolute;left:150rpx;;bottom:60rpx;z-index: 9999;">
  174. <div class="btnList" v-if="tableData.length!=0">
  175. <u-button shape="circle" type="primary" color="#4CB2B6" text="保存"
  176. customStyle="margin-right:20%" @click="checkPopupConfirm(item.id)">
  177. </u-button>
  178. <u-button shape="circle" type="primary" color="#4CB2B6" text="取消" @click="checkPopupCancel">
  179. </u-button>
  180. </div>
  181. </view>
  182. </view>
  183. </view>
  184. <view v-else>
  185. 暂无数据
  186. </view>
  187. </u-popup>
  188. <u-modal :show="show5" title="隐患描述" @confirm="descriptFpd" @cancel="show5 = false">
  189. <view class="slot-content shebeidesrip">
  190. <textarea v-model="description2" placeholder="请输入描述内容" />
  191. </view>
  192. </u-modal>
  193. <!-- 多选closeable closeOnClickOverlay--点击遮罩层不可关闭所属部门的弹出内容选中 ,选择部门-->
  194. </view>
  195. </template>
  196. <script>
  197. let that = null
  198. // #ifdef H5
  199. import {
  200. QrcodeStream
  201. } from 'vue-qrcode-reader'
  202. // #endif
  203. import {
  204. CheckActiveImplement, //每日巡查扫码界面
  205. saveCheckImplement, //保存检查项
  206. checkSubmitRelease, //提交发布检查下
  207. inspTypeList //二维码的弹框数据
  208. } from "@/api/check_active";
  209. import {
  210. getAccessToken
  211. } from '@/utils/auth'
  212. import config from '@/config'
  213. import store from "@/store"
  214. import loadImage from 'blueimp-load-image';
  215. const baseUrl = config.baseUrl
  216. const baseUrlImg = config.baseUrlImg
  217. export default {
  218. components: {
  219. // #ifdef H5
  220. QrcodeStream
  221. // #endif
  222. },
  223. data() {
  224. return {
  225. insType: 1, //1代表检查类型为消防设施,显示扫一扫按钮,其他则显示拍照
  226. // danger: danger, //有隐患图片
  227. moren: `${baseUrlImg}/checkActive/moren.png`, //默认图片
  228. zhengchang: `${baseUrlImg}/checkActive/zhengchang.png`,
  229. hidden: `${baseUrlImg}/checkActive/hidden.png`,
  230. photograph: `${baseUrlImg}/checkActive/photograph.png`,
  231. scan: `${baseUrlImg}/checkActive/scan.png`,
  232. tableData: [],
  233. maShow: false, //扫码后弹框是否展示
  234. // 每页数据量
  235. // 当前页
  236. // 数据总量
  237. total: 0,
  238. getqrcode: false,
  239. loading: false,
  240. formData: {
  241. id: 0,
  242. pageNo: 1,
  243. pageSize: 10,
  244. status: 0,
  245. taskStatus: 1,
  246. broadId: 0,
  247. },
  248. saveImplement: {
  249. inspectList: [],
  250. inspectTime: "", //传的当前事件
  251. orgId: 0,
  252. taskId: 0, //待完成列表所点击的id
  253. broadId: 0,
  254. description: ''
  255. },
  256. isZhengChang: false, //是否正常
  257. isYinHuan: false, //是否隐患
  258. show: false, //未巡查提示框
  259. show2: false, //隐患描述提示框
  260. show3: false, //未拍照提示框
  261. show4: false, //未巡查扫码提示框
  262. show5: false, //检查设备隐患描述提示框
  263. title: '注意',
  264. content: '巡查未完成',
  265. contents: '',
  266. description: '', //隐患描述内容
  267. description2: '', //检查设备的描述内容
  268. newtableDatas: [], //缓存的数据,防止覆盖
  269. id: '',
  270. FinalTime: '',
  271. Insdengers: '', //每个列的检查项是否勾选
  272. nnorNormalValue: '',
  273. erWeiMaShu: '', //二维码内容对象
  274. insTypeData: '', //扫二维码后出现的消防列表数据内容
  275. newInsTypeData: [], //点击扫码后的设备内容
  276. confirminsTypeData: [], //点击确定新建一个新的数组
  277. checkTableDataId: 0, //扫码所点击的当前检查设施的id
  278. descriptIndex: '', //描述所在id
  279. yilou: false, //如果显示了有遗漏的检查项就不提示还未拍照
  280. type: '',
  281. selectedIndex: '',
  282. qrcodeShow: false,
  283. qrcodeResault: '等待扫码...',
  284. onDecodeIndex: ''
  285. }
  286. },
  287. watch: {
  288. loading: {
  289. handler(newLength, oldLength) {
  290. this.$modal.isLoadingModel(this.loading)
  291. },
  292. immediate: true
  293. }
  294. },
  295. // 在 vue页面,向起始页通过事件传递数据
  296. onLoad: function(option) {
  297. this.type = option.type ? option.type : ''
  298. that = this;
  299. const eventChannel = this.getOpenerEventChannel();
  300. eventChannel.on('acceptDataFromOpenerPage', function(val) {
  301. // that.formData = val
  302. that.options = val.taskInfo ? val.taskInfo : val
  303. that.formData.id = parseInt(that.options.id)
  304. that.contents = that.options.taskContent
  305. that.formData.broadId = parseInt(option.broadId)
  306. that.saveImplement.broadId = parseInt(option.broadId)
  307. that.saveImplement.orgId = parseInt(that.options.orgId)
  308. that.newtableDatas.push(uni.getStorageSync('tableData'))
  309. if (that.newtableDatas && that.newtableDatas[0][option.broadId]) { //获取本地缓存的数据
  310. that.tableData = that.newtableDatas[0][option.broadId]
  311. that.insTypeData = uni.getStorageSync('insTypeData')
  312. } else {
  313. that.tableData = []
  314. that.getData(that.formData.pageNo)
  315. }
  316. })
  317. },
  318. onShow() {
  319. // console.log(uni.getStorageSync('tableData'), 'uni.getStorageSync');
  320. // this.tableData=uni.getStorageSync('tableData')
  321. // if(uni.getStorageSync('tableData')){
  322. //
  323. // console.log(this.tableData,'1111111111');
  324. // }
  325. },
  326. // watch: {
  327. // maShow: {
  328. // handler(newLength, oldLength) {
  329. // uni.setStorageSync('tableData', this.tableData)
  330. // },
  331. // deep: true,
  332. // immediate: true
  333. // }
  334. // },
  335. methods: {
  336. //扫码
  337. erWeiMa(checkTableDataIds, index) {
  338. // #ifdef H5
  339. console.log(this.tableData[index], ' this.tableData[index].');
  340. this.tableData[index].qrcodeShow = true
  341. this.$forceUpdate()
  342. this.onDecodeIndex = index
  343. this.checkTableDataId = checkTableDataIds
  344. // #endif
  345. // #ifdef MP-WEIXIN
  346. var that = this
  347. this.description = ''
  348. // 只允许从相机扫码
  349. uni.scanCode({
  350. onlyFromCamera: true, //只允许从相机扫码
  351. success: function(res) {
  352. if (res.errMsg == "scanCode:ok") {
  353. let result = JSON.parse(res.result)
  354. if (that.tableData[index].hisFpdCreateReqVOList.length > 0) {
  355. var temp = that.tableData[index].hisFpdCreateReqVOList
  356. // console.log(temp);
  357. console.log("result.id: ", result.id);
  358. temp = temp.filter(i => i.id == result.id)
  359. console.log("temp: ", temp);
  360. if (temp.length > 0) {
  361. this.tableData[this.onDecodeIndex].qrcodeShow = false
  362. return that.$modal.alert('该设备已检查')
  363. }
  364. }
  365. //调接口,会传过来id标识,失败显示错误信息,比如该设备不存在,成功的花弹出扫码成功
  366. inspTypeList(JSON.parse(res.result)).then(reponse => {
  367. console.log(reponse, 'reponsesssssssssssssss');
  368. if (reponse.code == 0) {
  369. that.maShow = true
  370. that.insTypeData = reponse.data.records
  371. that.insTypeData.map(i => i.attUrl = [])
  372. }
  373. })
  374. setTimeout(() => {
  375. that.$modal.msgSuccess('扫码成功')
  376. }, 200)
  377. that.checkTableDataId = checkTableDataIds
  378. }
  379. },
  380. fail: () => {
  381. that.$modal.msgError('未识别到二维码,请重新尝试!')
  382. }
  383. })
  384. // #endif
  385. },
  386. // #ifdef H5
  387. // H5相机相关函数
  388. onDecode(qrcodeVal) {
  389. this.$modal.msgSuccess('扫码成功', qrcodeVal)
  390. this.qrcodeResault = qrcodeVal
  391. let result = JSON.parse(qrcodeVal)
  392. this.tableData[this.onDecodeIndex].qrcodeShow = false
  393. var that = this
  394. if (that.tableData[this.onDecodeIndex].hisFpdCreateReqVOList.length > 0) {
  395. var temp = that.tableData[this.onDecodeIndex].hisFpdCreateReqVOList
  396. temp = temp.filter(i => i.id == result.id)
  397. if (temp.length > 0) return that.$modal.alert('该设备已检查')
  398. }
  399. //调接口,会传过来id标识,失败显示错误信息,比如该设备不存在,成功的花弹出扫码成功
  400. inspTypeList(JSON.parse(qrcodeVal)).then(reponse => {
  401. if (reponse.code == 0) {
  402. that.maShow = true
  403. that.insTypeData = reponse.data.records
  404. that.insTypeData.map(i => i.attUrl = [])
  405. }
  406. })
  407. setTimeout(() => {
  408. that.$modal.msgSuccess('扫码成功')
  409. }, 200)
  410. },
  411. onInit(promise) { //未使用
  412. promise
  413. .then(console.log)
  414. .catch(console.error)
  415. },
  416. // #endif
  417. descript(index) { //隐患描述点击确认
  418. // this.show2 = false
  419. // this.tableData[index].description = this.description
  420. },
  421. descriptFpd() { //隐患描述点击确认
  422. this.show5 = false
  423. },
  424. closeImage(item, val, k) { //删除图片
  425. console.log(item, 'iii');
  426. if (item.fpdType) {
  427. this.insTypeData[k].attUrl.splice(val, 1)
  428. }
  429. this.tableData[k].attUrl.splice(val, 1)
  430. that.$forceUpdate();
  431. },
  432. goDetail() { //去详情
  433. uni.navigateTo({
  434. url: '/pagesA/fire/check_active/check_implement_detail/check_implement_detail',
  435. })
  436. },
  437. checkImplementConfirm() { //确认保存检查项
  438. this.shuJu()
  439. var total = uni.getStorageSync('tableData') ? uni.getStorageSync('tableData') : {} //避免掉覆盖
  440. total[this.saveImplement.broadId] = this.tableData
  441. uni.setStorageSync('tableData', total)
  442. this.$modal.msg('暂存成功')
  443. // this.tableData.map(i => {
  444. // if (i.isdenger == undefined) {
  445. // this.show = true
  446. // }
  447. // }) //判断是否完成巡查
  448. //批量保存
  449. // console.log(this.show,'Confirmthis.show');
  450. // if (!this.show) {
  451. // saveCheckImplement(JSON.stringify(this.saveImplement)).then(response => { 调接口了
  452. // if (response.data) {
  453. // uni.showToast({
  454. // title: '保存成功',
  455. // icon: 'none',
  456. // duration: 2000
  457. // })
  458. // uni.navigateBack()
  459. // } else {
  460. // this.$modal.msgError('保存失败')
  461. // }
  462. // });
  463. // }
  464. },
  465. checkImplementRelease() { //提交发布
  466. this.shuJu()
  467. this.saveImplement.inspectList.map((i) => { //提交数据组装
  468. if (i.inspType == 'fpd') {
  469. i.hisFpdCreateReqVOList.map(k => {
  470. k.status = 0
  471. k.fpdId = k.id
  472. if (k.dangerDescribe != undefined) {
  473. let strs = ""
  474. strs += `${k.dangerDescribe},`
  475. i.description = strs.slice(0, strs.length - 1)
  476. }
  477. k.imgUrl1 = k.attUrl[0]
  478. k.imgUrl2 = k.attUrl[1]
  479. k.imgUrl3 = k.attUrl[2]
  480. k.fpdResultCreateReqVOList = []
  481. k.fpdResultCreateReqVOList = k.inspectResultList
  482. k.fpdResultCreateReqVOList.map(z => {
  483. z.broadId = this.formData.broadId
  484. z.fpdId = z.id
  485. z.resLable = z.subLable
  486. z.resValue = z.subValue
  487. z.status = 0
  488. if (z.subValue == 0 && z.isNormal ==
  489. 1) { //必传参数,只有该检查项正常为0,那么isdenger==1
  490. k.isdanger = 1
  491. i.isdanger = 1
  492. }
  493. })
  494. })
  495. } else {
  496. i.hisResultCreateReqVOList = i.inspectResultList
  497. i.hisResultCreateReqVOList.map(k => {
  498. k.status = 0
  499. k.broadId = this.formData.broadId
  500. k.fpdId = k.id
  501. k.resLable = k.subLable
  502. k.resValue = k.subValue
  503. k.status = 0
  504. if (k.subValue == 0 && k.isNormal == 1) {
  505. i.isdanger = 1
  506. }
  507. })
  508. }
  509. });
  510. //检查拍照是否有遗漏没有勾选拍照的----------
  511. let arrs = new Array()
  512. this.saveImplement.inspectList.map((i, index) => {
  513. if (i.inspType != 'fpd') {
  514. console.log('12222');
  515. arrs[index] = new Array()
  516. i.inspectResultList.map((k, indexs) => {
  517. arrs[index][indexs] = new Array(i.inspectResultList.length)
  518. arrs[index][indexs] = k.subValue
  519. })
  520. }
  521. })
  522. arrs.map(i => {
  523. if (!i.includes(1)) {
  524. // this.yilou = true
  525. this.show = true
  526. return;
  527. }
  528. })
  529. // this.saveImplement.inspectList.map((i, index) => {
  530. // if (i.inspType != 'fpd') {
  531. // i.inspectResultList.map((k, indexs) => {
  532. // if (i.attUrl.length == 0) {
  533. // if (k.isNormal == 1 && k.subValue == 0 && !this.yilou) return this.show3 =
  534. // true
  535. // }
  536. // })
  537. // } else if (i.inspType == 'fpd' && i.hisFpdCreateReqVOList.length == 0) {
  538. // return this.show4 = true
  539. // }
  540. // })
  541. // console.log(this.saveImplement, '消防设备和消防设施'); 屏蔽未检查校验2
  542. //检查拍照是否有遗漏没有勾选的-----------
  543. // if (!this.show && !this.show3 && !this.show4) {屏蔽未检查校验2
  544. if (!this.show) {
  545. // 巡查未完成判断
  546. console.log(this.saveImplement, '1111111111111111');
  547. checkSubmitRelease(JSON.stringify(this.saveImplement)).then(response => {
  548. if (response.data) {
  549. uni.showToast({
  550. title: '提交成功',
  551. icon: 'none',
  552. duration: 2000
  553. })
  554. const table = uni.getStorageSync('tableData')
  555. delete table[this.saveImplement.broadId] //保存时删除掉保存的那一项再保存
  556. uni.setStorageSync('tableData', table)
  557. setTimeout(() => {
  558. uni.redirectTo({
  559. url: `/pagesA/fire/check_active/index?current=1&type=${this.type}`
  560. });
  561. }, 1000)
  562. } else {
  563. this.$modal.msgError('提交失败')
  564. }
  565. })
  566. }
  567. },
  568. shuJu() {
  569. this.saveImplement.inspectList = this.tableData
  570. this.saveImplement.taskId = this.formData.id
  571. console.log(this.saveImplement, 'this.saveImplementthis.saveImplement');
  572. },
  573. // 获取数据
  574. getData(pageNo, value = '') {
  575. console.log('999999999')
  576. this.loading = true
  577. this.formData.pageNo = pageNo
  578. CheckActiveImplement(JSON.stringify(this.formData)).then(response => {
  579. if (response.data) {
  580. this.total = response.data.total
  581. this.loading = false;
  582. this.tableData = response.data.records
  583. this.tableData.map(i => {
  584. i.inspId = i.id
  585. // i.inspName = i.insp_name
  586. // i.inspCode = i.insp_code
  587. i.isreport = 0
  588. i.status = 0
  589. i.attUrl = []
  590. i.description = ''
  591. i.isdanger = i.isdanger
  592. i.hisFpdCreateReqVOList = []
  593. i.hisResultCreateReqVOList = []
  594. i.qrcodeShow = false
  595. })
  596. }
  597. console.log(this.tableData, 'this.tableData');
  598. });
  599. // this.newInsTypeData.map(i => {
  600. // i.attUrl = []
  601. // })
  602. },
  603. // 触底的事件
  604. scrolltolower() {
  605. // 判断是否还有下一页数据
  606. if (this.formData.pageNo * this.formData.pageSize >= this.total) return uni.showToast({
  607. title: `数据加载完毕`
  608. })
  609. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  610. if (this.loading) return
  611. this.formData.pageNo += 1
  612. },
  613. noNormal() {
  614. this.$modal.alert('此检查项为消防设备,请对设备进行扫码')
  615. },
  616. normal(items, indexs, index, item) {
  617. this.tableData[index].description = this.description
  618. // 根据norNormal == 1判断哪一个是单独与其他互斥的
  619. this.id = items.id
  620. this.descriptIndex = index //给提交发布的描述用的
  621. this.tableData[index].inspectResultList.map(k => {
  622. if (k.isNormal == 1) this.nnorNormalValue = k.id
  623. //给提交发布的描述用的
  624. if (this.tableData[index].inspectResultList[indexs].isNormal != 1 && this.tableData[index]
  625. .inspectResultList[indexs].subValue != 1) {
  626. this.show2 = true
  627. }
  628. })
  629. // tableItem当前点击的复选框值
  630. let tableItem = this.tableData[index].inspectResultList[indexs]
  631. let ALLinspectResultList = this.tableData[index].inspectResultList
  632. let YesinspectResultList = [] //独一个
  633. let NorinspectResultList = [] //其他的互斥的
  634. var Y = ALLinspectResultList.filter(i => i.id == this.nnorNormalValue)
  635. var N = ALLinspectResultList.filter(i => i.id != this.nnorNormalValue)
  636. N.map(n => {
  637. NorinspectResultList.push(n.subValue)
  638. })
  639. Y.map(y => {
  640. YesinspectResultList.push(y.subValue)
  641. })
  642. // items.isdenger = 0 ? 1 : 0
  643. if (NorinspectResultList.includes(1)) { //如果互斥的数组存在true normal!=1的数组
  644. if (tableItem.id == this.nnorNormalValue) { //当点击的是value == this.nnorNormalValue是
  645. this.tableData[index].inspectResultList.map((i, kindex) => {
  646. console.log(i.id, this.nnorNormalValue, 'llllllllo');
  647. if (i.id != this.nnorNormalValue) {
  648. i.subValue = 0
  649. this.show2 = false
  650. } else {
  651. i.subValue = 1
  652. }
  653. })
  654. } else {
  655. // tableItem.subValue = !tableItem.subValue //不为独一份时,执行改语句
  656. items.subValue = items.subValue == 0 ? 1 : 0
  657. this.show2 = false
  658. }
  659. } else { //如果互斥的数组不存在true,全是false normal!=1的数组
  660. if (tableItem.id == this.nnorNormalValue) { //如果点击的是独一份
  661. // tableItem.subValue = !tableItem.subValue //允许执行
  662. items.subValue = items.subValue == 0 ? 1 : 0
  663. } else { //如果点击的是互斥的
  664. // if (YesinspectResultList.includes(true)) { //是否存在第一份
  665. this.tableData[index].inspectResultList.map((i, kindex) => {
  666. if (i.id == this.nnorNormalValue) {
  667. i.subValue = 0
  668. }
  669. })
  670. // }
  671. // tableItem.subValue = !tableItem.subValue
  672. items.subValue = items.subValue == 0 ? 1 : 0
  673. }
  674. }
  675. if (items.isNormal == 0 && items.subValue == 1) {
  676. item.showDescription = true; // 显示描述框
  677. } else {
  678. item.showDescription = false; // 显示描述框
  679. }
  680. console.log(this.tableData, 'this.tableData不是消防');
  681. },
  682. // 消防设备扫码
  683. normalPopup(items, indexs, index) {
  684. // this.insTypeData.map(k => {
  685. // k.attUrl = []
  686. // })
  687. this.insTypeData[index].inspectResultList.map(k => {
  688. if (k.isNormal == 1) this.nnorNormalValue = k.id
  689. if (this.insTypeData[index].inspectResultList[indexs].isNormal != 1 && this.insTypeData[index]
  690. .inspectResultList[indexs].subValue != 1) {
  691. this.show5 = true
  692. }
  693. })
  694. let tableItem = this.insTypeData[index].inspectResultList[indexs]
  695. let ALLinspectResultList = this.insTypeData[index].inspectResultList
  696. let YesinspectResultList = []
  697. let NorinspectResultList = []
  698. var Y = ALLinspectResultList.filter(i => i.id == this.nnorNormalValue)
  699. var N = ALLinspectResultList.filter(i => i.id != this.nnorNormalValue)
  700. N.map(n => {
  701. NorinspectResultList.push(n.subValue)
  702. })
  703. Y.map(y => {
  704. YesinspectResultList.push(y.subValue)
  705. })
  706. // items.isdenger = 0 ? 1 : 0
  707. if (NorinspectResultList.includes(1)) { //如果互斥的数组存在true normal!=1的数组
  708. if (tableItem.id == this.nnorNormalValue) {
  709. this.insTypeData[index].inspectResultList.map((i, kindex) => {
  710. if (i.id != this.nnorNormalValue) {
  711. i.subValue = 0
  712. } else {
  713. i.subValue = 1
  714. }
  715. })
  716. } else {
  717. items.subValue = items.subValue == 0 ? 1 : 0
  718. }
  719. } else {
  720. if (tableItem.id == this.nnorNormalValue) {
  721. items.subValue = items.subValue == 0 ? 1 : 0
  722. } else {
  723. // if (YesinspectResultList.includes(true)) { //是否存在第一份
  724. this.insTypeData[index].inspectResultList.map((i, kindex) => {
  725. if (i.id == this.nnorNormalValue) {
  726. i.subValue = 0
  727. }
  728. })
  729. // }
  730. items.subValue = items.subValue == 0 ? 1 : 0
  731. }
  732. }
  733. },
  734. checkPopupConfirm(fpdId) { //弹出得到的那一条数据insTypeData的id 弹出保存
  735. //this.insTypeData[0]扫二维码后点击出现的一条消防列表数据内容 this.newInsTypeData的多条数据列表
  736. let arr = []
  737. let normalArr = 0
  738. this.insTypeData[0].inspectResultList.map((i, index) => {
  739. arr.push(i.subValue)
  740. if (i.isNormal == 1) {
  741. normalArr = index //找到正常的所在的index
  742. }
  743. })
  744. if (arr.includes(1)) { //包含了证明勾选了
  745. arr.map((i, index) => {
  746. if (i == 1) { //如果i是1表示点击了隐患,判断点击的隐患是否是isnormal=1的,如不是并且图片长度为0,就提示拍照
  747. // if (index != normalArr && this.insTypeData[0].attUrl.length == 0) {
  748. // that.$modal.alert('请对有问题设备进行拍照')
  749. // } else {
  750. // this.newInsTypeData = [...this.newInsTypeData, ...this.insTypeData]
  751. // uni.setStorageSync('newInsTypeDatas', this.newInsTypeData)
  752. // this.newInsTypeData = uni.getStorageSync('newInsTypeDatas')
  753. this.tableData.map(i => {
  754. if (i.id == this.checkTableDataId) {
  755. i.hisFpdCreateReqVOList = [...i.hisFpdCreateReqVOList, ...
  756. this.insTypeData
  757. ]
  758. i.hisFpdCreateReqVOList.map(k => {
  759. k['broadId'] = that.formData.broadId
  760. if (k.id == fpdId) {
  761. k['dangerDescribe'] = this.description2
  762. }
  763. })
  764. }
  765. })
  766. this.insTypeData = []
  767. this.insTypeData.map(k => {
  768. k.attUrl = []
  769. })
  770. console.log(this.tableData, '111111');
  771. this.maShow = false
  772. // }
  773. }
  774. })
  775. } else {
  776. that.$modal.msg('请勾选检查结果')
  777. }
  778. // this.tableData.map((i) => { //这一段不用放开,以前是用于消防设备扫多个码统计数据展示的
  779. // if (i.id = fpdId) {
  780. // let isNormalZero=new Array(i.inspectResultList.length) //新建数组用来放isNormal为1和不为1处理后的分别的数组
  781. // this.newInsTypeData.map(k => {
  782. // k.inspectResultList.map((j,index) => {
  783. // isNormalZero[index]=[]
  784. // isNormalZero[index].push(j.subValue)
  785. // })
  786. // })
  787. // i.inspectResultList.map((g,index)=>{
  788. // if(isNormalZero[index].includes(1)){
  789. // g.subValue=1
  790. // if(g.isNormal==1){
  791. // g.subValue=0
  792. // }
  793. // }
  794. // })
  795. // }
  796. // })
  797. // this.$forceUpdate()
  798. },
  799. checkPopupCancel() {
  800. this.tableData[this.onDecodeIndex].qrcodeShow = false
  801. this.maShow = false
  802. },
  803. //拍照上传
  804. photoUpload(val) {
  805. let pictures = [];
  806. let that = this;
  807. uni.chooseImage({
  808. sourceType: ['camera'], //实现拍照
  809. count: 3,
  810. sizeType: ['original', 'compressed'],
  811. // sourceType: ['album','camera'], //打开系统相册
  812. success(res) {
  813. that.loading = true
  814. if (Array.isArray(res.tempFilePaths)) { //从相册选择有三张的情况
  815. // if (res.tempFilePaths.length === 3) {
  816. // pictures.length = 0
  817. // } else if (res.tempFilePaths.length == 2 && pictures.length == 2) {
  818. // pictures.splice(0, 1)
  819. // }
  820. res.tempFilePaths.forEach(item => {
  821. // let picture = {
  822. // url: item,
  823. // show: false
  824. // }
  825. // pictures.push(picture)
  826. loadImage(
  827. item,
  828. function(canvas) {
  829. canvas.toBlob(function(blob) {
  830. // 压缩后的 Blob 对象
  831. const compressedFile = blob;
  832. // 将压缩后的文件 `compressedFile` 转换为临时URL
  833. const fileUrl = URL.createObjectURL(
  834. compressedFile);
  835. uni.uploadFile({
  836. url: baseUrl +
  837. '/admin-api/infra/file/upload', //后端用于处理图片并返回图片地址的接口
  838. filePath: item,
  839. name: 'file',
  840. header: {
  841. "Authorization": 'Bearer ' +
  842. getAccessToken(),
  843. }, //请求token
  844. success: (res) => {
  845. that.loading = false
  846. let imgUrl = JSON.parse(res
  847. .data)
  848. // that.imageList.push(imgUrl.data)
  849. if (!val.fpdType) {
  850. console.log(that.tableData,
  851. '!val.fpdType');
  852. that.tableData.map((i,
  853. index) => {
  854. if (val.id == i
  855. .id) {
  856. i.attUrl
  857. .push(
  858. imgUrl
  859. .data
  860. )
  861. }
  862. })
  863. } else { //消防设备外(扫一扫下方)展示的图片
  864. //弹出层的消防设备展示的图片
  865. that.insTypeData.map((i,
  866. index) => {
  867. if (val.id == i
  868. .id) {
  869. i.attUrl
  870. .push(
  871. imgUrl
  872. .data
  873. )
  874. }
  875. })
  876. }
  877. that.$forceUpdate();
  878. // // 返回的url
  879. },
  880. fail: () => {
  881. that.loading = false
  882. this.$modal.msg(err)
  883. }
  884. })
  885. // // 保存到本地
  886. // uni.saveImageToPhotosAlbum({
  887. // filePath: item,
  888. // })
  889. // 上传完毕后,释放临时URL
  890. URL.revokeObjectURL(fileUrl);
  891. }, 'image/jpeg', 0.6); // 设置压缩后的图片格式为 JPEG,压缩质量为 0.6
  892. }, {
  893. canvas: true,
  894. maxWidth: 800
  895. } // 设置最大宽度为 800px
  896. );
  897. })
  898. }
  899. }
  900. })
  901. },
  902. // // 将拍的照片的base64转成文件格式然后再转成FormData,就可以使用上传图片的接口了
  903. // base64ToFile(base64){
  904. // const dataArr = base64.split(',');
  905. // const byteString = atob(dataArr[1]);
  906. // const options = {
  907. // type:'image/jpeg',
  908. // endings:'native'
  909. // };
  910. // const u8Arr = new Uint8Array(byteString.length)
  911. // for(let i=0;i<byteString.length;i++){
  912. // u8Arr[i]=byteString.charCodeAt(i);
  913. // }
  914. // return new File([u8Arr],'phone.png',options)
  915. // },
  916. //methode结束
  917. }
  918. }
  919. </script>
  920. <style lang="scss" scoped>
  921. page {
  922. background-color: rgb(245, 247, 249) !important;
  923. }
  924. .container {
  925. // height: 100vh;
  926. position: relative;
  927. background-color: rgb(245, 247, 249);
  928. }
  929. /deep/.uni-card {
  930. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  931. border-radius: 20rpx;
  932. }
  933. .tupian {
  934. width: 48rpx;
  935. height: 48rpx;
  936. }
  937. .tupian2 {
  938. width: 30rpx;
  939. height: 30rpx;
  940. }
  941. .text {
  942. text-align: center;
  943. color: #000;
  944. font-size: 26rpx;
  945. margin-top: 20rpx;
  946. }
  947. .text2 {
  948. text-align: center;
  949. color: #000;
  950. font-size: 22rpx;
  951. margin-top: 10rpx;
  952. }
  953. .child {
  954. margin: 20rpx 0 0 20rpx;
  955. border-radius: 10rpx;
  956. .child-new {
  957. display: flex;
  958. .child-new-item {
  959. width: 30%;
  960. margin-top: 25%;
  961. transform: translateY(-50px);
  962. }
  963. .child-result {
  964. /deep/.data-v-525ecd67 {
  965. // width: 130rpx;
  966. height: 100rpx;
  967. }
  968. }
  969. }
  970. }
  971. .titles {
  972. padding: 20rpx 0;
  973. color: #383838;
  974. }
  975. .grid-item-box {
  976. flex: 1;
  977. display: flex;
  978. flex-direction: column;
  979. align-items: center;
  980. justify-content: center;
  981. padding: 15px 0;
  982. }
  983. /deep/ .uni-grid-item {
  984. height: 140rpx !important;
  985. }
  986. /deep/.uni-textarea-textarea {
  987. // border: 1px solid #4CB2B6;
  988. border-radius: 16rpx;
  989. }
  990. .shebeidesrip {
  991. /deep/.uni-textarea-textarea {
  992. border: none;
  993. border-radius: 16rpx;
  994. }
  995. }
  996. .btnList {
  997. display: flex
  998. }
  999. /deep/.u-icon--right[data-v-172979f2],
  1000. /deep/.u-icon--right.data-v-172979f2,
  1001. /deep/.u-icon--right {
  1002. background-color: #f8f8f8;
  1003. border-radius: 5rpx;
  1004. position: absolute;
  1005. top: -14rpx;
  1006. right: 20rpx;
  1007. }
  1008. .uni-grid-wraps {
  1009. margin-left: 60rpx;
  1010. margin-bottom: 40rpx;
  1011. }
  1012. /deep/.u-slide-up-enter-active[data-v-39e33bf2],
  1013. /deep/.u-slide-up-enter-active.data-v-39e33bf2,
  1014. /deep/.u-slide-up-enter-active {
  1015. height: 90% !important;
  1016. }
  1017. .springFarm {
  1018. margin-left: 40rpx;
  1019. }
  1020. .show-title {
  1021. font-size: 32rpx;
  1022. color: #383838;
  1023. margin: 40rpx 0;
  1024. }
  1025. .tiantupian {
  1026. margin: 40rpx;
  1027. width: 100rpx;
  1028. height: 100rpx
  1029. }
  1030. /deep/.u-modal {
  1031. border: 1px solid #4CB2B6 !important;
  1032. }
  1033. .slot-contents {
  1034. margin-left: 40rpx;
  1035. }
  1036. /deep/ .slot-contents .uni-textarea-textarea {
  1037. border: 1px solid #4CB2B6;
  1038. // background-color: #F0F2F3;
  1039. }
  1040. /deep/ .uni-textarea-placeholder {
  1041. color: #274647;
  1042. margin-top: 20rpx;
  1043. margin-left: 30rpx;
  1044. }
  1045. /deep/.canvasBox {
  1046. .box {
  1047. width: 600rpx;
  1048. /* 设置扫码容器宽度 */
  1049. height: 600rpx;
  1050. /* 设置扫码容器高度 */
  1051. }
  1052. }
  1053. </style>