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) {
return fetch('/farmTemplate/add', params,'post','json')
},
update(params) {
return fetch('/farmTemplate/update', params,'post','json')
},
list(params) {
return fetch('/farmTemplate/list', params,'post','json')

View File

@ -1,53 +1,100 @@
<template>
<div>
<a-button type="primary" @click="show = true">{{ title }}</a-button>
<a-modal v-model:visible="show" @before-ok="submit">
<a-textarea v-model="tmp" :auto-size="{miniRows:6}"></a-textarea>
<a-button type="text" @click="show = true">{{ title }}</a-button>
<a-modal v-model:visible="show" @before-ok="submit" @close="reset">
<a-textarea v-model="tmp" :auto-size="{ miniRows: 6 }"></a-textarea>
</a-modal>
</div>
</template>
<script>
export default {
watch: {
show:{
handler(val){
if (val){
this.tmp = JSON.stringify(this.from,null,4)
props: {
type: {
type: String,
default: 'add'
},
info: {
type:Object,
default:null
}
}
}
},
},
watch: {
show: {
handler(val) {
if (val) {
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() {
return {
tmp:null,
tmp: null,
show: false,
title: '新增',
from: {
circleDays: 0,
desc: '请输入描述',
isCircle: 0,
isSystem: 0,
name: '请输入名称',
remark: '请输入备注',
remark: '请输入备注'
}
}
},
methods: {
submit(done) {
const data = JSON.parse(this.tmp)
this.$api.flower.save(data).then(res => {
if (res.code === 200){
this.$message.success(res.msg)
this.$emit('ok')
done()
} else{
this.$message.error(res.msg)
done(false)
methods: {
reset(){
this.from = {
circleDays: 0,
desc: '请输入描述',
isCircle: 0,
name: '请输入名称',
remark: '请输入备注'
}
},
submit(done) {
const data = JSON.parse(this.tmp)
if (this.type === 'add') {
this.$api.flower.save(data).then(res => {
if (res.code === 200) {
this.$message.success(res.msg)
this.$emit('ok')
done()
} else {
this.$message.error(res.msg)
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>

View File

@ -5,7 +5,13 @@
<div class="flex flex-center flex-justify-start">
<edit @ok="fetchList"/>
</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>
</div>
</template>
@ -33,6 +39,9 @@ export default {
{
title:'周期',
dataIndex: 'CircleDays',
},{
title:"操作",
slotName:'menu'
}
]
}