putUpWatch.vue 13 KB

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