addinfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <template>
  2. <view>
  3. <ujp-navbar :title="id!=0?'编辑':'新增'">
  4. <view slot="right" @click="infodelete()" v-if="id!=0" style="margin-right: 20px;">
  5. <span class="delete">删除</span>
  6. </view>
  7. </ujp-navbar>
  8. <u-keyboard ref="uKeyboard" @change="valChange" @backspace="backspace" mode="car" v-model="show"></u-keyboard>
  9. <view class="ower-infos">
  10. <view class="infos-item">
  11. <view class="title">
  12. 员工类型<text class="asterisk">*</text>
  13. </view>
  14. <view class="content">
  15. <u-radio-group
  16. @change="radioGroupChange"
  17. v-model="obj.entAccountEnabled">
  18. <u-radio name="1">
  19. 充电员工
  20. </u-radio>
  21. <u-radio name="0">
  22. 普通员工
  23. </u-radio>
  24. </u-radio-group>
  25. </view>
  26. </view>
  27. <view class="infos-item">
  28. <view class="title">
  29. 手机号码<text class="asterisk">*</text>
  30. </view>
  31. <view class="content">
  32. <u-input v-model="obj.phone" placeholder="请填写手机号码" />
  33. </view>
  34. </view>
  35. <view class="infos-item">
  36. <view class="title">
  37. 车主姓名<text class="asterisk">*</text>
  38. </view>
  39. <view class="content">
  40. <u-input v-model="obj.userName" placeholder="请填写车主姓名" />
  41. </view>
  42. </view>
  43. <view class="infos-item border-none" v-if="obj.entAccountEnabled==0">
  44. <view class="title">
  45. 车牌号码<text class="asterisk">*</text>
  46. </view>
  47. <view class="content" @click="show=true">
  48. {{obj.carNum?obj.carNum:'请填写车牌号码'}}
  49. </view>
  50. </view>
  51. <view v-else>
  52. <view class="infos-item border-none" v-for="(item,i ) in carlist" :key="i">
  53. <view class="title">
  54. 车牌号码{{i+1}}
  55. </view>
  56. <view class="content2"
  57. :class="{
  58. content3:!item.id
  59. }"
  60. @click="content2click(i,item)">
  61. {{item.carNum?item.carNum:'请选择企业车牌'}}
  62. </view>
  63. <view class="icon" @click="iconClick(i)" >
  64. <u-icon color="#00B962"
  65. v-if="i==0"
  66. name="plus-circle" size="40"></u-icon>
  67. <u-icon
  68. v-if="i!=0"
  69. name="minus-circle" size="40"></u-icon>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <u-button type="primary" @click="submit()">保存</u-button>
  75. <u-popup
  76. v-model="showSelect" :closeable="true"
  77. mode="bottom" border-radius="30" >
  78. <view class="indexData5content">
  79. <view class="contentTitle">
  80. 选择充电车辆
  81. </view>
  82. <u-input :border="true"
  83. v-if="querycarList.length"
  84. v-model="querycarListvalue" type="text" placeholder="搜索车牌号码(不区分大小写)" />
  85. <view style="text-align: center;margin-top: 100px" v-if="!querycarList.length">
  86. <img src="@/assets/img/blankpage.png">
  87. <view>车辆为空,请先添加车辆</view>
  88. </view>
  89. <scroll-view scroll-y="true" v-else style="height: 520rpx;">
  90. <view style="padding-bottom: 30rpx;" >
  91. <u-radio-group
  92. style="width: 100%;"
  93. v-model="defaultsCar.id" size="42">
  94. <view class="contentbody">
  95. <view v-for="(item,index) in querycarList"
  96. v-show="!item.select&&item.carNum.indexOf(querycarListvalue.toUpperCase())>-1"
  97. @click="popupclickCar(item)"
  98. class="contentItem" :key="index" >
  99. <view class="span1">{{item.carNum}}</view>
  100. <view class="span2" >
  101. <span v-show="!item.vin" style="color:#fff" >aaa</span>
  102. <img v-show="item.vin" style="vertical-align: bottom;" width="20" src="@/assets/img/riLine-link-m.png"/>
  103. <span v-show="item.vin" style="color:#999999 " >已关联Vin码</span>
  104. </view>
  105. <view class="span3">
  106. <u-radio
  107. :name="item.id">
  108. <span style="color:#fff">.</span>
  109. </u-radio>
  110. </view>
  111. </view>
  112. </view>
  113. </u-radio-group>
  114. </view>
  115. </scroll-view>
  116. </view>
  117. </u-popup>
  118. </view>
  119. </template>
  120. <script>
  121. import * as API from '@/apis/finance.js'
  122. import * as API_at8 from '@/apis/accountType8.js'
  123. import {
  124. checkPhone
  125. } from '@/utils'
  126. export default {
  127. data() {
  128. return {
  129. show: false,
  130. carlist: [{}],
  131. querycarList:[],
  132. value: '',
  133. uuid: '',
  134. id: "",
  135. querycarListvalue:"",
  136. platform: "",
  137. obj: {
  138. platform: "",
  139. userName: "",
  140. phone: "",
  141. carNum: "",
  142. entAccountEnabled: "0",
  143. vipUserId: "",
  144. },
  145. defaultsCar:{
  146. id:''
  147. },
  148. showSelect:false,
  149. pid:"",
  150. }
  151. },
  152. onReady() {
  153. if (this.id != 0) {
  154. this.getInfo()
  155. }else{
  156. this.getList()
  157. }
  158. },
  159. onLoad(op) {
  160. this.platform = op.p
  161. this.id = op.id
  162. this.pid = op.pid
  163. this.uuid = op.uuid;
  164. },
  165. methods: {
  166. content2click(i,item){
  167. this.showSelect=true,
  168. this.defaultsCar.i=i
  169. this.defaultsCar.id=item.id
  170. var carlist= this.carlist;
  171. var sz=[]
  172. for(var i in carlist){
  173. var item=carlist[i]
  174. if(item.id){
  175. sz.push(item.id)
  176. }
  177. }
  178. var accountCarIds=sz.join()
  179. var querycarList=this.querycarList
  180. for(var i in querycarList){
  181. var item=querycarList[i]
  182. item.select=false;
  183. if(accountCarIds.indexOf(item.id)>-1){
  184. item.select=true;
  185. }
  186. }
  187. },
  188. radioGroupChange(e){
  189. this.obj.entAccountEnabled=e;
  190. console.log(this.obj.entAccountEnabled)
  191. this.$forceUpdate()
  192. },
  193. iconClick(i){
  194. if(i==0){
  195. this.carlist.push({});
  196. }else{
  197. this.carlist.splice(i,1);
  198. }
  199. },
  200. popupclickCar(item){
  201. this.defaultsCar.id=(item.id)
  202. this.carlist[this.defaultsCar.i]=item
  203. this.showSelect = false;
  204. },
  205. getList() {
  206. uni.showLoading({
  207. title: "加载中",
  208. mask: true,
  209. })
  210. API_at8.entCarList({
  211. entAccountId:this.pid,
  212. pageIndex:1,
  213. pageSize:9999
  214. }).then((res) => {
  215. this.querycarList = res.data.data;
  216. //this.recordsTotal = res.data.recordsTotal
  217. uni.hideLoading()
  218. }).catch(error => {
  219. uni.showToast({
  220. title: error
  221. })
  222. })
  223. },
  224. confirmCar(){
  225. },
  226. // 按键被点击(点击退格键不会触发此事件)
  227. valChange(val) {
  228. // 将每次按键的值拼接到value变量中,注意+=写法
  229. this.value += val;
  230. console.log(this.value);
  231. this.obj.carNum = this.value
  232. },
  233. // 退格键被点击
  234. backspace() {
  235. // 删除value的最后一个字符
  236. if (this.value.length) this.value = this.value.substr(0, this.value.length - 1);
  237. console.log(this.value);
  238. this.obj.carNum = this.value
  239. },
  240. infodelete() {
  241. uni.showLoading({
  242. title: "加载中",
  243. mask: true,
  244. })
  245. this.obj.platform = this.platform
  246. API.vipUserDelete(this.obj).then((res) => {
  247. uni.hideLoading()
  248. this.carhelp.set("addOwnerInformation", {
  249. uuid: this.uuid,
  250. selectObj: this.obj
  251. })
  252. uni.showModal({
  253. showCancel: false,
  254. title: '提示',
  255. content: '操作成功',
  256. success: function(res) {
  257. uni.navigateBack({
  258. })
  259. }
  260. });
  261. }).catch(error => {
  262. uni.showToast({
  263. title: error
  264. })
  265. })
  266. },
  267. submit() {
  268. if (!this.obj.phone) {
  269. uni.showToast({
  270. title: "请填写手机号码"
  271. })
  272. return false
  273. }
  274. if (!this.obj.userName) {
  275. uni.showToast({
  276. title: "请填写车主姓名"
  277. })
  278. return false
  279. }
  280. if (!this.obj.carNum&&this.obj.entAccountEnabled==0) {
  281. uni.showToast({
  282. title: "请填写车牌号码"
  283. })
  284. return false
  285. }
  286. if(this.obj.entAccountEnabled==1){
  287. var sz=[]
  288. //
  289. var carlist= this.carlist;
  290. for(var i in carlist){
  291. var item=carlist[i]
  292. if(item.id){
  293. sz.push(item.id)
  294. }
  295. }
  296. this.obj.accountCarIds=sz.join()
  297. }
  298. var checkPhoneResult = checkPhone(this.obj.phone);
  299. if (checkPhoneResult !== true) {
  300. uni.showToast({
  301. title: checkPhoneResult,
  302. })
  303. return;
  304. }
  305. uni.showLoading({
  306. title: "加载中",
  307. mask: true,
  308. })
  309. this.obj.platform = this.platform
  310. API.vipUserSave(this.obj).then((res) => {
  311. uni.hideLoading()
  312. this.carhelp.set("addOwnerInformation", {
  313. uuid: this.uuid,
  314. selectObj: this.obj
  315. })
  316. uni.showModal({
  317. showCancel: false,
  318. title: '提示',
  319. content: '操作成功',
  320. success: function(res) {
  321. uni.navigateBack({
  322. })
  323. }
  324. });
  325. }).catch(error => {
  326. uni.showToast({
  327. title: error
  328. })
  329. })
  330. },
  331. getInfo() {
  332. uni.showLoading({
  333. title: "加载中",
  334. mask: true,
  335. })
  336. API.vipUserDetails({
  337. vipUserId: this.id,
  338. }).then((res) => {
  339. this.obj = res.data.vipUser;
  340. var entRegCarList=res.data.entRegCarList;
  341. this.querycarList = entRegCarList;
  342. this.obj.vipUserId = this.id
  343. var carlist=[];
  344. if(this.obj.accountCarIds){
  345. for(var i in entRegCarList){
  346. var item=entRegCarList[i];
  347. if(this.obj.accountCarIds.indexOf(item.id)>-1){
  348. carlist.push(item);
  349. }
  350. }
  351. }
  352. if(carlist.length){
  353. this.carlist=carlist
  354. }else{
  355. this.carlist=[{}]
  356. }
  357. uni.hideLoading()
  358. }).catch(error => {
  359. uni.showToast({
  360. title: error
  361. })
  362. })
  363. }
  364. }
  365. }
  366. </script>
  367. <style lang="scss" scoped>
  368. .indexData5content {
  369. padding: 40rpx 40rpx;
  370. .contentTitle{
  371. color:#333333;
  372. font-size: 40rpx;
  373. font-weight: bold;
  374. margin-bottom: 8px;
  375. }
  376. .contentbody{
  377. width: 100%;
  378. display: block;
  379. .contentItem{
  380. border-bottom: 1px solid #ededed;
  381. padding:12rpx 0;
  382. font-size: 32rpx;
  383. display: flex;
  384. width: 100%;
  385. .span1{
  386. padding-top:8rpx ;
  387. width: 50%;
  388. }
  389. .span2{
  390. padding-top:8rpx ;
  391. width: 35%;
  392. }
  393. .span3{
  394. padding-top:8rpx ;
  395. padding-left: 8rpx;
  396. width: 10%;
  397. }
  398. }
  399. }
  400. }
  401. page {
  402. background-color: #f3f4f7;
  403. }
  404. .ower-infos {
  405. background-color: #fff;
  406. padding-left: 16px;
  407. .border-none {
  408. border: none !important;
  409. }
  410. .infos-item {
  411. padding: 24rpx 0;
  412. display: flex;
  413. border-bottom: 1px solid #e9e9e9;
  414. .title {
  415. width: 30%;
  416. font-size: 32rpx;
  417. line-height: 64rpx;
  418. color: #7d7d7d;
  419. .asterisk {
  420. color: #EE3138;
  421. }
  422. }
  423. .content {
  424. font-size: 32rpx;
  425. line-height: 64rpx;
  426. width: 70%;
  427. }
  428. .content2 {
  429. font-size: 32rpx;
  430. line-height: 64rpx;
  431. width: 40%;
  432. }
  433. .content3 {
  434. color: rgba(172, 172, 172, 100);
  435. }
  436. .icon{
  437. line-height: 64rpx;
  438. width: 10%;
  439. }
  440. }
  441. }
  442. .u-btn {
  443. background-color: rgba(0, 90, 217, 100);
  444. margin: 16px;
  445. height: 44px;
  446. line-height: 44px;
  447. font-size: 18px
  448. }
  449. .delete {
  450. color: rgba(238, 49, 56, 100);
  451. font-size: 16px;
  452. }
  453. </style>