daily_log.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <scroll-view>
  3. <view class="background">
  4. <view>
  5. <view class="uni-list">
  6. <view
  7. style="font-size: 16px;margin-left: 10px;margin-top: 10px;display: flex; justify-content: space-between;margin-bottom: 10px;">
  8. {{objValue.enginClassValue}}
  9. <span
  10. style="color: blue;font-size: 14px; display: flex;justify-content:flex-end; margin-right: 10px;"
  11. @click="history">历史</span>
  12. </view>
  13. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  14. <view>
  15. 施工时间
  16. </view>
  17. <view @click="openDatetimePicker('sg')">
  18. <span style="color: black;">{{time}}</span>
  19. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  20. </view>
  21. </view>
  22. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  23. <view class="uni-common-mt" style="width: 100%;">
  24. <text class="uni-title uni-common-pl">施工内容</text>
  25. <view style="width: 100%;box-sizing: border-box;">
  26. <textarea class="textarea" placeholder="请输入施工内容" maxlength="255"
  27. placeholder-style="padding: 10rpx;"
  28. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  29. auto-height v-model="projectContent"></textarea>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  35. <view class="container" style="color: #b2b2b2;">*请上传照片</view>
  36. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  37. <image :src="loadImgSrc('updateimg.png')" mode=""
  38. style="width: 200rpx; height: 150rpx; margin: 0 12rpx;; " @click="choose()"
  39. v-show="reviewStatus!='1'"></image>
  40. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  41. <view
  42. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg'||item.substring(item.length-4)=='jpeg' ">
  43. <image :src="item" mode="" style="width: 200rpx; height: 200rpx; margin: 0 12rpx;"
  44. @click="showPhoto(index)">
  45. </image>
  46. </view>
  47. <view v-else>
  48. <video :src="item" style="width: 200rpx; height: 200rpx; margin: 0 12rpx;"></video>
  49. </view>
  50. <view @click="remove(index)"
  51. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  52. <image :src="loadImgSrc('icon_close.png')" style=" width: 15px; height: 15px;">
  53. </image>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="action-btn" v-show="reviewStatus!='1'">
  61. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  62. </view>
  63. <bottom-sheet ref="refShare" :data="historyList"></bottom-sheet>
  64. <yt-dateTimePicker ref="myPicker" @submit="handleSubmit" :start-year="2024" :end-year="2099"
  65. :time-hide="[true, true, true, true, true, true]" :time-label="['年', '月', '日', '时', '分', '秒']" />
  66. </scroll-view>
  67. </template>
  68. <script>
  69. import bottomSheet from '../../components/bottomSheet/bottomSheet.vue'
  70. import {
  71. getDicts
  72. } from "@/api/system/dict/data";
  73. import {
  74. addTearOldPipe,
  75. } from '@/api/common'
  76. import {
  77. getToken
  78. } from '../../utils/auth';
  79. export default {
  80. components: {
  81. bottomSheet,
  82. },
  83. data() {
  84. return {
  85. headers: {
  86. Authorization: "Bearer " + getToken()
  87. },
  88. reviewStatus: '', //是否可以点击
  89. startDate: '2022-02-04',
  90. endDate: '2025-02-04',
  91. mode: 4,
  92. type: '',
  93. objValue: '', //上一页面传过来的值 新增接口用
  94. imgArr: [],
  95. time: '', //施工时间
  96. timeType: '', //时间类型
  97. showTime: false,
  98. progress: 0, //上传图片进度百分比
  99. loading: false,
  100. title: '',
  101. historyList: {} //历史数据
  102. }
  103. },
  104. created() {
  105. this.time = this.traversalTime(new Date().getTime()) //在data里定义变量-nowTime
  106. },
  107. onLoad(options) {
  108. if ('params' in options) {
  109. this.objValue = JSON.parse(decodeURIComponent(options.params));
  110. }
  111. },
  112. methods: {
  113. // 打开picker
  114. openDatetimePicker(type) {
  115. this.timeType = type;
  116. this.$refs.myPicker.show();
  117. },
  118. // 关闭picker
  119. closeDatetimePicker() {
  120. this.$refs.myPicker.hide();
  121. },
  122. handleSubmit(e) {
  123. if (this.timeType == 'ht') {
  124. this.BackfillingTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
  125. } else {
  126. this.time = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
  127. }
  128. },
  129. //获取当前时间
  130. traversalTime(timestamp) {
  131. //timestamp(时间戳)是整数,否则要parseInt转换
  132. let time = new Date(timestamp);
  133. let y = time.getFullYear();
  134. let m = time.getMonth() + 1;
  135. let d = time.getDate();
  136. let h = time.getHours();
  137. let mm = time.getMinutes();
  138. let s = time.getSeconds();
  139. return y + '-' + this.addTimes(m) + '-' + this.addTimes(d) + ' ' + this.addTimes(h) + ':' + this.addTimes(
  140. mm) + ':' + this.addTimes(s);
  141. },
  142. addTimes(m) {
  143. return m < 10 ? '0' + m : m
  144. },
  145. //判断是否选择
  146. isEmpty(str) {
  147. return (!str || 0 === str.length);
  148. },
  149. // 显示历史弹窗
  150. handleShowSheet() {
  151. this.shareState = true;
  152. },
  153. // 隐藏历史弹窗
  154. handleHiddenShare() {
  155. this.shareState = false;
  156. },
  157. showPhoto(index) {
  158. uni.previewImage({
  159. current: index,
  160. urls: this.imgArr,
  161. })
  162. },
  163. remove(index) {
  164. uni.showModal({
  165. title: '提示',
  166. content: '是否删除该图片或视频?',
  167. success: (res) => {
  168. if (res.confirm) {
  169. this.imgArr.splice(index, 1)
  170. if (this.imgArr.length <= 0) {
  171. this.photo = true;
  172. }
  173. }
  174. }
  175. })
  176. },
  177. choose() {
  178. let _this = this;
  179. uni.showActionSheet({
  180. title: '上传',
  181. itemList: ['图片', '视频'],
  182. success: (res) => {
  183. if (res.tapIndex == 0) {
  184. this.chooseimage()
  185. } else {
  186. this.choosevideo()
  187. }
  188. }
  189. })
  190. },
  191. chooseimage() {
  192. let _this = this;
  193. uni.chooseImage({
  194. sizeType: ['album', 'camera'],
  195. success(resp) {
  196. resp.tempFiles.forEach((item, index) => {
  197. const task = uni.uploadFile({
  198. url: _this.$HTTP + `/obs`,
  199. filePath: item.path,
  200. name: 'file',
  201. formData: {},
  202. header: _this.headers,
  203. success: res => {
  204. // 判断是否json字符串,将其转为json格式
  205. // let data = _this.$u.test.jsonString(res
  206. // .data) ? JSON.parse(res.data) : res.data;
  207. let data = JSON.parse(res.data);
  208. if (![200].includes(data.code)) {
  209. // this.uploadError(index, data);
  210. _this.$modal.msg(data.msg)
  211. } else {
  212. if (_this.progress === 100) {
  213. _this.imgArr.push(data.data.url)
  214. _this.$modal.msg('上传成功!')
  215. _this.photo = false;
  216. }
  217. }
  218. },
  219. fail: e => {
  220. _this.$modal.msg('上传失败!')
  221. //_this.uploadError(index, e);
  222. },
  223. complete: res => {
  224. uni.hideLoading();
  225. _this.uploading = false;
  226. }
  227. });
  228. task.onProgressUpdate(res => {
  229. _this.progress = res.progress;
  230. uni.showLoading({
  231. title: '上传中'
  232. })
  233. if (_this.progress != 100) {
  234. _this.loading = false
  235. } else {
  236. _this.loading = true
  237. }
  238. });
  239. })
  240. },
  241. })
  242. },
  243. choosevideo() {
  244. let _this = this;
  245. uni.chooseVideo({
  246. sourceType: ['album', 'camera'],
  247. maxDuration: 60,
  248. success(resp) {
  249. const task = uni.uploadFile({
  250. url: _this.$HTTP + `/obs`,
  251. filePath: resp.tempFilePath,
  252. name: 'file',
  253. formData: {},
  254. header: _this.headers,
  255. success: res => {
  256. // 判断是否json字符串,将其转为json格式
  257. let data = JSON.parse(res.data);
  258. if (![200].includes(res.statusCode)) {
  259. this.uploadError(index, data);
  260. } else {
  261. //上传成功
  262. if (_this.progress === 100) {
  263. _this.imgArr.push(data.data.url)
  264. _this.$modal.msg('上传成功!')
  265. _this.photo = false;
  266. }
  267. }
  268. },
  269. fail: e => {
  270. _this.$modal.msg('上传失败!')
  271. this.uploadError(index, e);
  272. },
  273. complete: res => {
  274. uni.hideLoading();
  275. _this.uploading = false;
  276. }
  277. });
  278. task.onProgressUpdate(res => {
  279. _this.progress = res.progress;
  280. uni.showLoading({
  281. title: '上传中'
  282. })
  283. if (_this.progress != 100) {
  284. _this.loading = false
  285. } else {
  286. _this.loading = true
  287. }
  288. });
  289. },
  290. })
  291. },
  292. //提交数据
  293. submit() {
  294. if (this.imgArr.length <= 0) {
  295. this.$modal.msg('请上传照片或视频')
  296. return
  297. }
  298. if (this.loading == false) {
  299. this.$modal.msg('照片或视频未上传完毕,无法提交!')
  300. return
  301. }
  302. //提交
  303. this.onsubmit();
  304. },
  305. onsubmit() {
  306. //提交
  307. let param = {
  308. enginType: this.objValue.enginType, //写死 上一页面传过来的 新建/旧改
  309. enginClassification: this.objValue.enginClassification, //写死 上一页面传过来的 //室内 - 庭院 - 架空
  310. enginCycle: this.projectValue.dictValue, //工程周期
  311. zEngineeringNodeBo: {
  312. type: this.objValue.enginClassValue, //写死 上一页面传过来的 (拆旧管等 字典值)
  313. zEngineeringInfoBo: {
  314. //constructAccordingDrawings: this.isCheck, //是否按图纸施工
  315. segmentedCompressionQualified: this.isOkValue, // 分段打压是否台格
  316. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  317. constructTime: this.time, //施工时间
  318. backfillTime: this.BackfillingTime, // 回填时间
  319. remark: this.projectContent, //施工内容
  320. // headName: this.user.nickName, // 负责人名称
  321. // headPhone: this.user.phonenumber, // 负责人电话
  322. zEngineeringMaterialBo: [{
  323. materialQuality: this.materialValue.id, //材质
  324. specifications: this.specificationValue.id, //规格
  325. number: this.inputNumberValue //数量
  326. }]
  327. }
  328. }
  329. }
  330. uni.showLoading()
  331. addTearOldPipe(param).then(res => {
  332. if (res.code == '200') {
  333. uni.hideLoading()
  334. uni.showToast({
  335. title: res.msg,
  336. icon: 'none',
  337. //显示持续时间为 3秒
  338. duration: 2000
  339. });
  340. setTimeout(function() {
  341. uni.navigateBack();
  342. }, 1000)
  343. }
  344. //this.$modal.closeLoading()
  345. })
  346. },
  347. history() {
  348. let param = {
  349. enginType: this.objValue.enginType, //写死 上一页面传过来的 新建/旧改
  350. enginClassification: this.objValue.enginClassification, //写死 上一页面传过来的 //室内 - 庭院 - 架空
  351. }
  352. getRoomProjectId(param).then(res => {
  353. if (res.code == '200') {
  354. if (res.data != null) {
  355. getRoomProjectList(res.data.id, this.objValue.enginClassValue).then(
  356. res => {
  357. this.historyList = res.data
  358. if (res.data.zEngineeringNodeBo != null) {
  359. this.showHistoryList();
  360. } else {
  361. this.$modal.msg("暂无历史信息")
  362. }
  363. })
  364. } else {
  365. this.$modal.msg("暂无工程信息")
  366. }
  367. } else {
  368. this.$modal.msg(res.msg)
  369. }
  370. })
  371. },
  372. showHistoryList() {
  373. this.$refs.refShare.handleShowShare();
  374. }
  375. }
  376. }
  377. </script>
  378. <style lang="scss">
  379. .container {
  380. display: flex;
  381. align-items: center;
  382. justify-content: space-between;
  383. padding: 10px;
  384. position: relative;
  385. }
  386. .uni-list {
  387. border: 1xp solid #eee;
  388. }
  389. .to-right-icon {
  390. width: 15px;
  391. height: 15px;
  392. position: absolute;
  393. top: 50%;
  394. transform: translateY(-50%);
  395. }
  396. .text {
  397. font-size: 16px;
  398. color: #333;
  399. }
  400. .background {
  401. // border: 15px solid hsla(0, 0%, 100%, .5);
  402. background: white;
  403. background-clip: padding-box;
  404. padding: 20rpx;
  405. border-radius: 20rpx;
  406. margin: 20rpx;
  407. /*从padding开始往外面裁剪背景*/
  408. }
  409. .btn {
  410. width: 715rpx;
  411. height: 69rpx;
  412. background: #79A4F0;
  413. border-radius: 6rpx;
  414. font-size: 25rpx;
  415. font-family: Microsoft YaHei;
  416. font-weight: 400;
  417. color: #FFFFFF;
  418. line-height: 69rpx;
  419. margin-top: 40rpx;
  420. margin-bottom: 100rpx;
  421. }
  422. .number {
  423. display: flex;
  424. /* 水平居中显示子元素 */
  425. align-items: flex-start;
  426. /* 垂直居中显示子元素 */
  427. justify-content: space-between;
  428. /* 左右间距等于间距大小 */
  429. padding: 10px;
  430. /* 设置padding以提高视觉效果 */
  431. }
  432. .textarea {
  433. margin-top: 10upx;
  434. width: 100%;
  435. border: 1rpx solid red;
  436. min-height: 100upx;
  437. line-height: 20px;
  438. }
  439. </style>