Files
dvcp_v2_wxcp_app/library/apps/AppCreditPoints/giveIntegral.vue
2024-10-31 14:34:57 +08:00

104 lines
2.6 KiB
Vue

<template>
<section class="giveIntegral">
<AiGroup>
<AiItem label="选择对象" required>
<AiSelect v-model="form.objectType" dict="integralGiveObjType"/>
</AiItem>
<AiItem label="选择人员" required v-if="form.objectType">
<AiPagePicker v-if="form.objectType==0" single auditStatus="1" @select="handleSelectUser">
<AiMore v-model="form.userName"/>
</AiPagePicker>
<AiPagePicker v-if="form.objectType==1" single @select="handleSelectUser" type="sysUser">
<AiMore v-model="form.userName"/>
</AiPagePicker>
</AiItem>
</AiGroup>
<AiGroup>
<AiItem label="赠送分值" required topLabel>
<div slot="sub" class="color-999">(积分总额{{ info.sysUserIntegral || 0 }})</div>
<input v-model.number="form.integral"/>
</AiItem>
</AiGroup>
<AiBottomBtn text="确认赠送" @click="submit"/>
</section>
</template>
<script>
import {mapState} from "vuex";
export default {
name: "giveIntegral",
appName: "积分赠送",
computed: {
...mapState(['user'])
},
data() {
return {
info: {},
form: {userName: ""},
flag: false
}
},
methods: {
getInfo() {
let {user: {id: userId}} = this
this.$http.post('/app/appvillagerintegraldetail/sysUserIntegralList', null, {
params: {userId, current: 1, size: 10}
}).then(res => {
if (res?.data) {
this.info = res.data
}
})
},
submit() {
if(this.flag) return
let {objectType, userId, integral} = this.form
if (!objectType) {
return this.$u.toast("请选择对象")
}
if (!userId) {
return this.$u.toast("请选择人员")
}
if (isNaN(integral) || !/^\d*[.\d]\d?$/.test(integral)) {
return this.$u.toast("请输入赠送分值,最多保留一位小数")
}
this.flag = true
this.$http.post("/admin/user/giveIntegral", null, {
params: {...this.form}
}).then(res => {
if (res?.code == 0) {
uni.$emit("updateIntegral")
this.$u.toast("提交成功!")
uni.navigateBack({})
}else {
this.flag = false
this.$u.toast(res.msg)
}
}).catch((err) => {
this.flag = false
this.$u.toast(err)
})
},
handleSelectUser(v) {
this.form.userId = v?.[0]?.id || ""
this.form.userName = v?.[0]?.name || ""
}
},
created() {
this.getInfo()
this.$dict.load("integralGiveObjType")
}
}
</script>
<style lang="scss" scoped>
.giveIntegral {
width: 100vw;
min-height: 100vh;
.color-999 {
color: #999;
}
}
</style>