integralInfo.js 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  1. /**
  2. * 初始化人才认定申报详情对话框
  3. */
  4. var locked = false;
  5. var IntegralInfoDlg = {
  6. integralInfoData: {},
  7. validateFields: {
  8. name: {validators: {notEmpty: {message: '姓名不能为空'}}},
  9. card_type: {validators: {notEmpty: {message: '证件类型不能为空'}}},
  10. card_number: {
  11. validators: {
  12. notEmpty: {message: '证件号码不能为空'},
  13. regexp: {
  14. regexp: /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/,
  15. message: "身份证号码格式不正确"
  16. }
  17. }
  18. },
  19. phone: {
  20. validators: {
  21. notEmpty: {
  22. message: '手机号码不能为空'
  23. },
  24. regexp: {
  25. regexp: /0?(13|14|15|17|18|19)[0-9]{9}/,
  26. message: "手机号码格式不正确"
  27. }
  28. }
  29. },
  30. email: {
  31. validators: {
  32. notEmpty: {
  33. message: '电子邮箱不能为空'
  34. },
  35. emailAddress: {
  36. message: "电子邮箱格式不正确"
  37. }
  38. }
  39. }
  40. }
  41. };
  42. /**
  43. * 清除数据
  44. */
  45. IntegralInfoDlg.clearData = function () {
  46. this.integralInfoData = {};
  47. }
  48. /**
  49. * 设置对话框中的数据
  50. *
  51. * @param key 数据的名称
  52. * @param val 数据的具体值
  53. */
  54. IntegralInfoDlg.set = function (key, val) {
  55. var dis = $("#" + key).attr("disabled");
  56. if (dis == "disabled") {
  57. $("#" + key).removeAttr("disabled");
  58. }
  59. this.integralInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  60. if (dis == "disabled") {
  61. $("#" + key).prop("disabled", true);
  62. }
  63. return this;
  64. }
  65. /**
  66. * 设置对话框中的数据
  67. *
  68. * @param key 数据的名称
  69. * @param val 数据的具体值
  70. */
  71. IntegralInfoDlg.get = function (key) {
  72. return $("#" + key).val();
  73. }
  74. /**
  75. * 关闭此对话框
  76. */
  77. IntegralInfoDlg.close = function () {
  78. parent.layer.close(window.parent.Integral.layerIndex);
  79. }
  80. /**
  81. * 收集数据
  82. */
  83. IntegralInfoDlg.collectData = function () {
  84. this
  85. .set('id')
  86. .set('type')
  87. .set('name')
  88. .set('card_type')
  89. .set('card_number')
  90. .set('phone')
  91. .set('email');
  92. }
  93. /**
  94. * 验证数据
  95. */
  96. IntegralInfoDlg.validate = function () {
  97. $('#integralInfoForm').data("bootstrapValidator").resetForm();
  98. $('#integralInfoForm').bootstrapValidator('validate');
  99. return $("#integralInfoForm").data('bootstrapValidator').isValid();
  100. }
  101. /**
  102. * 初始化表格的列
  103. */
  104. IntegralInfoDlg.initFileTypeColumn = function () {
  105. return [
  106. {field: 'selectItem', checkbox: false, visible: false},
  107. {title: '附件列表', field: 'name', visible: true, align: 'left', valign: 'middle', width: "100%", 'class': 'uitd_showTip',
  108. formatter: function (value, row, index) {
  109. return '<span style="color:#ff0000;">申报"' + value + '"积分项目需要上传以下附件(带*号的附件必需上传)</span>';
  110. }
  111. },
  112. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "8%"},
  113. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%"}
  114. ]
  115. };
  116. IntegralInfoDlg.addItem = function () {
  117. var html = '<table style="width:100%;border-collapse: collapse;" class="table table-bordered">' +
  118. ' <tr>' +
  119. ' <td style="width:40px;">' +
  120. ' <div class="rowGroup">' +
  121. ' <label class="control-label spacing td-label">选择</label>' +
  122. ' <input type="checkbox" name="chk[]" class="form-control"/>' +
  123. ' </td>' +
  124. ' <td>' +
  125. ' <div class="rowGroup">' +
  126. ' <label class=" control-label spacing td-label"><span style="color: red">*</span>项目类别</label>' +
  127. ' <select class="form-control" name="projectType[]" value="" onchange="IntegralInfoDlg.onProjectTypeChange(this);">' +
  128. ' <option value="">请选择</option>' +
  129. ' <!--<option value="1">基础分</option>-->' +
  130. ' <option value="2">贡献分</option>' +
  131. ' <option value="3">资历分</option>' +
  132. ' </select>' +
  133. ' </div>' +
  134. ' </td>' +
  135. ' <td>' +
  136. ' <div class="rowGroup">' +
  137. ' <label class=" control-label spacing td-label"><span style="color: red">*</span>积分项目</label>' +
  138. ' <select class="form-control" name="projectId[]" value="" onchange="IntegralInfoDlg.onProjectChange(this);">' +
  139. ' <option value="">请选择</option>' +
  140. ' </select>' +
  141. ' </div>' +
  142. ' </td>' +
  143. ' <td>' +
  144. ' <div class="rowGroup">' +
  145. ' <label class=" control-label spacing td-label"><span style="color: red">*</span>积分标准</label>' +
  146. ' <select class="form-control" name="item_id[]" value="" onchange="IntegralInfoDlg.onItemChange(this);">' +
  147. ' <option value="">请选择</option>' +
  148. ' </select>' +
  149. ' </div>' +
  150. ' </td>' +
  151. ' <td>' +
  152. ' <div class="rowGroup">' +
  153. ' <label class="control-label spacing td-label"><span style="color: red">*</span>数额<span class="unit"></span></label>' +
  154. ' <input type="text" class="form-control" name="amount[]" value="" onkeyup="IntegralInfoDlg.onAmountChange(this);"/>' +
  155. ' </div>' +
  156. ' </td>' +
  157. ' <td>' +
  158. ' <div class="rowGroup">' +
  159. ' <label class=" control-label spacing td-label">预估积分</label>' +
  160. ' <div class="form-control points" style="border: none">-</div>' +
  161. ' </div>' +
  162. ' </td>' +
  163. ' </tr>' +
  164. ' </table>';
  165. /*
  166. *
  167. ' <tr>' +
  168. ' <td colspan="5">' +
  169. ' <table class="fileTable"></table>' +
  170. ' </td>' +
  171. ' </tr>' +
  172. *
  173. */
  174. $("#toolbar").before(html);
  175. }
  176. IntegralInfoDlg.changeAndLoadFile = function () {
  177. var table = $(".fileTable");
  178. var items = $("select[name='item_id[]']");
  179. var item_id = [];
  180. for (var i = 0; i < items.length; i++) {
  181. let _id = items.eq(i).val();
  182. if (_id) {
  183. item_id.push(_id);
  184. }
  185. }
  186. if (item_id.length == 0) {
  187. table.bootstrapTable("destroy");
  188. return;
  189. }
  190. var ajax = new $ax("/common/api/findCommonFileType", function (data) {
  191. table.bootstrapTable("destroy");
  192. if (data == null || data.length == 0) {
  193. return;
  194. }
  195. table.bootstrapTable({
  196. columns: IntegralInfoDlg.initFileTypeColumn(),
  197. data: data.rows,
  198. showHeader: true,
  199. rowStyle: function (row, index) {
  200. return {classes: ""};
  201. },
  202. onPostBody: function (data) {
  203. for (var i in data) {
  204. var fileTypes = data[i].fileTypes;
  205. for (var k in fileTypes) {
  206. var fileType = fileTypes[k];
  207. /**-- 构造附件类型标题栏 --**/
  208. let name = '<div class="word-wrap">';
  209. if (fileType.must == 1) {
  210. name = name + '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + fileType.name;
  211. }
  212. if (fileType.must == 2) {
  213. name = name + '<i class="fa fa-paste"></i>' + fileType.name;
  214. }
  215. name = name + '<br />' + fileType.description + '</div>'
  216. var template = "";
  217. if (fileType.templateUrl == null || fileType.templateUrl == '' || fileType.templateUrl == 'null') {
  218. template = '无';
  219. } else {
  220. template = "<button type='button' onclick=\"IntegralInfoDlg.downloadFile('" + fileType.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  221. "<i class=\"fa fa-download\"></i>下载" +
  222. "</button>";
  223. }
  224. var uploadBtn = IntegralInfoDlg.validUploadButton(1, fileType.id, '', data[i].id);
  225. var tr = '<tr class="subTitleLine"><td class="uitd_showTip" style="text-align: left; vertical-align: middle; width: 82%; ">'
  226. + name +
  227. '</td>\n\
  228. \n\
  229. <td style="text-align: center; vertical-align: middle; width: 8%; ">' + template +
  230. '</td>\n\
  231. <td style="text-align: center; vertical-align: middle; width: 10%; ">' + uploadBtn +
  232. '</td></tr>';
  233. /**-- --**/
  234. var typeId = fileType.id;
  235. var files = fileType.files;
  236. var html = '<ul class="imgs"><li style="width: 70%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">预览</li><li style="width: 20%;font-weight: bold;padding-top: 5px;">操作</li>';
  237. for (var key in files) {
  238. var btn = "";
  239. btn = IntegralInfoDlg.validUploadButton(2, typeId, files[key].id, files[key].relationId);
  240. var sn = files[key].url.lastIndexOf(".");
  241. var suffix = files[key].ext; //files[key].url.substring(sn + 1, files[key].url.length);
  242. var imgStr = "";
  243. if (suffix == "pdf" || suffix == "PDF") {
  244. imgStr = "<button type='button' onclick=\"Feng.showPdf('" + files[key].url + "','" + files[key].id + "','" + files[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
  245. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') {
  246. imgStr = "<button type='button' onclick=\"Feng.showExcel('" + files[key].url + "','" + files[key].id + "','" + files[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
  247. } else {
  248. imgStr = '<img class=\"imgUrl\" onclick=\"Feng.showImg(this)\" src=\"' + files[key].url + '\" style=\"width:25px;height:25px;\">';
  249. }
  250. html += '<li data-id="' + files[key].id + '">\n\
  251. <div><input type="hidden" name="uploadFiles[]" value="' + files[key].id + '"></div>\n' +
  252. '<div style="width: 70%;">' + files[key].orignName + '</div>\n' +
  253. '<div style="width: 10%;">' + imgStr + '</div>\n' +
  254. '<div style="width: 20%;">' + btn + '</div>\n\
  255. </li>';
  256. }
  257. html = html + '</ul>';
  258. table.find("tr[data-index='" + i + "'] td").eq(0).attr("colspan", 3);
  259. table.find("tr[data-index='" + i + "'] td").eq(1).remove();
  260. table.find("tr[data-index='" + i + "'] td").eq(2).remove();
  261. table.find("tr[data-index='" + i + "']").after(tr);
  262. table.find("tr[data-index='" + i + "']").next(".subTitleLine").after('<tr class="detail-view"><td colspan="5">' + html + '</td></tr>');
  263. }
  264. }
  265. $("td.uitd_showTip").bind("mouseover", function () {
  266. var htm = $(this).html();
  267. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  268. });
  269. },
  270. });
  271. }, function (data) {
  272. Feng.error("查询失败!" + data.responseJSON.message + "!");
  273. });
  274. var queryData = {};
  275. queryData["mainId"] = $("#id").val();
  276. queryData['project'] = CONFIG.project_integral_apply;
  277. queryData['type'] = $("#type").val();
  278. queryData['pageToken'] = $("input[name=__token__]").val();
  279. queryData["itemId"] = item_id;
  280. queryData['checkState'] = $("#checkState").val();
  281. ajax.set(queryData);
  282. ajax.start();
  283. }
  284. IntegralInfoDlg.deleteItem = function () {
  285. var len = $("input[name='chk[]']:checked").length;
  286. if (len == 0) {
  287. Feng.info("请选择要移除的项目");
  288. }
  289. for (var i = 0; i < len; i++) {
  290. $("input[name='chk[]']:checked").eq(0).parents("table").remove();
  291. }
  292. IntegralInfoDlg.changeAndLoadFile();
  293. }
  294. IntegralInfoDlg.onProjectTypeChange = function (obj) {
  295. var projectType = $(obj).val();
  296. var projectObj = $(obj).parents("table").find("select[name='projectId[]']")
  297. Feng.addAjaxSelect({
  298. "obj": projectObj,
  299. "displayCode": "id",
  300. "displayName": "name",
  301. "type": "GET",
  302. "url": "/common/api/getIntegralProjectsByType/projectType/" + projectType
  303. });
  304. IntegralInfoDlg.calIntegral(obj);
  305. }
  306. IntegralInfoDlg.onProjectChange = function (obj) {
  307. var projectId = $(obj).val();
  308. var itemObj = $(obj).parents("table").find("select[name='item_id[]']");
  309. if (projectId) {
  310. Feng.addAjaxSelect({
  311. "obj": itemObj,
  312. "displayCode": "id",
  313. "displayName": "name",
  314. "bindData": "unit",
  315. "type": "GET",
  316. "url": "/common/api/getIntegralItemsByProject/projectId/" + projectId
  317. });
  318. IntegralInfoDlg.calIntegral(obj);
  319. }
  320. }
  321. IntegralInfoDlg.onItemChange = function (obj) {
  322. var unit = $(obj).find("option:selected").data("unit");
  323. var parent = $(obj).parents("table");
  324. if (typeof unit != "undefined" && unit) {
  325. parent.find(".unit").html("(" + unit + ")");
  326. } else {
  327. parent.find(".unit").html("");
  328. }
  329. IntegralInfoDlg.changeAndLoadFile();
  330. IntegralInfoDlg.calIntegral(obj);
  331. }
  332. IntegralInfoDlg.timeout = null;
  333. IntegralInfoDlg.delay = 500;
  334. IntegralInfoDlg.onAmountChange = function (obj) {
  335. clearTimeout(IntegralInfoDlg.timeout);
  336. IntegralInfoDlg.timeout = setTimeout(function () {
  337. IntegralInfoDlg.calIntegral(obj);
  338. }, IntegralInfoDlg.delay);
  339. }
  340. IntegralInfoDlg.calIntegral = function (obj) {
  341. var parent = $(obj).parents("table");
  342. var cardType = $("#card_type").val();
  343. var cardNumber = $("#card_number").val();
  344. var itemId = parent.find("select[name='item_id[]']").val();
  345. var amount = parent.find("input[name='amount[]']").val();
  346. var cardTypeArr = ["1", "2", "3"];
  347. if (cardTypeArr.indexOf(cardType) > -1 && cardNumber != "" && itemId > 0 && !isNaN(amount) && amount != "") {
  348. //条件齐全就可以查询积分
  349. var ajax = new $ax(Feng.ctxPath + "/common/api/calIntegral", function (data) {
  350. /*let point1 = typeof data.projectRemainderPoints != "undefined" ? (data.projectRemainderPoints > data.points ? data.points : data.projectRemainderPoints) : data.points;
  351. let point2 = typeof data.itemRemainderPoints != "undefined" ? (data.itemRemainderPoints > data.points ? data.points : data.itemRemainderPoints) : data.points;
  352. let points = point1 > point2 ? point2 : point1;*/
  353. parent.find(".points").html(data.points);
  354. }, function (data) {
  355. Feng.error("预估积分失败!" + data.responseJSON.message + "!");
  356. });
  357. ajax.set("cardType", cardType);
  358. ajax.set("cardNumber", cardNumber);
  359. ajax.set("itemId", itemId);
  360. ajax.set("amount", amount);
  361. ajax.start();
  362. } else {
  363. parent.find(".points").html("-");
  364. }
  365. }
  366. IntegralInfoDlg.multipleRefreshPoints = function () {
  367. var count = $("#itemList").find("table").length;
  368. for (var i = 0; i < count; i++) {
  369. var table = $("#itemList").find("table").eq(i);
  370. IntegralInfoDlg.calIntegral(table.find(".points")[0]);
  371. }
  372. }
  373. /**
  374. * 提交添加
  375. */
  376. IntegralInfoDlg.addSubmit = function () {
  377. this.clearData();
  378. this.collectData();
  379. if (!IntegralInfoDlg.validate()) {
  380. return;
  381. }
  382. var id = $('#id').val();
  383. if (id != null && id != '') {
  384. if (!IntegralInfoDlg.validateIsEdit())
  385. return;
  386. }
  387. $("select").each(function () {
  388. $(this).removeAttr("disabled");
  389. });
  390. if (locked) {
  391. //return;
  392. }
  393. locked = true;
  394. $("#integralInfoForm").attr("action", "/enterprise/integral/apply");
  395. $("#integralInfoForm")[0].submit();
  396. }
  397. //回调
  398. IntegralInfoDlg.infoCallback = function (data) {
  399. locked = false;
  400. IntegralInfoDlg.setNoChangeField();
  401. Feng.info(data.msg);
  402. if (data.code == 200) {
  403. window.parent.Integral.table.refresh();
  404. $("#id").val(data.obj.id);
  405. $("#fileLi").removeAttr("style");
  406. $("#checkState").val(data.obj.checkState);
  407. }
  408. return;
  409. }
  410. //校验是否保存基础信息
  411. IntegralInfoDlg.validId = function () {
  412. var id = $("#id").val();
  413. if (id != null && id != '') {
  414. $("#fileLi").removeAttr("style");
  415. } else {
  416. $("#fileLi").attr("style", "pointer-events: none");
  417. }
  418. }
  419. var currentTable = null;
  420. var currentTr = null;
  421. //选择附件并显示附件名
  422. IntegralInfoDlg.checkFile = function (content, fileTypeId, fileId, itemId) {
  423. currentTable = $(content).parents(".fileTable");
  424. var findTr = null;
  425. var curTr = $(content).parents("tr");
  426. while (!findTr) {
  427. if (curTr.prev("tr[data-index]")) {
  428. findTr = curTr.prev("tr[data-index]")
  429. } else {
  430. curTr = curTr.prev();
  431. }
  432. }
  433. currentTr = findTr.data("index");
  434. if (!IntegralInfoDlg.validateIsEdit())
  435. return;
  436. $("#upload_file").unbind("change");
  437. $("#upload_file").change(function () {
  438. if (!Feng.chkFileInvalid(this.files[0], 5, 10))
  439. return;
  440. IntegralInfoDlg.upload(fileTypeId, fileId, itemId);
  441. });
  442. $('#upload_file').val("");
  443. $('#upload_file').click();
  444. }
  445. //上传附件
  446. IntegralInfoDlg.upload = function (fileTypeId, fileId, itemId) {
  447. var id = $("#id").val();
  448. if (!IntegralInfoDlg.validateIsEdit())
  449. return;
  450. if (fileId != null && fileId != 'null') {
  451. $("#fileId").val(fileId)
  452. } else {
  453. $("#fileId").val("");
  454. }
  455. $("#mainId").val(id);
  456. $("#fileTypeId").val(fileTypeId);
  457. var index = layer.load(0, {shade: false, time: 0});
  458. $("#index").val(index);
  459. $("#relationId").val(itemId);
  460. $("#pageToken").val($("input[name=__token__]").val());
  461. $("#uploadForm").submit();
  462. }
  463. //删除附件
  464. IntegralInfoDlg.deleteFile = function (id, state) {
  465. if (!IntegralInfoDlg.validateIsEdit())
  466. return;
  467. var operation = function () {
  468. var ajax = new $ax(Feng.ctxPath + "/common/api/deleteFile", function (data) {
  469. if (data.code == 200) {
  470. Feng.success(data.msg);
  471. $("input[name='uploadFiles[]'][value='" + id + "']").parents("li").remove();
  472. //$("#fileTable").bootstrapTable("refresh", {});
  473. } else {
  474. Feng.error(data.msg);
  475. }
  476. }, function (data) {
  477. Feng.error("删除失败!" + data.responseJSON.message + "!");
  478. });
  479. ajax.set("id", id);
  480. ajax.set("type", 20);
  481. ajax.start();
  482. }
  483. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  484. }
  485. /**
  486. * 提交审核
  487. */
  488. IntegralInfoDlg.submitToCheck = function () {
  489. /*if (!IntegralInfoDlg.validate()) {
  490. return;
  491. }*/
  492. var id = $("#id").val();
  493. /*if (id == null || id == "") {
  494. Feng.info("请先填写基础信息并上传附件");
  495. return;
  496. }*/
  497. if (!IntegralInfoDlg.validateIsEdit())
  498. return;
  499. var operation = function () {
  500. IntegralInfoDlg.clearData();
  501. IntegralInfoDlg.collectData();
  502. /*if (!IntegralInfoDlg.validate()) {
  503. return;
  504. }*/
  505. var id = $('#id').val();
  506. if (id != null && id != '') {
  507. if (!IntegralInfoDlg.validateIsEdit())
  508. return;
  509. }
  510. $("select").each(function () {
  511. $(this).removeAttr("disabled");
  512. });
  513. if (locked) {
  514. return;
  515. }
  516. locked = true;
  517. $("#integralInfoForm").attr("action", "/enterprise/integral/submitToCheck");
  518. $("#integralInfoForm")[0].submit();
  519. }
  520. Feng.confirm("请确认积分申报内容已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  521. }
  522. //回调
  523. IntegralInfoDlg.submitCallback = function (data) {
  524. locked = false;
  525. IntegralInfoDlg.setNoChangeField();
  526. if (data.code == 200) {
  527. Feng.success(data.msg);
  528. // $("#checkState").val(data.obj);
  529. window.parent.Integral.table.refresh();
  530. IntegralInfoDlg.close();
  531. } else {
  532. Feng.error(data.msg);
  533. }
  534. }
  535. /**
  536. * 校验是否可以修改/提交审核
  537. */
  538. IntegralInfoDlg.validateIsEdit = function () {
  539. var checkState = $("#checkState").val();
  540. if (checkState != 0 && checkState != 1) {
  541. if (checkState == 5 || checkState == 8) {
  542. Feng.error("您的申报审核不通过,无法再修改");
  543. return false;
  544. } else if (checkState == 28) {
  545. Feng.error("申报已完成");
  546. return false;
  547. } else if (checkState == 6) {
  548. Feng.error("您的申报已审核通过,无法再修改");
  549. return false;
  550. } else if (checkState == 22 || checkState == 25 || checkState == 27) {
  551. Feng.error("该申报已终止");
  552. return false;
  553. } else {
  554. Feng.error("您的申报正在审核中,请耐心等待");
  555. return false;
  556. }
  557. }
  558. return true;
  559. }
  560. /**
  561. * 校验是否显示按钮
  562. * @param type 类型 1-上传按钮,2-修改删除按钮
  563. * @param row
  564. * @returns {string}
  565. */
  566. IntegralInfoDlg.validUploadButton = function (type, fileTypeId, fileId, itemId) {
  567. var files = $("#files").val();
  568. files = files.split(",");
  569. var checkState = $("#checkState").val();
  570. var realState = $("#realState").val();
  571. if (Feng.isEmptyStr(checkState) || checkState == 0 || (checkState == 1 && realState == 1) || (realState == 4 && files[0] == 1)) {
  572. if (type == 1) { //上传
  573. return "<button type='button' onclick=\"IntegralInfoDlg.checkFile(this," + fileTypeId + "," + null + "," + itemId + ")\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  574. "<i class=\"fa fa-upload\"></i>上传" +
  575. "</button>";
  576. } else {
  577. return "<button type=\'button\' onclick=\"IntegralInfoDlg.checkFile(this," + fileTypeId + "," + fileId + "," + itemId + ")\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\">" +
  578. "<i class=\"fa fa-paste\"></i>修改" +
  579. "</button>" +
  580. "<button type='button' onclick=\"IntegralInfoDlg.deleteFile(" + fileId + ")\" class=\"btn btn-xs btn-danger\">" +
  581. "<i class=\"fa fa-times\"></i>删除" +
  582. "</button>";
  583. }
  584. } else {
  585. return "";
  586. }
  587. }
  588. //回调
  589. IntegralInfoDlg.callBack = function (data) {
  590. layer.close(data.obj);
  591. Feng.info(data.msg);
  592. if (data.code == 200) {
  593. var sn = data.info.lastIndexOf(".");
  594. var suffix = data.ext; //data.info.substring(sn + 1, data.info.length);
  595. var imgStr = "";
  596. if (suffix == "pdf" || suffix == "PDF") {
  597. imgStr = "<button type='button' onclick=\"Feng.showPdf('" + data.info + "','" + data.id + "','" + data.orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
  598. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') {
  599. imgStr = "<button type='button' onclick=\"Feng.showExcel('" + data.info + "','" + data.id + "','" + data.orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
  600. } else {
  601. imgStr = '<img class="imgUrl" src="' + data.info + '" style="width:25px;height:25px;">';
  602. }
  603. var li = $("input[name='uploadFiles[]'][value='" + data.id + "'").parents("li");
  604. if (li.length > 0) {
  605. li.find("div").eq(1).html(data.orignName);
  606. li.find("div").eq(2).html(imgStr);
  607. } else {
  608. var html = '<li data-id="' + data.id + '">\n\
  609. <div><input type="hidden" name="uploadFiles[]" value="' + data.id + '"></div>\n\
  610. <div style="width: 70%;">' + data.orignName + '</div>\n\
  611. <div style="width: 10%;">' + imgStr + '</div>\n\
  612. <div style="width: 20%;">\n\
  613. <button type="button" onclick="IntegralInfoDlg.checkFile(this,' + data.typeId + ',' + data.id + ',' + data.itemId + ')" style="margin-right: 10px" class="btn btn-xs btn-info"><i class="fa fa-paste"></i>修改</button>\n\
  614. <button type="button" onclick="IntegralInfoDlg.deleteFile(' + data.id + ')" class="btn btn-xs btn-danger"><i class="fa fa-times"></i>删除</button>\n\
  615. </div></li></ul>';
  616. $(currentTable).find("tr[data-index='" + currentTr + "']").next().next().find(".imgs").append(html);
  617. }
  618. }
  619. }
  620. IntegralInfoDlg.downloadFile = function (id, type) {
  621. window.location.href = Feng.ctxPath + "/api/common/downloadFile?id=" + id + "&type=" + type;
  622. }
  623. //设置不可修改的字段
  624. IntegralInfoDlg.setNoChangeField = function () {
  625. var checkState = $("#checkState").val();
  626. var fields = $("#fields").val();
  627. var allowedModifyItem = $("#files").val() == "1" ? true : false;
  628. var realState = $("#realState").val();
  629. if (realState == 4 || checkState == 2) {
  630. $("input,textarea").each(function () {
  631. $(this).attr("readonly", "readonly");
  632. });
  633. $("select,input[type=radio]").each(function () {
  634. $(this).attr("disabled", "disabled");
  635. });
  636. if (fields != null && fields != '') {
  637. var arr = fields.split(",");
  638. for (var key in arr) {
  639. if (arr[key] != "") {
  640. var name = $("#" + arr[key]).prop("tagName");
  641. if (name == 'select' || name == 'SELECT') {
  642. $("#" + arr[key]).removeAttr("disabled");
  643. } else if (name == "input" || name == 'textarea' || name == "INPUT" || name == 'TEXTAREA') {
  644. $("#" + arr[key]).removeAttr("readonly");
  645. } else {
  646. if (typeof name == "undefined") {
  647. $("input[name=" + arr[key] + "]").removeAttr("disabled").removeAttr("readonly");
  648. }
  649. }
  650. }
  651. }
  652. }
  653. if (!allowedModifyItem) {
  654. $("#toolbar").css("display", "none");
  655. } else {
  656. $("#itemList :input").removeAttr("readonly");
  657. $("#itemList :input").removeAttr("disabled");
  658. }
  659. }
  660. }
  661. $(function () {
  662. IntegralInfoDlg.setNoChangeField();
  663. $('#integralInfoForm').bootstrapValidator({
  664. feedbackIcons: {
  665. valid: 'glyphicon glyphicon-ok',
  666. invalid: 'glyphicon glyphicon-remove',
  667. validating: 'glyphicon glyphicon-refresh'
  668. },
  669. container: 'tooltip',
  670. group: '.rowGroup',
  671. fields: IntegralInfoDlg.validateFields,
  672. live: 'enabled',
  673. message: '该字段不能为空'
  674. }).on('error.field.bv', function (e, data) {
  675. // Get the tooltip
  676. var $parent = data.element.parents('#integralInfoForm'),
  677. $icon = $parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]'),
  678. title = $icon.data('bs.tooltip').getTitle();
  679. $icon.tooltip('show').tooltip({
  680. html: true,
  681. placement: 'right',
  682. title: title,
  683. container: 'body'
  684. });
  685. });
  686. var id = $("#id").val();
  687. var checkState = $("#checkState").val();
  688. if (id != null && id != '') {
  689. //select初始化
  690. $("select").each(function () {
  691. $(this).val($(this).attr("value")).trigger("change");
  692. });
  693. Feng.getCheckLog("logTable", {"type": CONFIG.project_integral_apply, "mainId": id, "typeFileId": "", "active": 1})
  694. }
  695. $("#card_type").val($("#card_type").attr("value"));
  696. IntegralInfoDlg.validId();
  697. //IntegralInfoDlg.changeAndLoadFile();
  698. });