chooseDept.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <el-dialog v-if="visible" :title="title" width="50%" custom-class="dialog-med3" top="5vh" center
  3. :before-close="dialogClose" :visible.sync="visible" :close-on-click-modal="false" :append-to-body="true">
  4. <!-- 搜索信息 -->
  5. <el-form ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="80px">
  6. <el-form-item label="部门名称" prop="deviceType">
  7. <el-input v-model="queryParams.departmentName" placeholder="请输入部门名称" clearable style="width: 230px" />
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button type="primary" icon="el-icon-search" size="mini" @click="searchEvent">查询</el-button>
  11. <el-button ref="btn" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  12. </el-form-item>
  13. </el-form>
  14. <CommonTable ref="deviceTypeTable" :tableHeaderTitle="tableHeaderTitle" :tableData="tableData"
  15. :isShowCheckbox="isShowCheckbox" :isShowIndex="isShowIndex" :tableHight="tableHight"
  16. :tableOperate="tableOperate" @chooseDeptEvent="chooseDeptEvent"></CommonTable>
  17. <!-- 分页信息 -->
  18. <pagination v-show="tableTotal > 0" :total="tableTotal" :page.sync="queryParams.page"
  19. :limit.sync="queryParams.limit" align="right" @pagination="getDeptList" />
  20. </el-dialog>
  21. </template>
  22. <script>
  23. import CommonTable from '@/components/CommonTable/index.vue'
  24. import { getDeptList } from '@/api/system/dept'
  25. export default {
  26. components: {
  27. CommonTable
  28. },
  29. created() {
  30. this.getDeptList()
  31. },
  32. data() {
  33. return {
  34. visible: false,
  35. title: '选择部门',
  36. //表格参数
  37. isShowCheckbox: false,
  38. isShowIndex: true,
  39. tableHight: '31vh',
  40. tableHeaderTitle: [
  41. {
  42. propName: "departmentName",
  43. labelName: "部门名称",
  44. },
  45. {
  46. propName: "departmentNum",
  47. labelName: "排序号",
  48. },
  49. // {
  50. // propName: "deviceTypeRemark",
  51. // labelName: "备注",
  52. // },
  53. {
  54. propName: "createTime",
  55. labelName: "创建时间",
  56. }
  57. ],
  58. tableData: [],
  59. tableOperate: [
  60. {
  61. btnName: '选择',
  62. size: "mini",
  63. style: '',
  64. icon: 'el-icon-search',
  65. methodName: "chooseDeptEvent",
  66. }
  67. ],
  68. queryParams: {
  69. page: 1,
  70. limit: 10,
  71. departmentName: null
  72. },
  73. tableTotal: 0
  74. }
  75. },
  76. methods: {
  77. /** 关闭弹出层 */
  78. dialogClose() {
  79. this.$refs['queryForm'].resetFields()
  80. this.visible = false
  81. },
  82. /** 搜索 */
  83. searchEvent() {
  84. this.queryParams.page = 1
  85. this.queryParams.limit = 10
  86. this.getDeptList()
  87. },
  88. /** 重置按钮操作 */
  89. resetQuery(event) {
  90. this.$refs['queryForm'].resetFields()
  91. },
  92. /** 分页查询部门信息 */
  93. getDeptList() {
  94. getDeptList(this.queryParams).then(res => {
  95. if (!res || !res.data) {
  96. this.$message({
  97. message: '数据查询失败!',
  98. type: 'warning'
  99. })
  100. return
  101. }
  102. this.tableTotal = res.data.count
  103. this.tableData = res.data.departmentList
  104. })
  105. },
  106. /** 将选择部门传递给父组件 */
  107. chooseDeptEvent(row) {
  108. this.$emit('receiveChooseDept', row)
  109. this.visible = false
  110. }
  111. }
  112. }
  113. </script>
  114. <style rel="stylesheet/scss" lang="scss">
  115. .dialog-med3 {
  116. height: 70vh;
  117. .el-dialog__body {
  118. height: 64vh;
  119. overflow: auto;
  120. }
  121. }
  122. </style>