|
|
@@ -106,6 +106,7 @@
|
|
|
</el-dialog>
|
|
|
|
|
|
<el-dialog
|
|
|
+ @close="cancelLevel1ModalForm"
|
|
|
:visible.sync="level1ModalFormVisible"
|
|
|
destroy-on-close
|
|
|
width="30%"
|
|
|
@@ -133,7 +134,7 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="level1ModalFormVisible = false">取 消</el-button>
|
|
|
+ <el-button @click="cancelLevel1ModalForm()">取 消</el-button>
|
|
|
<el-button type="primary" @click="handleLevel1Submit"
|
|
|
>确 定</el-button
|
|
|
>
|
|
|
@@ -144,6 +145,7 @@
|
|
|
<el-dialog
|
|
|
destroy-on-close
|
|
|
:visible.sync="level2ModalFormVisible"
|
|
|
+ @close="cancelLevel2ModalForm()"
|
|
|
width="30%"
|
|
|
center
|
|
|
>
|
|
|
@@ -169,6 +171,7 @@
|
|
|
action=""
|
|
|
:limit="1"
|
|
|
:http-request="handleFileUpload"
|
|
|
+ :before-upload="beforeFileUpload"
|
|
|
list-type="picture-card"
|
|
|
accept=".jpeg,.jpg,.png,.png"
|
|
|
:file-list="level2ModalForm.filelist"
|
|
|
@@ -189,7 +192,7 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="level2ModalFormVisible = false">取 消</el-button>
|
|
|
+ <el-button @click="cancelLevel2ModalForm()">取 消</el-button>
|
|
|
<el-button type="primary" @click="handleLevel2Submit"
|
|
|
>确 定</el-button
|
|
|
>
|
|
|
@@ -231,10 +234,10 @@
|
|
|
<template #default="{ row }">
|
|
|
<!-- <el-button type="text" @click="handleVillageSettings(row.id)"
|
|
|
>村落设置</el-button
|
|
|
- >
|
|
|
- <el-button type="text" @click="handleLevel2Edit(row.id)"
|
|
|
- >编辑</el-button
|
|
|
> -->
|
|
|
+ <el-button type="text" @click="handleVillageEdit(row.id)"
|
|
|
+ >编辑</el-button
|
|
|
+ >
|
|
|
<el-popconfirm
|
|
|
title="确定删除吗?"
|
|
|
@confirm="handleVillageDelete(row.id)"
|
|
|
@@ -249,14 +252,14 @@
|
|
|
</div>
|
|
|
|
|
|
<el-dialog
|
|
|
- v-if="showVillageForm"
|
|
|
:visible.sync="showVillageForm"
|
|
|
destroy-on-close
|
|
|
width="30%"
|
|
|
+ @close="cancelVillage"
|
|
|
center
|
|
|
>
|
|
|
<div slot="title" class="lv1-modal-header">
|
|
|
- <span>新增</span>
|
|
|
+ <span>{{ villageForm?.id ? "新增" : "新增" }}</span>
|
|
|
</div>
|
|
|
<el-form
|
|
|
ref="villageForm"
|
|
|
@@ -273,8 +276,9 @@
|
|
|
action=""
|
|
|
:limit="1"
|
|
|
:http-request="handleVillageFileUpload"
|
|
|
+ :before-upload="beforeFileUpload"
|
|
|
list-type="picture-card"
|
|
|
- accept=".jpeg,.jpg,.png,.png"
|
|
|
+ accept=".jpeg,.jpg,.png"
|
|
|
:file-list="villageForm.filelist"
|
|
|
:on-remove="handleVillageFileRemove"
|
|
|
>
|
|
|
@@ -299,7 +303,7 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="showVillageForm = false">取 消</el-button>
|
|
|
+ <el-button @click="cancelVillage">取 消</el-button>
|
|
|
<el-button type="primary" @click="handleVillageSubmit"
|
|
|
>确 定</el-button
|
|
|
>
|
|
|
@@ -319,7 +323,6 @@ import {
|
|
|
getEntity,
|
|
|
fileUpload
|
|
|
} from '@/apis/tab5'
|
|
|
-
|
|
|
export default {
|
|
|
name: 'tab5',
|
|
|
components: {},
|
|
|
@@ -335,7 +338,7 @@ export default {
|
|
|
level1Modal: false,
|
|
|
level1ModalFormVisible: false,
|
|
|
level1ModalForm: {},
|
|
|
- villageForm: null,
|
|
|
+ villageForm: {},
|
|
|
showVillageForm: false,
|
|
|
level1ModalFormRules: {
|
|
|
name: [{ required: true, message: '请输入名称', trigger: 'change' }],
|
|
|
@@ -371,17 +374,38 @@ export default {
|
|
|
watch: {},
|
|
|
// 方法集合
|
|
|
methods: {
|
|
|
+ cancelLevel1ModalForm () {
|
|
|
+ this.level1ModalFormVisible = false
|
|
|
+ this.handleAllReset()
|
|
|
+ },
|
|
|
+ cancelLevel2ModalForm () {
|
|
|
+ this.level2ModalFormVisible = false
|
|
|
+ this.handleAllReset()
|
|
|
+ },
|
|
|
+ cancelVillage () {
|
|
|
+ this.showVillageForm = false
|
|
|
+ this.villageForm = {
|
|
|
+ name: '',
|
|
|
+ thumb: '',
|
|
|
+ remark: '',
|
|
|
+ link: '',
|
|
|
+ fileList: [],
|
|
|
+ sort: 1
|
|
|
+ }
|
|
|
+ },
|
|
|
editVillage (add = false) {
|
|
|
if (add) {
|
|
|
- this.villageForm = {
|
|
|
- name: '',
|
|
|
- thumb: '',
|
|
|
- remark: '',
|
|
|
- link: ''
|
|
|
- }
|
|
|
+ // this.villageForm = {
|
|
|
+ // name: '',
|
|
|
+ // thumb: '',
|
|
|
+ // remark: '',
|
|
|
+ // link: '',
|
|
|
+ // fileList: [],
|
|
|
+ // sort: 1
|
|
|
+ // }
|
|
|
setTimeout(() => {
|
|
|
this.showVillageForm = true
|
|
|
- }, 100)
|
|
|
+ }, 0)
|
|
|
}
|
|
|
},
|
|
|
async handleVillageSettings (id) {
|
|
|
@@ -409,8 +433,7 @@ export default {
|
|
|
message: res.msg,
|
|
|
type: 'success'
|
|
|
})
|
|
|
- this.villageForm = null
|
|
|
- this.showVillageForm = false
|
|
|
+ this.cancelVillage()
|
|
|
await this.getVillageList()
|
|
|
} else {
|
|
|
this.$message({
|
|
|
@@ -506,6 +529,26 @@ export default {
|
|
|
}
|
|
|
await this.getVillageList()
|
|
|
},
|
|
|
+
|
|
|
+ async handleVillageEdit (id) {
|
|
|
+ this.showVillageForm = true
|
|
|
+ const res = await getEntity(id)
|
|
|
+ const domain =
|
|
|
+ process.env.NODE_ENV === 'development'
|
|
|
+ ? 'http://project.4dage.com:8016'
|
|
|
+ : ''
|
|
|
+ this.villageForm = {
|
|
|
+ id: res.data.id,
|
|
|
+ name: res.data.name,
|
|
|
+ thumb: res.data.thumb,
|
|
|
+ remark: res.data.remark,
|
|
|
+ link: res.data.link,
|
|
|
+ sort: res.data.sort,
|
|
|
+ filelist: [{ name: 'food.jpg', url: domain + res.data.thumb }]
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('res', res)
|
|
|
+ },
|
|
|
async handleLevel1Edit (id) {
|
|
|
this.level1ModalFormVisible = true
|
|
|
const res = await getEntity(id)
|
|
|
@@ -522,7 +565,6 @@ export default {
|
|
|
file: file,
|
|
|
type: 'thumb'
|
|
|
})
|
|
|
- console.log('res', res.data.filePath)
|
|
|
this.level2ModalForm.thumb = res.data.filePath
|
|
|
},
|
|
|
handleVillageFileRemove () {
|
|
|
@@ -536,6 +578,21 @@ export default {
|
|
|
console.log('res', res.data.filePath)
|
|
|
this.villageForm.thumb = res.data.filePath
|
|
|
},
|
|
|
+ beforeFileUpload (file) {
|
|
|
+ const isLt2M = file.size / 1024 / 1024 < 5
|
|
|
+ console.error(file.type)
|
|
|
+ const isFormat =
|
|
|
+ file.type === 'image/jpeg' ||
|
|
|
+ file.type === 'image/jpg' ||
|
|
|
+ file.type === 'image/png'
|
|
|
+ if (!isFormat) {
|
|
|
+ this.$message.error('支持png、jpg格式!')
|
|
|
+ }
|
|
|
+ if (!isLt2M) {
|
|
|
+ this.$message.error('大小不能超过 5MB!')
|
|
|
+ }
|
|
|
+ return isLt2M && isFormat
|
|
|
+ },
|
|
|
handleLevel2Submit () {
|
|
|
this.$refs.level2Form.validate(async (valid) => {
|
|
|
if (valid) {
|