vadd.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. <template>
  2. <view class="check">
  3. <uni-forms ref="form" :model="datainfo" :rules="rules">
  4. <view class="cbox">
  5. <view class="chtop flexc">
  6. <view class="line"></view>
  7. <view>访客信息</view>
  8. </view>
  9. <view class="chmain">
  10. <!-- 选择房屋 -->
  11. <uni-forms-item label="访客姓名" name="name">
  12. <view class="flexc">
  13. <uni-easyinput :disabled="isdisabled" v-model="datainfo.name" :inputBorder='false' placeholder="请输入访客姓名" />
  14. <!-- <uni-data-checkbox selectedColor="#0156FE" selectedTextColor="#272727" v-model="datainfo.sex" :localdata="sexs" /> -->
  15. </view>
  16. </uni-forms-item>
  17. <uni-forms-item label="来访人数" name="num">
  18. <view class="flexc">
  19. <uni-easyinput :disabled="isdisabled" v-model="datainfo.num" type="Number" :inputBorder='false' placeholder="请输入来访人数" />
  20. <view class="rimg"><image :src="rimg"></image></view>
  21. </view>
  22. </uni-forms-item>
  23. <uni-forms-item label="来访时间" name="visitorTime">
  24. <view class="flexc">
  25. <uni-datetime-picker :disabled="isdisabled" :class="datainfo.visitorTime?'co27':'coa'" type="date" placeholder="请选择来访时间" :border="false" :hide-second='true' v-model="datainfo.visitorTime" @change="changeLog" />
  26. <view class="rimg"><image :src="rimg"></image></view>
  27. </view>
  28. <!-- <picker range-key='dictLabel' :value="vxlbidx" :range="vxlbList" @change='bindDateChangea'>
  29. <view class="flexc">
  30. <view class="flex1 txr f13 co27" v-if="datainfo.maintenanceCategory&&!vxlb">{{statusFormats(datainfo.maintenanceCategory,vxlbList,'vxlb')}}</view>
  31. <view class="flex1 txr f13" v-else :class="vxlb?'co27':'coa'">{{vxlb||"请选择来访时间"}}</view>
  32. <view class="rimg"><image :src="rimg"></image></view>
  33. </view>
  34. </picker> -->
  35. </uni-forms-item>
  36. <uni-forms-item label="来访事由" name="reason">
  37. <view class="flexc">
  38. <uni-easyinput :disabled="isdisabled" v-model="datainfo.reason" :inputBorder='false' placeholder="请输入来访事由" />
  39. <view class="rimg"><image :src="rimg"></image></view>
  40. <!-- <picker range-key='dictLabel' :value="syqxidx" :range="sexs" @change='bindDateChange'>
  41. <view class="rimg"><image :src="rimg"></image></view>
  42. </picker> -->
  43. </view>
  44. </uni-forms-item>
  45. <uni-forms-item label="来访门户" name="portalId">
  46. <w-select
  47. style="margin-left: 20rpx;"
  48. v-model="chooseValue"
  49. :list='fwlist'
  50. valueName='label'
  51. keyName="value"
  52. :chosevalue="datainfo.houseAddress"
  53. :filterable='filterable'
  54. @change='getchange'
  55. >
  56. </w-select>
  57. </uni-forms-item>
  58. </view>
  59. </view>
  60. <view class="cbox">
  61. <view class="chtop flexc">
  62. <view class="line"></view>
  63. <view>驾车信息</view>
  64. </view>
  65. <view class="chmain">
  66. <uni-forms-item label="是否驾车" name="isCar">
  67. <view class="flexc" @click="getChangeFn">
  68. <view class="flex1"></view>
  69. <image :src="check" v-if="datainfo.isCar=='Y'" class="checkimg"></image>
  70. <image :src="ncheck" v-else class="checkimg"></image>
  71. </view>
  72. </uni-forms-item>
  73. <uni-forms-item label="车牌号码" name="plateNumber">
  74. <view class="flexc">
  75. <!-- disabled -->
  76. <uni-easyinput :disabled="isdisabled" v-model="datainfo.plateNumber" :inputBorder='false' placeholder="请输入车牌号" />
  77. <!-- <view class="aphoto" @click="getaddImage">
  78. <image :src="aphoto"></image>
  79. </view> -->
  80. </view>
  81. </uni-forms-item>
  82. <uni-forms-item label="手机号码" name="mobileNumber">
  83. <view class="flexc">
  84. <uni-easyinput :disabled="isdisabled" v-model="datainfo.mobileNumber" :inputBorder='false' placeholder="请输入手机号码" />
  85. <view class="rimg"></view>
  86. </view>
  87. </uni-forms-item>
  88. <view class="tips">
  89. 如驾车,填写车牌后,访客到访时,车闸机自动打开
  90. </view>
  91. </view>
  92. </view>
  93. </uni-forms>
  94. <view class="pdlr12 mt63">
  95. <view class="rhbtn" @click="getEditFn" v-if="isdisabled">修改</view>
  96. <view class="rhbtn" @click="getSubmit" v-else>确定</view>
  97. </view>
  98. <loading></loading>
  99. </view>
  100. </template>
  101. <script>
  102. import config from '@/config'
  103. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  104. import {uploadIdentify,uploadmore} from '@/utils/common.js'
  105. import {reservAdd,reservDet,reservPut} from "@/api/work/people.js"
  106. import {houseInfolistNoPage} from "@/api/work/work.js"
  107. import wSelect from "@/work/components/w-select/w-select.vue"
  108. export default {
  109. components: {wSelect},
  110. data() {
  111. return {
  112. rimg: require('@/static/images/rimg.png'),
  113. aphoto: require('@/work/static/visitor/aphoto.png'),
  114. check: require('@/mine/static/check.png'),
  115. ncheck: require('@/mine/static/ncheck.png'),
  116. baseUrl: config.baseUrl,
  117. checkflag:true,
  118. datainfo: {
  119. // "visitorManageId":"",//来访主键
  120. "portalId":"",//门户id
  121. "houseAddress":"",//详细门牌号
  122. "name":"",//访客姓名
  123. "num":"",//来访人数
  124. "reason":"",//来访事由
  125. "mobileNumber":"",//手机号码
  126. "isCar":"N",//是否驾车 N:否 Y:是
  127. "plateNumber":"",//车牌号码
  128. // "reserveTime":"",//预约时间
  129. "visitorTime":"",//来访时间
  130. // "status":"",//状态 1:预约成功 2:已来访 3:已过期
  131. // "photo":""//人脸信息
  132. },
  133. syqxidx:'',
  134. sexs: [{
  135. text: '男',
  136. value: 0
  137. }, {
  138. text: '女',
  139. value: 1
  140. }],
  141. rules:{name: {rules: [{required: true,errorMessage: '请输入访客姓名' }]},
  142. portalId: {rules: [{required: true,errorMessage: '请选择来访门户' }]},
  143. mobileNumber: {rules: [{required: true,errorMessage: '请输入手机号'}, {pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,errorMessage:'请输入正确的手机号码'}]},},
  144. phofile:[],
  145. filterable:true,
  146. chooseValue:'',
  147. fwlist:[],
  148. id:'',
  149. isdisabled:false,
  150. ptype:'add',
  151. userId:this.$store.state.user.userId,
  152. }
  153. },
  154. onLoad: function(e) {
  155. if(e.id){
  156. this.id=e.id;
  157. this.ptype="edit";
  158. // this.isdisabled=true;
  159. this.getDetail()
  160. }
  161. this.init()
  162. },
  163. methods: {
  164. checkPermi,
  165. checkRole,
  166. getEditFn(){
  167. this.isdisabled=false;
  168. },
  169. changeLog(){
  170. },
  171. init(){
  172. // 自己的房屋
  173. var params={
  174. userId:this.userId,
  175. pageSize: 100,
  176. pageNum: 1,
  177. }
  178. houseInfolistNoPage(params).then(res=>{
  179. if(res.code==200){
  180. this.fwlist= res.rows.map(v => {
  181. return {
  182. label: v.detailedAddress,
  183. value: v.houseId,
  184. location: v.location
  185. }
  186. })
  187. }
  188. })
  189. },
  190. bindDateChange(e){
  191. var val=e.detail.value;
  192. // this.datainfo.applicationBank=this.sdyhlist[val].value;
  193. // this.applicationBank=this.sdyhlist[val].label;
  194. },
  195. getChangeFn(){
  196. if(this.isdisabled){
  197. return
  198. }
  199. if(this.datainfo.isCar=='Y'){
  200. this.datainfo.isCar='N'
  201. }else{
  202. this.datainfo.isCar='Y'
  203. }
  204. },
  205. getDetail(){
  206. reservDet(this.id).then(res=>{
  207. if(res.code==200){
  208. this.datainfo=res.data;
  209. this.chooseValue=res.data.portalId
  210. }
  211. })
  212. },
  213. getSubmit(){
  214. this.$refs.form.validate().then(res => {
  215. var params=JSON.parse(JSON.stringify(this.datainfo))
  216. if(!params.portalId){
  217. this.$toast("请选择来访门户")
  218. return
  219. }
  220. if(params.isCar=='Y'&&!params.plateNumber){
  221. this.$toast("请输入车牌号")
  222. return
  223. }
  224. if(!params.visitorTime){
  225. this.$toast("请选择来访时间")
  226. return
  227. }
  228. var lng = '117.211954';
  229. var lat = '31.839676';
  230. params.lgt=lng;
  231. params.lat=lat;
  232. if(this.ptype=='add'){
  233. reservAdd(params).then(res=>{
  234. if(res.code==200){
  235. this.$toast("新增成功")
  236. setTimeout(function(){
  237. // uni.$emit("refComelist")
  238. uni.navigateBack({
  239. delta:1
  240. })
  241. },1500)
  242. }
  243. })
  244. }else{
  245. reservPut(params).then(res=>{
  246. if(res.code==200){
  247. this.$toast("修改成功")
  248. setTimeout(function(){
  249. // uni.$emit("refComelist")
  250. uni.navigateBack({
  251. delta:1
  252. })
  253. },1500)
  254. }
  255. })
  256. }
  257. })
  258. },
  259. getchange(e){
  260. this.datainfo.portalId=e.value;
  261. this.datainfo.houseAddress=e.label;
  262. this.datainfo.detailAddress=e.location;
  263. },
  264. getaddImage(e) {
  265. let that = this;
  266. let file = [],
  267. count = 9
  268. uni.chooseImage({
  269. success: function(res) {
  270. let img = res.tempFilePaths;
  271. if (img.length + file.length > count) {
  272. uni.showToast({
  273. title: '最多上传' + count + '张图片',
  274. icon: 'none',
  275. duration: 2000
  276. })
  277. } else {
  278. let imglen = res.tempFilePaths.length;
  279. var fuwufile = [];
  280. uploadmore('/common/upload', img, 0, 0, 0, imglen, fuwufile, function(rs) {
  281. that.phofile = that.phofile.concat(rs);
  282. })
  283. }
  284. }
  285. });
  286. },
  287. // getaddImage(e) {
  288. // let that = this;
  289. // // var rs=['D:\\idcard.png']
  290. // // if(rs&&rs.length>0){
  291. // // var obj={
  292. // // type:e,
  293. // // // url:baseUrl+rs.join(',')
  294. // // url:rs.join(',')
  295. // // }
  296. // // that.getOcrIdCard(obj)
  297. // // }
  298. // // return
  299. // let file = [],
  300. // count = 9
  301. // uni.chooseImage({
  302. // count: 1,
  303. // success: function(res) {
  304. // let img = res.tempFilePaths;
  305. // if (img.length + file.length > count) {
  306. // uni.showToast({
  307. // title: '最多上传' + count + '张图片',
  308. // icon: 'none',
  309. // duration: 2000
  310. // })
  311. // } else {
  312. // let imglen = res.tempFilePaths.length;
  313. // var fuwufile = [];
  314. // uploadIdentify('/common/upload', img, 0, 0, 0, imglen, fuwufile, function(rs) {
  315. // var resurl = rs[0];
  316. // if (e == 'front') {
  317. // that.datainfo.front = resurl.fileName;
  318. // } else {
  319. // that.datainfo.back = resurl.fileName;
  320. // }
  321. // if (rs && rs.length > 0) {
  322. // var obj = {
  323. // type: e,
  324. // url: resurl.urlOnline
  325. // }
  326. // that.getOcrIdCard(obj)
  327. // }
  328. // })
  329. // }
  330. // }
  331. // });
  332. // },
  333. // getOcrIdCard(obj) {
  334. // var params = {
  335. // image: obj.url,
  336. // idCardSide: obj.type
  337. // }
  338. // getOcrIdCard(params).then(res => {
  339. // if (res.code == 200) {
  340. // var datainfo = res.data;
  341. // if (obj.type == 'front') {
  342. // this.datainfo.realName = datainfo.realName;
  343. // this.datainfo.idCard = datainfo.idCard;
  344. // this.datainfo.address = datainfo.address;
  345. // } else {
  346. // this.datainfo.expirationDate = datainfo.expirationDate
  347. // }
  348. // }
  349. // })
  350. // }
  351. }
  352. }
  353. </script>
  354. <style>
  355. page{background: #F3F3F0;}
  356. </style>
  357. <style lang="scss" scoped>
  358. .coa /deep/ .uni-date__x-input{text-align: right;color: #AAAAAA;}
  359. .check /deep/ .select-wrap{border: none;width: 100%;}
  360. .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;}
  361. .check .cbox /deep/ .uni-forms-item:last-child{border: none;}
  362. .check /deep/ .uni-forms-item__label{font-weight: bold;font-size: 26rpx;color: #222327;flex: 0 0 auto;width: auto !important;}
  363. .check /deep/ .uni-easyinput{flex: 1;text-align: right;font-size: 26rpx;color: #222327;}
  364. .check /deep/ .uni-easyinput__content-textarea{min-height: 40rpx;font-size: 26rpx;}
  365. .check /deep/ .uni-easyinput__placeholder-class{font-size: 26rpx;color: #AAAAAA;}
  366. .check /deep/ .uni-input-input{font-size: 26rpx;}
  367. .check /deep/ .uni-textarea-textarea{font-size: 26rpx;}
  368. .check /deep/ .is-disabled{color: #222327;background-color: #ffffff !important;}
  369. .check /deep/ .uni-data-checklist .checklist-group .checklist-box{margin:10rpx 8rpx 10rpx 16rpx;}
  370. .check /deep/ .uni-data-checklist{flex: 0 0 auto;}
  371. .check{min-height: 100vh;padding: 20rpx 18rpx 24rpx;box-sizing: border-box;}
  372. .cbox{background: #FFFFFF;border-radius: 20rpx;flex: 1;margin-bottom: 24rpx;
  373. .chtop{padding-top: 32rpx;margin-bottom: 8rpx;
  374. image{width: 14rpx;height: 48rpx;margin-right: 20rpx;}
  375. view{font-weight: bold;font-size: 32rpx;color: #272727;}
  376. }
  377. .chmain{
  378. padding: 0 32rpx;
  379. .upbox{height: 224rpx;background: #EFF4FF;border-radius: 20rpx;display: flex;align-items: center;justify-content: center;flex-direction: column;margin-bottom: 8rpx;overflow: auto;
  380. .img{width: 100%;height: 100%;}
  381. .addimg{width: 70rpx;height: 70rpx;margin-bottom: 16rpx;}
  382. view{font-weight: bold;font-size: 26rpx;color: #4C6686;}
  383. }
  384. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  385. image{width: 100%;height: 100%;}
  386. }
  387. .checkimg{width: 80rpx;height: 40rpx;margin-right: 8rpx;}
  388. .aphoto{padding: 0 24rpx;border-left: 2rpx solid #e6e6e6;margin-left: 26rpx;
  389. image{width: 40rpx;height: 38rpx;}
  390. }
  391. }
  392. }
  393. .line{width: 14rpx;height: 48rpx;background: #0256FD;border-radius:0 12rpx 12rpx 0;margin-right: 18rpx;}
  394. .tips{font-weight: 500;font-size: 22rpx;color: #0256FD;padding: 20rpx 0;}
  395. </style>