| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678 |
- export default {
- data() {
- return {
- activeStyle: {},
- active: 0,
- weeks: [],
- status: [],
- length: 0, //周
- //预约记录操作
- operation: {
- arrived_store: [{
- title: '确认完成',
- event: 'complet'
- }],
- wait_confirm: [{
- title: '确认预约',
- event: 'confirm'
- },
- {
- title: '更改预约',
- event: 'update'
- },
- {
- title: '取消预约',
- event: 'cancel'
- }
- ],
- wait_to_store: [{
- title: '确认到店',
- event: 'tostore'
- },
- {
- title: '取消预约',
- event: 'cancel'
- }
- ]
- },
- yuYueTime: [], //预约时间段
- yuYueConfig: {},
- yuYueData: {
- time: '', //时间
- date: '', //日期
- member_id: '',
- member: {},
- // store_id:'',
- goods: [],
- desc: '',
- reserve_id: 0
- },
- searchMobile: '',
- flag: false,
- yuYueDetail: null,
- weekDate: {
- start: '-',
- end: '-'
- },
- week: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
- current: '',
- yuYueDateType: 'week',
- goodsList: [],
- allServicerList: [], //所有的员工
- servicerList: [], //所有的员工
- yuyueList: [],
- yuyuePage: 1,
- yuyueSearchText: '',
- reserveId: 0,
- yuyueInfo: null,
- toDay: '', // 今天日期
- };
- },
- onLoad() {
- uni.hideTabBar();
- this.init();
- },
- onReady() {
- this.tabActive('tab');
- },
- methods: {
- init() {
- this.weeks = [];
- this.getYuyueStatus(); // 预约状态
- this.getYuyueConfig(); // 预约配置
- this.getGoodsList(); // 预约项目列表
- this.getServicerList(); // 员工列表
- this.getWeekReserve(); // 预约看板/周
- this.getYuyueList(); // 预约记录列表
- let date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- var d = date.getDate();
- this.toDay = y + '-' + m + '-' + d;
- },
- tabActive(id) {
- const query = uni.createSelectorQuery().in(this);
- var tab;
- query.select('#' + id).boundingClientRect(data => {
- tab = data;
- });
- query
- .select('#' + id + ' .active-bar .text')
- .boundingClientRect(data => {
- this.activeStyle = {
- width: data.width + 'px',
- transform: 'translateX(' + (data.left - tab.left) + 'px)'
- };
- })
- .exec();
- },
- switchTab(value) {
- this.active = value;
- this.$nextTick(() => {
- this.tabActive('tab');
- });
- },
- swiperChange(e) {
- this.active = e.detail.current;
- this.$nextTick(() => {
- this.tabActive('tab');
- });
- },
- // 预约状态
- getYuyueStatus() {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/status',
- success: res => {
- if (res.code >= 0) {
- this.status = res.data;
- }
- }
- });
- },
- // 预约配置
- getYuyueConfig() {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/getConfig',
- success: res => {
- if (res.code >= 0) {
- this.yuYueConfig = res.data;
- }
- }
- });
- },
- // ******************** 预约看板 ********************
- // 查询预约记录(每周)
- getWeekReserve() {
- if (this.flag) return;
- this.flag = true;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/getweekday',
- data: {
- length: this.length
- },
- success: res => {
- if (res.code >= 0) {
- this.weeks = res.data;
- this.$refs.loading.hide();
- this.weekDate.start = this.$util.timeFormat(this.weeks[0].start, 'y-m-d');
- this.weekDate.end = this.$util.timeFormat(this.weeks[this.weeks.length - 1].end,
- 'y-m-d');
- for (let i in this.weeks) {
- this.getReserve(i);
- if (i == this.weeks.length - 1) {
- setTimeout(() => {
- this.flag = false;
- }, 500);
- }
- }
- }
- this.flag = false;
- }
- });
- },
- //获取预约分页数据
- getReserve(index) {
- let currentWeek = this.weeks[index];
- if (!currentWeek.page) currentWeek.page = 1;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/lists',
- data: {
- page: currentWeek.page,
- start: currentWeek.start,
- end: currentWeek.end
- },
- success: res => {
- if (res.code >= 0) {
- let data = res.data;
- if (currentWeek.page == 1) {
- currentWeek.data = {
- list: [],
- page_count: data.page_count,
- count: data.count
- };
- currentWeek.data['list'] = data.list;
- } else {
- currentWeek.data['list'] = currentWeek.data['list'].concat(data.list);
- }
- if (data.page_count >= currentWeek.page) currentWeek.page++;
- this.$forceUpdate();
- }
- }
- });
- },
- //上一周
- prevWeek() {
- this.$refs.loading.show();
- --this.length;
- this.getWeekReserve();
- },
- //下一周
- nextWeek() {
- this.$refs.loading.show();
- ++this.length;
- this.getWeekReserve();
- },
- // ******************** 添加/编辑预约 ********************
- // 查询预约项目列表
- getGoodsList() {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/servicelist',
- data: {
- page: 1,
- page_size: 0
- },
- success: res => {
- if (res.code >= 0) {
- this.goodsList = res.data.list;
- }
- }
- });
- },
- // 查询员工列表
- getServicerList() {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/servicer',
- success: res => {
- if (res.code >= 0) {
- this.allServicerList = res.data;
- }
- }
- });
- },
- //添加预约
- addYuyue() {
- this.yuYueData = {
- reserve_id: 0,
- member_id: '',
- member: {},
- time: '', //时间
- date: this.toDay, //日期
- goods: [{}],
- desc: '',
- };
- this.reserveId = 0;
- this.handleYuyueDate();
- this.$refs.addYuyuePop.open();
- },
- closeYuyuePop() {
- this.yuYueData = {
- time: '', //时间
- date: '', //日期
- member_id: '',
- member: {},
- goods: [{}],
- desc: '',
- reserve_id: 0
- };
- this.$refs.addYuyuePop.close();
- },
- // 查询会员信息
- searchMember() {
- if (this.searchMobile.length == 0) {
- this.$util.showToast({
- title: '请输入客户手机号'
- });
- return;
- }
- if (!this.$util.verifyMobile(this.searchMobile)) {
- this.$util.showToast({
- title: '手机号格式不正确'
- });
- return;
- }
- this.$api.sendRequest({
- url: '/cashier/storeapi/member/searchmember',
- data: {
- search_text: this.searchMobile
- },
- success: res => {
- if (res.data) {
- this.yuYueData.member_id = res.data.member_id;
- this.yuYueData.member = res.data;
- } else {
- this.yuYueData.member_id = '';
- this.yuYueData.member = {};
- this.$util.showToast({
- title: '客户未找到'
- });
- }
- }
- });
- },
- //处理预约时间段
- handleYuyueDate() {
- let time_list = [];
- let start = this.yuYueConfig.start / 60;
- let end = this.yuYueConfig.end / 60;
- let date = new Date();
- var y = date.getFullYear();
- var m = date.getMonth() + 1;
- var d = date.getDate();
- let time = date.getHours() * 60 + date.getMinutes();
- let yuyue_time_stamp = this.$util.timeTurnTimeStamp(this.yuYueData.date);
- let time_stamp = this.$util.timeTurnTimeStamp(y + '-' + m + '-' + d);
- // if(time > start) start = time;
-
- for (let i = start; i < end; i++) {
- if (i % this.yuYueConfig.interval == 0) {
- let data = {
- label: (Math.floor(i / 60) < 10 ? '0' + Math.floor(i / 60) : Math.floor(i / 60)) + ':' + (
- i % 60 == '0' ? '00' : i % 60),
- value: (Math.floor(i / 60) < 10 ? '0' + Math.floor(i / 60) : Math.floor(i / 60)) + ':' + (
- i % 60 == '0' ? '00' : i % 60),
- disabled: false
- };
- if (yuyue_time_stamp < time_stamp) data.disabled = true;
- if (yuyue_time_stamp == time_stamp && time > i) data.disabled = true;
- let week = new Date(this.yuYueData.date).getDay();
- let yuyue_week = this.yuYueConfig.week;
- let config_week = [];
- for (let i in yuyue_week) config_week.push(parseInt(yuyue_week[i]));
- if (config_week.indexOf(week) === -1) data.disabled = true;
- time_list.push(data);
- }
- }
- this.yuYueTime = time_list;
- },
- // 监听预约时间
- changeYuyueTime(time) {
- this.yuYueData.date = time;
- this.handleYuyueDate();
- },
- // 选择预约时间·
- selectYuYueTime(index, item) {
- if (index >= 0) {
- this.yuYueData.time = item.value;
- } else {
- this.yuYueData.time = '';
- }
- },
- // 设置项目
- selectGoods(data, index) {
- this.yuYueData.goods[index] = Object.assign(this.yuYueData.goods[index], JSON.parse(JSON.stringify(data)));
- this.$forceUpdate();
- },
- // 加载员工列表
- loadServicer(index) {
- let goods_id = this.yuYueData.goods[index].goods_id;
- this.servicerList = this.allServicerList;
- },
- // 设置员工
- selectServicer(data, index) {
- this.yuYueData.goods[index].uid = data.uid;
- this.yuYueData.goods[index].username = data.username;
- this.$forceUpdate();
- },
- // 添加项目
- addService() {
- this.yuYueData.goods.push({});
- },
- // 删除项目
- deleleService(index) {
- if (this.yuYueData.goods.length == 1) {
- this.$util.showToast({
- title: '至少需要有一项项目'
- });
- } else {
- this.yuYueData.goods.splice(index, 1);
- }
- },
- // 预约验证
- verify() {
- if (!this.yuYueData.member_id) {
- this.$util.showToast({
- title: '请选择会员'
- });
- return false;
- }
- if (!this.yuYueData.date || !this.yuYueData.time) {
- this.$util.showToast({
- title: '请设置到店时间'
- });
- return false;
- }
- if (!this.yuYueData.goods.length) {
- this.$util.showToast({
- title: '请选择预约项目'
- });
- return false;
- }
- for (let i in this.yuYueData.goods) {
- if (!this.yuYueData.goods[i]['goods_id']) {
- this.$util.showToast({
- title: '请选择预约项目'
- });
- return false;
- }
- }
- return true;
- },
- // 添加/编辑预约
- yuYueSubmit() {
- if (this.verify()) {
- if (this.flag) return;
- this.flag = true;
- let data = Object.assign({}, this.yuYueData);
- data.goods = JSON.stringify(data.goods);
- data.member = JSON.stringify(data.member);
- let url = '/store/storeapi/reserve/add';
- if (data.reserve_id) url = '/store/storeapi/reserve/update';
- this.$api.sendRequest({
- url,
- data,
- success: res => {
- this.$util.showToast({
- title: res.message
- });
- this.flag = false;
- if (res.code >= 0) {
- this.getWeekReserve();
- if (this.reserveId) this.getYuyueInfo();
- this.closeYuyuePop();
- this.yuyuePage = 1;
- this.getYuyueList();
- }
- }
- });
- }
- },
- //操作
- yuyueEvent(event, data) {
- this.reserveId = data.reserve_id;
- switch (event) {
- case 'info':
- this.getYuYueDetail(data.reserve_id);
- break;
- case 'tostore':
- this.tostore(data.reserve_id);
- break;
- case 'cancel':
- this.cancel(data.reserve_id);
- break;
- case 'confirm':
- this.confirm(data.reserve_id);
- break;
- case 'update': // 修改预约
- this.$refs.loading.show();
- this.yuYueInfo(data.reserve_id);
- break;
- case 'complet':
- this.complet(data.reserve_id);
- break;
- }
- },
- //修改预约
- yuYueInfo(reserve_id) {
- if (this.flag) return;
- this.flag = true;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/detail',
- data: {
- reserve_id
- },
- success: res => {
- if (res.code >= 0) {
- this.yuYueData = {
- reserve_id: res.data.reserve_id,
- member_id: res.data.member_id,
- member: res.data.member,
- time: this.$util.timeFormat(res.data.reserve_time, 'h:i'),
- date: this.$util.timeFormat(res.data.reserve_time, 'y-m-d'),
- goods: res.data.item,
- desc: res.data.remark
- };
- this.handleYuyueDate();
- this.$refs.addYuyuePop.open();
- } else {
- this.$util.showToast({
- title: res.message
- });
- }
- this.flag = false;
- this.$refs.loading.hide();
- }
- });
- },
- // 预约详情
- getYuYueDetail(reserve_id) {
- if (this.flag) return;
- this.flag = true;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/detail',
- data: {
- reserve_id
- },
- success: res => {
- if (res.code >= 0) {
- this.yuYueDetail = res.data;
- this.$refs.yuyuePop.open();
- }
- this.flag = false;
- }
- });
- },
- //确定预约
- confirm(reserve_id) {
- if (this.flag) return;
- this.flag = true;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/confirm',
- data: {
- reserve_id
- },
- success: res => {
- this.flag = false;
- if (res.code >= 0) {
- this.getWeekReserve();
- this.getYuyueInfo();
- }
- this.$util.showToast({
- title: res.message
- });
- }
- });
- },
- //完成
- complet(reserve_id) {
- if (this.flag) return;
- this.flag = true;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/complete',
- data: {
- reserve_id
- },
- success: res => {
- this.flag = false;
- if (res.code >= 0) {
- this.getWeekReserve();
- this.getYuyueInfo();
- }
- this.$util.showToast({
- title: res.message
- });
- }
- });
- },
- //取消预约
- cancel(reserve_id) {
- if (this.flag) return;
- this.flag = true;
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/cancel',
- data: {
- reserve_id
- },
- success: res => {
- this.flag = false;
- if (res.code >= 0) {
- this.getWeekReserve();
- this.getYuyueInfo();
- }
- this.$util.showToast({
- title: res.message
- });
- }
- });
- },
- //确认到店
- tostore(reserve_id) {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/confirmToStore',
- data: {
- reserve_id
- },
- success: res => {
- this.flag = false;
- if (res.code >= 0) {
- this.getWeekReserve();
- this.getYuyueInfo();
- }
- this.$util.showToast({
- title: res.message
- });
- }
- });
- },
- // ******************** 预约列表 ********************
- // 获取预约分页数据
- getYuyueList() {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/lists',
- data: {
- page: this.yuyuePage,
- search_text: this.yuyueSearchText
- },
- success: res => {
- if (res.code >= 0) {
- if (this.yuyuePage == 1) this.yuyueList = [];
- this.yuyueList = this.yuyueList.concat(res.data.list);
- if (this.yuyuePage == 1 && this.yuyueList.length > 0) {
- this.reserveId = this.yuyueList[0]['reserve_id'];
- this.getYuyueInfo();
- }
- if (res.data.page_count >= this.yuyuePage) this.yuyuePage++;
- }
- }
- });
- },
- // 搜索预约客户
- searchYuyueList() {
- this.yuyuePage = 1;
- this.getYuyueList();
- },
- selectYuyue(id) {
- this.reserveId = id;
- this.getYuyueInfo();
- },
- getYuyueInfo() {
- this.$api.sendRequest({
- url: '/store/storeapi/reserve/detail',
- data: {
- reserve_id: this.reserveId
- },
- success: res => {
- if (res.code >= 0) {
- this.yuyueInfo = res.data;
- } else {
- this.yuyueInfo = null;
- }
- this.refreshStatus();
- this.$forceUpdate();
- }
- });
- },
- refreshStatus(){
- if(this.yuyueList && this.yuyueInfo){
- Object.keys(this.yuyueList).forEach(key => {
- let data = this.yuyueList[key];
- if(data.reserve_id == this.yuyueInfo['reserve_id']){
- this.yuyueList[key]['reserve_state'] = this.yuyueInfo['reserve_state'];
- this.yuyueList[key]['reserve_state_name'] = this.yuyueInfo['reserve_state_name'];
- }
- })
- }
- }
- }
- };
|