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

opt

parent 2912f34c
...@@ -8,7 +8,8 @@ Component({ ...@@ -8,7 +8,8 @@ Component({
props: { props: {
limit: 20, limit: 20,
list: [], list: [],
onChange: () => {} onChange: () => {},
dataName: ''
}, },
didMount() {}, didMount() {},
didUpdate() {}, didUpdate() {},
...@@ -46,19 +47,19 @@ Component({ ...@@ -46,19 +47,19 @@ Component({
this.setData({ dialogVisible: false }) this.setData({ dialogVisible: false })
}, },
onPrizeUpdate(data, index) { onPrizeUpdate(data, index) {
const { onChange, list } = this.props; const { onChange, list, dataName } = this.props;
const updatedData = list.map((v, i) => { const updatedData = list.map((v, i) => {
if(index === i) return {...v, ...data} if(index === i) return {...v, ...data}
return v; return v;
}) })
onChange && onChange(updatedData) onChange && onChange(updatedData, dataName)
}, },
onPrizeAdd(data) { 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({ ...@@ -11,7 +11,8 @@ Component({
fixedRank: [], fixedRank: [],
maxRankLimit: '', maxRankLimit: '',
list: [], list: [],
onChange: () => {} onChange: () => {},
dataName: ''
}, },
didMount() {}, didMount() {},
didUpdate() {}, didUpdate() {},
...@@ -54,17 +55,17 @@ Component({ ...@@ -54,17 +55,17 @@ Component({
this.setData({ dialogVisible: false }) this.setData({ dialogVisible: false })
}, },
onPrizeUpdate(data, index) { onPrizeUpdate(data, index) {
const { onChange, list } = this.props; const { onChange, list, dataName } = this.props;
const updatedData = list.map((v, i) => { const updatedData = list.map((v, i) => {
if(index === i) return {...v, ...data} if(index === i) return {...v, ...data}
return v; return v;
}) })
onChange && onChange(updatedData) onChange && onChange(updatedData, dataName)
}, },
onPrizeAdd(data) { onPrizeAdd(data) {
const { list, onChange } = this.props; const { list, onChange, dataName } = this.props;
let newList = [...list, data].sort((a, b) => { let newList = [...list, data].sort((a, b) => {
let prevRank = a.rank.split('-')[0] let prevRank = a.rank.split('-')[0]
...@@ -72,7 +73,7 @@ Component({ ...@@ -72,7 +73,7 @@ Component({
return prevRank - nextRank; return prevRank - nextRank;
}) })
onChange && onChange(newList) onChange && onChange(newList, dataName)
} }
}, },
}); });
...@@ -200,7 +200,7 @@ Component({ ...@@ -200,7 +200,7 @@ Component({
rule rule
}) })
}, },
setDataByKey(name, val) { setDataByKey(val, name) {
const keys = name.split('.'); const keys = name.split('.');
if (keys.length === 1) { if (keys.length === 1) {
this.setData({ this.setData({
...@@ -224,14 +224,14 @@ Component({ ...@@ -224,14 +224,14 @@ Component({
}) })
} }
}, },
onTaskInputChange(e) { onConfigInputChange(e) {
const { const {
name name
} = e.target.dataset; } = e.target.dataset;
const { const {
value value
} = e.detail; } = e.detail;
this.setDataByKey(name, value); this.setDataByKey(value, name);
}, },
onCheckChange(e) { onCheckChange(e) {
const { const {
...@@ -240,11 +240,11 @@ Component({ ...@@ -240,11 +240,11 @@ Component({
const { const {
value value
} = e.detail; } = e.detail;
this.setDataByKey(name, value); this.setDataByKey(value, name);
}, },
onTaskChange(data, key) { onTaskChange(data, key) {
console.log(data, key) console.log(data, key)
this.setDataByKey(key, data); this.setDataByKey(data, key);
}, },
onImageChange(image) { onImageChange(image) {
console.log('image', image) console.log('image', image)
...@@ -271,10 +271,9 @@ Component({ ...@@ -271,10 +271,9 @@ Component({
}) })
}, },
onPrizeListChange(prizeInfoList) { onPrizeListChange(list, target) {
console.log('prizeInfoList', prizeInfoList);
this.setData({ this.setData({
prizeInfoList [target]: list
}) })
}, },
validateForm(data, target) { validateForm(data, target) {
...@@ -440,7 +439,7 @@ Component({ ...@@ -440,7 +439,7 @@ Component({
}) })
}, },
onChangeByDataName(val, dataName) { onChangeByDataName(val, dataName) {
this.setDataByKey(dataName, val) this.setDataByKey(val, dataName)
}, },
onCloseDialog(data) { 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