CourtyardNetworkManagement.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. <template>
  2. <view>
  3. <image src="https://cczdsz.cn/app/images/background-from.png" class="background"></image>
  4. <view class="project-content">
  5. <u-form :model="form" :rules="rules" ref="form">
  6. <u-form-item label="楼栋" borderBottom ref="item1" labelWidth="140">
  7. <u-input v-model="buildingName" disabled borderBottom @click=" showbuilding= true&&type!=1"
  8. placeholder="请选择楼栋"></u-input>
  9. <u-select v-model="showbuilding" :list="buildingList" label-name="name" value-name="id"
  10. @confirm="buildingconfirm()"> </u-select>
  11. <u-icon slot="right" name="arrow-right"></u-icon>
  12. </u-form-item>
  13. <!-- <u-form-item label="单元" labelWidth="140" borderBottom ref="item1">
  14. <u-input v-model="unitName" disabled borderBottom @click=" showunit= true "
  15. placeholder="请选择单元"></u-input>
  16. <u-select v-model="showunit" :list="unitList" label-name="name" value-name="id"
  17. @confirm="unitconfirm()"> </u-select>
  18. <u-icon slot="right" name="arrow-right"></u-icon>
  19. </u-form-item> -->
  20. <u-form-item label="发现问题" labelWidth="140" borderBottom ref="item1">
  21. <u-radio-group v-model="form.findProblem" >
  22. <u-radio @change="confirm"
  23. v-for="(item, index) in typelist.find_problem"
  24. :key="index" :name="item.dictValue">
  25. {{item.dictLabel}}
  26. </u-radio>
  27. </u-radio-group>
  28. </u-form-item>
  29. <u-form-item borderBottom ref="item1">
  30. <view>备注</view>
  31. <u-input v-model="form.remarks" type="textarea" placeholder="请输入备注" ></u-input>
  32. </u-form-item>
  33. <u-form-item borderBottom ref="item1">
  34. <view>巡检照片</view>
  35. <u-input v-model="WarningColumnInformation" disabled placeholder="请上传巡检照片"></u-input>
  36. <view class="" style="display: flex; flex-wrap: wrap; margin: 0 55rpx;">
  37. <image src="https://cczdsz.cn/app/images/chooseimg.png" mode=""
  38. style="width: 190rpx; height: 190rpx; margin: 0 12rpx; " @click="choose()" >
  39. </image>
  40. <view v-for="(item,index) in imgymxs" :key="index" style="position: relative;">
  41. <view v-if="item.type == 'image'">
  42. <image :src="item.url" mode="" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"
  43. @click="showPhoto(index)">
  44. </image>
  45. </view>
  46. <view v-else>
  47. <video :src="item" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"></video>
  48. </view>
  49. <view @click="remove(index)"
  50. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  51. <u-icon name="close" color="#FFFFFF" size="35" ></u-icon>
  52. </view>
  53. </view>
  54. </view>
  55. </u-form-item>
  56. </u-form>
  57. <u-button style="background: #2d95f4;color: #fff;border-radius: 20rpx;" @click="save()" v-if="type!=1"
  58. type='primary'>确认上传</u-button>
  59. <u-button style="background: #2d95f4;color: #fff;border-radius: 20rpx;" @click="update()"
  60. type='primary'>确认修改</u-button>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import service from '@/api/index.js'
  66. export default {
  67. data() {
  68. return {
  69. repairType: [{
  70. label: '施工问题',
  71. value: 1
  72. }, {
  73. label: '施工问题',
  74. value: 2
  75. }, ],
  76. showrepairType: false,
  77. action: this.$HTTP.webUrl + `/obs`,
  78. headers: {
  79. MAuthorization: "wxBearer " + uni.getStorageSync('token')
  80. },
  81. url: [],
  82. uploading: false,
  83. imgArr: [],
  84. imgymxs: [],
  85. progress: 0, //图片或视频上传百分比
  86. form: {findProblem:1},
  87. typelist: [],
  88. causesOfFamageLabel: null,
  89. dictlist: ['find_problem'],
  90. buildingName: null,
  91. unit: null,
  92. unitName: null,
  93. showbuilding: false,
  94. showunit: false,
  95. buildingList: [],
  96. unitList: [],
  97. type: 2,
  98. id: null,
  99. community: null,
  100. createBy:null
  101. }
  102. },
  103. onLoad(e) {
  104. this.building = e.building
  105. this.buildingName = e.buildingName
  106. this.community = e.community
  107. this.unitName = e.unitName
  108. this.unit = e.unit
  109. this.id = e.id
  110. this.type = e.type
  111. console.log(e)
  112. this.getdictsysinfo()
  113. uni.setNavigationBarTitle({
  114. title: '庭院网管表单'
  115. });
  116. uni.setNavigationBarColor({
  117. frontColor: '#ffffff',
  118. backgroundColor: '#2d95f4',
  119. })
  120. if (this.type != 1) {
  121. this.getBuildingList()
  122. }
  123. this.getUserName()
  124. },
  125. methods: {
  126. getUserName(){
  127. service.getUserName().then(res=>{
  128. this.userId=res.id
  129. thuis.createBy=res.name
  130. })
  131. },
  132. showPhoto(index) {
  133. uni.previewImage({
  134. current: index,
  135. urls: this.imgArr,
  136. })
  137. },
  138. showPhotos(index) {
  139. uni.previewImage({
  140. current: index,
  141. urls: this.photo,
  142. })
  143. },
  144. buildingconfirm(e) {
  145. this.buildingName = e[0].label
  146. this.building = e[0].value
  147. console.log(this.building)
  148. //this.getUnitList(e[0].value)
  149. },
  150. unitconfirm(e) {
  151. this.unitName = e[0].label
  152. this.unit = e[0].value
  153. },
  154. getBuildingList() {
  155. const _this = this
  156. service.getBuildingList({
  157. areaId: this.community
  158. }).then(res => {
  159. _this.buildingList = res
  160. })
  161. },
  162. getUnitList(building) {
  163. const _this = this
  164. service.getUnitList({
  165. buildingId: building
  166. }).then(res => {
  167. _this.unitList = res
  168. })
  169. },
  170. update()
  171. {
  172. let _this = this
  173. this.form.photoList = this.imgArr
  174. this.form.pressureStatus = null
  175. this.building=this.form.buildingId
  176. if(this.building==null)
  177. {
  178. uni.showToast({
  179. title: '请选择楼栋',
  180. icon: 'none'
  181. })
  182. return
  183. }
  184. if(this.imgArr.length==0)
  185. {
  186. uni.showToast({
  187. title: '请上传图片或视频!',
  188. icon: 'none'
  189. })
  190. return
  191. }
  192. this.form.buildingId = this.building
  193. this.form.communityId=this.community
  194. this.form.userId=this.userId
  195. this.form.createBy=this.userId
  196. service.updatecourtyardNetworkManagement(this.form).then(res => {
  197. console.log(res)
  198. _this.$UTILS.showPrompt('修改成功!')
  199. // setTimeout(() => {
  200. // console.log('跳')
  201. // uni.switchTab({
  202. // url: '/pages/index/index'
  203. // })
  204. // }, 2000)
  205. // this.form={findProblem:1}
  206. // this.buildingName=''
  207. // this.imgArr=[]
  208. // this.imgymxs=[]
  209. })
  210. },
  211. save() {
  212. let _this = this
  213. this.form.photoList = this.imgArr
  214. if(this.building==null)
  215. {
  216. uni.showToast({
  217. title: '请选择楼栋',
  218. icon: 'none'
  219. })
  220. return
  221. }
  222. if(this.imgArr.length==0)
  223. {
  224. uni.showToast({
  225. title: '请上传图片或视频!',
  226. icon: 'none'
  227. })
  228. return
  229. }
  230. this.form.buildingId = this.building
  231. this.form.communityId=this.community
  232. this.form.userId=this.userId
  233. this.form.createBy=this.userId
  234. service.setcourtyardNetworkManagement(this.form).then(res => {
  235. console.log(res)
  236. _this.$UTILS.showPrompt('上报成功!')
  237. // setTimeout(() => {
  238. // console.log('跳')
  239. // uni.switchTab({
  240. // url: '/pages/index/index'
  241. // })
  242. // }, 2000)
  243. this.form={findProblem:1}
  244. this.buildingName=''
  245. this.imgArr=[]
  246. this.imgymxs=[]
  247. })
  248. },
  249. getdictsysinfo() {
  250. let _this = this
  251. service.getDictInfoList({
  252. type: this.dictlist
  253. }).then(res => {
  254. if (this.type == 1) {
  255. let _this = this
  256. console.log(this.id)
  257. service.getcourtyardNetworkManagement(this.id).then(res => {
  258. console.log(_this.typelist)
  259. _this.buildingName = res.buildingName
  260. _this.unitName = res.unitName
  261. // let list = []
  262. // list = _this.typelist.find_problem
  263. // list.forEach((item) => {
  264. // if (item.dictValue == res.findProblem) {
  265. // _this.causesOfFamageLabel = item.dictLabel
  266. // }
  267. // })
  268. if (null != res.photoList) {
  269. res.photoList.forEach(item => {
  270. let url = {}
  271. url.url = item
  272. url.type = 'image'
  273. this.imgymxs.push(url)
  274. this.imgArr.push(item)
  275. })
  276. }
  277. this.form = res
  278. })
  279. }
  280. _this.typelist = res
  281. console.log(res)
  282. })
  283. },
  284. confirm(e) {
  285. this.form.findProblem =e
  286. },
  287. choose() {
  288. let _this = this;
  289. uni.showActionSheet({
  290. title: '上传',
  291. itemList: ['图片', '视频'],
  292. success: (res) => {
  293. // console.log(res)
  294. if (res.tapIndex == 0) {
  295. this.chooseimage()
  296. } else {
  297. this.choosevideo()
  298. }
  299. }
  300. })
  301. },
  302. chooseimage() {
  303. console.log('图片')
  304. let _this = this;
  305. uni.chooseImage({
  306. sourceType: ['camera'],
  307. success(resp) {
  308. console.log('res--uni.chooseMedia', resp);
  309. resp.tempFiles.forEach((item, index) => {
  310. const task = uni.uploadFile({
  311. url: _this.$HTTP.webUrl + `/obs`,
  312. filePath: item.path,
  313. name: 'file',
  314. formData: {},
  315. header: _this.headers,
  316. success: res => {
  317. // 判断是否json字符串,将其转为json格式
  318. let data = _this.$u.test.jsonString(res.data) ? JSON.parse(
  319. res.data) : res.data;
  320. if (![200, 201, 204].includes(res.statusCode)) {
  321. // this.uploadError(index, data);
  322. _this.$UTILS.showPrompt('选取失败!')
  323. } else {
  324. // 上传成功
  325. // this.lists[index].response = data;
  326. // this.lists[index].progress = 100;
  327. // this.lists[index].error = false;
  328. // this.$emit('on-success', data, index, this.lists, this
  329. // .index);
  330. if (_this.progress === 100) {
  331. // console.log('_this.progress', _this.progress)
  332. // console.log('data----', data)
  333. // console.log('res--', res)
  334. _this.imgymxs.push({
  335. url: data.data.url,
  336. type: 'image'
  337. })
  338. _this.imgArr.push(data.data.url)
  339. // console.log('imgArr', _this.imgArr)
  340. _this.$UTILS.showPrompt('选取成功!')
  341. }
  342. }
  343. },
  344. fail: e => {
  345. _this.$UTILS.showPrompt('选取失败!')
  346. this.uploadError(index, e);
  347. },
  348. complete: res => {
  349. _this.uploading = false;
  350. // _this.uploadFile(index + 1);
  351. // this.$emit('on-change', res, index, this.lists, this
  352. // .index);
  353. }
  354. });
  355. task.onProgressUpdate(res => {
  356. // if (res.progress > 0) {
  357. // this.lists[index].progress = res.progress;
  358. // this.$emit('on-progress', res, index, this.lists, this.index);
  359. // }
  360. _this.progress = res.progress;
  361. console.log('onProgressUpdate', res)
  362. uni.showLoading({
  363. title: '选取中'
  364. })
  365. });
  366. })
  367. },
  368. })
  369. },
  370. choosevideo() {
  371. let _this = this;
  372. console.log('视频')
  373. uni.chooseVideo({
  374. sourceType: ['camera'],
  375. maxDuration: 30,
  376. success(resp) {
  377. const task = uni.uploadFile({
  378. url: _this.$HTTP.webUrl + `/obs`,
  379. filePath: resp.tempFilePath,
  380. name: 'file',
  381. formData: {},
  382. header: _this.headers,
  383. success: res => {
  384. // 判断是否json字符串,将其转为json格式
  385. let data = _this.$u.test.jsonString(res.data) ? JSON.parse(res.data) :
  386. res.data;
  387. if (![200, 201, 204].includes(res.statusCode)) {
  388. this.uploadError(index, data);
  389. } else {
  390. // 上传成功
  391. // this.lists[index].response = data;
  392. // this.lists[index].progress = 100;
  393. // this.lists[index].error = false;
  394. // this.$emit('on-success', data, index, this.lists, this
  395. // .index);
  396. if (_this.progress === 100) {
  397. console.log('_this.progress', _this.progress)
  398. console.log('data----', data)
  399. console.log('res--', res)
  400. // _this.imgArr.push(data.data.url)
  401. _this.imgymxs.push({
  402. url: data.data.url,
  403. type: 'video'
  404. })
  405. _this.imgArr.push(data.data.url)
  406. console.log('imgArr', _this.imgArr)
  407. _this.$UTILS.showPrompt('选取成功!')
  408. }
  409. }
  410. },
  411. fail: e => {
  412. _this.$UTILS.showPrompt('选取失败!')
  413. this.uploadError(index, e);
  414. },
  415. complete: res => {
  416. uni.hideLoading();
  417. _this.uploading = false;
  418. // _this.uploadFile(index + 1);
  419. // this.$emit('on-change', res, index, this.lists, this
  420. // .index);
  421. }
  422. });
  423. task.onProgressUpdate(res => {
  424. // if (res.progress > 0) {
  425. // this.lists[index].progress = res.progress;
  426. // this.$emit('on-progress', res, index, this.lists, this.index);
  427. // }
  428. _this.progress = res.progress;
  429. console.log('onProgressUpdate', res)
  430. uni.showLoading({
  431. title: '选取中'
  432. })
  433. });
  434. },
  435. })
  436. },
  437. remove(index) {
  438. uni.showModal({
  439. title: '提示',
  440. content: '是否删除该图片或视频?',
  441. success: (res) => {
  442. if (res.confirm) {
  443. this.imgArr.splice(index, 1);
  444. this.imgymxs.splice(index, 1);
  445. console.log('this.imgarr', this.imgArr)
  446. }
  447. }
  448. })
  449. },
  450. }
  451. }
  452. </script>
  453. <style>
  454. .project-content {
  455. padding: 10rpx 20rpx;
  456. border-radius: 20rpx;
  457. background: #fff;
  458. width: 90%;
  459. margin: 0 auto;
  460. }
  461. .background {
  462. z-index: -1;
  463. position: fixed;
  464. width: 100%;
  465. height: 100%;
  466. background-size: 100% 100%;
  467. }
  468. </style>