verticalBar.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. <template>
  2. <view>
  3. <view class="background">
  4. <view class="uni-list">
  5. <view class="container">
  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. </view>
  13. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xzq')">
  14. <span style="color: black;">{{XZQValue.dictLabel}}</span>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="uni-list">
  19. <view class="container">
  20. <view>
  21. 小区
  22. </view>
  23. <view v-if="this.isEmpty(this.XQValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  24. @click="pickerShow('xq')">
  25. <span style="color: darkgray;">请选择小区</span>
  26. </view>
  27. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xq')">
  28. <span style="color: black;">{{XQValue.name}}</span>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="uni-list">
  33. <view class="container">
  34. <view class="uni-list-cell-left">
  35. 楼栋
  36. </view>
  37. <view v-if="this.isEmpty(this.LDValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  38. @click="pickerShow('ld')">
  39. <span style="color: darkgray;">请选择楼栋</span>
  40. </view>
  41. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('ld')">
  42. <span style="color: black;">{{LDValue.name}}</span>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="uni-list" style="margin-top: 10;">
  47. <view class="container">
  48. <view class="uni-list-cell-left">
  49. 单元
  50. </view>
  51. <view v-if="this.isEmpty(this.DYValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  52. @click="pickerShow('dy')">
  53. <span style="color: darkgray;">请选择单元</span>
  54. </view>
  55. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('dy')">
  56. <span style="color: black;">{{DYValue.name}}</span>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="uni-list">
  61. <view class="container">
  62. <view class="uni-list-cell-left">
  63. 房间
  64. </view>
  65. <view v-if="this.isEmpty(this.FJValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  66. @click="pickerShow('fj')">
  67. <span style="color: darkgray;">请选择房间</span>
  68. </view>
  69. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('fj')">
  70. <span style="color: black;">{{FJValue.name}}</span>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="container">
  75. <view class="title">是否按照施工图纸施工</view>
  76. <switch style="transform: scale(0.6,0.6);" @change="switch2Change" />
  77. </view>
  78. <SelectPicker :list="selectList" @change="changeSelect" v-if="open" @close="close" titleKey="name"
  79. subtitleKey="id" v-model="name"></SelectPicker>
  80. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  81. titleKey="dictLabel" subtitleKey="dictValue" v-model="dictLabel"></SelectPicker>
  82. </view>
  83. <view class="background">
  84. <view class="uni-list">
  85. <view style="font-size: 16px;margin-left: 10px;margin-top: 10px;">
  86. 立杠
  87. <span
  88. style="color: blue;font-size: 14px; display: flex;justify-content:flex-end; margin-right: 15px;">历史</span>
  89. </view>
  90. <view class="container">
  91. <view>
  92. 材 质
  93. </view>
  94. <view class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xzq')">
  95. <span>{{attributeXZQ}}</span>
  96. </view>
  97. </view>
  98. <view class="container">
  99. <view>
  100. 规 格
  101. </view>
  102. <view class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xzq')">
  103. <span>{{attributeXZQ}}</span>
  104. </view>
  105. </view>
  106. <view class="number">
  107. <text>数 量</text> <!-- 左边文字 -->
  108. <input type="number" v-model="number"class="input" placeholder="请填写数量" style="margin-left: 10px;"></input>
  109. <!-- 右边输入框 -->
  110. </view>
  111. </view>
  112. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  113. <view class="container" style="color: gainsboro;">*请上传照片</view>
  114. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px;">
  115. <image src="/static/images/chooseimg.png" mode=""
  116. style="width: 190rpx; height: 190rpx; margin: 0 12rpx;; " @click="chooseimage()"></image>
  117. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  118. <view>
  119. <image :src="item" mode="" style="width: 190rpx; height: 190rpx; margin: 0 12rpx;"
  120. @click="showPhoto(index)">
  121. </image>
  122. </view>
  123. <view @click="remove(index)"
  124. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  125. <u-icon name="close" color="#FFFFFF" size="35"></u-icon>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. <view class="action-btn">
  132. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  133. </view>
  134. </view>
  135. </template>
  136. <script>
  137. import SelectPicker from '../../../components/selectPicker/select_picker.vue'
  138. import {
  139. getDicts
  140. } from "@/api/system/dict/data";
  141. import {
  142. getAreaList,
  143. getBuildingList,
  144. getUnitList,
  145. getHousesList
  146. } from '@/api/common'
  147. export default {
  148. components: {
  149. SelectPicker
  150. },
  151. data() {
  152. return {
  153. number: '',
  154. type: '',
  155. open: false,
  156. openDict: false,
  157. selectList: [],
  158. dictOptions: [],
  159. imgArr: [],
  160. XQValue: {},
  161. XZQValue: {},
  162. LDValue: {},
  163. DYValue: {},
  164. FJValue: {},
  165. FSValue: {},
  166. XQList: '',
  167. LDList: '',
  168. DYList: '',
  169. FJList: '',
  170. progress: 0, //上传图片进度百分比
  171. loading: false
  172. }
  173. },
  174. created() {
  175. getDicts("district").then(response => {
  176. this.dictOptions = response;
  177. });
  178. },
  179. onLoad() {
  180. uni.setNavigationBarTitle({
  181. title: '旧改工程-室内'
  182. })
  183. },
  184. methods: {
  185. //判断是否选择
  186. isEmpty(str) {
  187. return (!str || 0 === str.length);
  188. },
  189. showPhoto(index) {
  190. uni.previewImage({
  191. current: index,
  192. urls: this.imgArr,
  193. })
  194. console.log('sss')
  195. },
  196. remove(index) {
  197. uni.showModal({
  198. title: '提示',
  199. content: '是否删除该图片或视频?',
  200. success: (res) => {
  201. if (res.confirm) {
  202. this.imgArr.splice(index, 1)
  203. console.log('this.imgarr', this.imgArr)
  204. if (this.imgArr.length <= 0) {
  205. this.photo = true;
  206. }
  207. }
  208. }
  209. })
  210. },
  211. chooseimage() {
  212. console.log('图片')
  213. let _this = this;
  214. uni.chooseImage({
  215. sizeType: ['album', 'camera'],
  216. success(resp) {
  217. console.log('res--uni.chooseMedia', resp);
  218. resp.tempFiles.forEach((item, index) => {
  219. const task = uni.uploadFile({
  220. url: _this.$HTTP.webUrl + `/obs`,
  221. filePath: item.path,
  222. name: 'file',
  223. formData: {},
  224. header: _this.headers,
  225. success: res => {
  226. // 判断是否json字符串,将其转为json格式
  227. let data = _this.$u.test.jsonString(res
  228. .data) ? JSON.parse(res.data) : res.data;
  229. if (![200, 201, 204].includes(res.statusCode)) {
  230. // this.uploadError(index, data);
  231. _this.$modal.msg('上传失败!')
  232. } else {
  233. if (_this.progress === 100) {
  234. console.log('_this.progress', _this.progress)
  235. console.log('data----', data)
  236. console.log('res--', res)
  237. _this.imgArr.push(data.data.url)
  238. console.log('imgArr', _this.imgArr)
  239. _this.$modal.msg('上传成功!')
  240. _this.photo = false;
  241. }
  242. }
  243. },
  244. fail: e => {
  245. _this.$modal.msg('上传失败!')
  246. this.uploadError(index, e);
  247. },
  248. complete: res => {
  249. uni.hideLoading();
  250. _this.uploading = false;
  251. }
  252. });
  253. task.onProgressUpdate(res => {
  254. _this.progress = res.progress;
  255. console.log('onProgressUpdate', res)
  256. console.log('task.onProgressUpdate', _this.progress)
  257. uni.showLoading({
  258. title: '上传中'
  259. })
  260. if (_this.progress != 100) {
  261. _this.loading = false
  262. console.log('_this.loading false', _this.loading)
  263. } else {
  264. _this.loading = true
  265. console.log('_this.loading true', _this.loading)
  266. }
  267. });
  268. })
  269. },
  270. })
  271. },
  272. pickerShow(e) {
  273. this.type = e; //赋值类型
  274. if (e == 'xzq') { //行政区
  275. this.openDict = true;
  276. //this.selectList = this.dictOptions;
  277. } else if (e == 'xq') { //小区
  278. if (this.isEmpty(this.XZQValue.dictValue)) {
  279. this.$modal.msg('请选择行政区')
  280. } else {
  281. this.open = true;
  282. this.selectList = this.XQList;
  283. }
  284. } else if (e == 'ld') { //楼栋
  285. if (this.isEmpty(this.XQValue.id)) {
  286. this.$modal.msg('请选择小区')
  287. } else {
  288. this.open = true;
  289. this.selectList = this.LDList;
  290. }
  291. } else if (e == 'dy') { //单元
  292. if (this.isEmpty(this.LDValue.id)) {
  293. this.$modal.msg('请选择楼栋')
  294. } else {
  295. this.open = true;
  296. this.selectList = this.DYList;
  297. }
  298. } else if (e == 'fj') { //房间
  299. if (this.isEmpty(this.DYValue.id)) {
  300. this.$modal.msg('请选择单元')
  301. } else {
  302. this.open = true;
  303. this.selectList = this.FJList;
  304. }
  305. }
  306. },
  307. switch2Change(e) {
  308. console.log('switch2 发生 change 事件,携带值为', e.detail.value)
  309. },
  310. changeSelectDict(item, index) {
  311. this.openDict = false;
  312. this.XZQValue = item;
  313. //根据行政区id获取小区数据
  314. this.XQValue.name = ''; //重置楼栋数据
  315. this.LDValue.name = ''; //重置楼栋数据
  316. this.DYValue.name = ''; //重置单元数据
  317. this.FJValue.name = ''; //重置房间数据
  318. getAreaList(item.dictValue).then(res => {
  319. this.XQList = res;
  320. })
  321. },
  322. changeSelect(item, index) {
  323. // this.index = index;
  324. // this.address = item.communityName;
  325. this.open = false;
  326. if (this.type == 'xq') {
  327. this.XQValue = item;
  328. //根据小区id 获取楼栋数据
  329. this.LDValue.name = ''; //重置楼栋数据
  330. this.DYValue.name = ''; //重置单元数据
  331. this.FJValue.name = ''; //重置房间数据
  332. getBuildingList(item.id).then(res => {
  333. this.LDList = res
  334. // console.log("楼栋=", res)
  335. })
  336. } else if (this.type == 'ld') {
  337. this.LDValue = item;
  338. //根据楼栋ID 获取单元数据
  339. this.DYValue.name = ''; //重置单元数据
  340. this.FJValue.name = ''; //重置房间数据
  341. getUnitList(item.id).then(res => {
  342. this.DYList = res
  343. // console.log("单元=", res)
  344. })
  345. } else if (this.type == 'dy') {
  346. this.DYValue = item;
  347. //根据单元数据 获取房间数据
  348. this.FJValue.name = ''; //重置房间数据
  349. getHousesList(item.id).then(res => {
  350. this.FJList = res
  351. // console.log("房间=", res)
  352. })
  353. } else if (this.type == 'fj') {
  354. this.FJValue = item;
  355. }
  356. },
  357. //关闭弹窗
  358. close(e) {
  359. this.open = false
  360. },
  361. //关闭弹窗
  362. closeDict(e) {
  363. this.openDict = false
  364. },
  365. //提交数据
  366. submit() {
  367. if (this.isEmpty(this.XZQValue.dictValue)) {
  368. this.$modal.msg("请选择行政区")
  369. } else if (this.isEmpty(this.XQValue.id)) {
  370. this.$modal.msg("请选择小区")
  371. } else if (this.isEmpty(this.LDValue.id)) {
  372. this.$modal.msg("请选择楼栋")
  373. } else if (this.isEmpty(this.DYValue.id)) {
  374. this.$modal.msg("请选择单元")
  375. } else if (this.isEmpty(this.FJValue.id)) {
  376. this.$modal.msg("请选择房间")
  377. } else if (this.imgArr.length <= 0) {
  378. this.$modal.msg('请上传照片')
  379. } else if (this.loading == false) {
  380. this.$modal.msg('照片未上传完毕,无法提交!')
  381. }
  382. }
  383. }
  384. }
  385. </script>
  386. <style>
  387. .container {
  388. display: flex;
  389. margin-left: 10px;
  390. margin-top: 10px;
  391. margin-right: 10px;
  392. align-items: flex-start;
  393. justify-content: space-between;
  394. }
  395. .number {
  396. display: flex;
  397. /* 水平居中显示子元素 */
  398. align-items: flex-start;
  399. /* 垂直居中显示子元素 */
  400. justify-content: space-between;
  401. /* 左右间距等于间距大小 */
  402. padding: 10px;
  403. /* 设置padding以提高视觉效果 */
  404. }
  405. .text {
  406. font-size: 16px;
  407. color: #333;
  408. }
  409. .background {
  410. border: 15px solid hsla(0, 0%, 100%, .5);
  411. background: white;
  412. background-clip: padding-box;
  413. /*从padding开始往外面裁剪背景*/
  414. }
  415. .btn {
  416. margin-top: 40px;
  417. margin-right: 20px;
  418. margin-bottom: 20px;
  419. margin-left: 20px;
  420. height: 45px;
  421. }
  422. </style>