add.vue 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <el-form ref="form" :model="formData" :rules="formRules" label-width="120px">
  3. <el-form-item label="押金类型" prop="depositType">
  4. <el-select placeholder="请选择押金类型" v-model="formData.depositType" clearable>
  5. <el-option label="装修押金" :value="1"></el-option>
  6. <el-option label="租赁押金" :value="2"></el-option>
  7. <el-option label="出入证押金" :value="3"></el-option>
  8. <el-option label="门禁卡押金" :value="4"></el-option>
  9. </el-select>
  10. </el-form-item>
  11. <el-form-item label="金额" prop="amount">
  12. <el-input v-model="formData.amount" placeholder="请输入金额"></el-input>
  13. </el-form-item>
  14. <el-form-item label="应收时间" prop="receivableDate" class="chargeStartTime">
  15. <el-date-picker v-model="formData.receivableDate" type="datetime" placeholder="选择应收时间"> </el-date-picker>
  16. </el-form-item>
  17. </el-form>
  18. </template>
  19. <script >
  20. export default {
  21. props: ['params'],
  22. data() {
  23. return {
  24. formData: {
  25. depositType: '',
  26. receivableDate: '',
  27. amount: '',
  28. communityId: '',
  29. buildingId: '',
  30. houseId: '',
  31. roomNumber: ''
  32. },
  33. formRules: {
  34. depositType: [this.$valid.selectRequired('押金类型')],
  35. amount: [this.$valid.inputRequired('金额')],
  36. receivableDate: [this.$valid.selectRequired('应收时间')]
  37. }
  38. };
  39. },
  40. methods: {
  41. submit() {
  42. this.$refs.form.validate((valid) => {
  43. if (valid) {
  44. var loading = this.$loading();
  45. this.$http
  46. .post('/sc-charge/deposit/add', this.formData)
  47. .then(({ status, msg }) => {
  48. if (status == 0) {
  49. this.$message.success(msg);
  50. this.params.callback();
  51. this.$emit('close');
  52. } else {
  53. this.$message.error(msg);
  54. }
  55. loading.close();
  56. })
  57. .catch(() => {
  58. loading.close();
  59. });
  60. }
  61. });
  62. }
  63. },
  64. created() {
  65. let { communityId, buildingId, houseId, houseName } = this.params.thisCommObj;
  66. this.formData.communityId = communityId;
  67. this.formData.buildingId = buildingId;
  68. this.formData.houseId = houseId;
  69. this.formData.roomNumber = houseName;
  70. }
  71. };
  72. </script>
  73. <style lang="scss" scoped>
  74. .chargeStartTime {
  75. /deep/ .el-date-editor {
  76. width: 100%;
  77. }
  78. }
  79. </style>