sunmingan пре 4 година
родитељ
комит
c124b5483a
1 измењених фајлова са 120 додато и 42 уклоњено
  1. 120 42
      UI/src/pages/sellmanage/appManagement.js

+ 120 - 42
UI/src/pages/sellmanage/appManagement.js

@@ -25,14 +25,68 @@ class AddminiFans extends Component {
       formOption: [],
       formOption2: [],
       formOption3: [],
+      formOption4: [],
       formWidth: 520,
       formConfirmLoading: false,
       formOption: { modal: "", title: "" },
       formOption2: { modal: "", title: "" },
       formOption3: { modal: "", title: "" },
-      downData : [{label:'',value:''}]
+      formOption4: { modal: "", title: "" },
+      addfromVisiable: false,
+      downData : [{label:'',value:''}],
+      applicationId : '',
     };
   }
+  // 点击新增端口
+  addpush =() =>{
+    this.setState({
+      addfromVisiable: true,
+    });
+  }
+  /* 点击新增端口按钮取消事件 */
+  addlistCancelClick = () => {
+    this.setState({
+      addfromVisiable: false,
+    });
+  };
+  /* 点击新增端口按钮确认事件 */
+  addlistClick = () => {
+    let self = this;
+    let form = this.refs.autoForm4;
+    if (!form.validate()) return;
+
+    let dto = form.state.initValue;
+    
+
+    let extraParams = form.state.extraParams;
+    for (let extra of extraParams) {
+      dto[extra.field] = extra.value;
+    }
+    
+    let daval = {portId: dto['portId'],applicationId : self.state.applicationId};
+    request({
+      url: WXMpAPI + "/wx/application/pushSave",
+      method: "post",
+      data: daval
+    }).then(function(result) {
+      if (result.success === 1) {
+        message.success("操作成功!");
+        // 操作成功之后
+        // if (callback) callback(result);
+        self.setState({
+          addfromVisiable: false,
+        });
+        self.refs.releaseChannel.reload();
+        
+      } else {
+        if (result.message) {
+          message.error(result.message);
+        } else {
+          message.error(result.msg);
+        }
+      }
+    });
+  };
 
   //点击查看事件
   seeLinks = () => {
@@ -87,7 +141,7 @@ class AddminiFans extends Component {
     request({
       url: WXMpAPI + "/wx/application/save",
       method: "post",
-      data: dto
+      data: daval
     }).then(function(result) {
       if (result.success === 1) {
         message.success("操作成功!");
@@ -204,8 +258,7 @@ class AddminiFans extends Component {
                   ];
       
                   let formOption = { model: "add", title: "添加应用", fields: fields, value: data,  extraParams: [], sourceData:data };
-      
-                  self.setState({ formVisiable: true, formOption: formOption });
+                  self.setState({ formVisiable: true, formOption: formOption ,applicationId: data.id});
                 }
               }
             ]
@@ -291,7 +344,7 @@ class AddminiFans extends Component {
       sortDirection: "asc",
       url: {
         read: WXMpAPI + "/wx/application/getPushAll",
-        add: WXMpAPI + "/wx/application/pushSave",
+        //add: WXMpAPI + "/wx/application/pushSave",
         edit: WXMpAPI + "/ums/resource/update"
         // delete: "/test/delete"
       },
@@ -300,45 +353,10 @@ class AddminiFans extends Component {
       },
       columns: [
         { title: "序号", data: "id", type: "number" },
-        { title: "应用id", data: "applicationId", type: "text",value:'1' ,hide :true, query: false,editor :{isRequired: true }},
+        { title: "应用id", data: "applicationId", type: "text",value:'123121' ,hide :true, query: false,editor :{isRequired: true }},
         { title: "发布端口", data: "portName", type: "text", query: false 
         // editor: { isRequired: true }
         },
-        /** 发布渠道新增 begin */
-        { title: "端口类型", data: "name66", type: "dropdown", query: false , hide: true, editor: { isRequired: true ,onChange:(name,val) =>{
-            console.log(name + "$" + val)
-            request({
-              url: WXMpAPI + "/wx/port/getAllName",
-              method: "get",
-              data:{'type': val}
-            }).then(function(result) {
-              let tempList = self.state.downData;
-
-              tempList.splice(1,tempList.length);
-              for(var i in result){
-                tempList.push(result[i]);
-              }
-
-              self.setState((prevState) =>{
-                delete prevState.downData;
-  	 	          return prevState;
-              });
-              console.log(tempList)
-              self.setState({downData: tempList})
-              // self.forceUpdate();
-              console.log(self.state.downData)
-            });
-          }},source:{multi:false,data:[
-          {label:'企业微信',value:'1'},
-          {label:'公众号',value:'0'},
-          {label:'小程序',value:'2'},
-        ]}
-        },
-        { title: "发布端口", data: "portId", type: "dropdown", query: false, source: { 
-          multi:false,data : self.state.downData
-        }, editor: { isRequired: true }, hide: true },
-        /** 发布渠道新增 end */
-
        /** { title: "模板消息ID", data: "names", type: "text", query: false, editor: { isRequired: true ,ap: 'hide'}, hide: true },*/
         { title: "链接",  data: "url", render: (text, row, index) => (
             <div key={index}>
@@ -353,6 +371,55 @@ class AddminiFans extends Component {
           type: "command"
         }
       ]
+      ,
+      actions: [
+        {
+          name: "新增发布渠道",
+          onClick: data => {
+              this.addpush(data)
+              const fields = [
+                  /** 发布渠道新增 begin */
+                  { title: "端口类型",data: "applicationId", type: "dropdown", query: false , hide: true, editor: { isRequired: true ,onChange:(name,val) =>{
+                      console.log(name + "$" + val)
+                      request({
+                        url: WXMpAPI + "/wx/port/getAllName",
+                        method: "get",
+                        data:{'type': val}
+                      }).then(function(result) {
+                        let tempList = self.state.downData;
+
+                        tempList.splice(1,tempList.length);
+                        for(var i in result){
+                          tempList.push(result[i]);
+                        }
+
+                        self.setState((prevState) =>{
+                          delete prevState.downData;
+                          return prevState;
+                        });
+                        console.log(tempList)
+                        self.setState({downData: tempList})
+                        // self.forceUpdate();
+                        console.log(self.state.downData)
+                      });
+                    }},source:{multi:false,data:[
+                    {label:'企业微信',value:'1'},
+                    {label:'公众号',value:'0'},
+                    {label:'小程序',value:'2'},
+                  ]}
+                  },
+                  { title: "发布端口", data: "portId", type: "dropdown", query: false, source: { 
+                    multi:false,data : self.state.downData
+                  }, editor: { isRequired: true }, hide: true },
+              ];
+  
+              let formOption4 = { model: "add", title: "添加应用", fields: fields, value: data,  extraParams: [], sourceData:data };
+  
+              self.setState({ addformVisiable: true, formOption4: formOption4 });
+            
+          }
+        }
+      ]
     };
 
     return (
@@ -382,7 +449,8 @@ class AddminiFans extends Component {
               <BirdGrid
                 gridOption={releaseChannel}
                 ref="releaseChannel"
-              ></BirdGrid>
+              >
+              </BirdGrid>
             </TabPane>
           </Tabs>
         </Modal>
@@ -413,6 +481,16 @@ class AddminiFans extends Component {
             </Button>
           </div>
         </Modal>
+         {/* 点击发布渠道新增弹窗 */}
+         <Modal
+          title="新增端口"
+          width={this.state.formWidth}
+          visible={this.state.addfromVisiable}
+          onOk={() => this.addlistClick()}
+          onCancel={() => this.addlistCancelClick()}
+        >
+          <AutoForm formOption={this.state.formOption4} ref="autoForm4" />
+        </Modal>
       </div>
     );
   }