ソースを参照

Merge branch 'master' of http://git.qiniu1314.com/cmy/jztStore

cmy 2 年 前
コミット
237ab5fcc1

+ 396 - 0
src/components/ruleList/index.vue

@@ -0,0 +1,396 @@
+<template>
+	<div class="goodList">
+		<Table ref="table" no-data-text="暂无数据" @on-select-all="selectAll" @on-select-all-cancel="cancelAll"
+			@on-select="TableSelectRow" @on-select-cancel="TableSelectCancelRow" no-filtered-data-text="暂无筛选结果"
+			:columns="columns4" :data="tableList" :loading="loading" class="mr-20" height="500">
+			<!-- <template slot-scope="{ row }" slot="store_name">
+				<Tooltip max-width="200" placement="bottom">
+					<span class="line2">{{ row.store_name }}{{row.suk}}</span>
+					<p slot="content">{{ row.store_name }}{{row.suk}}</p>
+				</Tooltip>
+			</template> -->
+			<template slot-scope="{ row, index }" slot="workdays">
+				<!-- <el-tag v-for="witem in row.checkin_option.checkindate[0].workdays">{{witem | showWd}}</el-tag> -->
+				<div v-for="witem in row.checkin_option.checkindate" class="jg">
+					<div>
+						<span>工作日:</span>
+						<el-tag v-for="item in witem.workdays">{{item | showWd}}</el-tag>
+					</div>
+					<div class="flex">
+						<span>上班时段:</span>
+						<div>
+							<div v-for="itemx in witem.checkintime">
+								<span>{{itemx.work_sec| showTime}} </span> -
+								<span>{{itemx.off_work_sec | showTime}}</span>
+							</div>
+						</div>
+					</div>
+			
+				</div>
+			</template>
+		</Table>
+		<div class="acea-row row-right page">
+			<Page :total="total" show-elevator show-total @on-change="pageChange" :page-size="formValidate.limit" />
+		</div>
+	</div>
+</template>
+
+<script>
+	import {
+		mapState
+	} from "vuex";
+
+	import {
+		checkRuleList
+	} from '@/api/check'
+
+	export default {
+		name: "index",
+		props: {
+			serviceProject: {
+				type: Number,
+				default: 0,
+			},
+			serviceCard: {
+				type: Number,
+				default: 0,
+			},
+			goodsType: {
+				type: Number,
+				default: 0,
+			},
+			storeType: {
+				type: Number,
+				default: 0,
+			},
+			is_new: {
+				type: String,
+				default: "",
+			},
+			diy: {
+				type: Boolean,
+				default: false,
+			},
+			isdiy: {
+				type: Boolean,
+				default: false,
+			},
+			ischeckbox: {
+				type: Boolean,
+				default: false,
+			},
+			liveStatus: {
+				type: Boolean,
+				default: false,
+			},
+			isLive: {
+				type: Boolean,
+				default: false,
+			},
+			datas: {
+				type: Object,
+				default: function() {
+					return {};
+				},
+			},
+		},
+		data() {
+			return {
+				//选中商品集合
+				selectEquips: [],
+				// 选中的id集合
+				selectEquipsIds: [],
+				labelSelect: [],
+				cateIds: [],
+				modal_loading: false,
+				treeSelect: [],
+				formValidate: {
+					page: 1,
+					limit: 10,
+				},
+				total: 0,
+				modals: false,
+				loading: false,
+				grid: {
+					xl: 10,
+					lg: 10,
+					md: 12,
+					sm: 24,
+					xs: 24,
+				},
+				tableList: [],
+				currentid: 0,
+				productRow: {},
+				columns4: [{
+						title: "规则ID",
+						key: "id",
+					},
+					{
+						title: '工作日',
+						slot: 'workdays',
+						minWidth: 300
+					},
+					{
+						title: "创建时间",
+						key: "create_time",
+						minWidth: 100,
+					},
+				],
+				images: [],
+				many: "",
+			};
+		},
+		created() {
+			let radio = {
+				title: "选择",
+				width: 70,
+				align: "center",
+				render: (h, params) => {
+					let id = params.row.id;
+					let flag = false;
+					if (this.currentid === id) {
+						flag = true;
+					} else {
+						flag = false;
+					}
+					let self = this;
+					return h("div", [
+						h("Radio", {
+							props: {
+								value: flag,
+							},
+							on: {
+								"on-change": () => {
+									self.currentid = id;
+									this.productRow = params.row;
+									console.log('zhe+++')
+									this.$emit("getProductId", this.productRow);
+									
+								},
+							},
+						}),
+					]);
+				},
+			};
+
+			let checkbox = {
+				type: "selection",
+				width: 60,
+				align: "center",
+			};
+			let many = "";
+			if (this.ischeckbox) {
+				many = "many";
+			} else {
+				many = this.$route.query.type;
+			}
+			this.many = many;
+			if (many === "many") {
+				this.columns4.unshift(checkbox);
+				this.columns5.unshift(checkbox);
+			} else {
+				this.columns4.unshift(radio);
+				this.columns5.unshift(radio);
+			}
+		},
+		mounted() {
+			this.getList();
+		},
+		filters: {
+			showWd(day) {
+				let str = ''
+				if(day) {
+					switch (day*1){
+						case 1:
+							str = '星期一'
+							break;
+						case 2:
+							str = '星期二'
+							break;
+						case 3:
+							str = '星期三'
+							break;
+						case 4:
+							str = '星期四'
+							break;
+						case  5:
+							str = '星期五'
+							break;
+						case 6:
+							str = '星期六'
+							break;
+						case  0:
+							str = '星期日'
+							break;
+						default:
+							break;
+					}
+				}
+				return str
+			}
+		},
+		methods: {
+			
+			// 判断是否选中
+			sortData() {
+				if (this.selectEquipsIds.length) {
+					this.tableList.forEach(ele => {
+						if (this.selectEquipsIds.includes(ele.id)) ele._checked = true;
+					})
+				}
+			},
+			// 选中一行
+			TableSelectRow(selection, row) {
+				if (!this.selectEquipsIds.includes(row.id)) {
+					this.selectEquipsIds.push(row.id);
+					this.selectEquips.push(row);
+				}
+			},
+			// 取消选中一行
+			TableSelectCancelRow(selection, row) {
+				var _index = this.selectEquipsIds.indexOf(row.id);
+				if (_index != -1) {
+					this.selectEquipsIds.splice(_index, 1);
+					this.selectEquips.splice(_index, 1);
+				}
+			},
+			// 选中所有
+			selectAll() {
+				for (let i = this.tableList.length - 1; i >= 0; i--) {
+					this.TableSelectRow(null, this.tableList[i]);
+				}
+			},
+			// 取消选中所有
+			cancelAll() {
+				for (let i = this.tableList.length - 1; i >= 0; i--) {
+					this.TableSelectCancelRow(null, this.tableList[i]);
+				}
+			},
+
+			handleSelectAll() {
+				this.$refs.table.selectAll(false);
+			},
+			pageChange(index) {
+				this.formValidate.page = index;
+				this.getList();
+			},
+			// 列表
+			getList() {
+				this.loading = true;
+				checkRuleList(this.formValidate)
+					.then(async (res) => {
+						let data = res.data;
+						this.tableList = data.data;
+						this.total = res.data.count;
+						this.sortData();
+						this.loading = false;
+					})
+					.catch((res) => {
+						this.loading = false;
+						this.$Message.error(res.msg);
+					});
+
+			},
+			changeCheckbox(selection) {
+				let images = [];
+				selection.forEach(function(item) {
+					let imageObject = {
+						image: item.image,
+						product_id: item.id,
+						store_name: item.store_name,
+						temp_id: item.temp_id
+					};
+					images.push(imageObject);
+				});
+				this.images = images;
+				this.$emit("getProductDiy", selection);
+			},
+			ok() {
+				// console.log('selectEquips',this.selectEquips)
+				this.$emit("getProductId", this.selectEquips);
+				// let images = [];
+				// this.selectEquips.forEach(function(item) {
+				// 	let imageObject = {
+				// 		image: item.image,
+				// 		product_id: item.id,
+				// 		store_name: item.store_name,
+				// 		temp_id: item.temp_id
+				// 	};
+				// 	images.push(imageObject);
+				// });
+				// if (images.length > 0) {
+				// 	if (this.$route.query.fodder === "image") {
+				// 		let imageValue = form_create_helper.get("image");
+				// 		form_create_helper.set("image", imageValue.concat(images));
+				// 		form_create_helper.close("image");
+				// 	} else {
+				// 		if (this.isdiy) {
+				// 			this.$emit("getProductId", this.selectEquips);
+				// 		} else {
+				// 			this.$emit("getProductId", images);
+				// 		}
+				// 	}
+				// } else {
+				// 	this.$Message.warning("请先选择商品");
+				// }
+			},
+			treeSearchs(value) {
+				this.cateIds = value;
+				this.formValidate.page = 1;
+				this.getList();
+			},
+			// 表格搜索
+			userSearchs() {
+				this.formValidate.page = 1;
+				this.getList();
+			},
+			clear() {
+				this.productRow.id = "";
+				this.currentid = "";
+			},
+		},
+	};
+</script>
+
+<style scoped lang="stylus">
+	/deep/.ivu-table-header thead tr th {
+		padding: 8px 5px;
+	}
+
+	/deep/.ivu-radio-wrapper {
+		margin-right: 0 !important;
+	}
+
+	.footer {
+		margin: 15px 0;
+	}
+
+	.tabBox_img {
+		width: 36px;
+		height: 36px;
+		border-radius: 4px;
+		cursor: pointer;
+
+		img {
+			width: 100%;
+			height: 100%;
+		}
+	}
+
+	.tabform {
+		>>>.ivu-form-item {
+			margin-bottom: 16px !important;
+		}
+	}
+
+	.btn {
+		margin-top: 20px;
+		float: right;
+	}
+
+	.goodList {}
+
+	.mr-20 {
+		margin-right: 10px;
+	}
+</style>

+ 1 - 1
src/components/staffList/index.vue

@@ -27,7 +27,7 @@
 	import {
 		getYgList
 	} from '@/api/check'
-	export default {
+ 	export default {
 		name: "index",
 		props: {
 			serviceProject: {

+ 30 - 67
src/pages/check/classes/add.vue

@@ -1,29 +1,14 @@
 <template>
 	<div class="form-submit">
-		<div class="i-layout-page-header">
-			<PageHeader class="product_tabs" hidden-breadcrumb>
-				<div slot="title">
-					<router-link :to="{ path: `${roterPre}/store/checkRule/index` }">
-						<div class="font-sm after-line">
-							<span class="iconfont iconfanhui"></span>
-							<span class="pl10">返回</span>
-						</div>
-					</router-link>
-					<span v-text="$route.params.id ? '编辑打卡规则' : '添加打卡规则'" class="mr20 ml16"></span>
-				</div>
-			</PageHeader>
-		</div>
+
 		<Card :bordered="false" dis-hover class="ivu-mt">
 			<Form :model="formData" :label-width="150">
-				<FormItem label="规则名称" required>
+				<FormItem label="班次名称" required>
 					<Input v-model="formData.groupname" v-width="320"></Input>
 				</FormItem>
 				<FormItem label="打卡规则" required>
-					<!-- <Input v-model="formData.groupname" v-width="320"></Input> -->
-					<template v-for="item in checkedStaff">
-						<Tag>{{item.name}}</Tag>
-					</template>
-					<Button type="primary" @click="chooseSatff">选择员工</Button>
+					<Tag v-if="checkedStaff && checkedStaff.checkin_option">{{checkedStaff.checkin_option.groupname}}</Tag>
+					<Button type="primary" @click="chooseRule">选择打卡规则</Button>
 				</FormItem>
 				<card v-for="(itemx,indexx) in formData.checkindate" style="width:1000px;">
 					<card v-for="(item,index) in itemx.checkintime" style="margin-bottom: 10px;">
@@ -74,32 +59,19 @@
 				<Button type="primary" @click="showDate()">测试数据</Button>
 			</div>
 		</Card>
-		<Modal v-model="modals" title="员工列表" footerHide class="paymentFooter" scrollable width="900"
+		<Modal v-model="modals" title="规则列表" footerHide class="paymentFooter" scrollable width="900"
 			@on-cancel="cancel">
-			<staff-list ref="stafflist" :goodsType="1" v-if="modals" @getProductId="getProductId"
-				:serviceCard="1"></staff-list>
+			<rule-list ref="rulelist" :goodsType="1" v-if="modals" @getProductId="getProductId"
+				:serviceCard="1"></rule-list>
 		</Modal>
 	</div>
 </template>
 
 <script>
-	import {
-		mapState
-	} from "vuex";
-	import staffList from "@/components/staffList/index";
-	import storeList from "@/components/storeList";
-	import {
-		couponCategoryApi,
-		couponSaveApi,
-		couponDetailApi,
-		VipEditApi,
-		serveAddApi,
-		serveReadApi,
-		createServeProduct
-	} from "@/api/marketing";
+	import ruleList from "@/components/ruleList/index";
 	import {
 		addCheckRule
-	} from '@/api/store';
+	} from '@/api/check';
 	import {
 		brandList
 	} from "@/api/product";
@@ -108,12 +80,11 @@
 	export default {
 		name: "storeCouponCreate",
 		components: {
-			storeList,
-			staffList
+			ruleList
 		},
 		data() {
 			return {
-				checkedStaff: [],
+				checkedStaff: {},
 				modals: false, //选择员工弹出
 				value: '',
 				id: '',
@@ -172,17 +143,14 @@
 				modals: false,
 			}
 		},
-		computed: {
-			...mapState("admin/layout", ["isMobile", "menuCollapse"]),
-		},
 		created() {},
 		methods: {
 			// 测试数据
 			showDate() {
 				console.log('shuju', this.formData)
 			},
-			// 打开员工选择弹窗
-			chooseSatff() {
+			// 打开选择弹窗
+			chooseRule() {
 				this.modals = true;
 			},
 			changeT(e) {
@@ -238,7 +206,7 @@
 			delNewDkTime(index) {
 				this.formData.checkindate.splice(index, 1)
 			},
-			delNewDk(item,index) {
+			delNewDk(item, index) {
 				item.splice(index, 1)
 			},
 			// 
@@ -250,12 +218,7 @@
 				this.modals = false;
 				console.log(row, '这个');
 				this.checkedStaff = row
-				let arr = []
-				this.checkedStaff.forEach(item => {
-					arr.push(item.userid)
-				})
-				this.formData.range.userid = arr
-
+				// this.formData.checkindate = row.
 			},
 			// 选择商品
 			changeGoods() {
@@ -273,13 +236,13 @@
 				// }
 			},
 			getTime(str) {
-				if(typeof(str) == 'string') {
+				if (typeof(str) == 'string') {
 					let arr = str.split(':')
-					return arr[0]*60*60 + arr[1]*60
-				}else {
+					return arr[0] * 60 * 60 + arr[1] * 60
+				} else {
 					return str
 				}
-				
+
 			},
 			// 创建
 			save() {
@@ -287,20 +250,20 @@
 				this.downTab();
 				console.log('这');
 				let qdata = {}
-				qdata = Object.assign(qdata,this.formData)
-				try{
+				qdata = Object.assign(qdata, this.formData)
+				try {
 					// let qdata = JSON.parse(JSON.stringify(this.formData))
 					let checkindate = []
 					this.formData.checkindate.forEach(item => {
 						// checkindate.push(item.)
 						let mitem = []
 						item.checkintime.forEach(itemt => {
-							for(let key in itemt) {
+							for (let key in itemt) {
 								// let val = ''
-								if(key != 'time_id') {
+								if (key != 'time_id') {
 									itemt[key] = that.getTime(itemt[key])
-								}else {
-									itemt[key] = itemt[key]*1
+								} else {
+									itemt[key] = itemt[key] * 1
 								}
 							}
 							mitem.push(itemt)
@@ -309,13 +272,13 @@
 						checkindate.push(item)
 					})
 					qdata.checkindate = checkindate
-					console.log(qdata,'this.formData')
-				}catch(e){
+					console.log(qdata, 'this.formData')
+				} catch (e) {
 					//TODO handle the exception
-					console.log(e,'cuow')
+					console.log(e, 'cuow')
 				}
-				
-				
+
+
 				addCheckRule({
 						'group': qdata
 					})

+ 3 - 26
src/pages/check/classes/index.vue

@@ -1,14 +1,11 @@
 <template>
 	<div>
-		<div class="i-layout-page-header">
-			<PageHeader class="product_tabs" title="会员卡" hidden-breadcrumb></PageHeader>
-		</div>
 		<Card :bordered="false" dis-hover class="ivu-mt">
 			<Form ref="tableFrom" :model="tableFrom" :label-width="labelWidth" :label-position="labelPosition"
 				@submit.native.prevent>
 				<Row type="flex">
 					<Col v-bind="grid">
-					<Button v-auth="['admin-store-classes-add']" type="primary" icon="md-add"
+					<Button v-auth="['store-check-classes-add']" type="primary" icon="md-add"
 						@click="add">添加班次</Button>
 					</Col>
 				</Row>
@@ -46,8 +43,6 @@
 					:page-size="tableFrom.limit" />
 			</div>
 		</Card>
-		<!--表单编辑-->
-		<edit-from :FromData="FromData" @changeType="changeType" ref="edits"></edit-from>
 	</div>
 </template>
 
@@ -56,11 +51,8 @@
 		mapState
 	} from 'vuex';
 	import {
-		checkGroupList,
-		checkRuleList,
 		getClasses
-	} from '@/api/store';
-	import editFrom from '@/components/from/from';
+	} from '@/api/check';
 	import {
 		formatDate
 	} from '@/utils/validate';
@@ -106,9 +98,6 @@
 				return str
 			}
 		},
-		components: {
-			editFrom
-		},
 		filters: {
 			showTime(seconds) {
 				  
@@ -181,9 +170,6 @@
 			this.getList();
 		},
 		computed: {
-			...mapState('admin/layout', [
-				'isMobile'
-			]),
 			labelWidth() {
 				return this.isMobile ? undefined : 90;
 			},
@@ -208,13 +194,6 @@
 					this.$Message.error(res.msg);
 				});
 			},
-			// 发布
-			couponSend(row) {
-				// this.$modalForm(VipEditApi(row.id)).then(() => this.getList());
-				this.$router.push({
-					path: this.roterPre + "/store/checkRule/create"
-				});
-			},
 			// 删除
 			couponDel(row, tit, num) {
 				let delfromData = {
@@ -253,11 +232,9 @@
 			},
 			// 添加
 			add() {
-				// this.$modalForm(couponCreateApi()).then(() => this.getList());
 				this.$router.push({
-					path: this.roterPre + "/store/classes/create"
+					path:  "/store/check/classes/add"
 				});
-				// this.addType(0);
 			},
 			addType(type) {
 				couponCreateApi(type).then(async res => {

+ 47 - 11
src/pages/check/rule/index.vue

@@ -8,8 +8,7 @@
 				@submit.native.prevent>
 				<Row type="flex">
 					<Col v-bind="grid">
-					<Button v-auth="['store-check-rule-add']" type="primary" icon="md-add"
-						@click="add">添加打卡规则</Button>
+					<Button v-auth="['store-check-rule-add']" type="primary" icon="md-add" @click="add">添加打卡规则</Button>
 					</Col>
 				</Row>
 			</Form>
@@ -19,7 +18,23 @@
 					{{row.checkin_option.groupname}}
 				</template>
 				<template slot-scope="{ row, index }" slot="workdays">
-					<el-tag v-for="witem in row.checkin_option.checkindate[0].workdays">{{witem | showWd}}</el-tag>
+					<!-- <el-tag v-for="witem in row.checkin_option.checkindate[0].workdays">{{witem | showWd}}</el-tag> -->
+					<div v-for="witem in row.checkin_option.checkindate" class="jg">
+						<div>
+							<span>工作日:</span>
+							<el-tag v-for="item in witem.workdays">{{item | showWd}}</el-tag>
+						</div>
+						<div class="flex">
+							<span>上班时段:</span>
+							<div>
+								<div v-for="itemx in witem.checkintime">
+									<span>{{itemx.work_sec| showTime}} </span> -
+									<span>{{itemx.off_work_sec | showTime}}</span>
+								</div>
+							</div>
+						</div>
+
+					</div>
 				</template>
 				<template slot-scope="{ row, index }" slot="status">
 					<Icon type="md-checkmark" v-if="row.status === 1" color="#0092DC" size="14" />
@@ -66,8 +81,8 @@
 			},
 			showWd(day) {
 				let str = ''
-				if(day) {
-					switch (day*1){
+				if (day) {
+					switch (day * 1) {
 						case 1:
 							str = '星期一'
 							break;
@@ -80,13 +95,13 @@
 						case 4:
 							str = '星期四'
 							break;
-						case  5:
+						case 5:
 							str = '星期五'
 							break;
 						case 6:
 							str = '星期六'
 							break;
-						case  0:
+						case 0:
 							str = '星期日'
 							break;
 						default:
@@ -94,11 +109,21 @@
 					}
 				}
 				return str
+			},
+			showTime(seconds) {
+
+
+				if (seconds) {
+					var hours = Math.floor(seconds / 3600);
+					var minutes = Math.floor((seconds % 3600) / 60);
+					return (hours > 9 ? hours : '0' + hours) + ": " + (minutes > 9 ? minutes : '0' + minutes)
+				}
 			}
 		},
 		components: {
 			editFrom
 		},
+
 		data() {
 			return {
 				roterPre: Setting.routePre,
@@ -118,12 +143,12 @@
 					{
 						title: '规则名称',
 						slot: 'groupname',
-						minWidth: 150
+						minWidth: 80
 					},
 					{
 						title: '工作日',
 						slot: 'workdays',
-						minWidth: 80
+						minWidth: 500
 					},
 					{
 						title: '添加时间',
@@ -170,9 +195,9 @@
 			couponDel(row, tit, num) {
 				let delfromData = {
 					title: tit,
-					url: `work/getCheckinOption/${row.id}`,
+					url: `work/deleteCheckRule`,
 					method: 'POST',
-					ids: ''
+					ids: {id: row.id}
 				};
 				this.$modalSure(delfromData).then((res) => {
 					this.$Message.success(res.msg);
@@ -220,4 +245,15 @@
 	.ivu-col:nth-of-type(1) .ivu-form-item .ivu-form-item-content {
 		margin-left: 80px !important;
 	}
+
+	.flex {
+		display: flex;
+	}
+
+	.jg {
+		border-bottom: 1px solid #999;
+	}
+	.jg:last-of-type {
+		border-bottom: none;
+	}
 </style>

+ 18 - 18
src/router/modules/check.js

@@ -44,24 +44,24 @@ export default {
             },
             component: () => import('@/pages/check/rule/add')
         },
-  //       {
-  //           path: 'classes/index',
-  //           name: `${pre}classesIndex`,
-  //           meta: {
-  //               auth: ['store-check-classes-index'],
-  //               title: '考勤组列表'
-  //           },
-  //           component: () => import('@/pages/check/classes/index')
-  //       },
-		// {
-		//     path: 'classes/add',
-		//     name: `${pre}classesAdd`,
-		//     meta: {
-		//         auth: ['store-check-classes-add'],
-		//         title: '考勤组列表'
-		//     },
-		//     component: () => import('@/pages/check/classes/add')
-		// },
+        {
+            path: 'classes/index',
+            name: `${pre}classesIndex`,
+            meta: {
+                auth: ['store-check-classes-index'],
+                title: '班次列表'
+            },
+            component: () => import('@/pages/check/classes/index')
+        },
+		{
+		    path: 'classes/add',
+		    name: `${pre}classesAdd`,
+		    meta: {
+		        auth: ['store-check-classes-add'],
+		        title: '添加班次'
+		    },
+		    component: () => import('@/pages/check/classes/add')
+		},
 		{
 		    path: 'staff/index',
 		    name: `${pre}staffIndex`,