open_bolt.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  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.XZQValue.dictValue)" style="margin-top: 10;"
  10. @click="pickerShow('xzq')">
  11. <span style="color: darkgray;">请选择行政区</span>
  12. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  13. </view>
  14. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xzq')">
  15. <span style="color: black;">{{XZQValue.dictLabel}}</span>
  16. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="uni-list">
  21. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  22. <view>
  23. 小区
  24. </view>
  25. <view v-if="this.isEmpty(this.XQValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  26. @click="pickerShow('xq')">
  27. <span style="color: darkgray;">请选择小区</span>
  28. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  29. </view>
  30. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xq')">
  31. <span style="color: black;">{{XQValue.name}}</span>
  32. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="uni-list">
  37. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  38. <view class="uni-list-cell-left">
  39. 楼栋
  40. </view>
  41. <view v-if="this.isEmpty(this.LDValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  42. @click="pickerShow('ld')">
  43. <span style="color: darkgray;">请选择楼栋</span>
  44. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  45. </view>
  46. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('ld')">
  47. <span style="color: black;">{{LDValue.name}}</span>
  48. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="uni-list" style="margin-top: 10;">
  53. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  54. <view class="uni-list-cell-left">
  55. 单元
  56. </view>
  57. <view v-if="this.isEmpty(this.DYValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  58. @click="pickerShow('dy')">
  59. <span style="color: darkgray;">请选择单元</span>
  60. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  61. </view>
  62. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('dy')">
  63. <span style="color: black;">{{DYValue.name}}</span>
  64. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  65. </view>
  66. </view>
  67. </view>
  68. <view class="uni-list">
  69. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  70. <view class="uni-list-cell-left">
  71. 房间
  72. </view>
  73. <view v-if="this.isEmpty(this.FJValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  74. @click="pickerShow('fj')">
  75. <span style="color: darkgray;">请选择房间</span>
  76. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  77. </view>
  78. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('fj')">
  79. <span style="color: black;">{{FJValue.name}}</span>
  80. <image :src="loadImgSrc('icon_right.png')" class="to-right-icon"></image>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="background" style="margin-top: 20px;margin-bottom: 20px;">
  86. <view class="container" style="border-bottom: 1px solid #f8f8f8;">
  87. <view class="uni-common-mt" style="width: 100%;">
  88. <text class="uni-title uni-common-pl">描述</text>
  89. <view style="width: 100%;box-sizing: border-box;">
  90. <textarea class="textarea" placeholder="请输入描述" maxlength="255"
  91. placeholder-style="padding: 10rpx;"
  92. style="width: 100%;height: 100%;border: 1rpx solid #cccccc; border-radius: 15rpx;padding: 10rpx;line-height:normal;"
  93. auto-height v-model="remark"></textarea>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="container" style="color: #b2b2b2;">*请上传照片</view>
  98. <view style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  99. <image :src="loadImgSrc('updateimg.png')" mode=""
  100. style="width: 200rpx; height: 150rpx; margin: 0 12rpx;; " @click="chooseimage()"
  101. v-show="reviewStatus!='1'"></image>
  102. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  103. <view
  104. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg'||item.substring(item.length-4)=='jpeg' ">
  105. <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  106. @click="showPhoto(index)">
  107. </image>
  108. </view>
  109. <view v-else>
  110. <video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
  111. </view>
  112. <view @click="remove(index)" style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  113. <image :src="loadImgSrc('icon_close.png')" style=" width: 15px; height: 15px;">
  114. </image>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="action-btn" v-show="reviewStatus!='1'">
  120. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  121. </view>
  122. <bottom-sheet ref="refShare" :data="historyList"></bottom-sheet>
  123. <SelectPicker :list="selectList" @change="changeSelect" v-if="open" @close="close" titleKey="name"
  124. subtitleKey="id" v-model="name"></SelectPicker>
  125. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  126. titleKey="dictLabel" subtitleKey="dictValue" v-model="dictLabel"></SelectPicker>
  127. <yt-dateTimePicker ref="myPicker" @submit="handleSubmit" :start-year="2024" :end-year="2099"
  128. :time-hide="[true, true, true, true, true, true]" :time-label="['年', '月', '日', '时', '分', '秒']" />
  129. </scroll-view>
  130. </template>
  131. <script>
  132. import SelectPicker from '../../components/selectPicker/select_picker.vue'
  133. import bottomSheet from '../../components/bottomSheet/bottomSheet.vue'
  134. import {
  135. getDicts
  136. } from "@/api/system/dict/data";
  137. import {
  138. getAreaList,
  139. getBuildingList,
  140. getUnitList,
  141. getHousesList,
  142. addTearOldPipe,
  143. getRoomProjectList,
  144. getRoomProjectId,
  145. } from '@/api/common';
  146. import {
  147. getToken
  148. } from '../../utils/auth';
  149. export default {
  150. components: {
  151. SelectPicker,
  152. bottomSheet,
  153. },
  154. data() {
  155. return {
  156. title: '',
  157. name: '开栓',
  158. headers: {
  159. Authorization: "Bearer " + getToken()
  160. },
  161. type: '',
  162. open: false,
  163. reviewStatus: '', //是否可以点击
  164. objValue: '', //上一页面传过来的值 新增接口用
  165. openDict: false,
  166. selectList: [],
  167. dictOptions: [],
  168. imgArr: [],
  169. XQValue: {},
  170. XZQValue: {},
  171. projectValue: {
  172. 'dictValue': '0'
  173. },
  174. remark: '',
  175. LDValue: {},
  176. DYValue: {},
  177. FJValue: {},
  178. XQList: '',
  179. LDList: '',
  180. DYList: '',
  181. FJList: '',
  182. progress: 0, //上传图片进度百分比
  183. loading: false,
  184. historyList: {}, //历史数据
  185. inputNumberValue: '',
  186. inputIntegerNumberValue: '',
  187. inputDecimalNumberValue: '',
  188. }
  189. },
  190. onLoad(options) {
  191. if ('params' in options) {
  192. this.objValue = JSON.parse(decodeURIComponent(options.params));
  193. if (this.objValue.enginType == `old_renovation`) {
  194. this.title = '旧改工程-开栓'
  195. } else if (this.objValue.enginType == `new_built`) {
  196. this.title = '新建工程-开栓'
  197. }
  198. uni.setNavigationBarTitle({
  199. title: this.title
  200. })
  201. }
  202. },
  203. methods: {
  204. //判断是否选择
  205. isEmpty(str) {
  206. return (!str || 0 === str.length);
  207. },
  208. submit() {
  209. if (this.isEmpty(this.projectValue.dictValue)) {
  210. this.$modal.msg("请选择工程周期")
  211. } else if (this.isEmpty(this.XZQValue.dictValue)) {
  212. this.$modal.msg("请选择行政区")
  213. } else if (this.isEmpty(this.XQValue.id)) {
  214. this.$modal.msg("请选择小区")
  215. } else if (this.isEmpty(this.LDValue.id)) {
  216. this.$modal.msg("请选择楼栋")
  217. } else if (this.isEmpty(this.DYValue.id)) {
  218. this.$modal.msg("请选择单元")
  219. } else if (this.isEmpty(this.FJValue.id)) {
  220. this.$modal.msg("请选择房间")
  221. } else if (this.imgArr.length <= 0) {
  222. this.$modal.msg("请上传照片")
  223. } else {
  224. uni.showLoading()
  225. let param = {
  226. district: this.XZQValue.dictValue,
  227. areaId: this.XQValue.id,
  228. buildingId: this.LDValue.id,
  229. unitId: this.DYValue.id,
  230. houseId:this.FJValue.id,
  231. enginType: this.objValue.enginType, //写死 上一页面传过来的
  232. enginClassification: this.objValue
  233. .enginClassification, //写死 上一页面传过来的 //室内 - 庭院 - 架空
  234. enginCycle: this.projectValue.dictValue, //工程周期
  235. zEngineeringNodeBo: {
  236. type: this.objValue.enginClassValue, //写死 上一页面传过来的 (拆旧管等 字典值)
  237. zEngineeringInfoBo: {
  238. constructTime: this.time,
  239. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  240. }
  241. }
  242. }
  243. addTearOldPipe(param).then(res => {
  244. uni.hideLoading()
  245. if (res.code == '200') {
  246. uni.showToast({
  247. title: res.msg,
  248. icon: 'none',
  249. //显示持续时间为 3秒
  250. duration: 2000
  251. });
  252. setTimeout(function() {
  253. uni.navigateBack();
  254. }, 1000)
  255. }
  256. })
  257. //提交接口执行逻辑
  258. }
  259. },
  260. showPhoto(index) {
  261. uni.previewImage({
  262. current: index,
  263. urls: this.imgArr,
  264. })
  265. },
  266. remove(index) {
  267. uni.showModal({
  268. title: '提示',
  269. content: '是否删除该图片或视频?',
  270. success: (res) => {
  271. if (res.confirm) {
  272. this.imgArr.splice(index, 1)
  273. if (this.imgArr.length <= 0) {
  274. this.photo = true;
  275. }
  276. }
  277. }
  278. })
  279. },
  280. chooseimage() {
  281. let _this = this;
  282. uni.chooseImage({
  283. sizeType: ['album', 'camera'],
  284. success(resp) {
  285. resp.tempFiles.forEach((item, index) => {
  286. const task = uni.uploadFile({
  287. url: _this.$HTTP + `/obs`,
  288. filePath: item.path,
  289. name: 'file',
  290. formData: {},
  291. header: _this.headers,
  292. success: res => {
  293. // 判断是否json字符串,将其转为json格式
  294. let data = JSON.parse(res.data);
  295. if (![200].includes(data.code)) {
  296. _this.$modal.msg(data.msg)
  297. } else {
  298. if (_this.progress === 100) {
  299. _this.imgArr.push(data.data.url)
  300. _this.$modal.msg('上传成功!')
  301. _this.photo = false;
  302. }
  303. }
  304. },
  305. fail: e => {
  306. _this.$modal.msg('上传失败!')
  307. },
  308. complete: res => {
  309. uni.hideLoading();
  310. _this.uploading = false;
  311. }
  312. });
  313. task.onProgressUpdate(res => {
  314. _this.progress = res.progress;
  315. uni.showLoading({
  316. title: '上传中'
  317. })
  318. if (_this.progress != 100) {
  319. _this.loading = false
  320. } else {
  321. _this.loading = true
  322. }
  323. });
  324. })
  325. },
  326. })
  327. },
  328. pickerShow(e) {
  329. this.type = e; //赋值类型
  330. if (e == 'xzq') { //行政区
  331. if (this.isEmpty(this.projectValue.dictValue)) {
  332. this.$modal.msg('请选择工程周期')
  333. } else {
  334. this.openDict = true;
  335. getDicts("district").then(response => {
  336. this.dictOptions = response.data;
  337. });
  338. }
  339. } else if (e == 'xq') { //小区
  340. if (this.isEmpty(this.XZQValue.dictValue)) {
  341. this.$modal.msg('请选择行政区')
  342. } else {
  343. this.open = true;
  344. this.selectList = this.XQList;
  345. }
  346. } else if (e == 'ld') { //楼栋
  347. if (this.isEmpty(this.XQValue.id)) {
  348. this.$modal.msg('请选择小区')
  349. } else {
  350. this.open = true;
  351. this.selectList = this.LDList;
  352. }
  353. } else if (e == 'dy') { //单元
  354. if (this.isEmpty(this.LDValue.id)) {
  355. this.$modal.msg('请选择楼栋')
  356. } else {
  357. this.open = true;
  358. this.selectList = this.DYList;
  359. }
  360. } else if (e == 'fj') { //房间
  361. if (this.isEmpty(this.DYValue.id)) {
  362. this.$modal.msg('请选择单元')
  363. } else {
  364. this.open = true;
  365. this.selectList = this.FJList;
  366. }
  367. }
  368. },
  369. changeSelectDict(item, index) {
  370. this.openDict = false;
  371. if (this.type == 'xzq') {
  372. this.XZQValue = item;
  373. //根据行政区id获取小区数据
  374. this.XQValue = ''; //重置小区数据
  375. this.LDValue = ''; //重置楼栋数据
  376. this.DYValue = ''; //重置单元数据
  377. getAreaList(item.dictValue).then(res => {
  378. this.XQList = res.data;
  379. })
  380. }
  381. },
  382. changeSelect(item, index) {
  383. this.open = false;
  384. if (this.type == 'xq') {
  385. this.XQValue = item;
  386. //根据小区id 获取楼栋数据
  387. this.LDValue = ''; //重置楼栋数据
  388. this.DYValue = ''; //重置单元数据
  389. getBuildingList(item.id).then(res => {
  390. this.LDList = res.data
  391. })
  392. } else if (this.type == 'ld') {
  393. this.LDValue = item;
  394. //根据楼栋ID 获取单元数据
  395. this.DYValue = ''; //重置单元数据
  396. this.FJValue = ''; //重置房间数据
  397. getUnitList(item.id).then(res => {
  398. this.DYList = res.data
  399. })
  400. } else if (this.type == 'dy') {
  401. this.DYValue = item; //根据单元数据 获取房间数据
  402. this.FJValue = ''; //重置房间数据
  403. getHousesList(item.id).then(res => {
  404. this.FJList = res.data
  405. })
  406. } else if (this.type == 'fj') {
  407. this.FJValue = item;
  408. }
  409. },
  410. //关闭弹窗
  411. close(e) {
  412. this.open = false
  413. },
  414. //关闭弹窗
  415. closeDict(e) {
  416. this.openDict = false
  417. },
  418. }
  419. }
  420. </script>
  421. <style lang="scss">
  422. .container {
  423. display: flex;
  424. align-items: center;
  425. justify-content: space-between;
  426. padding: 10px;
  427. position: relative;
  428. }
  429. .uni-list {
  430. border: 1xp solid #eee;
  431. }
  432. .to-right-icon {
  433. width: 15px;
  434. height: 15px;
  435. position: absolute;
  436. top: 50%;
  437. transform: translateY(-50%);
  438. }
  439. .text {
  440. font-size: 16px;
  441. color: #333;
  442. }
  443. .background {
  444. // border: 15px solid hsla(0, 0%, 100%, .5);
  445. background: white;
  446. background-clip: padding-box;
  447. padding: 20rpx;
  448. border-radius: 20rpx;
  449. margin: 20rpx;
  450. /*从padding开始往外面裁剪背景*/
  451. }
  452. .btn {
  453. width: 715rpx;
  454. height: 69rpx;
  455. background: #79A4F0;
  456. border-radius: 6rpx;
  457. font-size: 25rpx;
  458. font-family: Microsoft YaHei;
  459. font-weight: 400;
  460. color: #FFFFFF;
  461. line-height: 69rpx;
  462. margin-top: 40rpx;
  463. margin-bottom: 100rpx;
  464. }
  465. .number {
  466. display: flex;
  467. /* 水平居中显示子元素 */
  468. align-items: flex-start;
  469. /* 垂直居中显示子元素 */
  470. justify-content: space-between;
  471. /* 左右间距等于间距大小 */
  472. padding: 10px;
  473. /* 设置padding以提高视觉效果 */
  474. }
  475. .textarea {
  476. margin-top: 10upx;
  477. width: 100%;
  478. border: 1rpx solid red;
  479. min-height: 100upx;
  480. line-height: 20px;
  481. }
  482. </style>