zoneAddEdit.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <div class="alert-body__main_content">
  3. <div>
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="130px" class="demo-ruleForm">
  5. <el-row>
  6. <el-col :span="24">
  7. <el-form-item label="车库名称" prop="garageId">
  8. <el-select v-model="ruleForm.garageId" placeholder="请选择车库名称">
  9. <el-option
  10. v-for="(item, index) in garageList"
  11. :label="item.label"
  12. :value="item.id"
  13. :key="index"
  14. ></el-option>
  15. </el-select>
  16. </el-form-item>
  17. <el-form-item label="分区名称" prop="areaName">
  18. <el-input v-model="ruleForm.areaName"></el-input>
  19. </el-form-item>
  20. <el-form-item label="车位数量" prop="parkingNumber">
  21. <el-input v-model="ruleForm.parkingNumber"></el-input>
  22. </el-form-item>
  23. <el-form-item label="备注信息">
  24. <el-input type="textarea" :rows="4" v-model="ruleForm.remarks" maxlength="300"> </el-input>
  25. <span style="position: absolute; bottom: 0; right: 10px">{{ ruleForm.remarks.length }}/300</span>
  26. </el-form-item>
  27. </el-col>
  28. </el-row>
  29. </el-form>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. props: ['params'],
  36. data() {
  37. return {
  38. garageList: [], //车库名称下拉列表
  39. ruleForm: {
  40. garageId: '', //车库名称
  41. areaName: '', //分区名称
  42. parkingNumber: '', //车位数量
  43. remarks: '', //备注
  44. communityId: this.params.data.communityId
  45. },
  46. rules: {
  47. garageId: [{ required: true, message: '请输入车库名称', trigger: 'change' }],
  48. areaName: [{ required: true, message: '请输入分区名称', trigger: 'change' }],
  49. parkingNumber: [{ required: true, message: '请输入车位数量', trigger: 'change' }]
  50. },
  51. radio: '1'
  52. };
  53. },
  54. components: {},
  55. computed: {},
  56. methods: {
  57. //获取车库名称下拉列表
  58. garageNameList() {
  59. this.garageList = [];
  60. let onOption = '';
  61. this.$http.post('/sc-community/assets/garage/list', { communityId: sessionStorage.getItem('communityId') }).then((res) => {
  62. res.data.map((res) => {
  63. onOption = {
  64. label: res.garageName,
  65. id: res.id
  66. };
  67. this.garageList.push(onOption);
  68. });
  69. });
  70. },
  71. submit() {
  72. this.$refs['ruleForm'].validate((valid) => {
  73. if (valid) {
  74. var loading = this.$loading();
  75. let url = '/sc-community/assets/garage/area/add';
  76. if (this.params.todo == 'edit') {
  77. url = '/sc-community/assets/garage/area/update';
  78. }
  79. this.$http
  80. .post(url, this.ruleForm)
  81. .then(({ status, msg }) => {
  82. if (status == 0) {
  83. this.$message.success(msg);
  84. this.params.callback();
  85. this.$emit('close');
  86. } else {
  87. this.$message.error(msg);
  88. }
  89. loading.close();
  90. })
  91. .catch(() => {
  92. loading.close();
  93. });
  94. }
  95. });
  96. }
  97. },
  98. created() {
  99. this.garageNameList();
  100. if (this.params.todo == 'edit') {
  101. this.ruleForm = this.params.data;
  102. }
  103. this.ruleForm.communityId = this.params.data.communityId;
  104. }
  105. };
  106. </script>
  107. <style lang='scss'>
  108. .alert-body__main_content {
  109. .blockName {
  110. padding: 20px;
  111. i {
  112. color: red;
  113. }
  114. }
  115. }
  116. </style>