Index.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048
  1. <template>
  2. <view style="position: relative;" v-show="isShow">
  3. <form @submit="onSubmit">
  4. <scroll-view scroll-y class="container">
  5. <view class="formBox">
  6. <view class="hiddenDangerBox">
  7. <view class="hiddenDangerItemBox workBox" style="margin-top: 0px;">
  8. <view class="hiddenDangerHeader">上报信息</view>
  9. <view class="hiddenDangerBody">
  10. <view class="fway-form-item">
  11. <view class="fway-form-lable"><text class="mustTips">*</text>作业类型</view>
  12. <view class="fway-form-input-select">
  13. <radio-group @change="bindWorkTypeChange">
  14. <label class="fway-form-checkbox" v-for="(item, index) in WorkTypeData" :key="index">
  15. <radio style="transform:scale(0.8);" color="#3e6ffd" :value="item.id"></radio>{{item.dicDataName}}
  16. </label>
  17. </radio-group>
  18. </view>
  19. </view>
  20. <view class="fway-form-item">
  21. <view class="fway-form-lable"><text class="mustTips">*</text>施工地点</view>
  22. <view class="fway-form-input-inline">
  23. <view class="fway-form-input-inline" @tap="onMapTo" style="width: 100%;">
  24. <input type="text" disabled class="fway-form-input" placeholder="请准确标记施工作业具体位置" v-model="data.address" />
  25. </view>
  26. <view class="fway-form-input-inline" v-if="data.address" style="width: 100%;">
  27. <input type="text" class="fway-form-input" placeholder="请填写详细地址" v-model="data.fullAddress" @tap="inputTap" data-focus="fullAddress" :focus="focusID == 'fullAddress' ? true : false" />
  28. </view>
  29. </view>
  30. </view>
  31. <view class="fway-form-item">
  32. <view class="fway-form-lable"><text class="mustTips">*</text>是否已申报</view>
  33. <view class="fway-form-input-select">
  34. <radio-group @change="bindIsDeclarationChange">
  35. <label class="fway-form-checkbox">
  36. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  37. </label>
  38. <label class="fway-form-checkbox">
  39. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  40. </label>
  41. </radio-group>
  42. </view>
  43. </view>
  44. <view class="fway-form-item" v-show="data.isDeclare == true">
  45. <view class="fway-form-lable"><text class="mustTips">*</text>申报人手机号</view>
  46. <view class="fway-form-input-inline">
  47. <input type="number" class="fway-form-input" placeholder="请录入申报人手机号" v-model="data.declarePhoneNumber" @tap="inputTap" data-focus="declarePhoneNumber" :focus="focusID == 'declarePhoneNumber' ? true : false" />
  48. </view>
  49. </view>
  50. <view class="hiddenDangerItem" style="padding: 0 10rpx;">
  51. <view style="padding: 10rpx 0;">
  52. <text class="mustTips" style="vertical-align: text-top;">*</text>
  53. <view style="display: inline-block;width: calc(100% - 30rpx);vertical-align: text-top;">
  54. <text class="itemHeaderText">现场图片/视频</text>
  55. <text class="itemHeaderTips" style="line-height: 40rpx;">(图片请采用近景、含参照物远景图,并保持清晰)</text>
  56. </view>
  57. </view>
  58. <view class="hiddenDangerItemBody">
  59. <view class="photoListBox">
  60. <view class="photoItemBox" v-for="(item, index) in photoList" :key="index" @tap="onPreviewImage" :data-url="item.tempFilePath">
  61. <image class="photoItemImg" :src="item.tempFilePath" mode="aspectFit"></image>
  62. <image class="closeBtn" src="/static/img/common/close.png" @tap.stop="onDelImg" :data-index="index"></image>
  63. </view>
  64. <view class="photoItemBoxsel" v-show="photoList.length < 4" @tap="onChooseImageVideo('image')">
  65. <image class="photoItemImgsel" src="/static/img/write/selPhoto.png"></image>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="hiddenDangerItem" style="padding: 0 10rpx;">
  71. <view class="hiddenDangerItemHeader">
  72. <text class="itemHeaderText">现场视频</text>
  73. </view>
  74. <view class="hiddenDangerItemBody">
  75. <view class="photoListBox">
  76. <view class="photoItemBox" v-for="(item, index) in videoList" :key="index">
  77. <video class="photoItemImg" :id="index" :src="item.tempFilePath"></video>
  78. <image class="closeBtn" src="/static/img/common/close.png" @tap.stop="onDelVideo" :data-index="index"></image>
  79. </view>
  80. <view class="photoItemBoxsel" v-show="videoList.length < 3" @tap="onChooseImageVideo('video')">
  81. <image class="photoItemImgsel" src="/static/img/write/selVideo.png"></image>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="hiddenDangerItemBox reportPersonBox">
  89. <view class="hiddenDangerHeader">上报人信息</view>
  90. <view class="hiddenDangerBody">
  91. <view class="hiddenDangerItem" style="margin-bottom: 0;">
  92. <view class="hiddenDangerItemBody">
  93. <view class="fway-form-item">
  94. <view class="fway-form-lable"><text class="mustTips">*</text>姓名</view>
  95. <view class="fway-form-input-inline">
  96. <input type="text" class="fway-form-input" placeholder="请录入上报人姓名" v-model="data.name" @tap="inputTap" data-focus="name" :focus="focusID == 'name' ? true : false" />
  97. </view>
  98. </view>
  99. <view class="fway-form-item">
  100. <view class="fway-form-lable"><text class="mustTips">*</text>联系方式</view>
  101. <view class="fway-form-input-inline">
  102. <input type="number" class="fway-form-input" placeholder="请录入上报人的联系电话" v-model="data.phoneNumber" @tap="inputTap" data-focus="phoneNumber" :focus="focusID == 'phoneNumber' ? true : false" />
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view class="hiddenDangerItemBox">
  110. <view class="hiddenDangerHeader"><text class="mustTips">*</text>检查事项</view>
  111. <view class="hiddenDangerBody">
  112. <view class="inspectBox">
  113. <view class="inspectItem">
  114. <view class="inspectItemText" style="font-weight: bold;">检查事项</view>
  115. <view class="inspectItemResult" style="font-weight: bold;">检查结果</view>
  116. </view>
  117. <view class="inspectItem">
  118. <view class="inspectItemText">生产经营单位内部是否按规定办理审批手续</view>
  119. <view class="inspectItemResult">
  120. <radio-group @change="(e) => bindInspectChange(e, 'isApprovalProcess')">
  121. <label class="fway-form-checkbox">
  122. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  123. </label>
  124. <label class="fway-form-checkbox">
  125. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  126. </label>
  127. </radio-group>
  128. </view>
  129. </view>
  130. <view class="inspectItem">
  131. <view class="inspectItemText">电气焊作业人员是否取得职业资格证书</view>
  132. <view class="inspectItemResult">
  133. <radio-group @change="(e) => bindInspectChange(e, 'isProfessionalCertificate')">
  134. <label class="fway-form-checkbox">
  135. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  136. </label>
  137. <label class="fway-form-checkbox">
  138. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  139. </label>
  140. </radio-group>
  141. </view>
  142. </view>
  143. <view class="inspectItem">
  144. <view class="inspectItemText">是否落实作业现场监护人员</view>
  145. <view class="inspectItemResult">
  146. <radio-group @change="(e) => bindInspectChange(e, 'isSiteMonitoring')">
  147. <label class="fway-form-checkbox">
  148. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  149. </label>
  150. <label class="fway-form-checkbox">
  151. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  152. </label>
  153. </radio-group>
  154. </view>
  155. </view>
  156. <view class="inspectItem">
  157. <view class="inspectItemText">是否在人员密集场所营业期间动火作业</view>
  158. <view class="inspectItemResult">
  159. <radio-group @change="(e) => bindInspectChange(e, 'isFireWork')">
  160. <label class="fway-form-checkbox">
  161. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  162. </label>
  163. <label class="fway-form-checkbox">
  164. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  165. </label>
  166. </radio-group>
  167. </view>
  168. </view>
  169. <view class="inspectItem">
  170. <view class="inspectItemText">是否清除作业现场及周围易燃物品或落实有效安全防范措施</view>
  171. <view class="inspectItemResult">
  172. <radio-group @change="(e) => bindInspectChange(e, 'isClearSafety')">
  173. <label class="fway-form-checkbox">
  174. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  175. </label>
  176. <label class="fway-form-checkbox">
  177. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  178. </label>
  179. </radio-group>
  180. </view>
  181. </view>
  182. <view class="inspectItem">
  183. <view class="inspectItemText">作业现场是否配备能满足现场灭火应急需求消防器材</view>
  184. <view class="inspectItemResult">
  185. <radio-group @change="(e) => bindInspectChange(e, 'hasFireEquipment')">
  186. <label class="fway-form-checkbox">
  187. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  188. </label>
  189. <label class="fway-form-checkbox">
  190. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  191. </label>
  192. </radio-group>
  193. </view>
  194. </view>
  195. <view class="inspectItem">
  196. <view class="inspectItemText">作业现场使用的工器具是否进行安全检查</view>
  197. <view class="inspectItemResult">
  198. <radio-group @change="(e) => bindInspectChange(e, 'isToolSafety')">
  199. <label class="fway-form-checkbox">
  200. <radio style="transform:scale(0.8);" color="#3e6ffd" value="是"></radio>是
  201. </label>
  202. <label class="fway-form-checkbox">
  203. <radio style="transform:scale(0.8);" color="#3e6ffd" value="否"></radio>否
  204. </label>
  205. </radio-group>
  206. </view>
  207. </view>
  208. </view>
  209. </view>
  210. </view>
  211. </view>
  212. </view>
  213. </scroll-view>
  214. <view class="fway-btnBox">
  215. <button class="fway-btn" formType="submit">立即上报</button>
  216. </view>
  217. </form>
  218. </view>
  219. </template>
  220. <script>
  221. var qqMap = require('@/static/js/qqmap-wx-jssdk.min.js');
  222. var qqMapsdk;
  223. var that;
  224. export default {
  225. data() {
  226. return {
  227. isShow: false,
  228. data: {
  229. longitude: '',
  230. latitude: '',
  231. areaCode: '',
  232. province: '',
  233. city: '',
  234. county: '',
  235. town: '',
  236. street: '',
  237. address: '',
  238. fullAddress: '',
  239. jobType: '',
  240. phoneNumber: '',
  241. name: '',
  242. declarePhoneNumber: '',
  243. isDeclare: null,
  244. isApprovalProcess: null,
  245. isProfessionalCertificate: null,
  246. isSiteMonitoring: null,
  247. isFireWork: null,
  248. isClearSafety: null,
  249. hasFireEquipment: null,
  250. isToolSafety: null,
  251. files: []
  252. },
  253. photoList: [],
  254. videoList: [],
  255. WorkTypeData: [],
  256. focusID: '',
  257. fileSize: 10, // 单位M
  258. }
  259. },
  260. onLoad(option) {
  261. that = this;
  262. qqMapsdk = new qqMap({
  263. key: 'TE4BZ-ZFEAT-45CX3-VPZ3R-GOLS6-EGF54'
  264. });
  265. that.onGetWorkType(function(){
  266. that.isShow = true;
  267. });
  268. },
  269. onShow() {
  270. that.data.phoneNumber = that.data.phoneNumber ? that.data.phoneNumber : uni.getStorageSync('userInfo').userTel || '';
  271. that.data.name = that.data.name ? that.data.name : uni.getStorageSync('userInfo').userName || '';
  272. },
  273. methods: {
  274. // 获取作业类型数据
  275. onGetWorkType(fun){
  276. that.$admin.req({
  277. method: 'GET',
  278. url: '/api/v1/Snapshot/report/base'
  279. }).then(res => {
  280. if (res.jobType && res.jobType.length > 0) {
  281. that.WorkTypeData = res.jobType;
  282. } else {
  283. that.$util.msg('服务异常,请稍后重试!');
  284. }
  285. typeof fun === 'function' && fun();
  286. })
  287. },
  288. // 作业类型下拉选择
  289. bindWorkTypeChange(e){
  290. if (e.detail.value){
  291. that.data.jobType = e.detail.value;
  292. }
  293. },
  294. bindIsDeclarationChange(e){
  295. if (e.detail.value){
  296. that.data.isDeclare = e.detail.value == '是' ? true : false;
  297. if(that.data.isDeclare == false){
  298. that.$util.msg('请提醒作业人员及时进行电气焊作业申报!');
  299. }
  300. }
  301. },
  302. bindInspectChange(e, key){
  303. if (e.detail.value){
  304. that.data[key] = e.detail.value == '是' ? true : false;
  305. }
  306. },
  307. // 监听input框点击设置焦点
  308. inputTap(e) {
  309. if(that.focusID != e.currentTarget.dataset.focus){
  310. uni.hideKeyboard();
  311. setTimeout(function() {
  312. that.focusID = e.currentTarget.dataset.focus
  313. }, 200)
  314. }
  315. },
  316. // 验证地理位置是否在自贡市
  317. onGetAddress(latitude, longitude, fun) {
  318. qqMapsdk.reverseGeocoder({
  319. location: {
  320. latitude: latitude,
  321. longitude: longitude
  322. },
  323. success(res) {
  324. // 地址信息
  325. if (res.result.address_component.city != '自贡市') {
  326. typeof fun === 'function' && fun(false);
  327. } else {
  328. typeof fun === 'function' && fun(res.result);
  329. }
  330. },
  331. fail: function(error) {
  332. console.error(error);
  333. typeof fun === 'function' && fun(false);
  334. }
  335. });
  336. },
  337. onMapTo() {
  338. // 判断微信位置是否开启
  339. let appAuthorizeSetting = uni.getAppAuthorizeSetting();
  340. if (appAuthorizeSetting.locationAuthorized != 'authorized') {
  341. that.$util.msg("定位失败,请在手机设置中打开微信位置权限");
  342. return;
  343. }
  344. uni.chooseLocation({
  345. success: function(res) {
  346. if (res.name) {
  347. that.onGetAddress(res.latitude, res.longitude, function(data) {
  348. if (data) {
  349. console.log(data);
  350. that.data.longitude = res.longitude;
  351. that.data.latitude = res.latitude;
  352. that.data.areaCode = data.ad_info.adcode;
  353. that.data.province = data.address_component.province;
  354. that.data.city = data.address_component.city;
  355. that.data.county = data.address_component.district;
  356. that.data.town = data.address_reference.town.title;
  357. that.data.street = data.address_component.street;
  358. // that.data.address = data.address;
  359. if (res.address) {
  360. let address = res.address;
  361. try {
  362. address = address.replace('四川省自贡市', '');
  363. that.data.address = res.name + '(' + address + ')';
  364. } catch (d) {
  365. that.data.address = res.name + '(' + address + ')';
  366. }
  367. } else {
  368. that.data.address = res.name;
  369. }
  370. } else {
  371. that.$util.msg("选择的地点不属于自贡市行政管辖范围,请重新确认作业地点");
  372. }
  373. })
  374. } else {
  375. that.$util.msg("作业地点定位失败,请重新选择");
  376. }
  377. },
  378. fail() {
  379. that.$util.msg("作业地点定位失败,请重新选择");
  380. }
  381. });
  382. },
  383. // 选择图片和视频
  384. onChooseImageVideo(type) {
  385. // 附件类型
  386. let mediaType = type;
  387. // 图片、视频数量限制剩余数量
  388. let remainPhotoNum = 4 - that.photoList.length;
  389. let remainVideoNum = 3 - that.videoList.length;
  390. // 选择限制数量
  391. // let count = remainPhotoNum + remainVideoNum;
  392. let count = 0;
  393. if (type == 'image'){
  394. count = remainPhotoNum;
  395. }else if (type == 'video'){
  396. count = remainVideoNum;
  397. }
  398. if (count > 0) {
  399. uni.chooseMedia({
  400. count: count, //默认9
  401. mediaType: mediaType,
  402. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  403. sourceType: ['album', 'camera'], //从相册选择
  404. success: (res) => {
  405. let arrPhotoData = [];
  406. let arrVideoData = [];
  407. let strPhotoErrorIndex = '';
  408. let strVideoErrorIndex = '';
  409. let strVideoErrorSizeIndex = '';
  410. res.tempFiles.forEach((item, index) => {
  411. if (item.fileType == 'image') {
  412. arrPhotoData.push(item)
  413. } else if (item.fileType == 'video') {
  414. arrVideoData.push(item)
  415. }
  416. });
  417. let strErrorTips = '';
  418. // 判断图片是否满足条件
  419. let rightPhotoData = [];
  420. arrPhotoData.forEach((item, index) => {
  421. if (item.size > 0 && item.size <= that.fileSize * 1024 * 1024) {
  422. rightPhotoData.push(item)
  423. } else {
  424. if (strPhotoErrorIndex == '') {
  425. strPhotoErrorIndex = (index + 1)
  426. } else {
  427. strPhotoErrorIndex += ',' + (index + 1)
  428. }
  429. }
  430. });
  431. if (strPhotoErrorIndex != '') {
  432. if (strErrorTips != "") {
  433. strErrorTips += '\n';
  434. }
  435. strErrorTips += '您上传的第' + strPhotoErrorIndex + '张图片超过系统文件限制大小,请重新选择上传。'
  436. }
  437. if (rightPhotoData.length > remainPhotoNum) {
  438. if (strErrorTips != "") {
  439. strErrorTips += '\n';
  440. }
  441. strErrorTips += '您选择的图片超出数量限制,仅按顺序保留。'
  442. rightPhotoData.splice(remainPhotoNum, (rightPhotoData.length - remainPhotoNum))
  443. }
  444. // 判断视频是否满足条件
  445. let rightVideoData = [];
  446. arrVideoData.forEach((item, index) => {
  447. if (item.duration > 0 && item.duration <= 60) {
  448. if (item.size > 0 && item.size <= that.fileSize * 1024 * 1024) {
  449. rightVideoData.push(item)
  450. } else {
  451. if (strVideoErrorSizeIndex == '') {
  452. strVideoErrorSizeIndex = (index + 1)
  453. } else {
  454. strVideoErrorSizeIndex += ',' + (index + 1)
  455. }
  456. }
  457. } else {
  458. if (strVideoErrorIndex == '') {
  459. strVideoErrorIndex = (index + 1)
  460. } else {
  461. strVideoErrorIndex += ',' + (index + 1)
  462. }
  463. }
  464. });
  465. if (strVideoErrorIndex != '') {
  466. if (strErrorTips != "") {
  467. strErrorTips += '\n';
  468. }
  469. strErrorTips += '您上传的第' + strVideoErrorIndex + '个视频超过支持的最大时长60s,请重新上传。'
  470. }
  471. if (strVideoErrorSizeIndex != '') {
  472. if (strErrorTips != "") {
  473. strErrorTips += '\n';
  474. }
  475. strErrorTips += '您上传的第' + strVideoErrorSizeIndex + '个视频超过系统文件限制大小,请重新选择上传。'
  476. }
  477. if (rightVideoData.length > remainVideoNum) {
  478. if (strErrorTips != "") {
  479. strErrorTips += '\n';
  480. }
  481. strErrorTips += '您选择的满足条件的视频超出数量限制,仅按顺序保留。'
  482. rightVideoData.splice(remainVideoNum, rightVideoData.length - remainVideoNum);
  483. }
  484. // 保存
  485. if (rightPhotoData.length > 0) {
  486. if (that.photoList.length != 0) {
  487. that.photoList = that.photoList.concat(rightPhotoData)
  488. } else {
  489. that.photoList = rightPhotoData
  490. }
  491. }
  492. if (rightVideoData.length > 0) {
  493. if (that.videoList.length != 0) {
  494. that.videoList = that.videoList.concat(rightVideoData)
  495. } else {
  496. that.videoList = rightVideoData
  497. }
  498. }
  499. if (strErrorTips != "") {
  500. uni.showModal({
  501. title: '提示',
  502. content: strErrorTips,
  503. showCancel: false,
  504. confirmText: '确定',
  505. confirmColor: '#3e6ffd'
  506. })
  507. }
  508. }
  509. });
  510. } else {
  511. that.$util.msg('最多上传4张图片和3段视频!');
  512. }
  513. },
  514. onPreviewImage(e) {
  515. let arrStrPhoto = [];
  516. that.photoList.forEach((item, index) => {
  517. arrStrPhoto.push(item.tempFilePath)
  518. })
  519. uni.previewImage({
  520. urls: arrStrPhoto,
  521. current: e.currentTarget.dataset.url
  522. });
  523. },
  524. onDelImg(e) {
  525. uni.showModal({
  526. content: '确定要删除吗?',
  527. confirmText: '确定',
  528. confirmColor: '#3e6ffd',
  529. success: res => {
  530. if (res.confirm) {
  531. that.photoList.splice(e.currentTarget.dataset.index, 1)
  532. }
  533. }
  534. })
  535. },
  536. onDelVideo(e) {
  537. uni.showModal({
  538. content: '确定要删除吗?',
  539. confirmText: '确定',
  540. confirmColor: '#3e6ffd',
  541. success: res => {
  542. if (res.confirm) {
  543. that.videoList.splice(e.currentTarget.dataset.index, 1)
  544. }
  545. }
  546. })
  547. },
  548. // 附件上传
  549. onUploadFiles(fun) {
  550. uni.showLoading({
  551. title: '上传中,请稍后',
  552. mask: true
  553. })
  554. let files = that.photoList;
  555. // 组装数据
  556. if (that.videoList.length > 0) {
  557. files = files.concat(that.videoList)
  558. }
  559. let pArr = [];
  560. if (files && files.length > 0) {
  561. files.forEach((file, i, array) => {
  562. pArr.push(new Promise(function(resolve, reject) {
  563. that.onUpLoadSingleFile(file, "uploadkey" + i, resolve, reject);
  564. }))
  565. });
  566. Promise.all(pArr).then(res => {
  567. uni.hideLoading();
  568. typeof fun === 'function' && fun(res);
  569. }, err => {
  570. uni.hideLoading();
  571. that.$util.msg(err.msg);
  572. })
  573. } else {
  574. uni.hideLoading();
  575. typeof fun === 'function' && fun();
  576. }
  577. },
  578. // 单个附件上传
  579. onUpLoadSingleFile(file, key, resolve, reject) {
  580. console.log(file);
  581. let fileObj = {
  582. fileType: file.fileType,
  583. msg: ''
  584. };
  585. switch (fileObj.fileType) {
  586. case 'file':
  587. fileObj.msg = '文件上传失败';
  588. break;
  589. case 'image':
  590. fileObj.msg = '图片上传失败';
  591. break;
  592. case 'video':
  593. fileObj.msg = '视频上传失败';
  594. break;
  595. default:
  596. break;
  597. }
  598. uni.uploadFile({
  599. url: that.$admin.config.upfileurl + '?source=hotline',
  600. filePath: file.tempFilePath,
  601. name: 'fileData',
  602. timeout: 10000,
  603. success: res => {
  604. if (res.statusCode == 200) {
  605. try {
  606. let data = JSON.parse(res.data);
  607. let obj = {
  608. additionId: data.result.id,
  609. duration: file.duration || 0,
  610. fileName: data.result.fileName,
  611. path: data.result.path
  612. };
  613. return resolve(obj);
  614. } catch (d) {
  615. return reject(fileObj)
  616. }
  617. } else {
  618. return reject(fileObj)
  619. }
  620. },
  621. fail: res => {
  622. return reject(fileObj)
  623. },
  624. })
  625. },
  626. // 表单验证
  627. formValidation() {
  628. if(!that.data.jobType){
  629. that.$util.msg("请选择作业类型!");
  630. return false;
  631. }
  632. if (!that.data.address) {
  633. that.$util.msg("请选择施工地点!");
  634. return false;
  635. }
  636. if (that.data.fullAddress) {
  637. if (escape(that.data.fullAddress).indexOf("%u") == -1) {
  638. that.$util.msg("请输入正确的地址信息!");
  639. return false;
  640. }
  641. }
  642. if(that.data.isDeclare == null){
  643. that.$util.msg("请选择是否已申报!");
  644. return false;
  645. }
  646. if (that.data.isDeclare){
  647. if (!that.data.declarePhoneNumber) {
  648. that.$util.msg("请输入申报人手机号码!");
  649. return false;
  650. }else {
  651. if (that.$util.e_checkPhone(that.data.declarePhoneNumber) === false) {
  652. that.$util.msg('申报人手机号码格式不正确!');
  653. return false;
  654. }
  655. }
  656. }
  657. if (that.photoList.length == 0 && that.videoList.length == 0) {
  658. that.$util.msg("请上传现场图片或者视频!");
  659. return false;
  660. }
  661. if (!that.data.name) {
  662. that.$util.msg("请输入上报人姓名!");
  663. return false;
  664. }
  665. if (!that.data.phoneNumber) {
  666. that.$util.msg("请输入上报人手机号码!");
  667. return false;
  668. }
  669. if (that.$util.e_checkPhone(that.data.phoneNumber) === false) {
  670. that.$util.msg('上报人手机号码格式不正确!');
  671. return false;
  672. }
  673. if (that.data.isApprovalProcess == null) {
  674. that.$util.msg("请选择检查事项1!");
  675. return false;
  676. }
  677. if (that.data.isProfessionalCertificate == null) {
  678. that.$util.msg("请选择检查事项2!");
  679. return false;
  680. }
  681. if (that.data.isSiteMonitoring == null) {
  682. that.$util.msg("请选择检查事项3!");
  683. return false;
  684. }
  685. if (that.data.isFireWork == null) {
  686. that.$util.msg("请选择检查事项4!");
  687. return false;
  688. }
  689. if (that.data.isClearSafety == null) {
  690. that.$util.msg("请选择检查事项5!");
  691. return false;
  692. }
  693. if (that.data.hasFireEquipment == null) {
  694. that.$util.msg("请选择检查事项6!");
  695. return false;
  696. }
  697. if (that.data.isToolSafety == null) {
  698. that.$util.msg("请选择检查事项7!");
  699. return false;
  700. }
  701. return true;
  702. },
  703. // 表单提交
  704. onSubmit(e) {
  705. if (!that.formValidation()) {
  706. return;
  707. }
  708. if (!that.data.isDeclare){
  709. that.data.declarePhoneNumber = '';
  710. }
  711. let params = that.data;
  712. that.onUploadFiles(function(arr) {
  713. params.files = arr || [];
  714. that.$admin.req({
  715. method: 'POST',
  716. url: '/api/v1/Snapshot/report',
  717. data: params
  718. }).then(res => {
  719. if (res) {
  720. that.$util.msg('上报成功!', function(){
  721. let obj = uni.getStorageSync('userInfo');
  722. obj.userName = that.data.name;
  723. uni.setStorageSync('userInfo', obj);
  724. uni.switchTab({
  725. url: "/pages/Index/IntServ"
  726. })
  727. });
  728. } else {
  729. that.$util.msg("对不起,提交失败,请稍后重试!");
  730. }
  731. });
  732. });
  733. },
  734. }
  735. }
  736. </script>
  737. <style lang="less">
  738. .container {
  739. background-color: #f7f7f7;
  740. font-size: 0;
  741. }
  742. .helpBox {
  743. padding: 20rpx;
  744. }
  745. .formBox {
  746. margin: 0;
  747. padding-bottom: 140rpx;
  748. }
  749. .fway-btnBox{
  750. position: absolute;
  751. bottom: 0;
  752. width: 100%;
  753. padding: 20rpx 0 30rpx;
  754. background-color: #f7f7f7;
  755. z-index: 9;
  756. }
  757. .hiddenDangerBox {
  758. padding: 30rpx 20rpx 0;
  759. }
  760. .hiddenDangerItemBox {
  761. padding: 0;
  762. background-color: #fff;
  763. margin-top: 20rpx;
  764. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  765. border-radius: 10rpx;
  766. }
  767. .hiddenDangerHeader {
  768. padding: 30rpx 20rpx 20rpx;
  769. font-size: 30rpx;
  770. font-weight: bold;
  771. color: #000;
  772. }
  773. .hiddenDangerBody {
  774. padding: 0 20rpx 10rpx;
  775. }
  776. .hiddenDangerItem {
  777. margin-bottom: 20rpx;
  778. }
  779. .hiddenDangerItemHeader {
  780. padding: 10rpx 0;
  781. display: flex;
  782. justify-content: left;
  783. align-items: center;
  784. height: 32rpx;
  785. }
  786. .mustTips {
  787. width: 30rpx;
  788. font-size: 32rpx;
  789. font-weight: bold;
  790. color: #fd0101;
  791. }
  792. .itemHeaderText {
  793. color: #000;
  794. font-size: 28rpx;
  795. }
  796. .itemHeaderTips {
  797. font-size: 24rpx;
  798. color: #777;
  799. }
  800. .hiddenDangerItemBody {
  801. padding: 0;
  802. }
  803. .hiddenDangerHeaderBtn {
  804. width: calc(100% - 288rpx);
  805. display: inline-block;
  806. vertical-align: middle;
  807. text-align: right;
  808. }
  809. .fway-form-item {
  810. padding: 0 10rpx;
  811. }
  812. .fway-form-textarea {
  813. width: calc(100% - 40rpx);
  814. padding: 20rpx;
  815. height: 180rpx;
  816. }
  817. .fway-form-tips {
  818. padding: 10rpx 0;
  819. }
  820. .workBox .fway-form-lable {
  821. width: 180rpx;
  822. }
  823. .workBox .lableTips{
  824. font-size: 24rpx;
  825. color: #777;
  826. }
  827. .workBox .fway-form-input {
  828. width: calc(100% - 20rpx);
  829. }
  830. .workBox .fway-form-input-select {
  831. width: calc(100% - 210rpx);
  832. position: relative;
  833. }
  834. .workBox .fway-form-input-inline {
  835. width: calc(100% - 210rpx);
  836. position: relative;
  837. }
  838. .workBox .fway-form-input-select .fway-form-input {
  839. width: calc(100% - 50rpx);
  840. padding-right: 40rpx;
  841. }
  842. .workBox .fway-form-input-select .fway-form-selectImg{
  843. position: absolute;
  844. right: 10rpx;
  845. top: 34rpx;
  846. }
  847. .workBox .fway-form-checkbox{
  848. margin-right: 20rpx;
  849. }
  850. .reportPersonBox .fway-form-item {
  851. border-bottom: 2rpx #eaeaea solid;
  852. }
  853. .reportPersonBox .fway-form-lable {
  854. padding: 10rpx 0;
  855. width: 150rpx;
  856. color: #777;
  857. }
  858. .reportPersonBox .fway-form-input-inline {
  859. width: calc(100% - 150rpx);
  860. padding: 10rpx 0 0;
  861. }
  862. .reportPersonBox .fway-form-input {
  863. background-color: #fff;
  864. }
  865. .chooseFileItem{
  866. padding: 0 0 0 10rpx;
  867. }
  868. .chooseFileItemHeader{
  869. display: flex;
  870. justify-content: space-between;
  871. align-items: center;
  872. height: 60rpx;
  873. line-height: 60rpx;
  874. }
  875. .chooseFileItemBtn{
  876. height: 50rpx;
  877. line-height: 50rpx;
  878. color: #FFFFFF;
  879. background-color: #3e6ffd;
  880. text-align: center;
  881. border-radius: 20rpx;
  882. padding: 0 40rpx;
  883. }
  884. .photoListBox {
  885. width: calc(100% - 20rpx);
  886. padding: 10rpx 0 20rpx;
  887. display: flex;
  888. justify-content: left;
  889. align-items: start;
  890. flex-wrap: wrap;
  891. align-content: start;
  892. }
  893. .photoItemBox {
  894. width: calc(25% - 20rpx);
  895. height: 130rpx;
  896. position: relative;
  897. border: 2rpx #E5E5E5 solid;
  898. border-radius: 10rpx;
  899. }
  900. .photoItemBox + .photoItemBox{
  901. margin-left: 20rpx;
  902. }
  903. .photoItemBox + .photoItemBoxsel{
  904. margin-left: 20rpx;
  905. }
  906. .photoItemBoxsel {
  907. width: calc(25% - 20rpx);
  908. height: 130rpx;
  909. position: relative;
  910. background-color: #f7f7f7;
  911. border-radius: 10rpx;
  912. display: flex;
  913. justify-content: center;
  914. align-items: center;
  915. }
  916. .photoItemImg {
  917. width: 100%;
  918. height: 100%;
  919. }
  920. .photoItemImgsel{
  921. width: 60rpx;
  922. height: 60rpx;
  923. }
  924. .closeBtn {
  925. background-color: #00000060;
  926. width: 30rpx;
  927. height: 30rpx;
  928. position: absolute;
  929. padding: 10rpx;
  930. top: 0;
  931. right: 0;
  932. }
  933. .fileListBox{
  934. padding: 20rpx 10rpx;
  935. }
  936. .fileItemBox{
  937. display: flex;
  938. justify-content: space-between;
  939. align-items: center;
  940. width: 100%;
  941. }
  942. .fileItemBox + .fileItemBox{
  943. margin-top: 20rpx;
  944. }
  945. .fileName{
  946. width: calc(100% - 60rpx);
  947. margin-right: 20rpx;
  948. white-space: nowrap;
  949. overflow: hidden;
  950. text-overflow: ellipsis;
  951. color: #53d4fc;
  952. }
  953. .fileDeleteBtn{
  954. width: 40rpx;
  955. height: 40rpx;
  956. }
  957. .inspectBox{
  958. margin: 10rpx 0;
  959. border-radius: 30rpx;
  960. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  961. background-color: #fafafa;
  962. }
  963. .inspectItem{
  964. padding: 20rpx 10rpx;
  965. margin: 0 20rpx;
  966. display: flex;
  967. justify-content: space-between;
  968. align-items: center;
  969. }
  970. .inspectItem + .inspectItem{
  971. border-Top: 2rpx #bebebe dashed;
  972. }
  973. .inspectItemText{
  974. width: calc(100% - 230rpx);
  975. line-height: 40rpx;
  976. }
  977. .inspectItemResult{
  978. width: 230rpx;
  979. text-align: right;
  980. }
  981. .inspectBox .fway-form-checkbox {
  982. margin-right: 0;
  983. }
  984. .inspectBox .fway-form-checkbox + .fway-form-checkbox {
  985. margin-left: 30rpx;
  986. }
  987. .inspectBox radio-group label{
  988. padding-right: 0;
  989. }
  990. </style>