Browse Source

aql启用禁用

master_hella_20240701
zhaoyiran 8 months ago
parent
commit
f3ba9aa2a8
  1. 8
      src/api/qms/aql/index.ts
  2. 8
      src/config/axios/index.ts
  3. 23
      src/utils/disposition/defaultButtons.ts
  4. 18
      src/views/qms/aql/aql.data.ts
  5. 43
      src/views/qms/aql/index.vue

8
src/api/qms/aql/index.ts

@ -105,3 +105,11 @@ export const importTemplate = () => {
export const getSamplingScheme = async () => { export const getSamplingScheme = async () => {
return await request.get({ url: `/qms/sampling-scheme/get-available-list`}) 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 })
}

8
src/config/axios/index.ts

@ -39,6 +39,14 @@ export default {
const res = await request({ method: 'DELETE', ...option }) const res = await request({ method: 'DELETE', ...option })
return res.data as unknown as T return res.data as unknown as T
}, },
enable: async <T = any>(option: any) => {
const res = await request({ method: 'POST', ...option })
return res.data as unknown as T
},
disable: async <T = any>(option: any) => {
const res = await request({ method: 'POST', ...option })
return res.data as unknown as T
},
put: async <T = any>(option: any) => { put: async <T = any>(option: any) => {
const res = await request({ method: 'PUT', ...option }) const res = await request({ method: 'PUT', ...option })
return res.data as unknown as T return res.data as unknown as T

23
src/utils/disposition/defaultButtons.ts

@ -250,7 +250,28 @@ export function mainListDeleteBtn(option:any) {
hasPermi: '' 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 // 主列表-中止按钮1
export function mainListSuspend1Btn(option:any) { export function mainListSuspend1Btn(option:any) {
return __defaultBtnOption(option,{ return __defaultBtnOption(option,{

18
src/views/qms/aql/aql.data.ts

@ -550,6 +550,24 @@ export const Aql = useCrudSchemas(reactive<CrudSchema[]>([
} }
}, },
}, },
{
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: '操作', label: '操作',
field: 'action', field: 'action',

43
src/views/qms/aql/index.vue

@ -33,7 +33,7 @@
</el-button> </el-button>
</template> </template>
<template #action="{ row }"> <template #action="{ row }">
<ButtonBase :Butttondata="butttondata" @button-base-click="buttonTableClick($event,row)" /> <ButtonBase :Butttondata="butttondata(row)" @button-base-click="buttonTableClick($event,row)" />
</template> </template>
</Table> </Table>
</ContentWrap> </ContentWrap>
@ -132,18 +132,29 @@ const buttonBaseClick = (val, item) => {
} }
} }
// - const isShowMainButton = (row,val) => {
const butttondata = [ if (val.indexOf(row.available) > -1) {
defaultButtons.mainListEditBtn({hasPermi:'qms:aql:update'}), // return false
defaultButtons.mainListDeleteBtn({hasPermi:'qms:aql:delete'}), // } 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) => { const buttonTableClick = async (val, row) => {
if (val == 'edit') { // if (val == 'edit') { //
openForm('update', row) openForm('update', row)
} else if (val == 'delete') { // } else if (val == 'enable') {
handleDelete(row.id) handleEnable(row.id)
}else if (val == 'disable') {
handleDisable(row.id)
} }
} }
@ -195,6 +206,22 @@ const handleDelete = async (id: number) => {
await getList() await getList()
} catch {} } 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) // const exportLoading = ref(false) //

Loading…
Cancel
Save