Blame view

src/components/staff/addAStaffCommunity.vue 4.27 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
ebc1053d   wuxw   加入运营员工详情功能
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
75
76
77
78
79
80
81
82
83
84
85
86
87
    <el-dialog :title="$t('addAStaffCommunity.community')" :visible.sync="visible" width="60%" :before-close="handleClose">
      <el-card>
        <el-row>
          <el-col :span="12">
            <el-input v-model="searchForm.communityName" :placeholder="$t('addAStaffCommunity.searchPlaceholder')" clearable
              @keyup.enter.native="searchCommunities">
              <el-button slot="append" icon="el-icon-search" @click="searchCommunities" />
            </el-input>
          </el-col>
        </el-row>
  
        <el-table class="margin-top" :data="communities" border style="width: 100%">
          <el-table-column width="55">
            <template slot-scope="scope">
              <el-checkbox v-model="scope.row.checked" @change="handleCheckChange(scope.row)" />
            </template>
          </el-table-column>
          <el-table-column prop="communityId" :label="$t('addAStaffCommunity.communityId')" align="center" />
          <el-table-column prop="name" :label="$t('addAStaffCommunity.communityName')" align="center" />
          <el-table-column prop="address" :label="$t('addAStaffCommunity.communityAddress')" align="center" />
        </el-table>
  
        <el-pagination class="margin-top" :current-page.sync="pagination.current" :page-sizes="[10, 20, 30, 50]"
          :page-size="pagination.size" :total="pagination.total" layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange" @current-change="handleCurrentChange" />
      </el-card>
  
      <div slot="footer" class="dialog-footer">
        <el-button @click="handleClose">{{ $t('addAStaffCommunity.cancel') }}</el-button>
        <el-button type="primary" @click="addStaffCommunity">{{ $t('addAStaffCommunity.submit') }}</el-button>
      </div>
    </el-dialog>
  </template>
  
  <script>
  import { listWaitStaffCommunities, saveStaffCommunity } from '@/api/staff/aStaffDetailApi'
  
  export default {
    name: 'AddAStaffCommunity',
    data() {
      return {
        visible: false,
        searchForm: {
          communityName: ''
        },
        communities: [],
        selectedCommunities: [],
        staffId: '',
        pagination: {
          current: 1,
          size: 10,
          total: 0
        }
      }
    },
    methods: {
      open(params) {
        this.staffId = params.staffId
        this.visible = true
        this.loadCommunities()
      },
      handleClose() {
        this.visible = false
        this.resetForm()
      },
      resetForm() {
        this.searchForm.communityName = ''
        this.communities = []
        this.selectedCommunities = []
        this.pagination.current = 1
        this.pagination.total = 0
      },
      async loadCommunities() {
        try {
          const response = await listWaitStaffCommunities({
            staffId: this.staffId,
            page: this.pagination.current,
            row: this.pagination.size,
            nameLike: this.searchForm.communityName
          })
          this.communities = (response.data || []).map(item => {
            return {
              ...item,
              checked: false
            }
          })
f9f29297   wuxw   v1.9 分页 record 传给...
88
          this.pagination.total = response.total || 0
ebc1053d   wuxw   加入运营员工详情功能
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
        } catch (error) {
          this.$message.error(this.$t('addAStaffCommunity.loadError'))
        }
      },
      searchCommunities() {
        this.pagination.current = 1
        this.loadCommunities()
      },
      handleCheckChange(row) {
        if (row.checked) {
          this.selectedCommunities.push({
            communityId: row.communityId,
            communityName: row.name
          })
        } else {
          this.selectedCommunities = this.selectedCommunities.filter(
            item => item.communityId !== row.communityId
          )
        }
      },
      handleSizeChange(size) {
        this.pagination.size = size
        this.loadCommunities()
      },
      handleCurrentChange(page) {
        this.pagination.current = page
        this.loadCommunities()
      },
      async addStaffCommunity() {
        if (this.selectedCommunities.length === 0) {
          this.$message.warning(this.$t('addAStaffCommunity.selectCommunity'))
          return
        }
  
        try {
          await saveStaffCommunity({
            staffId: this.staffId,
            communitys: this.selectedCommunities
          })
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
128
          this.$message.success(this.$t('common.operationSuccess'))
ebc1053d   wuxw   加入运营员工详情功能
129
130
131
132
133
134
135
136
137
          this.handleClose()
          this.$emit('success')
        } catch (error) {
          this.$message.error(this.$t('addAStaffCommunity.addError'))
        }
      }
    }
  }
  </script>