enterprise_change_edit1.js 17 KB

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