Pārlūkot izejas kodu

装集客项目更新

lijiangwei 4 gadi atpakaļ
vecāks
revīzija
c475fe1cb0
2 mainītis faili ar 25 papildinājumiem un 24 dzēšanām
  1. 23 22
      uis/views/customer/edit.html
  2. 2 2
      uis/views/customer/index.html

+ 23 - 22
uis/views/customer/edit.html

@@ -68,18 +68,18 @@
                         </div>
 
                         <div>
-                            <label class="layui-form-label">来源:</label>
+                            <label class="layui-form-label"><font color='red' size="4">*</font>来源:</label>
                             <div class="layui-input-block">
-                                <select name="source" id="id_source">
+                                <select lay-verify="required" name="source" id="id_source">
                                     <option value="">请选择来源</option>
                                 </select>
                             </div>
                         </div>
 
                         <div>
-                            <label class="layui-form-label">项目:</label>
+                            <label class="layui-form-label"><font color='red' size="4">*</font>项目:</label>
                             <div class="layui-input-block">
-                                 <select name="project" id="tags" xm-select="tags" xm-select-skin="primary">
+                                 <select lay-verify="required" name="project" id="tags" xm-select="tags" xm-select-skin="primary">
                                      <option value="">请选择</option>
                                  </select>
                             </div>
@@ -115,21 +115,10 @@
             , formSelects = layui.formSelects
             , form = layui.form
         var id = layui.view.getParameterByName('id');
-
-        formSelects.data('tags', 'local', {
-            arr: [
-                {"name": "北京", "value": 1},
-                {"name": "上海", "value": 2},
-                {"name": "广州", "value": 3},
-                {"name": "深圳", "value": 4},
-                {"name": "天津", "value": 5}
-            ]
-        });
-
+        var editdata = {};
         if (id) {
-            var editdata = JSON.parse(JSON.stringify(parent.layui.table.editdata)); // 框架有Bug所以这么转换
+            editdata = JSON.parse(JSON.stringify(parent.layui.table.editdata)); // 框架有Bug所以这么转换
             editdata['gender'] = editdata['gender'].toString();
-            form.val("component-form-element", editdata);
         }
 
         admin.req({
@@ -142,7 +131,7 @@
                     var name = data[i].name;
                     source_node.append("<option value='" + pid + "'>" + name + "</option>");
                 }
-                form.render(); //更新form
+                form.val("component-form-element", editdata);
             }
         });
 
@@ -150,7 +139,18 @@
             url: '/customer/project/dict/',
             done: function (res) {
                 var data = res.data;
-                console.log(res, "opppppppp")
+                let tempData = [];
+                if(res.data && res.data.length > 0){
+                    tempData =  res.data.map(item=>{
+                        if(id && editdata['project']){
+                           console.log(editdata['project']);
+                        }
+                        return {value: item.id, name: item.name}
+                    });
+                }
+                formSelects.data('tags', 'local', {
+                    arr: tempData
+                });
             }
         });
 
@@ -158,13 +158,14 @@
 
         form.on('submit(component-form-element)', function (data) {
             if (id) {
-                var url = '/customer/' + id + '/';
+                var url = '/reportcustomer/' + id + '/';
                 var type = 'put';
             } else {
-                url = '/customer/';
+                url = '/reportcustomer/';
                 type = 'post'
             }
-
+            if(data.field.source) data.field.source = parseInt(data.field.source);
+            console.log(data.field, "opopopopop")
             admin.req({
                 url: url
                 , data: data.field

+ 2 - 2
uis/views/customer/index.html

@@ -124,7 +124,7 @@
 
         table.render({
             elem: '#customer_datagrid'
-            , url: '/customer/'
+            , url: '/reportcustomer/'
             , cols: [[
                 {field: 'name', title: '姓名', width: 200}
                 , {field: 'gender_text', title: "性别", width: 70}
@@ -170,7 +170,7 @@
                 layer.confirm('确定要删除吗?', function (index) {
                     layer.close(index);
                     admin.req({
-                        url: '/customer/' + data.id + '/'
+                        url: '/reportcustomer/' + data.id + '/'
                         , type: 'delete'
                         , done: function (res) {
                             table.reload('customer_datagrid', {});