|
@@ -27,8 +27,7 @@
|
|
|
</template>
|
|
|
|
|
|
<template #statusSlot="scope">
|
|
|
- <status-indicator v-if="scope.row.status === 1" pulse type="success"></status-indicator>
|
|
|
- <status-indicator v-else pulse type="danger"></status-indicator>
|
|
|
+ <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" @change="() => handleStatusChange(scope.row)"></el-switch>
|
|
|
</template>
|
|
|
|
|
|
<template #actionSlot="scope">
|
|
@@ -55,11 +54,11 @@
|
|
|
</template>
|
|
|
<script lang="tsx" setup>
|
|
|
import app from '@/api/system/app'
|
|
|
+import configure from '@/api/system/configure'
|
|
|
import { computed, nextTick, ref, watch } from 'vue'
|
|
|
-import {ElMessage, ElMessageBox, ElTree} from 'element-plus'
|
|
|
+import { ElMessage, ElMessageBox, ElTree } from 'element-plus'
|
|
|
import { useTablePage } from '@/hooks/useTablePage'
|
|
|
import { Plus, Delete } from '@element-plus/icons-vue'
|
|
|
-import StatusIndicator from '@/components/StatusIndicator'
|
|
|
|
|
|
const visible = ref(false) // 弹窗显示隐藏
|
|
|
const isCreate = ref(true)
|
|
@@ -204,6 +203,7 @@ const columns = [
|
|
|
label: '操作',
|
|
|
width: 100,
|
|
|
fixed: 'right',
|
|
|
+ align: 'center',
|
|
|
slots: {
|
|
|
default: 'actionSlot'
|
|
|
}
|
|
@@ -286,6 +286,22 @@ const addHandler = () => {
|
|
|
visible.value = true
|
|
|
}
|
|
|
|
|
|
+const handleStatusChange = (row: any) => {
|
|
|
+ // 状态 0、禁用 1、正常
|
|
|
+ const status = row.status
|
|
|
+ let text = Number(row.status) === 0 ? '禁用' : '启用'
|
|
|
+ ElMessageBox.confirm('请确认是否' + text + '当前数据?', '提示', { type: 'warning' })
|
|
|
+ .then(async () => {
|
|
|
+ await configure.configureStatusApi({ id: row.id, status }) // 接口请求
|
|
|
+ ElMessage.success(`${text}成功`)
|
|
|
+ })
|
|
|
+ .catch(status => {
|
|
|
+ if (status == 'cancel') {
|
|
|
+ row.status = Number(row.status) === 0 ? 1 : 0
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
nextTick(() => {
|
|
|
queryList()
|
|
|
})
|