enterprise_change_edit.js 12 KB

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