素材库

This commit is contained in:
yanran200730
2023-03-02 15:23:23 +08:00
parent 421c7ee0a5
commit 6a91ea51c9
3 changed files with 307 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<template>
<div class="doc-circulation ailist-wrapper">
<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'
import Add from './components/Add'
export default {
name: 'AppMaterialLibrary',
label: '素材库',
props: {
instance: Function,
dict: Object
},
data () {
return {
component: 'List',
params: {},
include: []
}
},
components: {
Add,
List
},
mounted () {
},
methods: {
onChange (data) {
if (data.type === 'Add') {
this.component = 'Add'
this.params = data.params
}
if (data.type === 'list') {
this.component = 'List'
this.params = data.params
this.$nextTick(() => {
if (data.isRefresh) {
this.$refs.component.getList()
}
})
}
}
}
}
</script>
<style lang="scss">
.doc-circulation {
height: 100%;
background: #F3F6F9;
overflow: auto;
}
</style>

View File

@@ -0,0 +1,119 @@
<template>
<ai-detail>
<template slot="title">
<ai-title title="添加二维码" isShowBack isShowBottomBorder @onBackClick="cancel(false)">
</ai-title>
</template>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<el-form class="ai-form" ref="form" :model="form" label-width="110px" label-position="right">
<el-form-item label="地区" style="width: 100%;" prop="codeName">
<span style="color: #666;">{{ form.areaName }}</span>
</el-form-item>
<el-form-item label="二维码名称" prop="codeName" :rules="[{ required: true, message: '请输入二维码名称', trigger: 'blur' }]">
<el-input size="small" maxlength="30" show-word-limit placeholder="请输入二维码名称" style="width: 328px;" v-model="form.codeName"></el-input>
</el-form-item>
<el-form-item style="width: 100%;" label="二维码类型" prop="type" :rules="[{ required: true, message: '请选择二维码类型', trigger: 'change' }]">
<el-radio-group v-model="form.type">
<el-radio label="0">群二维码</el-radio>
<el-radio label="1">个人二维码</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="上传二维码" prop="codeUrl" style="width: 100%;" :rules="[{ required: true, message: '请上传二维码', trigger: 'change' }]">
<ai-uploader :instance="instance" v-model="form.codeUrl" :limit="1"></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>
export default {
name: 'Add',
props: {
instance: Function,
dict: Object,
params: Object
},
data () {
return {
info: {},
form: {
areaId: '',
codeName: '',
areaName: '',
code: '',
codeUrl: [],
type: '',
},
id: ''
}
},
created () {
if (this.params && this.params.areaId && !this.params.id) {
this.form.areaId = this.params.areaId
this.form.areaName = this.params.areaName
}
if (this.params && this.params.id) {
this.id = this.params.id
this.getInfo(this.params.id)
}
},
methods: {
getInfo (id) {
this.instance.post(`/app/appeveryvillagecode/queryDetailById?id=${id}`).then(res => {
if (res.code === 0) {
this.form = res.data
this.form.codeUrl = [{
url: res.data.codeUrl
}]
}
})
},
onClose () {
this.form.explain = ''
},
confirm () {
this.$refs.form.validate((valid) => {
if (valid) {
this.instance.post(`/app/appeveryvillagecode/addOrUpdate`, {
...this.form,
codeUrl: this.form.codeUrl[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,122 @@
<template>
<ai-list class="villagecode">
<template slot="title">
<ai-title title="一村一码" isShowBottomBorder></ai-title>
</template>
<template slot="content">
<ai-search-bar class="search-bar">
<template #left>
<el-button size="small" type="primary" :disabled="isShowAdd" icon="iconfont iconAdd" @click="toAdd('')">添加活码</el-button>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:col-configs="colConfigs"
:total="total"
style="margin-top: 6px;"
:current.sync="search.current"
:size.sync="search.size"
@getList="getList">
<el-table-column slot="options" width="120px" fixed="right" label="操作" align="center">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click="toAdd(row.id)">编辑</el-button>
<el-button type="text" @click="remove(row.id)">删除</el-button>
</div>
</template>
</el-table-column>
</ai-table>
</template>
</ai-list>
</template>
<script>
export default {
name: 'List',
props: {
instance: Function,
dict: Object
},
data() {
return {
search: {
current: 1,
size: 10,
status: 0,
title: '',
areaId: ''
},
defaultExpanded: [],
defaultChecked: [],
areaTree: [],
defaultProps: {
children: 'children',
label: 'name'
},
currIndex: -1,
total: 10,
colConfigs: [
{prop: 'codeName', label: '名称', align: 'left'},
{prop: 'type', label: '二维码类型', align: 'left', format: v => v === '0' ? '群二维码' : '个人二维码'},
{prop: 'createUserName', label: '创建人'},
{prop: 'createTime', label: '创建时间'},
{slot: 'options', label: '操作'}
],
areaName: '',
unitName: '',
tableData: []
}
},
mounted() {
this.search.areaId = this.user.info.areaId
this.areaName = this.user.info.areaName
this.getList()
this.$nextTick(() => {
})
},
methods: {
getList() {
this.instance.post(`/app/appeveryvillagecode/list`, null, {
params: {
...this.search
}
}).then(res => {
if (res.code == 0) {
this.tableData = res.data.records
this.total = res.data.total
}
})
},
remove(id) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/appeveryvillagecode/delete?ids=${id}`).then(res => {
if (res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
toAdd(id) {
this.$emit('change', {
type: 'Add',
params: {
areaName: this.areaName,
id: id || '',
areaId: this.search.areaId
}
})
}
}
}
</script>
<style lang="scss" scoped>
</style>