open_bolt.vue 16 KB

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