patroladd.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="check">
  3. <uni-forms ref="form" :model="datainfo">
  4. <view class="cbox">
  5. <view class="patlist">
  6. <view class="pattop flexc">
  7. <image :src="home" class="imgs"></image>
  8. <view class="tit">{{datainfo.checkAddress}}</view>
  9. <view class="flex1"></view>
  10. </view>
  11. <view class="patlistr">
  12. <view class="clist"><view class="tit">巡检类型</view>:{{kaType(datainfo.checkType)}}</view>
  13. <view class="clist"><view class="tit">巡检时间</view>:{{datainfo.checkResultTime}}</view>
  14. <view class="clist"><view class="tit">巡检路线</view>:{{datainfo.checkAddress}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="cbox" style="padding-bottom: 98rpx;">
  19. <view class="chmain">
  20. <uni-forms-item label="巡检结果" name="phonenumber">
  21. <!-- <picker range-key='dictLabel' :value="xgjgidx" :range="xgjgList" @change='bindDateChange'>
  22. <view class="flexc">
  23. <view class="flex1 txr f13" :class="datainfo.iszc?'co27':'coa'">{{datainfo.iszc?'是':'请选择是否正常'}}</view>
  24. <view class="rimg"><image :src="rimg"></image></view>
  25. </view>
  26. </picker> -->
  27. <picker range-key='dictLabel' :disabled="isdisabled" :value="xgjgidx" :range="xgjgList" @change='bindDateChange'>
  28. <view class="flexc">
  29. <view class="flex1 txr f13 co27" v-if="datainfo.checkResult&&!xgjg">{{statusFormats(datainfo.checkResult,xgjgList,'xgjg')}}</view>
  30. <view class="flex1 txr f13" v-else :class="xgjg?'co27':'coa'">{{xgjg||"请选择巡更结果"}}</view>
  31. <view class="rimg"><image :src="rimg"></image></view>
  32. </view>
  33. </picker>
  34. </uni-forms-item>
  35. <uni-easyinput maxlength='-1' type="textarea" autoHeight v-model="datainfo.checkResultDetails" :inputBorder='false' placeholder="可详细描述巡检结果…" />
  36. <view class="voice mb20">
  37. <view class="flexc">
  38. <image :src="voice"></image>
  39. 语音输入
  40. </view>
  41. </view>
  42. <!-- 图片 -->
  43. <view class="imgs">
  44. <block v-if="phofile&&phofile.length">
  45. <view class="img" v-for="(ite,idx) in phofile" :key="idx" @click="getPreview(idx,phofile)">
  46. <image :src="baseUrl+ite" class="pico"></image>
  47. <image :src="del" class="del" @click.stop="getDelFn(idx)"></image>
  48. </view>
  49. </block>
  50. <view class="addbox" @click="getaddImage">
  51. <image :src="photo" class="pico"></image>
  52. <view>添加图片</view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="pdlr12 mt63">
  57. <view class="rhbtn" @click="getSubmit">提交信息</view>
  58. </view>
  59. </view>
  60. </uni-forms>
  61. <loading></loading>
  62. </view>
  63. </template>
  64. <script>
  65. import config from '@/config'
  66. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  67. import {uploadmore} from '@/utils/common.js'
  68. import {getDictionaryFn} from "@/api/system/user.js"
  69. import {xgdjlDet,xgdjlPut} from "@/api/work/service.js"
  70. import {selectDictValue,selectValueKey} from "@/utils/common.js"
  71. export default {
  72. components: {},
  73. data() {
  74. return {
  75. voice: require('@/service/static/service/voice.png'),
  76. home:require("@/service/static/service/home.png"),
  77. photo:require("@/service/static/service/photo.png"),
  78. del:require('@/car/static/car/del.png'),
  79. rimg: require('@/people/static/people/rimg.png'),
  80. baseUrl: config.baseUrl,
  81. checkflag:true,
  82. datainfo: {
  83. "checkType":"",//巡更类型
  84. "checkTime":"",//巡更时间
  85. "checkAddress":"",//巡更路线
  86. "checkUserName":"",//巡更人姓名
  87. "checkUseId":"",//巡更人id
  88. "checkResult":"",//巡更结果 1:正常 2:损坏
  89. "checkResultDetails":"",//巡更结果详情
  90. "checkResultPhoto":"",//巡更结果照片
  91. // "checkResultTime":""//巡更结果时间
  92. },
  93. ptype:'add',
  94. id:2,
  95. isdisabled:false,
  96. xgjg:'',
  97. xgjgidx:'',
  98. xglxList:[],
  99. xgjgList:[],
  100. phofile:[]
  101. }
  102. },
  103. onLoad: function(e) {
  104. this.init();
  105. this.ptype='edit';
  106. this.id=e.id;
  107. this.getDetail()
  108. },
  109. methods: {
  110. checkPermi,
  111. checkRole,
  112. init(){
  113. // 巡更类型
  114. getDictionaryFn('patrol_type').then(res=>{
  115. if(res.code==200){
  116. this.xglxList = res.data.map(v => {
  117. return {
  118. dictLabel: v.dictLabel,
  119. dictValue: v.dictValue
  120. }
  121. })
  122. }
  123. })
  124. //巡更结果
  125. getDictionaryFn('check_result').then(res=>{
  126. if(res.code==200){
  127. this.xgjgList = res.data.map(v => {
  128. return {
  129. dictLabel: v.dictLabel,
  130. dictValue: v.dictValue
  131. }
  132. })
  133. }
  134. })
  135. },
  136. time() {
  137. var date = new Date();
  138. var y = date.getFullYear();
  139. var m = date.getMonth() + 1;
  140. var d = date.getDate();
  141. var h = date.getHours();
  142. var min = date.getMinutes();
  143. var s = date.getSeconds();
  144. var yearStr = y + '-' + (m < 10 ? ('0' + m) : m) + '-' + (d < 10 ? ('0' + d) : d)
  145. var timeStr = (h < 10 ? ('0' + h) : h) + ':' + (min < 10 ? ('0' + min) : min) + ':' + (s < 10 ? (
  146. '0' + s) : s);
  147. var kaTime = yearStr + ' ' + timeStr;
  148. return kaTime
  149. },
  150. kaType(data){
  151. return selectDictValue(this.xglxList, data);
  152. },
  153. statusFormats(data, list,type) {
  154. var aite=selectValueKey(list, data);
  155. if(type=='xgjg'){
  156. this.xgjgidx=aite.key
  157. }
  158. return aite.actions;
  159. },
  160. bindDateChange(e){
  161. var val=e.detail.value;
  162. this.datainfo.checkResult=this.xgjgList[val].dictValue;
  163. this.xgjg=this.xgjgList[val].dictLabel;
  164. },
  165. getPreview(idx,arr) {
  166. var newArr=[];
  167. arr.forEach(ite=>{
  168. var ds=this.baseUrl+ite
  169. newArr.push(ds)
  170. })
  171. uni.previewImage({
  172. urls: newArr,
  173. current:idx,
  174. success: function(data) {},
  175. fail: function(err) {}
  176. });
  177. },
  178. getDelFn(idx){
  179. var that=this;
  180. uni.showModal({
  181. title: '确认删除',
  182. content: "是否确认删除",
  183. cancelText: '取消',
  184. confirmText: '确认',
  185. success: function(res) {
  186. if (res.confirm) {
  187. that.phofile.splice(idx,1)
  188. } else if (res.cancel) {
  189. }
  190. }
  191. });
  192. },
  193. getaddImage(e){
  194. let that = this;
  195. let file =[],count=9
  196. uni.chooseImage({
  197. // count: 1,
  198. success:function(res){
  199. let img= res.tempFilePaths;
  200. if(img.length + file.length > count){
  201. uni.showToast({
  202. title: '最多上传'+count+'张图片',
  203. icon: 'none',
  204. duration: 2000
  205. })
  206. }else{
  207. let imglen = res.tempFilePaths.length;
  208. var fuwufile = [];
  209. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  210. that.phofile = that.phofile.concat(rs);
  211. })
  212. }
  213. }
  214. });
  215. },
  216. getDetail(){
  217. xgdjlDet(this.id).then(res=>{
  218. if(res.code==200){
  219. this.datainfo=res.data;
  220. if(res.data&&res.data.checkResultPhoto){
  221. this.phofile=res.data.checkResultPhoto.split(',')
  222. }
  223. }
  224. })
  225. },
  226. getSubmit(){
  227. var that=this;
  228. var params=JSON.parse(JSON.stringify(this.datainfo))
  229. var phofile=JSON.parse(JSON.stringify(this.phofile))
  230. if(phofile&&phofile.length){
  231. params.checkResultPhoto=this.phofile.join(',');
  232. }
  233. if(!params.checkResult){
  234. this.$toast("请选择巡更结果")
  235. return
  236. }
  237. params.checkResultTime=this.time();
  238. params.checkStatus='2';
  239. xgdjlPut(params).then(res=>{
  240. if(res.code==200){
  241. this.$toast("操作成功")
  242. setTimeout(function(){
  243. uni.$emit("refCarPark")
  244. uni.navigateBack({
  245. delta:1
  246. })
  247. },1500)
  248. }
  249. })
  250. }
  251. }
  252. }
  253. </script>
  254. <style>
  255. page{background: #F3F3F0;}
  256. </style>
  257. <style lang="scss" scoped>
  258. .check /deep/ .uni-forms-item{min-height: 106rpx;box-sizing: border-box;display: flex;align-items: center;margin-bottom: 0;border-bottom: 2rpx solid #E6E6E6;padding:10rpx 0;}
  259. .check .cbox /deep/ .uni-forms-item:last-child{border: none;}
  260. .check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  261. .check /deep/ .uni-easyinput{flex: 1;text-align: left;font-size: 26rpx;color: #222327;padding-left: 12rpx;min-height: 200rpx;}
  262. .check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
  263. .check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  264. .check /deep/ .uni-input-input{font-size: 26rpx;}
  265. .check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  266. .check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  267. .check /deep/ .uni-data-checklist .checklist-group .checklist-box{margin:10rpx 8rpx 10rpx 16rpx;}
  268. .check /deep/ .uni-data-checklist{flex: 0 0 auto;}
  269. .check{min-height: 100vh;padding: 20rpx 18rpx 24rpx;box-sizing: border-box;}
  270. .cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
  271. .chmain{padding: 0 32rpx;
  272. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  273. image{width: 100%;height: 100%;}
  274. }
  275. }
  276. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;margin-top: 40rpx;
  277. font-size: 24rpx;
  278. color: #45CB99;
  279. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  280. }
  281. .imgs{display: flex;align-items: center;flex-wrap: wrap;
  282. .img{width: 142rpx;height:142rpx;border-radius: 20rpx;margin: 0 26rpx 20rpx 0;position: relative;
  283. &:nth-of-type(4n){margin-right: 0;}
  284. }
  285. .pico{width: 100%;height: 100%;border-radius: 20rpx;}
  286. .del{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  287. .addbox{background: #F0F0F0;border-radius: 20rpx;display: flex;align-items: center;flex-direction: column;width: 142rpx;height:142rpx;justify-content: center;margin-bottom: 20rpx;
  288. image{width: 48rpx;height: 42rpx;margin-bottom: 12rpx;}
  289. view{font-weight: 500;font-size: 24rpx;color: #666666;}
  290. }
  291. }
  292. }
  293. .patlist{background: #FFFFFF;border-radius: 20rpx;margin-bottom: 24rpx;padding: 0 24rpx 30rpx;
  294. .pattop{padding:22rpx 30rpx;margin-bottom: 2rpx;
  295. .imgs{width: 28rpx;height: 28rpx;margin-right: 12rpx;}
  296. .tit{font-size: 30rpx;color: #272727;font-weight: bold;margin-right: 14rpx;}
  297. .txt{font-weight: 500;font-size:24rpx;
  298. &.ca{color: #3565ED;}
  299. &.cb{color: #FE5A0E;}
  300. &.cc{color: #28C529;}
  301. &.cd{color: #FF6969;}
  302. }
  303. }
  304. .patlistr{background: #EFF4FF;border-radius: 20rpx;padding: 20rpx 32rpx;
  305. .clist{font-weight: 500;font-size: 26rpx;color: #272727;display: flex;line-height: 50rpx;
  306. .tit{font-size: 26rpx;flex: 0 0 auto;min-width: 108rpx;text-align-last: justify;font-weight: bold;}
  307. }
  308. }
  309. }
  310. </style>