123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- /**
- * 初始化认定条件管理详情对话框
- */
- var IntegralItemMgrInfo = {
- integralItemMgrInfoData: {},
- validateFields: {
- projectId: {
- validators: {
- notEmpty: {
- message: '请选择所属积分项目'
- }
- }
- },
- name: {
- validators: {
- notEmpty: {
- message: '请输入标准名称'
- }
- }
- },
- active: {
- validators: {
- notEmpty: {
- message: '请选择启用状态'
- }
- }
- },
- plan: {
- validators: {
- notEmpty: {
- message: '请选择积分方案'
- }
- }
- },
- unit: {
- validators: {
- notEmpty: {
- message: '请输入计量单位'
- }
- }
- },
- fstNeedAmount: {
- validators: {
- notEmpty: {
- message: '请输入首次达成量'
- }
- }
- },
- fstGainPoints: {
- validators: {
- notEmpty: {
- message: '请输入首次获得积分'
- }
- }
- },
- stepNeedAmount: {
- validators: {
- notEmpty: {
- message: '请输入每新增量'
- }
- }
- },
- stepGainPoints: {
- validators: {
- notEmpty: {
- message: '请输入每新增获得积分'
- }
- }
- }
- }
- };
- /**
- * 清除数据
- */
- IntegralItemMgrInfo.clearData = function () {
- this.integralItemMgrInfoData = {};
- }
- /**
- * 设置对话框中的数据
- *
- * @param key 数据的名称
- * @param val 数据的具体值
- */
- IntegralItemMgrInfo.set = function (key, val) {
- this.integralItemMgrInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
- return this;
- }
- /**
- * 设置对话框中的数据
- *
- * @param key 数据的名称
- * @param val 数据的具体值
- */
- IntegralItemMgrInfo.get = function (key) {
- return $("#" + key).val();
- }
- /**
- * 关闭此对话框
- */
- IntegralItemMgrInfo.close = function () {
- parent.layer.close(window.parent.IntegralItemMgr.layerIndex);
- }
- /**
- * 收集数据
- */
- IntegralItemMgrInfo.collectData = function () {
- this
- .set('id')
- .set('type')
- .set('projectId')
- .set('name')
- .set('plan')
- .set('unit')
- .set('fstNeedAmount')
- .set('fstGainPoints')
- .set('stepNeedAmount')
- .set('stepGainPoints')
- .set('fileTypeId')
- .set('limit')
- .set('yearly')
- .set('max')
- .set('active');
- }
- IntegralItemMgrInfo.onTypeChange = function () {
- var type = $("#type").val();
- Feng.addAjaxSelect({
- "id": "projectId",
- "displayCode": "id",
- "displayName": "name",
- "type": "GET",
- "url": "/admin/integral_mgr/getProjectsByType/type/" + type
- });
- var projectId = $("#projectId").attr("selectVal");
- $("#projectId").val(projectId);
- Feng.addAjaxSelect({
- "id": "fileTypeId",
- "displayCode": "id",
- "displayName": "name",
- "type": "GET",
- "url": "/admin/integral_mgr/getFilesByType/type/" + type
- });
- $("#fileTypeId").trigger('chosen:updated');
- }
- //切换积分方案
- IntegralItemMgrInfo.onIntegralPlanChange = function () {
- var plan = $("#plan").val();
- switch (plan) {
- case "1":
- $(".planb").css("display", "none");
- $('#integraMgrInfoForm').bootstrapValidator('removeField', "stepNeedAmount");
- $('#integraMgrInfoForm').bootstrapValidator('removeField', "stepGainPoints");
- break;
- case "2":
- case "3":
- $(".planb").css("display", "block");
- $('#integraMgrInfoForm').bootstrapValidator('addField', "stepNeedAmount", {validators: {notEmpty: {message: '请填写每新增量'}}});
- $('#integraMgrInfoForm').bootstrapValidator('addField', "stepGainPoints", {validators: {notEmpty: {message: '请填写每新增获得积分'}}});
- break;
- }
- }
- IntegralItemMgrInfo.onLimitChange = function () {
- var limit = $("#limit").val();
- switch (limit) {
- case "1":
- $('#integraMgrInfoForm').bootstrapValidator('addField', "yearly", {validators: {notEmpty: {message: '请选择上限方案'}}});
- $('#integraMgrInfoForm').bootstrapValidator('addField', "max", {validators: {notEmpty: {message: '请填写积分上限'}}});
- $(".limit-setting").css("display", "block");
- break;
- default:
- $('#integraMgrInfoForm').bootstrapValidator('removeField', "yearly");
- $('#integraMgrInfoForm').bootstrapValidator('removeField', "max");
- $(".limit-setting").css("display", "none");
- }
- }
- /**
- * 提交添加
- */
- IntegralItemMgrInfo.addSubmit = function () {
- this.clearData();
- this.collectData();
- if (!this.validate()) {
- return;
- }
- var ajax = new $ax("/admin/integral_mgr/addItem", function (data) {
- if (data.code == "200") {
- Feng.success(data.msg);
- window.parent.IntegralItemMgr.table.refresh();
- IntegralItemMgrInfo.close();
- } else {
- Feng.error(data.msg);
- }
- }, function (data) {
- Feng.error("添加失败!" + data.responseJSON.message + "!");
- });
- ajax.set(this.integralItemMgrInfoData);
- ajax.start();
- }
- /**
- * 提交修改
- */
- IntegralItemMgrInfo.editSubmit = function () {
- this.clearData();
- this.collectData();
- if (!this.validate()) {
- return;
- }
- var ajax = new $ax(Feng.ctxPath + "/admin/integral_mgr/editItem", function (data) {
- if (data.code == "200") {
- Feng.success(data.msg);
- window.parent.IntegralItemMgr.table.refresh();
- IntegralItemMgrInfo.close();
- } else {
- Feng.error(data.msg);
- }
- }, function (data) {
- Feng.error("修改失败!" + data.responseJSON.message + "!");
- });
- ajax.set(this.integralItemMgrInfoData);
- ajax.start();
- }
- /**
- * 验证数据是否为空
- */
- IntegralItemMgrInfo.validate = function () {
- $('#integraMgrInfoForm').data("bootstrapValidator").resetForm();
- $('#integraMgrInfoForm').bootstrapValidator('validate');
- return $("#integraMgrInfoForm").data('bootstrapValidator').isValid();
- }
- $(function () {
- Feng.initValidator("integraMgrInfoForm", IntegralItemMgrInfo.validateFields);
- //下拉框数据回显
- $("select").each(function () {
- $(this).val($(this).attr("selectVal"));
- });
- IntegralItemMgrInfo.onTypeChange();
- IntegralItemMgrInfo.onIntegralPlanChange();
- IntegralItemMgrInfo.onLimitChange();
- $("#fileTypeId").chosen({
- no_results_text: "没有找到结果!",
- width: '100%',
- search_contains: true, //关键字模糊搜索。设置为true,只要选项包含搜索词就会显示;设置为false,则要求从选项开头开始匹配
- disable_search: false,
- enable_split_word_search: true,
- rtl: true
- });
- var fileTypeIds = $("#fileTypeId").attr("selectVal")
- $("#fileTypeId").val(fileTypeIds.split(",")).trigger("chosen:updated");
- });
|