Blame view

ant-design-vue-jeecg/src/views/system/DepartList2.vue 7.16 KB
肖超群 authored
1
2
3
4
5
6
7
8
<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <!--
   -->
    <!-- 操作按钮区域 -->
    <div class="table-operator">
9
      <a-button @click="handleAdd" type="primary" icon="plus">{{ $t('button.new') }}</a-button>
肖超群 authored
10
11
12
13

      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
14
            <a-icon type="delete"/>{{$t('button.delete')}}
肖超群 authored
15
16
          </a-menu-item>
        </a-menu>
17
        <a-button style="margin-left: 8px">{{$t('button.multiSelectActions')}}
肖超群 authored
18
19
20
21
22
23
24
25
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
26
27
28
        <i class="anticon anticon-info-circle ant-alert-icon"></i> {{ $t('button.selected') }}
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a> {{ $t('button.item') }}
        <a style="margin-left: 24px" @click="onClearSelected">{{ $t('button.clearAll') }}</a>
肖超群 authored
29
      </div>
30
肖超群 authored
31
32
33
34
35
36
37
38
39
40
41
42
43
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <span slot="action" slot-scope="text, record">
44
          <a @click="handleEdit(record)">{{$t('button.edit')}}</a>
肖超群 authored
45
46
47

          <a-divider type="vertical"/>
          <a-dropdown>
48
            <a class="ant-dropdown-link">{{$t('button.more')}}&nbsp;<a-icon type="down"/></a>
肖超群 authored
49
50
            <a-menu slot="overlay">
              <a-menu-item>
51
                <a href="javascript:;" @click="handleDetail(record)">{{$t('button.details')}}</a>
肖超群 authored
52
53
              </a-menu-item>
              <a-menu-item>
54
55
                <a-popconfirm :title="$t('button.deletingIt')" @confirm="() => handleDelete(record.id)">
                  <a>{{$t('button.delete')}}</a>
肖超群 authored
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <sysDepart-modal ref="sysDepartModal" @ok="modalFormOk"></sysDepart-modal>
  </a-card>
</template>

<script>
肖超群 authored
72
73
74
75
76
import SysDepartModal from './modules/DepartModal'
/*  import { filterObj } from '@/utils/util'
  , queryByFactories*/
import {queryDepartTreeList} from '@/api/api'
import {deleteAction} from '@/api/manage'
77
import { translateResultMessage } from '@/api/api'
肖超群 authored
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

// 表头
const columns = [
  {
    title: '机构名称',
    dataIndex: 'departName',
  },
  {
    title: '机构类型',
    align: "center",
    dataIndex: 'orgType'
  },
  {
    title: '机构编码',
    dataIndex: 'orgCode'
  },
  {
    title: '手机号',
    dataIndex: 'mobile'
  },
  {
    title: '传真',
    dataIndex: 'fax'
  },
  {
    title: '地址',
    dataIndex: 'address'
  },
  {
    title: '排序',
    align: 'center',
    dataIndex: 'departOrder'
  },
  {
112
    title: this.$t('system.options'),
肖超群 authored
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
    align: "center",
    dataIndex: 'action',
    scopedSlots: {customRender: 'action'},
  }
];

export default {
  name: "DepartList2",
  components: {
    SysDepartModal
  },
  data() {
    return {
      description: 'jeecg 生成SysDepart代码管理页面',
      // 查询条件
      queryParam: {},
      //数据集
      factories: '',
      dataSource: [],
      columns: columns,
      // 分页参数
      /*        ipagination:{
                current: 1,
                pageSize: 5,
                pageSizeOptions: ['5', '10', '20'],
                showTotal: (total, range) => {
谭毅彬 authored
139
                  return range[0] + "-" + range[1] + " " + this.$t('list.showing') + " " + total + " " + this.$t('list.records')
肖超群 authored
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
              },*/
      isorter: {
        column: 'createTime',
        order: 'desc',
      },
      loading: false,
      selectedRowKeys: [],
      selectedRows: [],
      url: {
        list: "/sys/sysDepart/list",
        delete: "/sys/sysDepart/delete",
        deleteBatch: "/sys/sysDepart/deleteBatch",
      },
肖超群 authored
157
158

    }
肖超群 authored
159
160
161
162
163
164
165
166
167
168
169
170
  },
  created() {
    this.loadData();
  },
  methods: {
    loadData() {
      this.dataSource = [];
      queryDepartTreeList().then((res) => {
        if (res.success) {
          this.dataSource = res.result;
        }
      })
肖超群 authored
171
172
173

    },
肖超群 authored
174
175
176
177
178
    getQueryField() {
      //TODO 字段权限控制
      var str = "id,";
      for (var a = 0; a < this.columns.length; a++) {
        str += "," + this.columns[a].dataIndex;
肖超群 authored
179
      }
肖超群 authored
180
      return str;
肖超群 authored
181
    },
肖超群 authored
182
183
184
185
186
187
188
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
肖超群 authored
189
190
    },
//TODO getQueryParams
肖超群 authored
191
192
193
194
    handleDelete: function (id) {
      var that = this;
      deleteAction(that.url.delete, {id: id}).then((res) => {
        if (res.success) {
195
          that.$message.success(translateResultMessage(res, res.message))
肖超群 authored
196
          that.loadData();
肖超群 authored
197
        } else {
198
          that.$message.warning(translateResultMessage(res, res.message))
肖超群 authored
199
        }
肖超群 authored
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
      });
    },
    handleDetail(record) {
      this.$refs.sysDepartModal.edit(record);
      this.$refs.sysDepartModal.title = "详情";
      this.$refs.sysDepartModal.disableSubmit = true;
    },
    batchDel: function () {
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录!');
        return;
      } else {
        var ids = "";
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ",";
肖超群 authored
215
        }
肖超群 authored
216
217
218
219
220
221
222
        var that = this;
        this.$confirm({
          title: "确认删除",
          content: "是否删除选中数据?",
          onOk: function () {
            deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
              if (res.success) {
223
                that.$message.success(translateResultMessage(res, res.message))
肖超群 authored
224
225
226
                that.loadData();
                that.onClearSelected();
              } else {
227
                that.$message.warning(translateResultMessage(res, res.message))
肖超群 authored
228
229
230
231
              }
            });
          }
        });
肖超群 authored
232
      }
肖超群 authored
233
234
235
    },
    handleEdit: function (record) {
      this.$refs.sysDepartModal.edit(record);
236
      this.$refs.sysDepartModal.title = this.$t('button.edit');
肖超群 authored
237
238
239
    },
    handleAdd() {
      this.$refs.sysDepartModal.add();
240
      this.$refs.sysDepartModal.title = this.$t('button.new');
肖超群 authored
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
    },
    handleTableChange(pagination, filters, sorter) {
      //分页、排序、筛选变化时触发
      console.log(sorter);
      //TODO 筛选
      if (Object.keys(sorter).length > 0) {
        this.isorter.column = sorter.field;
        this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
      }
      /*this.ipagination = pagination;*/
      this.loadData();
    },
    modalFormOk() {
      // 新增/修改 成功时,重载列表
      this.loadData();
肖超群 authored
256
257
    }
  }
肖超群 authored
258
}
肖超群 authored
259
260
</script>
<style scoped>
肖超群 authored
261
@import '~@assets/less/common.less'
肖超群 authored
262
</style>