enterprise_change_edit1.js 16 KB

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