add
素材分发 增加用户备注 add_asset_user_remark.sql
This commit is contained in:
@@ -27,6 +27,20 @@
|
|||||||
<el-table :data="tableData" v-loading="loading">
|
<el-table :data="tableData" v-loading="loading">
|
||||||
<!-- <el-table-column prop="id" label="ID" width="80" /> -->
|
<!-- <el-table-column prop="id" label="ID" width="80" /> -->
|
||||||
<el-table-column prop="phone" label="手机号" />
|
<el-table-column prop="phone" label="手机号" />
|
||||||
|
<el-table-column label="备注" min-width="200">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<div class="flex items-center gap-1 min-w-0">
|
||||||
|
<span class="truncate text-gray-600" :title="row.remark || ''">
|
||||||
|
{{ row.remark || '—' }}
|
||||||
|
</span>
|
||||||
|
<el-tooltip content="编辑备注" placement="top">
|
||||||
|
<el-icon class="shrink-0 cursor-pointer text-gray-400 hover:text-primary" @click="openQuickRemark(row)">
|
||||||
|
<Edit />
|
||||||
|
</el-icon>
|
||||||
|
</el-tooltip>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column prop="create_time" label="创建时间" width="180" />
|
<el-table-column prop="create_time" label="创建时间" width="180" />
|
||||||
<el-table-column prop="status" label="状态" width="100">
|
<el-table-column prop="status" label="状态" width="100">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
@@ -70,6 +84,16 @@
|
|||||||
<el-form-item label="密码" prop="password">
|
<el-form-item label="密码" prop="password">
|
||||||
<el-input v-model="formData.password" placeholder="为空则默认为 123456" show-password />
|
<el-input v-model="formData.password" placeholder="为空则默认为 123456" show-password />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.remark"
|
||||||
|
type="textarea"
|
||||||
|
:rows="3"
|
||||||
|
maxlength="500"
|
||||||
|
show-word-limit
|
||||||
|
placeholder="可填写用户相关信息,仅管理员可见"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="状态" prop="status">
|
<el-form-item label="状态" prop="status">
|
||||||
<el-switch v-model="formData.status" :active-value="1" :inactive-value="0" />
|
<el-switch v-model="formData.status" :active-value="1" :inactive-value="0" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -79,12 +103,30 @@
|
|||||||
<el-button type="primary" @click="submitForm" :loading="submitLoading">确定</el-button>
|
<el-button type="primary" @click="submitForm" :loading="submitLoading">确定</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 快捷备注 -->
|
||||||
|
<el-dialog v-model="remarkDialogVisible" title="快捷备注" width="420px" destroy-on-close>
|
||||||
|
<div class="text-sm text-gray-500 mb-3">账号:{{ remarkTargetPhone }}</div>
|
||||||
|
<el-input
|
||||||
|
v-model="remarkDraft"
|
||||||
|
type="textarea"
|
||||||
|
:rows="4"
|
||||||
|
maxlength="500"
|
||||||
|
show-word-limit
|
||||||
|
placeholder="可填写用户相关信息,仅管理员可见"
|
||||||
|
/>
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="remarkDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="remarkSaving" @click="saveQuickRemark">保存</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { Edit } from '@element-plus/icons-vue'
|
||||||
import { apiAssetUserList, apiAssetUserAdd, apiAssetUserEdit, apiAssetUserDelete } from '@/api/asset'
|
import { apiAssetUserList, apiAssetUserAdd, apiAssetUserEdit, apiAssetUserDelete } from '@/api/asset'
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@@ -105,10 +147,17 @@ const dialogTitle = ref('')
|
|||||||
const submitLoading = ref(false)
|
const submitLoading = ref(false)
|
||||||
const formRef = ref()
|
const formRef = ref()
|
||||||
|
|
||||||
|
const remarkDialogVisible = ref(false)
|
||||||
|
const remarkSaving = ref(false)
|
||||||
|
const remarkDraft = ref('')
|
||||||
|
const remarkTargetId = ref<number | string>('')
|
||||||
|
const remarkTargetPhone = ref('')
|
||||||
|
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: '',
|
id: '',
|
||||||
phone: '',
|
phone: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
remark: '',
|
||||||
status: 1
|
status: 1
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -154,16 +203,41 @@ const handleStatusChange = async (row: any) => {
|
|||||||
|
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
dialogTitle.value = '新增账号'
|
dialogTitle.value = '新增账号'
|
||||||
Object.assign(formData, { id: '', phone: '', password: '', status: 1 })
|
Object.assign(formData, { id: '', phone: '', password: '', remark: '', status: 1 })
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleEdit = (row: any) => {
|
const handleEdit = (row: any) => {
|
||||||
dialogTitle.value = '编辑账号'
|
dialogTitle.value = '编辑账号'
|
||||||
Object.assign(formData, { id: row.id, phone: row.phone, password: '', status: row.status })
|
Object.assign(formData, { id: row.id, phone: row.phone, password: '', remark: row.remark || '', status: row.status })
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const openQuickRemark = (row: any) => {
|
||||||
|
remarkTargetId.value = row.id
|
||||||
|
remarkTargetPhone.value = row.phone || ''
|
||||||
|
remarkDraft.value = row.remark || ''
|
||||||
|
remarkDialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const saveQuickRemark = async () => {
|
||||||
|
if (!remarkTargetId.value) return
|
||||||
|
remarkSaving.value = true
|
||||||
|
try {
|
||||||
|
await apiAssetUserEdit({ id: remarkTargetId.value, remark: remarkDraft.value })
|
||||||
|
const target = tableData.value.find((item: any) => item.id === remarkTargetId.value)
|
||||||
|
if (target) {
|
||||||
|
target.remark = remarkDraft.value
|
||||||
|
}
|
||||||
|
ElMessage.success('备注已保存')
|
||||||
|
remarkDialogVisible.value = false
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
} finally {
|
||||||
|
remarkSaving.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleDelete = async (row: any) => {
|
const handleDelete = async (row: any) => {
|
||||||
try {
|
try {
|
||||||
await ElMessageBox.confirm('确定要删除该账号及其关联资源吗?', '提示', { type: 'warning' })
|
await ElMessageBox.confirm('确定要删除该账号及其关联资源吗?', '提示', { type: 'warning' })
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ class AssetUserController extends BaseAdminController
|
|||||||
'phone' => $params['phone'],
|
'phone' => $params['phone'],
|
||||||
'password' => $passwordHash,
|
'password' => $passwordHash,
|
||||||
'status' => $params['status'] ?? 1,
|
'status' => $params['status'] ?? 1,
|
||||||
|
'remark' => trim((string)($params['remark'] ?? '')),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return $this->success('添加成功', ['id' => $user->id]);
|
return $this->success('添加成功', ['id' => $user->id]);
|
||||||
@@ -93,6 +94,10 @@ class AssetUserController extends BaseAdminController
|
|||||||
$user->status = $params['status'];
|
$user->status = $params['status'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (array_key_exists('remark', $params)) {
|
||||||
|
$user->remark = trim((string)$params['remark']);
|
||||||
|
}
|
||||||
|
|
||||||
$user->save();
|
$user->save();
|
||||||
return $this->success('修改成功');
|
return $this->success('修改成功');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
-- 分发账号:管理员备注
|
||||||
|
ALTER TABLE `zyt_asset_user`
|
||||||
|
ADD COLUMN `remark` varchar(500) NOT NULL DEFAULT '' COMMENT '管理员备注' AFTER `status`;
|
||||||
Reference in New Issue
Block a user