historyDetailsInfrastructure.vue 17 KB

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