Index.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107
  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(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  37. </label>
  38. <label class="fway-form-checkbox">
  39. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  123. </label>
  124. <label class="fway-form-checkbox">
  125. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  136. </label>
  137. <label class="fway-form-checkbox">
  138. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  149. </label>
  150. <label class="fway-form-checkbox">
  151. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  162. </label>
  163. <label class="fway-form-checkbox">
  164. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  175. </label>
  176. <label class="fway-form-checkbox">
  177. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  188. </label>
  189. <label class="fway-form-checkbox">
  190. <radio style="transform:scale(1);" 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(1);" color="#3e6ffd" value="是"></radio>是
  201. </label>
  202. <label class="fway-form-checkbox">
  203. <radio style="transform:scale(1);" 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. .fway-btn{
  758. height: 80rpx;
  759. line-height: 80rpx;
  760. font-size: 40rpx;
  761. }
  762. .hiddenDangerBox {
  763. padding: 30rpx 20rpx 0;
  764. }
  765. .hiddenDangerItemBox {
  766. padding: 0;
  767. background-color: #fff;
  768. margin-top: 20rpx;
  769. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  770. border-radius: 10rpx;
  771. }
  772. .hiddenDangerHeader {
  773. padding: 30rpx 20rpx 20rpx;
  774. font-size: 44rpx;
  775. font-weight: bold;
  776. color: #000;
  777. }
  778. .hiddenDangerBody {
  779. padding: 0 20rpx 10rpx;
  780. }
  781. .hiddenDangerItem {
  782. margin-bottom: 20rpx;
  783. }
  784. .hiddenDangerItemHeader {
  785. padding: 10rpx 0;
  786. display: flex;
  787. justify-content: left;
  788. align-items: center;
  789. }
  790. .mustTips {
  791. width: 30rpx;
  792. font-size: 40rpx;
  793. font-weight: bold;
  794. color: #fd0101;
  795. }
  796. .itemHeaderText {
  797. color: #000;
  798. font-size: 36rpx;
  799. }
  800. .itemHeaderTips {
  801. font-size: 28rpx;
  802. color: #777;
  803. }
  804. .hiddenDangerItemBody {
  805. padding: 0;
  806. }
  807. .hiddenDangerHeaderBtn {
  808. width: calc(100% - 288rpx);
  809. display: inline-block;
  810. vertical-align: middle;
  811. text-align: right;
  812. }
  813. .fway-form-item {
  814. padding: 0 10rpx;
  815. }
  816. .fway-form-textarea {
  817. width: calc(100% - 40rpx);
  818. padding: 20rpx;
  819. height: 180rpx;
  820. }
  821. .fway-form-tips {
  822. padding: 10rpx 0;
  823. }
  824. .workBox .fway-form-lable {
  825. width: 230rpx;
  826. font-size: 36rpx;
  827. }
  828. .workBox .lableTips{
  829. font-size: 28rpx;
  830. color: #777;
  831. }
  832. .workBox .fway-form-input-select {
  833. width: calc(100% - 260rpx);
  834. position: relative;
  835. }
  836. .workBox .fway-form-input-inline {
  837. width: calc(100% - 260rpx);
  838. position: relative;
  839. }
  840. .workBox .fway-form-input-select .fway-form-input {
  841. width: calc(100% - 60rpx);
  842. padding-right: 40rpx;
  843. }
  844. .workBox .fway-form-input-select .fway-form-selectImg{
  845. position: absolute;
  846. right: 10rpx;
  847. top: 34rpx;
  848. }
  849. .reportPersonBox .fway-form-item {
  850. border-bottom: 2rpx #eaeaea solid;
  851. }
  852. .reportPersonBox .fway-form-lable {
  853. padding: 10rpx 0;
  854. width: 200rpx;
  855. color: #777;
  856. font-size: 36rpx;
  857. }
  858. .reportPersonBox .fway-form-input-inline {
  859. width: calc(100% - 200rpx);
  860. padding: 10rpx 0 0;
  861. }
  862. .reportPersonBox .fway-form-input {
  863. background-color: #fff;
  864. }
  865. .fway-form-input {
  866. width: calc(100% - 40rpx);
  867. padding: 0 20rpx;
  868. height: 80rpx;
  869. line-height: 80rpx;
  870. font-size: 36rpx;
  871. }
  872. .fway-form-textarea {
  873. width: calc(100% - 40rpx);
  874. padding: 20rpx;
  875. height: 180rpx;
  876. font-size: 36rpx;
  877. line-height: 46rpx;
  878. }
  879. .fway-form-checkbox, .fway-form-radioBox{
  880. font-size: 36rpx;
  881. }
  882. .workBoxHeader{
  883. display: flex;
  884. justify-content: space-between;
  885. align-items: center;
  886. }
  887. .workBoxHeaderAdd{
  888. color: #3e6ffd;
  889. font-weight: normal;
  890. font-size: 32rpx;
  891. }
  892. .workPersonItem{
  893. border: 2rpx #c7c7c7 dotted;
  894. border-radius: 20rpx;
  895. margin-bottom: 20rpx;
  896. }
  897. .workPersonItemTitle{
  898. padding: 20rpx 30rpx 10rpx;
  899. font-size: 36rpx;
  900. font-weight: bold;
  901. color: #000;
  902. display: flex;
  903. justify-content: space-between;
  904. align-items: center;
  905. }
  906. .workPersonItemTitleDelete{
  907. color: #fd0101;
  908. font-weight: normal;
  909. font-size: 32rpx;
  910. }
  911. .workPersonItemBody{
  912. padding-bottom: 10rpx;
  913. }
  914. .chooseFileItem{
  915. padding: 0 0 0 10rpx;
  916. }
  917. .chooseFileItemHeader{
  918. display: flex;
  919. justify-content: space-between;
  920. align-items: center;
  921. height: 60rpx;
  922. line-height: 60rpx;
  923. font-size: 32rpx;
  924. }
  925. .chooseFileItemBtn{
  926. height: 50rpx;
  927. line-height: 50rpx;
  928. color: #FFFFFF;
  929. background-color: #3e6ffd;
  930. text-align: center;
  931. border-radius: 20rpx;
  932. padding: 0 40rpx;
  933. }
  934. .photoListBox {
  935. width: calc(100% - 20rpx);
  936. padding: 10rpx 0 20rpx;
  937. display: flex;
  938. justify-content: left;
  939. align-items: start;
  940. flex-wrap: wrap;
  941. align-content: start;
  942. }
  943. .photoItemBox {
  944. width: calc(25% - 20rpx);
  945. height: 130rpx;
  946. position: relative;
  947. border: 2rpx #E5E5E5 solid;
  948. border-radius: 10rpx;
  949. }
  950. .photoItemBox + .photoItemBox{
  951. margin-left: 20rpx;
  952. }
  953. .photoItemBox + .photoItemBoxsel{
  954. margin-left: 20rpx;
  955. }
  956. .photoItemBoxsel {
  957. width: calc(25% - 20rpx);
  958. height: 130rpx;
  959. position: relative;
  960. background-color: #f7f7f7;
  961. border-radius: 10rpx;
  962. display: flex;
  963. justify-content: center;
  964. align-items: center;
  965. }
  966. .photoItemImg {
  967. width: 100%;
  968. height: 100%;
  969. }
  970. .photoItemImgsel{
  971. width: 60rpx;
  972. height: 60rpx;
  973. }
  974. .closeBtn {
  975. background-color: #00000060;
  976. width: 30rpx;
  977. height: 30rpx;
  978. position: absolute;
  979. padding: 10rpx;
  980. top: 0;
  981. right: 0;
  982. }
  983. .fileListBox{
  984. padding: 20rpx 10rpx;
  985. }
  986. .fileItemBox{
  987. display: flex;
  988. justify-content: space-between;
  989. align-items: center;
  990. width: 100%;
  991. }
  992. .fileItemBox + .fileItemBox{
  993. margin-top: 20rpx;
  994. }
  995. .fileName{
  996. width: calc(100% - 70rpx);
  997. margin-right: 20rpx;
  998. white-space: nowrap;
  999. overflow: hidden;
  1000. text-overflow: ellipsis;
  1001. color: #53d4fc;
  1002. font-size: 32rpx;
  1003. }
  1004. .fileDeleteBtn{
  1005. width: 50rpx;
  1006. height: 50rpx;
  1007. }
  1008. .inspectBox{
  1009. margin: 10rpx 0;
  1010. border-radius: 30rpx;
  1011. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  1012. background-color: #fafafa;
  1013. }
  1014. .inspectItem{
  1015. padding: 20rpx 10rpx;
  1016. margin: 0 20rpx;
  1017. display: flex;
  1018. justify-content: space-between;
  1019. align-items: center;
  1020. }
  1021. .inspectItem + .inspectItem{
  1022. border-Top: 2rpx #bebebe dashed;
  1023. }
  1024. .inspectItemText{
  1025. width: calc(100% - 260rpx);
  1026. line-height: 50rpx;
  1027. font-size: 36rpx;
  1028. }
  1029. .inspectItemResult{
  1030. width: 260rpx;
  1031. text-align: right;
  1032. font-size: 36rpx;
  1033. }
  1034. .inspectBox .fway-form-checkbox {
  1035. margin-right: 0;
  1036. }
  1037. .inspectBox .fway-form-checkbox + .fway-form-checkbox {
  1038. margin-left: 30rpx;
  1039. }
  1040. .inspectBox radio-group label{
  1041. padding-right: 0;
  1042. }
  1043. </style>