123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- <!-- 企业管理 -->
- <div id="companyList" class="plg-tab-container">
- <div class="layui-carousel" id="comp_div2" style="height:auto !important;">
- <div carousel-item>
- <div id="comp_div">
- <button class="layui-btn layui-btn-sm layui-col-md-offset11" id="comp_install"><i class="layui-icon"></i> 新增</button>
- <div id="comp_div5"></div>
- </div>
- <div id="comp_div1" class="grid-container-full">
- <div class="tc-title">
- <a href="#" id="comp_return" class="back-link"><i class="layui-icon layui-icon-return"></i></a>
- <span id="comp_title">修改</span>
- </div>
- <div id="comp_div4" class="grid-container-full"></div>
- </div>
- </div>
- </div>
- </div>
- <style>
- #comp_install {
- background-color: #1E90FF;
- }
- </style>
- <script type="text/javascript">
- /**
- * guoj
- * 2018.11.05
- * 企业管理
- */
- (function() {
- var province;
- var ddfrom;
- //新增还是修改
- var message;
- //查询省
- // utilSyncAjaxGJ("/api/service-maindata/zone/getZoneByFatherid/v1.0", "post", JSON.stringify({ "fatherid": "01" }), function(data) {
-
- // province = data.data;
- // for (x in province) {
- // province[x].text = province[x].keyvalue;
- // province[x].value = province[x].zoneid;
- // }
- // }, "application/json");
- //查询数据
- //公共div对象
- var div_data;
- var comp_data;
- //查询按钮
- var com_button;
- //新增按钮
- var com_addButton = [{ text: '新增', fn: 'install' }];
- //查询
- queryGj();
- function queryGj() {
- $("#comp_div5").empty();
- //查询数据
- utilSyncAjaxGJ("/api/service-users/enterprise/getEnterprise/v1.0", "post", { objectcode: 'wmsRegion' }, function(data) {
- comp_data = data.data;
- for (var i = 0; i < comp_data.length; i++) {
- comp_data[i].title = comp_data[i].text;
- for (var y = 0; y < comp_data[i].data.length; y++) {
- comp_data[i].data[y].cardNo = comp_data[i].data[y].p_enterprisecode;
- comp_data[i].data[y].cardName = comp_data[i].data[y].p_name;
- if (comp_data[i].data[y].p_status == "10") {
- com_button = [{ text: '详情', fn: 'detailsFn' }, { text: '取消启用', fn: 'updata_start' }];
- } else {
- com_button = [{ text: '详情', fn: 'detailsFn' }, { text: '启用', fn: 'updata1_start' }];
- }
- comp_data[i].data[y].btn = com_button;
- }
- comp_data[i].data.push({ "cardNo": "新增", "cardName": "点击按钮新增数据", "btn": com_addButton, });
- comp_data[i].dataList = comp_data[i].data;
- }
- });
- var config2 = {
- renderer: 'comp_div5',
- config: {
- style: 'oneTitle', // one. two, three, add
- data: comp_data
- }
- };
- div_data = null;
- div_data = new PlgCard(config2);
- //添加事件
- div_data.on("click", function(ind, callBackFn, text) {
- if (callBackFn === "detailsFn") {
- detailsFn(ind, text);
- }
- if (callBackFn === "updata_start") {
- updata_start(ind, "20", text);
- }
- if (callBackFn === "install") {
- addFn(text);
- }
- if (callBackFn === "updata1_start") {
- updata_start(ind, "10", text);
- }
- });
- //详情
- function detailsFn(ind, text) {
- var data = get_data(text, 2, ind);
- ddfrom.clear();
- message = 1;
- changePanel();
- ddfrom.setFormData(data);
- linkage(message, data);
- }
- //修改状态
- function updata_start(ind, status, text) {
- var data = get_data(text, 2, ind);
- var data = { "p_id": data.p_id, "p_status": status };
- utilAjaxGJ("/api/service-users/enterprise/updatePlgFxEnterpriseById/v1.0", "put", JSON.stringify(data), function(data) {
- queryGj();
- layer.msg(data.message);
- }, "application/json");
- }
- //新增
- function addFn(text) {
- var data = get_data(text, 1);
- ddfrom.clear();
- message = 0;
- changePanel();
- ddfrom.setFormData({ "p_region": data.value });
- linkage(message, { "p_region": data.value });
- }
- }
-
- //新增
- document.querySelector("#comp_install").onclick = function() {
- changePanel();
- ddfrom.clear();
- message = 0;
- };
- //根据id获取数据
- function get_data(text, type, ind) {
- var dataZs;
- for (var i = 0; i < comp_data.length; i++) {
- if (comp_data[i].title == text) {
- if (type == 1) {
- return comp_data[i];
- }
- dataZs = comp_data[i].dataList;
- }
- }
- for (var i = 0; i < dataZs.length; i++) {
- if (dataZs[i].p_enterprisecode == ind) {
- return dataZs[i];
- }
- }
- }
- //三级联动
- function linkage(type, data) {
- var f = ddfrom;
- f.attachComboEvent("p_province", "onChange", function(id) {
- f.getCombo("p_city").setComboText("");
- 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" });
- });
- f.attachComboEvent("p_city", "onChange", function(id) {
- f.getCombo("p_area").setComboText("");
- 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" });
- });
- if (type == 1) {
- 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" });
- f.getCombo("p_city").setComboText(data.p_cityname == "" ? data.p_city : data.p_cityname);
- 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" });
- f.getCombo("p_area").setComboText(data.p_areaname == "" ? data.p_area : data.p_areaname);
- }
- }
- //跳转页面
- var carousel = layui.carousel;
- var car = carousel.render({
- elem: '#comp_div2',
- autoplay: false,
- index: 0,
- arrow: 'none',
- indicator: 'none',
- anim: "fade",
- width: '100%', //设置容器宽度
- height: '100%'
- });
- //跳转方法
- var tt = "comp_div";
- function changePanel() {
- car.slide(tt);
- tt = tt == "comp_div1" ? "comp_div" : "comp_div1";
- }
- ddfrom = $("#comp_div4").initPlgForm({
- items: [
- { type: "settings", position: "label-left", width: 300, labelWidth: 80 },
- { type: "newcolumn", offset: 30 },
- { type: "input", name: "p_enterprisecode", label: "企业编号:", tooltip: 'll', width: 230, editable: false, validate: "NotEmpty", required: true },
- { type: "input", name: "p_name", label: "企业名称:", tooltip: 'll', width: 230, editable: false, validate: "NotEmpty", required: true },
- {
- type: "combo", name: "p_province", label: "省:", tooltip: 'll', width: 230, options: []
- },
- {
- type: "combo", name: "p_city", label: "市:", tooltip: 'll', width: 230
- },
- {
- type: "combo", name: "p_area", label: "区:", tooltip: 'll', width: 230
- },
- { type: "newcolumn", offset: 30 },
- { type: "input", name: "p_address", label: "地址:", tooltip: 'll', width: 230 },
- { type: "input", name: "p_postcode", label: "邮编:", tooltip: 'll', width: 230 },
- { type: "input", name: "p_faxno", label: "传真:", tooltip: 'll', width: 230 },
- { type: "input", name: "p_contactman", label: "联系人:", tooltip: 'll', width: 230 },
- { type: "button", name: "company_save", width: 50, value: "保存" },
- { type: "newcolumn", offset: 30 },
- { type: "input", name: "p_tel", label: "电话:", tooltip: 'll', width: 230 },
- {
- type: "combo", name: "p_status", label: "状态:", tooltip: 'll', width: 230, options: [
- { text: "启用", value: "10" },
- { text: "空闲", value: "20" }]
- },
- {
- type: "combo", name: "p_region", label: "地区:", tooltip: 'll', width: 230, options: [
- { text: "东北地区", value: "DB" },
- { text: "华北地区", value: "HB" },
- { text: "华中地区", value: "HZ" },
- { text: "华东地区", value: "HD" },
- { text: "华南地区", value: "HN" },
- { text: "西北地区", value: "XB" },
- { text: "西南地区", value: "XN" }]
- },
- { type: "input", name: "p_createtime", label: "创建时间:", tooltip: 'll', width: 230 }]
- });
- //返回
- document.querySelector("#comp_return").onclick = function() {
- changePanel();
- }
- //保存
- ddfrom.attachEvent("onButtonClick", function(name) {
- if (name == "company_save") {
- //数据data
- var feik = ddfrom.validate();
- if (!feik) {
- return;
- }
- var data = ddfrom.getFormData();
- //请求地址和类型
- var url = "/api/service-users/enterprise/updateEnterprise/v1.0";
- var type = "put";
- var contentType = "application/json";
- //message新增为0,修改为1
- if (message == 0) {
- contentType = "application/x-www-form-urlencoded";
- url = "/api/service-users/enterprise/insertEnterprise/v1.0";
- type = "post";
- } else {
- delete data["p_createtime"];
- delete data["p_lastmodifytime"];
- data = JSON.stringify(data);
- }
- utilAjaxGJ(url, type, data, function(data) {
- queryGj();
- layer.msg(data.message);
- changePanel();
- }, contentType);
- //调用ajax方法
- }
- });
- })();
- </script>
|