|
@@ -0,0 +1,179 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <a-button type="link" @click="showDrawer">编辑</a-button>
|
|
|
|
|
+ <a-drawer
|
|
|
|
|
+ v-model:open="visible"
|
|
|
|
|
+ class="custom-class"
|
|
|
|
|
+ title="编辑奖项"
|
|
|
|
|
+ placement="right"
|
|
|
|
|
+ width="600"
|
|
|
|
|
+ :closable="false"
|
|
|
|
|
+ :maskClosable="!loading"
|
|
|
|
|
+ >
|
|
|
|
|
+ <a-form ref="formRef" :model="form" layout="vertical">
|
|
|
|
|
+ <a-row :gutter="16">
|
|
|
|
|
+ <a-col :span="24">
|
|
|
|
|
+ <a-form-item label="奖项名称" name="name" :rules="[{ required: true, message: '请输入奖项名称'}]">
|
|
|
|
|
+ <a-input v-model:value="form.name" placeholder="请输入奖项名称"></a-input>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col :span="24">
|
|
|
|
|
+ <a-form-item label="中奖概率" name="percentage" :rules="[{ required: true,validator: checkNumber,trigger: 'blur' }]">
|
|
|
|
|
+ <a-input v-model:value="form.percentage" placeholder="请输入中奖概率"></a-input>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col :span="24">
|
|
|
|
|
+ <a-form-item label="类型">
|
|
|
|
|
+ <a-radio-group v-model:value="form.type">
|
|
|
|
|
+ <a-radio value="现金">现金</a-radio>
|
|
|
|
|
+ <a-radio value="实物">实物</a-radio>
|
|
|
|
|
+ </a-radio-group>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col :span="24" v-if="form.type == '现金'">
|
|
|
|
|
+ <a-form-item label="金额(元)" name="price" :rules="[{ required: true,validator: checkNumber2,trigger: 'blur' },{pattern:/^([1-9][0-9]*)+(\.[0-9]{1,2})?$/,required: true, message: '请输入数字,最多两位小数',trigger:'blur'}]">
|
|
|
|
|
+ <a-input v-model:value="form.price" placeholder="请输入金额(元)"></a-input>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col :span="24">
|
|
|
|
|
+ <a-form-item label="对外余量" name="outcount" :rules="[{ required: true, message: '请输入对外余量'},{ pattern:/^[0-9]*$/,message:'请输入正数字',trigger:'blur'}]">
|
|
|
|
|
+ <a-input v-model:value="form.outcount" placeholder="请输入对外余量"></a-input>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col :span="24">
|
|
|
|
|
+ <a-form-item label="总量" name="totalcount" :rules="[{ required: true, message: '请输入总量'},{ pattern:/^[0-9]*$/,message:'请输入正数字',trigger:'blur'}]">
|
|
|
|
|
+ <a-input v-model:value="form.totalcount" placeholder="请输入总量"></a-input>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ <a-col :span="24">
|
|
|
|
|
+ <a-form-item label="封面图" name="attinfos" :rules="[{ required: true,message:'请选择图片',trigger: 'blur' }]">
|
|
|
|
|
+ <Upload
|
|
|
|
|
+ :bindData="bindData"
|
|
|
|
|
+ @fileChange="form.attinfos='1';loading=true"
|
|
|
|
|
+ :multiple="false"
|
|
|
|
|
+ accept="image/*"
|
|
|
|
|
+ ref="upload"
|
|
|
|
|
+ @uploadSuccess="loading=false"
|
|
|
|
|
+ ></Upload>
|
|
|
|
|
+ <p style="color:#b8b3b3">注:建议上传图片大小130x80像素,大小不超过2M,格式为JPG/PNG</p>
|
|
|
|
|
+ </a-form-item>
|
|
|
|
|
+ </a-col>
|
|
|
|
|
+ </a-row>
|
|
|
|
|
+ </a-form>
|
|
|
|
|
+ <template #extra>
|
|
|
|
|
+ <a-space>
|
|
|
|
|
+ <CustomButton type="primary" @click="submit" :loading="loading">保存</CustomButton>
|
|
|
|
|
+ </a-space>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </a-drawer>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script setup>
|
|
|
|
|
+import dayjs from 'dayjs'
|
|
|
|
|
+import {ref,defineEmits, watch, inject, nextTick} from 'vue'
|
|
|
|
|
+import Api from '@/api/api'
|
|
|
|
|
+import utils from '@/utils/utils'
|
|
|
|
|
+import Upload from '@/MAR/assetsStore/detail/fileUpload.vue'
|
|
|
|
|
+import { useAuthStore } from '@/stores/modules/auth'
|
|
|
|
|
+import { useRouter } from "vue-router";
|
|
|
|
|
+const router = useRouter()
|
|
|
|
|
+const emit = defineEmits(['onSuccess'])
|
|
|
|
|
+const props = defineProps(['rowData'])
|
|
|
|
|
+const visible = ref(false)
|
|
|
|
|
+const form = ref({
|
|
|
|
|
+ "sa_awardid": router.currentRoute.value.query.id,
|
|
|
|
|
+ "sa_awarditemsid": 0,
|
|
|
|
|
+ "sequence": 1,
|
|
|
|
|
+ "name": "",
|
|
|
|
|
+ "price": '',
|
|
|
|
|
+ "percentage": '',
|
|
|
|
|
+ "type": "实物",
|
|
|
|
|
+ "outcount": '',
|
|
|
|
|
+ "totalcount": '',
|
|
|
|
|
+ attinfos:''
|
|
|
|
|
+})
|
|
|
|
|
+let bindData = ref({})
|
|
|
|
|
+let loading = ref()
|
|
|
|
|
+
|
|
|
|
|
+const checkNumber = async (_rule, value) => {
|
|
|
|
|
+ console.log(value)
|
|
|
|
|
+ if (value === '' || value == null) {
|
|
|
|
|
+ return Promise.reject('请输入内容');
|
|
|
|
|
+ } else if(value <=0 || value > 100){
|
|
|
|
|
+ return Promise.reject('数值范围1-100');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Promise.resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+const checkNumber2 = async (_rule, value) => {
|
|
|
|
|
+ console.log(value)
|
|
|
|
|
+ if (value === '' || value == null) {
|
|
|
|
|
+ return Promise.reject('请输入内容');
|
|
|
|
|
+ } else if(value <=0.3){
|
|
|
|
|
+ return Promise.reject('数值必须大于等于0.3');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return Promise.resolve();
|
|
|
|
|
+ }
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const typeChange = () => {
|
|
|
|
|
+ if(form.value.type == '实物') {
|
|
|
|
|
+ form.value.price = ''
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+let upload = ref()
|
|
|
|
|
+const showDrawer = async ()=>{
|
|
|
|
|
+ form.value = Object.assign({},form.value,props.rowData)
|
|
|
|
|
+ form.value.attinfos = utils.fileList(form.value.attinfos)
|
|
|
|
|
+ form.value.percentage = form.value.percentage * 100
|
|
|
|
|
+ bindData.value = {ownerid:form.value.sa_awarditemsid,ownertable:'sa_awarditems',usetype:'default'}
|
|
|
|
|
+ visible.value = true
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ upload.value.fileList = form.value.attinfos
|
|
|
|
|
+ })
|
|
|
|
|
+ console.log(form.value,props.rowData);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const formRef = ref()
|
|
|
|
|
+const submit = async ()=>{
|
|
|
|
|
+ try {
|
|
|
|
|
+ console.log(form.value)
|
|
|
|
|
+ loading.value = true
|
|
|
|
|
+ const values = await formRef.value.validateFields();
|
|
|
|
|
+ form.value.percentage = form.value.percentage/100
|
|
|
|
|
+ const res = await Api.requested({
|
|
|
|
|
+ "id":"20240514131202",
|
|
|
|
|
+ "content":form.value
|
|
|
|
|
+ })
|
|
|
|
|
+ utils.message(res,'操作成功',() => {
|
|
|
|
|
+ visible.value = false
|
|
|
|
|
+ refresh()
|
|
|
|
|
+ upload.value.refresh()
|
|
|
|
|
+ emit('onSuccess')
|
|
|
|
|
+ loading.value = false
|
|
|
|
|
+ })
|
|
|
|
|
+ } catch (errorInfo) {
|
|
|
|
|
+ console.log('Failed:', errorInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+const refresh = () => {
|
|
|
|
|
+ form.value = {
|
|
|
|
|
+ "sa_awardid": router.currentRoute.value.query.id,
|
|
|
|
|
+ "sa_awarditemsid": 0,
|
|
|
|
|
+ "sequence": 1,
|
|
|
|
|
+ "name": "",
|
|
|
|
|
+ "price": '',
|
|
|
|
|
+ "percentage": '',
|
|
|
|
|
+ "type": "实物",
|
|
|
|
|
+ "outcount": '',
|
|
|
|
|
+ "totalcount": ''
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+</script>
|
|
|
|
|
+<style scoped>
|
|
|
|
|
+.ant-picker {
|
|
|
|
|
+ width: 100%;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|