historyDetailsTopTube.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. <template>
  2. <view>
  3. <view class="uni-media-list">
  4. <view class="uni-media-list-body">
  5. <view v-for="(value, key) in dataJson.zEngineeringNodeBo.zEngineeringInfoBoList" :key="key"
  6. v-if="isEdit(value)">
  7. <view class="uni-media-list-text-top">
  8. <view class="tit-text">施工时间:</view>{{value.updateTime}}
  9. </view>
  10. <view class="uni-media-list-text-top">
  11. <view class="uni-common-mt" style="width: 100%;">
  12. <text class="tit-text" style=" font-size: 13px;color:
  13. #000;margin-top: 5px;">施工内容:</text>
  14. <view style="width: 100%;box-sizing: border-box;">
  15. <textarea class="textarea" maxlength="255" placeholder-style="padding: 10rpx;"
  16. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  17. auto-height :value="value.remark"
  18. @blur="bindTextAreaBlur($event.target.value,key)"></textarea>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="cz-style" v-for="(a,index) in value.zEngineeringMaterialBo" :key="index">
  23. <view class="uni-media-list-text-top" style=" ">
  24. <view class="tit-text">材质:</view>
  25. <view class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('cz',key,index)">
  26. <span
  27. style="color: black;">{{a.materialQualityName==''?'请选择材质':a.materialQualityName}}</span>
  28. </view>
  29. </view>
  30. <view class="uni-media-list-text-top" style=" ">
  31. <view class="tit-text">规格:</view>
  32. <view class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('gg',key,index)">
  33. <span
  34. style="color: black;">{{a.specificationsName==''?'请选择规格':a.specificationsName}}</span>
  35. </view>
  36. </view>
  37. <view class="uni-media-list-text-top" style="border-bottom: 1px solid #f8f8f8;">
  38. <text class="tit-text">米 数</text>
  39. <view style="display: flex; justify-content: right; width: 70%;">
  40. <input class="uni-input" type="number" :value="getIntegerPart(a.number,0)"
  41. @change="setInfoBoNumber(key,index,$event.target.value,0)" maxlength="6"
  42. style="text-align: center; border: 1px solid #00aaff; border-radius: 20rpx;"></input>
  43. <text style="font-weight:bold;margin-left: 10px;margin-right: 10px;">.</text>
  44. <input class="uni-input" type="number" :value="getIntegerPart(a.number,1)"
  45. @change="setInfoBoNumber(key,index,$event.target.value,1)" maxlength="1"
  46. style="text-align: center; border: 1px solid #00aaff; border-radius: 20rpx;"></input>
  47. </view>
  48. </view>
  49. <button v-if="index!=0" @click="btnDel(key,index)" class="sc-btn">删除</button>
  50. </view>
  51. <button @click="btnAdd(key,index)" class="tj-btn">添加</button>
  52. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  53. <image :src="loadImgSrc('updateimg.png')" mode=""
  54. style="width: 200rpx; height: 150rpx; margin: 0 12rpx;; " @click="choose(key)">
  55. </image>
  56. <view v-for="(item,index) in value.zEngiineeringPhotoBoList" :key="index"
  57. style="position: relative;">
  58. <view
  59. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg'||item.substring(item.length-4)=='jpeg' ">
  60. <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  61. @click="showPhoto(index,value.zEngiineeringPhotoBoList)">
  62. </image>
  63. </view>
  64. <view v-else>
  65. <video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
  66. </view>
  67. <view @click="remove(index,key)"
  68. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  69. <image :src="loadImgSrc('icon_close.png')" style=" width: 15px; height: 15px;">
  70. </image>
  71. </view>
  72. </view>
  73. </view>
  74. <!-- </view> -->
  75. </view>
  76. </view>
  77. </view>
  78. <SelectPicker :list="selectList" @change="changeSelect" v-if="open" @close="close" titleKey="name"
  79. subtitleKey="id">
  80. </SelectPicker>
  81. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  82. titleKey="dictLabel" subtitleKey="dictValue" v-model="name"></SelectPicker>
  83. <view class="action-btn" v-if="hideButton==false">
  84. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认</button>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import SelectPicker from '../../components/selectPicker/select_picker.vue'
  90. import {
  91. getDicts
  92. } from "@/api/system/dict/data";
  93. import {
  94. getToken
  95. } from '../../utils/auth';
  96. import user from '@/store/modules/user'
  97. import {
  98. getHistoryTopTubeDetails,
  99. getEnginMaterialQualityList,
  100. PutTopPipeWork,
  101. getEnginSpecificationsList,
  102. } from '@/api/common'
  103. export default {
  104. components: {
  105. SelectPicker,
  106. },
  107. data() {
  108. return {
  109. selectZbfList: [],
  110. dictOptions: [],
  111. openDict: false,
  112. dataIndex: 0, //数据用第几条
  113. selectIndex: 0, //材质规格用的第几条
  114. imageIndex: 0,
  115. headers: {
  116. Authorization: "Bearer " + getToken()
  117. },
  118. nodeId: '',
  119. type: '',
  120. title: '',
  121. dataJson: '',
  122. enginClassification: '',
  123. enginType: '',
  124. enginClassValue: '',
  125. selectList: [],
  126. open: false,
  127. chooseType: '',
  128. hideButton: false,
  129. roomId: '',
  130. newPhone: []
  131. }
  132. },
  133. onLoad(options) {
  134. if ('params' in options) {
  135. let e = JSON.parse(decodeURIComponent(options.params));
  136. this.nodeId = e.id;
  137. this.type = e.type;
  138. getHistoryTopTubeDetails(this.nodeId, this.type).then(response => {
  139. if (response.data.zEngineeringNodeBo != null) {
  140. let flag = false;
  141. for (let i in response.data.zEngineeringNodeBo.zEngineeringInfoBoList) {
  142. if (response.data.zEngineeringNodeBo.zEngineeringInfoBoList[i].createBy == this.$user
  143. .state.name) {
  144. flag = true;
  145. break;
  146. }
  147. }
  148. if (flag) {
  149. this.hideButton = false;
  150. this.dataJson = response.data;
  151. this.title = response.data.zEngineeringNodeBo.type;
  152. this.enginType = response.data.enginType;
  153. this.enginClassification = response.data.enginClassification;
  154. } else {
  155. this.hideButton = true;
  156. this.$modal.msg("暂无本人历史信息")
  157. }
  158. } else {
  159. this.hideButton = true;
  160. this.$modal.msg("暂无历史信息")
  161. }
  162. });
  163. }
  164. },
  165. methods: {
  166. //关闭弹窗
  167. closeDict(e) {
  168. this.openDict = false
  169. },
  170. btnAdd(key, index) {
  171. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[key].zEngineeringMaterialBo.push({
  172. 'materialQuality': '',
  173. 'materialQualityName': '',
  174. 'number': '',
  175. 'specifications': '',
  176. 'specificationsName': ''
  177. });
  178. },
  179. btnDel(key, index) {
  180. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[key].zEngineeringMaterialBo.splice(index, 1);
  181. },
  182. remove(index, key) {
  183. uni.showModal({
  184. title: '提示',
  185. content: '是否删除该图片或视频?',
  186. success: (res) => {
  187. if (res.confirm) {
  188. this.dataJson.zEngineeringNodeBo
  189. .zEngineeringInfoBoList[key]
  190. .zEngiineeringPhotoBoList.splice(index, 1)
  191. }
  192. }
  193. })
  194. },
  195. choose(index1, index) {
  196. this.dataIndex = index1;
  197. let _this = this;
  198. uni.showActionSheet({
  199. title: '上传',
  200. itemList: ['图片', '视频'],
  201. success: (res) => {
  202. if (res.tapIndex == 0) {
  203. this.chooseimage()
  204. } else {
  205. this.choosevideo()
  206. }
  207. }
  208. })
  209. },
  210. chooseimage() {
  211. let _this = this;
  212. uni.chooseImage({
  213. sizeType: ['album', 'camera'],
  214. success(resp) {
  215. resp.tempFiles.forEach((item, index) => {
  216. const task = uni.uploadFile({
  217. url: _this.$HTTP + `/obs`,
  218. filePath: item.path,
  219. name: 'file',
  220. formData: {},
  221. header: _this.headers,
  222. success: res => {
  223. let data = JSON.parse(res.data);
  224. if (![200].includes(data.code)) {
  225. _this.$modal.msg(data.msg)
  226. } else {
  227. if (_this.progress === 100) {
  228. _this.dataJson.zEngineeringNodeBo
  229. .zEngineeringInfoBoList[_this.dataIndex]
  230. .zEngiineeringPhotoBoList.push(data.data.url);
  231. _this.$modal.msg('上传成功!')
  232. _this.photo = false;
  233. }
  234. }
  235. },
  236. fail: e => {
  237. _this.$modal.msg('上传失败!')
  238. },
  239. complete: res => {
  240. uni.hideLoading();
  241. _this.uploading = false;
  242. }
  243. });
  244. task.onProgressUpdate(res => {
  245. _this.progress = res.progress;
  246. uni.showLoading({
  247. title: '上传中'
  248. })
  249. if (_this.progress != 100) {
  250. _this.loading = false
  251. } else {
  252. _this.loading = true
  253. }
  254. });
  255. })
  256. },
  257. })
  258. },
  259. bindTextAreaBlur(e, index) {
  260. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[index].remark = e;
  261. },
  262. choosevideo() {
  263. let _this = this;
  264. uni.chooseVideo({
  265. sourceType: ['album', 'camera'],
  266. maxDuration: 30,
  267. success(resp) {
  268. const task = uni.uploadFile({
  269. url: _this.$HTTP + `/obs`,
  270. filePath: resp.tempFilePath,
  271. name: 'file',
  272. formData: {},
  273. header: _this.headers,
  274. success: res => {
  275. let data = JSON.parse(res.data);
  276. if (![200].includes(res.statusCode)) {
  277. this.uploadError(index, data);
  278. } else {
  279. //上传成功
  280. if (_this.progress === 100) {
  281. _this.dataJson.zEngineeringNodeBo
  282. .zEngineeringInfoBoList[_this.dataIndex]
  283. .zEngiineeringPhotoBoList.push(data.data.url);
  284. _this.$modal.msg('上传成功!')
  285. _this.photo = false;
  286. }
  287. }
  288. },
  289. fail: e => {
  290. _this.$modal.msg('上传失败!')
  291. this.uploadError(index, e);
  292. },
  293. complete: res => {
  294. uni.hideLoading();
  295. _this.uploading = false;
  296. }
  297. });
  298. task.onProgressUpdate(res => {
  299. _this.progress = res.progress;
  300. uni.showLoading({
  301. title: '上传中'
  302. })
  303. if (_this.progress != 100) {
  304. _this.loading = false
  305. } else {
  306. _this.loading = true
  307. }
  308. });
  309. },
  310. })
  311. },
  312. showPhoto(index, arr) {
  313. // uni.previewImage({
  314. // current: index,
  315. // urls: arr,
  316. // })
  317. let newArr = [];
  318. arr.forEach((item, index) => {
  319. if (item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ||
  320. item.substring(item.length - 4) == 'jpeg') {
  321. newArr.push(item)
  322. }
  323. });
  324. uni.previewImage({
  325. current: index,
  326. urls: newArr,
  327. })
  328. },
  329. //关闭弹窗
  330. close(e) {
  331. this.open = false
  332. },
  333. // 截取小数点前的字符串
  334. getIntegerPart(numStr, i) {
  335. return numStr.toString().split('.')[i] == undefined ? '0' : numStr.toString().split('.')[i];
  336. },
  337. setInfoBoNumber(key, index, number, i) {
  338. let Ynumber = this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[key].zEngineeringMaterialBo[index]
  339. .number;
  340. let resAry = Ynumber.toString().split('.');
  341. resAry[i] = number
  342. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[key].zEngineeringMaterialBo[index].number = resAry
  343. .join('.');
  344. },
  345. changeSelectDict(item, index) {
  346. this.openDict = false;
  347. if (this.chooseType == 'door') {
  348. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[0]
  349. .visitType = item.dictValue;
  350. }
  351. },
  352. pickerShow(e, index, indexTwo) {
  353. this.dataIndex = index;
  354. this.selectIndex = indexTwo; //材质规格 第几条
  355. this.chooseType = e;
  356. if (e == 'cz') {
  357. this.open = true;
  358. // if (this.type == '阀管') {
  359. // getEnginMaterialQualityList("民用工程", this.enginType, this.enginClassification, this.title, "灶具管厂家")
  360. // .then(response => {
  361. // this.selectList = response.data;
  362. // });
  363. // } else {
  364. this.getFSDJLevel();
  365. // }
  366. }
  367. if (e == 'gg') {
  368. if (this.isEmpty(this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex]
  369. .zEngineeringMaterialBo[this.selectIndex].materialQuality)) {
  370. this.$modal.msg('请选择材质')
  371. } else {
  372. this.open = true;
  373. getEnginSpecificationsList(this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex]
  374. .zEngineeringMaterialBo[this.selectIndex].materialQuality).then(res => {
  375. this.selectList = res.data
  376. })
  377. }
  378. }
  379. },
  380. isEmpty(str) {
  381. return (!str || 0 === str.length);
  382. },
  383. changeSelect(item, index) {
  384. this.open = false;
  385. if (this.chooseType == 'cz') {
  386. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[this
  387. .selectIndex]
  388. .materialQuality = item.id;
  389. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[this
  390. .selectIndex]
  391. .materialQualityName = item.name;
  392. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[this
  393. .selectIndex]
  394. .specifications = '';
  395. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[this
  396. .selectIndex]
  397. .specificationsName = '';
  398. } else if (this.chooseType == 'gg') {
  399. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[this
  400. .selectIndex]
  401. .specifications = item.id;
  402. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList[this.dataIndex].zEngineeringMaterialBo[this
  403. .selectIndex]
  404. .specificationsName = item.name;
  405. }
  406. },
  407. getFSDJLevel() {
  408. getEnginMaterialQualityList("顶管工程").then(
  409. response => {
  410. this.selectList = response.data;
  411. this.$forceUpdate();
  412. });
  413. },
  414. isEdit(item) {
  415. var isShow = item.createBy == this.$user.state.name;
  416. return isShow;
  417. },
  418. submit() {
  419. let isSubmit = true;
  420. this.dataJson.zEngineeringNodeBo.zEngineeringInfoBoList.forEach((res) => {
  421. if (res.createBy == this.$user.state.name) {
  422. // if (res.zEngineeringMaterialBo[0].specifications == '') {
  423. // this.$modal.msg("请选择规格");
  424. // isSubmit = false;
  425. // }
  426. // if (res.zEngineeringMaterialBo[0].number == '') {
  427. // this.$modal.msg("请输入米数");
  428. // isSubmit = false;
  429. // }
  430. // if (this.getIntegerPart(res.zEngineeringMaterialBo[0].number, 0) == '') {
  431. // this.$modal.msg("请输入米数");
  432. // isSubmit = false;
  433. // }
  434. res.zEngineeringMaterialBo.forEach((itme) => {
  435. if (itme.specifications == '') {
  436. this.$modal.msg("请选择规格");
  437. isSubmit = false;
  438. }
  439. if (itme.number == '') {
  440. this.$modal.msg("请输入米数");
  441. isSubmit = false;
  442. }
  443. if (this.getIntegerPart(itme.number, 0) == '') {
  444. this.$modal.msg("请输入米数");
  445. isSubmit = false;
  446. }
  447. })
  448. if (res.zEngiineeringPhotoBoList.length == 0) {
  449. this.$modal.msg("请上传照片");
  450. isSubmit = false;
  451. }
  452. }
  453. })
  454. if (!isSubmit) {
  455. return
  456. }
  457. PutTopPipeWork(this.dataJson).then(
  458. response => {
  459. if (response.code == '200') {
  460. uni.hideLoading()
  461. uni.showToast({
  462. title: response.msg,
  463. icon: 'none',
  464. duration: 2000
  465. });
  466. setTimeout(function() {
  467. uni.navigateBack();
  468. }, 1000)
  469. }
  470. });
  471. }
  472. }
  473. }
  474. </script>
  475. <style lang="scss">
  476. .uni-media-list-body {
  477. background: #fff;
  478. border: 1px solid #eee;
  479. border-radius: 40rpx;
  480. margin: 20rpx;
  481. padding: 10rpx 0 40rpx;
  482. box-shadow: 0 0 5px #eee;
  483. }
  484. .uni-media-list-text-top {
  485. display: flex;
  486. align-items: center;
  487. justify-content: space-between;
  488. padding: 10px;
  489. position: relative;
  490. }
  491. .to-right-icon {
  492. width: 15px;
  493. height: 15px;
  494. position: absolute;
  495. top: 50%;
  496. transform: translateY(-50%);
  497. }
  498. .share {
  499. width: 100%;
  500. height: 100%;
  501. }
  502. .tit-text {
  503. color: #4f535a;
  504. margin-right: 20rpx;
  505. }
  506. .normal-text {}
  507. .cz-style {
  508. background: #e8f4f9;
  509. margin: 20rpx;
  510. padding: 10rpx;
  511. border-radius: 20rpx;
  512. border: 1px solid #d4e3f0;
  513. }
  514. .uni-media-list-text-top {
  515. font-size: 14px;
  516. color: #696969;
  517. padding: 20rpx 20rpx;
  518. border-bottom: 1px solid #eee;
  519. display: flex;
  520. align-items: center;
  521. }
  522. .share-box {
  523. width: 100%;
  524. height: 100%;
  525. position: fixed;
  526. top: 0rpx;
  527. left: 0rpx;
  528. bottom: 0rpx;
  529. right: 0rpx;
  530. background-color: rgba(0, 0, 0, 0.4);
  531. transition: .3s;
  532. z-index: 999;
  533. }
  534. // 进入分享动画
  535. .share-show {
  536. transition: all 0.3s ease;
  537. transform: translateY(0%) !important;
  538. border-radius: 20px 20px 0px 0px;
  539. }
  540. .scroll-Y {
  541. height: 58vh;
  542. }
  543. // 离开分享动画
  544. .share-item {
  545. position: fixed;
  546. left: 0;
  547. bottom: 0;
  548. width: 100%;
  549. height: 70%;
  550. background-color: #FFFFFF;
  551. transition: all 0.3s ease;
  552. transform: translateY(100%);
  553. z-index: 1999;
  554. .share-to {
  555. // width: 100%;
  556. height: 30px;
  557. display: flex;
  558. justify-content: center;
  559. margin: 30rpx 0 !important;
  560. align-items: center;
  561. }
  562. .content {
  563. width: 100%;
  564. height: auto;
  565. display: flex;
  566. flex-wrap: wrap;
  567. .block {
  568. width: 100%;
  569. display: flex;
  570. flex-direction: column;
  571. justify-content: center;
  572. align-items: left;
  573. height: auto;
  574. image {
  575. width: 80rpx;
  576. height: 80rpx;
  577. }
  578. text {
  579. margin-top: 16rpx;
  580. font-size: 28rpx;
  581. color: #606266;
  582. }
  583. }
  584. }
  585. .cancel {
  586. width: 100%;
  587. height: 3rem;
  588. display: flex;
  589. justify-content: center;
  590. align-items: center;
  591. border-top: 1rpx solid #E4E7ED;
  592. }
  593. }
  594. .uni-media-list-text-top {
  595. display: flex;
  596. align-items: center;
  597. justify-content: space-between;
  598. padding: 10px;
  599. position: relative;
  600. }
  601. .uni-list {
  602. border: 1xp solid #eee;
  603. }
  604. .to-right-icon {
  605. width: 15px;
  606. height: 15px;
  607. position: absolute;
  608. top: 50%;
  609. transform: translateY(-50%);
  610. }
  611. .text {
  612. font-size: 16px;
  613. color: #333;
  614. }
  615. </style>