OpenApiAuthList.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <div class="p-2">
  3. <!--查询区域-->
  4. <div class="jeecg-basic-table-form-container">
  5. <a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
  6. <a-row :gutter="24">
  7. <a-col :lg="6">
  8. <a-form-item name="name">
  9. <template #label><span title="授权名称">授权名称</span></template>
  10. <a-input placeholder="请输入授权名称" v-model:value="queryParam.name" allow-clear></a-input>
  11. </a-form-item>
  12. </a-col>
  13. <a-col :lg="6">
  14. <a-form-item name="createBy">
  15. <template #label><span title="关联系统用户名">关联系统用户名</span></template>
  16. <JSearchSelect
  17. dict="sys_user,username,username"
  18. v-model:value="queryParam.createBy"
  19. placeholder="请输入关联系统用户名"
  20. allow-clear
  21. ></JSearchSelect>
  22. <!-- <a-input placeholder="请输入关联系统用户名" v-model:value="queryParam.systemUserId" allow-clear ></a-input>-->
  23. </a-form-item>
  24. </a-col>
  25. <a-col :xl="6" :lg="7" :md="8" :sm="24">
  26. <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
  27. <a-col :lg="6">
  28. <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
  29. <a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
  30. <a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
  31. {{ toggleSearchStatus ? '收起' : '展开' }}
  32. <Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
  33. </a>
  34. </a-col>
  35. </span>
  36. </a-col>
  37. </a-row>
  38. </a-form>
  39. </div>
  40. <!--引用表格-->
  41. <BasicTable @register="registerTable" :rowSelection="rowSelection">
  42. <!--插槽:table标题-->
  43. <template #tableTitle>
  44. <a-button type="primary" v-auth="'openapi:open_api_auth:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
  45. <a-button type="primary" v-auth="'openapi:open_api_auth:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
  46. <j-upload-button type="primary" v-auth="'openapi:open_api_auth:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls"
  47. >导入</j-upload-button
  48. >
  49. <a-dropdown v-if="selectedRowKeys.length > 0">
  50. <template #overlay>
  51. <a-menu>
  52. <a-menu-item key="1" @click="batchHandleDelete">
  53. <Icon icon="ant-design:delete-outlined"></Icon>
  54. 删除
  55. </a-menu-item>
  56. </a-menu>
  57. </template>
  58. <a-button v-auth="'openapi:open_api_auth:deleteBatch'"
  59. >批量操作
  60. <Icon icon="mdi:chevron-down"></Icon>
  61. </a-button>
  62. </a-dropdown>
  63. <!-- 高级查询 -->
  64. <super-query :config="superQueryConfig" @search="handleSuperQuery" />
  65. </template>
  66. <!--操作栏-->
  67. <template #action="{ record }">
  68. <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
  69. </template>
  70. <template v-slot:bodyCell="{ column, record, index, text }"> </template>
  71. </BasicTable>
  72. <!-- 表单区域 -->
  73. <OpenApiAuthModal ref="registerModal" @success="handleSuccess"></OpenApiAuthModal>
  74. <AuthModal ref="authModal" @success="handleSuccess"></AuthModal>
  75. </div>
  76. </template>
  77. <script lang="ts" name="openapi-openApiAuth" setup>
  78. import { ref, reactive } from 'vue';
  79. import { BasicTable, TableAction } from '/@/components/Table';
  80. import { useListPage } from '/@/hooks/system/useListPage';
  81. import { columns, superQuerySchema } from './OpenApiAuth.data';
  82. import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, getGenAKSK, saveOrUpdate } from './OpenApiAuth.api';
  83. import OpenApiAuthModal from './components/OpenApiAuthModal.vue';
  84. import AuthModal from './components/AuthModal.vue';
  85. import { useUserStore } from '/@/store/modules/user';
  86. import JSearchSelect from '../../components/Form/src/jeecg/components/JSearchSelect.vue';
  87. const formRef = ref();
  88. const queryParam = reactive<any>({});
  89. const toggleSearchStatus = ref<boolean>(false);
  90. const registerModal = ref();
  91. const authModal = ref();
  92. const userStore = useUserStore();
  93. //注册table数据
  94. const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
  95. tableProps: {
  96. title: '授权管理',
  97. api: list,
  98. columns,
  99. canResize: false,
  100. useSearchForm: false,
  101. actionColumn: {
  102. width: 200,
  103. fixed: 'right',
  104. },
  105. beforeFetch: async (params) => {
  106. return Object.assign(params, queryParam);
  107. },
  108. },
  109. exportConfig: {
  110. name: '授权管理',
  111. url: getExportUrl,
  112. params: queryParam,
  113. },
  114. importConfig: {
  115. url: getImportUrl,
  116. success: handleSuccess,
  117. },
  118. });
  119. const [registerTable, { reload, updateTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
  120. const labelCol = reactive({
  121. xs: 24,
  122. sm: 10,
  123. xl: 6,
  124. xxl: 10,
  125. });
  126. const wrapperCol = reactive({
  127. xs: 24,
  128. sm: 20,
  129. });
  130. // 高级查询配置
  131. const superQueryConfig = reactive(superQuerySchema);
  132. /**
  133. * 高级查询事件
  134. */
  135. function handleSuperQuery(params) {
  136. Object.keys(params).map((k) => {
  137. queryParam[k] = params[k];
  138. });
  139. searchQuery();
  140. }
  141. /**
  142. * 新增事件
  143. */
  144. function handleAdd() {
  145. registerModal.value.disableSubmit = false;
  146. registerModal.value.add();
  147. }
  148. /**
  149. * 编辑事件
  150. */
  151. function handleAuth(record: Recordable) {
  152. authModal.value.disableSubmit = false;
  153. authModal.value.edit(record);
  154. }
  155. /**
  156. * 编辑事件
  157. */
  158. function handleEdit(record: Recordable) {
  159. registerModal.value.disableSubmit = false;
  160. registerModal.value.authDrawerOpen = true;
  161. registerModal.value.edit(record);
  162. }
  163. /**
  164. * 重置事件
  165. * @param record
  166. */
  167. async function handleReset(record: Recordable) {
  168. const AKSKObj = await getGenAKSK({});
  169. record.ak = AKSKObj[0];
  170. record.sk = AKSKObj[1];
  171. saveOrUpdate(record, true);
  172. // handleSuccess;
  173. }
  174. /**
  175. * 详情
  176. */
  177. function handleDetail(record: Recordable) {
  178. registerModal.value.disableSubmit = true;
  179. registerModal.value.edit(record);
  180. }
  181. /**
  182. * 删除事件
  183. */
  184. async function handleDelete(record) {
  185. await deleteOne({ id: record.id }, handleSuccess);
  186. }
  187. /**
  188. * 批量删除事件
  189. */
  190. async function batchHandleDelete() {
  191. await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
  192. }
  193. /**
  194. * 成功回调
  195. */
  196. function handleSuccess() {
  197. (selectedRowKeys.value = []) && reload();
  198. }
  199. /**
  200. * 操作栏
  201. */
  202. function getTableAction(record) {
  203. return [
  204. {
  205. label: '授权',
  206. onClick: handleAuth.bind(null, record),
  207. auth: 'openapi:open_api_auth:edit',
  208. },
  209. {
  210. label: '重置',
  211. popConfirm: {
  212. title: '是否重置AK,SK',
  213. confirm: handleReset.bind(null, record),
  214. placement: 'topLeft',
  215. },
  216. auth: 'openapi:open_api_auth:edit',
  217. },
  218. ];
  219. }
  220. /**
  221. * 下拉操作栏
  222. */
  223. function getDropDownAction(record) {
  224. return [
  225. {
  226. label: '详情',
  227. onClick: handleDetail.bind(null, record),
  228. },
  229. {
  230. label: '删除',
  231. popConfirm: {
  232. title: '是否确认删除',
  233. confirm: handleDelete.bind(null, record),
  234. placement: 'topLeft',
  235. },
  236. auth: 'openapi:open_api_auth:delete',
  237. },
  238. ];
  239. }
  240. /**
  241. * 查询
  242. */
  243. function searchQuery() {
  244. reload();
  245. }
  246. /**
  247. * 重置
  248. */
  249. function searchReset() {
  250. formRef.value.resetFields();
  251. selectedRowKeys.value = [];
  252. //刷新数据
  253. reload();
  254. }
  255. </script>
  256. <style lang="less" scoped>
  257. .jeecg-basic-table-form-container {
  258. padding: 0;
  259. .table-page-search-submitButtons {
  260. display: block;
  261. margin-bottom: 24px;
  262. white-space: nowrap;
  263. }
  264. .query-group-cust {
  265. min-width: 100px !important;
  266. }
  267. .query-group-split-cust {
  268. width: 30px;
  269. display: inline-block;
  270. text-align: center;
  271. }
  272. .ant-form-item:not(.ant-form-item-with-help) {
  273. margin-bottom: 16px;
  274. height: 32px;
  275. }
  276. :deep(.ant-picker),
  277. :deep(.ant-input-number) {
  278. width: 100%;
  279. }
  280. }
  281. </style>