report.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. <template>
  2. <view class="f-padding">
  3. <u-navbar
  4. :title="title"
  5. title-color="#fff"
  6. :border-bottom="false"
  7. :custom-back="customBack"
  8. back-icon-color="#CCE8FF"
  9. :background="{background: 'linear-gradient(99deg, #7A4398 0%, #5A5DB9 100%)' }"></u-navbar>
  10. <u-form :model="form" ref="uForm">
  11. <!-- <u-form-item label="路段/停车场:" prop="roadName" required :label-width="labelWidth">
  12. <u-input v-model="form.roadName" type="select" :border="true" placeholder="请选择" @click="selectShow = true" />
  13. <u-select v-model="selectShow" :list="roadList" value-name="roadNo" label-name="roadName" @confirm="selectConfirm"></u-select>
  14. </u-form-item> -->
  15. <view class="block-til">异常信息</view>
  16. <view class="block">
  17. <u-form-item label="问题描述" prop="exceprionDes" required :label-width="labelWidth">
  18. <u-input type="textarea" :border="true" maxlength="200" v-model="form.exceprionDes" />
  19. </u-form-item>
  20. <u-form-item label="图片说明" :label-width="labelWidth" :border-bottom="false">
  21. <u-upload ref="uploadRef" :action="action" :file-list="fileList" max-count="3"></u-upload>
  22. </u-form-item>
  23. </view>
  24. <view class="block-til">处理登记</view>
  25. <view class="block">
  26. <u-form-item label="处理状态" :label-width="labelWidth" prop="isProcess" :required="true">
  27. <view class="select-view" @click="oneSelectOpen('isProcess')">
  28. {{form.isProcess|filterIsProcess}}
  29. </view>
  30. <u-icon @click="oneSelectOpen('isProcess')" color="#42494F" name="arrow-right"></u-icon>
  31. </u-form-item>
  32. <view v-if="form.isProcess&&form.isProcess!=0" class="">
  33. <u-form-item label="处理员" prop="processBy" required :label-width="labelWidth">
  34. <u-input type="text" :border="true" maxlength="200" v-model="form.processBy" />
  35. </u-form-item>
  36. <u-form-item label="处理设备" :label-width="labelWidth" prop="processDevice" :required="false">
  37. <view class="select-view" @click="oneSelectOpen('processDeviceList')">
  38. {{filterProcessDevice(form.processDevice)||'请选择'}}
  39. </view>
  40. <u-icon @click="oneSelectOpen('processDeviceList')" color="#42494F" name="arrow-right"></u-icon>
  41. </u-form-item>
  42. <u-form-item label="损坏类型" :label-width="labelWidth" prop="damageType" :required="false">
  43. <view class="select-view" @click="oneSelectOpen('damageTypeList')">
  44. {{filterDamageType(form.damageType)||'请选择'}}
  45. </view>
  46. <u-icon @click="oneSelectOpen('damageTypeList')" color="#42494F" name="arrow-right"></u-icon>
  47. </u-form-item>
  48. <u-form-item label="处理方式" :label-width="labelWidth" prop="processType" :required="false">
  49. <view class="select-view" @click="oneSelectOpen('processTypeList')">
  50. {{filterProcessType(form.processType)||'请选择'}}
  51. </view>
  52. <u-input @click="oneSelectOpen('processTypeList')" placeholder="请选择" v-model="form.processType"
  53. disabled />
  54. <u-icon @click="oneSelectOpen('processTypeList')" color="#42494F" name="arrow-right"></u-icon>
  55. </u-form-item>
  56. </view>
  57. </view>
  58. </u-form>
  59. <u-button type="primary" @click="submit" style="margin-top: 24rpx;">提交</u-button>
  60. <!-- 单列下拉选择 -->
  61. <u-select v-model="selectShow" :list="selectData" @confirm="selectConfirm"></u-select>
  62. </view>
  63. </template>
  64. <script>
  65. export default{
  66. data(){
  67. return{
  68. title:'问题上报',
  69. labelWidth:190,
  70. action:this.config.upFileUrl,
  71. fileList:[],
  72. selectShow:false,
  73. selectList:[],
  74. roadList:[],
  75. selectTag: '',
  76. selectShow: false,
  77. selectData: [],
  78. listMap: {
  79. isProcess: [{
  80. value: '0',
  81. label: '未处理'
  82. }, {
  83. value: '1',
  84. label: '已处理'
  85. }, {
  86. value: '2',
  87. label: '部分处理'
  88. }],
  89. processDeviceList:[],
  90. damageTypeList:[],
  91. processTypeList:[],
  92. },
  93. form:{
  94. roadName:'',
  95. roadNo:'',
  96. exceprionDes:'',
  97. imgList:[]
  98. },
  99. rules:{
  100. roadName: [
  101. {
  102. required: true,
  103. message: '请选择路段',
  104. trigger: ['change','blur'],
  105. }
  106. ],
  107. processBy: [
  108. {
  109. required: true,
  110. message: '请输入处理员',
  111. trigger: ['change','blur'],
  112. }
  113. ],
  114. exceprionDes: [
  115. {
  116. required: true,
  117. message: '请输入内容',
  118. trigger: ['change','blur'],
  119. }
  120. ],
  121. }
  122. }
  123. },
  124. onLoad(page){
  125. this.form.deviceId = page.deviceId;
  126. this.form.deviceType = page.deviceType;
  127. this.form.roadNo = page.roadNo;
  128. this.form.roadName = page.roadName;
  129. this.reportId = page.reportId;
  130. // console.log('this.reportId',this.reportId);
  131. if(this.reportId){
  132. this.getReportDetails();
  133. }
  134. },
  135. onShow(){
  136. this.getProcessDevice();
  137. this.getDamageType();
  138. this.getProcessType();
  139. },
  140. onReady() {
  141. this.$refs.uForm.setRules(this.rules);
  142. },
  143. computed:{
  144. filterProcessDevice(value){
  145. return function(value){
  146. let v = '';
  147. for (let i = 0; i < this.listMap.processDeviceList.length; i++){
  148. let item = this.listMap.processDeviceList[i];
  149. if (value == item.value) {
  150. v = item.label;
  151. break;
  152. }
  153. }
  154. return v
  155. }
  156. },
  157. filterDamageType(value){
  158. return function(value){
  159. let v = '';
  160. for (let i = 0; i < this.listMap.damageTypeList.length; i++){
  161. let item = this.listMap.damageTypeList[i];
  162. if (value == item.value) {
  163. v = item.label;
  164. break;
  165. }
  166. }
  167. return v
  168. }
  169. },
  170. filterProcessType(value){
  171. return function(value){
  172. let v = '';
  173. for (let i = 0; i < this.listMap.processTypeList.length; i++){
  174. let item = this.listMap.processTypeList[i];
  175. if (value == item.value) {
  176. v = item.label;
  177. break;
  178. }
  179. }
  180. return v
  181. }
  182. },
  183. },
  184. methods:{
  185. customBack(){
  186. uni.navigateBack()
  187. },
  188. getReportDetails(){
  189. this.$u.api.excptionById({id:this.reportId}).then(res=>{
  190. if(res.code==200){
  191. // this.reportDetails = res.data;
  192. // this.fileList = res.data.imgList;
  193. let imgList = res.data.imgList;
  194. if(imgList.length>0){
  195. this.fileList=imgList.map(img=>{
  196. return {url:img}
  197. })
  198. }
  199. this.form = {
  200. ...res.data,
  201. imgList:[],
  202. }
  203. console.log('this.formthis.form',this.form);
  204. }else{
  205. uni.showToast({
  206. icon:'none',
  207. title:res.msg
  208. })
  209. }
  210. console.log('res',res);
  211. }).catch(err=>{
  212. console.log('err',err);
  213. })
  214. },
  215. getProcessDevice(){
  216. console.log('this.form.deviceType',this.form.deviceType);
  217. if(this.form.deviceType==1){
  218. this.getProcessDeviceGeo();
  219. }else if(this.form.deviceType==2){
  220. this.getProcessDeviceLock();
  221. }else if(this.form.deviceType==3){
  222. this.getProcessDeviceRoom();
  223. }
  224. },
  225. getProcessDeviceGeo(){
  226. this.$u.api.processDeviceGeo().then(res=>{
  227. if(res.code==200){
  228. this.listMap.processDeviceList = res.data.data.map(item=>{
  229. return {value:item.dictValue,label:item.dictLabel}
  230. });
  231. // console.log('this.listMap.processDeviceList',this.listMap.processDeviceList);
  232. }else{
  233. uni.showToast({
  234. icon:'none',
  235. title:res.msg
  236. })
  237. }
  238. console.log('res',res);
  239. }).catch(err=>{
  240. console.log('err',err);
  241. })
  242. },
  243. getProcessDeviceLock(){
  244. this.$u.api.processDeviceLock().then(res=>{
  245. if(res.code==200){
  246. this.listMap.processDeviceList = res.data.data.map(item=>{
  247. return {value:item.dictValue,label:item.dictLabel}
  248. });
  249. // console.log('this.listMap.processDeviceList',this.listMap.processDeviceList);
  250. }else{
  251. uni.showToast({
  252. icon:'none',
  253. title:res.msg
  254. })
  255. }
  256. console.log('res',res);
  257. }).catch(err=>{
  258. console.log('err',err);
  259. })
  260. },
  261. getProcessDeviceRoom(){
  262. this.$u.api.processDeviceRoom().then(res=>{
  263. if(res.code==200){
  264. this.listMap.processDeviceList = res.data.data.map(item=>{
  265. return {value:item.dictValue,label:item.dictLabel}
  266. });
  267. // console.log('this.listMap.processDeviceList',this.listMap.processDeviceList);
  268. }else{
  269. uni.showToast({
  270. icon:'none',
  271. title:res.msg
  272. })
  273. }
  274. console.log('res',res);
  275. }).catch(err=>{
  276. console.log('err',err);
  277. })
  278. },
  279. getDamageType(){
  280. this.$u.api.damageType().then(res=>{
  281. if(res.code==200){
  282. this.listMap.damageTypeList = res.data.data.map(item=>{
  283. return {value:item.dictValue,label:item.dictLabel}
  284. });
  285. // console.log('getDeviceStatis',res);
  286. }else{
  287. uni.showToast({
  288. icon:'none',
  289. title:res.msg
  290. })
  291. }
  292. console.log('res',res);
  293. }).catch(err=>{
  294. console.log('err',err);
  295. })
  296. },
  297. getProcessType(){
  298. this.$u.api.processType().then(res=>{
  299. if(res.code==200){
  300. this.listMap.processTypeList = res.data.data.map(item=>{
  301. return {value:item.dictValue,label:item.dictLabel}
  302. });
  303. // console.log('getDeviceStatis',res);
  304. }else{
  305. uni.showToast({
  306. icon:'none',
  307. title:res.msg
  308. })
  309. }
  310. console.log('res',res);
  311. }).catch(err=>{
  312. console.log('err',err);
  313. })
  314. },
  315. // selectConfirm(e){
  316. // // console.log('e',e);
  317. // this.form.roadNo = e[0].value;
  318. // this.form.roadName = e[0].label;
  319. // // console.log('this.form',this.form);
  320. // },
  321. // 单列下拉选择框打开事件
  322. oneSelectOpen(key) {
  323. this.selectTag = key;
  324. this.selectData = this.listMap[key];
  325. this.selectShow = true
  326. },
  327. selectConfirm(e) {
  328. // console.log('selectConfirm',e);
  329. // console.log('selectTag', this.selectTag);
  330. switch (this.selectTag) {
  331. case 'isProcess': //处理状态
  332. // console.log('处理状态',e);
  333. this.form.isProcess = e[0].value;
  334. break;
  335. case 'processDeviceList': //处理设备
  336. this.form.processDevice = e[0].value;
  337. this.form.damageType = '';
  338. this.form.processType = '';
  339. // this.getDamageType();
  340. break;
  341. case 'damageTypeList': //损坏类型
  342. this.form.damageType = e[0].value;
  343. this.form.processType = '';
  344. // this.getProcessType();
  345. break;
  346. case 'processTypeList': //处理方式
  347. this.form.processType = e[0].value;
  348. break;
  349. default:
  350. // console.log('3', e);
  351. }
  352. },
  353. submit(){
  354. // console.log('this.form',this.form);
  355. let that = this;
  356. this.$refs.uForm.validate(valid => {
  357. if (valid) {
  358. console.log('验证通过');
  359. // delete this.dealForm.selectedUserList;
  360. let files = [];
  361. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  362. files = this.$refs.uploadRef.lists.filter(val => {
  363. return val.progress == 100;
  364. })
  365. console.log('files',files);
  366. // 如果您不需要进行太多的处理,直接如下即可
  367. // files = this.$refs.uUpload.lists;
  368. files.forEach(function(item){
  369. console.log('item',item);
  370. if(item?.response?.data){that.form.imgList.push(item.response.data.url)}
  371. else if(item.url){that.form.imgList.push(item.url)}
  372. });
  373. if(this.reportId){
  374. this.editReport();
  375. }else{
  376. this.addReport();
  377. }
  378. } else {
  379. console.log('验证失败');
  380. }
  381. });
  382. },
  383. addReport(){
  384. let that = this;
  385. this.$u.api.deviceexcptionprocess(this.form).then(res=>{
  386. console.log('res',res);
  387. // this.form = {};
  388. uni.showToast({
  389. icon:'none',
  390. title:res.msg,
  391. duration:1500,
  392. });
  393. if(res.code==200){
  394. setTimeout(()=>{
  395. that.customBack()
  396. },1500)
  397. }
  398. }).catch(err=>{
  399. uni.showToast({
  400. icon:'none',
  401. title:err.msg
  402. })
  403. console.log('err',err);
  404. })
  405. },
  406. editReport(){
  407. let that = this;
  408. this.$u.api.editDeviceexcptionprocess(this.form).then(res=>{
  409. console.log('res',res);
  410. // this.form = {};
  411. uni.showToast({
  412. icon:'none',
  413. title:res.msg,
  414. duration:1500,
  415. });
  416. if(res.code==200){
  417. setTimeout(()=>{
  418. that.customBack()
  419. },1500)
  420. }
  421. }).catch(err=>{
  422. uni.showToast({
  423. icon:'none',
  424. title:err.msg
  425. })
  426. console.log('err',err);
  427. })
  428. }
  429. }
  430. }
  431. </script>
  432. <style>
  433. page{background-color: #F3F3F3;}
  434. </style>
  435. <style lang="scss" scoped>
  436. @import '@/pages/report/report.scss';
  437. .select-view{
  438. box-sizing: border-box;
  439. padding-right: 24rpx;
  440. width: 100%;
  441. text-align: right;
  442. }
  443. </style>