【前端】智能库房综合管理系统前端项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

176 lines
5.7 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <div>
  3. <!--工具栏-->
  4. <div class="head-container">
  5. <crudOperation :permission="permission">
  6. <template v-slot:left>
  7. <el-button v-permission="permission.add" size="mini" type="primary" icon="el-icon-plus" :disabled="!activeAddBtn" @click="crud.toAdd">新增</el-button>
  8. </template>
  9. <template v-slot:right>
  10. <el-button v-permission="permission.del" icon="el-icon-delete" size="mini" :loading="crud.delAllLoading" :disabled="crud.selections.length === 0" @click="toDelete(crud.selections)">删除</el-button>
  11. </template>
  12. </crudOperation>
  13. </div>
  14. <!--表单组件-->
  15. <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title">
  16. <span class="dialog-right-top" />
  17. <span class="dialog-left-bottom" />
  18. <div class="setting-dialog">
  19. <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
  20. <el-form-item label="字典名称" prop="dicName">
  21. <el-input v-model="form.dicName" style="width: 370px;" />
  22. </el-form-item>
  23. <el-form-item label="字典代码" prop="dicCode">
  24. <el-input v-model="form.dicCode" style="width: 370px;" />
  25. </el-form-item>
  26. <el-form-item label="内容说明" prop="dicExplain">
  27. <el-input v-model="form.dicExplain" style="width: 370px;" type="textarea" :rows="4" />
  28. </el-form-item>
  29. </el-form>
  30. <div slot="footer" class="dialog-footer">
  31. <el-button type="text" @click="crud.cancelCU">取消</el-button>
  32. <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
  33. </div>
  34. </div>
  35. </el-dialog>
  36. <el-dialog title="删除字典内容" :visible.sync="deleteVisible" :before-close="handleClose">
  37. <span class="dialog-right-top" />
  38. <span class="dialog-left-bottom" />
  39. <div class="setting-dialog">
  40. <div class="dialog-delt">
  41. <p><span>确定删除当前字典内容吗</span></p>
  42. </div>
  43. <div slot="footer" class="dialog-footer">
  44. <el-button type="primary" @click.native="handleConfirm">确定</el-button>
  45. </div>
  46. </div>
  47. </el-dialog>
  48. <!--表格渲染-->
  49. <el-table ref="table" v-loading="crud.loading" :data="crud.data" highlight-current-row style="width: 100%;" @selection-change="selectionChangeHandler" @row-click="clickRowHandler">
  50. <el-table-column type="selection" width="55" />
  51. <el-table-column prop="dicName" label="字典名称" />
  52. <el-table-column prop="dicCode" label="字典代码" />
  53. <el-table-column prop="dicExplain" label="内容说明" />
  54. </el-table>
  55. <!--分页组件-->
  56. <pagination />
  57. </div>
  58. </template>
  59. <script>
  60. import crudDictDetail from '@/api/archivesConfig/dictDetail'
  61. import CRUD, { presenter, header, form } from '@crud/crud'
  62. import crudOperation from '@crud/CRUD.operation'
  63. import pagination from '@crud/Pagination'
  64. const defaultForm = { id: null, dicName: null, dicCode: null, dicExplain: null, dicType: false }
  65. export default {
  66. components: { crudOperation, pagination },
  67. cruds() {
  68. return [
  69. CRUD({
  70. title: '字典内容', url: 'api/dictrionary/findSubsetById', query: { id: '' },
  71. crudMethod: { ...crudDictDetail },
  72. optShow: {
  73. add: false,
  74. edit: true,
  75. del: false,
  76. reset: false,
  77. download: false,
  78. group: false
  79. },
  80. queryOnPresenterCreated: false,
  81. sort: ['dicCode,asc']
  82. })
  83. ]
  84. },
  85. mixins: [
  86. presenter(),
  87. header(),
  88. form(function() {
  89. return Object.assign({ dicPid: this.dicPid }, defaultForm)
  90. })
  91. ],
  92. props: {
  93. activeAddBtn: {
  94. type: Boolean
  95. }
  96. },
  97. data() {
  98. return {
  99. dicPid: null,
  100. needRefreshTree: false,
  101. rules: {
  102. dicName: [
  103. { required: true, message: '请输入字典名称', trigger: 'blur' }
  104. ],
  105. dicCode: [
  106. { required: true, message: '请输入字典代码', trigger: 'blur' }
  107. ]
  108. },
  109. permission: {
  110. add: ['admin', 'dict:add'],
  111. edit: ['admin', 'dict:edit'],
  112. del: ['admin', 'dict:del']
  113. },
  114. deleteVisible: false,
  115. deleteData: {}
  116. }
  117. },
  118. methods: {
  119. [CRUD.HOOK.afterSubmit]() {
  120. this.needRefreshTree = true
  121. },
  122. [CRUD.HOOK.afterDelete]() {
  123. this.needRefreshTree = true
  124. },
  125. // 获取数据前设置默认参数
  126. [CRUD.HOOK.beforeRefresh]() {
  127. this.crud.query.id = this.dicPid
  128. },
  129. [CRUD.HOOK.afterRefresh](crud) {
  130. if (this.needRefreshTree) {
  131. this.needRefreshTree = false
  132. this.$emit('treeRefresh', crud.data)
  133. }
  134. },
  135. clickRowHandler(row) {
  136. this.$refs.table.clearSelection()
  137. this.$refs.table.toggleRowSelection(row)
  138. },
  139. selectionChangeHandler(val) {
  140. if (val.length > 1) {
  141. // 取出最后val的最后一个返回出来
  142. const finalVal = val.pop()
  143. // 清除所有选中
  144. this.$refs.table.clearSelection()
  145. // 给最后一个加上选中
  146. this.$refs.table.toggleRowSelection(finalVal)
  147. this.crud.selectionChangeHandler([finalVal])
  148. } else {
  149. this.crud.selectionChangeHandler(val)
  150. }
  151. },
  152. toDelete(data) {
  153. this.deleteData = data
  154. this.deleteVisible = true
  155. },
  156. handleConfirm() {
  157. this.deleteVisible = false
  158. this.crud.delAllLoading = true
  159. this.crud.doDelete(this.deleteData)
  160. },
  161. handleClose(done) {
  162. this.deleteData = {}
  163. done()
  164. }
  165. }
  166. }
  167. </script>
  168. <style rel="stylesheet/scss" lang="scss" scoped>
  169. ::v-deep thead .el-table-column--selection .cell {
  170. display: none;
  171. }
  172. </style>