提交 ed988fdd authored 作者: lihuihui's avatar lihuihui

update

上级 1fb15727
...@@ -67,3 +67,23 @@ export function getConnectionList() { ...@@ -67,3 +67,23 @@ export function getConnectionList() {
export function searchUser(params: any) { export function searchUser(params: any) {
return httpRequest.get('/api/lab/v1/experiment/system/search-user', { params }) return httpRequest.get('/api/lab/v1/experiment/system/search-user', { params })
} }
// 新建资料
export function createMaterial(data: { name: string; type: string; content: string; status: string }) {
return httpRequest.post('/api/lab/v1/experiment/marketing-material/create', data)
}
// 更新资料
export function updateMaterial(data: { name: string; content: string; status: string }) {
return httpRequest.post('/api/lab/v1/experiment/marketing-material/update', data)
}
// 资料列表
export function getMaterialList(params?: { name: string; type: string; id: string; status: string; updated_operator: string }) {
return httpRequest.get('/api/lab/v1/experiment/marketing-material/list', { params })
}
// 删除资料
export function deleteMaterial(data: { id: string }) {
return httpRequest.post('/api/lab/v1/experiment/marketing-material/delete', data)
}
\ No newline at end of file
<script setup lang="ts">
import type { FormInstance, FormRules } from 'element-plus'
import { ElMessage } from 'element-plus'
import { createMaterial, updateMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import AppUpload from '@/components/base/AppUpload.vue'
const ruleFormRef = ref<FormInstance>()
interface Props {
data?: MaterialProp
type: string
}
const props = defineProps<Props>()
const emit = defineEmits<{
(e: 'update'): void
(e: 'update:modelValue', visible: boolean): void
}>()
const form = $ref(
props.data || {
name: '',
content: '',
status: ''
}
)
const rules = ref<FormRules>({
name: [{ required: true, message: '请输入' }],
status: [{ required: true, message: '请选择' }],
content: [{ required: true, message: '请输入' }]
})
// 提交
const submitForm = (formEl: FormInstance | undefined) => {
const params = Object.assign(form, { type: props.type })
if (!formEl) return
formEl.validate(valid => {
if (valid) {
if (props.data?.id) {
updateMaterial(form).then(res => {
emit('update')
emit('update:modelValue', false)
ElMessage({ message: '更新成功', type: 'success' })
})
} else {
createMaterial(params).then(res => {
emit('update')
emit('update:modelValue', false)
ElMessage({ message: '新建成功', type: 'success' })
})
}
} else {
console.log('error submit!')
return false
}
})
}
// 查看h5链接
const handleViewH5 = function () {
window.open(`https://${form.content}`)
}
</script>
<template>
<el-dialog
class="connect-form"
:title="props.data ? (props.data?.isView ? '查看资料' : '编辑资料') : '新建资料'"
:close-on-click-modal="false"
width="800px"
@update:modelValue="$emit('update:modelValue')"
>
<el-form
:disabled="props.data?.isView"
ref="ruleFormRef"
style="width: 400px; margin: 0 auto; padding: 0 30px 30px 0"
:model="form"
:rules="rules"
label-suffix=":"
label-width="110px"
>
<el-form-item label="资料名称" prop="name">
<el-input placeholder="请输入" v-model="form.name" style="width: 100%"></el-input>
</el-form-item>
<el-form-item label="资料内容" prop="content">
<el-input
v-if="type === '1'"
placeholder="请输入"
type="textarea"
v-model="form.content"
style="width: 100%"
></el-input>
<AppUpload v-if="type === '2' || type === '6' || type === '7' || type === '8'" v-model="form.content" />
<div class="audio" v-if="type === '3'">
<AppUpload v-model="form.content" accept=".mp3">
<el-button type="primary">上传语音</el-button>
</AppUpload>
<audio v-if="form.content" :src="form.content" controls></audio>
</div>
<div class="video" v-if="type === '4'">
<AppUpload v-model="form.content" accept=".mp4">
<el-button type="primary">上传视频</el-button>
</AppUpload>
<video controls id="video" v-if="form.content" style="width: 100%">
<source :src="form.content" />
</video>
</div>
<div class="h5" v-if="type === '5'">
<el-input v-model="form.content" placeholder="请输入">
<template #prepend>Http://</template>
</el-input>
<span v-if="form.content" @click="handleViewH5">查看</span>
</div>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-switch v-model="form.status" active-text="生效" active-value="1" inactive-text="失效" inactive-value="0" />
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm(ruleFormRef)">提交</el-button>
<el-button @click="$emit('update:modelValue', false)">关闭</el-button>
</el-form-item>
</el-form>
</el-dialog>
</template>
<style lang="scss">
.h5 {
display: flex;
span {
white-space: nowrap;
margin-left: 10px;
color: rgba(15, 64, 245, 1);
cursor: pointer;
}
}
</style>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '3'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '8'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '5'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '2'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '7'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '6'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
import httpRequest from '@/utils/axios'
// 人员列表
export function getMemberList(params: { name?: string; id?: string; mobile?: string; status?: string; page?: number; page_size?: number }) {
return httpRequest.get('/api/lab/v1/experiment/member/list', { params })
}
// 链接列表
export function getMemberConnectionsList() {
return httpRequest.get('/api/lab/v1/experiment/member/connections')
}
// 用户属性
export function getMemberFieldsList() {
return httpRequest.get('/api/lab/v1/experiment/member/member-fields')
}
// 新建用户
export function createMember(data: { name: string; status: string; experiment_connection_id: string; gender: string; mobile: string; fields: string }) {
return httpRequest.post('/api/lab/v1/experiment/member/create', data)
}
// 删除用户
export function deleteMember(data: { ids: string; }) {
return httpRequest.post('/api/lab/v1/experiment/member/delete', data)
}
// 新建用户
export function updateMember(data: { id?: string; name: string; status: string; experiment_connection_id: string; gender: string; mobile: string; fields: string }) {
return httpRequest.post('/api/lab/v1/experiment/member/update', data)
}
// 单人员事件列表
export function getMemberEventList(params: { id: string; page?: number; page_size?: number }) {
return httpRequest.get('/api/lab/v1/experiment/member/member-events', { params })
}
// 事件列表
export function getEventList() {
return httpRequest.get('/api/lab/v1/experiment/member/events')
}
// 新建事件
export function createEvent(data: { experiment_member_id: string; experiment_meta_event_id: string; fields: any }) {
return httpRequest.post('/api/lab/v1/experiment/member/event-create', data)
}
// 更新事件
export function updateEvent(data: { id: string; fields: any }) {
return httpRequest.post('/api/lab/v1/experiment/member/event-update', data)
}
// 删除事件
export function deleteEvent(data: { id: string }) {
return httpRequest.post('/api/lab/v1/experiment/member/event-delete', data)
}
// 用户画像
export function getMemberImage(params: { id: string }) {
return httpRequest.get('/api/lab/v1/experiment/member/member-image', { params })
}
// 导入事件
export function importEvent(data: { event_id: string; file: any }) {
return httpRequest.post('/api/lab/v1/experiment/member/event-upload', data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
// 导入用户
export function importMember(data: { groups_id?: string; connection_id: string; file: any }) {
return httpRequest.post('/api/lab/v1/experiment/member/member-upload', data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
// 用户画像
export function getMemberGroups() {
return httpRequest.get('/api/lab/v1/experiment/member/groups')
}
\ No newline at end of file
export interface ConnectionsProp {
id: string
type: string
type_name: string
}
export interface MemberFieldsProp {
id: string
name: string
english_name: string
type: string
type_name: string
format: string
value: string
isShow: boolean
}
export interface MemberProp {
id: string
name: string
status: string
experiment_connection_id: string
gender: string
mobile: string
fields: string
isView?: boolean
connection_name: string
status_name: string
}
export interface EventProp {
name: string
id: string
attributes: AttributesProp[]
connection_name: string
}
export interface AttributesProp {
name: string
id: string
type: string
format: string
value: string
experiment_meta_event_id: string
fields: string
connection_id: string
isView: boolean
}
export interface ImageProp {
tag: string[]
static_groups: string[]
dynamic_groups: string[]
events: {
list: {
updated_time: string
connection_type: string
connection_name: string
event_name: string
}[]
}
}
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '1'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,22 +51,80 @@ const listOptions = computed(() => { ...@@ -26,22 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x> <template #table-x="{ row }">
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>删除</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Plus, Delete } from '@element-plus/icons-vue' import { Plus } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue' import AppList from '@/components/base/AppList.vue'
import { getMaterialList, deleteMaterial } from '@/api/base'
import type { MaterialProp } from '@/types'
import { ElMessage } from 'element-plus'
const UpdateMaterialDialog = defineAsyncComponent(() => import('@/components/base/UpdateMaterialDialog.vue'))
const appList = $ref<InstanceType<typeof AppList> | null>(null) const appList = $ref<InstanceType<typeof AppList> | null>(null)
// 资料类型
const materialType = '4'
// 列表配置 // 列表配置
const listOptions = computed(() => { const listOptions = computed(() => {
return { return {
filters: [{ type: 'input', prop: 'name', placeholder: '请输入资料名称' }], remote: {
httpRequest: getMaterialList,
params: { name: '', id: '', status: '', type: materialType, updated_operator: '' }
},
filters: [
{ type: 'input', prop: 'name', placeholder: '请输入资料名称' },
{ type: 'input', prop: 'name', placeholder: '请输入资料ID' },
{
type: 'select',
prop: 'status',
placeholder: '请选择资料状态',
options: [
{ label: '有效', value: '1' },
{ label: '失效', value: '0' }
]
},
{ type: 'input', prop: 'updated_operator', placeholder: '更新人' }
],
columns: [ columns: [
{ type: 'selection' }, // { type: 'selection' },
{ label: '序号', type: 'index', width: 60 }, { label: '序号', type: 'index', width: 60 },
{ label: '资料ID', prop: 'id' }, { label: '资料ID', prop: 'id' },
{ label: '资料名称', prop: 'name' }, { label: '资料名称', prop: 'name' },
{ label: '资料类型', prop: 'name' }, { label: '资料类型', prop: 'type_name' },
{ label: '状态', prop: 'name' }, { label: '状态', prop: 'status_name' },
{ label: '更新人', prop: 'name' }, { label: '更新人', prop: 'updated_operator_name' },
{ label: '更新时间', prop: 'name' }, { label: '更新时间', prop: 'updated_time' },
{ label: '操作', slots: 'table-x', width: 240 } { label: '操作', slots: 'table-x', width: 240 }
], ]
data: [{}, {}]
} }
}) })
...@@ -26,23 +51,80 @@ const listOptions = computed(() => { ...@@ -26,23 +51,80 @@ const listOptions = computed(() => {
function handleRefresh() { function handleRefresh() {
appList?.refetch() appList?.refetch()
} }
let updateVisible = $ref(false)
// 编辑
let currentRow = ref<MaterialProp>()
const handleEdit = function (row: MaterialProp) {
currentRow.value = row
row.isView = false
updateVisible = true
}
// 查看
const handleView = function (row: MaterialProp) {
row.isView = true
currentRow.value = row
updateVisible = true
}
// 新建
const handleAdd = function () {
updateVisible = true
currentRow.value = undefined
}
// 多选
let multipleSelection = $ref<MaterialProp[]>([])
function handleSelectionChange(selection: MaterialProp[]) {
multipleSelection = selection
}
// 删除
const handleRemove = function (row: { id: string }) {
deleteMembers(row.id)
}
const handleRemoves = function () {
const ids = multipleSelection
.reduce((a: any, b: any) => {
a.push(b.id)
return a
}, [])
.toString()
deleteMembers(ids)
}
const deleteMembers = function (ids: string) {
deleteMaterial({ id: ids }).then(res => {
ElMessage({ message: '删除成功', type: 'success' })
handleRefresh()
})
}
</script> </script>
<template> <template>
<AppCard> <AppCard>
<AppList v-bind="listOptions" ref="appList"> <AppList v-bind="listOptions" ref="appList" @selection-change="handleSelectionChange">
<template #header-buttons> <template #header-buttons>
<el-space> <el-space>
<el-button type="primary" :icon="Plus">新建</el-button> <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
<el-button type="danger" plain :icon="Delete">删除</el-button> <!-- <el-button type="danger" plain :icon="Delete" :disabled="!multipleSelection.length" @click="handleRemoves()"
>删除</el-button
> -->
</el-space> </el-space>
</template> </template>
<template #table-x="{ row }">
<template #table-x> <el-button type="primary" plain @click="handleView(row)">查看</el-button>
<el-button type="primary" plain>查看</el-button> <el-button type="primary" plain @click="handleEdit(row)">编辑</el-button>
<el-button type="primary" plain>编辑</el-button> <el-button type="primary" plain @click="handleRemove(row)">删除</el-button>
<el-button type="primary" plain>删除</el-button>
</template> </template>
</AppList> </AppList>
<UpdateMaterialDialog
:type="materialType"
:data="currentRow"
@update="handleRefresh()"
v-if="updateVisible"
v-model="updateVisible"
></UpdateMaterialDialog>
</AppCard> </AppCard>
</template> </template>
...@@ -110,3 +110,15 @@ export interface TagRule { ...@@ -110,3 +110,15 @@ export interface TagRule {
current_logic_operate: 'and' | 'or' current_logic_operate: 'and' | 'or'
items: string[] items: string[]
} }
// 资料管理
export interface MaterialProp {
id: string
name: string
content: string
type_name: string
type: string
status_name: string
status: string
isView: boolean
}
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论