| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928 |
- <!DOCTYPE html>
- <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
- <head>
- <th:block th:include="include :: header('教职人员列表')" />
- <th:block th:include="include :: datetimepicker-css" />
- </head>
- <body class="gray-bg">
- <div class="container-div">
- <div class="row">
- <div class="col-sm-12 search-collapse">
- <form id="formId">
- <div class="select-list">
- <ul>
- <li>
- <label>所属场所:</label>
- <select id="placeId" name="placeId" class="form-control">
- <option value="">所有场所</option>
- <option th:each="place : ${placeList}" th:value="${place.placeId}" th:text="${place.placeName}"></option>
- </select>
- </li>
- <li>
- <label>姓名:</label>
- <input type="text" name="name" placeholder="请输入姓名"/>
- </li>
- <li>
- <label>身份证号:</label>
- <input type="text" name="idNumber" placeholder="请输入身份证号"/>
- </li>
- <li>
- <label>宗教类别:</label>
- <select name="religionType" th:with="type=${@dict.getType('religion_type')}">
- <option value="">所有</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </li>
- <li>
- <label>所属区县:</label>
- <select name="county" class="form-control" th:with="type=${@dict.getType('region_xa_district')}">
- <option value="">所有区县</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </li>
- <li>
- <label>民族:</label>
- <select name="nation" class="form-control" th:with="type=${@dict.getType('sys_nation')}">
- <option value="">所有民族</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </li>
- <li>
- <label>联系电话:</label>
- <input type="text" name="phone" placeholder="请输入联系电话"/>
- </li>
- <li>
- <label>状态:</label>
- <select name="status" th:with="type=${@dict.getType('person_status')}">
- <option value="">所有</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </li>
- <li>
- <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i> 搜索</a>
- <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i> 重置</a>
- </li>
- </ul>
- </div>
- </form>
- </div>
- <div class="btn-group-sm" id="toolbar" role="group">
- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="religion:religionPerson:add">
- <i class="fa fa-plus"></i> 添加
- </a>
- <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="religion:religionPerson:edit">
- <i class="fa fa-edit"></i> 修改
- </a>
- <a class="btn btn-info" onclick="openBatchUpdateModal()" shiro:hasPermission="religion:religionPerson:edit">
- <i class="fa fa-edit"></i> 批量维护
- </a>
- <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="religion:religionPerson:remove">
- <i class="fa fa-remove"></i> 删除
- </a>
- <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="religion:religionPerson:export">
- <i class="fa fa-download"></i> 导出
- </a>
- </div>
- <div class="col-sm-12 select-table table-striped">
- <table id="bootstrap-table"></table>
- </div>
- </div>
- </div>
- <!-- 批量维护模态框 -->
- <div class="modal fade" id="personBatchModal" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-dialog" style="width: 1000px;">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title">批量维护教职人员</h4>
- </div>
- <div class="modal-body" style="max-height: 650px; overflow-y: auto;">
- <!-- 条件筛选区 -->
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">条件筛选(指定批量更新范围)</h3>
- </div>
- <div class="panel-body">
- <form id="batchConditionForm" class="form-horizontal">
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">姓名:</label>
- <div class="col-sm-8">
- <input type="text" id="cond_name" class="form-control" placeholder="请输入姓名">
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">身份证号:</label>
- <div class="col-sm-8">
- <input type="text" id="cond_idNumber" class="form-control" placeholder="请输入身份证号">
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">所属场所:</label>
- <div class="col-sm-8">
- <select id="cond_placeId" class="form-control">
- <option value="">所有场所</option>
- <option th:each="place : ${placeList}" th:value="${place.placeId}" th:text="${place.placeName}"></option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">宗教类别:</label>
- <div class="col-sm-8">
- <select id="cond_religionType" class="form-control" th:with="type=${@dict.getType('religion_type')}">
- <option value="">所有</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">性别:</label>
- <div class="col-sm-8">
- <select id="cond_gender" class="form-control">
- <option value="">所有</option>
- <option value="男">男</option>
- <option value="女">女</option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">民族:</label>
- <div class="col-sm-8">
- <select id="cond_nation" class="form-control" th:with="type=${@dict.getType('sys_nation')}">
- <option value="">所有民族</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">所属区县:</label>
- <div class="col-sm-8">
- <select id="cond_county" class="form-control" th:with="type=${@dict.getType('region_xa_district')}">
- <option value="">所有区县</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">状态:</label>
- <div class="col-sm-8">
- <select id="cond_status" class="form-control" th:with="type=${@dict.getType('person_status')}">
- <option value="">所有</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- </form>
- <div class="row">
- <div class="col-sm-12 text-right">
- <button type="button" class="btn btn-sm btn-info" onclick="queryPreview()">
- <i class="fa fa-search"></i> 查询
- </button>
- </div>
- </div>
- </div>
- </div>
- <!-- 查询结果预览区 -->
- <div class="panel panel-default" id="previewPanel" style="display: none;">
- <div class="panel-heading">
- <h3 class="panel-title">查询结果预览</h3>
- </div>
- <div class="panel-body">
- <div class="alert alert-info" style="margin-bottom: 10px;">
- <i class="fa fa-info-circle"></i> 共 <span id="batchTotalCount" style="font-weight: bold; color: #d9534f;">0</span> 条记录,将作为本次批量修改的对象
- </div>
- <div>
- <table id="previewTable"></table>
- </div>
- </div>
- </div>
- <!-- 批量更新字段区 -->
- <div class="panel panel-default">
- <div class="panel-heading">
- <h3 class="panel-title">批量更新字段(勾选需要修改的字段)</h3>
- </div>
- <div class="panel-body">
- <form id="batchUpdateForm" class="form-horizontal">
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newPlaceId"> 所属场所:
- </label>
- <div class="col-sm-8">
- <select id="new_placeId" class="form-control" disabled>
- <option value="">请选择所属场所</option>
- <option th:each="place : ${placeList}" th:value="${place.placeId}" th:text="${place.placeName}"></option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newReligionType"> 宗教类别:
- </label>
- <div class="col-sm-8">
- <select id="new_religionType" class="form-control" disabled th:with="type=${@dict.getType('religion_type')}">
- <option value="">请选择宗教类别</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newGender"> 性别:
- </label>
- <div class="col-sm-8">
- <select id="new_gender" class="form-control" disabled>
- <option value="">请选择性别</option>
- <option value="男">男</option>
- <option value="女">女</option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newNation"> 民族:
- </label>
- <div class="col-sm-8">
- <select id="new_nation" class="form-control" disabled th:with="type=${@dict.getType('sys_nation')}">
- <option value="">请选择民族</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newBirthday"> 出生日期:
- </label>
- <div class="col-sm-8">
- <div class="input-group date">
- <input id="new_birthday" class="form-control" placeholder="yyyy-MM-dd" type="text" disabled>
- <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
- </div>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newCounty"> 所属区县:
- </label>
- <div class="col-sm-8">
- <select id="new_county" class="form-control" disabled th:with="type=${@dict.getType('region_xa_district')}">
- <option value="">请选择区县</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newAddress"> 家庭地址:
- </label>
- <div class="col-sm-8">
- <input id="new_address" class="form-control" type="text" maxlength="512" placeholder="请输入家庭地址" disabled>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newPoliticalStatus"> 政治面貌:
- </label>
- <div class="col-sm-8">
- <select id="new_politicalStatus" class="form-control" disabled th:with="type=${@dict.getType('political_status')}">
- <option value="">请选择政治面貌</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newEduNational"> 国民教育学历:
- </label>
- <div class="col-sm-8">
- <select id="new_eduNational" class="form-control" disabled th:with="type=${@dict.getType('edu_national')}">
- <option value="">请选择学历</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newEduReligious"> 宗教学历:
- </label>
- <div class="col-sm-8">
- <select id="new_eduReligious" class="form-control" disabled th:with="type=${@dict.getType('edu_religious')}">
- <option value="">请选择宗教学历</option>
- <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
- </select>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newJoinTime"> 入教/出家时间:
- </label>
- <div class="col-sm-8">
- <div class="input-group date">
- <input id="new_joinTime" class="form-control" placeholder="yyyy-MM-dd" type="text" disabled>
- <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
- </div>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newPhone"> 联系电话:
- </label>
- <div class="col-sm-8">
- <input id="new_phone" class="form-control" type="text" maxlength="32" placeholder="请输入联系电话" disabled>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newDomicile"> 户籍所在地:
- </label>
- <div class="col-sm-8">
- <input id="new_domicile" class="form-control" type="text" maxlength="128" placeholder="请输入户籍所在地" disabled>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newNativePlace"> 籍贯:
- </label>
- <div class="col-sm-8">
- <input id="new_nativePlace" class="form-control" type="text" maxlength="128" placeholder="请输入籍贯" disabled>
- </div>
- </div>
- </div>
- </div>
- <div class="row">
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newOrgName"> 所属宫观名称:
- </label>
- <div class="col-sm-8">
- <input id="new_orgName" class="form-control" type="text" maxlength="256" placeholder="请输入所属宫观名称" disabled>
- </div>
- </div>
- </div>
- <div class="col-sm-6">
- <div class="form-group">
- <label class="col-sm-4 control-label">
- <input type="checkbox" id="chk_newOrgAddress"> 所属宫观地址:
- </label>
- <div class="col-sm-8">
- <textarea id="new_orgAddress" class="form-control" maxlength="512" placeholder="请输入所属宫观地址" disabled></textarea>
- </div>
- </div>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-primary" onclick="executeBatchUpdate()">执行批量更新</button>
- </div>
- </div>
- </div>
- </div>
- <!-- 批量更新预览模态框 -->
- <div class="modal fade" id="personBatchPreviewModal" tabindex="-1" role="dialog" aria-hidden="true">
- <div class="modal-dialog" style="width: 80%; max-width: 1200px;">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
- <h4 class="modal-title">批量更新预览</h4>
- </div>
- <div class="modal-body">
- <div class="alert alert-info">
- <i class="fa fa-info-circle"></i>
- 将影响 <strong id="previewTotalPersons">0</strong> 名人员,共 <strong id="previewTotalChanges">0</strong> 条字段变更。
- 请仔细核对以下变更内容,确认无误后点击"确认执行"按钮。
- </div>
- <div class="table-responsive">
- <table id="previewChangeTable" class="table table-striped table-bordered table-hover">
- <thead>
- <tr>
- <th>姓名</th>
- <th>所属场所</th>
- <th>字段名称</th>
- <th>修改前</th>
- <th>修改后</th>
- </tr>
- </thead>
- <tbody id="previewChangeTableBody">
- <!-- 动态填充 -->
- </tbody>
- </table>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
- <button type="button" class="btn btn-primary" id="btnConfirmBatchUpdate">确认执行</button>
- </div>
- </div>
- </div>
- </div>
- <th:block th:include="include :: footer" />
- <th:block th:include="include :: datetimepicker-js" />
- <script th:inline="javascript">
- var editFlag = [[${@permission.hasPermi('religion:religionPerson:edit')}]];
- var removeFlag = [[${@permission.hasPermi('religion:religionPerson:remove')}]];
- var religionTypeDatas = [[${@dict.getType('religion_type')}]];
- var nationDatas = [[${@dict.getType('sys_nation')}]];
- var statusDatas = [[${@dict.getType('person_status')}]];
- var prefix = ctx + "religion/religionPerson";
- $(function() {
- var options = {
- url: prefix + "/list",
- createUrl: prefix + "/add",
- updateUrl: prefix + "/edit/{id}",
- removeUrl: prefix + "/remove",
- exportUrl: prefix + "/export",
- modalName: "教职人员",
- showColumns: true,
- columns: [{
- checkbox: true
- },
- {
- field: 'personId',
- title: '人员ID',
- visible: false
- },
- {
- field: 'placeName',
- title: '所属场所'
- },
- {
- field: 'name',
- title: '姓名',
- sortable: true
- },
- {
- field: 'religionType',
- title: '宗教类别',
- formatter: function(value, row, index) {
- return $.table.selectDictLabel(religionTypeDatas, value);
- }
- },
- {
- field: 'gender',
- title: '性别'
- },
- {
- field: 'nation',
- title: '民族',
- formatter: function(value, row, index) {
- return $.table.selectDictLabel(nationDatas, value);
- }
- },
- {
- field: 'idNumber',
- title: '身份证号'
- },
- {
- field: 'birthday',
- title: '出生日期',
- visible: false
- },
- {
- field: 'phone',
- title: '联系电话'
- },
- {
- field: 'county',
- title: '所属区县'
- },
- {
- field: 'address',
- title: '家庭地址',
- visible: false
- },
- {
- field: 'politicalStatus',
- title: '政治面貌'
- },
- {
- field: 'eduNational',
- title: '国民教育学历',
- visible: false
- },
- {
- field: 'eduReligious',
- title: '宗教学历',
- visible: false
- },
- {
- field: 'joinTime',
- title: '入教/出家时间',
- visible: false
- },
- {
- field: 'domicile',
- title: '户籍所在地',
- visible: false
- },
- {
- field: 'nativePlace',
- title: '籍贯',
- visible: false
- },
- {
- field: 'orgName',
- title: '所属宫观名称',
- visible: false
- },
- {
- field: 'orgAddress',
- title: '所属宫观地址',
- visible: false
- },
- {
- field: 'status',
- title: '状态',
- formatter: function(value, row, index) {
- return $.table.selectDictLabel(statusDatas, value);
- }
- },
- {
- title: '操作',
- align: 'center',
- formatter: function(value, row, index) {
- var actions = [];
- actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.personId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
- actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.personId + '\')"><i class="fa fa-remove"></i>删除</a>');
- return actions.join('');
- }
- }]
- };
- $.table.init(options);
- // 初始化日期控件
- $("#new_birthday, #new_joinTime").datetimepicker({
- format: "yyyy-mm-dd",
- minView: "month",
- autoclose: true
- });
- // 复选框控制字段启用/禁用 - 使用事件委托
- $(document).on("change", "#batchUpdateForm input[type='checkbox']", function() {
- var checkboxId = $(this).attr("id");
- // chk_newReligionType -> ReligionType -> religionType
- var fieldName = checkboxId.replace("chk_new", "");
- var fieldId = "new_" + fieldName.charAt(0).toLowerCase() + fieldName.slice(1);
- var isChecked = $(this).is(":checked");
-
- var $field = $("#" + fieldId);
- console.log("复选框变化:", checkboxId, "->", fieldId, "启用:", isChecked, "找到元素:", $field.length);
-
- if ($field.length > 0) {
- $field.prop("disabled", !isChecked);
- console.log("设置后disabled状态:", $field.prop("disabled"));
-
- // 如果是日期选择器,需要特殊处理
- if (fieldId === "new_birthday" || fieldId === "new_joinTime") {
- if (isChecked) {
- $field.datetimepicker('enable');
- } else {
- $field.datetimepicker('disable');
- }
- }
- } else {
- console.error("未找到元素:", fieldId);
- }
- });
-
- // 确认批量更新按钮点击事件
- $("#btnConfirmBatchUpdate").on("click", function() {
- if (!window.batchUpdateRequestData) {
- $.modal.alertError("请求数据丢失,请重新操作");
- return;
- }
-
- $.modal.confirm("确定要执行批量更新吗?", function() {
- $.ajax({
- url: prefix + "/batchUpdateByCondition",
- type: "post",
- contentType: "application/json",
- data: JSON.stringify(window.batchUpdateRequestData),
- success: function(result) {
- if (result.code == web_status.SUCCESS) {
- var count = result.data || 0;
- $.modal.msgSuccess("批量更新成功,共修改 " + count + " 条记录");
- $("#personBatchPreviewModal").modal("hide");
- $("#personBatchModal").modal("hide");
- $.table.refresh();
- // 清空保存的请求数据
- window.batchUpdateRequestData = null;
- } else {
- $.modal.alertError(result.msg);
- }
- },
- error: function() {
- $.modal.alertError("批量更新失败,请稍后重试");
- }
- });
- });
- });
- });
- // 打开批量维护模态框
- function openBatchUpdateModal() {
- // 重置表单
- $("#batchConditionForm")[0].reset();
- $("#batchUpdateForm")[0].reset();
- $("#batchUpdateForm input[type='checkbox']").prop("checked", false);
- // 只禁用输入框、下拉框和文本域,不禁用复选框
- $("#batchUpdateForm input[type='text'], #batchUpdateForm input[type='date'], #batchUpdateForm select, #batchUpdateForm textarea").prop("disabled", true);
-
- // 隐藏预览区并重置
- $("#previewPanel").hide();
- $("#batchTotalCount").text("0");
- if ($("#previewTable").data('bootstrap.table')) {
- $("#previewTable").bootstrapTable('destroy');
- }
-
- // 显示模态框
- $("#personBatchModal").modal("show");
- }
- // 查询预览
- function queryPreview() {
- var conditions = getConditions();
-
- // 初始化预览表格
- var previewOptions = {
- url: prefix + "/batchPreviewList",
- method: 'post',
- contentType: "application/json",
- ajax: function(request) {
- var queryParams = $.extend({}, conditions);
- queryParams.pageNum = request.data.offset / request.data.limit + 1;
- queryParams.pageSize = request.data.limit;
-
- $.ajax({
- type: "POST",
- url: request.url,
- contentType: "application/json",
- data: JSON.stringify(queryParams),
- dataType: "json",
- success: function(res) {
- request.success({
- total: res.total,
- rows: res.rows
- });
- },
- error: function(res) {
- request.error(res);
- }
- });
- },
- pagination: true,
- sidePagination: "server",
- pageSize: 20,
- pageList: [10, 20, 50],
- showRefresh: false,
- showToggle: false,
- showColumns: false,
- clickToSelect: false,
- columns: [{
- field: 'name',
- title: '姓名'
- },
- {
- field: 'placeName',
- title: '所属场所'
- },
- {
- field: 'religionType',
- title: '宗教类别',
- formatter: function(value, row, index) {
- return getDictLabel(religionTypeDatas, value);
- }
- },
- {
- field: 'gender',
- title: '性别'
- },
- {
- field: 'nation',
- title: '民族',
- formatter: function(value, row, index) {
- return getDictLabel(nationDatas, value);
- }
- },
- {
- field: 'county',
- title: '所属区县'
- },
- {
- field: 'status',
- title: '状态',
- formatter: function(value, row, index) {
- return getDictLabel(statusDatas, value);
- }
- }],
- onLoadSuccess: function(data) {
- $("#batchTotalCount").text(data.total || 0);
- $("#previewPanel").show();
- },
- onLoadError: function() {
- $.modal.alertError("查询失败,请稍后重试");
- }
- };
- // 销毁旧表格并初始化新表格
- if ($("#previewTable").data('bootstrap.table')) {
- $("#previewTable").bootstrapTable('destroy');
- }
- $("#previewTable").bootstrapTable(previewOptions);
- }
- // 执行批量更新(改为预览)
- function executeBatchUpdate() {
- // 检查是否至少选择了一个字段
- var checkedCount = $("#batchUpdateForm input[type='checkbox']:checked").length;
- if (checkedCount == 0) {
- $.modal.alertWarning("请至少选择一个要修改的字段");
- return;
- }
- // 获取条件
- var data = getConditions();
- // 收集勾选字段的值
- $("#batchUpdateForm input[type='checkbox']:checked").each(function() {
- var checkboxId = $(this).attr("id");
- // chk_newReligionType -> ReligionType
- var fieldName = checkboxId.replace("chk_new", "");
- // 构造输入框ID: new_religionType (首字母小写)
- var fieldId = "new_" + fieldName.charAt(0).toLowerCase() + fieldName.slice(1);
- var fieldValue = $("#" + fieldId).val();
- // 构造后端字段名: newReligionType (带new前缀,首字母大写)
- var backendFieldName = "new" + fieldName;
- if (fieldValue !== null && fieldValue !== "") {
- data[backendFieldName] = fieldValue;
- }
- });
- // 调用预览接口
- $.ajax({
- url: prefix + "/batchUpdatePreview",
- type: "post",
- contentType: "application/json",
- data: JSON.stringify(data),
- success: function(result) {
- if (result.code == web_status.SUCCESS) {
- var previewData = result.data;
-
- // 检查是否有实际变更
- if (!previewData || previewData.totalPersons == 0 || !previewData.rows || previewData.rows.length == 0) {
- $.modal.alertWarning("无实际变更,请检查筛选条件和修改字段");
- return;
- }
-
- // 保存请求数据供确认时使用
- window.batchUpdateRequestData = data;
-
- // 填充预览数据
- showBatchUpdatePreview(previewData);
- } else {
- $.modal.alertError(result.msg);
- }
- },
- error: function() {
- $.modal.alertError("预览失败,请稍后重试");
- }
- });
- }
-
- // 显示批量更新预览
- function showBatchUpdatePreview(previewData) {
- // 更新统计信息
- $("#previewTotalPersons").text(previewData.totalPersons);
- $("#previewTotalChanges").text(previewData.totalChanges);
-
- // 清空并填充表格
- var tbody = $("#previewChangeTableBody");
- tbody.empty();
-
- if (previewData.rows && previewData.rows.length > 0) {
- $.each(previewData.rows, function(index, row) {
- var tr = $("<tr>");
- tr.append($("<td>").text(row.name || ""));
- tr.append($("<td>").text(row.placeName || ""));
- tr.append($("<td>").text(row.fieldLabel || ""));
- tr.append($("<td>").text(row.oldValue || ""));
- tr.append($("<td>").html("<strong>" + (row.newValue || "") + "</strong>"));
- tbody.append(tr);
- });
- }
-
- // 关闭批量维护模态框,打开预览模态框
- $("#personBatchModal").modal("hide");
- $("#personBatchPreviewModal").modal("show");
- }
- // 获取筛选条件
- function getConditions() {
- var conditions = {};
- var name = $.trim($("#cond_name").val());
- var idNumber = $.trim($("#cond_idNumber").val());
- var placeId = $("#cond_placeId").val();
- var religionType = $("#cond_religionType").val();
- var gender = $("#cond_gender").val();
- var nation = $("#cond_nation").val();
- var county = $("#cond_county").val();
- var status = $("#cond_status").val();
- if (name && name != "") conditions.name = name;
- if (idNumber && idNumber != "") conditions.idNumber = idNumber;
- if (placeId && placeId != "") conditions.placeId = placeId;
- if (religionType && religionType != "") conditions.religionType = religionType;
- if (gender && gender != "") conditions.gender = gender;
- if (nation && nation != "") conditions.nation = nation;
- if (county && county != "") conditions.county = county;
- if (status && status != "") conditions.status = status;
- return conditions;
- }
- // 获取字典标签
- function getDictLabel(datas, value) {
- if (!value || !datas) return "";
- for (var i = 0; i < datas.length; i++) {
- if (datas[i].dictValue == value) {
- return datas[i].dictLabel;
- }
- }
- return value;
- }
- </script>
- </body>
- </html>
|