integralInfo.js 28 KB

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