13c28174e7a88b43d075228334444f3c75105fb2.svn-base 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <a-card :bordered="false">
  3. <!-- 抽屉 -->
  4. <a-drawer
  5. title="字典列表"
  6. :width="screenWidth"
  7. @close="onClose"
  8. :visible="visible"
  9. >
  10. <!-- 抽屉内容的border -->
  11. <div
  12. :style="{
  13. padding:'10px',
  14. border: '1px solid #e9e9e9',
  15. background: '#fff',
  16. }">
  17. <div class="table-page-search-wrapper">
  18. <a-form layout="inline" :form="form" @keyup.enter.native="searchQuery">
  19. <a-row :gutter="10">
  20. <a-col :md="8" :sm="12">
  21. <a-form-item label="名称">
  22. <a-input style="width: 120px;" placeholder="请输入名称" v-model="queryParam.itemText"></a-input>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :md="9" :sm="24">
  26. <a-form-item label="状态" style="width: 170px" :labelCol="labelCol" :wrapperCol="wrapperCol">
  27. <a-select
  28. placeholder="请选择"
  29. v-model="queryParam.status"
  30. >
  31. <a-select-option value="1">正常</a-select-option>
  32. <a-select-option value="0">禁用</a-select-option>
  33. </a-select>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :md="7" :sm="24">
  37. <span style="float: left;" class="table-page-search-submitButtons">
  38. <a-button type="primary" @click="searchQuery">搜索</a-button>
  39. <a-button type="primary" @click="searchReset" style="margin-left: 8px">重置</a-button>
  40. </span>
  41. </a-col>
  42. </a-row>
  43. <a-row>
  44. <a-col :md="2" :sm="24">
  45. <a-button style="margin-bottom: 10px" type="primary" @click="handleAdd">新增</a-button>
  46. </a-col>
  47. </a-row>
  48. </a-form>
  49. </div>
  50. <div>
  51. <a-table
  52. ref="table"
  53. rowKey="id"
  54. size="middle"
  55. :columns="columns"
  56. :dataSource="dataSource"
  57. :pagination="ipagination"
  58. :loading="loading"
  59. @change="handleTableChange"
  60. :rowClassName="getRowClassname"
  61. >
  62. <span slot="action" slot-scope="text, record">
  63. <a @click="handleEdit(record)">编辑</a>
  64. <a-divider type="vertical"/>
  65. <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
  66. <a>删除</a>
  67. </a-popconfirm>
  68. </span>
  69. </a-table>
  70. </div>
  71. </div>
  72. </a-drawer>
  73. <dict-item-modal ref="modalForm" @ok="modalFormOk"></dict-item-modal> <!-- 字典数据 -->
  74. </a-card>
  75. </template>
  76. <script>
  77. import pick from 'lodash.pick'
  78. import {filterObj} from '@/utils/util';
  79. import DictItemModal from './modules/DictItemModal'
  80. import {JeecgListMixin} from '@/mixins/JeecgListMixin'
  81. export default {
  82. name: "DictItemList",
  83. mixins: [JeecgListMixin],
  84. components: {DictItemModal},
  85. data() {
  86. return {
  87. columns: [
  88. {
  89. title: '名称',
  90. align: "center",
  91. dataIndex: 'itemText',
  92. },
  93. {
  94. title: '数据值',
  95. align: "center",
  96. dataIndex: 'itemValue',
  97. },
  98. {
  99. title: '操作',
  100. dataIndex: 'action',
  101. align: "center",
  102. scopedSlots: {customRender: 'action'},
  103. }
  104. ],
  105. queryParam: {
  106. dictId: "",
  107. dictName: "",
  108. itemText: "",
  109. delFlag: "1",
  110. status: [],
  111. },
  112. title: "操作",
  113. visible: false,
  114. screenWidth: 800,
  115. model: {},
  116. dictId: "",
  117. status: 1,
  118. labelCol: {
  119. xs: {span: 5},
  120. sm: {span: 5},
  121. },
  122. wrapperCol: {
  123. xs: {span: 12},
  124. sm: {span: 12},
  125. },
  126. form: this.$form.createForm(this),
  127. validatorRules: {
  128. itemText: {rules: [{required: true, message: '请输入名称!'}]},
  129. itemValue: {rules: [{required: true, message: '请输入数据值!'}]},
  130. },
  131. url: {
  132. list: "/sys/dictItem/list",
  133. delete: "/sys/dictItem/delete",
  134. deleteBatch: "/sys/dictItem/deleteBatch",
  135. },
  136. }
  137. },
  138. created() {
  139. // 当页面初始化时,根据屏幕大小来给抽屉设置宽度
  140. this.resetScreenSize();
  141. },
  142. methods: {
  143. add(dictId) {
  144. this.dictId = dictId;
  145. this.edit({});
  146. },
  147. edit(record) {
  148. if (record.id) {
  149. this.dictId = record.id;
  150. }
  151. this.queryParam = {}
  152. this.form.resetFields();
  153. this.model = Object.assign({}, record);
  154. this.model.dictId = this.dictId;
  155. this.model.status = this.status;
  156. this.visible = true;
  157. this.$nextTick(() => {
  158. this.form.setFieldsValue(pick(this.model, 'itemText', 'itemValue'))
  159. });
  160. // 当其它模块调用该模块时,调用此方法加载字典数据
  161. this.loadData();
  162. },
  163. getQueryParams() {
  164. //update--begin--autor:wangshuai-----date:20191204------for:清空总条数 teambition JT-113------
  165. this.ipagination.total=0;
  166. //update--end--autor:wangshuai-----date:20191204------for:清空总条数 teambition JT-113------
  167. var param = Object.assign({}, this.queryParam);
  168. param.dictId = this.dictId;
  169. param.field = this.getQueryField();
  170. param.pageNo = this.ipagination.current;
  171. param.pageSize = this.ipagination.pageSize;
  172. if (this.superQueryParams) {
  173. param['superQueryParams'] = encodeURI(this.superQueryParams)
  174. param['superQueryMatchType'] = this.superQueryMatchType
  175. }
  176. return filterObj(param);
  177. },
  178. // 添加字典数据
  179. handleAdd() {
  180. this.$refs.modalForm.add(this.dictId);
  181. this.$refs.modalForm.title = "新增";
  182. },
  183. showDrawer() {
  184. this.visible = true
  185. },
  186. onClose() {
  187. this.visible = false
  188. this.form.resetFields();
  189. this.dataSource = [];
  190. },
  191. // 抽屉的宽度随着屏幕大小来改变
  192. resetScreenSize() {
  193. let screenWidth = document.body.clientWidth;
  194. if (screenWidth < 600) {
  195. this.screenWidth = screenWidth;
  196. } else {
  197. this.screenWidth = 600;
  198. }
  199. },
  200. //update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
  201. //增加样式方法返回值
  202. getRowClassname(record){
  203. if(record.status==0){
  204. return "data-rule-invalid"
  205. }
  206. }
  207. //update--end--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
  208. }
  209. }
  210. </script>
  211. <style lang="less" scoped>
  212. //update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
  213. /deep/ .data-rule-invalid{
  214. background: #f4f4f4;
  215. color: #bababa;
  216. }
  217. //update--begin--autor:wangshuai-----date:20191204------for:系统管理 数据字典禁用和正常区别开,添加背景颜色 teambition JT-22------
  218. </style>