|
@@ -0,0 +1,283 @@
|
|
|
+//@ sourceURL=instruction_code.js
|
|
|
+$(function () {
|
|
|
+ $("input").each(function (){
|
|
|
+ this.onkeydown = function (e) { // 监听键盘事件
|
|
|
+ let theEvent = window.event || e;
|
|
|
+ let code = theEvent.keyCode || theEvent.which;
|
|
|
+ if (code == 13) {//回车事件
|
|
|
+ $("#btn_search").click(); //触发搜索按钮点击事件
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //新增按钮点击事件
|
|
|
+ $("#btn_add").click(function (t) {
|
|
|
+ $("#editModal").modal();
|
|
|
+ $("#classTitle").text("新增");
|
|
|
+ clearInput();
|
|
|
+ $("#delFlag").val(0);
|
|
|
+ });
|
|
|
+ //保存按钮点击事件
|
|
|
+ $("#btn_save").click(function (t) {
|
|
|
+ var validatorResult = validator.checkAll($("#editGroupForm"));
|
|
|
+ if (validatorResult) {
|
|
|
+ saveMzZdInstruction();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $(".selectpicker").selectpicker();
|
|
|
+ //初始化表格数据
|
|
|
+ getAllMzZdInstruction();
|
|
|
+});
|
|
|
+
|
|
|
+/**
|
|
|
+ * 保存数据
|
|
|
+ */
|
|
|
+function saveMzZdInstruction() {
|
|
|
+ var data = JSON.stringify({
|
|
|
+ code: $("#code").val(),
|
|
|
+ delFlag: $("#delFlag").val(),
|
|
|
+ instructionText: $("#instructionText").val(),
|
|
|
+ instructionType: $("#instructionType").val()
|
|
|
+ });
|
|
|
+ $.ajax({
|
|
|
+ type: "POST",
|
|
|
+ url: '/thmz/saveMzZdInstruction',
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
|
|
|
+ data: data,
|
|
|
+ success: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view'
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == 0) {
|
|
|
+ $("#editModal").modal("hide");
|
|
|
+ clearInput();
|
|
|
+ $('#tb_table').bootstrapTable('refresh');
|
|
|
+ successMesage(res);
|
|
|
+ } else {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+}/**
|
|
|
+ * 修改嘱托状态
|
|
|
+ */
|
|
|
+function updateDelFlag(code,delFlag) {
|
|
|
+ $.ajax({
|
|
|
+ type: "GET",
|
|
|
+ url: '/thmz/updateDelFlag?code='+code+'&delFlag='+delFlag,
|
|
|
+ contentType: "application/json;charset=UTF-8",
|
|
|
+ dataType: "json",
|
|
|
+ headers: {'Accept': 'application/json', 'Authorization': 'Bearer ' + localStorage.getItem("token")},
|
|
|
+ data: {},
|
|
|
+ success: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view'
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (res.code == 0) {
|
|
|
+ $("#editModal").modal("hide");
|
|
|
+ clearInput();
|
|
|
+ $('#tb_table').bootstrapTable('refresh');
|
|
|
+ successMesage(res);
|
|
|
+ } else {
|
|
|
+ errorMesage(res);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 清空输入框
|
|
|
+ */
|
|
|
+function clearInput() {
|
|
|
+ $("#instructionText").val(null);
|
|
|
+ $("#instructionType").val(null);
|
|
|
+ $("#code").val(null);
|
|
|
+ $("#delFlag").val(null);
|
|
|
+ $("#instructionType").selectpicker('refresh');
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 重置查询表单
|
|
|
+ */
|
|
|
+function resetSearch() {
|
|
|
+ $("#instructionTypeSearch").val(null);
|
|
|
+ $("#pyCodeSearch").val(null);
|
|
|
+ $("#wbCodeSearch").val(null);
|
|
|
+ $("#instructionTypeSearch").selectpicker('refresh');
|
|
|
+ $("#delFlagSearch").val(null);
|
|
|
+ $("#delFlagSearch").selectpicker('refresh');
|
|
|
+ $("#instructionTextSearch").val(null);
|
|
|
+ $("#codeSearch").val(null);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 查询列表
|
|
|
+ */
|
|
|
+function getAllMzZdInstruction() {
|
|
|
+ $('#tb_table').bootstrapTable("destroy");
|
|
|
+ $('#tb_table').bootstrapTable({
|
|
|
+ url: '/thmz/getMzZdInstruction', //请求后台的URL(*)
|
|
|
+ method: 'post', //请求方式(*)
|
|
|
+ toolbar: '#toolbar', //工具按钮用哪个容器
|
|
|
+ striped: true, //是否显示行间隔色
|
|
|
+ cache: false, //是否使用缓存,默认为true,所以一般情况下需要设置一下这个属性(*)
|
|
|
+ pagination: true, //是否显示分页(*)
|
|
|
+ sortable: true, //是否启用排序
|
|
|
+ sortOrder: "desc", //排序方式
|
|
|
+ queryParams: queryParams, //传递参数(*)
|
|
|
+ sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)
|
|
|
+ pageNumber: 1, //初始化加载第一页,默认第一页
|
|
|
+ pageSize: 10, //每页的记录行数(*)
|
|
|
+ pageList: [10, 15, 25, 50, 100], //可供选择的每页的行数(*)
|
|
|
+ search: false, //是否显示表格搜索,此搜索是客户端搜索,不会进服务端,所以,个人感觉意义不大
|
|
|
+ strictSearch: true,
|
|
|
+ showColumns: false, //是否显示所有的列
|
|
|
+ showRefresh: false, //是否显示刷新按钮
|
|
|
+ minimumCountColumns: 2, //最少允许的列数
|
|
|
+ clickToSelect: true, //是否启用点击选中行
|
|
|
+ uniqueId: "groupNo", //每一行的唯一标识,一般为主键列
|
|
|
+ showToggle: false, //是否显示详细视图和列表视图的切换按钮
|
|
|
+ cardView: false, //是否显示详细视图
|
|
|
+ detailView: false,
|
|
|
+ //rowStyle:rowStyle,//通过自定义函数设置行样式
|
|
|
+ ajaxOptions: {
|
|
|
+ headers: {
|
|
|
+ 'Accept': 'application/json',
|
|
|
+ 'Authorization': 'Bearer ' + localStorage.getItem("token")
|
|
|
+ }
|
|
|
+ },
|
|
|
+ columns: [
|
|
|
+ {
|
|
|
+ title: '操作',
|
|
|
+ field: 'op',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle',
|
|
|
+ formatter: function (value, row, index) {
|
|
|
+ var str = '';
|
|
|
+ if (row.delFlag == 0) {
|
|
|
+ str += '<button type="button" class="btn btn-warning btn-sm" onclick="updateDelFlag(\'' + row.code + '\',1)">停用</button>';
|
|
|
+ } else if (row.delFlag == 1) {
|
|
|
+ str += '<button type="button" class="btn btn-success btn-sm" onclick="updateDelFlag(\'' + row.code + '\',0)">启用</button>';
|
|
|
+ }
|
|
|
+ str += '<button type="button" class="btn btn-primary btn-sm" onclick="updateInstructionCode(\'' + row.code + '\',\'' + row.instructionText + '\',\'' + row.instructionType + '\',\'' + row.delFlag + '\')">编辑</button>';
|
|
|
+ return [str].join('');
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ field: 'instructionText',
|
|
|
+ title: '嘱托内容',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ }, {
|
|
|
+ field: 'delFlag',
|
|
|
+ title: '停用状态',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle',
|
|
|
+ formatter: function (value, row, index) {
|
|
|
+ return value == 0 ? '<span style="color: green">否</span>' : '<span style="color: red">是</span>';
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'code',
|
|
|
+ title: '排序码',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'pyCode',
|
|
|
+ title: '拼音码',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ field: 'wbCode',
|
|
|
+ title: '五笔码',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle'
|
|
|
+ }, {
|
|
|
+ field: 'instructionType',
|
|
|
+ title: '类型',
|
|
|
+ align: "center",
|
|
|
+ valign: 'middle',
|
|
|
+ formatter: function (value, row, index) {
|
|
|
+ if(value == 0){
|
|
|
+ return "西药";
|
|
|
+ }else if(value == 1){
|
|
|
+ return "中药";
|
|
|
+ }else if(value == 2){
|
|
|
+ return "通用";
|
|
|
+ }
|
|
|
+ return '-';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ responseHandler: function (res) {
|
|
|
+ if (res == '401' || res == 401) {
|
|
|
+ window.location.href = '/thmz/login/view'
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var ress = eval(res);
|
|
|
+ if (ress.code == -1) {
|
|
|
+ if (ress.message != null && ress.message != '') {
|
|
|
+ new PNotify({
|
|
|
+ title: '错误提示',
|
|
|
+ text: ress.message,
|
|
|
+ type: 'error',
|
|
|
+ hide: true,
|
|
|
+ styling: 'bootstrap3'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ "total": 0,//总页数
|
|
|
+ "rows": {} //数据
|
|
|
+ };
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ "total": ress.total,//总页数
|
|
|
+ "rows": ress.data //数据
|
|
|
+ };
|
|
|
+ },
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 构建列表查询参数
|
|
|
+ * @param params
|
|
|
+ */
|
|
|
+function queryParams(params) {
|
|
|
+ var temp = { //这里的键的名字和控制器的变量名必须一直,这边改动,控制器也需要改成一样的
|
|
|
+ pageSize: params.limit, //页面大小
|
|
|
+ pageIndex: params.offset / params.limit, //页码
|
|
|
+ mzZdInstructionCode: {
|
|
|
+ delFlag: $("#delFlagSearch").val() == "" ? null : $("#delFlagSearch").val(),
|
|
|
+ instructionType: $("#instructionTypeSearch").val() == "" ? null : $("#instructionTypeSearch").val(),
|
|
|
+ wbCode: $("#wbCodeSearch").val() == "" ? null : $("#wbCodeSearch").val(),
|
|
|
+ pyCode: $("#pyCodeSearch").val() == "" ? null : $("#pyCodeSearch").val(),
|
|
|
+ instructionText: $("#instructionTextSearch").val() == "" ? null : $("#instructionTextSearch").val()
|
|
|
+ }
|
|
|
+ };
|
|
|
+ return temp;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 打开编辑窗口
|
|
|
+ * @param row
|
|
|
+ */
|
|
|
+function updateInstructionCode(code,instructionText,instructionType,delFlag) {
|
|
|
+ clearInput();
|
|
|
+ $("#classTitle").text("修改");
|
|
|
+ $("#code").val(code);
|
|
|
+ $("#delFlag").val(delFlag);
|
|
|
+ $("#instructionText").val(instructionText);
|
|
|
+ $("#instructionType").val(instructionType);
|
|
|
+ $("#instructionText").selectpicker('refresh');
|
|
|
+ $("#instructionType").selectpicker('refresh');
|
|
|
+ $("#editModal").modal();
|
|
|
+}
|