feat: enhance inspection type management table actions
Some checks failed
Release pipeline / publish (push) Has been cancelled
Release pipeline / Always run job (push) Has been cancelled

This commit is contained in:
sheng
2026-06-24 12:45:49 +08:00
parent 838db60965
commit 5ab5ad2bed
4 changed files with 65 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ export function useTableButtons (options = {}, permissionCheck) {
size: btn.size || 'mini', size: btn.size || 'mini',
auth: btn.auth, auth: btn.auth,
cssStyle: btn.cssStyle || {}, cssStyle: btn.cssStyle || {},
needSelection: !!btn.needSelection,
onClick: btn.onClick, onClick: btn.onClick,
hasPermission: btn.auth ? check(btn.auth) : true hasPermission: btn.auth ? check(btn.auth) : true
})) }))

View File

@@ -3283,6 +3283,8 @@
"tip": "Tip", "tip": "Tip",
"confirm_delete": "Are you sure to delete?", "confirm_delete": "Are you sure to delete?",
"required": "Required", "required": "Required",
"select_operate_data": "Please select data to operate",
"length_min_2": "At least 2 characters",
"please_enter": "Please enter", "please_enter": "Please enter",
"create_time": "Created At", "create_time": "Created At",
"created_at": "Created At", "created_at": "Created At",

View File

@@ -3283,6 +3283,8 @@
"tip": "提示", "tip": "提示",
"confirm_delete": "确定要执行该操作吗?", "confirm_delete": "确定要执行该操作吗?",
"required": "必填项", "required": "必填项",
"select_operate_data": "请选择要操作的数据",
"length_min_2": "长度最少 2 个字符",
"please_enter": "请输入", "please_enter": "请输入",
"create_time": "创建时间", "create_time": "创建时间",
"created_at": "创建时间", "created_at": "创建时间",

View File

@@ -41,6 +41,8 @@
:toolbar-buttons="toolbarButtons" :toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons" :row-buttons="rowButtons"
:pagination="pagination" :pagination="pagination"
:table-attrs="{ highlightCurrentRow: true }"
:table-listeners="{ 'sort-change': handleSort }"
help-url="/help/quality-management/inspection-type-management" help-url="/help/quality-management/inspection-type-management"
:help-text="$t(ckey('help'))" :help-text="$t(ckey('help'))"
auto-height auto-height
@@ -103,15 +105,21 @@ export default {
dialogTitle: '', dialogTitle: '',
editId: '', editId: '',
handleType: 'create', handleType: 'create',
search: {"code":"","name":""}, search: { code: '', name: '' },
pagination: { current: 1, size: 10, total: 0 }, pagination: { current: 1, size: 10, total: 0 },
formData: {"code":"","name":"","note":""}, order: {
order_type: undefined,
order_field: undefined
},
formData: { code: '', name: '', note: '' },
rules: { rules: {
code: [ code: [
{ required: true, message: this.key('required'), trigger: 'blur' } { required: true, message: this.key('required'), trigger: 'blur' },
{ min: 2, message: this.key('length_min_2'), trigger: 'blur' }
], ],
name: [ name: [
{ required: true, message: this.key('required'), trigger: 'blur' } { required: true, message: this.key('required'), trigger: 'blur' },
{ min: 2, message: this.key('length_min_2'), trigger: 'blur' }
] ]
}, },
columns: [], columns: [],
@@ -153,11 +161,11 @@ export default {
}, },
created () { created () {
this.columns = useTableColumns([ this.columns = useTableColumns([
{ prop: 'code', label: this.key('code'), minWidth: 130 }, { prop: 'code', label: this.key('code'), minWidth: 130, sortable: 'custom', showOverflowTooltip: true },
{ prop: 'name', label: this.key('name'), minWidth: 130 }, { prop: 'name', label: this.key('name'), minWidth: 130, sortable: 'custom', showOverflowTooltip: true },
{ prop: 'note', label: this.key('remark'), minWidth: 130 }, { prop: 'nickname', label: this.key('nickname'), minWidth: 130, sortable: 'custom', showOverflowTooltip: true },
{ prop: 'nickname', label: this.key('nickname'), minWidth: 130 }, { prop: 'create_date', label: this.key('create_date'), minWidth: 150, sortable: 'custom', showOverflowTooltip: true },
{ prop: 'create_date', label: this.key('create_date'), minWidth: 130 }, { prop: 'note', label: this.key('remark'), minWidth: 130, sortable: 'custom', showOverflowTooltip: true },
{ prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' } { prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' }
]) ])
const btns = useTableButtons({ const btns = useTableButtons({
@@ -167,8 +175,17 @@ export default {
label: this.key('add'), label: this.key('add'),
icon: 'el-icon-plus', icon: 'el-icon-plus',
type: 'primary', type: 'primary',
auth: '/quality_control/first_inspection/category/create', auth: '/quality_control/first_inspection/category/add',
onClick: this.openAdd onClick: this.openAdd
},
{
key: 'batch_delete',
label: this.key('delete'),
icon: 'el-icon-delete',
type: 'danger',
auth: '/quality_control/first_inspection/category/delete',
needSelection: true,
onClick: this.handleBatchDelete
} }
], ],
row: [ row: [
@@ -176,7 +193,7 @@ export default {
key: 'edit', key: 'edit',
label: this.key('edit'), label: this.key('edit'),
icon: 'el-icon-edit', icon: 'el-icon-edit',
auth: '/quality_control/first_inspection/category/edit', auth: '/quality_control/first_inspection/category/update',
onClick: this.openEdit onClick: this.openEdit
}, },
{ {
@@ -199,6 +216,7 @@ export default {
try { try {
const params = { const params = {
...this.search, ...this.search,
...this.order,
page_no: this.pagination.current, page_no: this.pagination.current,
page_size: this.pagination.size, page_size: this.pagination.size,
page: this.pagination.current, page: this.pagination.current,
@@ -217,7 +235,7 @@ export default {
this.fetchData() this.fetchData()
}, },
onReset () { onReset () {
this.search = {"code":"","name":""} this.search = { code: '', name: '' }
this.pagination.current = 1 this.pagination.current = 1
this.fetchData() this.fetchData()
}, },
@@ -229,8 +247,15 @@ export default {
onSelect (rows) { onSelect (rows) {
this.selectedRows = rows this.selectedRows = rows
}, },
handleSort ({ column, prop, order }) {
this.order = {
order_type: column && order ? (order === 'ascending' ? 'asc' : 'desc') : undefined,
order_field: column && order ? prop : undefined
}
this.fetchData()
},
resetForm () { resetForm () {
this.formData = {"code":"","name":"","note":""} this.formData = { code: '', name: '', note: '' }
this.editId = '' this.editId = ''
}, },
openAdd () { openAdd () {
@@ -243,7 +268,7 @@ export default {
this.handleType = 'edit' this.handleType = 'edit'
this.dialogTitle = this.key('edit_title') this.dialogTitle = this.key('edit_title')
this.editId = row.id this.editId = row.id
this.formData = { ...{"code":"","name":"","note":""}, ...row } this.formData = { ...{ code: '', name: '', note: '' }, ...row }
this.dialogVisible = true this.dialogVisible = true
}, },
async onDialogSubmit () { async onDialogSubmit () {
@@ -267,8 +292,27 @@ export default {
async handleDelete (row) { async handleDelete (row) {
const cancelled = await this.$confirmAction({ const cancelled = await this.$confirmAction({
message: this.key('confirm_delete'), message: this.key('confirm_delete'),
title: this.key('tip') title: this.key('tip'),
}, () => deleteInspectionTypeManagement({ id: [row.id], ids: [row.id], inspection_order_no: row.inspection_order_no })) confirmButtonText: this.key('confirm'),
cancelButtonText: this.key('cancel'),
closeOnClickModal: false
}, () => deleteInspectionTypeManagement({ id: [row.id] }))
if (cancelled) return
this.$message.success(this.$t(this.key('operation_success')))
this.fetchData()
},
async handleBatchDelete () {
if (!this.selectedRows.length) {
this.$message.error(this.$t(this.key('select_operate_data')))
return
}
const cancelled = await this.$confirmAction({
message: this.key('confirm_delete'),
title: this.key('tip'),
confirmButtonText: this.key('confirm'),
cancelButtonText: this.key('cancel'),
closeOnClickModal: false
}, () => deleteInspectionTypeManagement({ id: this.selectedRows.map(item => item.id) }))
if (cancelled) return if (cancelled) return
this.$message.success(this.$t(this.key('operation_success'))) this.$message.success(this.$t(this.key('operation_success')))
this.fetchData() this.fetchData()