renkang
2024-12-23 26b93e84d4153039ef3600355308d2a743dc3be7
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
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<template>
  <div class="main_app">
    <QueryForm v-model="filters" :query-form-config="queryFormConfig" @handleQuery="getList(1)" @clear="clear" />
    <div class="mt20">
      <el-button type="primary" @click="handleEdit()" icon="el-icon-plus"
        v-permissions="['business:ywpatrolline:create']">新建</el-button>
    </div>
    <el-table v-loading="loading" :data="list" stripe>
      <el-table-column prop="title" label="收支条目" min-width="100" show-overflow-tooltip />
      <el-table-column prop="companyName" label="收款公司" min-width="100" show-overflow-tooltip />
      <el-table-column label="账户类型" min-width="100" show-overflow-tooltip>
        <template v-slot="{row}">
          <span v-if="row.type == 0">对公</span>
          <span v-if="row.type == 1">个人</span>
        </template>
      </el-table-column>
      <el-table-column prop="name" label="账户名称" min-width="100" show-overflow-tooltip />
      <el-table-column prop="bankName" label="开户银行" min-width="100" show-overflow-tooltip />
      <el-table-column prop="bankNo" label="银行账号" min-width="100" show-overflow-tooltip />
      <el-table-column prop="status" label="状态" min-width="100" show-overflow-tooltip>
        <template v-slot="scope">
          <el-switch v-model="scope.row.status" @change="e =>changeStatus(scope.row)" :active-value="0" :inactive-value="1">
          </el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="120" fixed="right">
        <template slot-scope="{row}">
          <el-button type="text" @click="handleEdit(row)" icon="el-icon-edit"
            v-permissions="['business:category:update']">编辑</el-button>
          <el-button type="text" @click="handleDel(row)" icon="el-icon-delete"
            v-permissions="['business:category:delete']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="mt20">
      <Pagination @size-change="handleSizeChange" @current-change="getList" :pagination="pagination" />
    </div>
    <Edit v-if="showEdit" ref="EditRef" @success="getList" @close="showEdit = false" />
  </div>
</template>
 
<script>
import Pagination from '@/components/common/Pagination'
import QueryForm from '@/components/common/QueryForm'
import Edit from './components/accountEdit.vue'
import { fetchList, updateById, deleteById } from '@/api/business/ywAccount'
import { companyGetList } from '@/api/business/company'
import { Message } from 'element-ui'
export default {
  components: {
    Pagination,
    QueryForm,
    Edit
  },
  data() {
    return {
      loading: false,
      showEdit: false,
      pagination: {
        pageSize: 10,
        page: 1,
        total: 0
      },
      filters: {},
      list: [],
      total: 0,
      queryFormConfig: {
        formItems: [
          {
            filed: 'title',
            type: 'input',
            label: '收支条目'
          },
          {
            filed: 'companyId',
            type: 'select',
            label: '收款公司',
            labelCode: 'name',
            valueCode: 'id',
            options: []
          },
        ],
        online: true
      }
    }
  },
  created() {
    this.getList()
    this.getCompany()
  },
  methods: {
    getList(page) {
      const { pagination, filters } = this
      this.loading = true
      fetchList({
        model: {
          ...filters,
        },
        capacity: pagination.pageSize,
        page: page || pagination.page,
      }).then(res => {
        this.loading = false
        this.list = res.records || []
        this.list.forEach(item => {
          item.stautsName = item.status == 0 ? '正常' : item.status == 1 ? '损坏' : '报废'
        })
        this.pagination.total = res.total || 0
      }, () => {
        this.loading = false
      })
    },
    changeStatus(row) {
      updateById(row).then(res => {
        this.getList()
        Message.success('更新状态成功')
      }, () => {
        this.getList()
      })
    },
    getCompany(){
      companyGetList({
        model: {type: 2},
        capacity: 9999,
        page: 1
      }).then(res => {
       this.queryFormConfig.formItems[1].options = res.records || []
      })
    },
    handleEdit(row) {
      this.showEdit = true
      this.$nextTick(() => {
        this.$refs.EditRef.isShowModal = true
        if (row && row.id) {
          this.$refs.EditRef.getDetail(row.id)
        }
      })
 
    },
    handleDel(row) {
      let message = `确认删除该账户吗?`
      this.$dialog.deleteConfirm(message)
        .then(() => {
          deleteById(row.id)
            .then(() => {
              this.$tip.apiSuccess('删除成功')
              this.getList()
            })
        })
        .catch(() => { })
    },
    clear() {
      this.filters = {}
      this.pagination.pageSize = 10
      this.pagination.page = 1
      this.getList()
    },
    handleSizeChange(capacity) {
      this.pagination.pageSize = capacity
    }
  }
}
</script>
 
<style></style>