electricControl/.bin/main/set.js

210 lines
4.9 KiB
JavaScript
Raw Normal View History

2023-08-04 09:20:01 +08:00
(function() {
var Set = /*@__PURE__*/ (function(Component) {
function Set(props) {
Component.call(this, props);
this.data = {
setList: [
{
isSet: false,
setVal: "",
selectVal: "请选择",
selectIndex: 0,
name: "高压风冷"
},
{
isSet: true,
setVal: "",
selectVal: "请选择",
selectIndex: 0,
name: "中压风冷"
},
{
isSet: false,
setVal: "",
selectVal: "请选择",
selectIndex: 0,
name: "低压风冷"
},
{
isSet: true,
setVal: "",
selectVal: "请选择",
selectIndex: 0,
name: "闭锁调压"
}
],
//电流通道列表
currentList: ["1路", "2路", "3路", "4路"]
};
}
if (Component) Set.__proto__ = Component;
Set.prototype = Object.create(Component && Component.prototype);
Set.prototype.constructor = Set;
Set.prototype.apiready = function() {
var selector0 = document.getElementById("selector0");
var selector1 = document.getElementById("selector1");
var selector2 = document.getElementById("selector2");
var selector3 = document.getElementById("selector3");
selector0.setData({
data: this.data.currentList
});
selector1.setData({
data: this.data.currentList
});
selector2.setData({
data: this.data.currentList
});
selector3.setData({
data: this.data.currentList
});
};
Set.prototype.handleBackIndex = function() {
api.navigateBack({
delta: 2
});
};
Set.prototype.handleSwitchChange = function(e) {
var _index = e.target.attributes.index;
this.data.setList.forEach(function(item, index) {
if (index === _index) {
item.isSet = e.detail.value;
}
});
};
Set.prototype.handleSelectChange = function(e) {
var this$1 = this;
var _index = e.target.attributes.index;
this.data.setList.forEach(function(item, index) {
if (index === _index) {
item.selectIndex = e.detail.value;
item.selectVal = this$1.data.currentList[e.detail.value];
}
});
};
Set.prototype.render = function() {
var this$1 = this;
return apivm.h(
"view",
{class: "set_wrap"},
apivm.h(
"text",
{class: "set_back_text", onClick: this.handleBackIndex},
"返回"
),
apivm.h(
"view",
{class: "set_list"},
(Array.isArray(this.data.setList)
? this.data.setList
: Object.values(this.data.setList)
).map(function(item$1, index$1) {
return apivm.h(
"view",
{class: "list_inline"},
apivm.h(
"view",
{class: "inline_item"},
apivm.h("text", {class: "item_label"}, item$1.name, ""),
apivm.h(
"view",
{class: "item_content"},
apivm.h(
"view",
{class: "switch_box"},
apivm.h("switch", {
class: "switch",
index: index$1,
checked: item$1.isSet,
onChange: this$1.handleSwitchChange
})
),
apivm.h("input", {
class: "input",
type: "text",
disabled: !item$1.isSet,
placeholder: "请输入电流值"
})
)
),
apivm.h(
"view",
{class: "inline_item"},
apivm.h("text", {class: "item_label"}, "电流通道:"),
apivm.h(
"view",
{class: "item_content"},
apivm.h(
"picker",
{
class: "picker",
id: "selector" + index$1,
index: index$1,
mode: "selector",
value: item$1.selectIndex,
onChange: this$1.handleSelectChange
},
apivm.h("text", {class: "item_label"}, item$1.selectVal)
)
)
)
);
})
)
);
};
return Set;
})(Component);
Set.css = {
".set_wrap": {
width: "100%",
height: "100vh",
boxSizing: "border-box",
padding: "20px"
},
".set_back_text": {fontSize: "40px", color: "#000000", fontWeight: "bold"},
".set_list": {marginTop: "50px", display: "flex", alignItems: "center"},
".list_inline": {
display: "flex",
flexDirection: "row",
alignItems: "center",
margin: "10px 0"
},
".inline_item": {
margin: "0 40px",
display: "flex",
flexDirection: "row",
alignItems: "center"
},
".item_label": {fontSize: "40px", fontWeight: "bold", color: "#000000"},
".item_content": {
display: "flex",
flexDirection: "row",
alignItems: "center"
},
".switch_box": {
display: "flex",
justifyContent: "center",
alignItems: "center",
width: "76px",
height: "46px"
},
".switch": {transform: "scale(1.5, 1.5)"},
".input": {
boxSizing: "border-box",
padding: "5px",
border: "1px solid silver",
fontSize: "32px",
height: "60px",
width: "200px",
marginLeft: "20px",
borderRadius: "10px"
}
};
apivm.define("set", Set);
apivm.render(apivm.h("set", null), "body");
})();