songjun
2024-09-04 cc908053e0b5075fbfd27350b6da4b39bca9e550
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
@model sbcLabSystem.Models.Backstage.LabViewModel
@{
    ViewBag.Title = "添加实验室";
    Layout = "~/Views/Shared/Master.cshtml";
}
<script>
    var viewModel;
    $(function () {
        viewModel = new myViewModel_User(@Html.Raw(Json.Encode(Model)));
        ko.applyBindings(viewModel, $(".container")[0]);
    })
    function myViewModel_User(data) {
        var self = this;
        self.Step = function ()
        {
            console.log("上一个" + self.Labinfo.LabCode());
            DoAjaxPost("@Url.Action("SetpLab", "Backstage")",
                   JSON.stringify({
                       LabCode: self.Labinfo.LabCode(),
                       shang: "shang",
                }),
            function (json) {
                console.log(json);
                ko.mapping.fromJS(json, {}, viewModel.Labinfo);
 
            }); 
 
          
        }
        self.lower = function ()
        {
            console.log("下一个" + self.Labinfo.LabCode());
            DoAjaxPost("@Url.Action("SetpLab", "Backstage")",
                   JSON.stringify({
                       LabCode: self.Labinfo.LabCode(),
                   }),
                   function (json) {
                       console.log(json);
                       ko.mapping.fromJS(json, {}, viewModel.Labinfo);
 
                   }); 
        }
        ko.mapping.fromJS(data, mapping, self);
 
    }
    var mapping = {
        'Labinfo': {
            create: function (options) {
                return new Labinfo(options.data);
            }
        }
    }
    function Labinfo(data)
    {
        console.log(data)
        var self = this;
      
        self.PostCode = ko.observable(data.PostCode).extend({
            required: {
                params: true,
                message: "邮编不能为空"
            }
        })
        self.ManagerName = ko.observable(data.ManagerName).extend({
            required: {
                params: true,
                message: "姓名不能为空"
            }
        })
        self.ManagerPhone = ko.observable(data.ManagerPhone).extend({
            required: {
                params: true,
                message: "固定电话不能为空"
            }
        })
        self.ManagerMobile = ko.observable(data.ManagerMobile).extend({
            required: {
                params: true,
                message: "手机不能为空"
            }
        })
        self.ManagerEmail = ko.observable(data.ManagerEmail).extend({
            required: {
                params: true,
                message: "邮箱不能为空"
            }
        }).extend({
            email: {
                params: true,
                message: "邮箱格式不正确"
            }
        });
        self.OperatorName = ko.observable(data.OperatorName).extend({
            required: {
                params: true,
                message: "姓名不能为空"
            }
        })
        self.OperatorPhone = ko.observable(data.OperatorPhone);
        self.OperatorMobile = ko.observable(data.OperatorMobile).extend({
            required: {
                params: true,
                message: "手机不能为空"
            }
        });
        self.OperatorEmail = ko.observable(data.OperatorEmail).extend({
            required: {
                params: true,
                message: "邮箱不能为空"
            }
        }).extend({
            email: {
                params: true,
                message: "邮箱格式不正确"
            }
        });
        self.fsPassword = function () {
            $.ajax({
                    type: "post",
                    url: '@Url.Action("UpdatePassword", "Backstage")',
                    dataType: 'json',
                    cache: false, 
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify(ko.toJS(self)),
                    success: function (data) {
                        alert(data); 
                    },
                    error: function (err) {
                    } 
                });
        }
        self.seve = function () {
            self.errors = ko.validation.group(self, { deep: true });
            if (self.errors().length == 0) {
                $.ajax({
                    type: "post",
                    url: '@Url.Action("SubmitLab", "Backstage")',
                    dataType: 'json',
                    cache: false,
                    contentType: 'application/json; charset=utf-8',
                    data: JSON.stringify(ko.toJS(self)),
                    success: function (data) {
                        $.messager.popup("保存成功 ");
                        window.location.href = "@Url.Action("addlab", "Backstage")" + "?LabId=" + data.Id();
                    },
                    error: function (err) {
                    }
                });
            }
            else { self.errors.showAllMessages(); }
        }
 
        ko.mapping.fromJS(data, {}, self)
    }
</script>
<div class="container">
    <div class="row" data-bind="with:Labinfo">
        <table class="table table-bordered">
            <tr class="active">
                <td align="right" width="120">实验室名称:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:LabName" />
 
                </td>
                <td align="right" width="120">单位名称:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:CompanyName" />
 
                </td>
                <td align="right" width="120">纳税人编号:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:taxNo" />
 
                </td>
            </tr>
            <tr class="active">
                <td align="right" width="120">实验室代码:</td>
                <td>
                    <input disabled name="" type="text" id="" style="width:100%;" data-bind="value:LabCode" />
 
                </td>
                <td align="right" width="120">用户名:</td>
                <td>
                    <input disabled name="" type="text" id="" style="width:100%;" data-bind="value:LabLoginName" />
 
                </td>
                <td align="right" width="120">实验室密码:</td>
                <td>
                    <button class="btn btn-default" data-bind="click:fsPassword,style:{display:State()>0?'inline-block':'none'}">重新发送密码</button>
 
                </td>
            </tr>
            <tr class="active">
                <td align="right" width="120">地址:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:Address" />
 
                </td>
                <td align="right" width="120">省份:</td> 
                <td> 
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:Province" />
 
                </td>
                <td align="right" width="120">邮编:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:PostCode" />
 
                </td>
            </tr>
            <tr class="success">
                <td align="right" width="120">负责人姓名:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:ManagerName" />
 
                </td>
                <td align="right" width="120">负责人固话:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:ManagerPhone" />
 
                </td>
                <td align="right" width="120">负责人传真:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:ManagerFax" />
 
                </td>
            </tr>
            <tr class="success">
                <td align="right" width="120">负责人手机:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:ManagerMobile" />
 
                </td>
                <td align="right" width="120">负责人邮箱:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:ManagerEmail" />
 
                </td>
            </tr>
            <tr class="danger">
                <td align="right" width="120">操作人姓名:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:OperatorName" />
 
                </td>
                <td align="right" width="120">操作人固话:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:OperatorPhone" />
 
                </td>
                <td align="right" width="120">操作人传真:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:OperatorFax" />
 
                </td>
            </tr>
            <tr class="danger">
                <td align="right" width="120">操作人手机:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:OperatorMobile" />
 
                </td>
                <td align="right" width="120">操作人邮箱:</td>
                <td>
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:OperatorEmail" />
 
                </td>
            </tr>
            <tr class="warning">
                <td align="right" width="120">备注:</td>
                <td colspan="5">
                    <input name="" type="text" id="" style="width:100%;" data-bind="value:Remarks" />
                </td>
            </tr>
            <tr>
                <td colspan="6">
                    <button class="btn btn-danger center-block" style="width:100%" data-bind="click:seve,style:{display:$root.State()>0?'none':'inline-block'}">保 存</button>
                </td>
            </tr>
        </table>
       
    </div>
    <div class="row">
        <div class="col-xs-6" style="text-align:right"><button class="btn btn-primary" data-bind="click:Step">上一个</button> </div>
        <div class="col-xs-6" style="text-align:left"><button class="btn btn-primary" data-bind="click:lower">下一个</button></div>
    </div>
    @*<div class="row" style="width: 99.8%; overflow: auto;">
            <div class="table-responsive" style="width: 3000px; overflow: hidden;">
                <table class="table table-striped">
                    <caption> 确认是否有相同单位</caption>
                    <thead>
                        <tr>
                            <th>操作</th>
                            <th>单位名称</th>
                            <th>实验室名称</th>
                            <th>地址</th>
                            <th>所在</th>
                            <th>参加项目</th>
                            <th>申请时间</th>
                            <th>负责人</th>
                            <th>固话</th>
                            <th>传真</th>
                            <th>手机号码</th>
                            <th>邮箱</th>
                            <th>操作人</th>
                            <th>固话</th>
                            <th>传真</th>
                            <th>手机号码</th>
                            <th>邮箱</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>
 
                                <span>
                                    <button type="button" class="btn btn-info  btn-xs" data-bind="click:Detailed">
                                        确认
                                    </button>
 
                                </span>
                            </td>
                            <td data-bind="text:CompanyName"></td>
                            <td data-bind="text:LabName"></td>
                            <td data-bind="text:Address"></td>
                            <td data-bind="text:dizhi"></td>
                            <td data-bind="text:project"></td>
                            <td data-bind="text:dateTime"></td>
                            <td data-bind="text:ManagerName"></td>
                            <td data-bind="text:ManagerPhone"></td>
                            <td data-bind="text:ManagerFax"></td>
                            <td data-bind="text:ManagerMobile"></td>
                            <td data-bind="text:ManagerEmail"></td>
                            <td data-bind="text:OperatorName"></td>
                            <td data-bind="text:OperatorPhone"></td>
                            <td data-bind="text:OperatorFax"></td>
                            <td data-bind="text:OperatorMobile"></td>
                            <td data-bind="text:OperatorEmail"></td>
                        </tr>
 
                    </tbody>
                </table>
            </div>
        </div>*@
</div>