companyList.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. <!-- 企业管理 -->
  2. <div id="companyList" class="plg-tab-container">
  3. <div class="layui-carousel" id="comp_div2" style="height:auto !important;">
  4. <div carousel-item>
  5. <div id="comp_div">
  6. <button class="layui-btn layui-btn-sm layui-col-md-offset11" id="comp_install"><i class="layui-icon">&#xe605;</i> 新增</button>
  7. <div id="comp_div5"></div>
  8. </div>
  9. <div id="comp_div1" class="grid-container-full">
  10. <div class="tc-title">
  11. <a href="#" id="comp_return" class="back-link"><i class="layui-icon layui-icon-return"></i></a>
  12. <span id="comp_title">修改</span>
  13. </div>
  14. <div id="comp_div4" class="grid-container-full"></div>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. <style>
  20. #comp_install {
  21. background-color: #1E90FF;
  22. }
  23. </style>
  24. <script type="text/javascript">
  25. /**
  26. * guoj
  27. * 2018.11.05
  28. * 企业管理
  29. */
  30. (function() {
  31. var province;
  32. var ddfrom;
  33. //新增还是修改
  34. var message;
  35. //查询省
  36. // utilSyncAjaxGJ("/api/service-maindata/zone/getZoneByFatherid/v1.0", "post", JSON.stringify({ "fatherid": "01" }), function(data) {
  37. // province = data.data;
  38. // for (x in province) {
  39. // province[x].text = province[x].keyvalue;
  40. // province[x].value = province[x].zoneid;
  41. // }
  42. // }, "application/json");
  43. //查询数据
  44. //公共div对象
  45. var div_data;
  46. var comp_data;
  47. //查询按钮
  48. var com_button;
  49. //新增按钮
  50. var com_addButton = [{ text: '新增', fn: 'install' }];
  51. //查询
  52. queryGj();
  53. function queryGj() {
  54. $("#comp_div5").empty();
  55. //查询数据
  56. utilSyncAjaxGJ("/api/service-users/enterprise/getEnterprise/v1.0", "post", { objectcode: 'wmsRegion' }, function(data) {
  57. comp_data = data.data;
  58. for (var i = 0; i < comp_data.length; i++) {
  59. comp_data[i].title = comp_data[i].text;
  60. for (var y = 0; y < comp_data[i].data.length; y++) {
  61. comp_data[i].data[y].cardNo = comp_data[i].data[y].p_enterprisecode;
  62. comp_data[i].data[y].cardName = comp_data[i].data[y].p_name;
  63. if (comp_data[i].data[y].p_status == "10") {
  64. com_button = [{ text: '详情', fn: 'detailsFn' }, { text: '取消启用', fn: 'updata_start' }];
  65. } else {
  66. com_button = [{ text: '详情', fn: 'detailsFn' }, { text: '启用', fn: 'updata1_start' }];
  67. }
  68. comp_data[i].data[y].btn = com_button;
  69. }
  70. comp_data[i].data.push({ "cardNo": "新增", "cardName": "点击按钮新增数据", "btn": com_addButton, });
  71. comp_data[i].dataList = comp_data[i].data;
  72. }
  73. });
  74. var config2 = {
  75. renderer: 'comp_div5',
  76. config: {
  77. style: 'oneTitle', // one. two, three, add
  78. data: comp_data
  79. }
  80. };
  81. div_data = null;
  82. div_data = new PlgCard(config2);
  83. //添加事件
  84. div_data.on("click", function(ind, callBackFn, text) {
  85. if (callBackFn === "detailsFn") {
  86. detailsFn(ind, text);
  87. }
  88. if (callBackFn === "updata_start") {
  89. updata_start(ind, "20", text);
  90. }
  91. if (callBackFn === "install") {
  92. addFn(text);
  93. }
  94. if (callBackFn === "updata1_start") {
  95. updata_start(ind, "10", text);
  96. }
  97. });
  98. //详情
  99. function detailsFn(ind, text) {
  100. var data = get_data(text, 2, ind);
  101. ddfrom.clear();
  102. message = 1;
  103. changePanel();
  104. ddfrom.setFormData(data);
  105. linkage(message, data);
  106. }
  107. //修改状态
  108. function updata_start(ind, status, text) {
  109. var data = get_data(text, 2, ind);
  110. var data = { "p_id": data.p_id, "p_status": status };
  111. utilAjaxGJ("/api/service-users/enterprise/updatePlgFxEnterpriseById/v1.0", "put", JSON.stringify(data), function(data) {
  112. queryGj();
  113. layer.msg(data.message);
  114. }, "application/json");
  115. }
  116. //新增
  117. function addFn(text) {
  118. var data = get_data(text, 1);
  119. ddfrom.clear();
  120. message = 0;
  121. changePanel();
  122. ddfrom.setFormData({ "p_region": data.value });
  123. linkage(message, { "p_region": data.value });
  124. }
  125. }
  126. //新增
  127. document.querySelector("#comp_install").onclick = function() {
  128. changePanel();
  129. ddfrom.clear();
  130. message = 0;
  131. };
  132. //根据id获取数据
  133. function get_data(text, type, ind) {
  134. var dataZs;
  135. for (var i = 0; i < comp_data.length; i++) {
  136. if (comp_data[i].title == text) {
  137. if (type == 1) {
  138. return comp_data[i];
  139. }
  140. dataZs = comp_data[i].dataList;
  141. }
  142. }
  143. for (var i = 0; i < dataZs.length; i++) {
  144. if (dataZs[i].p_enterprisecode == ind) {
  145. return dataZs[i];
  146. }
  147. }
  148. }
  149. //三级联动
  150. function linkage(type, data) {
  151. var f = ddfrom;
  152. f.attachComboEvent("p_province", "onChange", function(id) {
  153. f.getCombo("p_city").setComboText("");
  154. f.loadComboData("p_city", { url: "/api/service-maindata/zone/getZoneByFatherid/v1.0", type: 'post', contentType: "application/json", data: JSON.stringify({ "fatherid": id }), valueField: "zoneid", textField: "keyvalue" });
  155. });
  156. f.attachComboEvent("p_city", "onChange", function(id) {
  157. f.getCombo("p_area").setComboText("");
  158. f.loadComboData("p_area", { url: "/api/service-maindata/zone/getZoneByFatherid/v1.0", type: 'post', contentType: "application/json", data: JSON.stringify({ "fatherid": id }), valueField: "zoneid", textField: "keyvalue" });
  159. });
  160. if (type == 1) {
  161. f.loadComboData("p_city", { url: "/api/service-maindata/zone/getZoneByFatherid/v1.0", type: 'post', contentType: "application/json", data: JSON.stringify({ "fatherid": data.p_province }), valueField: "zoneid", textField: "keyvalue" });
  162. f.getCombo("p_city").setComboText(data.p_cityname == "" ? data.p_city : data.p_cityname);
  163. f.loadComboData("p_area", { url: "/api/service-maindata/zone/getZoneByFatherid/v1.0", type: 'post', contentType: "application/json", data: JSON.stringify({ "fatherid": data.p_city }), valueField: "zoneid", textField: "keyvalue" });
  164. f.getCombo("p_area").setComboText(data.p_areaname == "" ? data.p_area : data.p_areaname);
  165. }
  166. }
  167. //跳转页面
  168. var carousel = layui.carousel;
  169. var car = carousel.render({
  170. elem: '#comp_div2',
  171. autoplay: false,
  172. index: 0,
  173. arrow: 'none',
  174. indicator: 'none',
  175. anim: "fade",
  176. width: '100%', //设置容器宽度
  177. height: '100%'
  178. });
  179. //跳转方法
  180. var tt = "comp_div";
  181. function changePanel() {
  182. car.slide(tt);
  183. tt = tt == "comp_div1" ? "comp_div" : "comp_div1";
  184. }
  185. ddfrom = $("#comp_div4").initPlgForm({
  186. items: [
  187. { type: "settings", position: "label-left", width: 300, labelWidth: 80 },
  188. { type: "newcolumn", offset: 30 },
  189. { type: "input", name: "p_enterprisecode", label: "企业编号:", tooltip: 'll', width: 230, editable: false, validate: "NotEmpty", required: true },
  190. { type: "input", name: "p_name", label: "企业名称:", tooltip: 'll', width: 230, editable: false, validate: "NotEmpty", required: true },
  191. {
  192. type: "combo", name: "p_province", label: "省:", tooltip: 'll', width: 230, options: []
  193. },
  194. {
  195. type: "combo", name: "p_city", label: "市:", tooltip: 'll', width: 230
  196. },
  197. {
  198. type: "combo", name: "p_area", label: "区:", tooltip: 'll', width: 230
  199. },
  200. { type: "newcolumn", offset: 30 },
  201. { type: "input", name: "p_address", label: "地址:", tooltip: 'll', width: 230 },
  202. { type: "input", name: "p_postcode", label: "邮编:", tooltip: 'll', width: 230 },
  203. { type: "input", name: "p_faxno", label: "传真:", tooltip: 'll', width: 230 },
  204. { type: "input", name: "p_contactman", label: "联系人:", tooltip: 'll', width: 230 },
  205. { type: "button", name: "company_save", width: 50, value: "保存" },
  206. { type: "newcolumn", offset: 30 },
  207. { type: "input", name: "p_tel", label: "电话:", tooltip: 'll', width: 230 },
  208. {
  209. type: "combo", name: "p_status", label: "状态:", tooltip: 'll', width: 230, options: [
  210. { text: "启用", value: "10" },
  211. { text: "空闲", value: "20" }]
  212. },
  213. {
  214. type: "combo", name: "p_region", label: "地区:", tooltip: 'll', width: 230, options: [
  215. { text: "东北地区", value: "DB" },
  216. { text: "华北地区", value: "HB" },
  217. { text: "华中地区", value: "HZ" },
  218. { text: "华东地区", value: "HD" },
  219. { text: "华南地区", value: "HN" },
  220. { text: "西北地区", value: "XB" },
  221. { text: "西南地区", value: "XN" }]
  222. },
  223. { type: "input", name: "p_createtime", label: "创建时间:", tooltip: 'll', width: 230 }]
  224. });
  225. //返回
  226. document.querySelector("#comp_return").onclick = function() {
  227. changePanel();
  228. }
  229. //保存
  230. ddfrom.attachEvent("onButtonClick", function(name) {
  231. if (name == "company_save") {
  232. //数据data
  233. var feik = ddfrom.validate();
  234. if (!feik) {
  235. return;
  236. }
  237. var data = ddfrom.getFormData();
  238. //请求地址和类型
  239. var url = "/api/service-users/enterprise/updateEnterprise/v1.0";
  240. var type = "put";
  241. var contentType = "application/json";
  242. //message新增为0,修改为1
  243. if (message == 0) {
  244. contentType = "application/x-www-form-urlencoded";
  245. url = "/api/service-users/enterprise/insertEnterprise/v1.0";
  246. type = "post";
  247. } else {
  248. delete data["p_createtime"];
  249. delete data["p_lastmodifytime"];
  250. data = JSON.stringify(data);
  251. }
  252. utilAjaxGJ(url, type, data, function(data) {
  253. queryGj();
  254. layer.msg(data.message);
  255. changePanel();
  256. }, contentType);
  257. //调用ajax方法
  258. }
  259. });
  260. })();
  261. </script>