enterprise_change_edit.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. var locked = false;
  2. var EpChangeEdit = {
  3. epChangeEditData: {},
  4. validateFields: {
  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. };
  68. /**
  69. * 清除数据
  70. */
  71. EpChangeEdit.clearData = function () {
  72. this.epChangeEditData = {};
  73. }
  74. /**
  75. * 设置对话框中的数据
  76. *
  77. * @param key 数据的名称
  78. * @param val 数据的具体值
  79. */
  80. EpChangeEdit.set = function (key, val) {
  81. this.epChangeEditData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
  82. return this;
  83. }
  84. /**
  85. * 设置对话框中的数据
  86. *
  87. * @param key 数据的名称
  88. * @param val 数据的具体值
  89. */
  90. EpChangeEdit.get = function (key) {
  91. return $("#" + key).val();
  92. }
  93. /**
  94. * 关闭此对话框
  95. */
  96. EpChangeEdit.close = function () {
  97. parent.layer.close(window.parent.EnterpriseCenter.layerIndex);
  98. }
  99. /**
  100. * 收集数据
  101. */
  102. EpChangeEdit.collectData = function () {
  103. this
  104. .set('id')
  105. .set('type')
  106. .set('newName')
  107. .set('newIdCard')
  108. .set('newEnterpriseTag')
  109. .set('newEnterpriseType')
  110. .set('newLegal')
  111. .set('newStreet')
  112. .set('newAddress')
  113. .set('newEphone')
  114. .set('newAgentName')
  115. .set('newAgentPhone')
  116. .set('newAgentEmail')
  117. .set('newIndustryFieldNew')
  118. .set('newIndustryFieldOld')
  119. .set('newBankCard')
  120. .set('newBank')
  121. .set('newBankNetwork')
  122. .set('enterprise_id');
  123. }
  124. /**
  125. * 验证数据
  126. */
  127. EpChangeEdit.validate = function () {
  128. $('#ecr_form').data("bootstrapValidator").resetForm();
  129. $('#ecr_form').bootstrapValidator('validate');
  130. return $("#ecr_form").data('bootstrapValidator').isValid();
  131. }
  132. EpChangeEdit.initFileTable = function () {
  133. $("#fileTable").bootstrapTable({
  134. url: Feng.ctxPath + "/common/api/listCurrencyFileType",
  135. method: 'POST',
  136. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  137. search: false, // 是否显示表格搜索,此搜索是客户端搜索,不会进服务端
  138. showRefresh: false, // 是否显示刷新按钮
  139. clickToSelect: true, // 是否启用点击选中行
  140. singleSelect: true, // 设置True 将禁止多选
  141. striped: true, // 是否显示行间隔色
  142. escape: true,
  143. pagination: false, // 设置为 true 会在表格底部显示分页条
  144. paginationHAlign: "left",
  145. paginationDetailHAlign: "right",
  146. sidePagination: "server", // 设置在哪里进行分页,可选值为 'client' 或者 'server'
  147. showColumns: false,
  148. detailView: true, //是否显示父子表
  149. pageList: [10, 30, 50],
  150. queryParams: function (params) {
  151. return $.extend({"type": "enterpriseChange"}, params)
  152. },
  153. rowStyle: function (row, index) {
  154. return {classes: "info"};
  155. },
  156. columns: EpChangeEdit.initFileTypeColumn(),
  157. onPostBody: function () {
  158. $("td.uitd_showTip").bind("mouseover", function () {
  159. var htm = $(this).html();
  160. $(this).webuiPopover({title: '详情', content: htm, trigger: 'hover'}).webuiPopover('show');
  161. });
  162. },
  163. onLoadSuccess: function (data) {
  164. $("#fileTable").bootstrapTable('expandAllRows');
  165. },
  166. onExpandRow: function (index, row, $detail) {
  167. var ajax = new $ax(Feng.ctxPath + "/common/api/listTalentCommonFile", function (data) {
  168. if (data == null || data.length == 0) {
  169. return;
  170. }
  171. var checkState = $("#checkState").length > 0 ? $("#checkState").val() : 1;
  172. var files = "";
  173. if (checkState != 1) {
  174. files = $("#files").val().split(",");
  175. }
  176. 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>';
  177. for (var key in data) {
  178. var sn = data[key].url.lastIndexOf(".");
  179. var suffix = data[key].ext;//data[key].url.substring(sn+1,data[key].url.length);
  180. var imgStr = "";
  181. if (suffix == "pdf" || suffix == "PDF") {
  182. 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>";
  183. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') {
  184. 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>";
  185. } else {
  186. imgStr = '<img class=\"imgUrl\" src=\"' + data[key].url + '\" style=\"width:25px;height:25px;\">';
  187. }
  188. 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>" +
  189. "<button type='button' onclick=\"EpChangeEdit.deleteFile('" + data[key].id + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-times\"></i>删除</button>";
  190. html = html + '<li style="display: none">' + data[key].id + '</li>\n' +
  191. '<li style="width: 80%;padding-top: 5px;">' + data[key].orignName + '</li>\n' +
  192. '<li style="width: 10%;">' + imgStr + '</li>\n' +
  193. '<li style="width: 10%;padding-top: 2px;">' + (checkState == 1 ? btn : (files.indexOf(data[key].typeId.toString()) > -1 ? btn : "")) + '</li>';
  194. }
  195. html = html + '</ul>';
  196. $detail.html(html);
  197. $(".imgs").viewer({
  198. // toolbar:false,
  199. fullscreen: false
  200. });
  201. }, function (data) {
  202. Feng.error("查询失败!" + data.responseJSON.message + "!");
  203. });
  204. var queryData = {};
  205. queryData["mainId"] = $("#id").val();
  206. queryData["typeId"] = row.id;
  207. ajax.set(queryData);
  208. ajax.start();
  209. }
  210. });
  211. }
  212. EpChangeEdit.initFileTypeColumn = function () {
  213. return [
  214. {field: 'selectItem', checkbox: false, visible: false},
  215. {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  216. formatter: function (value, row, index) {
  217. if (row.must == 1) {
  218. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  219. }
  220. if (row.must == 2) {
  221. return '<i class="fa fa-paste"></i>' + value;
  222. }
  223. }
  224. },
  225. {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "50%", 'class': 'uitd_showTip',
  226. formatter: function (value, row, index) {
  227. return '<span style="color: red">' + value + '</span>';
  228. }
  229. },
  230. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "10%",
  231. formatter: function (value, row, index) {
  232. if (value == null || value == '' || value == 'null') {
  233. return '无';
  234. }
  235. return "<button type='button' onclick=\"Feng.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  236. "<i class=\"fa fa-download\"></i>下载" +
  237. "</button>";
  238. }
  239. },
  240. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
  241. formatter: function (value, row, index) {
  242. var checkState = $("#checkState").length > 0 ? $("#checkState").val() : 1;
  243. if (checkState == 1) {
  244. return "<button type='button' onclick=\"EpChangeEdit.checkFile('" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  245. "<i class=\"fa fa-upload\"></i>上传" +
  246. "</button>";
  247. } else {
  248. var files = $("#files").val().split(",");
  249. if (files.indexOf(value.toString()) != -1) {
  250. return "<button type='button' onclick=\"EpChangeEdit.checkFile('" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  251. "<i class=\"fa fa-upload\"></i>上传" +
  252. "</button>";
  253. } else {
  254. return "";
  255. }
  256. }
  257. }
  258. }
  259. ]
  260. }
  261. //选择附件并显示附件名
  262. EpChangeEdit.checkFile = function (fileTypeId, fileId) {
  263. var checkState = $("#checkState").val();
  264. if (checkState == 2) {
  265. Feng.error("正在审核中,无法修改");
  266. return;
  267. }
  268. if (checkState == 4) {
  269. Feng.error("审核通过,无法修改");
  270. return;
  271. }
  272. $("#upload_file").unbind("change");
  273. $("#upload_file").change(function () {
  274. if (!Feng.chkFileInvalid(this.files[0], 5, 10))
  275. return;
  276. EpChangeEdit.upload(fileTypeId, fileId);
  277. });
  278. $('#upload_file').val("");
  279. $('#upload_file').click()
  280. }
  281. //上传附件
  282. EpChangeEdit.upload = function (fileTypeId, fileId) {
  283. if (fileId != null && fileId != 'null') {
  284. $("#fileId").val(fileId)
  285. } else {
  286. $("#fileId").val("");
  287. }
  288. $("#mainId").val($("#id").val());
  289. $("#typeId").val(fileTypeId);
  290. var index = layer.load(0, {shade: false, time: 0});
  291. $("#index").val(index);
  292. $("#uploadForm").submit();
  293. }
  294. //删除附件
  295. EpChangeEdit.deleteFile = function (id) {
  296. var checkState = $("#checkState").val();
  297. if (checkState == 2) {
  298. Feng.error("正在审核中,无法修改");
  299. return;
  300. }
  301. if (checkState == 4) {
  302. Feng.error("审核通过,无法删除");
  303. return;
  304. }
  305. var operation = function () {
  306. var ajax = new $ax("/common/api/deleteTalentCommonFile", function (data) {
  307. if (data.code = 200) {
  308. Feng.success(data.msg);
  309. $("#fileTable").bootstrapTable("refresh", {});
  310. } else {
  311. Feng.error(data.msg);
  312. }
  313. }, function (data) {
  314. Feng.error("删除失败!" + data.responseJSON.message + "!");
  315. });
  316. ajax.set("id", id);
  317. ajax.start();
  318. }
  319. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  320. }
  321. EpChangeEdit.addSubmit = function () {
  322. this.clearData();
  323. this.collectData();
  324. if (!this.validate()) {
  325. return;
  326. }
  327. var checkState = $("#checkState").val();
  328. if (checkState == 2 || checkState == 5) {
  329. Feng.info("正在审核中,无法修改")
  330. return;
  331. }
  332. if (checkState == 4) {
  333. Feng.info("已审核通过,无法修改")
  334. return;
  335. }
  336. // $(".layui-layer-btn0",parent.document).css("pointer-events","none");
  337. if (locked)
  338. return;
  339. locked = true;
  340. var ajax = new $ax(Feng.ctxPath + "/enterprise/api/upsert", function (data) {
  341. if (data.code == "200") {
  342. Feng.success(data.msg);
  343. $("#fileLi").removeAttr("style");
  344. $("#id").val(data.obj.id);
  345. $("#checkState").val(data.obj.checkState);
  346. window.parent.EnterpriseCenter.table.refresh();
  347. } else {
  348. Feng.info(data.msg);
  349. }
  350. // $(".layui-layer-btn0",parent.document).css("pointer-events","block");
  351. locked = false;
  352. }, function (data) {
  353. Feng.error("添加失败!" + data.responseJSON.msg + "!");
  354. locked = false;
  355. });
  356. ajax.set(this.epChangeEditData);
  357. ajax.start();
  358. };
  359. /**
  360. * 提交审核
  361. */
  362. EpChangeEdit.submitToCheck = function () {
  363. var id = $("#id").val();
  364. if (id == null || id == "") {
  365. Feng.info("请先填写基础信息并上传附件");
  366. return;
  367. }
  368. var checkState = $("#checkState").val();
  369. if (checkState == 2 || checkState == 5) {
  370. Feng.error("正在审核中,无法修改");
  371. return;
  372. }
  373. if (checkState == 4) {
  374. Feng.error("审核通过,无法修改");
  375. return;
  376. }
  377. $(".layui-layer-btn1", parent.document).css("pointer-events", "none");
  378. var operation = function () {
  379. var ajax = new $ax(Feng.ctxPath + "/enterprise/api/submitToCheck", function (data) {
  380. if (data.code == 200) {
  381. Feng.success(data.msg);
  382. window.parent.EnterpriseCenter.table.refresh();
  383. EpChangeEdit.close();
  384. } else {
  385. Feng.error(data.msg);
  386. }
  387. $(".layui-layer-btn1", parent.document).css("pointer-events", "block");
  388. }, function (data) {
  389. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  390. $(".layui-layer-btn1", parent.document).css("pointer-events", "block");
  391. });
  392. ajax.set("id", id);
  393. ajax.start();
  394. }
  395. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  396. }
  397. EpChangeEdit.callBack = function (data) {
  398. layer.close(data.obj);
  399. Feng.info(data.msg);
  400. if (data.code == 200) {
  401. $("#fileTable").bootstrapTable("refresh", {});
  402. }
  403. };
  404. EpChangeEdit.downloadFile = function (id) {
  405. window.location.href = Feng.ctxPath + '/enterprisechangeRecord/downloadFile?id=' + id;
  406. };
  407. EpChangeEdit.industryChange = function () {
  408. var industryNew = $("#newIndustryFieldNew").val();
  409. var arr = [{"name": "newIndustryFieldOld", "code": industryNew + "_field"}];
  410. Feng.findChildDictBatch(JSON.stringify(arr));
  411. }
  412. $(function () {
  413. Feng.initValidator("ecr_form", EpChangeEdit.validateFields);
  414. var industryNew = $("#newIndustryFieldNew").attr("value");
  415. var arr = [
  416. {"name": "newStreet", "code": "street"},
  417. {"name": "newEnterpriseTag", "code": "enterprise_tag"},
  418. {"name": "newEnterpriseType", "code": "enterprise_type"},
  419. {"name": "newIndustryFieldNew", "code": "industry_field"},
  420. {"name": "newIndustryFieldOld", "code": industryNew + "_field"}];
  421. Feng.findChildDictBatch(JSON.stringify(arr));
  422. $("select").each(function () {
  423. $(this).val($(this).attr("value"));
  424. })
  425. if ($("#type").val() == 1) {
  426. $("#newEnterpriseTag,#newIndustryFieldNew,#newIndustryFieldOld,#newEnterpriseType").parent().parent().attr("style", "display:block");
  427. $("#newEnterpriseTag").val($("#newEnterpriseTag").attr("value"));
  428. $("#newIndustryFieldNew").val($("#newIndustryFieldNew").attr("value"));
  429. $("#newIndustryFieldOld").val($("#newIndustryFieldOld").attr("value"));
  430. } else {
  431. $("#newEnterpriseTag,#newIndustryFieldNew,#newIndustryFieldOld,#newEnterpriseType").parent().parent().attr("style", "display:none");
  432. $("#newEnterpriseTag").val("");
  433. $("#newIndustryFieldNew").val("");
  434. }
  435. var id = $("#id").val();
  436. if (id != null && id != '') {
  437. $("#fileLi").removeAttr("style");
  438. } else {
  439. $("#fileLi").attr("style", "pointer-events: none");
  440. }
  441. var checkState = $("#checkState").length > 0 ? $("#checkState").val() : 1;
  442. if (checkState != 1) {
  443. $("#baseForm :input").prop("disabled", true);
  444. var fields = $("#fields").val().split(",");
  445. for (var i in fields) {
  446. $("#" + fields[i]).removeAttr("disabled");
  447. }
  448. }
  449. });