diff --git a/api/admin/role.ts b/api/admin/role.ts index 7db3a02..23fdc08 100644 --- a/api/admin/role.ts +++ b/api/admin/role.ts @@ -9,6 +9,13 @@ export default { params: {} }) }, + getDataDetail(id: number) { + return Request({ + url: `yt/role/${id}`, + method: 'get', + params: {} + }) + }, updateData(params: any) { return Request({ url: 'yt/role', diff --git a/api/common.ts b/api/common.ts index a0dde03..23c97ca 100644 --- a/api/common.ts +++ b/api/common.ts @@ -52,7 +52,7 @@ export const uploadApi = { method: 'post', data: params, params: { - expire: 24 * 30 * 12 * 10, + expire: 86400 * 24 * 30 * 12 * 10, }, headers: { "Content-Type": "multipart/form-data", diff --git a/components/JsonFormDialog.vue b/components/JsonFormDialog.vue index c098202..e7b2c67 100644 --- a/components/JsonFormDialog.vue +++ b/components/JsonFormDialog.vue @@ -477,12 +477,12 @@ const NodeEditor: Component = defineComponent({ const zhItem = Array.isArray(zhArr) ? zhArr[i] : undefined return h(NodeEditor, { parent: item, fieldKey: k, fieldMap: fm, depth: depth + 1, key: k, lang: p.lang, zhParent: zhItem }) }), - // h('div', { class: 'jfd-item-actions' }, - // h(ElButton, { - // size: 'small', type: 'danger', - // onClick: () => value.splice(i, 1), - // }, () => [h(ElIcon, { size: 14 }, () => h(Delete)), ' 删除此项']) - // ) + h('div', { class: 'jfd-item-actions' }, + h(ElButton, { + size: 'small', type: 'danger', + onClick: () => value.splice(i, 1), + }, () => [h(ElIcon, { size: 14 }, () => h(Delete)), ' 删除此项']) + ) ]) }) ) diff --git a/views/admin/list.tsx b/views/admin/list.tsx index bf89b03..86be385 100644 --- a/views/admin/list.tsx +++ b/views/admin/list.tsx @@ -62,7 +62,7 @@ const data: TableData = { }, ], subFun(self, data) { - return self.api?.addData(data) + return self.api?.addData({...data, role: String(data.role)}) } } } @@ -98,7 +98,7 @@ const data: TableData = { openValue: 1, closeValue: 2, subFun(self, data) { - return self.api?.updateData({id: String(data.id), status: String(data.status)}) + return self.api?.updateData({id: String(data.id), status: String(data.status), role: String(data.role)}) }, } }, diff --git a/views/admin/role.tsx b/views/admin/role.tsx index 856291c..1d5b27d 100644 --- a/views/admin/role.tsx +++ b/views/admin/role.tsx @@ -11,9 +11,9 @@ const data: TableData = { launchTask: [ async (self: any) => { if (self.bean) { - const res = await self.api?.getResources({type: "page"}) - const res2 = await self.api?.getResources({type: "api"}) - self.bean.resources = [...res.data.items, ...res2.data.items].map((item:any) => { + const res = await self.api?.getResources({ type: "page", page: 1, size: 1000 }) + const res2 = await self.api?.getResources({ type: "api", page: 1, size: 1000 }) + self.bean.resources = [...res.data.items, ...res2.data.items].map((item: any) => { const type = item.type === 'page' ? '页面' : '接口' return { key: item.id, @@ -60,7 +60,7 @@ const data: TableData = { subFun(self, data) { const params = { ...data, - resource: data.resource.map((i:number) => String(i)) + resource: data.resource.map((i: number) => String(i)) } return self.api?.addData(params) } @@ -98,6 +98,15 @@ const data: TableData = { title: '编辑', type: 'warning', primary: 'id', + beforeShow: async (self: any, form: any, row: any) => { + const res = await self.api?.getDataDetail(row.id) + const resources = res.data.map((item: any) => item.id) + const findItem = form.data.find((i: any) => i.key === 'resource') + findItem.values[form.show] = resources + console.log('row', row) + console.log('form', form) + console.log('resource', resources) + }, data: [ { key: 'name', @@ -120,7 +129,7 @@ const data: TableData = { const params = { ...data, id: String(data.id), - resource: data.resource.map((i:number) => String(i)) + resource: data.resource.map((i: number) => String(i)) } return self.api?.updateData(params) }