瑞利声电固定资产管理系统
ycq
2026-10-16 dbbadb021c2fc171466cc82bd9a7a82cc47165f5
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
<%@ page language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html>
<head>
    <base href="<%=basePath%>">
    <meta charset="UTF-8">
    <title>选择资产</title>
    <link href="static/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="static/plugins/layer/skin/default/layer.css" type="text/css">
    <script type="text/javascript" src="static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="static/plugins/layer/layer.js"></script>
    <style>
        html, body { height: 100%; margin: 0; font-family: "Microsoft YaHei", sans-serif; font-size: 13px; color: #333; }
        .wrap { display: flex; flex-direction: column; height: 100%; }
        .bar { padding: 10px 12px; border-bottom: 1px solid #e5e5e5; display: flex; align-items: center; gap: 10px; }
        .bar input { height: 28px; width: 320px; border: 1px solid #ccc; padding: 0 6px; }
        .btn { display: inline-block; padding: 5px 14px; border-radius: 3px; cursor: pointer; border: 1px solid #3f9ae0; background: #3f9ae0; color: #fff; }
        .btn-default { background: #fff; color: #333; border-color: #ccc; }
        .hint { color: #999; font-size: 12px; }
        .list { flex: 1; overflow: auto; }
        table { width: 100%; border-collapse: collapse; }
        th, td { border-bottom: 1px solid #f0f0f0; padding: 7px 8px; text-align: left; white-space: nowrap; }
        th { background: #fafafa; position: sticky; top: 0; }
        tr:hover td { background: #f5faff; }
        .foot { padding: 10px 12px; border-top: 1px solid #e5e5e5; display: flex; justify-content: space-between; align-items: center; }
        .empty { padding: 40px; text-align: center; color: #999; }
    </style>
</head>
<body>
<div class="wrap">
    <div class="bar">
        <input id="keyword" type="text" placeholder="资产编号 / 名称 / 规格 / 使用人 / 部门 / 位置">
        <span class="btn" id="search"><i class="fa fa-search"></i> 查询</span>
        <span class="hint">只列出可办理「<span id="billTitle"></span>」且未在其他单据中办理的资产,最多显示 ${maxCandidates} 条</span>
    </div>
    <div class="list">
        <table>
            <thead>
            <tr>
                <th style="width:32px;"><input type="checkbox" id="checkAll"></th>
                <th>资产编号</th><th>资产名称</th><th>规格型号</th><th>状态</th><th>使用部门</th><th>使用人</th><th>存放位置</th>
            </tr>
            </thead>
            <tbody id="rows"></tbody>
        </table>
    </div>
    <div class="foot">
        <span>已选 <b id="count">0</b> 件(最多 ${maxAssets} 件)</span>
        <span><span class="btn btn-default" id="cancel">取消</span> <span class="btn" id="ok">确定</span></span>
    </div>
</div>
<script type="text/javascript">
    var BILL_TYPE = "${billType}";
    var MAX_ASSETS = ${maxAssets};
    // 打开方通过 params 传入:selected 已选资产(id->文字)、sealType、billNo、callBack(ids, text, count)
    var params = {selected: null, sealType: '', billNo: '', callBack: null};
    var selected = {};
    var rows = [];
 
    $(function () {
        $('#billTitle').text("${billTitle}");
        $('#search').on('click', load);
        $('#keyword').on('keydown', function (e) { if (e.which === 13) { load(); } });
        $('#checkAll').on('change', function () {
            var checked = this.checked;
            $.each(rows, function (i, r) { toggle(r, checked); });
            render();
        });
        $('#rows').on('change', 'input[type=checkbox]', function () {
            toggle(rows[$(this).data('index')], this.checked);
            updateCount();
        });
        $('#cancel').on('click', close);
        $('#ok').on('click', confirm);
        waitForParams(0);
    });
 
    // params 由父页面在 iframe 加载完成后写入,等拿到回调再加载(最多等 3 秒)
    function waitForParams(tries) {
        if (params.callBack || tries >= 30) {
            selected = $.extend({}, params.selected || {});
            load();
            return;
        }
        setTimeout(function () { waitForParams(tries + 1); }, 100);
    }
 
    function load() {
        $.post('fams/apply/candidates', {billType: BILL_TYPE, sealType: params.sealType || '', keyword: $('#keyword').val(), billNo: params.billNo || ''},
            function (data) {
                if (!data.success) {
                    layer.alert((data.error && data.error.message) || '查询失败');
                    return;
                }
                rows = data.result;
                render();
            });
    }
 
    function render() {
        var $tbody = $('#rows').empty();
        if (!rows.length) {
            $tbody.append('<tr><td colspan="8" class="empty">没有可选的资产</td></tr>');
        }
        $.each(rows, function (i, r) {
            var $tr = $('<tr></tr>');
            $tr.append($('<td></td>').append($('<input type="checkbox">').attr('data-index', i).prop('checked', !!selected[r.ID])));
            $.each(['ASSET_NO', 'ASSET_NAME', 'SPEC_MODEL', 'ASSET_STATE', 'USE_DEPT_NAME', 'USER_NAME', 'LOCATION_NAME'], function (j, key) {
                $tr.append($('<td></td>').text(r[key] || ''));
            });
            $tbody.append($tr);
        });
        updateCount();
    }
 
    function toggle(row, checked) {
        if (checked) {
            selected[row.ID] = row.ASSET_NO + ' ' + row.ASSET_NAME;
        } else {
            delete selected[row.ID];
        }
    }
 
    function updateCount() {
        $('#count').text(Object.keys(selected).length);
    }
 
    function confirm() {
        var ids = Object.keys(selected);
        if (!ids.length) {
            layer.msg('请至少选择一件资产');
            return;
        }
        if (ids.length > MAX_ASSETS) {
            layer.msg('最多选择 ' + MAX_ASSETS + ' 件资产');
            return;
        }
        var texts = $.map(ids, function (id) { return selected[id]; });
        if (params.callBack) {
            params.callBack(ids.join(','), texts.join(';'), ids.length);
        }
        close();
    }
 
    function close() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    }
</script>
</body>
</html>