Blame view

ant-design-vue-jeecg/src/views/system/DepartList2.vue 6.73 KB
肖超群 authored
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
<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <!--
   -->
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>

      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
肖超群 authored
27
28
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
肖超群 authored
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
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>
      <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">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical"/>
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a href="javascript:;" @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </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
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
import SysDepartModal from './modules/DepartModal'
/*  import { filterObj } from '@/utils/util'
  , queryByFactories*/
import {queryDepartTreeList} from '@/api/api'
import {deleteAction} from '@/api/manage'

// 表头
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'
  },
  {
    title: '操作',
    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) => {
                  return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                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
156
157

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

    },
肖超群 authored
173
174
175
176
177
    getQueryField() {
      //TODO 字段权限控制
      var str = "id,";
      for (var a = 0; a < this.columns.length; a++) {
        str += "," + this.columns[a].dataIndex;
肖超群 authored
178
      }
肖超群 authored
179
      return str;
肖超群 authored
180
    },
肖超群 authored
181
182
183
184
185
186
187
    onSelectChange(selectedRowKeys, selectionRows) {
      this.selectedRowKeys = selectedRowKeys;
      this.selectionRows = selectionRows;
    },
    onClearSelected() {
      this.selectedRowKeys = [];
      this.selectionRows = [];
肖超群 authored
188
189
    },
//TODO getQueryParams
肖超群 authored
190
191
192
193
194
195
    handleDelete: function (id) {
      var that = this;
      deleteAction(that.url.delete, {id: id}).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
肖超群 authored
196
        } else {
肖超群 authored
197
          that.$message.warning(res.message);
肖超群 authored
198
        }
肖超群 authored
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
      });
    },
    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
214
        }
肖超群 authored
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
        var that = this;
        this.$confirm({
          title: "确认删除",
          content: "是否删除选中数据?",
          onOk: function () {
            deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.loadData();
                that.onClearSelected();
              } else {
                that.$message.warning(res.message);
              }
            });
          }
        });
肖超群 authored
231
      }
肖超群 authored
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
    },
    handleEdit: function (record) {
      this.$refs.sysDepartModal.edit(record);
      this.$refs.sysDepartModal.title = "编辑";
    },
    handleAdd() {
      this.$refs.sysDepartModal.add();
      this.$refs.sysDepartModal.title = "新增";
    },
    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
255
256
    }
  }
肖超群 authored
257
}
肖超群 authored
258
259
</script>
<style scoped>
肖超群 authored
260
@import '~@assets/less/common.less'
肖超群 authored
261
</style>