enterprise_change_edit.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. var locked = false;
  2. var EpChangeEdit = {
  3. epChangeEditData: {},
  4. validateFields1: {
  5. newName: {validators: {notEmpty: {message: '企业名称不能为空'}}}, //, regexp: {regexp: /^([\u4E00-\u9FA5]|\(|\)){1,100}$/, message: "单位名称只允许中文"}
  6. newIdCard: {validators: {notEmpty: {message: '统一社会信用代码不能为空'}}},
  7. newEnterpriseTag: {validators: {notEmpty: {message: '企业标签不能为空'}}},
  8. newEnterpriseType: {validators: {notEmpty: {message: '企业类型不能为空'}}},
  9. newLegal: {validators: {notEmpty: {message: '法人代表不能为空'}}}, //, regexp: {regexp: /^[\u4e00-\u9fa5]{1,50}$/, message: "法人代表只允许中文"}
  10. newAddress: {validators: {notEmpty: {message: '企业地址不能为空'}}},
  11. newStreet: {validators: {notEmpty: {message: '所属街道不能为空'}}},
  12. newAgentName: {validators: {notEmpty: {message: '人才联络员不能为空'}}},
  13. newEphone: {
  14. validators: {
  15. notEmpty: {
  16. message: '企业电话不能为空'
  17. },
  18. regexp: {
  19. regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
  20. message: "企业电话格式不正确"
  21. }
  22. }
  23. },
  24. newAgentPhone: {
  25. validators: {
  26. notEmpty: {
  27. message: '人才联络员电话不能为空'
  28. },
  29. regexp: {
  30. regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
  31. message: "人才联络员电话格式不正确"
  32. }
  33. }
  34. },
  35. newAgentEmail: {
  36. validators: {
  37. notEmpty: {
  38. message: '电子邮箱不能为空'
  39. },
  40. emailAddress: {
  41. message: "电子邮箱格式不正确"
  42. }
  43. }
  44. },
  45. newBankCard: {
  46. validators: {
  47. notEmpty: {
  48. message: '企业银行账号不能为空'
  49. }
  50. }
  51. },
  52. newBank: {
  53. validators: {
  54. notEmpty: {
  55. message: '企业开户银行不能为空'
  56. }
  57. }, regexp: {regexp: /^([\u4E00-\u9FA5]|\(|\)|\(|\)){1,100}$/, message: "开户银行只允许中文"}
  58. },
  59. newBankNetwork: {
  60. validators: {notEmpty: {message: '开户银行网点不能为空'},
  61. regexp: {
  62. regexp: /^[\u4e00-\u9fa5]*银行[\u4e00-\u9fa5]*$/,
  63. message: "开户银行网点格式不正确"
  64. }}
  65. }
  66. },
  67. validateFields2: {
  68. newName: {validators: {notEmpty: {message: '单位名称不能为空'}}}, //, regexp: {regexp: /^[\u4e00-\u9fa5]{1,100}$/, message: "单位名称只允许中文"}
  69. newAddress: {validators: {notEmpty: {message: '单位地址不能为空'}}},
  70. newStreet: {validators: {notEmpty: {message: '所属街道不能为空'}}},
  71. newAgentName: {validators: {notEmpty: {message: '人才联络员不能为空'}}},
  72. newEphone: {
  73. validators: {
  74. notEmpty: {
  75. message: '单位电话不能为空'
  76. },
  77. regexp: {
  78. regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
  79. message: "单位电话格式不正确"
  80. }
  81. }
  82. },
  83. newAgentPhone: {
  84. validators: {
  85. notEmpty: {
  86. message: '人才联络员电话不能为空'
  87. },
  88. regexp: {
  89. regexp: /(^(\d{11})|^((\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})))$/,
  90. message: "人才联络员电话格式不正确"
  91. }
  92. }
  93. },
  94. newAgentEmail: {
  95. validators: {
  96. notEmpty: {
  97. message: '电子邮箱不能为空'
  98. },
  99. emailAddress: {
  100. message: "电子邮箱格式不正确"
  101. }
  102. }
  103. }
  104. }
  105. };
  106. /**
  107. * 清除数据
  108. */
  109. EpChangeEdit.clearData = function () {
  110. this.epChangeEditData = {};
  111. }
  112. /**
  113. * 设置对话框中的数据
  114. *
  115. * @param key 数据的名称
  116. * @param val 数据的具体值
  117. */
  118. EpChangeEdit.set = function (key, val) {
  119. this.epChangeEditData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  120. return this;
  121. }
  122. /**
  123. * 设置对话框中的数据
  124. *
  125. * @param key 数据的名称
  126. * @param val 数据的具体值
  127. */
  128. EpChangeEdit.get = function (key) {
  129. return $("#" + key).val();
  130. }
  131. /**
  132. * 关闭此对话框
  133. */
  134. EpChangeEdit.close = function () {
  135. parent.layer.close(window.parent.EnterpriseCenter.layerIndex);
  136. }
  137. /**
  138. * 收集数据
  139. */
  140. EpChangeEdit.collectData = function () {
  141. this
  142. .set('id')
  143. .set('type')
  144. .set('newAgencyType')
  145. .set('newName')
  146. .set('newIdCard')
  147. .set('newEnterpriseTag')
  148. .set('newEnterpriseType')
  149. .set('newLegal')
  150. .set('newStreet')
  151. .set('newAddress')
  152. .set('newEphone')
  153. .set('newAgentName')
  154. .set('newAgentPhone')
  155. .set('newAgentEmail')
  156. .set('newIndustryFieldNew')
  157. .set('newIndustryFieldOld')
  158. .set('newOrganizationTag')
  159. .set('newInstitutionTag')
  160. .set('newBankCard')
  161. .set('newBank')
  162. .set('newBankNetwork')
  163. .set('enterprise_id');
  164. }
  165. /**
  166. * 验证数据
  167. */
  168. EpChangeEdit.validate = function () {
  169. $('#ecr_form').data("bootstrapValidator").resetForm();
  170. $('#ecr_form').bootstrapValidator('validate');
  171. return $("#ecr_form").data('bootstrapValidator').isValid();
  172. }
  173. EpChangeEdit.initFileTable = function () {
  174. $("#fileTable").bootstrapTable({
  175. url: Feng.ctxPath + "/common/api/listCurrencyFileType",
  176. method: 'POST',
  177. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  178. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  179. showRefresh: false, // 是否显示刷新按钮
  180. clickToSelect: true, // 是否启用点击选中行
  181. singleSelect: true, // 设置True 将禁止多选
  182. striped: true, // 是否显示行间隔色
  183. escape: true,
  184. pagination: false, // 设置为 true 会在表格底部显示分页条
  185. paginationHAlign: "left",
  186. paginationDetailHAlign: "right",
  187. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  188. showColumns: false,
  189. detailView: true, //是否显示父子表
  190. pageList: [10, 30, 50],
  191. queryParams: function (params) {
  192. return $.extend({"type": "enterpriseChange"}, params)
  193. },
  194. rowStyle: function (row, index) {
  195. return {classes: "info"};
  196. },
  197. columns: EpChangeEdit.initFileTypeColumn(),
  198. onPostBody: function () {
  199. $("td.uitd_showTip").bind("mouseover", function () {
  200. var htm = $(this).html();
  201. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  202. });
  203. },
  204. onLoadSuccess: function (data) {
  205. $("#fileTable").bootstrapTable('expandAllRows');
  206. },
  207. onExpandRow: function (index, row, $detail) {
  208. var ajax = new $ax(Feng.ctxPath + "/common/api/listTalentCommonFile", function (data) {
  209. if (data == null || data.length == 0) {
  210. return;
  211. }
  212. var checkState = $("#checkState").length > 0 ? $("#checkState").val() : 1;
  213. var files = "";
  214. if (checkState != 1) {
  215. files = $("#files").val().split(",");
  216. }
  217. var html = '<ul class="imgs"><li style="width: 80%;font-weight: bold;padding-top: 5px;">附件原名</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">预览</li><li style="width: 10%;font-weight: bold;padding-top: 5px;">操作</li>';
  218. for (var key in data) {
  219. var sn = data[key].url.lastIndexOf(".");
  220. var suffix = data[key].ext;//data[key].url.substring(sn+1,data[key].url.length);
  221. var imgStr = "";
  222. if (suffix == "pdf" || suffix == "PDF") {
  223. imgStr = "<button type='button' onclick=\"Feng.showPdf('" + data[key].url + "','" + data[key].id + "','" + data[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-pdf-o\" aria-hidden=\"true\"></i></button>";
  224. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') {
  225. imgStr = "<button type='button' onclick=\"Feng.showExcel('" + data[key].url + "','" + data[key].id + "','" + data[key].orignName + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-file-excel-o\" aria-hidden=\"true\"></i></button>";
  226. } else {
  227. imgStr = '<img class=\"imgUrl\" src=\"' + data[key].url + '\" style=\"width:25px;height:25px;\">';
  228. }
  229. var btn = "<button type=\'button\' onclick=\"EpChangeEdit.checkFile('" + row.id + "','" + data[key].id + "')\" style=\'margin-right: 10px\' class=\"btn btn-xs btn-info\"><i class=\"fa fa-paste\"></i>修改</button>" +
  230. "<button type='button' onclick=\"EpChangeEdit.deleteFile('" + data[key].id + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-times\"></i>删除</button>";
  231. html = html + '<li style="display: none">' + data[key].id + '</li>\n' +
  232. '<li style="width: 80%;padding-top: 5px;">' + data[key].orignName + '</li>\n' +
  233. '<li style="width: 10%;">' + imgStr + '</li>\n' +
  234. '<li style="width: 10%;padding-top: 2px;">' + (checkState == 1 ? btn : (files.indexOf(data[key].typeId.toString()) > -1 ? btn : "")) + '</li>';
  235. }
  236. html = html + '</ul>';
  237. $detail.html(html);
  238. $(".imgs").viewer({
  239. // toolbar:false,
  240. fullscreen: false
  241. });
  242. }, function (data) {
  243. Feng.error("查询失败!" + data.responseJSON.message + "!");
  244. });
  245. var queryData = {};
  246. queryData["mainId"] = $("#id").val();
  247. queryData["typeId"] = row.id;
  248. ajax.set(queryData);
  249. ajax.start();
  250. }
  251. });
  252. }
  253. EpChangeEdit.initFileTypeColumn = function () {
  254. return [
  255. {field: 'selectItem', checkbox: false, visible: false},
  256. {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  257. formatter: function (value, row, index) {
  258. if (row.must == 1) {
  259. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  260. }
  261. if (row.must == 2) {
  262. return '<i class="fa fa-paste"></i>' + value;
  263. }
  264. }
  265. },
  266. {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "50%", 'class': 'uitd_showTip',
  267. formatter: function (value, row, index) {
  268. return '<span style="color: red">' + value + '</span>';
  269. }
  270. },
  271. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "10%",
  272. formatter: function (value, row, index) {
  273. if (value == null || value == '' || value == 'null') {
  274. return '无';
  275. }
  276. return "<button type='button' onclick=\"Feng.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  277. "<i class=\"fa fa-download\"></i>下载" +
  278. "</button>";
  279. }
  280. },
  281. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
  282. formatter: function (value, row, index) {
  283. var checkState = $("#checkState").length > 0 ? $("#checkState").val() : 1;
  284. if (checkState == 1) {
  285. return "<button type='button' onclick=\"EpChangeEdit.checkFile('" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  286. "<i class=\"fa fa-upload\"></i>上传" +
  287. "</button>";
  288. } else {
  289. var files = $("#files").val().split(",");
  290. if (files.indexOf(value.toString()) != -1) {
  291. return "<button type='button' onclick=\"EpChangeEdit.checkFile('" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  292. "<i class=\"fa fa-upload\"></i>上传" +
  293. "</button>";
  294. } else {
  295. return "";
  296. }
  297. }
  298. }
  299. }
  300. ]
  301. }
  302. //选择附件并显示附件名
  303. EpChangeEdit.checkFile = function (fileTypeId, fileId) {
  304. var checkState = $("#checkState").val();
  305. if (checkState == 2) {
  306. Feng.error("正在审核中,无法修改");
  307. return;
  308. }
  309. if (checkState == 4) {
  310. Feng.error("审核通过,无法修改");
  311. return;
  312. }
  313. $("#upload_file").unbind("change");
  314. $("#upload_file").change(function () {
  315. if (!Feng.chkFileInvalid(this.files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "只允许上传PDF或图片"))
  316. return;
  317. EpChangeEdit.upload(fileTypeId, fileId);
  318. });
  319. $('#upload_file').val("");
  320. $('#upload_file').click()
  321. }
  322. //上传附件
  323. EpChangeEdit.upload = function (fileTypeId, fileId) {
  324. if (fileId != null && fileId != 'null') {
  325. $("#fileId").val(fileId)
  326. } else {
  327. $("#fileId").val("");
  328. }
  329. $("#mainId").val($("#id").val());
  330. $("#typeId").val(fileTypeId);
  331. var index = layer.load(0, {shade: false, time: 0});
  332. $("#index").val(index);
  333. $("#uploadForm").submit();
  334. }
  335. //删除附件
  336. EpChangeEdit.deleteFile = function (id) {
  337. var checkState = $("#checkState").val();
  338. if (checkState == 2) {
  339. Feng.error("正在审核中,无法修改");
  340. return;
  341. }
  342. if (checkState == 4) {
  343. Feng.error("审核通过,无法删除");
  344. return;
  345. }
  346. var operation = function () {
  347. var ajax = new $ax("/common/api/deleteTalentCommonFile", function (data) {
  348. if (data.code == 200) {
  349. Feng.success(data.msg);
  350. $("#fileTable").bootstrapTable("refresh", {});
  351. } else {
  352. Feng.error(data.msg);
  353. }
  354. }, function (data) {
  355. Feng.error("删除失败!" + data.responseJSON.message + "!");
  356. });
  357. ajax.set("id", id);
  358. ajax.start();
  359. }
  360. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  361. }
  362. EpChangeEdit.addSubmit = function () {
  363. this.clearData();
  364. this.collectData();
  365. if (!this.validate()) {
  366. return;
  367. }
  368. var checkState = $("#checkState").val();
  369. if (checkState == 2 || checkState == 5 || checkState == 7) {
  370. Feng.info("正在审核中,无法修改")
  371. return;
  372. }
  373. if (checkState == 4) {
  374. Feng.info("已审核通过,无法修改")
  375. return;
  376. }
  377. // $(".layui-layer-btn0",parent.document).css("pointer-events","none");
  378. if (locked) {
  379. Feng.info("保存进行中,请耐心等候")
  380. return;
  381. }
  382. locked = true;
  383. layer.load(0, {shade: false, time: 0});
  384. /*var ajax = new $ax(Feng.ctxPath + "/enterprise/api/upsert", function (data) {
  385. if (data.code == "200") {
  386. Feng.success(data.msg);
  387. $("#fileLi").removeAttr("style");
  388. $("#id").val(data.obj.id);
  389. $("#checkState").val(data.obj.checkState);
  390. window.parent.EnterpriseCenter.table.refresh();
  391. } else {
  392. Feng.info(data.msg);
  393. }
  394. // $(".layui-layer-btn0",parent.document).css("pointer-events","block");
  395. locked = false;
  396. }, function (data) {
  397. Feng.error("添加失败!" + data.responseJSON.msg + "!");
  398. locked = false;
  399. });
  400. ajax.set(this.epChangeEditData);
  401. ajax.start();*/
  402. $("#ecr_form :input").removeAttr("disabled");
  403. $("#ecr_form").attr("action", "/enterprise/api/upsert");
  404. $("#ecr_form")[0].submit();
  405. };
  406. /**
  407. * 提交审核
  408. */
  409. EpChangeEdit.submitToCheck = function () {
  410. if (locked) {
  411. Feng.info("保存进行中,请耐心等候")
  412. return;
  413. }
  414. var id = $("#id").val();
  415. if (id == null || id == "") {
  416. Feng.info("请先填写基础信息并上传附件");
  417. return;
  418. }
  419. var checkState = $("#checkState").val();
  420. if (checkState == 2 || checkState == 5) {
  421. Feng.error("正在审核中,无法修改");
  422. return;
  423. }
  424. if (checkState == 4) {
  425. Feng.error("审核通过,无法修改");
  426. return;
  427. }
  428. $(".layui-layer-btn1", parent.document).css("pointer-events", "none");
  429. var operation = function () {
  430. var ajax = new $ax(Feng.ctxPath + "/enterprise/api/submitToCheck", function (data) {
  431. if (data.code == 200) {
  432. Feng.success(data.msg);
  433. window.parent.EnterpriseCenter.table.refresh();
  434. EpChangeEdit.close();
  435. } else {
  436. Feng.error(data.msg);
  437. }
  438. $(".layui-layer-btn1", parent.document).css("pointer-events", "block");
  439. }, function (data) {
  440. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  441. $(".layui-layer-btn1", parent.document).css("pointer-events", "block");
  442. });
  443. ajax.set("id", id);
  444. ajax.start();
  445. }
  446. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  447. }
  448. EpChangeEdit.setFieldDisabled = function () {
  449. var checkState = $("#checkState").length > 0 ? $("#checkState").val() : 1;
  450. if (checkState != 1) {
  451. $("#ecr_form :input").prop("disabled", true);
  452. $("#ecr_form :button").css("display", "none");
  453. var fields = $("#fields").val().split(",");
  454. for (var i in fields) {
  455. $("#" + fields[i]).removeAttr("disabled");
  456. }
  457. var files = $("#files").val().split(",");
  458. for (var i in files) {
  459. switch (files[i]) {
  460. case "newImgurl":
  461. $("#imgurl").removeAttr("disabled");
  462. $("#imgurl").parent().find("button").removeAttr("disabled").css("display", "block");
  463. break;
  464. case "newBankImg":
  465. $("#bankImg").removeAttr("disabled");
  466. $("#bankImg").parent().find("button").removeAttr("disabled").css("display", "block");
  467. break;
  468. case "newDomainImg":
  469. $("#domainImg").removeAttr("disabled");
  470. $("#domainImg").parent().find("button").removeAttr("disabled").css("display", "block");
  471. break;
  472. case "newTypeImg":
  473. $("#typeImg").removeAttr("disabled");
  474. $("#typeImg").parent().find("button").removeAttr("disabled").css("display", "block");
  475. break;
  476. case "newBeian":
  477. $("#beian").removeAttr("disabled");
  478. $("#beian").parent().find("button").removeAttr("disabled").css("display", "block");
  479. break;
  480. }
  481. }
  482. }
  483. }
  484. EpChangeEdit.callBack = function (data) {
  485. layer.closeAll();
  486. EpChangeEdit.setFieldDisabled();
  487. locked = false;
  488. Feng.info(data.msg);
  489. if (data.code == 200) {
  490. $("#id").val(data.id);
  491. $("input[type=file]").val("");
  492. window.parent.EnterpriseCenter.table.refresh();
  493. }
  494. };
  495. EpChangeEdit.downloadFile = function (id) {
  496. window.location.href = Feng.ctxPath + '/enterprisechangeRecord/downloadFile?id=' + id;
  497. };
  498. EpChangeEdit.industryChange = function () {
  499. var industryNew = $("#newIndustryFieldNew").val();
  500. var arr = [{"name": "newIndustryFieldOld", "code": industryNew + "_field"}];
  501. Feng.findChildDictBatch(JSON.stringify(arr));
  502. }
  503. EpChangeEdit.changeEnterpriseType = function () {
  504. var enterpriseType = $("#newEnterpriseType").val();
  505. switch (enterpriseType) {
  506. case "guishang":
  507. case "gaoxinjishu":
  508. case "zhuanjingtexin":
  509. $("td.typeUploader").css("display", "table-cell");
  510. break;
  511. default:
  512. $("td.typeUploader").css("display", "none");
  513. break;
  514. }
  515. };
  516. $("#imgurl,#bankImg,#beian,#domainImg,#typeImg").change(function (e) {
  517. var that = this;
  518. if (!Feng.chkFileInvalid(that.files[0], 5, 10, ["image/jpeg", "image/gif", "image/png", "image/jpg", "application/pdf"], "只允许上传PDF或图片")) {
  519. return;
  520. }
  521. var file = that.files[0];
  522. var imgSrc;
  523. var reader = new FileReader();
  524. reader.readAsDataURL(file);
  525. reader.onload = function () {
  526. if (Feng.isImg(file.type)) {
  527. imgSrc = this.result;
  528. $(that).prev("img").attr("src", imgSrc);
  529. } else {
  530. $(that).prev("img").attr("src", Feng.ctxPath + "/static/img/Pdf.png");
  531. Feng.info("上传成功!<span style='color:red;'>*点击图标可预览</span>");
  532. }
  533. };
  534. });
  535. $("img").click(function () {
  536. var fileInput = $(this).next("input");
  537. var file = fileInput[0].files[0];
  538. if (typeof file != "undefined" && file.type == "application/pdf") {
  539. var url = URL.createObjectURL(file);
  540. var filename = file.name;
  541. //window.open(url)
  542. Feng.pdfReader(url, filename);
  543. } else {
  544. var url = $(this).data("url");
  545. if (typeof url != "undefined") {
  546. Feng.showPdf(url);
  547. }
  548. }
  549. })
  550. EpChangeEdit.agencyTypeChange = function () {
  551. var agencyType = $("#newAgencyType").val();
  552. switch (agencyType) {
  553. case "1":
  554. $("#typeGroup").attr("style", "display:block");
  555. $(".agencyType1").attr("style", "");
  556. $(".agencyType2").attr("style", "");
  557. break;
  558. case "2":
  559. $("#typeGroup").attr("style", "display:block");
  560. $(".agencyType1").attr("style", "display:none");
  561. $(".agencyType2").attr("style", "");
  562. $("#newIndustryFieldNew").val("");
  563. $("#newIndustryFieldOld").val("");
  564. break;
  565. default:
  566. $("#typeGroup").attr("style", "display:none");
  567. break;
  568. }
  569. }
  570. $(function () {
  571. EpChangeEdit.setFieldDisabled();
  572. var type = $("#type").val();
  573. var special = parseInt($("#special").val());
  574. $('#ecr_form').bootstrapValidator({
  575. feedbackIcons: {
  576. valid: 'glyphicon glyphicon-ok',
  577. invalid: 'glyphicon glyphicon-remove',
  578. validating: 'glyphicon glyphicon-refresh'
  579. },
  580. group: '.rowGroup',
  581. fields: special == 1 ? EpChangeEdit.validateFields2 : EpChangeEdit.validateFields1,
  582. live: 'enabled',
  583. message: '该字段不能为空'
  584. });
  585. //Feng.initValidator("ecr_form", EpChangeEdit.validateFields);
  586. var industryNew = $("#newIndustryFieldNew").attr("value");
  587. var arr = [
  588. {"name": "newStreet", "code": "street"},
  589. {"name": "newEnterpriseTag", "code": "enterprise_tag"},
  590. {"name": "newOrganizationTag", "code": "organization_tag"},
  591. {"name": "newInstitutionTag", "code": "institution_tag"},
  592. {"name": "newEnterpriseType", "code": "enterprise_type"},
  593. {"name": "newIndustryFieldNew", "code": "industry_field"},
  594. {"name": "newIndustryFieldOld", "code": industryNew + "_field"},
  595. {"name": "newAgencyType", "code": "agency_type"}];
  596. Feng.findChildDictBatch(JSON.stringify(arr));
  597. $("select").each(function () {
  598. $(this).val($(this).attr("value"));
  599. })
  600. if (type == 1) {
  601. $("#newEnterpriseTag,#newIndustryFieldNew,#newIndustryFieldOld,#newEnterpriseType").parent().parent().attr("style", "display:cell");
  602. $("#newEnterpriseTag").val($("#newEnterpriseTag").attr("value"));
  603. $("#newIndustryFieldNew").val($("#newIndustryFieldNew").attr("value"));
  604. $("#newIndustryFieldOld").val($("#newIndustryFieldOld").attr("value"));
  605. } else {
  606. $("#newEnterpriseTag,#newIndustryFieldNew,#newIndustryFieldOld,#newEnterpriseType").parent().parent().attr("style", "display:none");
  607. $("#newEnterpriseTag").val("");
  608. $("#newIndustryFieldNew").val("");
  609. $("#newBankCard").parent().find("span").css("display", "none");
  610. $("#newBankNetwork").parent().find("span").css("display", "none");
  611. $("#newBank").parent().find("span").css("display", "none");
  612. $("#bankImg").parent().find("span").css("display", "none");
  613. $('#ecr_form').bootstrapValidator("removeField", "newBankCard");
  614. $('#ecr_form').bootstrapValidator("removeField", "newBankNetwork");
  615. $('#ecr_form').bootstrapValidator("removeField", "newBank");
  616. }
  617. var id = $("#id").val();
  618. if (id != null && id != '') {
  619. $("#fileLi").removeAttr("style");
  620. } else {
  621. $("#fileLi").attr("style", "pointer-events: none");
  622. }
  623. });