|
@@ -52,7 +52,7 @@
|
|
|
size="small"
|
|
|
>
|
|
|
<el-option
|
|
|
- v-for="ele in item.gradeList||[]"
|
|
|
+ v-for="ele in item.gradeList || []"
|
|
|
:key="ele.id"
|
|
|
:label="ele.grade"
|
|
|
:value="ele.id.toString()"
|
|
@@ -61,18 +61,21 @@
|
|
|
</el-select>
|
|
|
</div>
|
|
|
<div>
|
|
|
- 满<el-input-number
|
|
|
+ 满
|
|
|
+ <el-input-number
|
|
|
v-model="item.ruleTerms"
|
|
|
:min="0"
|
|
|
size="small"
|
|
|
/>元(L) 开始积分
|
|
|
</div>
|
|
|
<div>
|
|
|
- 每消费<el-input-number
|
|
|
+ 每消费
|
|
|
+ <el-input-number
|
|
|
v-model="item.saleAmt"
|
|
|
size="small"
|
|
|
:min="0"
|
|
|
- />元获得<el-input-number
|
|
|
+ />元获得
|
|
|
+ <el-input-number
|
|
|
v-model="item.integral"
|
|
|
size="small"
|
|
|
:min="0"
|
|
@@ -142,7 +145,6 @@
|
|
|
v-model="form.datePicker"
|
|
|
clearable
|
|
|
size="small"
|
|
|
- @change="datePickerChang"
|
|
|
>
|
|
|
<el-option label="每周指定日" value="1"></el-option>
|
|
|
<el-option label="每月指定日" value="2"></el-option>
|
|
@@ -170,7 +172,7 @@
|
|
|
font-size: 12px;
|
|
|
cursor: pointer;
|
|
|
"
|
|
|
- @click="clickCalendar(item, index)"
|
|
|
+ @click="clickCalendar(index)"
|
|
|
>
|
|
|
<div>{{ item }}</div>
|
|
|
<div
|
|
@@ -295,7 +297,9 @@ export default {
|
|
|
},
|
|
|
// 表单校验
|
|
|
rules: {},
|
|
|
- headers: { Authorization: "Bearer " + getToken() },
|
|
|
+ headers: {
|
|
|
+ Authorization: "Bearer " + getToken(),
|
|
|
+ },
|
|
|
collectClickCalendar: [], // 收集固定日期选择的日子
|
|
|
collectClickWorkDay: [],
|
|
|
timeSelect: [
|
|
@@ -347,6 +351,13 @@ export default {
|
|
|
listRuleOne(this.queryParams).then((response) => {
|
|
|
console.log("拉取", response.data);
|
|
|
this.form = response.data;
|
|
|
+ if (datepicker == "1" || datepicker == "2") {
|
|
|
+ this.collectClickWorkDay = this.form.datePickerTime
|
|
|
+ .split(",")
|
|
|
+ .map(parseFloat);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
listRuleOne(this.queryParams).then((response) => {
|
|
@@ -358,32 +369,22 @@ export default {
|
|
|
if (this.form.itemsDetail.length == 0) {
|
|
|
this.form.itemsDetail = [{}];
|
|
|
} else {
|
|
|
- let itemDetail = this.form.itemsDetail;
|
|
|
- this.initGrade(itemDetail);
|
|
|
this.rowsnum = this.form.itemsDetail.length - 1;
|
|
|
}
|
|
|
} else {
|
|
|
this.form.itemsDetail = [{}];
|
|
|
}
|
|
|
let datepicker = this.form.datePicker;
|
|
|
- if (datepicker == "1") {
|
|
|
+ if (datepicker == "1" || datepicker == "2") {
|
|
|
this.workDaytrue = true;
|
|
|
- if (this.form.datePickerTime != null) {
|
|
|
- this.collectClickWorkDay = this.form.datePickerTime
|
|
|
- .split(",")
|
|
|
- .map(parseFloat);
|
|
|
- }
|
|
|
- } else if (datepicker == "2") {
|
|
|
- this.moonDaytrue = true;
|
|
|
- if (this.form.datePickerTime != null) {
|
|
|
- this.collectClickCalendar = this.form.datePickerTime
|
|
|
- .split(",")
|
|
|
- .map(parseFloat);
|
|
|
- }
|
|
|
+ this.collectClickWorkDay = this.form.datePickerTime
|
|
|
+ .split(",")
|
|
|
+ .map(parseFloat);
|
|
|
+
|
|
|
} else {
|
|
|
- this.datetrue = true;
|
|
|
if (this.form.datePickerTime != null) {
|
|
|
this.pickerTime = this.form.datePickerTime.split(",");
|
|
|
+
|
|
|
} else {
|
|
|
this.pickerTime = null;
|
|
|
}
|
|
@@ -399,10 +400,15 @@ export default {
|
|
|
methods: {
|
|
|
async initGrade(itemDetail) {
|
|
|
for (let j = 0; j < itemDetail.length; j++) {
|
|
|
- const response = await gradeList({ oilName: itemDetail[j].oilName });
|
|
|
+ const response = await gradeList({
|
|
|
+ oilName: itemDetail[j].oilName,
|
|
|
+ });
|
|
|
console.log("12");
|
|
|
console.log(response);
|
|
|
- response.rows.push({ id: 0, grade: "所有人" });
|
|
|
+ response.rows.push({
|
|
|
+ id: 0,
|
|
|
+ grade: "所有人",
|
|
|
+ });
|
|
|
this.gradeOptions.push(response.rows);
|
|
|
}
|
|
|
},
|
|
@@ -414,8 +420,8 @@ export default {
|
|
|
// 删除行
|
|
|
del(index) {
|
|
|
this.form.itemsDetail.splice(index, 1);
|
|
|
- if (this.form.itemsDetail.length <= 1){
|
|
|
- this.form.itemsDetail= [{}];
|
|
|
+ if (this.form.itemsDetail.length <= 1) {
|
|
|
+ this.form.itemsDetail = [{}];
|
|
|
}
|
|
|
},
|
|
|
delNoil() {
|
|
@@ -423,15 +429,19 @@ export default {
|
|
|
},
|
|
|
oilNameChang(item, index) {
|
|
|
gradeList({
|
|
|
- oilName:item.oilName
|
|
|
+ oilName: item.oilName,
|
|
|
}).then((response) => {
|
|
|
- item.gradeList = response.rows
|
|
|
- this.form = {...this.form}
|
|
|
+ item.gradeList = response.rows;
|
|
|
+ this.form = {
|
|
|
+ ...this.form,
|
|
|
+ };
|
|
|
});
|
|
|
|
|
|
queryOilType(item.oilName).then((res) => {
|
|
|
item.oilType = res;
|
|
|
- this.form = { ...this.form };
|
|
|
+ this.form = {
|
|
|
+ ...this.form,
|
|
|
+ };
|
|
|
});
|
|
|
},
|
|
|
|
|
@@ -441,7 +451,10 @@ export default {
|
|
|
for (let i = 0; i < fileList.length; i++) {
|
|
|
let fileName = fileList[i].name;
|
|
|
let imgurl = fileList[i].url;
|
|
|
- this.form.imgFileList.push({ name: fileName, url: imgurl });
|
|
|
+ this.form.imgFileList.push({
|
|
|
+ name: fileName,
|
|
|
+ url: imgurl,
|
|
|
+ });
|
|
|
}
|
|
|
} else {
|
|
|
this.form.imgFileList = fileList;
|
|
@@ -462,7 +475,10 @@ export default {
|
|
|
location.host +
|
|
|
process.env.VUE_APP_BASE_API +
|
|
|
response.fileName;
|
|
|
- this.form.imgFileList.push({ name: file.name, url: imgurl });
|
|
|
+ this.form.imgFileList.push({
|
|
|
+ name: file.name,
|
|
|
+ url: imgurl,
|
|
|
+ });
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
@@ -471,58 +487,11 @@ export default {
|
|
|
if (valid) {
|
|
|
if (this.form.id != null) {
|
|
|
let datepicker = this.form.datePicker;
|
|
|
+ console.log("你好", this.collectClickWorkDay);
|
|
|
if (datepicker == "1") {
|
|
|
- if (
|
|
|
- this.collectClickWorkDay != null &&
|
|
|
- this.collectClickWorkDay.length > 0
|
|
|
- ) {
|
|
|
- let discountTime = null;
|
|
|
- for (let i = 0; i < this.collectClickWorkDay.length; i++) {
|
|
|
- if (
|
|
|
- !isNaN(this.collectClickWorkDay[i]) &&
|
|
|
- this.collectClickWorkDay[i] != "NaN"
|
|
|
- ) {
|
|
|
- if (discountTime != null) {
|
|
|
- discountTime =
|
|
|
- discountTime + "," + this.collectClickWorkDay[i];
|
|
|
- } else {
|
|
|
- discountTime = this.collectClickWorkDay[i];
|
|
|
- }
|
|
|
- } else {
|
|
|
- discountTime = discountTime;
|
|
|
- }
|
|
|
- }
|
|
|
- this.form.datePickerTime = discountTime;
|
|
|
- discountTime = null;
|
|
|
- } else {
|
|
|
- this.form.datePickerTime = "";
|
|
|
- }
|
|
|
+ this.form.datePickerTime = this.collectClickWorkDay.toString();
|
|
|
} else if (datepicker == "2") {
|
|
|
- if (
|
|
|
- this.collectClickCalendar != null &&
|
|
|
- this.collectClickCalendar.length > 0
|
|
|
- ) {
|
|
|
- let discountTime = null;
|
|
|
- for (let i = 0; i < this.collectClickCalendar.length; i++) {
|
|
|
- if (
|
|
|
- !isNaN(this.collectClickCalendar[i]) &&
|
|
|
- this.collectClickCalendar[i] != "NaN"
|
|
|
- ) {
|
|
|
- if (discountTime != null) {
|
|
|
- discountTime =
|
|
|
- discountTime + "," + this.collectClickCalendar[i];
|
|
|
- } else {
|
|
|
- discountTime = this.collectClickCalendar[i];
|
|
|
- }
|
|
|
- } else {
|
|
|
- discountTime = discountTime;
|
|
|
- }
|
|
|
- }
|
|
|
- this.form.datePickerTime = discountTime;
|
|
|
- discountTime = null;
|
|
|
- } else {
|
|
|
- this.form.datePickerTime = "";
|
|
|
- }
|
|
|
+ this.form.datePickerTime = this.collectClickWorkDay.toString();
|
|
|
} else {
|
|
|
if (this.pickerTime != null) {
|
|
|
this.form.datePickerTime = this.pickerTime.toString();
|
|
@@ -658,80 +627,24 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- deleteItemFromArr(item) {
|
|
|
- // eslint-disable-next-line
|
|
|
- Array.prototype.indexOf = function (val) {
|
|
|
- for (var i = 0; i < this.length; i++) {
|
|
|
- if (this[i] === val) {
|
|
|
- return i;
|
|
|
- }
|
|
|
- }
|
|
|
- return -1;
|
|
|
- };
|
|
|
- // 通过索引删除数组元素
|
|
|
- Array.prototype.remove = function (val) {
|
|
|
- var index = this.indexOf(val);
|
|
|
- if (index > -1) {
|
|
|
- this.splice(index, 1);
|
|
|
- }
|
|
|
- };
|
|
|
- // 删除数组元素
|
|
|
- this.collectClickCalendar.remove(item);
|
|
|
- },
|
|
|
- clickCalendar(item, index) {
|
|
|
+ clickCalendar(index) {
|
|
|
if (this.collectClickCalendar.indexOf(index) === -1) {
|
|
|
this.collectClickCalendar.push(index);
|
|
|
} else if (this.collectClickCalendar.indexOf(index) > -1) {
|
|
|
- this.deleteItemFromArr(index);
|
|
|
- }
|
|
|
- },
|
|
|
- deleteWorkDayFromArr(item) {
|
|
|
- Array.prototype.indexOf = function (val) {
|
|
|
- for (var i = 0; i < this.length; i++) {
|
|
|
- if (this[i] === val) {
|
|
|
- return i;
|
|
|
- }
|
|
|
- }
|
|
|
- return -1;
|
|
|
- };
|
|
|
- // 通过索引删除数组元素
|
|
|
- Array.prototype.remove = function (val) {
|
|
|
- var index = this.indexOf(val);
|
|
|
- if (index > -1) {
|
|
|
- this.splice(index, 1);
|
|
|
- }
|
|
|
- };
|
|
|
- // 删除数组元素
|
|
|
- this.collectClickWorkDay.remove(item);
|
|
|
- },
|
|
|
- clickWorkDayCalendar(item, index) {
|
|
|
- if (this.collectClickWorkDay.indexOf(index) === -1) {
|
|
|
- this.collectClickWorkDay.push(index);
|
|
|
- } else if (this.collectClickWorkDay.indexOf(index) > -1) {
|
|
|
- this.deleteWorkDayFromArr(index);
|
|
|
- }
|
|
|
- },
|
|
|
- datePickerChang() {
|
|
|
- if (this.form.datePicker == "1") {
|
|
|
- this.workDaytrue = true;
|
|
|
- this.moonDaytrue = false;
|
|
|
- this.datetrue = false;
|
|
|
- } else if (this.form.datePicker == "2") {
|
|
|
- this.workDaytrue = false;
|
|
|
- this.moonDaytrue = true;
|
|
|
- this.datetrue = false;
|
|
|
- } else if (this.form.datePicker == "3") {
|
|
|
- this.workDaytrue = false;
|
|
|
- this.moonDaytrue = false;
|
|
|
- this.datetrue = true;
|
|
|
+ const temp = this.collectClickCalendar.findIndex((ele)=>{
|
|
|
+ return ele == index
|
|
|
+ })
|
|
|
+ console.log(temp);
|
|
|
+ this.collectClickCalendar.splice(temp,1)
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
|
+
|
|
|
<style scoped>
|
|
|
.hover-style:hover {
|
|
|
color: white;
|
|
|
background-color: blue;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|