Commit 4bc2bfc3 authored by 秦海涛's avatar 秦海涛

opt

parent 2912f34c
......@@ -8,7 +8,8 @@ Component({
props: {
limit: 20,
list: [],
onChange: () => {}
onChange: () => {},
dataName: ''
},
didMount() {},
didUpdate() {},
......@@ -46,19 +47,19 @@ Component({
this.setData({ dialogVisible: false })
},
onPrizeUpdate(data, index) {
const { onChange, list } = this.props;
const { onChange, list, dataName } = this.props;
const updatedData = list.map((v, i) => {
if(index === i) return {...v, ...data}
return v;
})
onChange && onChange(updatedData)
onChange && onChange(updatedData, dataName)
},
onPrizeAdd(data) {
const { list, onChange } = this.props;
const { list, onChange, dataName } = this.props;
onChange && onChange([...list, data])
onChange && onChange([...list, data], dataName)
}
},
});
......@@ -11,7 +11,8 @@ Component({
fixedRank: [],
maxRankLimit: '',
list: [],
onChange: () => {}
onChange: () => {},
dataName: ''
},
didMount() {},
didUpdate() {},
......@@ -54,17 +55,17 @@ Component({
this.setData({ dialogVisible: false })
},
onPrizeUpdate(data, index) {
const { onChange, list } = this.props;
const { onChange, list, dataName } = this.props;
const updatedData = list.map((v, i) => {
if(index === i) return {...v, ...data}
return v;
})
onChange && onChange(updatedData)
onChange && onChange(updatedData, dataName)
},
onPrizeAdd(data) {
const { list, onChange } = this.props;
const { list, onChange, dataName } = this.props;
let newList = [...list, data].sort((a, b) => {
let prevRank = a.rank.split('-')[0]
......@@ -72,7 +73,7 @@ Component({
return prevRank - nextRank;
})
onChange && onChange(newList)
onChange && onChange(newList, dataName)
}
},
});
......@@ -200,7 +200,7 @@ Component({
rule
})
},
setDataByKey(name, val) {
setDataByKey(val, name) {
const keys = name.split('.');
if (keys.length === 1) {
this.setData({
......@@ -224,14 +224,14 @@ Component({
})
}
},
onTaskInputChange(e) {
onConfigInputChange(e) {
const {
name
} = e.target.dataset;
const {
value
} = e.detail;
this.setDataByKey(name, value);
this.setDataByKey(value, name);
},
onCheckChange(e) {
const {
......@@ -240,11 +240,11 @@ Component({
const {
value
} = e.detail;
this.setDataByKey(name, value);
this.setDataByKey(value, name);
},
onTaskChange(data, key) {
console.log(data, key)
this.setDataByKey(key, data);
this.setDataByKey(data, key);
},
onImageChange(image) {
console.log('image', image)
......@@ -271,10 +271,9 @@ Component({
})
},
onPrizeListChange(prizeInfoList) {
console.log('prizeInfoList', prizeInfoList);
onPrizeListChange(list, target) {
this.setData({
prizeInfoList
[target]: list
})
},
validateForm(data, target) {
......@@ -440,7 +439,7 @@ Component({
})
},
onChangeByDataName(val, dataName) {
this.setDataByKey(dataName, val)
this.setDataByKey(val, dataName)
},
onCloseDialog(data) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment