tj
2025-03-20 a35f4b4d0c555493cc464bfd36d037230547f1aa
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<template>
  <a-row :gutter="24">
    <a-col :md="24">
      <a-card :style="cardStyle" :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
          <a-form layout="inline" @keyup.enter.native="searchQuery">
            <a-row :gutter="24">
              <a-col :md="6" :sm="24">
                <a-form-item label="字典编码" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input placeholder="请输入字典编码" v-model="queryParam.dictCode"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="字典名称" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-input placeholder="请输入字典名称" v-model="queryParam.dictName"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="6" :sm="24">
                <a-form-item label="状态" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-select placeholder="请选择状态" v-model="queryParam.status" allowClear>
                    <a-select-option :value="0">停用</a-select-option>
                    <a-select-option :value="1">启用</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
                <a-col :md="6" :sm="24">
                  <a-button type="primary" @click="searchQuery">查询</a-button>
                  <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
                </a-col>
              </span>
            </a-row>
          </a-form>
        </div>
        <!-- 操作按钮区域 -->
        <div class="table-operator" style="margin-top: 5px">
          <a-button type="primary" icon="plus" @click="handleAdd">新增</a-button>
          <a-button type="primary" icon="delete" @click="batchDel">删除</a-button>
        </div>
        <!-- table区域-begin -->
        <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 @click="handleItems(record)">字典项</a>
              <a-divider type="vertical" />
              <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                <a>删除</a>
              </a-popconfirm>
            </span>
            <template slot="statusSlot" slot-scope="text">
              <a-tag :color="text === 1 ? 'green' : 'orange'">
                {{ text === 1 ? '启用' : '停用' }}
              </a-tag>
            </template>
          </a-table>
        </div>
        <!-- table区域-end -->
        
        <!-- 表单区域 -->
        <sys-dict-modal ref="modalForm" @ok="modalFormOk"></sys-dict-modal>
        <sys-dict-item-modal ref="itemModalForm" @ok="modalFormOk"></sys-dict-item-modal>
      </a-card>
    </a-col>
  </a-row>
</template>
 
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import SysDictModal from './modules/SysDictModal'
  import SysDictItemModal from './modules/SysDictItemModal'
  import { deleteAction } from '@/api/manage'
 
  export default {
    name: "SysDictList",
    mixins:[JeecgListMixin],
    components: {
      SysDictModal,
      SysDictItemModal
    },
    data () {
      return {
        description: '字典管理页面',
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        // 查询条件
        queryParam: {
          dictCode: '',
          dictName: '',
          status: undefined
        },
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            width:150,
            align:"center",
            scopedSlots: { customRender: 'action' }
          },
          {
            title: '字典编码',
            align:"left",
            dataIndex: 'dictCode'
          },
          {
            title: '字典名称',
            align:"left",
            dataIndex: 'dictName'
          },
          {
            title: '描述',
            align:"left",
            dataIndex: 'description'
          },
          {
            title: '状态',
            align:"center",
            dataIndex: 'status',
            scopedSlots: { customRender: 'statusSlot' }
          },
          {
            title: '创建时间',
            align:"center",
            dataIndex: 'createTime',
            width: 180
          }
        ],
        url: {
          list: "/sysDict/list",
          delete: "/sysDict/delete",
          deleteBatch: "/sysDict/deleteBatch"
        },
        btnEnableList: [],
        cardStyle: {
          height: '100%'
        }
      }
    },
    methods: {
      searchReset() {
        this.queryParam = {
          dictCode: '',
          dictName: '',
          status: undefined
        }
        this.loadData(1);
      },
      handleEdit: function (record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = "编辑";
        this.$refs.modalForm.disableSubmit = false;
      },
      handleAdd: function () {
        this.$refs.modalForm.add();
        this.$refs.modalForm.title = "新增";
        this.$refs.modalForm.disableSubmit = false;
      },
      handleItems: function (record) {
        this.$refs.itemModalForm.show(record);
        this.$refs.itemModalForm.title = "字典项管理";
        this.$refs.itemModalForm.disableSubmit = false;
      },
      handleDelete(id) {
        deleteAction(this.url.delete, {id: id}).then((res) => {
          if (res.success) {
            this.$message.success(res.message);
            this.loadData();
          } else {
            this.$message.warning(res.message);
          }
        });
      },
      batchDel() {
        if (this.selectedRowKeys.length <= 0) {
          this.$message.warning('请选择一条记录!');
          return;
        }
        let ids = "";
        this.selectedRowKeys.forEach(function(val) {
          ids+=val+",";
        });
        ids = ids.substring(0,ids.length-1);
        deleteAction(this.url.deleteBatch, {ids: ids}).then((res) => {
          if (res.success) {
            this.$message.success(res.message);
            this.loadData();
            this.selectedRowKeys = [];
          } else {
            this.$message.warning(res.message);
          }
        });
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>