open_bolt.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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. this.openBoltKey = this.dictOptions[res.tapIndex].dictValue;
  270. this.openBoltValue = this.dictOptions[res.tapIndex].dictLabel;
  271. },
  272. fail: (err) => {
  273. console.log('弹窗取消');
  274. }
  275. });
  276. });
  277. },
  278. showPhoto(index) {
  279. uni.previewImage({
  280. current: index,
  281. urls: this.imgArr,
  282. })
  283. },
  284. remove(index) {
  285. uni.showModal({
  286. title: '提示',
  287. content: '是否删除该图片或视频?',
  288. success: (res) => {
  289. if (res.confirm) {
  290. this.imgArr.splice(index, 1)
  291. if (this.imgArr.length <= 0) {
  292. this.photo = true;
  293. }
  294. }
  295. }
  296. })
  297. },
  298. chooseimage() {
  299. let _this = this;
  300. uni.chooseImage({
  301. sizeType: ['album', 'camera'],
  302. success(resp) {
  303. resp.tempFiles.forEach((item, index) => {
  304. const task = uni.uploadFile({
  305. url: _this.$HTTP + `/obs`,
  306. filePath: item.path,
  307. name: 'file',
  308. formData: {},
  309. header: _this.headers,
  310. success: res => {
  311. // 判断是否json字符串,将其转为json格式
  312. let data = JSON.parse(res.data);
  313. if (![200].includes(data.code)) {
  314. _this.$modal.msg(data.msg)
  315. } else {
  316. if (_this.progress === 100) {
  317. _this.imgArr.push(data.data.url)
  318. _this.$modal.msg('上传成功!')
  319. _this.photo = false;
  320. }
  321. }
  322. },
  323. fail: e => {
  324. _this.$modal.msg('上传失败!')
  325. },
  326. complete: res => {
  327. uni.hideLoading();
  328. _this.uploading = false;
  329. }
  330. });
  331. task.onProgressUpdate(res => {
  332. _this.progress = res.progress;
  333. uni.showLoading({
  334. title: '上传中'
  335. })
  336. if (_this.progress != 100) {
  337. _this.loading = false
  338. } else {
  339. _this.loading = true
  340. }
  341. });
  342. })
  343. },
  344. })
  345. },
  346. pickerShow(e) {
  347. this.type = e; //赋值类型
  348. if (e == 'xzq') { //行政区
  349. if (this.isEmpty(this.projectValue.dictValue)) {
  350. this.$modal.msg('请选择工程周期')
  351. } else {
  352. this.openDict = true;
  353. getDicts("district").then(response => {
  354. this.dictOptions = response.data;
  355. });
  356. }
  357. } else if (e == 'xq') { //小区
  358. if (this.isEmpty(this.XZQValue.dictValue)) {
  359. this.$modal.msg('请选择行政区')
  360. } else {
  361. this.open = true;
  362. this.selectList = this.XQList;
  363. }
  364. } else if (e == 'ld') { //楼栋
  365. if (this.isEmpty(this.XQValue.id)) {
  366. this.$modal.msg('请选择小区')
  367. } else {
  368. this.open = true;
  369. this.selectList = this.LDList;
  370. }
  371. } else if (e == 'dy') { //单元
  372. if (this.isEmpty(this.LDValue.id)) {
  373. this.$modal.msg('请选择楼栋')
  374. } else {
  375. this.open = true;
  376. this.selectList = this.DYList;
  377. }
  378. } else if (e == 'fj') { //房间
  379. if (this.isEmpty(this.DYValue.id)) {
  380. this.$modal.msg('请选择单元')
  381. } else {
  382. this.open = true;
  383. this.selectList = this.FJList;
  384. }
  385. }
  386. },
  387. changeSelectDict(item, index) {
  388. this.openDict = false;
  389. if (this.type == 'xzq') {
  390. this.XZQValue = item;
  391. //根据行政区id获取小区数据
  392. this.XQValue = ''; //重置小区数据
  393. this.LDValue = ''; //重置楼栋数据
  394. this.DYValue = ''; //重置单元数据
  395. getAreaList(item.dictValue).then(res => {
  396. this.XQList = res.data;
  397. })
  398. }
  399. },
  400. changeSelect(item, index) {
  401. this.open = false;
  402. if (this.type == 'xq') {
  403. this.XQValue = item;
  404. //根据小区id 获取楼栋数据
  405. this.LDValue = ''; //重置楼栋数据
  406. this.DYValue = ''; //重置单元数据
  407. getBuildingList(item.id).then(res => {
  408. this.LDList = res.data
  409. })
  410. } else if (this.type == 'ld') {
  411. this.LDValue = item;
  412. //根据楼栋ID 获取单元数据
  413. this.DYValue = ''; //重置单元数据
  414. this.FJValue = ''; //重置房间数据
  415. getUnitList(item.id).then(res => {
  416. this.DYList = res.data
  417. })
  418. } else if (this.type == 'dy') {
  419. this.DYValue = item; //根据单元数据 获取房间数据
  420. this.FJValue = ''; //重置房间数据
  421. getHousesList(item.id).then(res => {
  422. this.FJList = res.data
  423. })
  424. } else if (this.type == 'fj') {
  425. this.FJValue = item;
  426. }
  427. },
  428. //关闭弹窗
  429. close(e) {
  430. this.open = false
  431. },
  432. //关闭弹窗
  433. closeDict(e) {
  434. this.openDict = false
  435. },
  436. }
  437. }
  438. </script>
  439. <style lang="scss">
  440. .container {
  441. display: flex;
  442. align-items: center;
  443. justify-content: space-between;
  444. padding: 10px;
  445. position: relative;
  446. }
  447. .uni-list {
  448. border: 1xp solid #eee;
  449. }
  450. .to-right-icon {
  451. width: 15px;
  452. height: 15px;
  453. position: absolute;
  454. top: 50%;
  455. transform: translateY(-50%);
  456. }
  457. .text {
  458. font-size: 16px;
  459. color: #333;
  460. }
  461. .background {
  462. // border: 15px solid hsla(0, 0%, 100%, .5);
  463. background: white;
  464. background-clip: padding-box;
  465. padding: 20rpx;
  466. border-radius: 20rpx;
  467. margin: 20rpx;
  468. /*从padding开始往外面裁剪背景*/
  469. }
  470. .btn {
  471. width: 715rpx;
  472. height: 69rpx;
  473. background: #79A4F0;
  474. border-radius: 6rpx;
  475. font-size: 25rpx;
  476. font-family: Microsoft YaHei;
  477. font-weight: 400;
  478. color: #FFFFFF;
  479. line-height: 69rpx;
  480. margin-top: 40rpx;
  481. margin-bottom: 100rpx;
  482. }
  483. .number {
  484. display: flex;
  485. /* 水平居中显示子元素 */
  486. align-items: flex-start;
  487. /* 垂直居中显示子元素 */
  488. justify-content: space-between;
  489. /* 左右间距等于间距大小 */
  490. padding: 10px;
  491. /* 设置padding以提高视觉效果 */
  492. }
  493. .textarea {
  494. margin-top: 10upx;
  495. width: 100%;
  496. border: 1rpx solid red;
  497. min-height: 100upx;
  498. line-height: 20px;
  499. }
  500. </style>