This commit is contained in:
sdaduanbilei-d1581 2025-09-28 15:17:06 +08:00
parent 2302cbfd43
commit 5964982b7c
3 changed files with 87 additions and 28 deletions

View File

@ -4,6 +4,9 @@ export default {
save(params) { save(params) {
return fetch('/farmTemplate/add', params,'post','json') return fetch('/farmTemplate/add', params,'post','json')
}, },
update(params) {
return fetch('/farmTemplate/update', params,'post','json')
},
list(params) { list(params) {
return fetch('/farmTemplate/list', params,'post','json') return fetch('/farmTemplate/list', params,'post','json')

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<a-button type="primary" @click="show = true">{{ title }}</a-button> <a-button type="text" @click="show = true">{{ title }}</a-button>
<a-modal v-model:visible="show" @before-ok="submit"> <a-modal v-model:visible="show" @before-ok="submit" @close="reset">
<a-textarea v-model="tmp" :auto-size="{ miniRows: 6 }"></a-textarea> <a-textarea v-model="tmp" :auto-size="{ miniRows: 6 }"></a-textarea>
</a-modal> </a-modal>
</div> </div>
@ -9,6 +9,16 @@
<script> <script>
export default { export default {
props: {
type: {
type: String,
default: 'add'
},
info: {
type:Object,
default:null
}
},
watch: { watch: {
show: { show: {
handler(val) { handler(val) {
@ -16,6 +26,22 @@ export default {
this.tmp = JSON.stringify(this.from, null, 4) this.tmp = JSON.stringify(this.from, null, 4)
} }
} }
},
type: {
handler(val) {
if (val === 'edit') {
console.log(this.info)
this.title = "编辑"
this.from.id = this.info.id
this.from.name = this.info.Name
this.from.desc = this.info.Desc
this.from.remark = this.info.Remark
this.from.circleDays = this.info.CircleDays
this.from.isCircle = this.info.isCircle
this.tmp = JSON.stringify(this.from, null, 4)
}
},
immediate: true
} }
}, },
data() { data() {
@ -27,15 +53,24 @@ export default {
circleDays: 0, circleDays: 0,
desc: '请输入描述', desc: '请输入描述',
isCircle: 0, isCircle: 0,
isSystem: 0,
name: '请输入名称', name: '请输入名称',
remark: '请输入备注', remark: '请输入备注'
} }
} }
}, },
methods: { methods: {
reset(){
this.from = {
circleDays: 0,
desc: '请输入描述',
isCircle: 0,
name: '请输入名称',
remark: '请输入备注'
}
},
submit(done) { submit(done) {
const data = JSON.parse(this.tmp) const data = JSON.parse(this.tmp)
if (this.type === 'add') {
this.$api.flower.save(data).then(res => { this.$api.flower.save(data).then(res => {
if (res.code === 200) { if (res.code === 200) {
this.$message.success(res.msg) this.$message.success(res.msg)
@ -46,8 +81,20 @@ export default {
done(false) done(false)
} }
}) })
} else {
this.$api.flower.update(data).then(res => {
if (res.code === 200) {
this.$message.success(res.msg)
this.$emit('ok')
done()
} else {
this.$message.error(res.msg)
done(false)
}
})
}
}
} }
},
} }
</script> </script>

View File

@ -5,7 +5,13 @@
<div class="flex flex-center flex-justify-start"> <div class="flex flex-center flex-justify-start">
<edit @ok="fetchList"/> <edit @ok="fetchList"/>
</div> </div>
<a-table class="mt-20" :columns="columns" :data="list"></a-table> <a-table class="mt-20" :columns="columns" :data="list" >
<template #menu="{record}">
<div>
<edit type="edit" :info="record" @ok="fetchList"/>
</div>
</template>
</a-table>
</a-card> </a-card>
</div> </div>
</template> </template>
@ -33,6 +39,9 @@ export default {
{ {
title:'周期', title:'周期',
dataIndex: 'CircleDays', dataIndex: 'CircleDays',
},{
title:"操作",
slotName:'menu'
} }
] ]
} }