collisionMouth.vue 16 KB

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