emergencyRepairOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view>
  3. <image src="/static/icon/background.png" mode="" class="background"></image>
  4. <view class="project-content">
  5. <u-form labelPosition="left" :model="form" :rules="rules" ref="form">
  6. <u-form-item label="接警时间" borderBottom ref="item1" labelWidth="120">
  7. <u-input v-model="form.repairTime" border="none" disabled @click="showtime=true"></u-input>
  8. <u-picker v-model="showtime" mode="time" :params="params" @confirm="time()"></u-picker>
  9. </u-form-item>
  10. <u-form-item label="报修人" labelWidth="120" borderBottom ref="item1">
  11. <u-input v-model="form.repairName" border="none"></u-input>
  12. </u-form-item>
  13. <u-form-item label="联系电话" labelWidth="120" borderBottom ref="item1">
  14. <u-input v-model="form.repairPhone" border="none"></u-input>
  15. </u-form-item>
  16. <u-form-item label="报修类型" labelWidth="120" borderBottom ref="item1">
  17. <u-input v-model="repairTypeLabel" disabled @click=" showrepairType= true;" borderBottom
  18. disabledColor="#ffffff" placeholder="请选择报修类型"></u-input>
  19. <u-select v-model="showrepairType" :list="typelist.repair_type" label-name="dictLabel"
  20. value-name="dictValue" @confirm="repairType()"></u-select>
  21. <u-icon slot="right" name="arrow-right"></u-icon>
  22. </u-form-item>
  23. <u-form-item label="报修内容" labelWidth="120" borderBottom ref="item1">
  24. <u-input v-model="form.repairContent" type="textarea" showWordLimit='255' border="none"></u-input>
  25. </u-form-item>
  26. <u-form-item label="损坏原因" labelWidth="120" borderBottom ref="item1">
  27. <u-input v-model="causesOfFamageLabel" disabled @click=" causesOfFamageType = true;"
  28. borderBottom></u-input>
  29. <u-select v-model="causesOfFamageType" :list="typelist.causes_of_damage" label-name="dictLabel" value-name="dictValue" @confirm="causesOfFamage()"></u-select>
  30. <u-icon slot="right" name="arrow-right"></u-icon>
  31. </u-form-item>
  32. <u-form-item label="管线压力" labelWidth="120" borderBottom ref="item1">
  33. <u-input v-model="pipelinePressureLabel" disabled @click=" pipelinePressureType= true;"
  34. borderBottom></u-input>
  35. <u-select v-model="pipelinePressureType" :list="typelist.pipeline_pressure" label-name="dictLabel" value-name="dictValue" @confirm="pipelinePressure()"></u-select>
  36. <u-icon slot="right" name="arrow-right"></u-icon>
  37. </u-form-item>
  38. <u-form-item label="停气方式" labelWidth="120" borderBottom ref="item1">
  39. <u-input v-model="form.stopGasMethod" border="none"></u-input>
  40. </u-form-item>
  41. <u-form-item label="使用材料" labelWidth="120" borderBottom ref="item1">
  42. <u-input v-model="form.usingMaterials" border="none"></u-input>
  43. </u-form-item>
  44. <u-form-item label="维修人" labelWidth="120" borderBottom ref="item1">
  45. <u-input v-model="form.maintenanceName" border="none"></u-input>
  46. </u-form-item>
  47. <u-form-item label="完成时间" labelWidth="120" borderBottom ref="item1">
  48. <u-input v-model="form.maintenanceTime" border="none" disabled @click="showtime2=true"></u-input>
  49. <u-picker v-model="showtime2" mode="time" :params="params" @confirm="time2()"></u-picker>
  50. </u-form-item>
  51. <u-form-item label="维修照片" labelWidth="120" borderBottom ref="item1">
  52. <view class="" style="display: flex; flex-wrap: wrap; margin: 0 55rpx;">
  53. <image src="/static/icon/chooseimg.png" mode=""
  54. style="width: 190rpx; height: 190rpx; margin: 0 12rpx; " @click="choose()"></image>
  55. <view v-for="(item,index) in imgymxs" :key="index" style="position: relative;">
  56. <view v-if="item.type == 'image'">
  57. <image :src="item.url" mode="" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"
  58. @click="showPhoto(index)">
  59. </image>
  60. </view>
  61. <view v-else>
  62. <video :src="item" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"></video>
  63. </view>
  64. <view @click="remove(index)"
  65. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  66. <u-icon name="close" color="#FFFFFF" size="35"></u-icon>
  67. </view>
  68. </view>
  69. </view>
  70. </u-form-item>
  71. <u-form-item label="备注" labelWidth="120" borderBottom ref="item1">
  72. <u-input v-model="form.remarks" border="none" type="textarea"></u-input>
  73. </u-form-item>
  74. </u-form>
  75. <u-button @click="save()">确认上传</u-button>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. import service from '@/api/index.js'
  81. export default {
  82. data() {
  83. return {
  84. params: {
  85. year: true,
  86. month: true,
  87. day: true,
  88. hour: true,
  89. minute: true,
  90. second: false
  91. },
  92. showtime:false,
  93. action: this.$HTTP.webUrl + `/obs`,
  94. causesOfFamageType: false,
  95. pipelinePressureType: false,
  96. repairTypeLabel: null,
  97. causesOfFamageLabel: null,
  98. pipelinePressureLabel: null,
  99. showtime2:false,
  100. headers: {
  101. MAuthorization: "wxBearer " + uni.getStorageSync('token')
  102. },
  103. url: [],
  104. uploading: false,
  105. imgArr: [],
  106. imgymxs: [],
  107. causesOfDamage:null,
  108. progress: 0, //图片或视频上传百分比
  109. form: {
  110. },
  111. userInfo: {},
  112. showrepairType: false,
  113. community: null,
  114. communityName:null,
  115. dictlist: ['causes_of_damage', 'pipeline_pressure','repair_type'],
  116. typelist: []
  117. };
  118. },
  119. onLoad(e) {
  120. uni.setNavigationBarTitle({
  121. title: '抢险维修单'
  122. });
  123. this.getdictsysinfo()
  124. },
  125. methods: {
  126. getdictsysinfo() {
  127. let _this = this
  128. service.getDictInfoList({
  129. type: this.dictlist
  130. }).then(res => {
  131. _this.typelist = res
  132. console.log(res)
  133. })
  134. },
  135. time(e)
  136. {
  137. console.log(`${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`)
  138. this.form.repairTime= `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`
  139. },
  140. time2(e)
  141. {
  142. console.log(`${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`)
  143. this.form.maintenanceTime= `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`
  144. },
  145. save() {
  146. let _this=this
  147. // this.form.unitId=this.unit
  148. this.form.photoList=this.imgArr
  149. service.setemergencyRepair(this.form
  150. ).then(res => {
  151. console.log(res)
  152. _this.$UTILS.showPrompt('上报成功!')
  153. setTimeout(()=>{
  154. console.log('跳')
  155. uni.switchTab({
  156. url:'/pages/index/index'
  157. })
  158. },2000)
  159. })
  160. },
  161. repairType(e) {
  162. console.log(e[0])
  163. this.form.repairType = e[0].value
  164. this.repairTypeLabel = e[0].label
  165. },
  166. causesOfFamage(e) {
  167. this.causesOfDamage=e[0].value
  168. this.form.causesOfDamage = e[0].value
  169. console.log(e[0])
  170. this.causesOfFamageLabel = e[0].label
  171. },
  172. pipelinePressure(e) {
  173. console.log(e[0])
  174. this.form.pipelinePressure = e[0].value
  175. this.pipelinePressureLabel = e[0].label
  176. },
  177. choose() {
  178. let _this = this;
  179. uni.showActionSheet({
  180. title: '上传',
  181. itemList: ['图片', '视频'],
  182. success: (res) => {
  183. // console.log(res)
  184. if (res.tapIndex == 0) {
  185. this.chooseimage()
  186. } else {
  187. this.choosevideo()
  188. }
  189. }
  190. })
  191. },
  192. chooseimage() {
  193. console.log('图片')
  194. let _this = this;
  195. uni.chooseImage({
  196. sizeType: ['album', 'camera'],
  197. success(resp) {
  198. console.log('res--uni.chooseMedia', resp);
  199. resp.tempFiles.forEach((item, index) => {
  200. const task = uni.uploadFile({
  201. url: _this.$HTTP.webUrl + `/obs`,
  202. filePath: item.path,
  203. name: 'file',
  204. formData: {},
  205. header: _this.headers,
  206. success: res => {
  207. // 判断是否json字符串,将其转为json格式
  208. let data = _this.$u.test.jsonString(res
  209. .data) ? JSON.parse(res.data) : res.data;
  210. if (![200, 201, 204].includes(res.statusCode)) {
  211. // this.uploadError(index, data);
  212. _this.$UTILS.showPrompt('选取失败!')
  213. } else {
  214. // 上传成功
  215. // this.lists[index].response = data;
  216. // this.lists[index].progress = 100;
  217. // this.lists[index].error = false;
  218. // this.$emit('on-success', data, index, this.lists, this
  219. // .index);
  220. if (_this.progress === 100) {
  221. // console.log('_this.progress', _this.progress)
  222. // console.log('data----', data)
  223. // console.log('res--', res)
  224. _this.imgymxs.push({
  225. url: data.data.url,
  226. type: 'image'
  227. })
  228. _this.imgArr.push(data.data.url)
  229. // console.log('imgArr', _this.imgArr)
  230. _this.$UTILS.showPrompt('选取成功!')
  231. }
  232. }
  233. },
  234. fail: e => {
  235. _this.$UTILS.showPrompt('选取失败!')
  236. this.uploadError(index, e);
  237. },
  238. complete: res => {
  239. _this.uploading = false;
  240. // _this.uploadFile(index + 1);
  241. // this.$emit('on-change', res, index, this.lists, this
  242. // .index);
  243. }
  244. });
  245. task.onProgressUpdate(res => {
  246. // if (res.progress > 0) {
  247. // this.lists[index].progress = res.progress;
  248. // this.$emit('on-progress', res, index, this.lists, this.index);
  249. // }
  250. _this.progress = res.progress;
  251. console.log('onProgressUpdate', res)
  252. uni.showLoading({
  253. title: '选取中'
  254. })
  255. });
  256. })
  257. },
  258. })
  259. },
  260. choosevideo() {
  261. let _this = this;
  262. console.log('视频')
  263. uni.chooseVideo({
  264. sourceType: ['album', 'camera'],
  265. maxDuration: 30,
  266. success(resp) {
  267. const task = uni.uploadFile({
  268. url: _this.$HTTP.webUrl + `/obs`,
  269. filePath: resp.tempFilePath,
  270. name: 'file',
  271. formData: {},
  272. header: _this.headers,
  273. success: res => {
  274. // 判断是否json字符串,将其转为json格式
  275. let data = _this.$u.test.jsonString(res
  276. .data) ? JSON.parse(res.data) : res.data;
  277. if (![200, 201, 204].includes(res.statusCode)) {
  278. this.uploadError(index, data);
  279. } else {
  280. // 上传成功
  281. // this.lists[index].response = data;
  282. // this.lists[index].progress = 100;
  283. // this.lists[index].error = false;
  284. // this.$emit('on-success', data, index, this.lists, this
  285. // .index);
  286. if (_this.progress === 100) {
  287. console.log('_this.progress', _this.progress)
  288. console.log('data----', data)
  289. console.log('res--', res)
  290. // _this.imgArr.push(data.data.url)
  291. _this.imgymxs.push({
  292. url: data.data.url,
  293. type: 'video'
  294. })
  295. _this.imgArr.push(data.data.url)
  296. console.log('imgArr', _this.imgArr)
  297. _this.$UTILS.showPrompt('选取成功!')
  298. }
  299. }
  300. },
  301. fail: e => {
  302. _this.$UTILS.showPrompt('选取失败!')
  303. this.uploadError(index, e);
  304. },
  305. complete: res => {
  306. uni.hideLoading();
  307. _this.uploading = false;
  308. // _this.uploadFile(index + 1);
  309. // this.$emit('on-change', res, index, this.lists, this
  310. // .index);
  311. }
  312. });
  313. task.onProgressUpdate(res => {
  314. // if (res.progress > 0) {
  315. // this.lists[index].progress = res.progress;
  316. // this.$emit('on-progress', res, index, this.lists, this.index);
  317. // }
  318. _this.progress = res.progress;
  319. console.log('onProgressUpdate', res)
  320. uni.showLoading({
  321. title: '选取中'
  322. })
  323. });
  324. },
  325. })
  326. },
  327. remove(index) {
  328. uni.showModal({
  329. title: '提示',
  330. content: '是否删除该图片或视频?',
  331. success: (res) => {
  332. if (res.confirm) {
  333. this.imgArr.splice(index, 1);
  334. this.imgymxs.splice(index, 1);
  335. console.log('this.imgarr', this.imgArr)
  336. }
  337. }
  338. })
  339. },
  340. }
  341. }
  342. </script>
  343. <style lang="scss">
  344. .background {
  345. z-index: -1;
  346. position: fixed;
  347. width: 100%;
  348. height: 100%;
  349. background-size: 100% 100%;
  350. }
  351. .project-content {
  352. border: 4rpx solid #3857F3;
  353. margin: 40rpx 55rpx 0;
  354. padding: 30rpx 20rpx;
  355. border-radius: 48rpx;
  356. }
  357. </style>