index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <el-card style="margin: 15px">
  3. <!-- 操作按钮区域 -->
  4. <div class="table-operator" style="margin: 5px 0;float: right">
  5. <a-button v-permission="['pc:system:dept:add']" type="primary" icon="plus" @click="handleAdd">新增</a-button>
  6. <a-dropdown v-if="selectedRowKeys.length > 0">
  7. <a-menu slot="overlay">
  8. <a-menu-item key="1" v-permission="['pc:system:dept:remove']" @click="batchDel">
  9. <a-icon type="delete" />
  10. 删除
  11. </a-menu-item>
  12. </a-menu>
  13. <a-button style="margin-left: 8px">
  14. 批量操作
  15. <a-icon type="down" />
  16. </a-button>
  17. </a-dropdown>
  18. </div>
  19. <!-- 查询区域 -->
  20. <div class="table-page-search-wrapper">
  21. <a-form layout="inline" @keyup.enter.native="searchQuery">
  22. <a-form-item>
  23. <a-input
  24. v-model="queryParam.deptName"
  25. style="width: 150px"
  26. placeholder="部门名称"
  27. />
  28. </a-form-item>
  29. <a-form-item>
  30. <a-button type="primary" @click="searchQuery">查询</a-button>
  31. <a-button style="margin-left: 8px" @click="searchReset">重置</a-button>
  32. </a-form-item>
  33. </a-form>
  34. </div>
  35. <!-- table区域-begin -->
  36. <div>
  37. <div class="ant-alert ant-alert-info" style="margin: 16px 0;">
  38. <i class="anticon anticon-info-circle ant-alert-icon" /> 已选择&nbsp;<a style="font-weight: 600">{{
  39. selectedRowKeys.length }}</a>项&nbsp;&nbsp;
  40. <a style="margin-left: 24px" @click="onClearSelected">清空</a>
  41. </div>
  42. <a-table
  43. ref="table"
  44. size="middle"
  45. bordered
  46. row-key="deptId"
  47. :columns="columns"
  48. :default-expanded-row-keys="[100]"
  49. :data-source="dataSource"
  50. :pagination="false"
  51. :loading="loading"
  52. :row-selection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
  53. @change="handleTableChange"
  54. >
  55. <template slot="status" slot-scope="text, record">
  56. <a-switch
  57. :checked="record.status==='1'?false:true"
  58. checked-children="启用"
  59. un-checked-children="停用"
  60. @change="changeStatus({$event,record})"
  61. />
  62. </template>
  63. <span slot="action" slot-scope="text, record">
  64. <a-button v-permission="['pc:system:dept:edit']" size="small" type="primary" @click="handleEdit(record)">
  65. 编辑
  66. </a-button>
  67. <a-divider type="vertical" />
  68. <a-popconfirm
  69. v-permission="['pc:system:dept:remove']"
  70. title="确定删除吗?"
  71. @confirm="() => handleDelete(record.deptId)"
  72. >
  73. <a-button size="small" type="danger">
  74. 删除
  75. </a-button>
  76. </a-popconfirm>
  77. </span>
  78. </a-table>
  79. <check-and-edit-model ref="modalForm" @ok="modalFormOk" />
  80. </div>
  81. <!-- table区域-end -->
  82. <!-- 表单区域 -->
  83. </el-card>
  84. </template>
  85. <script>
  86. import { listMixin } from '@/mixin/listMixin'
  87. import columns from './indexColumns'
  88. import CheckAndEditModel from './CheckAndEditModel'
  89. import { httpAction } from '@/api/request'
  90. export default {
  91. components: {
  92. CheckAndEditModel
  93. },
  94. mixins: [listMixin],
  95. data() {
  96. return {
  97. // 查询条件
  98. queryParam: {},
  99. // 表头
  100. columns: columns(this),
  101. url: {
  102. list: '/system/dept/tree',
  103. delete: '/system/dept/',
  104. exportXlsUrl: '/exportXlsUrl',
  105. importExcelUrl: `${process.env.VUE_APP_BASE_API}/importExcelUrl`
  106. }
  107. }
  108. },
  109. created() {
  110. },
  111. methods: {
  112. changeStatus({ $event, record }) {
  113. console.log($event, record)
  114. record.status = $event ? '0' : '1'
  115. httpAction('/system/dept', record, 'put').then((res) => {
  116. if (res.code === 200) {
  117. this.$message.success(res.msg)
  118. } else {
  119. console.log(res)
  120. }
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style scoped>
  127. @import '~@/assets/less/common.less'
  128. </style>