CourtyardNetworkManagement.vue 11 KB

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