chengjunhui 5 months ago
parent
commit
c2c820d2ff

+ 38 - 27
renren-admin/src/main/resources/statics/js/modules/qmgj/school.js

@@ -4,7 +4,6 @@ $(function () {
         datatype: "json",
         colModel: [
             { label: 'id', name: 'id', index: 'id', width: 50, key: true, hidden: true },
-            // { label: '序号', name: 'index', index: 'index', width: 50 },
             { label: '省', name: 'provincename', index: 'provincename' },
             { label: '市', name: 'regionname', index: 'regionname' },
             { label: '学校名称', name: 'schoolname', index: 'schoolname', width: 200 },
@@ -14,7 +13,7 @@ $(function () {
                 index: 'status',
                 width: 80,
                 formatter: function (cellvalue, options, rowObject) {
-                    return "<span style='color: #337ab7; cursor: pointer;margin-right: 10px;' onclick=\"handleEdit('" + rowObject.id + "',1)\">编辑</span><span style='color: #337ab7; cursor: pointer;' onclick=\"handleDel('" + rowObject.id + ")\">删除</span>"
+                    return "<span style='color: #337ab7; cursor: pointer;margin-right: 10px;' onclick=\"handleEdit('" + rowObject.guid + "')\">编辑</span><span style='color: #337ab7; cursor: pointer;' onclick=\"handleDel('" + rowObject.guid + "')\">删除</span>"
                 }
             },
         ],
@@ -44,7 +43,7 @@ $(function () {
         }
     });
     $.ajax({
-        type: "get",
+        type: "post",
         url: baseURL + "api/region/provinceList",
         contentType: "application/json",
         success: function (r) {
@@ -64,6 +63,7 @@ function handleEdit(id) {
 }
 
 function handleDel(id) {
+    console.log(id);
     layer.confirm('确定要删除选中的数据?', {
         btn: ['确定', '取消'] //按钮
     }, function () {
@@ -92,23 +92,23 @@ layui.use(['layer', 'form'], function () {
     var $ = layui.jquery, layer = layui.layer, form = layui.form;
     form.on('submit(go)', function (data) {
         $('#btnSaveOrUpdate').button('loading').delay(1000).queue(function () {
-            var url = vm.formData.id == null ? "qmgj/school/save" : "qmgj/school/update";
-            console.log(vm.formData);
+            var url = vm.formData.guid == null ? "qmgj/school/save" : "qmgj/school/update";
+            // console.log(vm.formData);
             // if (vm.formData)
-            if (!vm.formDataprovince) {
+            if (!vm.formData.province) {
                 layer.alert("请选择省");
                 return false;
             }
-            if (!vm.formData.region) { 
+            if (!vm.formData.region) {
                 layer.alert("请选择市");
                 return false;
             }
-            if (!vm.formData.schoolname) { 
+            if (!vm.formData.schoolname) {
                 layer.alert("请输入学校名称");
                 return false;
             }
             $.ajax({
-                type: vm.formData.id != null ? 'PUT' : "POST",
+                type: vm.formData.guid != null ? 'POST' : "POST",
                 url: baseURL + url,
                 contentType: "application/json",
                 data: JSON.stringify(vm.formData),
@@ -169,25 +169,32 @@ var vm = new Vue({
         },
         saveOrUpdate: function (event) {
         },
-        province: function (type) {
+        province: function (type, show = false) {
             // var d = event.target.value;
-            console.log(type);
+            console.log(type, show);
             let d = type == 1 ? vm.queryParam.province : vm.formData.province;
-            console.log(d)
-            if (type == 1) {
-                vm.location2.city = [];
-                vm.queryParam.city = ''; 
-            } else {
-                vm.location.city = [];
-                vm.formData.city = ''; 
+            // console.log(d)
+            if (!show) {
+                if (type == 1) {
+                    vm.location2.city = [];
+                    vm.queryParam.city = '';
+                } else {
+                    vm.location.city = [];
+                    vm.formData.city = '';
+                }
             }
             $.ajax({
-                type: "get",
-                url: baseURL + "api/region/childList?province=" + d,
+                type: "post",
+                url: baseURL + "api/region/childList",
                 contentType: "application/json",
+                data: JSON.stringify({ id: d }),
                 success: function (r) {
                     if (r.code == 0) {
-                        vm.location.city = r.decList;
+                        if (type == 1) {
+                            vm.location2.city = r.data;
+                        } else {
+                            vm.location.city = r.data;
+                        }
                     } else {
                         layer.alert("读取市失败");
                     }
@@ -197,8 +204,13 @@ var vm = new Vue({
         getInfo: function (id) {
             $.get(baseURL + "qmgj/school/info/" + id, function (r) {
                 // console.log(r);
-                vm.formData = r.data || r.news || {};
-                vm.formData.province = '';
+                if (r.code == 0) {
+                    vm.formData = r.schoolInfo || {};
+                    console.log(vm.formData);
+                    if (r.schoolInfo.province) {
+                        vm.province(2, true)
+                    }
+                }
             });
         },
         reload: function (event) {
@@ -210,15 +222,14 @@ var vm = new Vue({
             }).trigger("reloadGrid");
         },
         init: function () {
-            vm.queryParam.city = '';
-            vm.queryParam.staffId = '';
+            vm.queryParam.region = '';
             vm.queryParam.province = '';
-            vm.queryParam.title = '';
-            vm.queryParam.status = '';
+            vm.queryParam.schoolName = '';
         },
         reset: function () {
             vm.queryParam.publishStartTime = null;
             vm.queryParam.publishEndTime = null;
+
             vm.init();
             vm.reload(1);
         },

+ 3 - 4
renren-admin/src/main/resources/templates/modules/qmgj/school.html

@@ -20,7 +20,7 @@
                             <!--<option value="" disabled>湖北省</option>-->
                             <option v-for="item in location2.province" :value="item.id">{{item.name}}</option>
                         </select>
-                        <select class="form-control" v-model="queryParam.city" >
+                        <select class="form-control" v-model="queryParam.region" >
                             <option value="" disabled hidden>--市--</option>
                             <option v-for="item in location2.city" :value="item.id">{{item.name}}</option>
                         </select>
@@ -58,7 +58,7 @@
                     <div class="col-sm-3" style="width: 16.65%;">
                         <select class="form-control" v-model="formData.region">
                             <option value="" disabled hidden>--市--</option>
-                            <option v-for="item in location.city" :value="item.id">{{item.name}}</option>
+                            <option v-for="item in location.city" :value="item.id + ''">{{item.name}}</option>
                         </select>
                     </div>
                 </div>
@@ -70,8 +70,7 @@
                 </div>
                 <div class="form-group">
                     <div class="col-sm-12">
-                        <input type="button" class="btn btn-primary" id="btnSaveOrUpdate" data-loading-text="保存中..."
-                            @click="saveOrUpdate" value="确定" />
+                        <input type="button" lay-submit lay-filter="go" class="btn btn-primary" id="btnSaveOrUpdate" data-loading-text="保存中..."value="确定" />
                         &nbsp;&nbsp;<input type="button" class="btn btn-warning" @click="reload" value="返回" />
                     </div>