Initial commit
This commit is contained in:
178
src/views/cms/form/detail/components/checkbox-form.vue
Normal file
178
src/views/cms/form/detail/components/checkbox-form.vue
Normal file
@@ -0,0 +1,178 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="1000"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:title="isUpdate ? '编辑选项' : '添加选项'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="options"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新增</span>
|
||||
</a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'name'">
|
||||
<a-input v-model:value="record.value" />
|
||||
</template>
|
||||
<template v-if="column.key == 'action'">
|
||||
<a class="ele-text-danger" @click="remove(index)">删除</a>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { type EleProTable } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
const disabled = ref(false);
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: any | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', {}): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 顶部图片
|
||||
const photo = ref<ItemType[]>([]);
|
||||
// 背景图片
|
||||
const background = ref<ItemType[]>([]);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const formData = ref<[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<any>({
|
||||
id: undefined,
|
||||
type: '',
|
||||
name: '',
|
||||
checked: undefined,
|
||||
checkedList: [],
|
||||
options: [],
|
||||
radio: []
|
||||
});
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<any[]>([
|
||||
{
|
||||
title: '选项',
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
width: 180
|
||||
}
|
||||
]);
|
||||
|
||||
const options = ref<any[]>([]);
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const add = () => {
|
||||
options.value.push({});
|
||||
};
|
||||
|
||||
const remove = (index) => {
|
||||
options.value.splice(index, 1);
|
||||
}
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写表单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
path: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写路由地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
component: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写组件路径',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
form.options = options.value.map((d) => {
|
||||
return d.value;
|
||||
});
|
||||
updateVisible(false);
|
||||
emit('done', form);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
options.value = [];
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
props.data?.options.map((value) => {
|
||||
options.value.push({ value });
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
options.value = [];
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
183
src/views/cms/form/detail/components/radio-form.vue
Normal file
183
src/views/cms/form/detail/components/radio-form.vue
Normal file
@@ -0,0 +1,183 @@
|
||||
<!-- 编辑弹窗 -->
|
||||
<template>
|
||||
<ele-modal
|
||||
:width="1000"
|
||||
:visible="visible"
|
||||
:maskClosable="false"
|
||||
:title="isUpdate ? '编辑选项' : '添加选项'"
|
||||
:body-style="{ paddingBottom: '28px' }"
|
||||
@update:visible="updateVisible"
|
||||
@ok="save"
|
||||
>
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
:columns="columns"
|
||||
:datasource="options"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新增</span>
|
||||
</a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.key === 'name'">
|
||||
<a-input v-model:value="record.value" />
|
||||
</template>
|
||||
<template v-if="column.key == 'action'">
|
||||
<a class="ele-text-danger" @click="remove(index)">删除</a>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</ele-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import { type EleProTable } from 'ele-admin-pro';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { FormInstance } from 'ant-design-vue/es/form';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { PlusOutlined } from '@ant-design/icons-vue';
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
const useForm = Form.useForm;
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
const disabled = ref(false);
|
||||
// 编辑器内容,双向绑定
|
||||
const content = ref<any>('');
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: any | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'done', {}): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
// 顶部图片
|
||||
const photo = ref<ItemType[]>([]);
|
||||
// 背景图片
|
||||
const background = ref<ItemType[]>([]);
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const formData = ref<[]>([]);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<any>({
|
||||
id: undefined,
|
||||
type: '',
|
||||
name: '',
|
||||
checked: undefined,
|
||||
checkedList: [],
|
||||
options: [],
|
||||
radio: []
|
||||
});
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<any[]>([
|
||||
{
|
||||
title: '选项',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 180,
|
||||
key: 'action',
|
||||
align: 'center'
|
||||
}
|
||||
]);
|
||||
|
||||
const options = ref<any[]>([]);
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
const add = () => {
|
||||
options.value.push({});
|
||||
};
|
||||
|
||||
const remove = (index) => {
|
||||
options.value.splice(index, 1);
|
||||
}
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写表单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
path: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写路由地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
component: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写组件路径',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
form.options = options.value.map((d) => {
|
||||
return d.value;
|
||||
});
|
||||
updateVisible(false);
|
||||
emit('done', form);
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
options.value = [];
|
||||
if (props.data) {
|
||||
assignFields(props.data);
|
||||
props.data?.options.map((value) => {
|
||||
options.value.push({ value });
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
options.value = [];
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
<style lang="less"></style>
|
||||
851
src/views/cms/form/detail/index.vue
Normal file
851
src/views/cms/form/detail/index.vue
Normal file
@@ -0,0 +1,851 @@
|
||||
<template>
|
||||
<a-page-header
|
||||
:title="isUpdate ? '表单设计' : '新增表单'"
|
||||
@back="() => $router.go(-1)"
|
||||
>
|
||||
<div class="ele-cell ele-cell-align-top">
|
||||
<!-- 设计画布 -->
|
||||
<div class="body ele-cell-content ele-bg-white">
|
||||
<a-card>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
labelAlign="left"
|
||||
:label-col="
|
||||
styleResponsive ? { md: 4, sm: 5, xs: 24 } : { flex: '90px' }
|
||||
"
|
||||
:wrapper-col="
|
||||
styleResponsive ? { md: 18, sm: 19, xs: 24 } : { flex: '1' }
|
||||
"
|
||||
>
|
||||
<a-form-item label="表单名称" name="name">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="100"
|
||||
placeholder="请输入表单名称"
|
||||
v-model:value="form.name"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="表单说明">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="1000"
|
||||
show-count
|
||||
placeholder="请输入表单说明"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="提交次数"
|
||||
name="submitNumber"
|
||||
extra="设置每位用户可以提交表单的次数"
|
||||
>
|
||||
<a-radio-group v-model:value="form.submitNumber">
|
||||
<a-radio :value="1">1次</a-radio>
|
||||
<a-radio :value="0">不限</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="顶部图片" name="photo">
|
||||
<a-space direction="vertical" style="padding-top: 5px">
|
||||
<a-radio-group v-model:value="form.hidePhoto">
|
||||
<a-radio :value="1">隐藏</a-radio>
|
||||
<a-radio :value="0">顶部图片</a-radio>
|
||||
</a-radio-group>
|
||||
<template v-if="form.hidePhoto == 0">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="1"
|
||||
:data="photo"
|
||||
@done="chooseFile"
|
||||
@del="onDeleteItem"
|
||||
/>
|
||||
<div class="ele-text-placeholder"
|
||||
>请上传jpg、png格式的图片,图片尺寸:750px*460px</div
|
||||
>
|
||||
</template>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="视频文件" name="video">
|
||||
<a-space direction="vertical" style="padding-top: 5px">
|
||||
<a-radio-group v-model:value="form.hideVideo">
|
||||
<a-radio :value="1">隐藏</a-radio>
|
||||
<a-radio :value="0">视频文件</a-radio>
|
||||
</a-radio-group>
|
||||
<template v-if="form.hideVideo == 0">
|
||||
<SelectFile
|
||||
:placeholder="`请选择视频文件`"
|
||||
:limit="1"
|
||||
:data="video"
|
||||
:type="`video`"
|
||||
@done="chooseVideo"
|
||||
@del="onDeleteVideoItem"
|
||||
/>
|
||||
<div class="ele-text-placeholder"
|
||||
>请上传mp4格式的视频文件,大小200M以内</div
|
||||
>
|
||||
</template>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item label="背景图片" name="background">
|
||||
<a-space direction="vertical" style="padding-top: 5px">
|
||||
<a-radio-group
|
||||
v-model:value="form.hideBackground"
|
||||
name="submitNumber"
|
||||
>
|
||||
<a-radio :value="1">隐藏</a-radio>
|
||||
<a-radio :value="0">自定义</a-radio>
|
||||
</a-radio-group>
|
||||
<template v-if="form.hideBackground == 0">
|
||||
<SelectFile
|
||||
:placeholder="`请选择图片`"
|
||||
:limit="1"
|
||||
:data="background"
|
||||
@done="chooseFile2"
|
||||
@del="onDeleteItem2"
|
||||
/>
|
||||
<div class="ele-text-placeholder"
|
||||
>请上传jpg、png格式的图片,图片尺寸:750px*1624px</div
|
||||
>
|
||||
</template>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
<a-form-item
|
||||
label="背景透明度"
|
||||
name="opacity"
|
||||
v-if="form.hideBackground == 0"
|
||||
>
|
||||
<a-input-number
|
||||
style="width: 140px"
|
||||
:step="0.1"
|
||||
:max="1"
|
||||
:min="0.1"
|
||||
placeholder="设置背景透明度"
|
||||
v-model:value="form.opacity"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="表单内容" name="content">
|
||||
<div class="demo-drag-list">
|
||||
<vue-draggable
|
||||
v-model="formData"
|
||||
item-key="id"
|
||||
:animation="300"
|
||||
handle=".sort-handle"
|
||||
>
|
||||
<template #item="{ element, index }">
|
||||
<a-form-item>
|
||||
<div class="demo-drag-list-item ele-cell">
|
||||
<drag-outlined class="sort-handle" />
|
||||
<div class="ele-cell-content">
|
||||
<a-space class="ele-cell">
|
||||
<a-input
|
||||
v-model:value="element.name"
|
||||
style="width: 500px"
|
||||
>
|
||||
<template #addonBefore>
|
||||
<a-select
|
||||
v-model:value="element.type"
|
||||
style="width: 120px"
|
||||
@change="onSelect(element, index)"
|
||||
>
|
||||
<a-select-option value="text"
|
||||
>单行文本</a-select-option
|
||||
>
|
||||
<a-select-option value="textarea"
|
||||
>多行文本</a-select-option
|
||||
>
|
||||
<a-select-option value="radio"
|
||||
>单选</a-select-option
|
||||
>
|
||||
<a-select-option value="checkbox"
|
||||
>多选</a-select-option
|
||||
>
|
||||
<a-select-option value="phone"
|
||||
>手机号码</a-select-option
|
||||
>
|
||||
<a-select-option value="email"
|
||||
>邮箱</a-select-option
|
||||
>
|
||||
<a-select-option value="time"
|
||||
>时间</a-select-option
|
||||
>
|
||||
<a-select-option value="date"
|
||||
>日期</a-select-option
|
||||
>
|
||||
<a-select-option value="image"
|
||||
>图片上传</a-select-option
|
||||
>
|
||||
</a-select>
|
||||
</template>
|
||||
</a-input>
|
||||
<a-checkbox v-model:checked="element.checked"
|
||||
>必填</a-checkbox
|
||||
>
|
||||
<a
|
||||
v-if="element.type == 'radio'"
|
||||
@click="openRadioForm(element)"
|
||||
>设置</a
|
||||
>
|
||||
<a
|
||||
v-if="element.type == 'checkbox'"
|
||||
@click="openCheckboxForm(element)"
|
||||
>设置</a
|
||||
>
|
||||
<a-button
|
||||
@click="removeItem(index)"
|
||||
danger
|
||||
style="margin-left: 10px"
|
||||
>删除</a-button
|
||||
>
|
||||
</a-space>
|
||||
</div>
|
||||
</div>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</vue-draggable>
|
||||
<a @click="addItem"
|
||||
><PlusCircleOutlined style="margin-right: 4px" />新增</a
|
||||
>
|
||||
</div>
|
||||
</a-form-item>
|
||||
<a-form-item label="操作">
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-bg-warning ele-border-warning"
|
||||
@click="save1"
|
||||
>保存草稿</a-button
|
||||
>
|
||||
<a-button type="primary" @click="save2">保存并发布</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
<!-- 中间间隙 -->
|
||||
<div style="width: 500px"></div>
|
||||
<!-- 设计工具 -->
|
||||
<div class="phone-layout">
|
||||
<div class="phone-header-black ele-fluid">
|
||||
<div class="title ele-fluid"> {{ form.name }} </div>
|
||||
</div>
|
||||
<div
|
||||
class="phone-body-bg ele-fluid"
|
||||
:style="{
|
||||
background:
|
||||
form.hideBackground == 0 ? `url(${form.background})` : 'none',
|
||||
backgroundRepeat: 'no-repeat',
|
||||
opacity: form.opacity,
|
||||
backgroundPosition: 'center'
|
||||
}"
|
||||
>
|
||||
</div>
|
||||
<div class="phone-body" style="overflow-y: auto; overflow-x: hidden">
|
||||
<a-image
|
||||
:src="form.photo"
|
||||
:preview="false"
|
||||
v-if="form.hidePhoto == 0"
|
||||
/>
|
||||
<div class="comments" v-html="form.comments"></div>
|
||||
<div class="form-data ele-fluid">
|
||||
<a-form ref="formRef2" :rules="rules2" layout="vertical">
|
||||
<template v-for="(item, index) in formData" :key="index">
|
||||
<a-form-item v-if="item.name" :name="item.type">
|
||||
<template #label>
|
||||
<a-space>
|
||||
<span>{{ item.name }}</span>
|
||||
<span v-if="item.checked" class="ele-text-danger">*</span>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-if="item.type == 'text'">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="200"
|
||||
:placeholder="`${
|
||||
item.placeholder ? `请填写${item.name}` : '请输入'
|
||||
}`"
|
||||
v-model:value="item.value"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'textarea'">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
show-count
|
||||
:placeholder="`请输入${item.name}`"
|
||||
v-model:value="item.value"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'radio'">
|
||||
<a-radio-group v-model:value="item.radio">
|
||||
<template
|
||||
v-for="(radio, radioIndex) in item.options"
|
||||
:key="radioIndex"
|
||||
>
|
||||
<a-radio :value="radio">{{ radio }}</a-radio>
|
||||
</template>
|
||||
</a-radio-group>
|
||||
</template>
|
||||
<template v-if="item.type == 'checkbox'">
|
||||
<a-checkbox-group
|
||||
v-model:value="item.checkedList"
|
||||
:options="item.options"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'phone'">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="11"
|
||||
:placeholder="`${
|
||||
item.placeholder ? `请填写${item.name}` : '请输入'
|
||||
}`"
|
||||
v-model:value="item.value"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'email'">
|
||||
<a-input
|
||||
allow-clear
|
||||
:maxlength="11"
|
||||
:placeholder="`${
|
||||
item.placeholder ? `请填写${item.name}` : '请输入'
|
||||
}`"
|
||||
v-model:value="item.value"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'time'">
|
||||
<a-time-picker
|
||||
v-model:value="timeItem"
|
||||
format="HH:mm"
|
||||
@change="onTimeItem(index)"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'date'">
|
||||
<a-date-picker
|
||||
v-model:value="item.value"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'image'">
|
||||
<ele-image-upload
|
||||
v-model:value="imageItem"
|
||||
:limit="1"
|
||||
:upload-handler="uploadHandlerItem"
|
||||
@click="onClickItem(index)"
|
||||
@upload="onUploadItem"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="item.type == 'video'"></template>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<div class="submit-btn">
|
||||
<a-button type="primary" size="large" block>提交</a-button>
|
||||
</div>
|
||||
</a-form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 弹窗 -->
|
||||
<RadioForm
|
||||
v-model:visible="showRadioForm"
|
||||
:data="current"
|
||||
@done="doneRadio"
|
||||
/>
|
||||
<CheckboxForm
|
||||
v-model:visible="showCheckboxForm"
|
||||
:data="current"
|
||||
@done="doneCheckbox"
|
||||
/>
|
||||
</a-page-header>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { reactive, ref, unref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useThemeStore } from '@/store/modules/theme';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { addForm, getForm, updateForm } from '@/api/cms/form';
|
||||
import { Form as FormModel } from '@/api/cms/form/model';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { FormInstance, RuleObject } from 'ant-design-vue/es/form';
|
||||
import { getSiteInfo } from '@/api/layout';
|
||||
import { uuid } from 'ele-admin-pro';
|
||||
import { Website } from '@/api/cms/website/model';
|
||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
||||
import { uploadFile } from '@/api/system/file';
|
||||
import { PlusCircleOutlined, DragOutlined } from '@ant-design/icons-vue';
|
||||
import VueDraggable from 'vuedraggable';
|
||||
import { toDateString } from 'ele-admin-pro';
|
||||
import { Dayjs } from 'dayjs';
|
||||
import { FileRecord } from '@/api/system/file/model';
|
||||
import RadioForm from './components/radio-form.vue';
|
||||
import CheckboxForm from './components/checkbox-form.vue';
|
||||
import {push} from "echarts/types/src/component/dataZoom/history";
|
||||
import {openUrl} from "@/utils/common";
|
||||
// 是否开启响应式布局
|
||||
const themeStore = useThemeStore();
|
||||
|
||||
// 表格选中数据
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
const { currentRoute } = useRouter();
|
||||
const { query } = unref(currentRoute);
|
||||
const { styleResponsive } = storeToRefs(themeStore);
|
||||
const { screenWidth, tabs } = storeToRefs(themeStore);
|
||||
const spinning = ref(true);
|
||||
const siteInfo = ref<Website>();
|
||||
const formId = ref<number>(0);
|
||||
const isUpdate = ref<boolean>(false);
|
||||
const currentItemIndex = ref<number>(0);
|
||||
const showRadioForm = ref<boolean>(false);
|
||||
const showCheckboxForm = ref<boolean>(false);
|
||||
const current = ref<any>();
|
||||
// 顶部图片
|
||||
const photo = ref<ItemType[]>([]);
|
||||
// 视频文就
|
||||
const video = ref<ItemType[]>([]);
|
||||
// 背景图片
|
||||
const background = ref<ItemType[]>([]);
|
||||
// 表单数据里的图片
|
||||
const imageItem = ref<ItemType[]>([]);
|
||||
// 时间
|
||||
const timeItem = ref<Dayjs>();
|
||||
|
||||
const formData = ref<any[]>([
|
||||
{ id: uuid(4), type: 'text', name: '姓名', checked: true },
|
||||
{ id: uuid(4), type: 'phone', name: '手机号码', checked: true },
|
||||
{ id: uuid(4), type: 'date', name: '日期', checked: false }
|
||||
]);
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<FormModel>({
|
||||
formId: undefined,
|
||||
name: '',
|
||||
photo: '',
|
||||
background: '',
|
||||
video: '',
|
||||
submitNumber: 1,
|
||||
layout: '',
|
||||
userId: 0,
|
||||
status: 0,
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
hidePhoto: 1,
|
||||
hideBackground: 1,
|
||||
hideVideo: 1,
|
||||
opacity: 1.0,
|
||||
clearCache: undefined
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写表单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
submitNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请设置提交次数限制',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
content: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
trigger: 'blur',
|
||||
validator: async (_rule: RuleObject, value: string) => {
|
||||
if (formData.value.length === 0) {
|
||||
return Promise.reject('请配置表单内容');
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const rules2 = reactive({
|
||||
name: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写表单名称',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
path: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写路由地址',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
component: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写组件路径',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
const openRadioForm = (row: any) => {
|
||||
current.value = row ?? null;
|
||||
showRadioForm.value = true;
|
||||
};
|
||||
|
||||
const openCheckboxForm = (row: any) => {
|
||||
current.value = row ?? null;
|
||||
showCheckboxForm.value = true;
|
||||
};
|
||||
|
||||
const doneRadio = (item: any) => {
|
||||
formData.value.map((d) => {
|
||||
if (d.id == item.id) {
|
||||
d.options = item.options;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const doneCheckbox = (item: any) => {
|
||||
formData.value.map((d) => {
|
||||
if (d.id == item.id) {
|
||||
d.options = item.options;
|
||||
}
|
||||
});
|
||||
};
|
||||
const addItem = () => {
|
||||
formData.value.push({
|
||||
id: uuid(4),
|
||||
type: 'text',
|
||||
placeholder: '请填写',
|
||||
value: undefined
|
||||
});
|
||||
};
|
||||
|
||||
const removeItem = (index: number) => {
|
||||
formData.value.splice(index, 1);
|
||||
};
|
||||
|
||||
/* 上传事件 */
|
||||
const uploadHandlerItem = (file: File) => {
|
||||
const item: ItemType = {
|
||||
file,
|
||||
uid: (file as any).uid,
|
||||
name: file.name
|
||||
};
|
||||
if (file.type.startsWith('video')) {
|
||||
if (file.size / 1024 / 1024 > 200) {
|
||||
message.error('大小不能超过 200MB');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (file.type.startsWith('image')) {
|
||||
if (file.size / 1024 / 1024 > 5) {
|
||||
message.error('大小不能超过 5MB');
|
||||
return;
|
||||
}
|
||||
}
|
||||
onUploadItem(item);
|
||||
};
|
||||
|
||||
const onUploadItem = (item: any) => {
|
||||
const { file } = item;
|
||||
if (currentItemIndex.value > 0) {
|
||||
uploadFile(file)
|
||||
.then((data) => {
|
||||
// console.log(data);
|
||||
// console.log(formData.value[currentItemIndex.value])
|
||||
formData.value[currentItemIndex.value].image = data.path;
|
||||
imageItem.value.push({
|
||||
uid: data.id,
|
||||
url: data.path,
|
||||
status: 'done'
|
||||
});
|
||||
currentItemIndex.value = 0;
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const onClickItem = (index: number) => {
|
||||
currentItemIndex.value = index;
|
||||
};
|
||||
|
||||
const onSelect = (item: any, index: number) => {
|
||||
// console.log(item);
|
||||
// console.log(index)
|
||||
if (item.type == 'checkbox') {
|
||||
formData.value[index].checkedList = ['aaa'];
|
||||
formData.value[index].options = ['aaa', 'bbb'];
|
||||
}
|
||||
if (item.type == 'radio') {
|
||||
formData.value[index].radio = 'A';
|
||||
formData.value[index].options = ['A', 'B', 'C', 'D'];
|
||||
}
|
||||
};
|
||||
|
||||
const chooseFile = (data: FileRecord) => {
|
||||
photo.value.push({
|
||||
uid: data.id,
|
||||
url: data.downloadUrl,
|
||||
status: 'done'
|
||||
});
|
||||
form.photo = data.downloadUrl;
|
||||
};
|
||||
|
||||
const onDeleteItem = (index: number) => {
|
||||
photo.value.splice(index, 1);
|
||||
form.photo = '';
|
||||
};
|
||||
|
||||
const chooseVideo = (data: FileRecord) => {
|
||||
video.value.push({
|
||||
uid: data.id,
|
||||
url: data.downloadUrl,
|
||||
status: 'done'
|
||||
});
|
||||
form.video = data.downloadUrl;
|
||||
};
|
||||
|
||||
const onDeleteVideoItem = (index: number) => {
|
||||
video.value.splice(index, 1);
|
||||
form.video = '';
|
||||
};
|
||||
|
||||
const chooseFile2 = (data: FileRecord) => {
|
||||
background.value.push({
|
||||
uid: data.id,
|
||||
url: data.path,
|
||||
status: 'done'
|
||||
});
|
||||
form.background = data.path;
|
||||
};
|
||||
|
||||
const onDeleteItem2 = (index: number) => {
|
||||
background.value.splice(index, 1);
|
||||
form.background = '';
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
const saveData = {
|
||||
...form,
|
||||
layout: JSON.stringify(formData.value)
|
||||
};
|
||||
const saveOrUpdate = isUpdate.value ? updateForm : addForm;
|
||||
saveOrUpdate(saveData)
|
||||
.then((msg) => {
|
||||
message.success('保存成功');
|
||||
openUrl(`/website/form`);
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
const save1 = () => {
|
||||
form.clearCache = undefined;
|
||||
save();
|
||||
};
|
||||
|
||||
const save2 = () => {
|
||||
form.clearCache = 1;
|
||||
save();
|
||||
};
|
||||
|
||||
const { contentWidth } = storeToRefs(themeStore);
|
||||
// 使用 watch 监听 contentWidth 改变
|
||||
watch(contentWidth, (e) => {
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
const onTimeItem = (index: number) => {
|
||||
formData.value[index].value = toDateString(timeItem.value, 'HH:mm');
|
||||
};
|
||||
|
||||
/**
|
||||
* 加载数据
|
||||
*/
|
||||
const reload = () => {
|
||||
// 加载网站信息
|
||||
getSiteInfo().then((data) => {
|
||||
siteInfo.value = data;
|
||||
});
|
||||
getForm(formId.value).then((data) => {
|
||||
if (data) {
|
||||
spinning.value = false;
|
||||
isUpdate.value = true;
|
||||
if (data.layout) {
|
||||
// layout.value = JSON.parse(data.layout);
|
||||
}
|
||||
assignFields(data);
|
||||
photo.value = [];
|
||||
background.value = [];
|
||||
formData.value = [];
|
||||
if (data.photo) {
|
||||
photo.value.push({
|
||||
uid: 1,
|
||||
url: data.photo,
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
if (data.background) {
|
||||
background.value.push({
|
||||
uid: 2,
|
||||
url: data.background,
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
if (data.layout) {
|
||||
formData.value = JSON.parse(data.layout);
|
||||
formData.value.map((d) => {
|
||||
if (d.type == 'image') {
|
||||
imageItem.value = [];
|
||||
imageItem.value.push({
|
||||
uid: uuid(),
|
||||
url: d.image,
|
||||
status: 'done'
|
||||
});
|
||||
}
|
||||
if (d.type == 'time') {
|
||||
// timeItem.value = dayjs(d.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
(route) => {
|
||||
const { params, query } = unref(route);
|
||||
if(query.id){
|
||||
formId.value = Number(query.id);
|
||||
return reload();
|
||||
}
|
||||
const { id } = params;
|
||||
if (id) {
|
||||
formId.value = Number(id);
|
||||
return reload();
|
||||
}
|
||||
resetFields();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// watch(
|
||||
// () => query.id,
|
||||
// (id) => {
|
||||
// console.log(id);
|
||||
// if (id) {
|
||||
// isUpdate.value = true;
|
||||
// formId.value = Number(id);
|
||||
// reload();
|
||||
// } else {
|
||||
// isUpdate.value = false;
|
||||
// resetFields();
|
||||
// formRef.value?.clearValidate();
|
||||
// }
|
||||
// },
|
||||
// { immediate: true }
|
||||
// );
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'FormDetail'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.phone-layout {
|
||||
position: fixed;
|
||||
right: 16px;
|
||||
width: 390px;
|
||||
height: 844px;
|
||||
background: url('@/assets/img/app-ui.png');
|
||||
background-repeat: no-repeat;
|
||||
background-position: top;
|
||||
background-size: 100%;
|
||||
//position: relative;
|
||||
padding: 0 16px;
|
||||
.phone-header-black {
|
||||
height: 99px;
|
||||
border-radius: 20px 20px 0 0;
|
||||
background-size: 100%;
|
||||
.title {
|
||||
height: 99px;
|
||||
font-size: 16px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: end;
|
||||
padding-bottom: 13px;
|
||||
}
|
||||
}
|
||||
.phone-body-bg {
|
||||
padding: 0 16px;
|
||||
height: 680px;
|
||||
border-radius: 0 0 44px 44px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.phone-body {
|
||||
width: 360px;
|
||||
margin-left: 16px;
|
||||
height: 674px;
|
||||
padding: 0;
|
||||
position: absolute;
|
||||
top: 98px;
|
||||
left: 0;
|
||||
z-index: 999;
|
||||
.comments {
|
||||
padding: 20px;
|
||||
word-break: break-all;
|
||||
}
|
||||
.form-data {
|
||||
padding: 10px 20px;
|
||||
.submit-btn {
|
||||
padding: 30px 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.demo-drag-list {
|
||||
}
|
||||
|
||||
.demo-drag-list-item {
|
||||
padding: 0 16px 12px 0;
|
||||
}
|
||||
|
||||
.demo-drag-list-item + .demo-drag-list-item {
|
||||
//border-top: 1px solid hsla(0, 0%, 60%, 0.2);
|
||||
}
|
||||
|
||||
.demo-drag-list-item.sortable-chosen {
|
||||
background: hsla(0, 0%, 60%, 0.1);
|
||||
}
|
||||
|
||||
.demo-drag-list-item .sort-handle {
|
||||
cursor: move;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
350
src/views/cms/form/index.vue
Normal file
350
src/views/cms/form/index.vue
Normal file
@@ -0,0 +1,350 @@
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false" :body-style="{ padding: '16px' }">
|
||||
<ele-pro-table
|
||||
ref="tableRef"
|
||||
row-key="formId"
|
||||
:columns="columns"
|
||||
:datasource="datasource"
|
||||
:customRow="customRow"
|
||||
tool-class="ele-toolbar-form"
|
||||
class="sys-org-table"
|
||||
>
|
||||
<template #toolbar>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="openEdit">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>新增</span>
|
||||
</a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'name'">
|
||||
<span @click="openPreview('/form/' + record.formId)">{{
|
||||
record.name
|
||||
}}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'path'">
|
||||
<span class="ele-text-placeholder">{{ record.path }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'component'">
|
||||
<span class="ele-text-placeholder">{{ record.component }}</span>
|
||||
</template>
|
||||
<template v-if="column.key === 'formData'"> </template>
|
||||
<template v-if="column.key === 'status'">
|
||||
<a-badge
|
||||
v-if="record.status === 0"
|
||||
status="success"
|
||||
text="已发布"
|
||||
@click="onUpdateStatus(record)"
|
||||
/>
|
||||
<a-badge
|
||||
v-if="record.status === 1"
|
||||
status="default"
|
||||
text="已关闭"
|
||||
@click="onUpdateStatus(record)"
|
||||
/>
|
||||
</template>
|
||||
<template v-if="column.key === 'action'">
|
||||
<a-space>
|
||||
<a @click="openUrl('/cms/form-record?id=' + record.formId)"
|
||||
><SolutionOutlined />表单数据</a
|
||||
>
|
||||
<a-divider type="vertical" />
|
||||
<a-popover>
|
||||
<template #content>
|
||||
<div class="ele-cell">
|
||||
<ele-qr-code
|
||||
:value="`${domain}/form/${record.formId}`"
|
||||
:size="160"
|
||||
level="M"
|
||||
:margin="1"
|
||||
/>
|
||||
手机扫一扫
|
||||
</div>
|
||||
</template>
|
||||
<a @click="onShare"><QrcodeOutlined />分享</a>
|
||||
</a-popover>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="openEdit(record)">设计</a>
|
||||
<a-divider type="vertical" />
|
||||
<a @click="onUpdateStatus(record)">{{
|
||||
record.status == 1 ? '发布' : '关闭'
|
||||
}}</a>
|
||||
<a-divider type="vertical" />
|
||||
<a-popconfirm
|
||||
title="确定要删除此记录吗?"
|
||||
@confirm="remove(record)"
|
||||
>
|
||||
<a class="ele-text-danger">删除</a>
|
||||
</a-popconfirm>
|
||||
</a-space>
|
||||
</template>
|
||||
</template>
|
||||
</ele-pro-table>
|
||||
</a-card>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<!-- <FormEdit-->
|
||||
<!-- v-model:visible="showEdit"-->
|
||||
<!-- :data="current"-->
|
||||
<!-- @open="onOpen"-->
|
||||
<!-- @done="openEdit"-->
|
||||
<!-- />-->
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { createVNode, ref, unref, watch } from 'vue';
|
||||
import { message, Modal } from 'ant-design-vue';
|
||||
import {
|
||||
ExclamationCircleOutlined,
|
||||
PlusOutlined,
|
||||
QrcodeOutlined,
|
||||
SolutionOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import type { EleProTable } from 'ele-admin-pro';
|
||||
import type {
|
||||
DatasourceFunction,
|
||||
ColumnItem
|
||||
} from 'ele-admin-pro/es/ele-pro-table/types';
|
||||
import Search from './components/search.vue';
|
||||
import FormEdit from './components/form-edit.vue';
|
||||
import {
|
||||
pageForm,
|
||||
removeForm,
|
||||
updateForm,
|
||||
removeBatchForm
|
||||
} from '@/api/cms/form';
|
||||
import type { Form, FormParam } from '@/api/cms/form/model';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { openPreview, openUrl } from '@/utils/common';
|
||||
import { useTenantStore } from '@/store/modules/tenant';
|
||||
import { storeToRefs } from 'pinia';
|
||||
import { getSiteInfo } from '@/api/layout';
|
||||
const { push } = useRouter();
|
||||
const { currentRoute } = useRouter();
|
||||
// 表格实例
|
||||
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
|
||||
|
||||
// 表格选中数据
|
||||
const selection = ref<Form[]>([]);
|
||||
// 当前编辑数据
|
||||
const current = ref<Form | null>(null);
|
||||
// 是否显示编辑弹窗
|
||||
const showEdit = ref(false);
|
||||
// 是否显示批量移动弹窗
|
||||
const showMove = ref(false);
|
||||
// 二维码
|
||||
const showQrCode = ref(false);
|
||||
// 加载状态
|
||||
const loading = ref(true);
|
||||
// 网站域名
|
||||
const domain = ref('');
|
||||
|
||||
getSiteInfo().then((data) => {
|
||||
// tenantId.value = data.tenantId;
|
||||
domain.value = String(data.domain);
|
||||
});
|
||||
|
||||
// 表格数据源
|
||||
const datasource: DatasourceFunction = ({
|
||||
page,
|
||||
limit,
|
||||
where,
|
||||
orders,
|
||||
filters
|
||||
}) => {
|
||||
if (filters) {
|
||||
where.status = filters.status;
|
||||
}
|
||||
return pageForm({
|
||||
...where,
|
||||
...orders,
|
||||
page,
|
||||
limit
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列配置
|
||||
const columns = ref<ColumnItem[]>([
|
||||
{
|
||||
title: 'ID',
|
||||
width: 90,
|
||||
dataIndex: 'formId'
|
||||
},
|
||||
{
|
||||
title: '表单标题',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
width: 120,
|
||||
align: 'center',
|
||||
key: 'status'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 380,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
hideInSetting: true
|
||||
}
|
||||
]);
|
||||
|
||||
/* 搜索 */
|
||||
const reload = (where?: FormParam) => {
|
||||
selection.value = [];
|
||||
tableRef?.value?.reload({ where: where });
|
||||
};
|
||||
|
||||
/* 打开编辑弹窗 */
|
||||
const openEdit = (row?: Form) => {
|
||||
push({
|
||||
path: '/website/form/detail',
|
||||
query: {
|
||||
id: row?.formId
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const onShare = (item: any) => {
|
||||
showQrCode.value = true;
|
||||
current.value = item;
|
||||
};
|
||||
|
||||
const onUpdateStatus = (row?: Form) => {
|
||||
updateForm({ ...row, status: row?.status == 1 ? 0 : 1 }).then((msg) => {
|
||||
message.success(msg);
|
||||
reload();
|
||||
});
|
||||
};
|
||||
|
||||
const onOpen = (e) => {
|
||||
console.log(e);
|
||||
};
|
||||
|
||||
const openForm = (row?: Form) => {
|
||||
push({
|
||||
path: '/cms/form/detail',
|
||||
query: { id: row?.formId }
|
||||
});
|
||||
};
|
||||
|
||||
/* 打开批量移动弹窗 */
|
||||
const openMove = () => {
|
||||
showMove.value = true;
|
||||
};
|
||||
|
||||
/* 删除单个 */
|
||||
const remove = (row: Form) => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeForm(row.formId)
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
/* 批量删除 */
|
||||
const removeBatch = () => {
|
||||
if (!selection.value.length) {
|
||||
message.error('请至少选择一条数据');
|
||||
return;
|
||||
}
|
||||
Modal.confirm({
|
||||
title: '提示',
|
||||
content: '确定要删除选中的记录吗?',
|
||||
icon: createVNode(ExclamationCircleOutlined),
|
||||
maskClosable: true,
|
||||
onOk: () => {
|
||||
const hide = message.loading('请求中..', 0);
|
||||
removeBatchForm(selection.value.map((d) => d.formId))
|
||||
.then((msg) => {
|
||||
hide();
|
||||
message.success(msg);
|
||||
reload();
|
||||
})
|
||||
.catch((e) => {
|
||||
hide();
|
||||
message.error(e.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/* 查询 */
|
||||
const query = () => {
|
||||
loading.value = true;
|
||||
reload();
|
||||
};
|
||||
|
||||
/* 自定义行属性 */
|
||||
const customRow = (record: Form) => {
|
||||
return {
|
||||
// 行点击事件
|
||||
onClick: () => {
|
||||
// console.log(record);
|
||||
},
|
||||
// 行双击事件
|
||||
onDblclick: () => {
|
||||
openUrl('/cms/form-record?id=' + record.formId);
|
||||
// openEdit(record);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
watch(
|
||||
currentRoute,
|
||||
() => {
|
||||
query();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'FormIndex'
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.sys-org-table :deep(.ant-table-body) {
|
||||
overflow: auto !important;
|
||||
overflow: overlay !important;
|
||||
}
|
||||
|
||||
.sys-org-table :deep(.ant-table-pagination.ant-pagination) {
|
||||
padding: 0 4px;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.design-item {
|
||||
margin: auto;
|
||||
display: flex;
|
||||
text-align: center;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 70px;
|
||||
height: 70px;
|
||||
border-radius: 70px;
|
||||
background: url('data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(6.123233995736766e-17%2C%201%2C%20-0.024693877551020406%2C%206.123233995736766e-17%2C%200.5%2C%200)%22%3E%3Cstop%20stop-color%3D%22%230a060d%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23660061%22%20stop-opacity%3D%221%22%20offset%3D%220.95%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E');
|
||||
}
|
||||
.ele-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user