Blame view

src/components/dev/chooseService.vue 2.45 KB
b25b036d   wuxw   v1.9 优化日期
1
  <template>
a42b3256   wuxw   HC小区管理系统前段vue版正在开发中
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    <el-dialog 
      :title="$t('chooseService.title')" 
      :visible.sync="visible" 
      width="70%">
      <el-row :gutter="20">
        <el-col :span="18"></el-col>
        <el-col :span="6">
          <el-input 
            v-model="searchKey" 
            :placeholder="$t('chooseService.search')"
            clearable
            @keyup.enter.native="queryServices">
            <el-button 
              slot="append" 
              icon="el-icon-search" 
              @click="queryServices" />
          </el-input>
        </el-col>
      </el-row>
      <el-table :data="services" border style="width: 100%; margin-top: 20px">
        <el-table-column 
          prop="name" 
          :label="$t('chooseService.name')" 
          align="center" />
        <el-table-column 
          prop="serviceCode" 
          :label="$t('chooseService.serviceCode')" 
          align="center" />
        <el-table-column 
          prop="method" 
          :label="$t('chooseService.method')" 
          align="center" />
        <el-table-column 
          :label="$t('chooseService.operation')" 
          align="center" 
          width="120">
          <template slot-scope="scope">
            <el-button 
              type="primary" 
              size="mini" 
              @click="chooseService(scope.row)">
              {{ $t('chooseService.select') }}
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
  </template>
  
  <script>
  import { listServices } from '@/api/dev/devServiceProvideApi'
  
  export default {
    name: 'ChooseService',
    props: {
      emitChooseService: {
        type: String,
        default: ''
      },
      emitLoadData: {
        type: String,
        default: ''
      }
    },
    data() {
      return {
        visible: false,
        services: [],
        searchKey: '',
        page: {
          current: 1,
          size: 10
        }
      }
    },
    methods: {
      open() {
        this.visible = true
        this.searchKey = ''
        this.loadServices()
      },
      loadServices() {
        listServices({
          page: this.page.current,
          row: this.page.size,
          name: this.searchKey
        }).then(response => {
          this.services = response.data
        }).catch(error => {
          this.$message.error(error.message)
        })
      },
      queryServices() {
        this.page.current = 1
        this.loadServices()
      },
      chooseService(service) {
        this.$emit(this.emitChooseService, service)
        this.$emit(this.emitLoadData, { serviceId: service.serviceId })
        this.visible = false
      }
    }
  }
  </script>