| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751 |
- <style>
- .com-attrs-setting {
- width: 1300px;
- margin-top: 24px;
- margin-bottom: 10px;
- border: 1px solid #dddddd;
- border-radius: 6px;
- font-size: 13px;
- }
- .header-box {
- height: 40px;
- display: flex;
- background-color: #f5f6fa;
- border-bottom: 1px solid #dddddd;
- }
- .content-box {
- min-height: 360px;
- max-height: 600px;
- display: flex;
- }
- .left1-box {
- width: 150px;
- background-color: #f5f6fa;
- border-right: 1px solid #dddddd;
- }
- .left2-box {
- min-height: 360px;
- max-height: 600px;
- background-color: #f5f6fa;
- }
- .right1-box {
- width: calc(100% - 150px);
- padding: 0 20px;
- }
- .attrs-item {
- padding: 5px 4px;
- border-bottom: 1px solid #dddddd;
- text-align: center;
- cursor: pointer;
- }
- .attrs-item:last-child {
- border-bottom: none;
- }
- .scroll-box {
- overflow-y: scroll;
- }
- .flex-x {
- display: flex;
- justify-content: space-around;
- align-items: center;
- }
- .flex-l {
- display: flex;
- align-items: center;
- }
- .btn1 {
- margin-left: 8px;
- color: #409EFF;
- cursor: pointer;
- }
- .attr-select {
- background-color: #ffffff;
- }
- </style>
- <template id="com-attrs-setting">
- <div class="com-attrs-setting">
- <div class="header-box">
- <div class="left1-box flex-x">
- <span>选择规格</span>
- <span class="btn1" @click="dialogFormVisible = true" v-if="reserve_type == 0">批量设置</span>
- </div>
- <div class="right1-box flex-l bg">{{reserve_type == 0 ? '预约规则' : '规格规则'}}</div>
- </div>
- <div class="content-box">
- <div class="left1-box left2-box scroll-box">
- <div v-for="(item,index) in value" :key="index" @click="onAttr(index)" class="attrs-item" :class="item.isSelect ? 'attr-select' : ''">{{item.attr_list | formatAttr}}</div>
- </div>
- <div class="right1-box scroll-box">
- <el-form v-if="value && value[currentIndex]" :model="value[currentIndex]" ref="currentInfoReserve" size="mini"
- label-width="150px" class="demo-unifiedForm" style="padding: 10px 0">
- <template v-if="reserve_type == 0">
- <el-form-item label="可预约时间">
- <el-radio-group v-model="value[currentIndex].reserve_date_type" @input="onRadioChange">
- <el-radio :label="1">选择范围</el-radio>
- <el-radio :label="2">自选日期</el-radio>
- </el-radio-group>
- <div v-if="value[currentIndex].reserve_date_type == 1" class="range-box">
- <el-date-picker v-if="value[currentIndex].reserve_date_type == 1" v-model="value[currentIndex].checkRangeList" type="daterange"
- range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="dateSelectChange1"></el-date-picker>
- <div v-if="value[currentIndex].dayArr.length" class="range-check-box1">
- <el-checkbox-group v-model="value[currentIndex].checkWeekList" @change="weekSelectChange1">
- <el-checkbox v-for="(item,inx) in value[currentIndex].dayArr" :key="inx" :label="item.txt"></el-checkbox>
- </el-checkbox-group>
- </div>
- </div>
- <div v-if="value[currentIndex].reserve_date_type == 2" class="range-box">
- <el-date-picker v-if="value[currentIndex].reserve_date_type == 2" type="dates" v-model="value[currentIndex].reserve_date" value-format="yyyy-MM-dd" placeholder="选择一个或多个日期"></el-date-picker>
- </div>
- </el-form-item>
- <el-form-item label="预约模式">
- <el-radio-group v-model="value[currentIndex].reserve_time_range_type" @input="onRadioChange($event, 1)">
- <el-radio :label="1">按天预约</el-radio>
- <el-radio :label="2">按时间段预约</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="时段划分" v-if="value[currentIndex].reserve_time_range_type == 2">
- <el-radio-group v-model="value[currentIndex].time_slot_type" @input="onRadioChange">
- <el-radio :label="1">自定义时间段</el-radio>
- <el-radio :label="2">自动划分</el-radio>
- </el-radio-group>
- <div>
- <com-time-select ref="timeSelectChild" :date-list="value[currentIndex].reserve_date" :slot-type="value[currentIndex].time_slot_type"
- :price-type="value[currentIndex].reserve_price_type"
- :pre-selected-dates="value[currentIndex].selectTimeList" :select-list-str="selectListStr" :current-setting="value[currentIndex].finalData"
- @select="resetDateInfo1"></com-time-select>
- </div>
- </el-form-item>
- <el-form-item label="价格设置">
- <el-radio-group v-model="value[currentIndex].reserve_price_type" @input="onRadioChange($event, 2)">
- <el-radio :label="0">统一售价</el-radio>
- <el-radio :label="1" v-if="value[currentIndex].reserve_time_range_type == 2">按时间段设置</el-radio>
- <el-radio :label="2" v-if="value[currentIndex].reserve_time_range_type == 1">按天设置</el-radio>
- </el-radio-group>
- </el-form-item>
- </template>
- <template v-if="value[currentIndex].reserve_price_type == 0 || reserve_type == 1">
- <el-form-item label="售价" prop="price">
- <el-input placeholder="请输入价格" class="width-150" v-model="value[currentIndex].price" @input="onRadioChange">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="划线价" prop="original_price">
- <el-input placeholder="请输入价格" class="width-150" v-model="value[currentIndex].original_price" @input="onRadioChange">
- <template slot="append">元</template>
- </el-input>
- <p class="tips-text">商品没有优惠的情况下,划线价在商品详情会以划线形式显示</p>
- </el-form-item>
- <el-form-item :label="value[currentIndex].reserve_time_range_type == 1 ? '每天最多可预约的数量' : '每段时间最多可预约数量'" prop="reserve_max_buy">
- <el-input placeholder="" class="width-150" v-model="value[currentIndex].reserve_max_buy" @input="onRadioChange"></el-input>
- </el-form-item>
- </template>
- <template v-if="reserve_type == 1">
- <el-form-item label="服务时长" prop="service_min">
- <el-input placeholder="请输入服务时长" class="width-150" v-model="value[currentIndex].service_min"
- @input="onRadioChange">
- <template slot="append">分钟</template>
- </el-input>
- </el-form-item>
- <el-form-item label="服务单位" prop="unit">
- <el-input placeholder="请输入服务单位" class="width-150" v-model="value[currentIndex].unit" maxlength="20" show-word-limit @input="onRadioChange"></el-input>
- </el-form-item>
- </template>
- <template v-if="value[currentIndex].reserve_price_type == 1">
- <el-form-item label="" prop="">
- <com-price-set ref="priceSetChild" :price-type="1" @on-update-selected-date="onUpdateSelectedDate"
- :date-list="value[currentIndex].finalData.length > 0 ? value[currentIndex].finalData : value[currentIndex].reserve_date"></com-price-set>
- </el-form-item>
- </template>
- <template v-if="value[currentIndex].reserve_price_type == 2">
- <el-form-item label="" prop="">
- <com-price-day-set ref="priceSetChild" :price-type="2" :date-list="value[currentIndex].finalData.length > 0 ? value[currentIndex].finalData : value[currentIndex].reserve_date"
- @on-update-selected-date="onUpdateSelectedDate"></com-price-day-set>
- </el-form-item>
- </template>
- </el-form>
- </div>
- </div>
- <el-dialog title="批量设置全部规格" :visible.sync="dialogFormVisible" width="60%">
- <div class="time-select-box">
- <el-form :model="unifiedForm" ref="unifiedForm" size="mini" label-width="150px" class="demo-unifiedForm">
- <el-form-item label="可预约时间" required prop="reserve_date_type">
- <el-radio v-model="unifiedForm.reserve_date_type" :label="1">选择范围</el-radio>
- <el-radio v-model="unifiedForm.reserve_date_type" :label="2">自选日期</el-radio>
- <div v-if="unifiedForm.reserve_date_type == 1" class="range-box">
- <el-date-picker v-if="unifiedForm.reserve_date_type == 1" v-model="checkRangeList" type="daterange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" @change="dateSelectChange"></el-date-picker>
- <div v-if="dayArr.length" class="range-check-box1">
- <el-checkbox-group v-model="checkWeekList" @change="weekSelectChange">
- <el-checkbox v-for="(item,inx) in dayArr" :key="inx" :label="item.txt"></el-checkbox>
- </el-checkbox-group>
- </div>
- </div>
- <div v-if="unifiedForm.reserve_date_type == 2" class="range-box">
- <el-date-picker v-if="unifiedForm.reserve_date_type == 2" type="dates" v-model="unifiedForm.reserve_date" value-format="yyyy-MM-dd" placeholder="选择一个或多个日期"></el-date-picker>
- </div>
- </el-form-item>
- <el-form-item label="预约模式" required prop="reserve_time_range_type">
- <el-radio v-model="unifiedForm.reserve_time_range_type" :label="1">按天预约</el-radio>
- <el-radio v-model="unifiedForm.reserve_time_range_type" :label="2">按时间段预约</el-radio>
- </el-form-item>
- <el-form-item label="时段划分" required prop="time_slot_type" v-if="unifiedForm.reserve_time_range_type == 2">
- <el-radio v-model="unifiedForm.time_slot_type" :label="1">自定义时间段</el-radio>
- <el-radio v-model="unifiedForm.time_slot_type" :label="2">自动划分</el-radio>
- <div v-if="unifiedForm.time_slot_type == 1 || unifiedForm.time_slot_type == 2">
- <com-time-select ref="timeSelect" :date-list="unifiedForm.reserve_date"
- :slot-type="unifiedForm.time_slot_type" :price-type="unifiedForm.reserve_price_type" @select="resetDateInfo"></com-time-select>
- </div>
- </el-form-item>
- <el-form-item label="价格设置" required prop="reserve_price_type">
- <el-radio v-model="unifiedForm.reserve_price_type" :label="0">统一售价</el-radio>
- <el-radio v-model="unifiedForm.reserve_price_type" :label="1" v-if="unifiedForm.reserve_time_range_type == 2">按时间段设置</el-radio>
- <el-radio v-model="unifiedForm.reserve_price_type" :label="2" v-if="unifiedForm.reserve_time_range_type == 1">按天设置</el-radio>
- </el-form-item>
- <template v-if="unifiedForm.reserve_price_type == 0">
- <el-form-item label="售价" required prop="price">
- <el-input placeholder="请输入价格" class="width-150" v-model="unifiedForm.price" onInput="value=toNumber(value,2)">
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="划线价" prop="original_price">
- <el-input placeholder="请输入价格" class="width-150" v-model="unifiedForm.original_price" onInput="value=toNumber(value,2)">
- <template slot="append">元</template>
- </el-input>
- <p class="tips-text">商品没有优惠的情况下,划线价在商品详情会以划线形式显示</p>
- </el-form-item>
- <el-form-item :label="unifiedForm.reserve_time_range_type == 1 ? '每天最多可预约的数量' : '每段时间最多可预约数量'" prop="reserve_max_buy">
- <el-input placeholder="" class="width-150" v-model="unifiedForm.reserve_max_buy"></el-input>
- </el-form-item>
- </template>
- <template v-if="reserve_type == 1">
- <el-form-item label="服务时长" required prop="service_min">
- <el-input placeholder="请输入服务时长" class="width-150" v-model="unifiedForm.service_min" onInput="value=toNumber(value,0)">
- <template slot="append">分钟</template>
- </el-input>
- </el-form-item>
- <el-form-item label="服务单位" required prop="unit">
- <el-input placeholder="请输入服务单位" class="width-150" v-model="unifiedForm.unit" maxlength="20" show-word-limit></el-input>
- </el-form-item>
- </template>
- <template v-if="unifiedForm.reserve_price_type == 1">
- <el-form-item label="" prop="">
- <com-price-set ref="priceSet" :price-type="1" @on-update-selected-date="onUpdateSelectedDate" :date-list="unifiedForm.finalData"></com-price-set>
- </el-form-item>
- </template>
- <template v-if="unifiedForm.reserve_price_type == 2">
- <el-form-item label="" prop="">
- <com-price-day-set ref="priceSet" :price-type="2" :date-list="unifiedForm.finalData" @on-update-selected-date="onUpdateSelectedDate"></com-price-day-set>
- </el-form-item>
- </template>
- </el-form>
- </div>
- <div slot="footer" class="dialog-footer">
- <el-button @click="dialogFormVisible = false">取 消</el-button>
- <el-button type="primary" @click="unifiedSetting">确 定</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- Vue.component('com-attrs-setting', {
- template: '#com-attrs-setting',
- props: {
- value: {
- type: Array,
- default: () => {
- return []
- }
- },
- attrGroups: {
- type: Array,
- default: () => {
- return []
- }
- },
- reserve_type: {
- type: Number,
- default: 0
- }
- },
- data() {
- return {
- sign_id: '',
- currentIndex: 0,
- dialogFormVisible: false,
- unifiedForm: {
- reserve_date_type: 1, // 可预约时间类型(1范围 2自选日期)
- reserve_date: null, // 可预约日期
- reserve_time_range_type: 1, //预约模式(1按天预约 2按时间段预约)
- time_slot_type: 1, // 时间段划分方式(1自定义划分 2自动划分)
- reserve_time_slot: null, // 时间段划分
- reserve_price_type: 0, // 价格设置方式(0统一售价 1按日期时间段设置)
- reserve_time_slot_price: null, // 按时间段设置的价格
- reserve_week: [0,1,2,3,4,5,6], // 可预约周,如:0,1,2,3,4,5,6
- reserve_max_buy: 0, // 每天最大预约数量
- price: 0, // 售价
- original_price: 0, // 划线价
- service_min: 0, // 服务时长
- unit: '', // 单位
- },
- dayArr: [], //预约商品
- checkWeekList: [], //预约商品
- checkRangeList: [], //预约商品
- selectTimeList: [],
- currentItem: null,
- selectListStr: '',
- };
- },
- created() {},
- watch: {
- value: {
- handler(newvalue, oldvalue) {
- if (JSON.stringify(newvalue) === JSON.stringify(oldvalue)) {
- return;
- }
-
- this.$nextTick(() => {
- if (!Array.isArray(newvalue)) {
- return;
- }
-
- const valueData = JSON.parse(JSON.stringify(newvalue));
- let needUpdate = false;
-
- valueData.forEach(item => {
- if (!item.isSelect && !item.reserve_date_type) {
- needUpdate = true;
- }
-
- item.isSelect = item.isSelect || false;
- item.reserve_date_type = item.reserve_date_type || 1;
- item.reserve_date = item.reserve_date || null;
- item.reserve_time_range_type = item.reserve_time_range_type || 1;
- item.time_slot_type = item.time_slot_type || 1;
- item.reserve_time_slot = item.reserve_time_slot || null;
- item.reserve_price_type = item.reserve_price_type || 0;
- item.reserve_time_slot_price = item.reserve_time_slot_price || null;
- item.reserve_week = item.reserve_week || [0,1,2,3,4,5,6];
- item.reserve_max_buy = item.reserve_max_buy || null;
- item.price = item.price || null;
- item.original_price = item.original_price || null;
- item.dayArr = item.dayArr || [];
- item.checkWeekList = item.checkWeekList || [];
- item.checkRangeList = item.checkRangeList || [];
- item.selectTimeList = item.selectTimeList || [];
- item.finalData = item.finalData || [];
- item.service_min = item.service_min || null;
- item.unit = item.unit || '';
- });
- if(this.currentIndex > valueData.length - 1) {
- this.currentIndex = 0;
- needUpdate = true;
- }
-
- if(valueData[0]){
- if(!valueData[this.currentIndex].isSelect) {
- valueData[this.currentIndex].isSelect = true;
- this.sign_id = valueData[this.currentIndex].sign_id;
- this.currentItem = valueData[this.currentIndex];
- needUpdate = true;
- }
- }
- if (needUpdate) {
- this.$emit('input', valueData);
- }
-
- // 确保视图更新
- this.$nextTick(() => {
- this.$forceUpdate();
- });
- });
- },
- immediate: true,
- deep: true
- },
- },
- computed: {},
- filters: {
- formatAttr(list) {
- let str = '';
- list.forEach(item => {
- str = str + '+' + item.attr_name;
- });
- str = str.substring(1);
- return str;
- }
- },
- methods: {
- onAttr(index) {
- if (this.value[this.currentIndex] && this.value[this.currentIndex].reserve_price_type == 1) {
- this.value[this.currentIndex].finalData = this.$refs.priceSetChild ?
- JSON.parse(JSON.stringify(this.$refs.priceSetChild.selectedDates)) : [];
- }
- this.value.forEach(item => {
- item.isSelect = false;
- });
- this.value[index].isSelect = true;
- this.currentIndex = index;
- this.sign_id = this.value[index].sign_id;
- this.selectListStr = JSON.stringify(this.value[this.currentIndex].selectTimeList || []);
- this.$nextTick(() => {
- if (this.$refs.timeSelectChild) {
- this.$refs.timeSelectChild.initData();
- }
- });
- },
- onRadioChange(val, type) {
- switch (type) {
- case 1:
- this.$set(this.value[this.currentIndex], "reserve_price_type", 0)
- break;
- }
- this.$forceUpdate();
- },
- dateSelectChange(val) {
- let arr = [];
- let txtArr = [{val: 0,txt: '周日',children: []},{val: 1,txt: '周一',children: []},{val: 2,txt: '周二',children: []},{val: 3,txt: '周三',children: []},{val: 4,txt: '周四',children: []},{val: 5,txt: '周五',children: []},{val: 6,txt: '周六',children: []}];
- if (val) {
- let arr1 = [];
- let str1 = val[0];
- let str2 = val[1];
- let unixDb = str1.getTime() - 24 * 60 * 60 * 1000;
- let unixDe = str2.getTime() - 24 * 60 * 60 * 1000;
- for(let j = unixDb; j <= unixDe;){
- j = j + 24 * 60 * 60 * 1000
- arr1.push(new Date(parseInt(j)))
- }
- for(let i = 0; i < arr1.length; i++){
- txtArr.forEach(item => {
- if(item.val == arr1[i].getDay()){
- let fm = this.formatDate(arr1[i])
- item.children.push(fm);
- }
- })
- }
- txtArr.forEach(item => {
- if(item.children.length){
- arr.push(item);
- }
- });
- this.dayArr = arr;
- }
- this.checkWeekList = [];
- let warr = [];
- this.dayArr.forEach(item => {
- warr.push(item.txt);
- });
- this.checkWeekList = [...new Set(warr)];
- this.weekSelectChange();
- },
- dateSelectChange1(val) {
- let arr = [];
- let txtArr = [{val: 0,txt: '周日',children: []},{val: 1,txt: '周一',children: []},{val: 2,txt: '周二',children: []},{val: 3,txt: '周三',children: []},{val: 4,txt: '周四',children: []},{val: 5,txt: '周五',children: []},{val: 6,txt: '周六',children: []}];
- if (val) {
- let arr1 = [];
- let str1 = val[0];
- let str2 = val[1];
- let unixDb = str1.getTime() - 24 * 60 * 60 * 1000;
- let unixDe = str2.getTime() - 24 * 60 * 60 * 1000;
- for(let j = unixDb; j <= unixDe;){
- j = j + 24 * 60 * 60 * 1000
- arr1.push(new Date(parseInt(j)))
- }
- for(let i = 0; i < arr1.length; i++){
- txtArr.forEach(item => {
- if(item.val == arr1[i].getDay()){
- let fm = this.formatDate(arr1[i])
- item.children.push(fm);
- }
- })
- }
- txtArr.forEach(item => {
- if(item.children.length){
- arr.push(item);
- }
- });
- this.value[this.currentIndex].dayArr = arr;
- }
- this.value[this.currentIndex].checkWeekList = [];
- let warr = [];
- this.value[this.currentIndex].dayArr.forEach(item => {
- warr.push(item.txt);
- });
- this.value[this.currentIndex].checkWeekList = [...new Set(warr)];
- this.weekSelectChange1();
- this.$forceUpdate();
- },
- weekSelectChange() {
- let selectArr = [];
- let selectDateArr = [];
- for(let i = 0; i < this.dayArr.length; i++){
- this.checkWeekList.forEach(item => {
- if(item == this.dayArr[i].txt){
- selectArr.push(this.dayArr[i]);
- }
- });
- }
- for(let j = 0; j < selectArr.length; j++){
- selectDateArr = selectDateArr.concat(selectArr[j].children);
- }
- this.unifiedForm.reserve_date = selectDateArr;
- },
- weekSelectChange1() {
- let selectArr = [];
- let selectDateArr = [];
- for(let i = 0; i < this.value[this.currentIndex].dayArr.length; i++){
- this.value[this.currentIndex].checkWeekList.forEach(item => {
- if(item == this.value[this.currentIndex].dayArr[i].txt){
- selectArr.push(this.value[this.currentIndex].dayArr[i]);
- }
- });
- }
- for(let j = 0; j < selectArr.length; j++){
- selectDateArr = selectDateArr.concat(selectArr[j].children);
- }
- this.value[this.currentIndex].reserve_date = selectDateArr;
- this.$forceUpdate();
- },
- formatDate(date) {
- let result = '';
- let year = date.getFullYear().toString().padStart(4, '0');
- let month = (date.getMonth() + 1).toString().padStart(2, '0');
- let day = date.getDate().toString().padStart(2, '0');
- let hour = date.getHours().toString().padStart(2, '0');
- let minute = date.getMinutes().toString().padStart(2, '0');
- let second = date.getSeconds().toString().padStart(2, '0');
- result = `${year}-${month}-${day}`;
- return result;
- },
- resetDateInfo(e) {
- console.log('resetDateInforesetDateInforesetDateInforesetDateInfo----', e)
- this.selectTimeList = JSON.parse(JSON.stringify(e));
- if(this.unifiedForm.reserve_price_type == 1){
- let dates = e;
- if(this.unifiedForm.time_slot_type == 1){
- let arr = [];
- dates.forEach(item => {
- arr.push({
- date: item.date,
- times: item.children,
- isSelect: false
- });
- });
- arr[0].isSelect = true;
- this.$nextTick(() => {
- this.$refs.priceSet.initData(arr);
- });
- }
- if(this.unifiedForm.time_slot_type == 2){
- let arr1 = [];
- dates.forEach(item => {
- arr1.push({
- date: item.date,
- times: item.checkedIntervalList,
- isSelect: false
- });
- });
- arr1[0].isSelect = true;
- this.$nextTick(() => {
- this.$refs.priceSet.initData(arr1);
- });
- }
- }
- },
- resetDateInfo1(e) {
- this.value[this.currentIndex].selectTimeList = JSON.parse(JSON.stringify(e));
- let dates = e;
- // console.log('resetDateInfo1resetDateInfo1resetDateInfo1////',
- // this.currentIndex,
- // this.value[this.currentIndex].reserve_price_type,
- // this.value[this.currentIndex].time_slot_type,
- // this.value[this.currentIndex].reserve_time_range_type, e)
- // this.value[this.currentIndex].reserve_price_type == 0
- // this.value[this.currentIndex].time_slot_type == 1
- // if (this.value[this.currentIndex].reserve_time_range_type == 2) {
- // }
- // if (this.value[this.currentIndex].reserve_price_type == 0 &&
- // this.value[this.currentIndex].time_slot_type == 1 && this.value[this.currentIndex].reserve_time_range_type == 2) {
- // console.log('change finalData', this.currentIndex)
- // this.$set(this.value[this.currentIndex], 'finalData', JSON.parse(JSON.stringify(e)))
- // }
- if(this.value[this.currentIndex].reserve_price_type == 1){
- if(this.value[this.currentIndex].time_slot_type == 1){
- let arr = [];
- dates.forEach(item => {
- arr.push({
- date: item.date,
- times: item.children,
- isSelect: false
- });
- });
- if(this.value[this.currentIndex].finalData.length){
- let tarr = [];
- let selectedList = JSON.parse(JSON.stringify(this.value[this.currentIndex].finalData));
- let rarr2 = [];
- arr.forEach(item => {
- rarr2.push(item.date);
- });
- let rarr3 = [];
- selectedList.forEach(item => {
- if(rarr2.indexOf(item.date) > -1){
- arr.forEach(it => {
- if(it.date == item.date){
- item.times = it.times;
- }
- });
- rarr3.push(item);
- }
- });
- tarr = JSON.parse(JSON.stringify(rarr3));
- let oldDates2 = [];
- tarr.forEach(item => {
- oldDates2.push(item.date);
- });
- for(let i = 0;i < rarr2.length;i++){
- if(oldDates2.indexOf(rarr2[i]) < 0){
- tarr.push({
- date: rarr2[i],
- isSelect: false,
- times: []
- });
- }
- }
- if(tarr.length){
- tarr[0].isSelect = true;
- }
- this.$nextTick(() => {
- this.$refs.priceSetChild.initData(tarr);
- });
- }else{
- if(arr.length){
- arr[0].isSelect = true;
- }
- this.$nextTick(() => {
- this.$refs.priceSetChild.initData(arr);
- });
- }
- }
- if(this.value[this.currentIndex].time_slot_type == 2){
- let arr1 = [];
- dates.forEach(item => {
- arr1.push({
- date: item.date,
- times: item.checkedIntervalList,
- isSelect: false
- });
- });
- if(this.value[this.currentIndex].finalData.length){
- let tarr = [];
- let selectedList = JSON.parse(JSON.stringify(this.value[this.currentIndex].finalData));
- let rarr2 = [];
- arr1.forEach(item => {
- rarr2.push(item.date);
- });
- let rarr3 = [];
- selectedList.forEach(item => {
- if(rarr2.indexOf(item.date) > -1){
- arr1.forEach(it => {
- if(it.date == item.date){
- item.times = it.times;
- }
- });
- rarr3.push(item);
- }
- });
- tarr = JSON.parse(JSON.stringify(rarr3));
- let oldDates2 = [];
- tarr.forEach(item => {
- oldDates2.push(item.date);
- });
- for(let i = 0;i < rarr2.length;i++){
- if(oldDates2.indexOf(rarr2[i]) < 0){
- tarr.push({
- date: rarr2[i],
- isSelect: false,
- times: []
- });
- }
- }
- if(tarr.length){
- tarr[0].isSelect = true;
- }
- this.$nextTick(() => {
- this.$refs.priceSetChild.initData(tarr);
- });
- }else{
- if(arr1.length){
- arr1[0].isSelect = true;
- }
- this.$nextTick(() => {
- this.$refs.priceSetChild.initData(arr1);
- });
- }
- }
- this.$forceUpdate();
- }
- },
- formatInfo() {
- this.value.forEach(item => {
- item.selectTimeList = [];
- if(this.unifiedForm.reserve_price_type == 1){
- item.finalData = JSON.parse(JSON.stringify(this.$refs.priceSet.selectedDates));
- }
- this.selectTimeList.forEach(it => {
- item.selectTimeList.push({
- checkAll: it.checkAll,
- checkedIntervalList: JSON.parse(JSON.stringify(it.checkedIntervalList)),
- children: JSON.parse(JSON.stringify(it.children)),
- date: it.date,
- intervalList: JSON.parse(JSON.stringify(it.intervalList)),
- isIndeterminate: it.isIndeterminate,
- isSelect: it.isSelect,
- });
- });
- item.reserve_date_type = this.unifiedForm.reserve_date_type;
- item.reserve_date = this.unifiedForm.reserve_date;
- item.reserve_time_range_type = this.unifiedForm.reserve_time_range_type;
- item.time_slot_type = this.unifiedForm.time_slot_type;
- item.reserve_time_slot = this.unifiedForm.reserve_time_slot;
- item.reserve_price_type = this.unifiedForm.reserve_price_type;
- item.reserve_time_slot_price = this.unifiedForm.reserve_time_slot_price;
- item.reserve_week = this.unifiedForm.reserve_week;
- item.reserve_max_buy = this.unifiedForm.reserve_max_buy;
- item.price = this.unifiedForm.price;
- item.original_price = this.unifiedForm.original_price;
- item.dayArr = this.dayArr;
- item.checkWeekList = this.checkWeekList;
- item.checkRangeList = this.checkRangeList;
- item.service_min = this.unifiedForm.service_min;
- item.unit = this.unifiedForm.unit;
- if(this.unifiedForm.reserve_price_type == 2){
- item.finalData = JSON.parse(JSON.stringify(this.$refs.priceSet.selectedDates));
- }
- });
- },
- async unifiedSetting() {
- await this.formatInfo();
- this.$nextTick(() => {
- this.formatInfo();
- setTimeout(()=>{
- this.formatInfo();
- this.$refs.timeSelectChild.initData();
- this.dialogFormVisible = false;
- },500);
- });
- },
- onUpdateSelectedDate(val) {
- console.log('this.value[this.currentIndex]', this.value[this.currentIndex])
- this.$set(this.value[this.currentIndex], 'finalData', val)
- // this.value[this.currentIndex].finalData = val
- }
- }
- });
- </script>
|