|
|
<template>
|
|
|
<view>
|
|
|
<kevyloading v-if="loading" type="bsm-loader" color="#618af8" transparent></kevyloading>
|
|
|
|
|
|
<wd-form v-if="!loading" :model="form" :rules="rules" :disabled="mode == 'show'" ref="dialogForm" label-width="100px">
|
|
|
<wd-form-item label="折扣名称" prop="name">
|
|
|
<wd-input placeholder="请输入折扣名称" v-model="dataForm.name" clearable style="width: 100%"></wd-input>
|
|
|
</wd-form-item>
|
|
|
|
|
|
<wd-form-item label="满减数量" prop="full_discount">
|
|
|
<wd-input type="number" placeholder="请输入折扣比例" step="1" v-model.number="dataForm.full_discount" clearable
|
|
|
style="width: 100%"></wd-input>
|
|
|
</wd-form-item>
|
|
|
|
|
|
<wd-form-item label="折扣比例" prop="discount">
|
|
|
<wd-input type="number" placeholder="请输入折扣比例" step="1" v-model.number="dataForm.discount" clearable
|
|
|
style="width: 100%"></wd-input>
|
|
|
|
|
|
<div style="color: #666;font-size: 12px;">
|
|
|
如商品单价100,折扣比例40 (4折),仅需付40元
|
|
|
</div>
|
|
|
</wd-form-item>
|
|
|
|
|
|
<!-- 是否启用 -->
|
|
|
<wd-form-item label="是否启用:" prop="status">
|
|
|
<wd-switch v-model="dataForm.status" :active-value="1" :inactive-value="0"></wd-switch>
|
|
|
</wd-form-item>
|
|
|
|
|
|
<!-- 提交按钮 -->
|
|
|
<view class="mt-2 px-12 py-3 bg-slate-50">
|
|
|
<wd-button type="primary" size="large" @click="handleSubmit" block>
|
|
|
保存
|
|
|
</wd-button>
|
|
|
</view>
|
|
|
|
|
|
</wd-form>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
import yGoods from "@/components/yGoods/index.vue";
|
|
|
import uniDataPicker from "@/components/uni-data-picker/components/uni-data-picker/uni-data-picker.vue";
|
|
|
import kevyloading from "@/components/kevy-loading/kevy-loading";
|
|
|
import utils from '@/utils/utils.js'
|
|
|
import { useApi } from "@/hooks/useApi.js"
|
|
|
import discountApi from '@/api/mall/discount.js';
|
|
|
import yUpload from "@/components/yUpload/index.vue";
|
|
|
|
|
|
console.log(yGoods);
|
|
|
|
|
|
/**
|
|
|
* 从本地存储中获取用户信息
|
|
|
*/
|
|
|
const user_info = uni.getStorageSync("user_info");
|
|
|
|
|
|
export default {
|
|
|
components: {
|
|
|
yGoods, uniDataPicker, kevyloading, yUpload
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
utils,
|
|
|
user_info,
|
|
|
// 表单数据
|
|
|
dataForm: {
|
|
|
"id": 0,
|
|
|
},
|
|
|
columns: [],
|
|
|
loading: false
|
|
|
};
|
|
|
},
|
|
|
onLoad(e) {
|
|
|
if (e.id) {
|
|
|
|
|
|
this.getData(e.id)
|
|
|
|
|
|
// this.dataForm = JSON.parse(e.edit)
|
|
|
|
|
|
// this.dataForm.start_time = new Date(this.dataForm.start_time * 1000)
|
|
|
// this.dataForm.end_time = new Date(this.dataForm.end_time * 1000)
|
|
|
|
|
|
// console.log(this.dataForm);
|
|
|
} else {
|
|
|
|
|
|
}
|
|
|
|
|
|
for (let index = 1; index <= 100; index++) {
|
|
|
this.columns.push(index)
|
|
|
}
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
async getData(id) {
|
|
|
const { fetchData } = await useApi(discountApi.SalesFullDiscounts.GetItem)
|
|
|
|
|
|
fetchData({ id }).then(res => {
|
|
|
this.dataForm = res.data
|
|
|
})
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 处理省市区选择变化
|
|
|
* @param {Object} value - 选择的值
|
|
|
*/
|
|
|
areaChange(value) {
|
|
|
// 处理省市区选择变化的逻辑
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 处理表单提交
|
|
|
*/
|
|
|
async handleSubmit() {
|
|
|
// 处理表单提交的逻辑
|
|
|
const res = await discountApi.SalesFullDiscounts.Create({
|
|
|
...this.dataForm,
|
|
|
});
|
|
|
|
|
|
if (res.code == 0) {
|
|
|
setTimeout(() => {
|
|
|
uni.showToast({
|
|
|
title: '保存成功!',
|
|
|
icon: 'success'
|
|
|
});
|
|
|
}, 100);
|
|
|
|
|
|
uni.navigateBack()
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
/* 在这里添加样式,根据需要自定义表单样式 */
|
|
|
</style> |