|
@@ -3,7 +3,7 @@
|
|
|
<BaseDialog
|
|
|
width="800px"
|
|
|
:isShow.sync="isShow"
|
|
|
- :title="activeData.id ? '修改' : '新增'"
|
|
|
+ :title="goodsId ? '修改' : '新增'"
|
|
|
@submit="submitForm"
|
|
|
@close="close"
|
|
|
>
|
|
@@ -84,10 +84,7 @@
|
|
|
v-for="(item, index) in formData.mainImg"
|
|
|
:key="index"
|
|
|
>
|
|
|
- <i
|
|
|
- class="el-icon-error del"
|
|
|
- @click="formData.mainImg.splice(index, 1)"
|
|
|
- ></i>
|
|
|
+ <i class="el-icon-error del" @click="delImg(index)"></i>
|
|
|
<el-image
|
|
|
style="width: 90px; height: 90px"
|
|
|
:src="$methodsTools.splitImgHost(item)"
|
|
@@ -125,46 +122,31 @@
|
|
|
:min="0"
|
|
|
:precision="2"
|
|
|
/> </el-form-item
|
|
|
- ><el-form-item label="可抵扣积分:" prop="e">
|
|
|
+ ><el-form-item label="可抵扣积分:" prop="integral">
|
|
|
<el-input-number
|
|
|
+ :disabled="true"
|
|
|
:controls="false"
|
|
|
- v-model="formData.e"
|
|
|
+ v-model="formData.integral"
|
|
|
placeholder="输入可抵扣积分"
|
|
|
:min="0"
|
|
|
:precision="0" /></el-form-item
|
|
|
- ><el-form-item label="状态:" prop="status">
|
|
|
+ ><el-form-item label="是否上架:" prop="goodsStatus">
|
|
|
+ <el-radio-group v-model="formData.goodsStatus">
|
|
|
+ <el-radio :label="1">是</el-radio><el-radio :label="0">否</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="状态:" prop="status">
|
|
|
<el-radio-group v-model="formData.status">
|
|
|
<el-radio :label="1">启用</el-radio
|
|
|
><el-radio :label="0">禁用</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="商品详情:">
|
|
|
- <div style="margin-bottom: 14px">
|
|
|
- <el-button
|
|
|
- size="small"
|
|
|
- @click="mobileDetailStatus = 1"
|
|
|
- :type="mobileDetailStatus === 1 ? 'primary' : ''"
|
|
|
- >手机端</el-button
|
|
|
- >
|
|
|
- <el-button
|
|
|
- size="small"
|
|
|
- @click="mobileDetailStatus = 2"
|
|
|
- :type="mobileDetailStatus === 2 ? 'primary' : ''"
|
|
|
- >电脑端</el-button
|
|
|
- >
|
|
|
- </div>
|
|
|
<editor
|
|
|
- v-show="mobileDetailStatus === 1"
|
|
|
v-model="formData.mobileDetailHtml"
|
|
|
:min-height="300"
|
|
|
:max-height="500"
|
|
|
:uploadStatus="2"
|
|
|
- /><editor
|
|
|
- v-show="mobileDetailStatus === 2"
|
|
|
- v-model="formData.pcDetailHtml"
|
|
|
- :min-height="300"
|
|
|
- :max-height="500"
|
|
|
- :uploadStatus="2"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
@@ -183,54 +165,88 @@ export default {
|
|
|
type: Boolean,
|
|
|
default: false,
|
|
|
},
|
|
|
- activeData: {
|
|
|
- type: Object,
|
|
|
- default: () => {
|
|
|
- return {};
|
|
|
- },
|
|
|
+ goodsId: {
|
|
|
+ type: Number,
|
|
|
+ default: 0,
|
|
|
+ },
|
|
|
+ getRules: {
|
|
|
+ type: Number,
|
|
|
+ default: 0,
|
|
|
},
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- categoryIdsList: [
|
|
|
- {
|
|
|
- label: "技术类",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- label: "理疗类",
|
|
|
- value: 2,
|
|
|
- },
|
|
|
- ],
|
|
|
formData: {
|
|
|
useType: [],
|
|
|
merId: "",
|
|
|
storeId: "",
|
|
|
categoryIds: "",
|
|
|
- accountList: [{}],
|
|
|
- invoiceBo: {},
|
|
|
- storeId: null,
|
|
|
+ mainImg: [],
|
|
|
status: 1,
|
|
|
+ goodsStatus: 1,
|
|
|
},
|
|
|
- mobileDetailStatus: 1,
|
|
|
rules: {
|
|
|
+ goodsName: [
|
|
|
+ { required: true, message: "请输入商品名称", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ standPrice: [
|
|
|
+ { required: true, message: "请输入商品原价", trigger: "blur" },
|
|
|
+ ],
|
|
|
+ specialPrice: [
|
|
|
+ { required: true, message: "请输入会员优惠价", trigger: "blur" },
|
|
|
+ ],
|
|
|
useType: [
|
|
|
{ required: true, message: "请选择关联使用", trigger: "change" },
|
|
|
],
|
|
|
merId: [
|
|
|
{ required: true, message: "请选择合作商户", trigger: "change" },
|
|
|
],
|
|
|
+ mainImg: [
|
|
|
+ { required: true, message: "请上传商品主图", trigger: "change" },
|
|
|
+ ],
|
|
|
storeId: [
|
|
|
{ required: true, message: "请选择商户店铺", trigger: "change" },
|
|
|
],
|
|
|
categoryIds: [
|
|
|
{ required: true, message: "请选择商品分类", trigger: "change" },
|
|
|
],
|
|
|
- status: [{ required: true, message: "请选择状态", trigger: "change" }],
|
|
|
+ goodsStatus: [
|
|
|
+ { required: true, message: "请选择是否上架", trigger: "change" },
|
|
|
+ ],
|
|
|
+ status: [
|
|
|
+ { required: true, message: "请选择商品状态", trigger: "change" },
|
|
|
+ ],
|
|
|
},
|
|
|
};
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ "formData.standPrice"(newVal) {
|
|
|
+ if ((newVal || 0) && this.formData.specialPrice) {
|
|
|
+ var integral =
|
|
|
+ parseInt(
|
|
|
+ parseFloat(newVal) - parseFloat(this.formData.specialPrice)
|
|
|
+ ) * this.getRules;
|
|
|
+ this.$set(this.formData, "integral", integral);
|
|
|
+ } else {
|
|
|
+ this.$set(this.formData, "integral", 0);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "formData.specialPrice"(newVal) {
|
|
|
+ if ((newVal || newVal == 0) && this.formData.standPrice) {
|
|
|
+ var integral =
|
|
|
+ parseInt(parseFloat(this.formData.standPrice) - parseFloat(newVal)) *
|
|
|
+ this.getRules;
|
|
|
+ this.$set(this.formData, "integral", integral);
|
|
|
+ } else {
|
|
|
+ this.$set(this.formData, "integral", 0);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ delImg(index) {
|
|
|
+ this.formData.mainImg.splice(index, 1);
|
|
|
+ this.$refs["formData"].validateField("mainImg");
|
|
|
+ },
|
|
|
changeMerId(e) {
|
|
|
this.$set(this.formData, "storeId", null);
|
|
|
},
|
|
@@ -252,23 +268,32 @@ export default {
|
|
|
this.$upload
|
|
|
.upload(file, 0)
|
|
|
.then((res) => {
|
|
|
- self.formData.urls.push(res);
|
|
|
+ self.formData.mainImg.push(res);
|
|
|
+ this.$refs["formData"].validateField("mainImg");
|
|
|
})
|
|
|
.finally(() => {
|
|
|
e.target.value = "";
|
|
|
});
|
|
|
},
|
|
|
init() {
|
|
|
- this.formData = {
|
|
|
- useType:[],
|
|
|
- merId: "",
|
|
|
- storeId: "",
|
|
|
- categoryIds: "",
|
|
|
- accountList: [{}],
|
|
|
- invoiceBo: {},
|
|
|
- storeId: null,
|
|
|
- status: 1,
|
|
|
- };
|
|
|
+ if (this.goodsId) {
|
|
|
+ this.$api.obtainGoods(this.goodsId).then((res) => {
|
|
|
+ res.data.mainImg = res.data.mainImg?.split(",") || [];
|
|
|
+ res.data.useType = res.data.useType?.split(",").map(Number) || [];
|
|
|
+ res.data.categoryIds = parseInt(res.data.categoryIds);
|
|
|
+ this.formData = res.data;
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.formData = {
|
|
|
+ useType: [],
|
|
|
+ merId: "",
|
|
|
+ storeId: "",
|
|
|
+ categoryIds: "",
|
|
|
+ mainImg: [],
|
|
|
+ status: 1,
|
|
|
+ goodsStatus: 1,
|
|
|
+ };
|
|
|
+ }
|
|
|
},
|
|
|
close() {
|
|
|
this.$refs["formData"].resetFields();
|
|
@@ -276,9 +301,16 @@ export default {
|
|
|
submitForm() {
|
|
|
this.$refs["formData"].validate((valid) => {
|
|
|
if (valid) {
|
|
|
- this.$message.success("成功");
|
|
|
- this.isShow = false;
|
|
|
- this.$emit("search");
|
|
|
+ var data = JSON.parse(JSON.stringify(this.formData));
|
|
|
+ data.mainImg = data.mainImg.toString();
|
|
|
+ data.useType = data.useType.toString();
|
|
|
+ this.$api[
|
|
|
+ this.formData.goodsId ? "editgoodspoints" : "addgoodspoints"
|
|
|
+ ](data).then((res) => {
|
|
|
+ this.$message.success("操作成功");
|
|
|
+ this.isShow = false;
|
|
|
+ this.$emit("search");
|
|
|
+ });
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|