collisionMouth.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <scroll-view>
  3. <view class="background">
  4. <view class="uni-list">
  5. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  6. <view>
  7. 工程名称
  8. </view>
  9. <view v-if="this.isEmpty(this.projectName)" style="margin-top: 10;" @click="pickerShow('gcmc',0)">
  10. <span style="color: darkgray;">请选择工程名称</span>
  11. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  12. </view>
  13. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('gcmc',0)">
  14. <span style="color: black;">{{projectName}}</span>
  15. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="uni-list">
  20. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  21. <text>地点</text>
  22. <input class="uni-input" v-model="locations" disabled="true"
  23. style="margin-left: 10px;text-align: right;"></input>
  24. </view>
  25. </view>
  26. <SelectPicker :list="selectList" @change="changeSelect" v-if="open" @close="close" titleKey="name"
  27. subtitleKey="id" v-model="name"></SelectPicker>
  28. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  29. titleKey="dictLabel" subtitleKey="dictValue" v-model="dictLabel"></SelectPicker>
  30. </view>
  31. <view class="background">
  32. <view>
  33. <view class="uni-list">
  34. <view
  35. style="font-size: 16px;margin-left: 10px;margin-top: 10px;display: flex; justify-content: space-between;margin-bottom: 10px;">
  36. {{objValue.value}}
  37. <span
  38. style="color: blue;font-size: 14px; display: flex;justify-content:flex-end; margin-right: 10px;"
  39. @click="history">历史</span>
  40. </view>
  41. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  42. <view>
  43. 施工时间
  44. </view>
  45. <view @click="openDatetimePicker()">
  46. <span style="color: black;">{{time}}</span>
  47. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  48. </view>
  49. </view>
  50. <view class="uni-list" v-if="objValue.value=='管道压力'||objValue.value=='原有管线压力'">
  51. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  52. <text>{{objValue.value}}</text>
  53. <input class="uni-input" type="digit" v-model="pipePressure" :placeholder="placeholder"
  54. maxlength="100" style="margin-left: 10px;text-align: right;"></input>
  55. </view>
  56. </view>
  57. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  58. <view class="uni-common-mt" style="width: 100%;">
  59. <text class="uni-title uni-common-pl">施工内容</text>
  60. <view style="width: 100%;box-sizing: border-box;">
  61. <textarea class="textarea" placeholder="请输入施工内容" maxlength="255"
  62. placeholder-style="padding: 10rpx;"
  63. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  64. auto-height v-model="projectContent"></textarea>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  69. <view class="container" style="color: #b2b2b2;">*请上传照片</view>
  70. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  71. <image :src="loadImgSrc('updateimg.png')" mode=""
  72. style="width: 200rpx; height: 150rpx; margin: 0 12rpx;; " @click="choose('other')">
  73. </image>
  74. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  75. <view
  76. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg'||item.substring(item.length-4)=='jpeg' ">
  77. <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  78. @click="showPhoto(index,'other')">
  79. </image>
  80. </view>
  81. <view v-else>
  82. <video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
  83. </view>
  84. <view @click="remove(index,'other')"
  85. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  86. <image :src="loadImgSrc('icon_close.png')" style=" width: 15px; height: 15px;">
  87. </image>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="action-btn">
  96. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  97. </view>
  98. <bottom-sheet ref="refShare" :data="historyList" :TitleType="objValue.value"></bottom-sheet>
  99. <yt-dateTimePicker ref="myPicker" @submit="handleSubmit" :start-year="2024" :end-year="2099"
  100. :time-hide="[true, true, true, true, true, true]" :time-label="['年', '月', '日', '时', '分', '秒']" />
  101. </scroll-view>
  102. </template>
  103. <script>
  104. import SelectPicker from '../../components/selectPicker/select_picker.vue'
  105. import bottomSheet from '../../components/bottomSheet/bottomSheetMoreNew.vue'
  106. import {
  107. getDicts
  108. } from "@/api/system/dict/data";
  109. import {
  110. SubmitMouth,
  111. getProjectName,
  112. getHistoryMouthDetails,
  113. } from '@/api/common'
  114. import {
  115. getToken
  116. } from '../../utils/auth';
  117. export default {
  118. components: {
  119. SelectPicker,
  120. bottomSheet,
  121. },
  122. data() {
  123. return {
  124. historyList: {}, //历史数据
  125. show_loding: false,
  126. popupText: '', //对话框内容
  127. titleText: '',
  128. cancelText: '',
  129. confirmText: '',
  130. conLists: [],
  131. headers: {
  132. Authorization: "Bearer " + getToken()
  133. },
  134. time: '', //施工时间
  135. loading: false,
  136. loadingFile: false,
  137. open: false,
  138. objValue: '', //上一页面传过来的值 新增接口用
  139. openDict: false,
  140. projectContent: '', //施工内容
  141. selectList: [],
  142. dictOptions: [],
  143. imgArr: [],
  144. type: '',
  145. projectName: '', //工程名称
  146. createTime: '',
  147. address: '',
  148. imgHtqArr: [],
  149. imgJspsArr: [],
  150. imgHthArr: [],
  151. pipePressure: '',
  152. placeholder: '',
  153. //新
  154. createBy: '',
  155. createTime: '',
  156. updateBy: '',
  157. updateTime: '',
  158. updateInfoTime: '',
  159. id: '',
  160. modeOperation: '',
  161. enginName: '',
  162. locations: '',
  163. remark: '',
  164. }
  165. },
  166. created() {
  167. this.time = this.traversalTime(new Date().getTime()) //在data里定义变量-nowTime
  168. },
  169. onLoad(options) {
  170. if ('params' in options) {
  171. this.objValue = JSON.parse(decodeURIComponent(options.params));
  172. this.placeholder = '请输入' + this.objValue.value;
  173. }
  174. },
  175. methods: {
  176. //判断是否选择
  177. isEmpty(str) {
  178. return (!str || 0 === str.length);
  179. },
  180. handleSubmit(e) {
  181. this.time = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
  182. },
  183. //获取当前时间
  184. traversalTime(timestamp) {
  185. //timestamp(时间戳)是整数,否则要parseInt转换
  186. let time = new Date(timestamp);
  187. let y = time.getFullYear();
  188. let m = time.getMonth() + 1;
  189. let d = time.getDate();
  190. let h = time.getHours();
  191. let mm = time.getMinutes();
  192. let s = time.getSeconds();
  193. return y + '-' + this.addTimes(m) + '-' + this.addTimes(d) + ' ' + this.addTimes(h) + ':' + this.addTimes(
  194. mm) + ':' + this.addTimes(s);
  195. },
  196. addTimes(m) {
  197. return m < 10 ? '0' + m : m
  198. },
  199. // 打开picker
  200. openDatetimePicker() {
  201. this.$refs.myPicker.show();
  202. },
  203. // 关闭picker
  204. closeDatetimePicker() {
  205. this.$refs.myPicker.hide();
  206. },
  207. pickerShow(e, index) {
  208. this.SelectIndex = index;
  209. this.type = e; //赋值类型
  210. if (e == 'gcmc') { //工程名称
  211. this.open = true;
  212. //请求
  213. getProjectName(this.objValue.title, "1", '999999').then(response => {
  214. let result = JSON.parse(JSON.stringify(response.rows).replace(/enginName/g, 'name'));
  215. this.selectList = result;
  216. });
  217. }
  218. },
  219. showPhotoFile(index) {
  220. uni.previewImage({
  221. current: index,
  222. urls: this.fileImageArr,
  223. })
  224. },
  225. showPhoto(index, e) {
  226. let typeArr = [];
  227. let newArr = [];
  228. if (e == 'other') {
  229. typeArr = this.imgArr;
  230. }
  231. typeArr.forEach((item, index) => {
  232. if (item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ||
  233. item.substring(item.length - 4) == 'jpeg') {
  234. newArr.push(item)
  235. }
  236. });
  237. uni.previewImage({
  238. current: index,
  239. urls: newArr,
  240. })
  241. },
  242. remove(index, e) {
  243. let _this = this;
  244. uni.showModal({
  245. title: '提示',
  246. content: '是否删除该图片或视频?',
  247. success: (res) => {
  248. if (res.confirm) {
  249. if (e == 'other') {
  250. _this.imgArr.splice(index, 1)
  251. }
  252. }
  253. }
  254. })
  255. },
  256. choose(e) {
  257. let _this = this;
  258. uni.showActionSheet({
  259. title: '上传',
  260. itemList: ['图片', '视频'],
  261. success: (res) => {
  262. if (res.tapIndex == 0) {
  263. this.chooseimage(e)
  264. } else {
  265. this.choosevideo(e)
  266. }
  267. }
  268. })
  269. },
  270. chooseimage(e) {
  271. let _this = this;
  272. uni.chooseImage({
  273. sizeType: ['album', 'camera'],
  274. success(resp) {
  275. resp.tempFiles.forEach((item, index) => {
  276. const task = uni.uploadFile({
  277. url: _this.$HTTP + `/obs`,
  278. filePath: item.path,
  279. name: 'file',
  280. formData: {},
  281. header: _this.headers,
  282. success: res => {
  283. let data = JSON.parse(res.data);
  284. if (![200].includes(data.code)) {
  285. _this.$modal.msg(data.msg)
  286. } else {
  287. if (_this.progress === 100) {
  288. if (e == 'other') {
  289. _this.imgArr.push(data.data.url)
  290. }
  291. _this.$modal.msg('上传成功!')
  292. }
  293. }
  294. },
  295. fail: e => {
  296. _this.$modal.msg('上传失败!')
  297. },
  298. complete: res => {
  299. uni.hideLoading();
  300. _this.uploading = false;
  301. }
  302. });
  303. task.onProgressUpdate(res => {
  304. _this.progress = res.progress;
  305. uni.showLoading({
  306. title: '上传中'
  307. })
  308. if (_this.progress != 100) {
  309. _this.loading = false
  310. } else {
  311. _this.loading = true
  312. }
  313. });
  314. })
  315. },
  316. })
  317. },
  318. choosevideo(e) {
  319. let _this = this;
  320. uni.chooseVideo({
  321. sourceType: ['album', 'camera'],
  322. maxDuration: 30,
  323. success(resp) {
  324. const task = uni.uploadFile({
  325. url: _this.$HTTP + `/obs`,
  326. filePath: resp.tempFilePath,
  327. name: 'file',
  328. formData: {},
  329. header: _this.headers,
  330. success: res => {
  331. // 判断是否json字符串,将其转为json格式
  332. let data = JSON.parse(res.data);
  333. if (![200].includes(res.statusCode)) {
  334. this.uploadError(index, data);
  335. } else {
  336. //上传成功
  337. if (_this.progress === 100) {
  338. if (e == 'other') {
  339. _this.imgArr.push(data.data.url)
  340. }
  341. _this.$modal.msg('上传成功!')
  342. //_this.photo = false;
  343. }
  344. }
  345. },
  346. fail: e => {
  347. _this.$modal.msg('上传失败!')
  348. this.uploadError(index, e);
  349. },
  350. complete: res => {
  351. uni.hideLoading();
  352. _this.uploading = false;
  353. }
  354. });
  355. task.onProgressUpdate(res => {
  356. _this.progress = res.progress;
  357. uni.showLoading({
  358. title: '上传中'
  359. })
  360. if (_this.progress != 100) {
  361. _this.loadingFile = false
  362. } else {
  363. _this.loadingFile = true
  364. }
  365. });
  366. },
  367. })
  368. },
  369. changeSelectDict(item, index) {
  370. this.openDict = false;
  371. // this.projectName = ''; //重置工程名称
  372. // this.createTime = '';
  373. },
  374. changeSelect(item, index) {
  375. this.open = false;
  376. if (this.type == 'gcmc') {
  377. this.projectName = item.name;
  378. this.createBy = item.createBy;
  379. this.createTime = item.createTime;
  380. this.updateBy = item.updateBy;
  381. this.updateTime = item.updateTime;
  382. this.updateInfoTime = item.updateInfoTime;
  383. this.id = item.id;
  384. this.modeOperation = item.modeOperation;
  385. this.enginName = item.name;
  386. this.locations = item.locations;
  387. this.remark = item.remark;
  388. }
  389. },
  390. //关闭弹窗
  391. close(e) {
  392. this.open = false
  393. },
  394. //关闭弹窗
  395. closeDict(e) {
  396. this.openDict = false
  397. },
  398. //历史
  399. history() {
  400. if (this.isEmpty(this.projectName)) {
  401. this.$modal.msg('请选择工程名称')
  402. return
  403. }
  404. getHistoryMouthDetails(this.id, this.objValue.value).then(response => {
  405. this.historyList = response.data
  406. if (response.data.zEngineeringNodeBo != null) {
  407. this.$refs.refShare.handleShowShare();
  408. } else {
  409. this.$modal.msg("暂无历史信息")
  410. }
  411. });
  412. },
  413. submit() {
  414. if (this.isEmpty(this.projectName)) {
  415. this.$modal.msg('请选择工程名称')
  416. return
  417. }
  418. if (this.objValue.value == '原有管线压力' || this.objValue.value == '管道压力') {
  419. if (this.isEmpty(this.pipePressure)) {
  420. this.$modal.msg(this.placeholder)
  421. return
  422. }
  423. }
  424. if (this.imgArr.length <= 0) {
  425. this.$modal.msg('请上传照片或视频')
  426. return
  427. }
  428. if (this.loading == false) {
  429. this.$modal.msg('照片或视频未上传完毕,无法提交!')
  430. return
  431. }
  432. let param = {
  433. createBy: this.createBy,
  434. createTime: this.createTime,
  435. updateBy: this.updateBy,
  436. updateTime: this.updateTime,
  437. updateInfoTime: this.updateInfoTime,
  438. id: this.id,
  439. modeOperation: this.modeOperation,
  440. enginName: this.projectName,
  441. locations: this.locations,
  442. remark: this.remark,
  443. zEngineeringNodeBoList: [{
  444. type: this.objValue.value,
  445. zEngineeringInfoBo: {
  446. constructTime: this.time,
  447. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  448. remark: this.projectContent,
  449. constructAccordingDrawings: this.pipePressure,
  450. constructAddre: this.pipePressure,
  451. }
  452. }]
  453. }
  454. uni.showLoading()
  455. SubmitMouth('new', param).then(res => {
  456. if (res.code == '200') {
  457. uni.hideLoading()
  458. uni.showToast({
  459. title: res.msg,
  460. icon: 'none',
  461. //显示持续时间为 3秒
  462. duration: 2000
  463. });
  464. setTimeout(function() {
  465. uni.navigateBack();
  466. }, 1000)
  467. }
  468. })
  469. }
  470. }
  471. }
  472. </script>
  473. <style lang="scss">
  474. .container {
  475. display: flex;
  476. align-items: center;
  477. justify-content: space-between;
  478. padding: 10px;
  479. position: relative;
  480. }
  481. .uni-list {
  482. border: 1xp solid #eee;
  483. }
  484. .to-right-icon {
  485. width: 15px;
  486. height: 15px;
  487. position: absolute;
  488. top: 50%;
  489. transform: translateY(-50%);
  490. }
  491. .text {
  492. font-size: 16px;
  493. color: #333;
  494. }
  495. .background {
  496. // border: 15px solid hsla(0, 0%, 100%, .5);
  497. background: white;
  498. background-clip: padding-box;
  499. padding: 20rpx;
  500. border-radius: 20rpx;
  501. margin: 20rpx;
  502. /*从padding开始往外面裁剪背景*/
  503. }
  504. .btn {
  505. width: 715rpx;
  506. height: 69rpx;
  507. background: #79A4F0;
  508. border-radius: 6rpx;
  509. font-size: 25rpx;
  510. font-family: Microsoft YaHei;
  511. font-weight: 400;
  512. color: #FFFFFF;
  513. line-height: 69rpx;
  514. margin-top: 40rpx;
  515. margin-bottom: 100rpx;
  516. }
  517. .number {
  518. display: flex;
  519. /* 水平居中显示子元素 */
  520. align-items: flex-start;
  521. /* 垂直居中显示子元素 */
  522. justify-content: space-between;
  523. /* 左右间距等于间距大小 */
  524. padding: 10px;
  525. /* 设置padding以提高视觉效果 */
  526. }
  527. .textarea {
  528. margin-top: 10upx;
  529. width: 100%;
  530. border: 1rpx solid red;
  531. min-height: 100upx;
  532. line-height: 20px;
  533. }
  534. .tj-btn {
  535. height: 69rpx;
  536. background: #3184f0;
  537. border-radius: 6rpx;
  538. font-size: 25rpx;
  539. font-weight: 400;
  540. color: #FFFFFF;
  541. line-height: 69rpx;
  542. margin: 40rpx 70rpx;
  543. }
  544. .sc-btn {
  545. height: 69rpx;
  546. background: #f0686b;
  547. border-radius: 6rpx;
  548. font-size: 25rpx;
  549. font-weight: 400;
  550. color: #FFFFFF;
  551. line-height: 69rpx;
  552. margin: 40rpx;
  553. }
  554. .num-style {
  555. background: #e8f4f9;
  556. margin: 20rpx;
  557. padding: 10rpx;
  558. border-radius: 20rpx;
  559. border: 1px solid #d4e3f0;
  560. }
  561. </style>