添加颜色信息 修改属性
This commit is contained in:
@@ -9,6 +9,13 @@ from Simple_Drawing.settings import BASE_DIR
|
||||
url_ = "127.0.0.1:8000"
|
||||
|
||||
|
||||
def random_color():
|
||||
color_list = ["#009688", '#5FB878', '#393D49',
|
||||
'#1E9FFF', '#FFB800', '#FF5722',
|
||||
'#01AAED', '#2F4056']
|
||||
return random.choice(color_list)
|
||||
|
||||
|
||||
# 保存单个文件
|
||||
def keep_file(file_data, file_path, file_name=None, ui=0):
|
||||
if file_name is not None:
|
||||
@@ -87,7 +94,6 @@ class ChartParameter(object):
|
||||
if 'Senior' in data:
|
||||
self.Senior = data['Senior']
|
||||
|
||||
self.colors = 0
|
||||
self.colors_dict = {}
|
||||
|
||||
def html_out_Basics(self):
|
||||
@@ -121,18 +127,18 @@ class ChartParameter(object):
|
||||
style="height: 25px; width:80px;margin-top: 6px">
|
||||
"""
|
||||
if parameter.input_type == "color_name":
|
||||
self.colors_dict[f"color{self.colors}"] = "color_name"
|
||||
self.colors_dict[f"{parameter.name}"] = "color_name"
|
||||
parameter.input_type = f"""
|
||||
<div style="margin-left: 30px;">
|
||||
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
|
||||
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
|
||||
</div>
|
||||
"""
|
||||
self.colors += 1
|
||||
|
||||
if parameter.input_type == "rgb":
|
||||
self.colors_dict[f"color{self.colors}"] = "rgb"
|
||||
self.colors_dict[f"{parameter.name}"] = "rgb"
|
||||
f"""
|
||||
<div style="margin-left: 30px;">
|
||||
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
|
||||
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
|
||||
</div>
|
||||
"""
|
||||
self.colors += 1
|
||||
@@ -239,21 +245,21 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px">
|
||||
style="height: 25px; width:80px;margin-top: 6px">
|
||||
"""
|
||||
if parameter.input_type == "color_name":
|
||||
self.colors_dict[f"color{self.colors}"] = "color_name"
|
||||
self.colors_dict[f"{parameter.name}"] = "color_name"
|
||||
parameter.input_type = f"""
|
||||
<div style="margin-left: 30px;">
|
||||
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
|
||||
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
|
||||
</div>
|
||||
"""
|
||||
self.colors += 1
|
||||
|
||||
if parameter.input_type == "rgb":
|
||||
self.colors_dict[f"color{self.colors}"] = "rgb"
|
||||
self.colors_dict[f"{parameter.name}"] = "rgb"
|
||||
f"""
|
||||
<div style="margin-left: 30px;">
|
||||
<div id="color{self.colors}" style="margin-left: 30px; display: inline-block"></div>
|
||||
<div id="{parameter.name}" style="margin-left: 30px; display: inline-block"></div>
|
||||
</div>
|
||||
"""
|
||||
self.colors += 1
|
||||
|
||||
if parameter.input_type == "palettes":
|
||||
parameter.input_type = f"""
|
||||
<select {parameter.astrict} id="{parameter.name}" lay-verify="required" value="{parameter.value}" autocomplete="off"
|
||||
@@ -330,13 +336,24 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px">
|
||||
for title in self.Basics:
|
||||
for d in self.Basics[title]:
|
||||
parameter = ChartParameter(d)
|
||||
code += f"""{parameter.name}: (document.getElementById("{parameter.name}").value),
|
||||
|
||||
if parameter.input_type in ["rgb","hex",'color_name']:
|
||||
code += f"""{parameter.name}:{parameter.name},
|
||||
"""
|
||||
else:
|
||||
code += f"""{parameter.name}: (document.getElementById("{parameter.name}").value),
|
||||
"""
|
||||
print(parameter.input_type)
|
||||
for title in self.Senior:
|
||||
for d in self.Senior[title]:
|
||||
parameter = ChartParameter(d)
|
||||
code += f"""{parameter.name}: (document.getElementById("{parameter.name}").value),
|
||||
"""
|
||||
print(parameter.input_type)
|
||||
if parameter.input_type in ["rgb", "hex",'color_name']:
|
||||
code += f"""{parameter.name}:{parameter.name},
|
||||
"""
|
||||
else:
|
||||
code += f"""{parameter.name}: (document.getElementById("{parameter.name}").value),
|
||||
"""
|
||||
return code
|
||||
|
||||
def color_js(self):
|
||||
@@ -353,16 +370,17 @@ class="layui-input" style="height: 25px; width:80px;margin-top: 6px">
|
||||
, colorpicker = layui.colorpicker;
|
||||
|
||||
colorpicker.render({
|
||||
elem: '%s'
|
||||
, color: '#2ec770' //设置默认色
|
||||
elem: '#%s'
|
||||
, color: '%s' //设置默认色
|
||||
, size: "xs"
|
||||
, format: '%s'
|
||||
, done: function (color) {
|
||||
layer.tips('选择了:' + color, this.elem);
|
||||
var %s = color
|
||||
|
||||
}
|
||||
});
|
||||
})
|
||||
""" % (i, fl)
|
||||
""" % (i, random_color(), fl,i)
|
||||
|
||||
return code
|
||||
|
||||
|
||||
Reference in New Issue
Block a user