enterprise_change_edit.js 17 KB

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