Blame view

src/components/community/EditCommunitySpaceOpenTime.vue 1.71 KB
34fbc487   wuxw   完成预约功能
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
  <template>
    <el-dialog 
      :title="$t('communitySpaceManage.openTimeTitle')" 
      :visible.sync="visible"
      width="70%"
    >
      <el-row :gutter="20">
        <el-col :span="6" v-for="(item, index) in openTimes" :key="index">
          <div class="time-item">
            <span>{{ item.hours }}{{ $t('common.hour') }}</span>
            <el-select v-model="item.isOpen" @change="updateOpenTime(item)" style="width:100%">
              <el-option 
                :label="$t('communitySpaceManage.status1001')" 
                value="Y" 
              />
              <el-option 
                :label="$t('communitySpaceManage.status2002')" 
                value="N" 
              />
            </el-select>
          </div>
        </el-col>
      </el-row>
      
      <div slot="footer" class="dialog-footer">
        <el-button @click="visible = false">
          {{ $t('communitySpaceManage.cancel') }}
        </el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { updateCommunitySpaceOpenTime } from '@/api/community/communitySpaceManageApi'
  
  export default {
    name: 'EditCommunitySpaceOpenTime',
    data() {
      return {
        visible: false,
        openTimes: []
      }
    },
    methods: {
      open(space) {
        this.openTimes = space.openTimes || []
        this.visible = true
      },
      
      async updateOpenTime(item) {
        try {
          await updateCommunitySpaceOpenTime(item)
          this.$message.success(this.$t('common.success'))
        } catch (error) {
          console.error('更新开放时间失败:', error)
        }
      }
    }
  }
  </script>
  
  <style scoped>
  .time-item {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 4px;
  }
  .time-item span {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
  }
  </style>