|
@@ -9,65 +9,68 @@
|
|
|
<span class="pl10">返回</span>
|
|
|
</div>
|
|
|
</router-link>
|
|
|
- <span v-text="$route.params.id ? '编辑服务卡' : '添加服务卡'" class="mr20 ml16"></span>
|
|
|
+ <span v-text="'绑定项目'" class="mr20 ml16"></span>
|
|
|
</div>
|
|
|
</PageHeader>
|
|
|
</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,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>
|
|
|
- <template v-else>
|
|
|
- <viewer>
|
|
|
- <img class="product_img" :src="item.slider_image" alt="" />
|
|
|
- </viewer>
|
|
|
- <div class="">
|
|
|
- {{item.store_name}}
|
|
|
- </div>
|
|
|
- <div class="">
|
|
|
- 商品原价: {{ showPrice(item.product_id).price }} 元
|
|
|
- </div>
|
|
|
- <div class="">
|
|
|
- 商品ID:{{item.product_id}}
|
|
|
- </div>
|
|
|
- <Button type="primary" >切换服务项目</Button>
|
|
|
- </template>
|
|
|
- </div>
|
|
|
- <div></div>
|
|
|
- </FormItem>
|
|
|
- <!-- <FormItem label="业绩值" required>
|
|
|
- <Input v-model="item.performance_value" v-width="320"></Input>
|
|
|
- </FormItem>
|
|
|
- <FormItem label="手工费" required>
|
|
|
- <Input v-model="item.craft_price" v-width="320"></Input>
|
|
|
- </FormItem>
|
|
|
- <FormItem label="销售提成" required>
|
|
|
- <Input v-model="item.sales_commissions" v-width="320"></Input>
|
|
|
- </FormItem> -->
|
|
|
- <FormItem label="次数" required>
|
|
|
- <InputNumber v-model="item.repertory" v-width="320"></InputNumber>
|
|
|
- </FormItem>
|
|
|
- </Form>
|
|
|
- <!-- <div class="" v-if="item.repertory">
|
|
|
- 合计:业绩值:{{item.performance_value * item.repertory || 0 }} 手工费:{{item.craft_price *item.repertory || 0}} 销售提成:{{item.sales_commissions * item.repertory || 0}}
|
|
|
- </div> -->
|
|
|
+ <Card :bordered="false" dis-hover class="ivu-mt">
|
|
|
+ <div class="flex-box">
|
|
|
+ <div v-for="(item,index) in formData" class="product-item">
|
|
|
+ <Form :model="item" :label-width="100">
|
|
|
+ <FormItem label="服务项目" prop="product_id" required>
|
|
|
+ <div class="picBox" >
|
|
|
+ <Button type="primary" @click="changeGoods(item)" v-if="!item.product_id">选择服务项目</Button>
|
|
|
+ <template v-else>
|
|
|
+ <viewer>
|
|
|
+ <img class="product_img" :src="item.slider_image" alt="" />
|
|
|
+ </viewer>
|
|
|
+ <div class="">
|
|
|
+ {{item.store_name}}
|
|
|
+ </div>
|
|
|
+ <div class="">
|
|
|
+ 商品原价: {{ item.craft_price }} 元
|
|
|
+ </div>
|
|
|
+ <div class="">
|
|
|
+ 商品ID:{{item.product_id}}
|
|
|
+ </div>
|
|
|
+ <Button type="primary" @click="changeGoods(item)">切换服务项目</Button>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
+ <div></div>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="服务类型" required>
|
|
|
+ <Select v-model="item.type" placeholder="请选择" clearable v-width="320">
|
|
|
+ <Option :value="1">一次性</Option>
|
|
|
+ <Option :value="2">每月发放</Option>
|
|
|
+ </Select>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="发放月数" required v-if="item.type==2">
|
|
|
+ <Input v-model="item.month" v-width="320" placeholder=""></Input>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="每月张数" required v-if="item.type==2">
|
|
|
+ <InputNumber v-model="item.num" v-width="320"></InputNumber>
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="总次数" required v-if="item.type==2">
|
|
|
+ {{item.month*item.num}}
|
|
|
+ </FormItem>
|
|
|
+ <FormItem label="服务次数" required v-if="item.type==1">
|
|
|
+ <InputNumber v-model="item.repertory" v-width="320"></InputNumber>
|
|
|
+ </FormItem>
|
|
|
+ </Form>
|
|
|
+ <Button type="error" long @click="delNewProject(index,item)">删除</Button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <!-- <div class="heji">
|
|
|
- 总计:业绩值:{{ showAll('performance_value',formData)|| 0}} 手工费:{{showAll('craft_price',formData)|| 0}} 销售提成:{{showAll('sales_commissions',formData)|| 0}}
|
|
|
- </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" :serviceProject="1"></goods-list>
|
|
|
+ @on-cancel="cancel">
|
|
|
+ <goods-list ref="goodslist" :goodsType="1" v-if="modals" @getProductId="getProductId"
|
|
|
+ :serviceProject="1"></goods-list>
|
|
|
</Modal>
|
|
|
- <div style="width: 500px; display: flex;justify-content: center;">
|
|
|
- <Button type="primary bom" class="submission" @click="addNewProject" >添加新项目</Button>
|
|
|
- <Button type="primary" class="submission" @click="save" :disabled="disabled">保存</Button>
|
|
|
+ <div class="footer-buttom">
|
|
|
+ <Button type="primary" class="submission mr20" @click="addNewProject">添加新项目</Button>
|
|
|
+ <Button type="primary" class="submission" @click="save" :disabled="disabled">保存</Button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -76,227 +79,139 @@
|
|
|
import {
|
|
|
mapState
|
|
|
} from "vuex";
|
|
|
- import storeList from "@/components/storeList";
|
|
|
import goodsList from "@/components/goodsList/index";
|
|
|
import {
|
|
|
- couponCategoryApi,
|
|
|
- couponSaveApi,
|
|
|
- couponDetailApi,
|
|
|
- VipEditApi,
|
|
|
- serveAddApi,
|
|
|
bindServe,
|
|
|
addServiceProject,
|
|
|
serveReadApi,
|
|
|
serveProductDeleteApi
|
|
|
} from "@/api/marketing";
|
|
|
- import {
|
|
|
- brandList,
|
|
|
- changeListApi
|
|
|
- } from "@/api/product";
|
|
|
- // import { formatDate } from '@/utils/validate';
|
|
|
import Setting from "@/setting";
|
|
|
export default {
|
|
|
name: "storeCouponCreate",
|
|
|
components: {
|
|
|
goodsList,
|
|
|
- storeList
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- baseForm: {
|
|
|
- product_name: '',
|
|
|
- product_id: 0,
|
|
|
- performance_value: 0,
|
|
|
- craft_price: 0,
|
|
|
- sales_commissions: 0,
|
|
|
- repertory: 0
|
|
|
- },//基础数据
|
|
|
- modal_loading: false,
|
|
|
- modals: false,
|
|
|
- id: '',
|
|
|
roterPre: Setting.roterPre,
|
|
|
disabled: false,
|
|
|
- storesList: [],
|
|
|
- formData: [{
|
|
|
- id: 0,
|
|
|
- service_card_id: 0,
|
|
|
- product_id: 0,
|
|
|
- store_name: '',
|
|
|
- slider_image: '',
|
|
|
- performance_value: '',
|
|
|
- craft_price: '',
|
|
|
- sales_commissions: '',
|
|
|
- repertory: 0,
|
|
|
- }],
|
|
|
- isMinPrice: 0,
|
|
|
- isCouponTime: 1,
|
|
|
- isReceiveTime: 0,
|
|
|
+ formData: [],
|
|
|
modals: false,
|
|
|
- datetime1: [],
|
|
|
- datetime2: [],
|
|
|
- storeModals: false,
|
|
|
- currentTab: '1',
|
|
|
current: {},
|
|
|
service_card_id: '',
|
|
|
- productList: [],
|
|
|
};
|
|
|
},
|
|
|
- computed: {
|
|
|
- ...mapState("admin/layout", ["isMobile", "menuCollapse"]),
|
|
|
- },
|
|
|
created() {
|
|
|
- this.getProductList()
|
|
|
- console.log(this.$route.query);
|
|
|
if (this.$route.query.id) {
|
|
|
this.service_card_id = this.$route.query.id
|
|
|
- this.formData[0].service_card_id = this.$route.query.id
|
|
|
this.getCouponDetail();
|
|
|
+ } else {
|
|
|
+ this.addNewProject()
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- showPrice(id) {
|
|
|
- let item = this.productList.find(i=> {
|
|
|
- return i.id == id
|
|
|
- })
|
|
|
- if(item) {
|
|
|
- return item
|
|
|
- }else {
|
|
|
- return ''
|
|
|
- }
|
|
|
- },
|
|
|
- getProductList() {
|
|
|
- changeListApi({
|
|
|
- service_project: 1,
|
|
|
- page: 1,
|
|
|
- limit:1000
|
|
|
- }).then(res => {
|
|
|
- this.productList = res.data.list
|
|
|
- })
|
|
|
- },
|
|
|
- showAll(name,list) {
|
|
|
- let num = 0;
|
|
|
- list.forEach(item => {
|
|
|
- if(item.repertory) {
|
|
|
- num += item[name] * item.repertory * 1;
|
|
|
- }
|
|
|
- })
|
|
|
- return num;
|
|
|
- },
|
|
|
getCouponDetail() {
|
|
|
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,
|
|
|
- }]
|
|
|
+ if (res.data.info.storeInfo.project.length>0) {
|
|
|
+ that.formData = res.data.info.storeInfo.project.map(
|
|
|
+ (rs) => {
|
|
|
+ if (rs.type == 2) {
|
|
|
+ rs.num = Math.floor(rs.repertory / rs.month);
|
|
|
+ }
|
|
|
+ return rs
|
|
|
+ }
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ that.addNewProject();
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
// 选择商品
|
|
|
changeGoods(item) {
|
|
|
- this.modals = true;
|
|
|
- this.current = item
|
|
|
+ this.modals = true;
|
|
|
+ this.current = item;
|
|
|
+ console.log(item, 'item');
|
|
|
},
|
|
|
addNewProject() {
|
|
|
- console.log('dddddddddddddddddd');
|
|
|
let that = this
|
|
|
- try{
|
|
|
+ try {
|
|
|
this.formData.push({
|
|
|
- service_card_id: that.service_card_id,
|
|
|
- id: 0,
|
|
|
- product_id: 0,
|
|
|
- store_name: '',
|
|
|
- slider_image: '',
|
|
|
- performance_value: '',
|
|
|
- craft_price: '',
|
|
|
- sales_commissions: '',
|
|
|
- repertory: 0,
|
|
|
- })
|
|
|
+ service_card_id: that.service_card_id,
|
|
|
+ id: 0,
|
|
|
+ product_id: 0,
|
|
|
+ store_name: '',
|
|
|
+ slider_image: '',
|
|
|
+ performance_value: '',
|
|
|
+ craft_price: '',
|
|
|
+ sales_commissions: '',
|
|
|
+ repertory: 0,
|
|
|
+ type: 1,
|
|
|
+ month: 0,
|
|
|
+ num: 1,
|
|
|
+ })
|
|
|
// this.formData.concat(this.baseForm)
|
|
|
console.log(this.formData);
|
|
|
- }catch(e){
|
|
|
+ } catch (e) {
|
|
|
console.log(e);
|
|
|
//TODO handle the exception
|
|
|
}
|
|
|
},
|
|
|
- delNewProject(index,item) {
|
|
|
+ delNewProject(index, item) {
|
|
|
let that = this
|
|
|
- if(item.id) {
|
|
|
- try{
|
|
|
+ if (item.id) {
|
|
|
+ try {
|
|
|
let delfromData = {
|
|
|
- title: '删除服务项目',
|
|
|
- url: `service/productDelete/${item.id}`,
|
|
|
- method: 'DELETE',
|
|
|
- ids: ''
|
|
|
+ title: '删除服务项目',
|
|
|
+ url: `service/productDelete/${item.id}`,
|
|
|
+ method: 'DELETE',
|
|
|
+ ids: ''
|
|
|
};
|
|
|
this.$modalSure(delfromData).then((res) => {
|
|
|
- that.$Message.success(res.msg);
|
|
|
- that.formData.splice(index,1)
|
|
|
+ that.$Message.success(res.msg);
|
|
|
+ that.formData.splice(index, 1)
|
|
|
}).catch(res => {
|
|
|
- that.$Message.error(res.msg);
|
|
|
+ that.$Message.error(res.msg);
|
|
|
});
|
|
|
- }catch(e){
|
|
|
+ } catch (e) {
|
|
|
//TODO handle the exception
|
|
|
- console.log(e,'错误');
|
|
|
+ console.log(e, '错误');
|
|
|
}
|
|
|
-
|
|
|
// serveProductDeleteApi(item.id).then(res => {
|
|
|
// this.formData.splice(index,1)
|
|
|
// })
|
|
|
- }else {
|
|
|
- this.formData.splice(index,1)
|
|
|
+ } else {
|
|
|
+ that.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,
|
|
|
- }]
|
|
|
+ if (that.formData.length == 0) {
|
|
|
+ that.addNewProject();
|
|
|
}
|
|
|
},
|
|
|
// 商品id
|
|
|
getProductId(row) {
|
|
|
- console.log(row,'这个');
|
|
|
- this.modal_loading = false;
|
|
|
- this.modals = false;
|
|
|
- setTimeout(() => {
|
|
|
+ console.log(row, '这个');
|
|
|
+ this.modals = false;
|
|
|
+ setTimeout(() => {
|
|
|
this.current.product_id = row.id
|
|
|
this.current.store_name = row.store_name
|
|
|
this.current.slider_image = row.image
|
|
|
- // this.formData.image = row.image
|
|
|
- }, 500);
|
|
|
- },
|
|
|
- downTab() {
|
|
|
- if (!this.formData.card_name) {
|
|
|
- return this.$Message.error("请输入服务卡名称");
|
|
|
- }
|
|
|
- if (!this.formData.card_price) {
|
|
|
- return this.$Message.error("请输入售价");
|
|
|
- }
|
|
|
- if (!this.formData.repertory) {
|
|
|
- return this.$Message.error("请输入库存");
|
|
|
- }
|
|
|
+ this.current.craft_price = row.price
|
|
|
+ }, 500);
|
|
|
},
|
|
|
// 创建
|
|
|
save() {
|
|
|
- // this.downTab();
|
|
|
- // console.log('这');
|
|
|
- bindServe(this.service_card_id,{item: this.formData})
|
|
|
+ for (let i = 0; i < this.formData.length; i++) {
|
|
|
+ const item = this.formData[i];
|
|
|
+ if (item.type == 2) {
|
|
|
+ item.repertory = Math.floor(item.month * item.num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ bindServe(this.service_card_id, {
|
|
|
+ item: this.formData
|
|
|
+ })
|
|
|
.then((res) => {
|
|
|
this.disabled = true;
|
|
|
this.$Message.success(res.msg);
|
|
@@ -311,68 +226,30 @@
|
|
|
this.disabled = false;
|
|
|
});
|
|
|
},
|
|
|
- // 使用有效期--时间段
|
|
|
- dateChange(time) {
|
|
|
- this.formData.start_use_time = time[0];
|
|
|
- this.formData.end_use_time = time[1];
|
|
|
- },
|
|
|
- // 限时
|
|
|
- timeChange(time) {
|
|
|
- this.formData.start_time = time[0];
|
|
|
- this.formData.end_time = time[1];
|
|
|
- },
|
|
|
- //对象数组去重;
|
|
|
- unique(arr) {
|
|
|
- const res = new Map();
|
|
|
- return arr.filter(
|
|
|
- (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;
|
|
|
},
|
|
|
- // 删除商品
|
|
|
- remove(productId) {
|
|
|
- for (let index = 0; index < this.productList.length; index++) {
|
|
|
- if (this.productList[index].product_id == productId) {
|
|
|
- this.productList.splice(index, 1);
|
|
|
- }
|
|
|
- }
|
|
|
- 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;
|
|
|
- },
|
|
|
-
|
|
|
+
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
<style scoped lang="stylus">
|
|
|
- .product_img{
|
|
|
- width:100px;
|
|
|
- height:100px;
|
|
|
+ .product_img {
|
|
|
+ width: 100px;
|
|
|
+ height: 100px;
|
|
|
+ }
|
|
|
+
|
|
|
+ .footer-buttom {
|
|
|
+ padding: 20px 0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .flex-box {
|
|
|
+ display: flex;
|
|
|
+ justify-content: flex-start;
|
|
|
+ flex-wrap: wrap;
|
|
|
}
|
|
|
+
|
|
|
.tips {
|
|
|
display: inline-bolck;
|
|
|
font-size: 12px;
|
|
@@ -542,27 +419,36 @@
|
|
|
/deep/.vxe-tree-cell {
|
|
|
padding-left: 0 !important;
|
|
|
}
|
|
|
+
|
|
|
.upLoad {
|
|
|
- width: 58px;
|
|
|
- height: 58px;
|
|
|
- line-height: 58px;
|
|
|
- border: 1px dotted rgba(0, 0, 0, 0.1);
|
|
|
- border-radius: 4px;
|
|
|
- background: rgba(0, 0, 0, 0.02);
|
|
|
- cursor: pointer;
|
|
|
+ width: 58px;
|
|
|
+ height: 58px;
|
|
|
+ line-height: 58px;
|
|
|
+ border: 1px dotted rgba(0, 0, 0, 0.1);
|
|
|
+ border-radius: 4px;
|
|
|
+ background: rgba(0, 0, 0, 0.02);
|
|
|
+ cursor: pointer;
|
|
|
}
|
|
|
+
|
|
|
.product-item {
|
|
|
border: 1px solid #eee;
|
|
|
- min-width: 300px;
|
|
|
- padding: 20px
|
|
|
+ width: 600px;
|
|
|
+ padding: 20px;
|
|
|
+ margin-bottom: 15px;
|
|
|
+ border-radius: 10px;
|
|
|
+ box-shadow: 0px 0px 10px #e3e3e3;
|
|
|
+ margin-right: 20px;
|
|
|
+
|
|
|
.submission {
|
|
|
// display: block;
|
|
|
margin-left: 500px;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
.bom {
|
|
|
margin-right: 20px
|
|
|
}
|
|
|
+
|
|
|
.heji {
|
|
|
padding: 10px
|
|
|
}
|