liaoxujun@qq.com
2024-02-19 c32275f697e1541694836c47e1682e3291673dbc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
@model cy_scdz.ViewModel.Setting.SettingVm
@inject IStringLocalizer<Program> Localizer;
 
 
 
@for (int i = 0; i < Model.allNodesWithChildren.Count; i++)
{
    <div class="setfix set_allitem">
        <div class="content">
            <div class="text-justified bold-text tabsetsys">  @Model.allNodesWithChildren[i].Name:</div>
        </div>
        <div class="setfix">
            @for (int ix = 0; ix < Model.allNodesWithChildren[i].Children.Count; ix++)
            {
 
 
                <div class="content">
                    <div class="text-justified  itemsetsys">  @Model.allNodesWithChildren[i].Children.ToArray()[ix].Name</div>
                </div>
 
            }
            @if (Model.allNodesWithChildren[i].Key == "zbgys" || Model.allNodesWithChildren[i].Key == "fmzz" || Model.allNodesWithChildren[i].Key == "nyzz")
            {
                <button class="itemsetbutsys layui-btn-submit" id="@Model.allNodesWithChildren[i].Key">自定义增加</button>
            }
        </div>
    </div>
 
}
 
 
<style>
    .set_allitem {
        margin: 5px 0px;
    }
 
    .set_content {
        width: 100%;
        text-align: justify;
    }
 
    .text-justified {
        text-align: justify;
    }
 
        /* 对于现代浏览器(包括IE10+)的完整支持,可以添加以下样式以处理最后一行 */
        .text-justified:last-child::after {
            content: "";
            display: inline-block;
            width: 100%;
        }
 
    .font-black {
        color: #000000;
        /* 或者简写为 */
        color: black;
    }
 
    .bold-text {
        font-weight: bold;
    }
 
    .setfix {
        display: flex;
        height: 20px;
    }
 
    .tabsetsys {
        /* 标题偏移*/
        padding-left: 10px;
        width: 80px;
    }
 
    .itemsetbutsys {
        margin: 0px 10px;
    }
 
    .itemsetsys {
        /* 标题偏移*/
        padding: 0px 10px;
    }
</style>
 
 
<script>
    layui.use(['layer', 'jquery'], function () {
        var layer = layui.layer;
        var $ = layui.jquery;
 
        // 为所有具有特定类名(如:layui-btn-submit)的按钮绑定点击事件
        $('.layui-btn-submit').on('click', function (event) {
            event.preventDefault(); // 阻止默认行为
 
            // 获取当前点击按钮的id属性值
            var buttonId = "";
            switch (this.id) {
                case 'zbgys':
                    buttonId = "请输入新增中标供应商名称";
                    break;
                case 'fmzz':
                    buttonId = "请输入新增封面纸张规格";
                    break;
                case 'nyzz':
                    buttonId = "请输入新增内页纸张规格";
                    break;
                default:
                    buttonId = "";
                    break;
 
            }
 
            var btid = this.id;
 
            // 弹出一个对话框让用户输入内容
            layer.prompt({
                title: buttonId,
                formType: 0 // 0 表示文本输入框
            }, function (value, index, elem) {
                // 在这里执行提交逻辑,例如向服务器发送数据等
                submitData(btid, value, index);
 
            });
        });
 
        function submitData(id, value, index) {
           
            $.ajax({
                url: "/Setting/Setting/Edit",
                type: "POST"
                , contentType: "application/json; charset=utf-8"
                , dataType: "json"
                , data: JSON.stringify({ key: id, name: value })
 
 
                , success: function (result) {
                    debugger
                    if (result.code == 1) {
                        window.location.reload();
                        layer.alert(`写入成功`, {
                            icon: 0, // 设置图标为警告图标
                            title: '提示'
                        });
 
 
                        // 关闭对话框
                        layer.close(index);
                        return;
                    }
                    else {
                        layer.alert(`写入失败:${result.msg}`, {
                            icon: 2, // 设置图标为警告图标
                            title: '提示'
                        });
 
                        return;
                    }
                },
                    error: function (xhr, status, error) {
                        layer.alert(`系统错误:${error}`, {
                            icon: 2, // 设置图标为警告图标
                            title: '提示'
                        });
                        return;
                    }
                });
 
        }
    });
</script>