Commit 78aec937 by 姜雷

添加启用禁用交互

parent 3503c3c8
......@@ -166,38 +166,54 @@ Component({
if (!this.data.dataList[status].length) this.refreshList();
},
openEquipment(e) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/enable`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
wx.showModal({
title: '提示',
content: '是否启用设备',
success: res => {
if (res.confirm) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/enable`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
}
},
});
},
closeEquipment(e) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/forbidden`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
wx.showModal({
title: '提示',
content: '是否禁用设备',
success: res => {
if (res.confirm) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/forbidden`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
}
},
});
},
},
});
......@@ -53,7 +53,10 @@
}
.EquipmentState-elist-ItemLocation {
margin-left: 20rpx;
flex: 1;
width: 340rpx;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.EquipmentState-elist-ItemBtn {
width: 80rpx;
......
import { deviceFetch } from '../../../api/fetch';
let warningLevelRangeOption = { key: null, value: '' };
// pages/components/EquipmentWarning/EquipmentWarning.js
Component({
lifetimes: {
......@@ -49,7 +50,7 @@ Component({
.then(res => {
console.log(res);
this.setData({
warningLevelRange: res.data,
warningLevelRange: [warningLevelRangeOption, ...res.data],
});
})
.catch(err => {
......@@ -61,10 +62,18 @@ Component({
if (index === this.data.warnLevelIndex) return;
const item = this.data.warningLevelRange[index];
console.log(item);
this.setData({
warnLevelIndex: index,
warnLevel: item.key,
});
if (item.key) {
this.setData({
warnLevelIndex: index,
warnLevel: item.key,
});
} else {
this.setData({
warnLevelIndex: '',
warnLevel: 0,
});
}
this.refreshList();
},
changeLocation(e) {
......@@ -147,38 +156,54 @@ Component({
});
},
openEquipment(e) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/enable`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
wx.showModal({
title: '提示',
content: '是否启用设备',
success: res => {
if (res.confirm) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/enable`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
}
},
});
},
closeEquipment(e) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/forbidden`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
wx.showModal({
title: '提示',
content: '是否禁用设备',
success: res => {
if (res.confirm) {
const { code, type } = e.currentTarget.dataset;
console.log(code);
deviceFetch({
url: `/device/${code}/${type}/forbidden`,
method: 'POST',
})
.then(res => {
wx.showToast({
title: res.msg || '操作成功',
});
this.refreshList();
})
.catch(err => {
console.log(err);
});
}
},
});
},
},
});
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