recharge.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div class="formContent">
  3. <el-form
  4. ref="formDate"
  5. label-width="80px"
  6. :rules="rules"
  7. :model="formDate"
  8. >
  9. <div>
  10. <h3>{{this.userName}}</h3>
  11. <div class="formContent-item_title">充值信息</div>
  12. <el-row>
  13. <el-col :span="12">
  14. <el-col :span="9">车牌类型</el-col>
  15. <el-col :span="12">{{this.cardType== 0 ? '临时车'
  16. : this.cardType == 1 ? 'VIP车'
  17. : this.cardType == 2 ? '月租车'
  18. : this.cardType == 3 ? '充时车'
  19. : this.cardType == 4 ? '时租车'
  20. : this.cardType == 5 ? '产权车'
  21. : this.cardType == 6 ? '计次车'
  22. : this.cardType == 7 ? '贵宾卡'
  23. : '员工卡'}}</el-col>
  24. </el-col>
  25. <!-- 充值类型 -->
  26. <el-col :span="24">
  27. <el-col
  28. :span="0.5"
  29. style="content: '*';color: #F56C6C;"
  30. >*</el-col>
  31. <el-col :span="4">充值规则</el-col>
  32. <el-col :span="19">
  33. <el-form-item
  34. prop="parkingArea"
  35. ref="againValue"
  36. >
  37. <el-select v-model="valueselected">
  38. <el-option
  39. v-for="(item,index) in recharge"
  40. :key="index"
  41. :value="item.label"
  42. :label="item.name"
  43. @click.native="rechargeDates(item)"
  44. >
  45. </el-option>
  46. </el-select>
  47. </el-form-item>
  48. </el-col>
  49. </el-col>
  50. <!-- 充值 -->
  51. <el-col :span="24">
  52. <el-col :span="12">
  53. <el-col
  54. :span="0.5"
  55. style="content: '*';color: #F56C6C;"
  56. >*</el-col>
  57. <el-col :span="8">充值天数</el-col>
  58. <el-col :span="14">
  59. <el-form-item
  60. prop="parkingDays"
  61. ref="againDays"
  62. >
  63. <el-select v-model="rechargeDays">
  64. <el-option
  65. v-for="(itemes,indexes) in RechargeDaysed"
  66. :key="indexes"
  67. :value="itemes.name"
  68. :label="itemes.label"
  69. @click.native="recharges(itemes)"
  70. ></el-option>
  71. </el-select>
  72. </el-form-item>
  73. </el-col>
  74. </el-col>
  75. <el-col :span="12">
  76. <el-col :span="8">赠送天数</el-col>
  77. <el-col :span="15">
  78. <el-select
  79. disabled
  80. :placeholder='valueselect'
  81. >
  82. </el-select>
  83. </el-col>
  84. </el-col>
  85. </el-col>
  86. <!-- 日期 -->
  87. <el-col :span="24">
  88. <el-col
  89. :span="0.5"
  90. style="content: '*';color: #F56C6C;"
  91. >*</el-col>
  92. <el-col :span="4">开始时间</el-col>
  93. <el-col :span="18">
  94. <el-form-item
  95. prop="parkingPicker"
  96. ref="againPicker"
  97. >
  98. <el-date-picker
  99. v-model="value1"
  100. type="date"
  101. placeholder="选择日期"
  102. value-format="timestamp"
  103. @change="datePicker"
  104. >
  105. </el-date-picker>
  106. </el-form-item>
  107. </el-col>
  108. </el-col>
  109. <el-col :span="24">
  110. <el-col
  111. :span="4"
  112. style="margin-right: 5px;"
  113. >结束时间</el-col>
  114. <el-col :span="18">
  115. <el-date-picker
  116. v-model="value2"
  117. type="date"
  118. :placeholder="value2"
  119. value-format="timestamp"
  120. disabled
  121. >
  122. </el-date-picker>
  123. </el-col>
  124. <el-col
  125. :span="24"
  126. v-show="this.carStatus == 2 ? true : false"
  127. style="margin-left:12px"
  128. >
  129. <span>车辆未过期,已绑定充值规则,充值开始时间:过期时间+1</span>
  130. </el-col>
  131. </el-col>
  132. <!-- 收费金额 -->
  133. <el-col
  134. :span="24"
  135. style="margin-top: 8px;"
  136. >
  137. <el-col
  138. :span="4"
  139. style="margin-right: 5px;"
  140. >收费金额 </el-col>
  141. <el-form-item>
  142. <el-col :span="17">
  143. <el-input
  144. :placeholder="chargeAmount"
  145. :disabled="true"
  146. >
  147. </el-input>
  148. </el-col>
  149. <el-col
  150. :span="2"
  151. style="margin-left: 5px;"
  152. >元 </el-col>
  153. </el-form-item>
  154. </el-col>
  155. <!-- 支付方式 -->
  156. <el-col :span="24">
  157. <el-col
  158. :span="0.5"
  159. style="content: '*';color: #F56C6C;"
  160. >*</el-col>
  161. <el-col
  162. :span="4"
  163. style="margin-right: -2px;"
  164. >支付方式</el-col>
  165. <el-col :span="17">
  166. <el-form-item
  167. prop="parkingMethod"
  168. ref="againMethod"
  169. >
  170. <el-select
  171. v-model="paymentMethod"
  172. placeholder="请选择"
  173. @change="method"
  174. >
  175. <el-option
  176. value="1"
  177. label="微信"
  178. ></el-option>
  179. <el-option
  180. value="2"
  181. label="支付宝"
  182. ></el-option>
  183. <el-option
  184. value="3"
  185. label="现金"
  186. ></el-option>
  187. <el-option
  188. value="4"
  189. label="预存"
  190. ></el-option>
  191. <el-option
  192. value="5"
  193. label="其他"
  194. ></el-option>
  195. </el-select>
  196. </el-form-item>
  197. </el-col>
  198. </el-col>
  199. <!-- 备注 -->
  200. <el-col :span="24">
  201. <el-col :span="4">充值备注</el-col>
  202. <el-col :span="20">
  203. <el-input
  204. type="textarea"
  205. :rows="3"
  206. placeholder="请输入内容"
  207. v-model="inputText"
  208. maxlength="100"
  209. show-word-limit
  210. ></el-input>
  211. </el-col>
  212. </el-col>
  213. </el-row>
  214. </div>
  215. </el-form>
  216. </div>
  217. </template>
  218. <script>
  219. export default {
  220. props: ['params'],
  221. data () {
  222. return {
  223. communityId: '',//社区id
  224. valueselected: '',
  225. valueselect: '',//天数
  226. value1: '',//日期时间
  227. value2: '',
  228. rechargeDays: '',//充值时间
  229. chargeAmount: '',//收费金额
  230. paymentMethod: '',//支付方式
  231. inputText: '',//备注
  232. id: '',
  233. userName: "",
  234. cardType: "",
  235. parkId: "",
  236. cardId: "",
  237. recharge: [],
  238. RechargeDaysed: [],
  239. complimentaryDays: [],
  240. idType: '',
  241. valueselectName: "",
  242. chargeNumber: '',
  243. timeValue1: '',
  244. timeValue2: '',
  245. rechargeDate: [],
  246. fullCarNoStr: '',
  247. residentId: '',
  248. ruleId: '',
  249. ruleNamed: '',
  250. credit: '',
  251. rechargeDatesName: '',
  252. carStatus: '',
  253. formDate: {
  254. parkingArea: '',
  255. parkingDays: '',
  256. parkingPicker: '',
  257. parkingMethod: ''
  258. },
  259. parking: false,
  260. rules: {
  261. parkingArea: [{ required: true, message: '请选择充值规则', trigger: 'change' }],
  262. parkingDays: [{ required: true, message: '请选择充值天数', trigger: 'change' }],
  263. parkingPicker: [{ required: true, message: '请选择充值天数', trigger: 'change' }],
  264. parkingMethod: [{ required: true, message: '请选择充值天数', trigger: 'change' }],
  265. }
  266. }
  267. },
  268. methods: {
  269. method () {
  270. if (this.rules.parkingMethod[0].required == true && this.formDate.parkingMethod == '') {
  271. this.formDate.parkingMethod = '验证'
  272. this.rules.parkingMethod[0].required = this.formDate.parking;
  273. this.clearValidate('againMethod');
  274. }
  275. },
  276. clearValidate (formName) {
  277. this.$refs[formName].clearValidate();
  278. },
  279. rechargeDates (item) {
  280. if (this.rules.parkingArea[0].required == true && this.formDate.parkingArea == '') {
  281. this.formDate.parkingArea = '验证'
  282. this.rules.parkingArea[0].required = this.formDate.parking;
  283. this.clearValidate('againValue');
  284. }
  285. if (item.name != undefined) {
  286. this.rechargeDatesName = item.name;
  287. }
  288. this.rechargeDays = '';
  289. this.valueselect = '';
  290. this.valueselectName = '';
  291. this.idType = '';
  292. this.chargeAmount = '';
  293. this.chargeNumber = '';
  294. this.RechargeDaysed = [];
  295. this.complimentaryDays = [];
  296. this.RechargeDaysed.push({
  297. label: this.rechargeDate[item.nameId].rechargeAmount * (this.rechargeDate[item.nameId].rechargeType == 0 ? (1 * 1 / 100) : this.rechargeDate[item.nameId].rechargeType == 1 ? (1 * 1) : this.rechargeDate[item.nameId].rechargeType == 2 ? (1 * 1) : this.rechargeDate[item.nameId].rechargeType == 3 ? (1 * 1) : (1 * 1)) + (this.rechargeDate[item.nameId].rechargeType == 0 ? '元' : this.rechargeDate[item.nameId].rechargeType == 1 ? '月' : this.rechargeDate[item.nameId].rechargeType == 2 ? '天' : this.rechargeDate[item.nameId].rechargeType == 3 ? '小时' : '次'),
  298. name: this.rechargeDate[item.nameId].rechargeAmount * (this.rechargeDate[item.nameId].rechargeType == 0 ? (1 * 1 / 100) : this.rechargeDate[item.nameId].rechargeType == 1 ? (1 * 1) : this.rechargeDate[item.nameId].rechargeType == 2 ? (1 * 1) : this.rechargeDate[item.nameId].rechargeType == 3 ? (1 * 1) : (1 * 1)),
  299. id: item.nameId,
  300. })
  301. this.complimentaryDays.push({
  302. idType: this.rechargeDate[item.nameId].rechargeType,
  303. name: this.rechargeDate[item.nameId].sentAmount * (this.rechargeDate[item.nameId].sentType == 0 ? (1 * 1 / 100) : this.rechargeDate[item.nameId].sentType == 1 ? (1 * 1) : this.rechargeDate[item.nameId].sentType == 2 ? (1 * 1) : this.rechargeDate[item.nameId].sentType == 3 ? (1 * 1) : (1 * 1)),
  304. label: this.rechargeDate[item.nameId].sentAmount * (this.rechargeDate[item.nameId].sentType == 0 ? (1 * 1 / 100) : this.rechargeDate[item.nameId].sentType == 1 ? (1 * 1) : this.rechargeDate[item.nameId].sentType == 2 ? (1 * 1) : this.rechargeDate[item.nameId].sentType == 3 ? (1 * 1) : (1 * 1)) + (this.rechargeDate[item.nameId].sentType == 0 ? '元' : this.rechargeDate[item.nameId].sentType == 1 ? '月' : this.rechargeDate[item.nameId].sentType == 2 ? '天' : this.rechargeDate[item.nameId].sentType == 3 ? '小时' : '次'),
  305. chargeAmount: this.rechargeDate[item.nameId].basicMoney,
  306. })
  307. },
  308. datePicker () {
  309. if (this.rules.parkingPicker[0].required == true && this.formDate.parkingPicker == '') {
  310. this.formDate.parkingPicker = '验证'
  311. this.rules.parkingPicker[0].required = this.formDate.parking;
  312. this.clearValidate('againPicker');
  313. }
  314. // valueselect赠送
  315. // rechargeDays 天数
  316. if (this.idType == 0) {
  317. var time = this.value1;
  318. } else if (this.idType == 1) {
  319. var time = ((parseInt(this.valueselectName) + parseInt(this.rechargeDays * 30)) * 86400000) + this.value1;
  320. } else if (this.idType == 2) {
  321. var time = ((parseInt(this.valueselectName) + parseInt(this.rechargeDays)) * 86400000) + this.value1;
  322. } else if (this.idType == 3) {
  323. var time = ((parseInt(this.valueselectName) + parseInt(this.rechargeDays)) * 3600000) + this.value1;
  324. } else if (this.idType == 4) {
  325. var time = this.value1;
  326. }
  327. // var time = ((parseInt(this.valueselected) + parseInt(this.rechargeDays)) * 86400000) + this.value1;
  328. var timeCode = new Date(time);
  329. var year = timeCode.getFullYear();
  330. var month = timeCode.getMonth() + 1;
  331. var date = timeCode.getDate();
  332. this.value2 = year + "-" + (month.toString().length == 1 ? ('0' + month) : month) + "-" + (date.toString().length == 1 ? ('0' + date) : date);
  333. var timeCodes = new Date(this.value1);
  334. var year = timeCodes.getFullYear();
  335. var month = timeCodes.getMonth() + 1;
  336. var date = timeCodes.getDate();
  337. this.timeValue1 = year + "-" + (month.toString().length == 1 ? ('0' + month) : month) + "-" + (date.toString().length == 1 ? ('0' + date) : date) + ' ' + '00:00:00';
  338. this.timeValue2 = this.value2 + ' ' + '23:59:59';
  339. },
  340. // 充值规则
  341. rechargeRules () {
  342. this.$http
  343. .get('/sc-community/parkingCar/queryRechargeRules', { carType: this.cardType, parkingId: this.parkId })
  344. .then(({ data, msg, status }) => {
  345. this.rechargeDate = data;
  346. var daraRes = {
  347. nameId: ''
  348. }
  349. // daraRes.nameId = this.params.ruleId;
  350. // this.rechargeDates(daraRes);
  351. for (let i = 0; i < data.length; i++) {
  352. if (data[i].ruleId == this.params.ruleId) {
  353. daraRes.nameId = i;
  354. this.rechargeDates(daraRes);
  355. }
  356. this.recharge.push({
  357. name: data[i].ruleName,
  358. label: data[i].ruleId,
  359. nameId: i
  360. })
  361. if (data[i].ruleId == this.params.ruleId) {
  362. this.rechargeDatesName = data[i].ruleName
  363. }
  364. }
  365. })
  366. .catch(() => { });
  367. },
  368. recharges (item) {
  369. if (this.rules.parkingDays[0].required == true && this.formDate.parkingDays == '') {
  370. this.formDate.parkingDays = '验证'
  371. this.rules.parkingDays[0].required = this.formDate.parking;
  372. this.clearValidate('againDays');
  373. }
  374. this.id = item.id;
  375. this.valueselect = this.complimentaryDays[0].label;
  376. this.valueselectName = this.complimentaryDays[0].name;
  377. this.idType = this.complimentaryDays[0].idType;
  378. this.chargeAmount = this.complimentaryDays[0].chargeAmount / 100;
  379. this.chargeNumber = item.name;
  380. },
  381. submit () {
  382. this.$refs.formDate.validate((valid) => {
  383. if (valid) {
  384. this.$http.post('/sc-community/parkingCar/carCharge', {
  385. amount: this.chargeAmount * 100,
  386. communityId: this.communityId,
  387. carType: this.cardType,
  388. cardId: this.cardId,
  389. chargeMethod: this.idType,
  390. chargeNumber: this.chargeNumber,
  391. freeNumber: this.valueselectName,
  392. // orderNo: '',
  393. parkId: this.parkId,
  394. payChannel: this.paymentMethod,
  395. payMethod: this.paymentMethod,
  396. remark: this.inputText,
  397. validFrom: this.timeValue1,
  398. validTo: this.timeValue2,
  399. platNo: this.fullCarNoStr,
  400. userId: this.residentId,
  401. // ruleName: '',
  402. ruleName: this.rechargeDatesName,
  403. credit: this.valueselectName,//充值月份
  404. payStatus: this.paymentMethod
  405. }).then(({ data, status, msg }) => {
  406. if (status == 0) {
  407. this.params.callback();
  408. this.$emit('close');
  409. this.$message.success('成功');
  410. }
  411. })
  412. } else {
  413. return false;
  414. }
  415. })
  416. // this.params.callback();
  417. // this.$emit('close');
  418. },
  419. },
  420. created () {
  421. // this.formDate.parkingArea = '验证'
  422. // this.formDate.parkingDays = '验证'
  423. // this.formDate.parkingPicker = '验证'
  424. // this.formDate.parkingMethod = '验证'
  425. debugger
  426. this.communityId = this.params.communityId;
  427. this.userName = this.params.userName;
  428. this.cardType = this.params.cardType;
  429. this.parkId = this.params.parkId;
  430. this.cardId = this.params.cardId;
  431. this.fullCarNoStr = this.params.fullCarNoStr;
  432. this.residentId = this.params.residentId;
  433. this.ruleId = this.params.ruleId;
  434. this.carStatus = this.params.carStatus;
  435. this.valueselected = this.params.ruleId;
  436. this.rechargeRules();
  437. }
  438. }
  439. </script>
  440. <style lang="scss" scoped>
  441. h3 {
  442. margin-bottom: 15px;
  443. /* text-align: center !important; */
  444. font-size: 16px !important;
  445. }
  446. .el-col {
  447. margin-top: 5px !important;
  448. line-height: 30px;
  449. }
  450. // .el-select {
  451. // width: 90%;
  452. // }
  453. .el-col > span {
  454. font-size: 12px;
  455. font-weight: 400;
  456. color: #ff7171;
  457. line-height: 17px;
  458. display: flex;
  459. justify-content: center;
  460. }
  461. /deep/.el-form-item__content {
  462. margin-left: 0px !important;
  463. }
  464. .formContent-item_title {
  465. margin-bottom: 0 !important;
  466. }
  467. .el-date-editor.el-input,
  468. .el-date-editor.el-input__inner {
  469. width: 332px !important;
  470. }
  471. </style>