index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <el-card class="content-z">
  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. v-if="JSPermission(['pc:system:dept:edit'])"
  58. :checked="record.status==='1'?false:true"
  59. checked-children="启用"
  60. un-checked-children="停用"
  61. @change="changeStatus({$event,record})"
  62. />
  63. <span v-else>{{ record.status==='1'?'停用':'启用' }}</span>
  64. </template>
  65. <span slot="action" slot-scope="text, record">
  66. <a-button v-permission="['pc:system:dept:edit']" size="small" type="primary" @click="handleEdit(record)">
  67. 编辑
  68. </a-button>
  69. <a-divider type="vertical" />
  70. <a-popconfirm
  71. v-permission="['pc:system:dept:remove']"
  72. title="确定删除吗?"
  73. @confirm="() => handleDelete(record.deptId)"
  74. >
  75. <a-button size="small" type="danger">
  76. 删除
  77. </a-button>
  78. </a-popconfirm>
  79. </span>
  80. </a-table>
  81. <check-and-edit-model ref="modalForm" @ok="modalFormOk" />
  82. </div>
  83. <!-- table区域-end -->
  84. <!-- 表单区域 -->
  85. </el-card>
  86. </template>
  87. <script>
  88. import { listMixin } from '@/mixin/listMixin'
  89. import columns from './indexColumns'
  90. import CheckAndEditModel from './CheckAndEditModel'
  91. import { httpAction } from '@/api/request'
  92. import JSPermission from '@/utils/JSPermission'
  93. export default {
  94. components: {
  95. CheckAndEditModel
  96. },
  97. mixins: [listMixin],
  98. data() {
  99. return {
  100. // 查询条件
  101. queryParam: {},
  102. // 表头
  103. columns: columns(this),
  104. url: {
  105. list: '/system/dept/tree',
  106. delete: '/system/dept/',
  107. exportXlsUrl: '/exportXlsUrl',
  108. importExcelUrl: `${process.env.VUE_APP_BASE_API}/importExcelUrl`
  109. }
  110. }
  111. },
  112. created() {
  113. },
  114. methods: {
  115. JSPermission,
  116. changeStatus({ $event, record }) {
  117. console.log($event, record)
  118. record.status = $event ? '0' : '1'
  119. httpAction('/system/dept', record, 'put').then((res) => {
  120. if (res.code === 200) {
  121. this.$message.success(res.msg)
  122. } else {
  123. console.log(res)
  124. }
  125. })
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped>
  131. @import '~@/assets/less/common.less'
  132. </style>