addCheckReport.vue 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  1. <template>
  2. <view >
  3. <page-nav :desc="desc" :title="title"></page-nav>
  4. <view>
  5. <form @submit="formSubmit" @reset="formReset">
  6. <!-- 项目信息项 -->
  7. <view class="uni-form-item">
  8. <view class="view-flex-rs line-body">
  9. <view class="view-flex-cc">
  10. <text class="required-star">*</text>
  11. </view>
  12. <view style="width: 200rpx;" class="view-flex-cc item-title">
  13. <text>当前项目:</text>
  14. </view>
  15. <view style="flex-grow: 0.9;" class="view-flex-cc">
  16. <text>{{projectInfo.title}}</text>
  17. </view>
  18. <view style="width: 200rpx;" class="view-flex-cc">
  19. <button style="height: 80rpx;font-size: medium;" type="primary"
  20. @click="goto('/pages/checkReport/checkProjectSelect?model=1')">重新选择</button>
  21. </view>
  22. </view>
  23. </view>
  24. <!-- 检查区域信息项 -->
  25. <view class="uni-form-item" style="margin-top: 10px;">
  26. <view class="line-body view-flex-rs">
  27. <text class="required-star">*</text>
  28. <text class="item-title">检查区域</text>
  29. </view>
  30. <view>
  31. <uni-list-item @click="selectCheckArea()" :clickable="true" :ellipsis="1"
  32. :show-extra-icon="true" showArrow
  33. :extra-icon="{color: '#4cd964',size: '22',type: 'settings'}"
  34. v-bind:title="checkAreaDict.dictValue" />
  35. </view>
  36. <!-- <u-cell-item class="line-body" icon="setting-fill" v-bind:title="checkAreaDict.dictValue"
  37. hover-class="cell-hover-class" @click="selectCheckArea()"></u-cell-item> -->
  38. </view>
  39. <!-- 检查点位文本信息项 -->
  40. <view class="uni-form-item uni-column" style="margin-top: 10rpx;">
  41. <view class="line-body item-title">
  42. 具体位置
  43. </view>
  44. <view class="line-body">
  45. <uni-easyinput errorMessage v-model="failureCheckPointDesc" placeholder="请输入内容"></uni-easyinput>
  46. </view>
  47. </view>
  48. <!-- 安全隐患问题类型信息项,字典 -->
  49. <view class="uni-form-item" style="margin-top: 10px;">
  50. <view class="line-body view-flex-rs">
  51. <text class="required-star">*</text>
  52. <text class="item-title">安全问题隐患类型</text>
  53. </view>
  54. <view>
  55. <uni-list-item @click="selectCheckItemType()" :clickable="true" :ellipsis="1"
  56. :show-extra-icon="true" showArrow
  57. :extra-icon="{color: '#4cd964',size: '22',type: 'settings'}"
  58. v-bind:title="checkItemTypeDict.dictValue" />
  59. </view>
  60. <!-- <u-cell-item class="line-body" icon="setting-fill" v-bind:title="checkItemTypeDict.dictValue"
  61. hover-class="cell-hover-class" @click="selectCheckItemType()"></u-cell-item> -->
  62. </view>
  63. <!-- 安全隐患问题标签信息项,字典 -->
  64. <view class="uni-form-item" style="margin-top: 10px;">
  65. <view class="line-body view-flex-rs">
  66. <text class="required-star">*</text>
  67. <text class="item-title">检查部位</text>
  68. </view>
  69. <view>
  70. <uni-list-item @click="selectCheckItemLabel()" :clickable="true" :ellipsis="1"
  71. :show-extra-icon="true" showArrow
  72. :extra-icon="{color: '#4cd964',size: '22',type: 'settings'}"
  73. v-bind:title="checkItemLabelDict.dictValue" />
  74. </view>
  75. <!-- <u-cell-item class="line-body" icon="setting-fill" v-bind:title="checkItemLabelDict.dictValue"
  76. hover-class="cell-hover-class" @click="selectCheckItemLabel()"></u-cell-item> -->
  77. </view>
  78. <!-- 安全隐患问题排查标准信息项,字典 -->
  79. <view class="uni-form-item uni-column" style="margin-top: 10px;">
  80. <view class="line-body view-flex-rs">
  81. <text class="required-star">*</text>
  82. <text class="item-title">问题隐患标签</text>
  83. </view>
  84. <view>
  85. <uni-list-item @click="selectCheckStandard()" :clickable="true" :ellipsis="1"
  86. :show-extra-icon="true" showArrow
  87. :extra-icon="{color: '#4cd964',size: '22',type: 'settings'}"
  88. v-bind:title="checkStandardDict.dictValue" />
  89. </view>
  90. <!-- <u-cell-item class="line-body" icon="setting-fill" v-bind:title="checkStandardDict.dictValue"
  91. hover-class="cell-hover-class" @click="selectCheckStandard()"></u-cell-item> -->
  92. </view>
  93. <view class="uni-form-item uni-column" style="margin-top: 10px;">
  94. <view class="line-body item-title">
  95. 法律法规
  96. </view>
  97. <view class="line-body">
  98. <textarea disabled v-model="checkItemStandardBasisDict.dictValue" class="mline-text" />
  99. <!-- <uni-easyinput disabled v-model="checkItemStandardBasisDict.dictValue"></uni-easyinput> -->
  100. </view>
  101. </view>
  102. <!-- 安全隐患问题描述信息项,文本 -->
  103. <view class="uni-form-item uni-column" style="margin-top: 10px;">
  104. <view class="line-body item-title">
  105. 安全问题隐患描述
  106. </view>
  107. <view class="line-body">
  108. <textarea v-model="failureHiddenDangerDesc" name="failureCorrectiveSuggest"
  109. class="mline-text" />
  110. </view>
  111. </view>
  112. <!-- 隐患等级信息项,字典 -->
  113. <view class="uni-form-item" style="margin-top: 15px;">
  114. <view class="view-flex-rs">
  115. <view class="uni-title line-body"><text class="required-star">*</text><text
  116. class="item-title">隐患等级</text></view>
  117. <view class="line-body">
  118. <radio-group @change="hiddenDangerRadioChange"
  119. style="display: flex;flex-direction: row;justify-content: flex-start;">
  120. <label style="margin-top: 2px;margin-right: 5px;" class="view-flex-rs"
  121. v-for="(item, index) in hiddenDangerRadio.items" :key="item.id">
  122. <view>
  123. <radio :value="item.id" :checked="index === hiddenDangerRadio.current" />
  124. </view>
  125. <view style="font-size: 12px;">{{item.dictValue}}</view>
  126. </label>
  127. </radio-group>
  128. </view>
  129. </view>
  130. </view>
  131. <!-- 整改建议信息项,文本 -->
  132. <view class="uni-form-item uni-column" style="margin-top: 10px;">
  133. <view class="line-body item-title">
  134. 整改建议
  135. </view>
  136. <view class="line-body">
  137. <textarea v-model="failureCorrectiveSuggest" name="failureCorrectiveSuggest"
  138. class="mline-text" />
  139. </view>
  140. </view>
  141. <!-- 整改期限信息项,字典 -->
  142. <view class="uni-form-item" style="margin-top: 15px;">
  143. <view class="view-flex-rs">
  144. <view class="uni-title line-body"><text class="required-star">*</text><text
  145. class="item-title">整改期限</text></view>
  146. <view class="line-body">
  147. <radio-group @change="planTimeRadioChange"
  148. style="display: flex;flex-direction: row;justify-content: flex-start;">
  149. <label style="margin-top: 2px;margin-right: 5px;" class="view-flex-rs"
  150. v-for="(item, index) in planTimeRadio.items" :key="item.id">
  151. <view>
  152. <radio :value="item.id" :checked="index === planTimeRadio.current" />
  153. </view>
  154. <view style="font-size: 12px;">{{item.dictValue}}</view>
  155. </label>
  156. </radio-group>
  157. </view>
  158. </view>
  159. </view>
  160. <!-- 图片信息项 -->
  161. <view class="uni-form-item" style="margin-top: 10px;">
  162. <view class="view-flex-rs line-body">
  163. <view class="view-flex-cc" style="height: 40px;">
  164. <text class="item-title">安全隐患问题图片</text>
  165. </view>
  166. </view>
  167. </view>
  168. <view class="uni-form-item" style="margin-top: 10px;">
  169. <view class="img-container">
  170. <view class="note-image-box">
  171. <view class="note-image-item" v-for="(item , index) in localImageList" :key="index">
  172. <view class="close-icon" @click="onDeleteClick(index)">
  173. <uni-icons type="closeempty" size="18" color="#fff"></uni-icons>
  174. </view>
  175. <view class="image-box">
  176. <image :src="item" mode="widthFix"></image>
  177. </view>
  178. </view>
  179. <view v-if="localImageList.length < 9" class="note-image-item" @click="getPhoto()">
  180. <view class="image-box">
  181. <uni-icons type="plusempty" size="50" color="#eee"></uni-icons>
  182. </view>
  183. </view>
  184. </view>
  185. </view>
  186. </view>
  187. <u-gap height="50"></u-gap>
  188. <view class="uni-form-item uni-column">
  189. <view class="line-body">
  190. <button type="primary" form-type="submit">提交</button>
  191. </view>
  192. <view class="line-body" style="margin-top: 10px;">
  193. <button type="default" @click="onSaveClick">保存</button>
  194. </view>
  195. </view>
  196. <u-gap height="50"></u-gap>
  197. </form>
  198. </view>
  199. </view>
  200. </template>
  201. <script>
  202. import pageNav from '@/components/page-nav/page-nav.vue';
  203. import http from '@/http/api.js';
  204. import {
  205. pathToBase64,
  206. base64ToPath
  207. } from '@/js_sdk/mmmm-image-tools/index.js';
  208. import {
  209. devUrl,
  210. prodUrl
  211. } from '@/common/setting';
  212. export default {
  213. components: {
  214. pageNav
  215. },
  216. onLoad(option) {
  217. this.baseURL = process.env.NODE_ENV === 'development' ? devUrl : prodUrl;
  218. this.userInfo1 = uni.getStorageSync("userInfo");
  219. this.checkNo = this.getCheckNo();
  220. this.initProjectInfo(option.id);
  221. //查询隐患等级
  222. var dangerLevelList = [];
  223. http.request({
  224. url: '/galaxy-system/dict-biz/dictionary?code=danger_level',
  225. method: 'GET'
  226. }).then(res => {
  227. console.log(res.data)
  228. if (res.data != null) {
  229. const dictLength = res.data['length'];
  230. for (var i = 0; i < dictLength; i++) {
  231. let dict = res.data['' + i];
  232. dangerLevelList.push(dict);
  233. }
  234. }
  235. }).catch(err => {
  236. console.log(err)
  237. })
  238. this.hiddenDangerRadio.items = dangerLevelList;
  239. //查询整改期限
  240. var planTimeList = [];
  241. http.request({
  242. url: '/galaxy-system/dict-biz/dictionary?code=plan_time',
  243. method: 'GET'
  244. }).then(res => {
  245. console.log(res.data)
  246. if (res.data != null) {
  247. const dictLength = res.data['length'];
  248. for (var i = 0; i < dictLength; i++) {
  249. let dict = res.data['' + i];
  250. planTimeList.push(dict);
  251. }
  252. }
  253. }).catch(err => {
  254. console.log(err)
  255. })
  256. this.planTimeRadio.items = planTimeList;
  257. },
  258. data() {
  259. return {
  260. baseURL: '',
  261. userInfo1: {},
  262. checkNo: '',
  263. planTimeRadio: {
  264. items: [],
  265. current: 0,
  266. },
  267. hiddenDangerRadio: {
  268. items: [],
  269. current: 0,
  270. },
  271. localImageList: [],
  272. uploadImageList: [],
  273. checkAreaDict: {
  274. id: '',
  275. dictKey: '',
  276. dictValue: '请点击选择'
  277. },
  278. checkItemTypeDict: {
  279. id: '',
  280. dictKey: '',
  281. dictValue: '请点击选择'
  282. },
  283. checkItemLabelDict: {
  284. id: '',
  285. dictKey: '',
  286. dictValue: '请点击选择'
  287. },
  288. checkStandardDict: {
  289. id: '',
  290. dictKey: '',
  291. dictValue: '请点击选择'
  292. },
  293. checkItemStandardBasisDict: {
  294. id: '',
  295. dictKey: '',
  296. dictValue: ''
  297. },
  298. title: '开始检查',
  299. desc: '',
  300. projectInfo: {
  301. 'projectId': '',
  302. 'title': ''
  303. },
  304. failureHiddenDangerDesc: '',
  305. failureCheckPointDesc: '',
  306. failureCorrectiveSuggest: '',
  307. }
  308. },
  309. computed: {
  310. getIcon() {
  311. return path => {
  312. return 'https://cdn.uviewui.com/uview/example/' + path + '.png';
  313. }
  314. },
  315. },
  316. onShow() {
  317. uni.setNavigationBarTitle({
  318. title: ""
  319. });
  320. //项目选择结果监听
  321. uni.$on("handClickProjectSelect", res => {
  322. console.log(res);
  323. this.projectInfo = {
  324. projectId: res.projectId,
  325. title: res.title
  326. }
  327. // 清除监听
  328. uni.$off('handClickProjectSelect');
  329. })
  330. //检查区域选择结果监听
  331. uni.$on("handClickAreaSelect", res => {
  332. console.log(res);
  333. this.checkAreaDict = {
  334. dictValue: res.dictValue,
  335. dictKey: res.dictKey,
  336. id: res.id
  337. }
  338. // 清除监听
  339. uni.$off('handClickAreaSelect');
  340. })
  341. //安全隐患问题分类选择结果监听
  342. uni.$on("handClickItemSelect", res => {
  343. console.log("callback " + res);
  344. if (this.checkItemTypeDict.id == null || this.checkItemTypeDict.id.length == 0 || this
  345. .checkItemTypeDict.id !== res.id) {
  346. this.checkItemLabelDict = {
  347. id: '',
  348. dictKey: '',
  349. dictValue: '请点击选择'
  350. }
  351. this.checkStandardDict = {
  352. id: '',
  353. dictKey: '',
  354. dictValue: '请点击选择'
  355. }
  356. this.failureHiddenDangerDesc = "";
  357. this.checkItemStandardBasisDict = {
  358. id: '',
  359. dictKey: '',
  360. dictValue: ''
  361. }
  362. }
  363. this.checkItemTypeDict = {
  364. dictValue: res.dictValue,
  365. dictKey: res.dictKey,
  366. id: res.id
  367. }
  368. // 清除监听
  369. uni.$off('handClickItemSelect');
  370. })
  371. //安全隐患标签选择结果监听
  372. uni.$on("handClickItemLabelSelect", res => {
  373. console.log("handClickItemLabelSelect" + res);
  374. if (this.checkItemLabelDict.id == null || this.checkItemLabelDict.id.length == 0 || this
  375. .checkItemLabelDict.id !== res.id) {
  376. this.checkStandardDict = {
  377. id: '',
  378. dictKey: '',
  379. dictValue: '请点击选择'
  380. }
  381. this.failureHiddenDangerDesc = "";
  382. this.checkItemStandardBasisDict = {
  383. id: '',
  384. dictKey: '',
  385. dictValue: ''
  386. }
  387. }
  388. this.checkItemLabelDict = {
  389. dictValue: res.dictValue,
  390. dictKey: res.dictKey,
  391. id: res.id
  392. }
  393. // 清除监听
  394. uni.$off('handClickItemLabelSelect');
  395. })
  396. //安全隐患排查标准选择结果监听
  397. uni.$on("handClickStandardSelect", res => {
  398. console.log(res);
  399. if (this.checkStandardDict.id == null || this.checkStandardDict.id.length == 0 || this
  400. .checkStandardDict.id !== res.id) {
  401. this.failureHiddenDangerDesc = "";
  402. this.checkItemStandardBasisDict = {
  403. id: '',
  404. dictKey: '',
  405. dictValue: ''
  406. }
  407. }
  408. this.checkStandardDict = {
  409. dictValue: res.dictValue,
  410. dictKey: res.dictKey,
  411. id: res.id
  412. }
  413. this.failureHiddenDangerDesc = res.dictValue;
  414. this.checkItemStandardBasisDict = {
  415. dictValue: res.subDict.dictValue,
  416. dictKey: res.subDict.dictKey,
  417. id: res.subDict.id
  418. }
  419. // 清除监听
  420. uni.$off('handClickStandardSelect');
  421. })
  422. },
  423. created() {
  424. },
  425. methods: {
  426. dateFormat(dt) {
  427. var text = "" + dt.getFullYear();
  428. text += "-";
  429. text += ((dt.getMonth() + 1) < 10) ? ("0" + (dt.getMonth() + 1)) : (dt
  430. .getMonth() +
  431. 1);
  432. text += "-";
  433. text += dt.getDate() < 10 ? "0" + dt.getDate() : dt.getDate();
  434. text += " ";
  435. text += dt.getHours() < 10 ? "0" + dt.getHours() : dt.getHours();
  436. text += ":";
  437. text += dt.getMinutes() < 10 ? "0" + dt.getMinutes() : dt.getMinutes();
  438. text += ":";
  439. text += dt.getSeconds() < 10 ? "0" + dt.getSeconds() : dt.getSeconds();
  440. return text;
  441. },
  442. getCheckNo() {
  443. var dt = new Date();
  444. var recordNo = "" + dt.getFullYear();
  445. recordNo = recordNo.substr(2, 2);
  446. recordNo += ((dt.getMonth() + 1) < 10) ? ("0" + (dt.getMonth() + 1)) : (dt
  447. .getMonth() +
  448. 1);
  449. recordNo += dt.getDate() < 10 ? "0" + dt.getDate() : dt.getDate();
  450. recordNo += dt.getHours() < 10 ? "0" + dt.getHours() : dt.getHours();
  451. recordNo += dt.getMinutes() < 10 ? "0" + dt.getMinutes() : dt.getMinutes();
  452. recordNo += dt.getSeconds() < 10 ? "0" + dt.getSeconds() : dt.getSeconds();
  453. return recordNo;
  454. },
  455. initProjectInfo(failureProjectId) {
  456. const that = this;
  457. const id = failureProjectId;
  458. http.request({
  459. url: '/blade-business/report/projectInfo/detail',
  460. method: 'GET',
  461. params: {
  462. id
  463. }
  464. }).then(res => {
  465. console.log(res.data)
  466. that.projectInfo = {
  467. projectId: res.data.id,
  468. title: res.data.projectName
  469. }
  470. }).catch(err => {
  471. console.log(err)
  472. })
  473. },
  474. onDeleteClick(index) {
  475. this.localImageList.splice(index, 1);
  476. },
  477. planTimeRadioChange: function(evt) {
  478. for (let i = 0; i < this.planTimeRadio.items.length; i++) {
  479. if (this.planTimeRadio.items[i].id === evt.detail.value) {
  480. this.planTimeRadio.current = i;
  481. break;
  482. }
  483. }
  484. },
  485. hiddenDangerRadioChange: function(evt) {
  486. for (let i = 0; i < this.hiddenDangerRadio.items.length; i++) {
  487. if (this.hiddenDangerRadio.items[i].id === evt.detail.value) {
  488. this.hiddenDangerRadio.current = i;
  489. break;
  490. }
  491. }
  492. },
  493. getPhoto() {
  494. const that = this;
  495. if (this.localImageList.length > 9) {
  496. uni.showModal({
  497. content: '一次最多上传9张图片,请检查!',
  498. showCancel: false
  499. });
  500. } else {
  501. uni.chooseImage({
  502. sourceType: ['album', 'camera'],
  503. success: (res) => {
  504. const len = res.tempFilePaths.length;
  505. if (len > 0) {
  506. if (len + that.localImageList.length > 9) {
  507. uni.showModal({
  508. content: '一次最多上传9张图片,请检查!',
  509. showCancel: false
  510. });
  511. } else {
  512. let pathList = [];
  513. res.tempFilePaths.forEach(path => {
  514. pathList.push(path);
  515. })
  516. that.localImageList = that.localImageList.concat(pathList);
  517. }
  518. }
  519. }
  520. })
  521. }
  522. },
  523. onSaveClick(e) {
  524. if ((this.projectInfo.projectId != null && this.projectInfo.projectId.length > 0) &&
  525. (this.checkAreaDict.id != null && this.checkAreaDict.id.length > 0) &&
  526. (this.checkItemTypeDict.id != null && this.checkItemTypeDict.id.length > 0) &&
  527. (this.checkItemLabelDict.id != null && this.checkItemLabelDict.id.length > 0) &&
  528. (this.checkStandardDict.id != null && this.checkStandardDict.id.length > 0)) {
  529. try {
  530. var data = {};
  531. data['failureHiddenDangerDesc'] = this.failureHiddenDangerDesc;
  532. data['failureCheckPointDesc'] = this.failureCheckPointDesc;
  533. data['failureCorrectiveSuggest'] = this.failureCorrectiveSuggest;
  534. data['failureCheckNo'] = this.checkNo;
  535. data['failureProjectId'] = this.projectInfo.projectId;
  536. data['failureCheckArea'] = this.checkAreaDict.id;
  537. data['failureCheckHiddenDangerType'] = this.checkItemTypeDict.id;
  538. data['failureCheckHiddenDanger'] = this.checkItemLabelDict.id;
  539. data['failureCheckHiddenDangerItemPoint'] = this.checkStandardDict.id;
  540. data['failureCheckHiddenDangerStandard'] = this.checkItemStandardBasisDict.id;
  541. data['failureHiddenDangerLevel'] = this.hiddenDangerRadio.items[this.hiddenDangerRadio.current]
  542. .id;
  543. data['failureCorrectivePlanTime'] = this.planTimeRadio.items[this.planTimeRadio.current]
  544. .id;
  545. data['createTime'] = this.dateFormat(new Date());
  546. data['createUserName'] = this.userInfo1.nick_name;
  547. this.saveLocalFiles();
  548. console.log("save " + data);
  549. var list = uni.getStorageSync('check_report_storage_index');
  550. if (list != null && list.length > 0) {
  551. list.push(this.checkNo);
  552. uni.setStorageSync('check_report_storage_index', list);
  553. uni.setStorageSync('check_report_storage_' + this.checkNo, data);
  554. } else {
  555. list = [];
  556. list.push(this.checkNo);
  557. uni.setStorageSync('check_report_storage_index', list);
  558. uni.setStorageSync('check_report_storage_' + this.checkNo, data);
  559. }
  560. var that = this;
  561. uni.showModal({
  562. title: '流程确认',
  563. content: '请选择复制或继续检查',
  564. cancelText: '复制检查单',
  565. confirmText: '继续检查',
  566. success: function(res) {
  567. if (res.confirm) {
  568. that.onContinunClick();
  569. } else if (res.cancel) {
  570. that.onCopyClick();
  571. }
  572. }
  573. });
  574. //uni.navigateBack();
  575. } catch (e) {
  576. console.log(e)
  577. uni.showModal({
  578. content: '保存失败!',
  579. showCancel: false
  580. });
  581. }
  582. } else {
  583. uni.showModal({
  584. content: '请检查必填项',
  585. showCancel: false
  586. });
  587. }
  588. },
  589. saveLocalFile(paths) {
  590. var returnFileList = [];
  591. var count = 0;
  592. return new Promise((resolve, reject) => {
  593. paths.forEach(imagePath => {
  594. console.log("path " + imagePath);
  595. uni.saveFile({
  596. tempFilePath: imagePath,
  597. success: (res) => {
  598. var savedFilePath = res.savedFilePath;
  599. returnFileList.push(savedFilePath);
  600. count += 1;
  601. if (count == paths.length) {
  602. resolve(returnFileList);
  603. }
  604. },
  605. fail: (e) => {
  606. reject('err')
  607. }
  608. })
  609. });
  610. })
  611. },
  612. onCopyClick() {
  613. this.localImageList = [];
  614. this.checkNo = this.getCheckNo();
  615. },
  616. onContinunClick() {
  617. uni.navigateBack();
  618. },
  619. async saveLocalFiles() {
  620. if (this.localImageList.length > 0) {
  621. await this.saveLocalFile(this.localImageList).then(files => {
  622. uni.setStorageSync('check_report_storage_image_' + this
  623. .checkNo, files);
  624. });
  625. }
  626. },
  627. async upload(formdata) {
  628. if (this.localImageList.length > 0) {
  629. await this.uploadFile(this.localImageList).then(names => {
  630. names.forEach(name => {
  631. console.log("image path " + name);
  632. this.uploadImageList.push(name);
  633. })
  634. var photoPaths = [];
  635. this.uploadImageList.forEach(name => {
  636. let p = {
  637. failureCheckNo: this.checkNo,
  638. photoPath: name
  639. }
  640. photoPaths.push(p);
  641. })
  642. formdata['photoPaths'] = photoPaths;
  643. var that = this;
  644. http.request({
  645. url: '/blade-business/report/failure/save',
  646. method: 'POST',
  647. data: formdata
  648. }).then(res => {
  649. if (res.success) {
  650. uni.showModal({
  651. content: '上传成功',
  652. showCancel: false,
  653. success(res) {
  654. if (res.confirm) {
  655. uni.showModal({
  656. title: '流程确认',
  657. content: '请选择复制或继续检查',
  658. cancelText: '复制检查单',
  659. confirmText: '继续检查',
  660. confirmColor: '#000000',
  661. success: function(res) {
  662. if (res.confirm) {
  663. that.onContinunClick();
  664. } else if (res.cancel) {
  665. that.onCopyClick();
  666. }
  667. }
  668. });
  669. // uni.redirectTo({
  670. // url: 'pages/checkReport/copyCheckFormConfirm'
  671. // });
  672. //uni.navigateBack();
  673. }
  674. }
  675. });
  676. } else {
  677. uni.showModal({
  678. content: '' + res.msg,
  679. showCancel: false
  680. });
  681. }
  682. }).catch(err => {
  683. console.log(err)
  684. })
  685. })
  686. } else {
  687. var that = this;
  688. http.request({
  689. url: '/blade-business/report/failure/save',
  690. method: 'POST',
  691. data: formdata
  692. }).then(res => {
  693. if (res.success) {
  694. uni.showModal({
  695. content: '上传成功',
  696. showCancel: false,
  697. success(res) {
  698. if (res.confirm) {
  699. uni.showModal({
  700. title: '流程确认',
  701. content: '请选择复制或继续检查',
  702. cancelText: '复制检查单',
  703. confirmText: '继续检查',
  704. confirmColor: '#000000',
  705. success: function(res) {
  706. if (res.confirm) {
  707. that.onContinunClick();
  708. } else if (res.cancel) {
  709. that.onCopyClick();
  710. }
  711. }
  712. });
  713. //uni.navigateBack();
  714. }
  715. }
  716. });
  717. } else {
  718. uni.showModal({
  719. content: '' + res.msg,
  720. showCancel: false
  721. });
  722. }
  723. }).catch(err => {
  724. console.log(err)
  725. })
  726. }
  727. },
  728. uploadFile(imagePaths) {
  729. var count = 0;
  730. var returnImagePathList = [];
  731. console.log("accessToken:" + uni.getStorageSync('accessToken'));
  732. return new Promise((resolve, reject) => {
  733. imagePaths.forEach(imagePath => {
  734. console.log("path " + imagePath);
  735. uni.showLoading({
  736. title: '上传中'
  737. });
  738. uni.uploadFile({
  739. url: this.baseURL +
  740. '/galaxy-resource/oss/endpoint/put-file-attach?Blade-Auth=' +
  741. uni.getStorageSync('accessToken'),
  742. fileType: 'image',
  743. filePath: imagePath,
  744. name: 'file',
  745. success: (uploadFileRes) => {
  746. console.log(uploadFileRes);
  747. if (uploadFileRes.statusCode == 200) {
  748. let data = JSON.parse(uploadFileRes.data);
  749. if (data.success) {
  750. let name = data.data['name'];
  751. returnImagePathList.push(name);
  752. }
  753. }
  754. count += 1;
  755. if (count == imagePaths.length) {
  756. resolve(returnImagePathList);
  757. }
  758. },
  759. fail: (err) => {
  760. console.log(err);
  761. reject('err')
  762. },
  763. complete() {
  764. uni.hideLoading()
  765. }
  766. });
  767. });
  768. })
  769. },
  770. formSubmit: function(e) {
  771. console.log('form发生了submit事件,携带数据为:' + JSON.stringify(e.detail.value))
  772. //var formdata = e.detail.value
  773. if ((this.projectInfo.projectId != null && this.projectInfo.projectId.length > 0) &&
  774. (this.checkAreaDict.id != null && this.checkAreaDict.id.length > 0) &&
  775. (this.checkItemTypeDict.id != null && this.checkItemTypeDict.id.length > 0) &&
  776. (this.checkItemLabelDict.id != null && this.checkItemLabelDict.id.length > 0) &&
  777. (this.checkStandardDict.id != null && this.checkStandardDict.id.length > 0)) {
  778. var formdata = {};
  779. formdata['failureCheckNo'] = this.checkNo;
  780. formdata['failureProjectId'] = this.projectInfo.projectId;
  781. formdata['failureCheckArea'] = this.checkAreaDict.id;
  782. formdata['failureCheckHiddenDangerType'] = this.checkItemTypeDict.id;
  783. formdata['failureCheckHiddenDanger'] = this.checkItemLabelDict.id;
  784. formdata['failureCheckHiddenDangerItemPoint'] = this.checkStandardDict.id;
  785. formdata['failureCheckHiddenDangerStandard'] = this.checkItemStandardBasisDict.id;
  786. formdata['failureHiddenDangerDesc'] = this.failureHiddenDangerDesc;
  787. formdata['failureCheckPointDesc'] = this.failureCheckPointDesc;
  788. formdata['failureCorrectiveSuggest'] = this.failureCorrectiveSuggest;
  789. formdata['failureHiddenDangerLevel'] = this.hiddenDangerRadio.items[this.hiddenDangerRadio.current]
  790. .id;
  791. formdata['failureCorrectivePlanTime'] = this.planTimeRadio.items[this.planTimeRadio.current]
  792. .id;
  793. this.upload(formdata);
  794. } else {
  795. uni.showModal({
  796. content: '请检查必填项',
  797. showCancel: false
  798. });
  799. }
  800. },
  801. formReset: function(e) {
  802. console.log('清空数据')
  803. },
  804. selectCheckArea() {
  805. uni.navigateTo({
  806. url: '/pages/checkReport/checkAreaSelect'
  807. })
  808. },
  809. selectCheckItemType() {
  810. uni.navigateTo({
  811. url: '/pages/checkReport/checkItemSelect'
  812. })
  813. },
  814. selectCheckItemLabel() {
  815. if (this.checkItemTypeDict.id.length > 0) {
  816. uni.navigateTo({
  817. url: '/pages/checkReport/checkItemLabelSelect?id=' + this.checkItemTypeDict.id
  818. })
  819. } else {
  820. uni.showModal({
  821. content: '请先选择安全隐患问题类型',
  822. showCancel: false
  823. });
  824. }
  825. },
  826. selectCheckStandard() {
  827. if (this.checkItemLabelDict.id.length > 0) {
  828. uni.navigateTo({
  829. url: '/pages/checkReport/checkStandardSelect?id=' + this.checkItemLabelDict.id
  830. })
  831. } else {
  832. uni.showModal({
  833. content: '请先选择安全隐患问题标签',
  834. showCancel: false
  835. });
  836. }
  837. },
  838. openPage(path) {
  839. this.$u.route({
  840. url: path
  841. })
  842. },
  843. getGroupTitle(item) {
  844. return item.groupName
  845. },
  846. getFieldTitle(item) {
  847. return item.title
  848. },
  849. goto(url) {
  850. console.log(url);
  851. uni.navigateTo({
  852. url: url
  853. })
  854. }
  855. }
  856. }
  857. </script>
  858. <style>
  859. /* page {
  860. background-color: rgb(240, 242, 244);
  861. } */
  862. .cell-hover-class {
  863. background-color: rgb(235, 237, 238);
  864. }
  865. .view-flex-rs {
  866. display: flex;
  867. flex-direction: row;
  868. justify-content: flex-start;
  869. }
  870. .view-flex-rc {
  871. display: flex;
  872. flex-direction: row;
  873. justify-content: center;
  874. }
  875. .view-flex-re {
  876. display: flex;
  877. flex-direction: row;
  878. justify-content: flex-end;
  879. }
  880. .view-flex-cs {
  881. display: flex;
  882. flex-direction: column;
  883. justify-content: flex-start;
  884. }
  885. .view-flex-cc {
  886. display: flex;
  887. flex-direction: column;
  888. justify-content: center;
  889. }
  890. .view-flex-ce {
  891. display: flex;
  892. flex-direction: column;
  893. justify-content: flex-end;
  894. }
  895. .line-body {
  896. padding-left: 10px;
  897. padding-right: 10px;
  898. }
  899. .required-star {
  900. color: #FF0000;
  901. font-size: 15px;
  902. width: 20px;
  903. text-align: center;
  904. padding-left: 0px;
  905. padding-right: 2px;
  906. }
  907. .item-title {
  908. color: #909399;
  909. font-size: 15px;
  910. }
  911. .mline-text {
  912. padding-left: 2px;
  913. width: 100%;
  914. /* background-color:#909399; */
  915. height: 100px;
  916. border: 1px solid #FF5A5F;
  917. border-radius: 5px;
  918. }
  919. </style>
  920. <style lang="scss" scoped>
  921. .u-cell-icon {
  922. width: 36rpx;
  923. height: 36rpx;
  924. margin-right: 8rpx;
  925. }
  926. .slot-box {
  927. /* #ifndef APP-NVUE */
  928. display: flex;
  929. /* #endif */
  930. flex-direction: row;
  931. align-items: center;
  932. }
  933. .slot-image {
  934. /* #ifndef APP-NVUE */
  935. display: block;
  936. /* #endif */
  937. margin-right: 10px;
  938. width: 30px;
  939. height: 30px;
  940. }
  941. .slot-text {
  942. flex: 1;
  943. font-size: 14px;
  944. color: #4cd964;
  945. margin-right: 10px;
  946. }
  947. .img-container {
  948. margin-bottom: 20px;
  949. .note-image-box {
  950. margin-top: 5px;
  951. display: flex;
  952. flex-wrap: wrap;
  953. padding: 10px;
  954. .note-image-item {
  955. position: relative;
  956. width: 33.3%;
  957. height: 0;
  958. padding-top: 33.3%;
  959. box-sizing: border-box;
  960. // background-color: #18B566;
  961. .close-icon {
  962. display: flex;
  963. justify-content: center;
  964. align-items: center;
  965. position: absolute;
  966. right: 0px;
  967. top: 0px;
  968. width: 22px;
  969. height: 22px;
  970. border-radius: 50%;
  971. background-color: #d5d5d5;
  972. z-index: 2;
  973. }
  974. .image-box {
  975. display: flex;
  976. justify-content: center;
  977. align-items: center;
  978. position: absolute;
  979. top: 5px;
  980. right: 5px;
  981. border: 5px;
  982. left: 5px;
  983. border: 1px #eee solid;
  984. border-radius: 5px;
  985. overflow: hidden;
  986. width: 95%;
  987. height: 95%;
  988. }
  989. }
  990. }
  991. }
  992. </style>