From f3ba9aa2a8837b5ec81576cb97019ef28e768421 Mon Sep 17 00:00:00 2001 From: zhaoyiran Date: Fri, 19 Apr 2024 10:32:05 +0800 Subject: [PATCH] =?UTF-8?q?aql=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/qms/aql/index.ts | 8 +++++ src/config/axios/index.ts | 8 +++++ src/utils/disposition/defaultButtons.ts | 23 ++++++++++++- src/views/qms/aql/aql.data.ts | 18 +++++++++++ src/views/qms/aql/index.vue | 43 ++++++++++++++++++++----- 5 files changed, 91 insertions(+), 9 deletions(-) diff --git a/src/api/qms/aql/index.ts b/src/api/qms/aql/index.ts index dda72b699..2a3317051 100644 --- a/src/api/qms/aql/index.ts +++ b/src/api/qms/aql/index.ts @@ -105,3 +105,11 @@ export const importTemplate = () => { export const getSamplingScheme = async () => { return await request.get({ url: `/qms/sampling-scheme/get-available-list`}) } +// 启用 +export const enableAql = async (id: number) => { + return await request.enable({ url: `/qms/aql/enable?id=` + id }) +} +// 禁用 +export const disableAql = async (id: number) => { + return await request.disable({ url: `/qms/aql/disable?id=` + id }) +} diff --git a/src/config/axios/index.ts b/src/config/axios/index.ts index 69c5e72ac..ad0fd2f8c 100644 --- a/src/config/axios/index.ts +++ b/src/config/axios/index.ts @@ -39,6 +39,14 @@ export default { const res = await request({ method: 'DELETE', ...option }) return res.data as unknown as T }, + enable: async (option: any) => { + const res = await request({ method: 'POST', ...option }) + return res.data as unknown as T + }, + disable: async (option: any) => { + const res = await request({ method: 'POST', ...option }) + return res.data as unknown as T + }, put: async (option: any) => { const res = await request({ method: 'PUT', ...option }) return res.data as unknown as T diff --git a/src/utils/disposition/defaultButtons.ts b/src/utils/disposition/defaultButtons.ts index e8d89e7d8..0893325bb 100644 --- a/src/utils/disposition/defaultButtons.ts +++ b/src/utils/disposition/defaultButtons.ts @@ -250,7 +250,28 @@ export function mainListDeleteBtn(option:any) { hasPermi: '' }) } - +export function mainListEnableBtn(option:any) { + return __defaultBtnOption(option,{ + label: '启用', + name: 'enable', + hide: false, + type: 'danger', + color: '', + link: true, // 文本展现按钮 + hasPermi: '' + }) +} +export function mainListDisableBtn(option:any) { + return __defaultBtnOption(option,{ + label: '禁用', + name: 'disable', + hide: false, + type: 'danger', + color: '', + link: true, // 文本展现按钮 + hasPermi: '' + }) +} // 主列表-中止按钮1 export function mainListSuspend1Btn(option:any) { return __defaultBtnOption(option,{ diff --git a/src/views/qms/aql/aql.data.ts b/src/views/qms/aql/aql.data.ts index d16783a9f..1351f93d1 100644 --- a/src/views/qms/aql/aql.data.ts +++ b/src/views/qms/aql/aql.data.ts @@ -550,6 +550,24 @@ export const Aql = useCrudSchemas(reactive([ } }, }, + { + label: '是否可用', + field: 'available', + sort: 'custom', + dictType: DICT_TYPE.TRUE_FALSE, + dictClass: 'string', // 默认都是字符串类型其他暂不考虑 + form: { + component: 'Switch', + value: 'TRUE', + componentProps: { + inactiveValue: 'FALSE', + activeValue: 'TRUE' + } + }, + table: { + width: 110 + } + }, { label: '操作', field: 'action', diff --git a/src/views/qms/aql/index.vue b/src/views/qms/aql/index.vue index 378d5b12c..3ac3045a6 100644 --- a/src/views/qms/aql/index.vue +++ b/src/views/qms/aql/index.vue @@ -33,7 +33,7 @@ @@ -132,18 +132,29 @@ const buttonBaseClick = (val, item) => { } } -// 列表-操作按钮 -const butttondata = [ - defaultButtons.mainListEditBtn({hasPermi:'qms:aql:update'}), // 编辑 - defaultButtons.mainListDeleteBtn({hasPermi:'qms:aql:delete'}), // 删除 -] +const isShowMainButton = (row,val) => { + if (val.indexOf(row.available) > -1) { + return false + } else { + return true + } +} +const butttondata = (row) => { + return [ + defaultButtons.mainListEditBtn({hasPermi: 'qms:aql:update'}), + defaultButtons.mainListEnableBtn({hide:isShowMainButton(row,['FALSE']),hasPermi:'qms:aql:enable'}), + defaultButtons.mainListDisableBtn({hide:isShowMainButton(row,['TRUE']),hasPermi:'qms:aql:disable'}), + ] +} // 列表-操作按钮事件 const buttonTableClick = async (val, row) => { if (val == 'edit') { // 编辑 openForm('update', row) - } else if (val == 'delete') { // 删除 - handleDelete(row.id) + } else if (val == 'enable') { + handleEnable(row.id) + }else if (val == 'disable') { + handleDisable(row.id) } } @@ -195,6 +206,22 @@ const handleDelete = async (id: number) => { await getList() } catch {} } +const handleEnable = async (id: number) => { + try { + await AqlApi.enableAql(id) + message.success(t('common.delSuccess')) + // 刷新列表 + await getList() + } catch {} +} +const handleDisable = async (id: number) => { + try { + await AqlApi.disableAql(id) + message.success(t('common.delSuccess')) + // 刷新列表 + await getList() + } catch {} +} /** 导出按钮操作 */ const exportLoading = ref(false) // 导出的加载中