Blame view

src/views/system/DictItemList.vue 7.44 KB
DESKTOP-AO0VKC8\mahua 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
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
<template>
  <a-card :bordered="false">
    <!-- 抽屉 -->
    <a-drawer
      title="字典列表"
      :width="screenWidth"
      @close="onClose"
      :visible="visible"
    >
      <!-- 抽屉内容的border -->
      <div
        :style="{
          padding:'10px',
          border: '1px solid #e9e9e9',
          background: '#fff',
        }">

        <div class="table-page-search-wrapper">
          <a-form layout="inline" :form="form" @keyup.enter.native="searchQuery">
            <a-row :gutter="10">
              <a-col :md="8" :sm="12">
                <a-form-item label="名称">
                  <a-input style="width: 120px;" placeholder="请输入名称" v-model="queryParam.itemText"></a-input>
                </a-form-item>
              </a-col>
              <a-col :md="9" :sm="24">
                <a-form-item label="状态" style="width: 170px" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  <a-select
                    placeholder="请选择"
                    v-model="queryParam.status"
                  >
                    <a-select-option value="1">正常</a-select-option>
                    <a-select-option value="0">禁用</a-select-option>
                  </a-select>
                </a-form-item>
              </a-col>
              <a-col :md="7" :sm="24">
              <span style="float: left;" class="table-page-search-submitButtons">
                <a-button type="primary" @click="searchQuery">搜索</a-button>
                <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置</a-button>
              </span>
              </a-col>
            </a-row>
            <a-row>
              <a-col :md="2" :sm="24">
                <a-button style="margin-bottom: 10px" type="primary" @click="handleAdd">新增</a-button>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <div>
          <a-table
            ref="table"
            rowKey="id"
            size="middle"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            @change="handleTableChange"
            :rowClassName="getRowClassname"
          >

          <span slot="action" slot-scope="text, record">
            <a @click="handleEdit(record)">编辑</a>
66
            <a-divider type="vertical" />
DESKTOP-AO0VKC8\mahua authored
67
68
69
70
71
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
              <a>删除</a>
            </a-popconfirm>
          </span>
72
73
74
75
76
77
          <span slot="status" slot-scope="text, record">
            <a-tag :key="status" :color="record.itemColor">
              {{ record.itemText }}
            </a-tag>
          </span>
DESKTOP-AO0VKC8\mahua authored
78
79
80
81
82
83
84
85
86
          </a-table>
        </div>
      </div>
    </a-drawer>
    <dict-item-modal ref="modalForm" @ok="modalFormOk"></dict-item-modal> <!-- 字典数据 -->
  </a-card>
</template>

<script>
87
88
89
90
import pick from 'lodash.pick'
import { filterObj } from '@/utils/util'
import DictItemModal from './modules/DictItemModal'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
DESKTOP-AO0VKC8\mahua authored
91
92
93
94
95
96
97
98
99
100
101
102
export default {
  name: 'DictItemList',
  mixins: [JeecgListMixin],
  components: { DictItemModal },
  data() {
    return {
      columns: [
        {
          title: '名称',
          align: 'center',
          dataIndex: 'itemText'
DESKTOP-AO0VKC8\mahua authored
103
        },
104
105
106
107
        {
          title: '数据值',
          align: 'center',
          dataIndex: 'itemValue'
DESKTOP-AO0VKC8\mahua authored
108
        },
109
110
111
112
113
        {
          title: '标签颜色',
          align: 'center',
          dataIndex: 'itemColor',
          scopedSlots: { customRender: 'status' }
DESKTOP-AO0VKC8\mahua authored
114
        },
115
116
117
118
        {
          title: '排序',
          align: 'center',
          dataIndex: 'sortOrder'
DESKTOP-AO0VKC8\mahua authored
119
        },
120
121
122
123
124
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
DESKTOP-AO0VKC8\mahua authored
125
        }
126
127
128
129
130
131
132
      ],
      queryParam: {
        dictId: '',
        dictName: '',
        itemText: '',
        delFlag: '1',
        status: []
DESKTOP-AO0VKC8\mahua authored
133
      },
134
135
136
137
138
139
140
141
142
      title: '操作',
      visible: false,
      screenWidth: 800,
      model: {},
      dictId: '',
      status: 1,
      labelCol: {
        xs: { span: 5 },
        sm: { span: 5 }
DESKTOP-AO0VKC8\mahua authored
143
      },
144
145
146
      wrapperCol: {
        xs: { span: 12 },
        sm: { span: 12 }
DESKTOP-AO0VKC8\mahua authored
147
      },
148
149
150
151
      form: this.$form.createForm(this),
      validatorRules: {
        itemText: { rules: [{ required: true, message: '请输入名称!' }] },
        itemValue: { rules: [{ required: true, message: '请输入数据值!' }] }
DESKTOP-AO0VKC8\mahua authored
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
228
      url: {
        list: '/sys/dictItem/list',
        delete: '/sys/dictItem/delete',
        deleteBatch: '/sys/dictItem/deleteBatch'
      }
    }
  },
  created() {
    // 当页面初始化时,根据屏幕大小来给抽屉设置宽度
    this.resetScreenSize()
  },
  methods: {
    add(dictId) {
      this.dictId = dictId
      this.edit({})
    },
    edit(record) {
      if (record.id) {
        this.dictId = record.id
      }
      this.queryParam = {}
      this.form.resetFields()
      this.model = Object.assign({}, record)
      this.model.dictId = this.dictId
      this.model.status = this.status
      this.visible = true
      this.$nextTick(() => {
        this.form.setFieldsValue(pick(this.model, 'itemText', 'itemValue'))
      })
      // 当其它模块调用该模块时,调用此方法加载字典数据
      this.loadData()
    },

    getQueryParams() {
      //update--begin--autor:wangshuai-----date:20191204------for:清空总条数 teambition JT-113------
      this.ipagination.total = 0
      //update--end--autor:wangshuai-----date:20191204------for:清空总条数 teambition JT-113------
      var param = Object.assign({}, this.queryParam)
      param.dictId = this.dictId
      param.field = this.getQueryField()
      param.pageNo = this.ipagination.current
      param.pageSize = this.ipagination.pageSize
      if (this.superQueryParams) {
        param['superQueryParams'] = encodeURI(this.superQueryParams)
        param['superQueryMatchType'] = this.superQueryMatchType
      }
      return filterObj(param)
    },

    // 添加字典数据
    handleAdd() {
      this.$refs.modalForm.add(this.dictId)
      this.$refs.modalForm.title = '新增'
    },
    showDrawer() {
      this.visible = true
    },
    onClose() {
      this.visible = false
      this.form.resetFields()
      this.dataSource = []
    },
    // 抽屉的宽度随着屏幕大小来改变
    resetScreenSize() {
      let screenWidth = document.body.clientWidth
      if (screenWidth < 600) {
        this.screenWidth = screenWidth
      } else {
        this.screenWidth = 600
      }
    },
    //update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
    //增加样式方法返回值
    getRowClassname(record) {
      if (record.status == 0) {
        return 'data-rule-invalid'
DESKTOP-AO0VKC8\mahua authored
229
230
      }
    }
231
    //update--end--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
DESKTOP-AO0VKC8\mahua authored
232
  }
233
}
DESKTOP-AO0VKC8\mahua authored
234
235
236
</script>
<style lang="less" scoped>
//update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
237
/deep/ .data-rule-invalid {
DESKTOP-AO0VKC8\mahua authored
238
239
240
  background: #f4f4f4;
  color: #bababa;
}
241
DESKTOP-AO0VKC8\mahua authored
242
243
//update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
</style>