enterprise_change_edit.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  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 files = $("#files").val().split(",");
  172. 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>';
  173. for (var key in data) {
  174. var sn = data[key].url.lastIndexOf(".");
  175. var suffix = data[key].ext;//data[key].url.substring(sn+1,data[key].url.length);
  176. var imgStr = "";
  177. if (suffix == "pdf" || suffix == "PDF") {
  178. 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>";
  179. } else if (suffix == "xlsx" || suffix == "XLSX" || suffix == 'xls' || suffix == 'XLS' || suffix == 'docx' || suffix == 'doc' || suffix == 'DOCX' || suffix == 'DOC') {
  180. 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>";
  181. } else {
  182. imgStr = '<img class=\"imgUrl\" src=\"' + data[key].url + '\" style=\"width:25px;height:25px;\">';
  183. }
  184. 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>" +
  185. "<button type='button' onclick=\"EpChangeEdit.deleteFile('" + data[key].id + "')\" class=\"btn btn-xs btn-danger\"><i class=\"fa fa-times\"></i>删除</button>";
  186. html = html + '<li style="display: none">' + data[key].id + '</li>\n' +
  187. '<li style="width: 80%;padding-top: 5px;">' + data[key].orignName + '</li>\n' +
  188. '<li style="width: 10%;">' + imgStr + '</li>\n' +
  189. '<li style="width: 10%;padding-top: 2px;">' + (files.indexOf(data[key].typeId.toString()) > -1 ? btn : "") + '</li>';
  190. }
  191. html = html + '</ul>';
  192. $detail.html(html);
  193. $(".imgs").viewer({
  194. // toolbar:false,
  195. fullscreen: false
  196. });
  197. }, function (data) {
  198. Feng.error("查询失败!" + data.responseJSON.message + "!");
  199. });
  200. var queryData = {};
  201. queryData["mainId"] = $("#id").val();
  202. queryData["typeId"] = row.id;
  203. ajax.set(queryData);
  204. ajax.start();
  205. }
  206. });
  207. }
  208. EpChangeEdit.initFileTypeColumn = function () {
  209. return [
  210. {field: 'selectItem', checkbox: false, visible: false},
  211. {title: '名称', field: 'name', visible: true, align: 'center', valign: 'middle', width: "30%", 'class': 'uitd_showTip',
  212. formatter: function (value, row, index) {
  213. if (row.must == 1) {
  214. return '<i class="fa fa-paste"></i><span style="font-weight:bold;color:red;font-size:14px;font-family:宋体"> * </span> ' + value;
  215. }
  216. if (row.must == 2) {
  217. return '<i class="fa fa-paste"></i>' + value;
  218. }
  219. }
  220. },
  221. {title: '备注', field: 'description', visible: true, align: 'center', valign: 'middle', width: "50%", 'class': 'uitd_showTip',
  222. formatter: function (value, row, index) {
  223. return '<span style="color: red">' + value + '</span>';
  224. }
  225. },
  226. {title: '模板', field: 'templateUrl', visible: true, align: 'center', valign: 'middle', width: "10%",
  227. formatter: function (value, row, index) {
  228. if (value == null || value == '' || value == 'null') {
  229. return '无';
  230. }
  231. return "<button type='button' onclick=\"Feng.downloadFile('" + row.id + "',3)\" style='margin-right: 10px' class=\"btn btn-xs btn-primary\">" +
  232. "<i class=\"fa fa-download\"></i>下载" +
  233. "</button>";
  234. }
  235. },
  236. {title: '操作', field: 'id', visible: true, align: 'center', valign: 'middle', width: "10%",
  237. formatter: function (value, row, index) {
  238. var files = $("#files").val().split(",");
  239. if (files.indexOf(value.toString()) != -1) {
  240. return "<button type='button' onclick=\"EpChangeEdit.checkFile('" + value + "','" + null + "')\" style='margin-right: 10px' class=\"btn btn-xs btn-info\">" +
  241. "<i class=\"fa fa-upload\"></i>上传" +
  242. "</button>";
  243. } else {
  244. return "";
  245. }
  246. }
  247. }
  248. ]
  249. }
  250. //选择附件并显示附件名
  251. EpChangeEdit.checkFile = function (fileTypeId, fileId) {
  252. var checkState = $("#checkState").val();
  253. if (checkState == 2) {
  254. Feng.error("正在审核中,无法修改");
  255. return;
  256. }
  257. if (checkState == 4) {
  258. Feng.error("审核通过,无法修改");
  259. return;
  260. }
  261. $("#upload_file").unbind("change");
  262. $("#upload_file").change(function () {
  263. if (!Feng.chkFileInvalid(this.files[0], 5, 10))
  264. return;
  265. EpChangeEdit.upload(fileTypeId, fileId);
  266. });
  267. $('#upload_file').val("");
  268. $('#upload_file').click()
  269. }
  270. //上传附件
  271. EpChangeEdit.upload = function (fileTypeId, fileId) {
  272. if (fileId != null && fileId != 'null') {
  273. $("#fileId").val(fileId)
  274. } else {
  275. $("#fileId").val("");
  276. }
  277. $("#mainId").val($("#id").val());
  278. $("#typeId").val(fileTypeId);
  279. var index = layer.load(0, {shade: false, time: 0});
  280. $("#index").val(index);
  281. $("#uploadForm").submit();
  282. }
  283. //删除附件
  284. EpChangeEdit.deleteFile = function (id) {
  285. var checkState = $("#checkState").val();
  286. if (checkState == 2) {
  287. Feng.error("正在审核中,无法修改");
  288. return;
  289. }
  290. if (checkState == 4) {
  291. Feng.error("审核通过,无法删除");
  292. return;
  293. }
  294. var operation = function () {
  295. var ajax = new $ax("/common/api/deleteTalentCommonFile", function (data) {
  296. if (data.code = 200) {
  297. Feng.success(data.msg);
  298. $("#fileTable").bootstrapTable("refresh", {});
  299. } else {
  300. Feng.error(data.msg);
  301. }
  302. }, function (data) {
  303. Feng.error("删除失败!" + data.responseJSON.message + "!");
  304. });
  305. ajax.set("id", id);
  306. ajax.start();
  307. }
  308. Feng.confirm("删除后无法恢复,确认删除吗?", operation);
  309. }
  310. EpChangeEdit.addSubmit = function () {
  311. this.clearData();
  312. this.collectData();
  313. if (!this.validate()) {
  314. return;
  315. }
  316. var checkState = $("#checkState").val();
  317. if (checkState == 2 || checkState == 5) {
  318. Feng.info("正在审核中,无法修改")
  319. return;
  320. }
  321. if (checkState == 4) {
  322. Feng.info("已审核通过,无法修改")
  323. return;
  324. }
  325. // $(".layui-layer-btn0",parent.document).css("pointer-events","none");
  326. if (locked)
  327. return;
  328. locked = true;
  329. var ajax = new $ax(Feng.ctxPath + "/enterprise/api/upsert", function (data) {
  330. if (data.code == "200") {
  331. Feng.success(data.msg);
  332. $("#fileLi").removeAttr("style");
  333. $("#id").val(data.obj.id);
  334. $("#checkState").val(data.obj.checkState);
  335. window.parent.EnterpriseCenter.table.refresh();
  336. } else {
  337. Feng.info(data.msg);
  338. }
  339. // $(".layui-layer-btn0",parent.document).css("pointer-events","block");
  340. locked = false;
  341. }, function (data) {
  342. Feng.error("添加失败!" + data.responseJSON.msg + "!");
  343. locked = false;
  344. });
  345. ajax.set(this.epChangeEditData);
  346. ajax.start();
  347. };
  348. /**
  349. * 提交审核
  350. */
  351. EpChangeEdit.submitToCheck = function () {
  352. var id = $("#id").val();
  353. if (id == null || id == "") {
  354. Feng.info("请先填写基础信息并上传附件");
  355. return;
  356. }
  357. var checkState = $("#checkState").val();
  358. if (checkState == 2 || checkState == 5) {
  359. Feng.error("正在审核中,无法修改");
  360. return;
  361. }
  362. if (checkState == 4) {
  363. Feng.error("审核通过,无法修改");
  364. return;
  365. }
  366. $(".layui-layer-btn1", parent.document).css("pointer-events", "none");
  367. var operation = function () {
  368. var ajax = new $ax(Feng.ctxPath + "/enterprise/api/submitToCheck", function (data) {
  369. if (data.code == 200) {
  370. Feng.success(data.msg);
  371. window.parent.EnterpriseCenter.table.refresh();
  372. EpChangeEdit.close();
  373. } else {
  374. Feng.error(data.msg);
  375. }
  376. $(".layui-layer-btn1", parent.document).css("pointer-events", "block");
  377. }, function (data) {
  378. Feng.error("提交审核失败!" + data.responseJSON.message + "!");
  379. $(".layui-layer-btn1", parent.document).css("pointer-events", "block");
  380. });
  381. ajax.set("id", id);
  382. ajax.start();
  383. }
  384. Feng.confirm("请确认基础信息已核对无误,相应附件已上传,一旦提交,无法修改", operation);
  385. }
  386. EpChangeEdit.callBack = function (data) {
  387. layer.close(data.obj);
  388. Feng.info(data.msg);
  389. if (data.code == 200) {
  390. $("#fileTable").bootstrapTable("refresh", {});
  391. }
  392. };
  393. EpChangeEdit.downloadFile = function (id) {
  394. window.location.href = Feng.ctxPath + '/enterprisechangeRecord/downloadFile?id=' + id;
  395. };
  396. EpChangeEdit.industryChange = function () {
  397. var industryNew = $("#newIndustryFieldNew").val();
  398. var arr = [{"name": "newIndustryFieldOld", "code": industryNew + "_field"}];
  399. Feng.findChildDictBatch(JSON.stringify(arr));
  400. }
  401. $(function () {
  402. Feng.initValidator("ecr_form", EpChangeEdit.validateFields);
  403. var industryNew = $("#newIndustryFieldNew").attr("value");
  404. var arr = [
  405. {"name": "newStreet", "code": "street"},
  406. {"name": "newEnterpriseTag", "code": "enterprise_tag"},
  407. {"name": "newEnterpriseType", "code": "enterprise_type"},
  408. {"name": "newIndustryFieldNew", "code": "industry_field"},
  409. {"name": "newIndustryFieldOld", "code": industryNew + "_field"}];
  410. Feng.findChildDictBatch(JSON.stringify(arr));
  411. $("select").each(function () {
  412. $(this).val($(this).attr("value"));
  413. })
  414. if ($("#type").val() == 1) {
  415. $("#newEnterpriseTag,#newIndustryFieldNew,#newIndustryFieldOld,#newEnterpriseType").parent().parent().attr("style", "display:block");
  416. $("#newEnterpriseTag").val($("#newEnterpriseTag").attr("value"));
  417. $("#newIndustryFieldNew").val($("#newIndustryFieldNew").attr("value"));
  418. $("#newIndustryFieldOld").val($("#newIndustryFieldOld").attr("value"));
  419. } else {
  420. $("#newEnterpriseTag,#newIndustryFieldNew,#newIndustryFieldOld,#newEnterpriseType").parent().parent().attr("style", "display:none");
  421. $("#newEnterpriseTag").val("");
  422. $("#newIndustryFieldNew").val("");
  423. }
  424. var id = $("#id").val();
  425. if (id != null && id != '') {
  426. $("#fileLi").removeAttr("style");
  427. } else {
  428. $("#fileLi").attr("style", "pointer-events: none");
  429. }
  430. $("#baseForm :input").prop("disabled", true);
  431. var fields = $("#fields").val().split(",");
  432. for (var i in fields) {
  433. $("#" + fields[i]).removeAttr("disabled");
  434. }
  435. });