lhl 1 year ago
parent
commit
fe9738d8dc

+ 20 - 0
src/api/marketing.js

@@ -1361,4 +1361,24 @@ export function searchServe(id) {
         url: `/service/getServiceProject/${id}`,
         method: 'post'
     });
+}
+
+/**
+ * 获取服务卡详情
+ * @param {*} id
+ * @returns
+ */
+export function serveReadApi(id) {
+	return request({
+	    url: `/service/read/${id}`,
+	    method: 'get'
+	});
+}
+
+//productDelete
+export function serveProductDeleteApi(id) {
+	return request({
+	    url: `/service/productDelete/${id}`,
+	    method: 'DELETE'
+	});
 }

+ 99 - 48
src/pages/marketing/serve/bind.vue

@@ -15,29 +15,27 @@
 		</div>
 		<Card :bordered="false" dis-hover class="ivu-mt"  >
 			<div v-for="(item,index) in formData" class="product-item">
-				<Button type="primary" class="submission" @click="delNewProject(index)" >删除</Button>
+				<Button type="primary" class="submission" @click="delNewProject(index,item)" >删除</Button>
 				<Form   :model="item" :label-width="150" >
 					<FormItem label="选择商品:" prop="product_id" required>
 					    <div class="picBox" @click="changeGoods(item)">
 							<Button type="primary" v-if="!item.product_id">选择商品</Button>
 					        <div class="" v-else>
-								{{item.product_name}}
+								{{item.store_name}}
 					        </div>
 					    </div>
 					</FormItem>
 					<FormItem label="业绩值" required>
-						<Input v-model="item.performance_value" v-width="320" placeholder="请输入业绩值"></Input>
+						<Input  v-model="item.performance_value" v-width="320"></Input>
 					</FormItem>
 					<FormItem label="手工费" required>
-						<InputNumber  v-model="item.craft_price" v-width="320"></InputNumber>
+						<Input  v-model="item.craft_price" v-width="320"></Input>
 					</FormItem>
 					<FormItem label="销售提成" required>
-						<InputNumber  v-model="item.sales_commissions" v-width="320"></InputNumber>
-						</InputNumber>
+						<Input  v-model="item.sales_commissions" v-width="320"></Input>
 					</FormItem>
 					<FormItem label="库存量" required>
 						<InputNumber  v-model="item.repertory" v-width="320"></InputNumber>
-						</InputNumber>
 					</FormItem>
 				</Form>
 			</div>
@@ -49,8 +47,8 @@
 		    <goods-list ref="goodslist" :goodsType="1" v-if="modals" @getProductId="getProductId"></goods-list>
 		</Modal>
 		<div style="width: 500px; display: flex;justify-content: center;">
-			<Button  type="primary" class="submission" @click="addNewProject" >添加新项目</Button>
-			<Button  type="primary" class="submission" @click="save" :disabled="disabled">立即创建</Button>
+			<Button  type="primary bom" class="submission" @click="addNewProject" >添加新项目</Button>
+			<Button  type="primary" class="submission" @click="save" :disabled="disabled">保存</Button>
 		</div>
 	</div>
 </template>
@@ -68,7 +66,9 @@
 		VipEditApi,
 		serveAddApi,
 		bindServe,
-		searchServe
+		addServiceProject,
+		serveReadApi,
+		serveProductDeleteApi
 	} from "@/api/marketing";
 	import {
 		brandList
@@ -98,12 +98,15 @@
 				disabled: false,
 				storesList: [],
 				formData: [{
-					product_name: '',
+					id: 0,
+					service_card_id: 0,
 					product_id: 0,
-					performance_value: 0,
-					craft_price: 0,
-					sales_commissions: 0,
-					repertory: 0
+					store_name: '',
+					slider_image: '',
+					performance_value: '',
+					craft_price: '',
+					sales_commissions: '',
+					repertory: 0,
 				}],
 				isMinPrice: 0,
 				isCouponTime: 1,
@@ -114,6 +117,7 @@
 				storeModals: false,
 				currentTab: '1',
 				current: {},
+				service_card_id: '',
 			};
 		},
 		computed: {
@@ -122,28 +126,29 @@
 		created() {
 			console.log(this.$route.query);
 			if (this.$route.query.id) {
-				this.id = this.$route.query.id
-				console.log(this.id,'this.id');
+				this.service_card_id = this.$route.query.id
+				this.formData[0].service_card_id = this.$route.query.id
 				this.getCouponDetail();
 			}
 		},
 		methods: {
 			getCouponDetail() {
-				// console.log();
-				searchServe(this.id).then(res => {
-					let arr = []
-					res.data.list.forEach(item => {
-						let data = {
-							product_name: item.store_name,
-							product_id: item.id,
-							performance_value: item.performance_value || 0,
-							craft_price: item.craft_price || 0,
-							sales_commissions: item.sales_commissions || 0,
-							repertory:item.repertory
-						}
-						arr.push(data)
-					})
-					this.formData = arr
+				let that = this
+				serveReadApi(that.service_card_id).then(res => {
+					that.formData = res.data.info.storeInfo.project
+					if(that.formData.length == 0) {
+						that.formData = [{
+							id: 0,
+							service_card_id: that.service_card_id,
+							product_id: 0,
+							store_name: '',
+							slider_image: '',
+							performance_value: '',
+							craft_price: '',
+							sales_commissions: '',
+							repertory: 0,
+						}]
+					}
 				})
 			},
 			// 选择商品
@@ -153,14 +158,18 @@
 			},
 			addNewProject() {
 				console.log('dddddddddddddddddd');
+				let that = this
 				try{
 					this.formData.push({
-					product_name: '',
+					service_card_id: that.service_card_id,
+					id: 0,
 					product_id: 0,
-					performance_value: 0,
-					craft_price: 0,
-					sales_commissions: 0,
-					repertory: 0
+					store_name: '',
+					slider_image: '',
+					performance_value: '',
+					craft_price: '',
+					sales_commissions: '',
+					repertory: 0,
 				})
 					// this.formData.concat(this.baseForm)
 					console.log(this.formData);
@@ -169,8 +178,46 @@
 					//TODO handle the exception
 				}
 			},
-			delNewProject(index) {
-				this.formData.splice(index,1)
+			delNewProject(index,item) {
+				let that = this
+				if(item.id) {
+					try{
+						let delfromData = {
+						    title: '删除服务项目',
+						    url: `service/productDelete/${item.id}`,
+						    method: 'DELETE',
+						    ids: ''
+						};
+						this.$modalSure(delfromData).then((res) => {
+						    that.$Message.success(res.msg);
+						   that.formData.splice(index,1)
+						}).catch(res => {
+						    that.$Message.error(res.msg);
+						});
+					}catch(e){
+						//TODO handle the exception
+						console.log(e,'错误');
+					}
+					
+					// serveProductDeleteApi(item.id).then(res => {
+					// 	this.formData.splice(index,1)
+					// })
+				}else {
+					this.formData.splice(index,1)
+				}
+				if(that.formData.length == 0) {
+					that.formData = [{
+						id: 0,
+						service_card_id: that.service_card_id,
+						product_id: 0,
+						store_name: '',
+						slider_image: '',
+						performance_value: '',
+						craft_price: '',
+						sales_commissions: '',
+						repertory: 0,
+					}]
+				}
 			},
 			// 商品id
 			getProductId(row) {
@@ -179,7 +226,8 @@
 			    this.modals = false;
 			    setTimeout(() => {
 					this.current.product_id = row.id
-					this.current.product_name = row.store_name
+					this.current.store_name = row.store_name
+					this.current.slider_image = row.image
 					// this.formData.image = row.image
 			    }, 500);
 			},
@@ -198,19 +246,19 @@
 			save() {
 				// this.downTab();
 				// console.log('这');
-				console.log(this.id);
-				bindServe(this.id,this.formData)
+				bindServe(this.service_card_id,{item: this.formData})
 					.then((res) => {
 						this.disabled = true;
 						this.$Message.success(res.msg);
-						// setTimeout(() => {
-						// 	this.$router.push({
-						// 		path: this.roterPre + "/marketing/serve/index",
-						// 	});
-						// }, 1000);
+						setTimeout(() => {
+							this.$router.push({
+								path: this.roterPre + "/marketing/serve/index",
+							});
+						}, 1000);
 					})
 					.catch((err) => {
 						this.$Message.error(err.msg);
+						this.disabled = false;
 					});
 			},
 			// 使用有效期--时间段
@@ -455,7 +503,10 @@
 		padding: 20px
 		.submission {
 			// display: block;
-			margin-left: 500px; 
+			margin-left: 500px;
 		}
 	}
+	.bom {
+		margin-right: 20px
+	}
 </style>

+ 81 - 21
src/pages/marketing/serve/create.vue

@@ -15,6 +15,17 @@
 		</div>
 		<Card :bordered="false" dis-hover class="ivu-mt">
 			<Form :model="formData" :label-width="150">
+				<FormItem label="选择商品:" required>
+				    <div class="picBox" @click="changeGoods()">
+						<Button type="primary" v-if="!formData.product_id">选择商品</Button>
+				        <div class="" v-if="formData.product_id && !formData.id">
+							{{formData.product_name}}
+				        </div>
+						<Button type="primary" v-if="formData.product_id && formData.id">
+							切换商品
+						</Button>
+				    </div>
+				</FormItem>
 				<FormItem label="服务卡名称" required>
 					<Input v-model="formData.card_name" v-width="320" placeholder="请输入服务卡名称"></Input>
 				</FormItem>
@@ -24,14 +35,22 @@
 				<FormItem label="库存" required>
 					<InputNumber :min="1" :max="100000000" v-model="formData.repertory" v-width="320"></InputNumber>
 					</InputNumber>
-					<span class="ml10">%</span>
 				</FormItem>
-
+				<!-- explain -->
+				<FormItem label="备注">
+					<Input v-model="formData.explain" v-width="320" placeholder=""></Input>
+				</FormItem>
 			</Form>
 			<div style="width: 500px; display: flex;justify-content: center;">
-				<Button  type="primary" class="submission" @click="save" :disabled="disabled">立即创建</Button>
+				<Button  type="primary" class="submission" @click="save" :disabled="disabled" v-if="!formData.id">立即创建</Button>
+				<Button  type="primary" class="submission" @click="save" :disabled="disabled" v-else>立即修改</Button>
 			</div>
 		</Card>
+		<!-- 选择商品-->
+		<Modal v-model="modals" title="商品列表" footerHide class="paymentFooter" scrollable width="900"
+		    @on-cancel="cancel">
+		    <goods-list ref="goodslist" :goodsType="1" v-if="modals" @getProductId="getProductId"></goods-list>
+		</Modal>
 	</div>
 </template>
 
@@ -46,7 +65,8 @@
 		couponSaveApi,
 		couponDetailApi,
 		VipEditApi,
-		serveAddApi
+		serveAddApi,
+		serveReadApi
 	} from "@/api/marketing";
 	import {
 		brandList
@@ -66,9 +86,16 @@
 				disabled: false,
 				storesList: [],
 				formData: {
+					id: '',
+					product_name: '',
+					product_id: 0,
 					card_name: '',
 					repertory: '',
-					card_price: ''
+					card_price: '',
+					explain: '',
+					unit_name: '',
+					image: '',
+					images: ''
 				},
 				isMinPrice: 0,
 				isCouponTime: 1,
@@ -84,12 +111,39 @@
 			...mapState("admin/layout", ["isMobile", "menuCollapse"]),
 		},
 		created() {
-			if (this.$route.params.id) {
-				this.id = this.$route.params.id
-				// this.getCouponDetail();
+			if (this.$route.query.id) {
+				this.id = this.$route.query.id
+				this.getDetail();
 			}
 		},
 		methods: {
+			// 商品id
+			getProductId(row) {
+				console.log(row,'这个');
+			    this.modal_loading = false;
+			    this.modals = false;
+			    setTimeout(() => {
+					this.formData.product_id = row.id
+					this.formData.product_name = row.store_name
+					this.formData.card_price = row.price
+					this.formData = {
+						product_name: row.store_name,
+						product_id: row.id,
+						card_name: row.store_name,
+						card_price: row.price,
+						explain: '',
+						unit_name: row.unit_name,
+						image: row.image,
+						images: row.slider_image,
+						is_show: 1
+					}
+					// this.formData.image = row.image
+			    }, 500);
+			},
+			// 选择商品
+			changeGoods() {
+			    this.modals = true;
+			},
 			downTab() {
 				if (!this.formData.card_name) {
 					return this.$Message.error("请输入服务卡名称");
@@ -136,19 +190,6 @@
 					(arr) => !res.has(arr.product_id) && res.set(arr.product_id, 1)
 				);
 			},
-			// 选择的商品
-			getProductId(productList) {
-				this.modals = false;
-				this.productList = this.unique(this.productList.concat(productList));
-				this.formData.product_id = "";
-				this.productList.forEach((value) => {
-					if (this.formData.product_id) {
-						this.formData.product_id += `,${value.product_id}`;
-					} else {
-						this.formData.product_id += `${value.product_id}`;
-					}
-				});
-			},
 			cancel() {
 				this.modals = false;
 			},
@@ -168,6 +209,25 @@
 					}
 				});
 			},
+			// 获取详情
+			getDetail() {
+				serveReadApi(this.id).then(res => {
+					console.log(res);
+					let row = res.data.info.storeInfo
+					this.formData = {
+						id: row.id,
+						product_id: row.id,
+						card_name: row.card_name,
+						card_price: row.card_price,
+						explain: row.explain,
+						unit_name: row.unit_name,
+						image: row.image,
+						images: row.slider_image,
+						repertory: row.repertory,
+						is_show: 1
+					}
+				})
+			}
 		},
 	};
 </script>

+ 18 - 15
src/pages/marketing/serve/index.vue

@@ -6,15 +6,15 @@
 				
 				<Form ref="tableFrom" inline :model="tableFrom" :label-width="labelWidth"
 					:label-position="labelPosition" @submit.native.prevent>
-					<FormItem label="是否显示:" label-for="is_show">
-						<Select v-model="tableFrom.is_show" placeholder="请选择" clearable @on-change="userSearchs"
+					<FormItem label="是否删除:" label-for="is_show">
+						<Select v-model="tableFrom.is_del" placeholder="请选择" clearable @on-change="userSearchs"
 							class="input-add">
-							<Option :value="1">显示</Option>
-							<Option :value="0">隐藏</Option>
+							<Option :value="0">正常</Option>
+							<Option :value="1">已删除</Option>
 						</Select>
 					</FormItem>
 					<FormItem label="服务卡名称:" label-for="coupon_title">
-						<Input v-model="tableFrom.field_key" placeholder="请输入服务卡名称名称" @on-search="userSearchs"
+						<Input v-model="tableFrom.key" placeholder="请输入服务卡名称名称" @on-search="userSearchs"
 							class="input-add mr14" />
 						<Button type="primary" @click="orderSearch()" class="mr14">查询</Button>
 					</FormItem>
@@ -49,7 +49,7 @@
 					<span> {{row.is_show == 1 ?'显示': '隐藏'}}</span>
 				</template>
 				<template slot-scope="{ row, index }" slot="add_time">
-					<span> {{row.add_time | formatDate}}</span>
+					<span> {{row.add_time }}</span>
 				</template>
 				<template slot-scope="{ row, index }" slot="action">
 					<a @click="bind(row)">绑定项目</a>
@@ -122,7 +122,7 @@
 					},
 					{
 						title: '售价',
-						key: 'card_name',
+						key: 'card_price',
 						minWidth: 80
 					},
 					{
@@ -135,14 +135,14 @@
 						key: 'sales_volume',
 						minWidth: 100
 					},
-					{
-						title: '是否显示',
-						slot: 'is_show',
-						minWidth: 100
-					},
+					// {
+					// 	title: '是否显示',
+					// 	slot: 'is_show',
+					// 	minWidth: 100
+					// },
 					{
 						title: '备注',
-						key: 'mark',
+						key: 'explain',
 						minWidth: 100
 					},
 					{
@@ -161,7 +161,8 @@
 					is_show: 1,
 					field_key: '',
 					page: 1,
-					limit: 15
+					limit: 15,
+					is_del: 0
 				},
 				tableList: [],
 				total: 0,
@@ -207,7 +208,9 @@
 			},
 			// 发布
 			couponSend(row) {
-				this.$modalForm(serveEditApi(row.id)).then(() => this.getList());
+				// this.$modalForm(serveEditApi(row.id)).then(() => this.getList());
+				this.$router.push({path: this.roterPre + "/marketing/serve/create?id=" + row.id});
+				console.log(row);
 			},
 			// 删除
 			couponDel(row, tit, num) {