管理系统PC端
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

350 linhas
10 KiB

  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="字典名称" prop="dictName">
  5. <el-input
  6. v-model="queryParams.dictName"
  7. placeholder="请输入字典名称"
  8. clearable
  9. style="width: 240px"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="字典类型" prop="dictType">
  14. <el-input
  15. v-model="queryParams.dictType"
  16. placeholder="请输入字典类型"
  17. clearable
  18. style="width: 240px"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="状态" prop="status">
  23. <el-select
  24. v-model="queryParams.status"
  25. placeholder="字典状态"
  26. clearable
  27. style="width: 240px"
  28. >
  29. <el-option
  30. v-for="dict in dict.type.sys_normal_disable"
  31. :key="dict.value"
  32. :label="dict.label"
  33. :value="dict.value"
  34. />
  35. </el-select>
  36. </el-form-item>
  37. <el-form-item label="创建时间">
  38. <el-date-picker
  39. v-model="dateRange"
  40. style="width: 240px"
  41. value-format="yyyy-MM-dd"
  42. type="daterange"
  43. range-separator="-"
  44. start-placeholder="开始日期"
  45. end-placeholder="结束日期"
  46. ></el-date-picker>
  47. </el-form-item>
  48. <el-form-item>
  49. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  50. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  51. </el-form-item>
  52. </el-form>
  53. <el-row :gutter="10" class="mb8">
  54. <el-col :span="1.5">
  55. <el-button
  56. type="primary"
  57. plain
  58. icon="el-icon-plus"
  59. size="mini"
  60. @click="handleAdd"
  61. v-hasPermi="['system:dict:add']"
  62. >新增</el-button>
  63. </el-col>
  64. <el-col :span="1.5">
  65. <el-button
  66. type="success"
  67. plain
  68. icon="el-icon-edit"
  69. size="mini"
  70. :disabled="single"
  71. @click="handleUpdate"
  72. v-hasPermi="['system:dict:edit']"
  73. >修改</el-button>
  74. </el-col>
  75. <el-col :span="1.5">
  76. <el-button
  77. type="danger"
  78. plain
  79. icon="el-icon-delete"
  80. size="mini"
  81. :disabled="multiple"
  82. @click="handleDelete"
  83. v-hasPermi="['system:dict:remove']"
  84. >删除</el-button>
  85. </el-col>
  86. <el-col :span="1.5">
  87. <el-button
  88. type="warning"
  89. plain
  90. icon="el-icon-download"
  91. size="mini"
  92. @click="handleExport"
  93. v-hasPermi="['system:dict:export']"
  94. >导出</el-button>
  95. </el-col>
  96. <el-col :span="1.5">
  97. <el-button
  98. type="danger"
  99. plain
  100. icon="el-icon-refresh"
  101. size="mini"
  102. @click="handleRefreshCache"
  103. v-hasPermi="['system:dict:remove']"
  104. >刷新缓存</el-button>
  105. </el-col>
  106. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  107. </el-row>
  108. <el-table v-loading="loading" :data="typeList" @selection-change="handleSelectionChange">
  109. <el-table-column type="selection" width="55" align="center" />
  110. <el-table-column label="字典编号" align="center" prop="dictId" />
  111. <el-table-column label="字典名称" align="left" prop="dictName" :show-overflow-tooltip="true" />
  112. <el-table-column label="字典类型" align="left" :show-overflow-tooltip="true">
  113. <template slot-scope="scope">
  114. <router-link :to="'/system/dict-data/index/' + scope.row.dictId" class="link-type">
  115. <span>{{ scope.row.dictType }}</span>
  116. </router-link>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="状态" align="center" prop="status">
  120. <template slot-scope="scope">
  121. <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
  122. </template>
  123. </el-table-column>
  124. <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" />
  125. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  126. <template slot-scope="scope">
  127. <span>{{ parseTime(scope.row.createTime) }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  131. <template slot-scope="scope">
  132. <el-button
  133. size="mini"
  134. type="text"
  135. icon="el-icon-edit"
  136. @click="handleUpdate(scope.row)"
  137. v-hasPermi="['system:dict:edit']"
  138. >修改</el-button>
  139. <el-button
  140. size="mini"
  141. type="text"
  142. icon="el-icon-delete"
  143. @click="handleDelete(scope.row)"
  144. v-hasPermi="['system:dict:remove']"
  145. >删除</el-button>
  146. </template>
  147. </el-table-column>
  148. </el-table>
  149. <pagination
  150. v-show="total>0"
  151. :total="total"
  152. :page.sync="queryParams.pageNum"
  153. :limit.sync="queryParams.pageSize"
  154. @pagination="getList"
  155. />
  156. <!-- 添加或修改参数配置对话框 -->
  157. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  158. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  159. <el-form-item label="字典名称" prop="dictName">
  160. <el-input v-model="form.dictName" placeholder="请输入字典名称" />
  161. </el-form-item>
  162. <el-form-item label="字典类型" prop="dictType">
  163. <el-input v-model="form.dictType" placeholder="请输入字典类型" />
  164. </el-form-item>
  165. <el-form-item label="状态" prop="status">
  166. <el-radio-group v-model="form.status">
  167. <el-radio
  168. v-for="dict in dict.type.sys_normal_disable"
  169. :key="dict.value"
  170. :label="dict.value"
  171. >{{dict.label}}</el-radio>
  172. </el-radio-group>
  173. </el-form-item>
  174. <el-form-item label="备注" prop="remark">
  175. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
  176. </el-form-item>
  177. </el-form>
  178. <div slot="footer" class="dialog-footer">
  179. <el-button type="primary" @click="submitForm">确 定</el-button>
  180. <el-button @click="cancel">取 消</el-button>
  181. </div>
  182. </el-dialog>
  183. </div>
  184. </template>
  185. <script>
  186. import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type"
  187. export default {
  188. name: "Dict",
  189. dicts: ['sys_normal_disable'],
  190. data() {
  191. return {
  192. // 遮罩层
  193. loading: true,
  194. // 选中数组
  195. ids: [],
  196. // 非单个禁用
  197. single: true,
  198. // 非多个禁用
  199. multiple: true,
  200. // 显示搜索条件
  201. showSearch: true,
  202. // 总条数
  203. total: 0,
  204. // 字典表格数据
  205. typeList: [],
  206. // 弹出层标题
  207. title: "",
  208. // 是否显示弹出层
  209. open: false,
  210. // 日期范围
  211. dateRange: [],
  212. // 查询参数
  213. queryParams: {
  214. pageNum: 1,
  215. pageSize: 10,
  216. dictName: undefined,
  217. dictType: undefined,
  218. status: undefined,
  219. orderByColumn: "dictId",
  220. isAsc: "desc",
  221. },
  222. // 表单参数
  223. form: {},
  224. // 表单校验
  225. rules: {
  226. dictName: [
  227. { required: true, message: "字典名称不能为空", trigger: "blur" }
  228. ],
  229. dictType: [
  230. { required: true, message: "字典类型不能为空", trigger: "blur" }
  231. ]
  232. }
  233. }
  234. },
  235. created() {
  236. this.getList()
  237. },
  238. methods: {
  239. /** 查询字典类型列表 */
  240. getList() {
  241. this.loading = true
  242. listType(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
  243. this.typeList = response.rows
  244. this.total = response.total
  245. this.loading = false
  246. }
  247. )
  248. },
  249. // 取消按钮
  250. cancel() {
  251. this.open = false
  252. this.reset()
  253. },
  254. // 表单重置
  255. reset() {
  256. this.form = {
  257. dictId: undefined,
  258. dictName: undefined,
  259. dictType: undefined,
  260. status: "0",
  261. remark: undefined
  262. }
  263. this.resetForm("form")
  264. },
  265. /** 搜索按钮操作 */
  266. handleQuery() {
  267. this.queryParams.pageNum = 1
  268. this.getList()
  269. },
  270. /** 重置按钮操作 */
  271. resetQuery() {
  272. this.dateRange = []
  273. this.resetForm("queryForm")
  274. this.handleQuery()
  275. },
  276. /** 新增按钮操作 */
  277. handleAdd() {
  278. this.reset()
  279. this.open = true
  280. this.title = "添加字典类型"
  281. },
  282. // 多选框选中数据
  283. handleSelectionChange(selection) {
  284. this.ids = selection.map(item => item.dictId)
  285. this.single = selection.length!=1
  286. this.multiple = !selection.length
  287. },
  288. /** 修改按钮操作 */
  289. handleUpdate(row) {
  290. this.reset()
  291. const dictId = row.dictId || this.ids
  292. getType(dictId).then(response => {
  293. this.form = response.data
  294. this.open = true
  295. this.title = "修改字典类型"
  296. })
  297. },
  298. /** 提交按钮 */
  299. submitForm: function() {
  300. this.$refs["form"].validate(valid => {
  301. if (valid) {
  302. if (this.form.dictId != undefined) {
  303. updateType(this.form).then(response => {
  304. this.$modal.msgSuccess("修改成功")
  305. this.open = false
  306. this.getList()
  307. })
  308. } else {
  309. addType(this.form).then(response => {
  310. this.$modal.msgSuccess("新增成功")
  311. this.open = false
  312. this.getList()
  313. })
  314. }
  315. }
  316. })
  317. },
  318. /** 删除按钮操作 */
  319. handleDelete(row) {
  320. const dictIds = row.dictId || this.ids
  321. this.$modal.confirm('是否确认删除字典编号为"' + dictIds + '"的数据项?').then(function() {
  322. return delType(dictIds)
  323. }).then(() => {
  324. this.getList()
  325. this.$modal.msgSuccess("删除成功")
  326. }).catch(() => {})
  327. },
  328. /** 导出按钮操作 */
  329. handleExport() {
  330. this.download('system/dict/type/export', {
  331. ...this.queryParams
  332. }, `type_${new Date().getTime()}.xlsx`)
  333. },
  334. /** 刷新缓存按钮操作 */
  335. handleRefreshCache() {
  336. refreshCache().then(() => {
  337. this.$modal.msgSuccess("刷新成功")
  338. this.$store.dispatch('dict/cleanDict')
  339. })
  340. }
  341. }
  342. }
  343. </script>