完成本村相册

This commit is contained in:
yanran200730
2021-12-16 18:10:35 +08:00
parent fee27b681b
commit 2e10daef30
4 changed files with 1009 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
<template>
<div class="AppVillageAlbum">
<keep-alive :include="['List']">
<component ref="component" :is="component" @change="onChange" :params="params" :instance="instance" :dict="dict"></component>
</keep-alive>
</div>
</template>
<script>
import List from './components/List.vue'
import Add from './components/Add'
export default {
name: 'AppVillageAlbum',
label: '乡村相册',
components: {
List,
Add
},
props: {
instance: Function,
dict: Object,
permissions: Function
},
data () {
return {
currIndex: '0',
component: 'List',
params: {},
areaId: '',
isShowDetail: false
}
},
methods: {
onChange (data) {
if (data.type === 'list') {
this.component = 'List'
this.params = data.params
}
if (data.type === 'detail') {
this.component = 'Detail'
this.params = data.params
}
if (data.type === 'add') {
this.component = 'Add'
this.params = data.params
}
}
}
}
</script>
<style lang="scss" scoped>
.AppVillageAlbum {
height: 100%;
}
</style>

View File

@@ -0,0 +1,127 @@
<template>
<ai-detail>
<template slot="title">
<ai-title :title="params.id ? '编辑本村相册' : '添加本村相册'" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
</ai-title>
</template>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<el-form class="ai-form" :model="form" label-width="120px" ref="form">
<el-form-item label="相册名称" style="width: 100%;" prop="title" :rules="[{required: true, message: '请输入标题', trigger: 'blur'}]">
<el-input type="input" size="small" v-model="form.title" clearable placeholder="请输入..." maxlength="30" show-word-limit></el-input>
</el-form-item>
<el-form-item prop="areaId" style="width: 100%;" label="发布地区" :rules="[{required: true, message: '请选择地区', trigger: 'change'}]">
<ai-area-select clearable always-show :instance="instance" v-model="form.areaId" :disabled-level="disabledLevel"></ai-area-select>
</el-form-item>
<el-form-item label="相册主题" style="width: 100%;" prop="title" :rules="[{required: true, message: '请输入标题', trigger: 'blur'}]">
<el-input type="input" size="small" v-model="form.title" clearable placeholder="请输入..." maxlength="30" show-word-limit></el-input>
</el-form-item>
<el-form-item label="图片" style="width: 100%;" prop="thumbUrl">
<ai-uploader
:instance="instance"
isShowTip
v-model="form.thumbUrl"
:limit="20"
:cropOps="cropOps">
</ai-uploader>
</el-form-item>
</el-form>
</template>
</ai-card>
</template>
<template #footer>
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="confirm">提交</el-button>
</template>
</ai-detail>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object
},
data () {
return {
info: {},
form: {
title: '',
content: '',
areaId: '',
createUnitName: '',
createUserName: '',
status: '',
thumbUrl: []
},
cropOps: {
width: "336px",
height: "210px"
},
id: ''
}
},
computed: {
...mapState(['user'])
},
created () {
this.form.areaId = this.user.info.areaId
this.disabledLevel = this.user.info.areaList.length
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
},
methods: {
getInfo (id) {
this.instance.post(`/app/appcountrysidetourism/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = res.data
this.form.thumbUrl = res.data.thumbUrl ? JSON.parse(res.data.thumbUrl) : []
}
})
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/app/appcountrysidetourism/addOrUpdate`, {
...this.form,
type: 0,
createUserName: this.user.info.name,
thumbUrl: this.form.thumbUrl.length ? JSON.stringify([{
url: this.form.thumbUrl[0].url
}]) : ''
}).then(res => {
if (res.code == 0) {
this.$message.success('提交成功')
setTimeout(() => {
this.cancel(true)
}, 600)
}
})
}
})
},
cancel (isRefresh) {
this.$emit('change', {
type: 'list',
isRefresh: !!isRefresh
})
}
}
}
</script>
<style scoped lang="scss">
</style>

View File

@@ -0,0 +1,638 @@
<template>
<ai-list class="list">
<template slot="title">
<ai-title title="乡村相册" isShowBottomBorder :instance="instance" isShowArea v-model="search.areaId" @change="changeArea"></ai-title>
</template>
<template slot="content">
<ai-search-bar>
<template #left>
<ai-select
v-model="search.status"
@change="search.current = 1, getList()"
placeholder="项目状态"
:selectList="dict.getDict('questionnaireStatus')">
</ai-select>
<ai-select
v-model="search.type"
@change="search.current = 1, getList()"
placeholder="项目类型"
:selectList="dict.getDict('questionnaireType')">
</ai-select>
</template>
<template #right>
<el-input
v-model="search.title"
size="small"
placeholder="请输入模板名称或创建人"
clearable
@keyup.enter.native="search.current = 1, getList()"
@clear="search.current = 1, search.title = '', getList()"
suffix-icon="iconfont iconSearch">
</el-input>
</template>
</ai-search-bar>
<div v-loading="loading">
<div class="form-list__list">
<div class="list-item list-add" @click="toAdd('')">
<span class="iconfont iconAdd"></span>
<h2>添加相片</h2>
</div>
<div class="list-item" v-for="(item, index) in list" :key="index">
<div>
<div class="list-item__title">
<h2 :style="{color: dict.getColor('questionnaireStatus', item.status)}">{{ dict.getLabel('questionnaireStatus', item.status) }}</h2>
<span :class="'type-' + item.type">{{ dict.getLabel('questionnaireType', item.type) }}</span>
</div>
<p>{{ item.title }}</p>
<div class="list-item__user">
<span>{{ item.createUnitName }}</span>
<span>{{ item.createUserName }}</span>
</div>
</div>
<div class="list-item__bottom">
<span>{{ item.dataCount }} 份数据</span>
<i>{{ item.createTime }}</i>
</div>
<div class="list-item__operate">
<el-button
type="text"
icon="iconfont iconshare"
@click="toAdd(item.id)"
class="list-item__operate--item"
:disabled="item.status !== '1'">
编辑
</el-button>
<el-button
type="text"
icon="iconfont iconunpublish"
class="list-item__operate--item"
@click="toStop(item.id)">
下载
</el-button>
<el-button
@click="id = item.id, isShowAdd = true"
type="text"
icon="iconfont iconpublish"
class="list-item__operate--item">
删除
</el-button>
</div>
</div>
</div>
</div>
</template>
</ai-list>
</template>
<script>
import { mapState } from 'vuex'
export default {
name: 'FormList',
props: {
instance: Function,
dict: Object,
areaId: String
},
data () {
return {
search: {
current: 1,
areaId: '',
size: 1000000,
title: ''
},
isShowAdd: false,
form: {
},
list: [],
total: 0,
loading: false,
id: ''
}
},
computed: {
...mapState(['user'])
},
created () {
this.loading = true
this.search.areaId = this.user.info.areaId
this.dict.load(['questionnaireStatus', 'questionnaireType', 'questionnaireFieldType']).then(() => {
this.getList()
})
},
methods: {
changeArea (e) {
},
getList () {
this.instance.post(`/app/appquestionnairetemplate/list`, null, {
params: {
...this.search,
areaId: this.areaId
}
}).then(res => {
if (res.code == 0) {
this.list = res.data.records
this.total = res.data.total
this.loading = false
} else {
this.loading = false
}
}).catch(() => {
this.loading = false
})
},
downloadImg (url) {
let image = new Image()
image.setAttribute('crossOrigin', 'anonymous')
image.onload = function() {
let canvas = document.createElement('canvas')
canvas.width = image.width
canvas.height = image.height
let context = canvas.getContext('2d')
context.drawImage(image, 0, 0, image.width, image.height)
let url = canvas.toDataURL("image/png")
let a = document.createElement("a")
let event = new MouseEvent("click")
a.download = '二维码'
a.href = url
a.dispatchEvent(event)
}
image.src = url
},
toStop (id) {
this.$confirm('确定停止该表单?').then(() => {
this.instance.post(`/app/appquestionnairetemplate/stopRelease?id=${id}`).then(res => {
if (res.code === 0) {
this.$message.success('停止成功!')
this.getList()
}
})
})
},
showShare (info, isPreview) {
this.loading = true
this.info = info
this.instance.post(`/app/appquestionnairetemplate/queryQrCode?id=${info.id}`).then(res => {
if (res.code == 0) {
this.info.linkUrl = res.data.linkUrl
this.info.qrCodeUrl = res.data.qrCodeUrl
this.$nextTick(() => {
if (isPreview) {
this.isShowPreview = true
this.info.linkUrl = `${res.data.linkUrl}&preview=true#form`
} else {
this.isShowSuccess = true
}
})
}
this.loading = false
}).catch(() => {
this.loading = false
})
},
toAdd (id) {
this.$emit('change', {
type: 'add',
params: {
id
}
})
}
}
}
</script>
<style scoped lang="scss">
.list {
::v-deep .ai-list__content {
width: 100%;
.ai-list__content--right {
width: 100%!important;
.ai-list__content--right-wrapper {
padding: 0!important;
background: transparent!important;
box-shadow: none!important;
}
}
}
::v-deep.el-pager {
li.active + li {
border-left: 1px solid #D0D4DC;
}
}
.publish {
.tips {
display: flex;
align-items: center;
height: 36px;
margin-bottom: 20px;
padding: 0 12px;
background: #E8EFFF;
border-radius: 2px;
i {
margin-right: 2px;
color: #2367ff;
font-size: 16px;
}
h2 {
font-size: 12px;
color: #222222;
}
}
.form-item__wrapper {
padding-left: 24px;
.checkbox {
display: flex;
align-items: center;
margin-left: 9px;
&:first-child {
margin-bottom: 32px;
}
span {
color: #888888;
font-size: 14px;
}
}
.form-title {
display: flex;
align-items: center;
margin-bottom: 16px;
span {
margin-left: 16px;
color: #888888;
font-size: 14px;
}
h2 {
position: relative;
padding-left: 8px;
font-size: 16px;
font-weight: 700;
color: #222222;
&::after {
position: absolute;
left: 0;
top: 50%;
z-index: 1;
width: 3px;
height: 16px;
background: #2266FF;
content: ' ';
transform: translateY(-50%);
}
}
}
.form-item__container {
margin-left: 9px;
margin-bottom: 24px;
}
.form-field {
display: flex;
align-items: center;
margin-bottom: 16px;
i {
margin-right: 4px;
color: #FF4466;
font-size: 14px;
}
h2 {
color: #222222;
font-size: 14px;
}
span {
color: #888888;
font-size: 14px;
}
}
}
}
.newPagination {
width: 100%;
display: flex;
align-items: center;
height: 64px;
padding: 0 40px!important;
.el-pagination {
width: 100%;
padding: 0;
}
::v-deep .el-pager li.active {
background-color: #fff !important;
color: #2266FF !important;
border-color: #2266FF;
}
::v-deep .el-pager li {
background-color: #fff;
border: solid 1px #d0d4dc;
margin-left: 8px;
border-radius: 4px !important;
line-height: 26px !important;
}
.paginationPre {
display: flex;
height: 28px;
line-height: 1;
font-size: 14px;
font-weight: normal;
align-items: center;
.pagination-btns {
display: flex;
align-items: center;
gap: 8px;
color: #2266FF !important;
::v-deep span, ::v-deep div {
font-size: 12px;
cursor: pointer;
color: #2266FF !important;
&:hover {
opacity: 0.8;
}
}
}
.paginationPre-total {
font-size: 12px;
color: #555;
label {
padding: 0 2px;
font-weight: 700;
}
}
& > * + * {
margin-left: 24px;
}
::v-deep .el-pagination button, .el-pagination span:not([class*=suffix]) {
line-height: 1 !important;
}
::v-deep.el-checkbox {
padding-left: 14px;
display: flex;
align-items: center;
.el-checkbox__input, .el-checkbox__inner {
width: 14px;
height: 14px;
min-width: 0 !important;
line-height: 1 !important;
}
.el-checkbox__label {
font-size: 12px;
color: #222222;
height: auto !important;
line-height: 1 !important;
padding-left: 3px !important;
}
}
}
}
.iframe {
display: block;
width: 375px;
min-height: 450px;
margin: 0 auto;
}
.ai-dialog__success {
::v-deep .ai-dialog__content {
max-height: initial!important;
}
}
.type-0 {
color: #2266FF;
background: rgba(34, 102, 255, 0.1);
}
.type-1 {
color: rgba(34, 170, 153, 1);
background: rgba(34, 170, 153, 0.1);
}
.type-2 {
color: rgba(248, 180, 37, 1);
background: rgba(248, 180, 37, 0.1);
}
.type-3 {
color: rgba(102, 119, 187, 1);
background: rgba(102, 119, 187, 0.1);
}
.type-4 {
color: rgba(236, 68, 97, 1);
background: rgba(236, 68, 97, 0.1);
}
.form-list__list {
display: flex;
flex-wrap: wrap;
margin-top: 8px;
.list-item {
display: flex;
position: relative;
flex-direction: column;
justify-content: space-between;
margin-bottom: 12px;
padding: 18px 16px 16px;
&:hover {
.list-item__operate {
display: flex;
}
}
.list-item__operate {
display: none;
align-items: center;
position: absolute;
left: 0;
bottom: 0;
z-index: 1;
width: 100%;
height: 52px;
text-align: center;
background: #F7F8FA;
& > div {
flex: 1;
}
::v-deep .el-button {
margin-left: 0;
padding: 0;
i {
color: #8899BB;
font-size: 14px;
transition: all 0.3s;
}
.el-button + .el-button {
margin-left: 0;
}
span {
margin-left: 0;
color: #555555;
font-size: 12px;
transition: all 0.3s;
}
&:hover {
&.is-disabled {
i {
color: #8899BB;
}
span {
color: #555555;
}
}
}
}
.list-item__operate--item {
flex: 1;
&:hover {
::v-deep i, ::v-deep span {
color: #2266FF;
}
}
}
}
.list-item__bottom {
display: flex;
align-items: center;
justify-content: space-between;
color: #888888;
font-size: 12px;
i {
font-style: normal;
}
}
p {
line-height: 22px;
color: #333333;
font-size: 14px;
font-weight: 700;
}
.list-item__user {
display: flex;
align-items: center;
margin-top: 12px;
color: #888888;
font-size: 12px;
line-height: 20px;
& > div:first-child {
margin-right: 8px;
}
}
.list-item__title {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 14px;
h2 {
color: #2EA222;
font-size: 12px;
}
span {
width: 64px;
height: 24px;
line-height: 24px;
text-align: center;
border-radius: 4px;
font-size: 12px;
}
}
}
.list-add {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
padding: 0;
cursor: pointer;
span {
font-size: 32px;
color: #8899bb;
}
h2 {
color: #555555;
font-size: 12px;
}
&:hover {
opacity: 0.6;
}
}
& > div {
width: calc((100% - 60px) / 4);
height: 196px;
margin: 0 20px 20px 0;
background: #FFFFFF;
box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.05);
border-radius: 2px;
&:nth-of-type(4n) {
margin-right: 0;
}
}
}
}
</style>

View File

@@ -0,0 +1,181 @@
export const components = [
{
type: 'options',
tips: '(可重复添加)',
label: '选项',
children: [
{
type: 'radio',
label: '单选',
fixedLabel: '单选',
value: '',
points: '',
icon: 'iconradio',
isShowPoints: false,
required: true,
hasAnswer: false,
answer: '',
pointType: '0',
pointDict: [
{
dictName: '此题有唯一答案和分值',
dictValue: '0'
},
{
dictName: '每个选项都有对应分值',
dictValue: '1'
}
],
options: [
{
label: '选项1',
value: '',
point: '',
img: []
},
{
label: '选项2',
value: '',
point: '',
img: []
}
],
title: ''
},
{
type: 'checkbox',
label: '多选',
fixedLabel: '多选',
points: '',
icon: 'iconcheck_box',
isShowPoints: false,
required: true,
hasAnswer: false,
answer: [],
value: [],
pointType: '0',
pointDict: [
{
dictName: '此题有唯一答案和分值',
dictValue: '0'
},
{
dictName: '每个选项都有对应分值',
dictValue: '1'
},
{
dictName: '答对几项得几分,答错不得分',
dictValue: '2'
}
],
options: [
{
label: '选项1',
value: '',
point: '',
img: []
},
{
label: '选项2',
point: '',
value: '',
img: []
}
],
title: ''
},
{
type: 'select',
label: '单下拉框',
fixedLabel: '单下拉框',
value: '',
points: '',
icon: 'iconSelect',
isShowPoints: false,
required: true,
hasAnswer: false,
answer: '',
pointType: '0',
pointDict: [
{
dictName: '此题有唯一答案和分值',
dictValue: '0'
},
{
dictName: '每个选项都有对应分值',
dictValue: '1'
}
],
options: [
{
label: '选项1',
value: '',
point: '',
img: []
},
{
label: '选项2',
value: '',
point: '',
img: []
}
],
title: ''
}
]
},
{
type: 'input',
tips: '(可重复添加)',
label: '填空',
children: [
{
type: 'input',
label: '单行填空',
fixedLabel: '单行填空',
value: '',
pointType: '0',
icon: 'icontext_box',
isShowPoints: false,
points: '',
required: true,
hasAnswer: false,
placeholder: '请输入...',
answer: ''
},
{
type: 'textarea',
label: '多行填空',
fixedLabel: '多行填空',
pointType: '0',
icon: 'icontext_area',
points: '',
isShowPoints: false,
required: true,
hasAnswer: false,
answer: '',
placeholder: '请输入...',
value: ''
}
]
},
{
type: 'annex',
tips: '(可重复添加)',
label: '附件',
children: [
{
type: 'upload',
label: '上传图片',
fixedLabel: '上传图片',
value: '',
icon: 'iconpic',
isShowPoints: false,
points: '',
required: true,
hasAnswer: false,
answer: ''
}
]
}
];