2 Коміти 1d1ef577e8 ... 13ff629bc4

Автор SHA1 Опис Дата
  nanshan 13ff629bc4 search 2 роки тому
  nanshan 875249c938 search 2 роки тому

+ 23 - 6
src/api/publisher/publish.js

@@ -1,4 +1,5 @@
 import request from "@/utils/request";
+import Vue from "vue";
 
 // 新增发行人
 export function addpublish(data) {
@@ -17,7 +18,7 @@ export function publishList(params) {
   });
 }
 
-// 根据发行人编号 搜寻信息
+// 根据发行人编号 
 export function searchPublish(id) {
   return request({
     url: "/system/issuer/" + id,
@@ -29,14 +30,30 @@ export function upload(file) {
   return request({
     url: "/file/upload",
     method: "post",
-    data: file
+    data: file,
   });
 }
 
-// 删除
+// 删除消息
 export function deletePublish(id) {
   return request({
-      url: '/system/issuer/' + id,
-      method: 'delete'
-  })
+    url: "system/issuer/" + id,
+    method: "delete",
+  });
+}
+
+// 修改发行人
+export function updatapub(data) {
+  return request({
+    url: '/system/issuer/',
+    method: 'put',
+    data });
 }
+
+export function selectpublish(params){
+  console.log(params);
+  return request({
+    url: "/system/issuer/query/",
+    params
+  });
+}

+ 130 - 43
src/views/publishers/addPublisher.vue

@@ -2,41 +2,60 @@
   <div>
     <div class="addfrom">
       <div class="addcenter">
-        <el-form ref="pubform" label-width="100px" :style="{ border: '1px soild #ccc' }" :model="pubform" :rules="rules">
+        <el-form
+          ref="pubform"
+          label-width="100px"
+          :style="{ border: '1px soild #ccc' }"
+          :model="pubform"
+          :rules="rules"
+        >
           <el-form-item label="发行方名称" prop="collectionTitle">
             <el-input v-model="pubform.collectionTitle"></el-input>
           </el-form-item>
 
-          <el-form-item label="联系人" prop="issuerName">
-            <el-input v-model="pubform.issuerName"></el-input>
+          <el-form-item label="联系人" prop="aname">
+            <el-input></el-input>
           </el-form-item>
 
-          <el-form-item label="联系电话" prop="issuerPhone">
-            <el-input v-model="pubform.issuerPhone"></el-input>
+          <el-form-item label="联系电话" prop="tel">
+            <el-input></el-input>
           </el-form-item>
 
           <el-form-item label="电子邮箱" prop="email">
-            <el-input v-model="pubform.email"></el-input>
+            <el-input></el-input>
           </el-form-item>
 
-          <el-form-item label="详细地址" prop="issuerAddress">
-            <el-input v-model="pubform.issuerAddress"></el-input>
+          <el-form-item label="详细地址" prop="address">
+            <el-input></el-input>
           </el-form-item>
 
           <el-form-item label="上传头像" prop="headPortrait">
-            <el-upload class="avatar-uploader" action="http://39.105.160.25:10996" :show-file-list="false"
-              :on-success="handleAvatarSuccess" :before-upload="beforeAvatarUpload">
-              <img v-if="this.pubform.headPortrait" :src="this.pubform.headPortrait" class="avatar">
+            <el-upload
+              class="avatar-uploader"
+              action="http://39.105.160.25:10996"
+              :show-file-list="false"
+              :on-success="handleAvatarSuccess"
+              :before-upload="beforeAvatarUpload"
+            >
+              <img
+                v-if="this.pubform.headPortrait"
+                :src="this.pubform.headPortrait"
+                class="avatar"
+              />
               <i v-else class="el-icon-plus avatar-uploader-icon"></i>
             </el-upload>
           </el-form-item>
 
           <el-form-item label="备注" prop="remark">
-            <el-input type="textarea" :rows="4" v-model="pubform.remark"></el-input>
+            <el-input
+              type="textarea"
+              :rows="4"
+              v-model="pubform.remark"
+            ></el-input>
           </el-form-item>
           <el-form-item>
             <el-button type="primary" @click="submitpub">提交</el-button>
-            <el-button>重置</el-button>
+            <el-button @click="empty">重置</el-button>
           </el-form-item>
         </el-form>
       </div>
@@ -45,12 +64,19 @@
 </template>
 
 <script>
-import { addpublish, upload } from "../../api/publisher/publish";
+import {
+  addpublish,
+  upload,
+  searchPublish,
+  updatapub,
+} from "../../api/publisher/publish";
 export default {
   name: "addPublisher",
+  // props: ["issuerID"],
   data() {
     return {
-      imageUrl: '',
+      imageUrl: "",
+      fileList: [], //上传的文件列表
       pubform: {
         collectionTitle: "",
         issuerName: "",
@@ -59,7 +85,9 @@ export default {
         issuerAddress: "",
         headPortrait: "",
         remark: "",
+        issuerId: "",
       },
+
       rules: {
         pname: [
           { required: true, message: "请输入发行方名称", trigger: "blur" },
@@ -67,45 +95,106 @@ export default {
       },
     };
   },
-  watch: {},
+
+  created() {
+  
+    this.init()
+  },
+  watch: {
+    $route(to, from) {
+      //这里可以加你监听到路由改变时要触发的方法
+     
+      this.init();
+    },
+  },
+
   methods: {
+    init() {
+      let pubformdetail = this.$route.params.rows;
+      console.log(pubformdetail);
+      if (pubformdetail == undefined) {
+        this.pubform.collectionTitle = "";
+        this.pubform.issuerName = "";
+        this.pubform.email = "";
+        this.pubform.issuerPhone = "";
+        this.pubform.issuerAddress = "";
+        this.pubform.headPortrait = "";
+        this.pubform.remark = "";
+        this.pubform.issuerId = ''
+      } else {
+        this.pubform.issuerId = pubformdetail.issuerId;
+        this.searchPublisher(this.pubform.issuerId);
+      }
+    },
+    async searchPublisher(id) {
+      let { code, data } = await searchPublish(id).catch((err) => err);
+      console.log(code, data);
+      if (code === 200) {
+        this.pubform.collectionTitle = data.collectionTitle;
+        this.pubform.issuerName = data.issuerName;
+        this.pubform.email = data.email;
+        this.pubform.issuerPhone = data.issuerPhone;
+        this.pubform.issuerAddress = data.issuerAddress;
+        this.pubform.headPortrait = data.headPortrait;
+        this.pubform.remark = data.remark;
+      }
+    },
+    empty() {
+      this.pubform.collectionTitle = "";
+      this.pubform.issuerName = "";
+      this.pubform.email = "";
+      this.pubform.issuerPhone = "";
+      this.pubform.issuerAddress = "";
+      this.pubform.headPortrait = "";
+      this.pubform.remark = "";
+    },
     handleAvatarSuccess() {
       console.log("上传成功");
     },
     beforeAvatarUpload(file) {
       let formData = new FormData();
-      formData.append('file', file);
-      upload(formData).then(res => {
+      formData.append("file", file);
+      upload(formData).then((res) => {
+        console.log(res);
         this.pubform.headPortrait = res.url;
-      })
+      });
     },
 
     submitpub() {
-      this.$refs.pubform.validate((valid) => {
-        if (valid) {
-          addpublish(this.pubform).then(() => {
-            this.pubform.collectionTitle = "";
-            this.pubform.issuerName = "";
-            this.pubform.email = "";
-            this.pubform.issuerPhone = "";
-            this.pubform.issuerAddress = "";
-            this.pubform.headPortrait = "";
-            this.pubform.remark = ""
-          });
+      let valid = this.$refs.pubform.validate().catch((err) => false);
+      if (!valid) {
+        this.$notify({
+          title: "警告",
+          message: "请填写内容",
+          type: "warning",
+        });
+      }
+
+      if (this.pubform.issuerId) {
+        // console.log("获取到id了");
+        updatapub(this.pubform).then(() => {
           this.$notify({
             title: "成功",
-            message: "创建消息成功",
+            message: "修改发行人成功",
             type: "success",
           });
-          this.$router.push("./publisherList");
-        } else {
-          this.$notify({
-            title: "警告",
-            message: "请填写内容",
-            type: "warning",
-          });
-        }
-      });
+        });
+      } else {
+        addpublish(this.pubform).then(() => {
+          this.pubform.collectionTitle = "";
+          this.pubform.issuerName = "";
+          this.pubform.email = "";
+          this.pubform.issuerPhone = "";
+          this.pubform.issuerAddress = "";
+          this.pubform.headPortrait = "";
+          this.pubform.remark = "";
+        });
+        this.$notify({
+          title: "成功",
+          message: "创建消息成功",
+          type: "success",
+        })
+      }
     },
   },
 };
@@ -119,7 +208,6 @@ export default {
   margin-top: 40px;
   border-radius: 4px;
 }
-
 .addcenter {
   margin: auto;
   width: 60%;
@@ -137,7 +225,7 @@ export default {
 }
 
 .avatar-uploader .el-upload:hover {
-  border-color: #409EFF;
+  border-color: #409eff;
 }
 
 .avatar-uploader-icon {
@@ -151,7 +239,6 @@ export default {
 
 .avatar {
   width: 100%;
-  height: 100%;
   display: block;
 }
 </style>

+ 100 - 56
src/views/publishers/publisherList.vue

@@ -4,17 +4,21 @@
       <el-row :style="{ padding: '12px' }">
         <el-col :span="12">
           <i class="el-icon-search"></i>
-          <span :style="{ padding: '4px' }">筛选发行商 </span>
+          <span :style="{ padding: '4px' }">筛选搜索</span>
         </el-col>
         <el-col :span="12" :style="{ textAlign: 'right' }">
           <el-button @click="empty">重置</el-button>
-          <el-button type="primary" @click="search">查询搜索</el-button>
+          <el-button type="primary" @click="check" >查询搜索</el-button>
         </el-col>
       </el-row>
       <el-row :style="{ marginLeft: '32px' }">
         <el-form inline>
-          <el-form-item label="发行方ID: ">
-            <el-input placeholder="筛选发行方ID" clearable v-model="issuerID"></el-input>
+          <el-form-item label="联系人名称: ">
+            <el-input
+              placeholder="筛选联系人"
+              clearable
+              v-model="value1"
+            ></el-input>
           </el-form-item>
         </el-form>
       </el-row>
@@ -27,41 +31,57 @@
         </el-col>
 
         <el-col :span="12" :style="{ textAlign: 'right' }">
-          <el-button plain @click="addPublish">添加</el-button>
+          <el-button plain>添加</el-button>
         </el-col>
       </el-row>
     </div>
     <div class="pubform">
-      <el-table :data="tableData" stripe border :style="{ borderRadius: '4px' }"
-        :header-cell-style="{ 'text-align': 'center' }" :cell-style="{ 'text-align': 'center' }">
+      <el-table :data="tabletab"
+        stripe
+        border
+        :style="{ borderRadius: '4px' }"
+        :header-cell-style="{ 'text-align': 'center' }"
+        :cell-style="{'text-align':'center'}"
+      >
         <el-table-column prop="issuerId" label="ID"> </el-table-column>
         <el-table-column prop="headPortrait" label="头像">
-          <template v-slot="scope">
-            <img class="avaImg" :src="scope.row.headPortrait" width="40" height="40">
+          <template v-slot:default="slotProps">
+            <el-avatar :src="slotProps.row.headPortrait" />
           </template>
         </el-table-column>
         <el-table-column prop="collectionTitle" label="发行方名称">
         </el-table-column>
+        <el-table-column prop="issuerName" label="联系人">
+        </el-table-column>
         <el-table-column prop="opreation" label="操作">
           <template slot-scope="scope">
-            <el-button type="text">修改</el-button>
-            <el-button type="text" @click="deleteInfo(scope.row)">删除</el-button>
+            <el-button type="primary" @click="turnPage(scope.row)"
+              >修改</el-button
+            >
+            <el-button type="danger" @click="deleteP(scope.row)"
+              >删除</el-button
+            >
           </template>
         </el-table-column>
       </el-table>
       <el-row :style="{ marginTop: '16px' }">
-        <el-col :span="24" :style="{ textAlign: 'right' }">
-          <el-pagination background :page-size="10" layout="total, prev, pager, next" :total="total"
-            @current-change="handleCurrentChange">
-          </el-pagination>
-        </el-col>
-      </el-row>
+      <el-col :span="24" :style="{ textAlign: 'right' }">
+        <el-pagination
+         background
+          :page-size="10"
+          layout="total, prev, pager, next"
+          :total="100"
+        >
+        </el-pagination>
+      </el-col>
+    </el-row>
     </div>
+    
   </div>
 </template>
-
 <script>
-import { publishList, searchPublish, deletePublish } from "@/api/publisher/publish";
+import { publishList } from "@/api/publisher/publish";
+import { searchPublish, deletePublish,selectpublish } from "@/api/publisher/publish";
 export default {
   name: "publisherList",
   data() {
@@ -73,21 +93,74 @@ export default {
       },
       tableData: [], // 具体数据
       total: 1, // 数据个数
-      issuerID: '' //发行商ID
+      issuerID: "", //发行商ID
+
+      value1:''
     };
   },
-  mounted() {
+  created() {
     this.getpublishList();
   },
+  watch: {
+    $route(to, from) {
+      //这里可以加你监听到路由改变时要触发的方法
+      // console.log(to.path);
+      // console.log(from.path);
+      this.getpublishList();
+    },
+  },
   methods: {
+    
+    
+    turnPage(rows) {
+      // console.log(rows)
+      this.$router.push({
+        name: "addPublisher",
+        params: {
+          rows: rows,
+        },
+      });
+    },
+    //  删除发行商
+    deleteP(id) {
+      console.log(id.issuerId);
+      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      })
+        .then(() => {
+          deletePublish(id.issuerId).then(() => {
+            this.getpublishList();
+          });
+          this.$message({
+            type: "success",
+            message: "删除成功!",
+          });
+        })
+        .catch(() => {
+          this.$message({
+            type: "info",
+            message: "已取消删除",
+          });
+        });
+    },
     empty() {
-      this.issuerID = ''
+      this.value1 = "";
+      this.getpublishList();
     },
-    search() {
-      if (this.issuerId) {
-        searchPublish(issuerId).then((res) => {
-          console.log(res);
+    check() {
+      if (this.value1) {
+        let searchCon = {
+          issuerName: this.value1,
+        }
+        selectpublish(searchCon).then((res)=>{
+         this.tableData=res.rows;
+         this.total=res.total
         })
+       
+      } else {
+          this.$message("请先输入再搜索")
       }
     },
     addPublish() {
@@ -95,6 +168,7 @@ export default {
     },
     getpublishList() {
       publishList(this.pageInfo).then((data) => {
+        console.log(data);
         this.tableData = data.rows;
         this.total = data.total;
       });
@@ -103,30 +177,6 @@ export default {
       this.pageInfo.pageNum = newPage;
       this.getpublishList();
     },
-    deleteInfo(id) {
-      console.log(id.issuerId);
-      this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        let issuerId = id.issuerId
-        deletePublish(issuerId).then(() => {
-          this.$message({
-            type: 'success',
-            message: '删除成功!'
-          });
-          this.getpublishList();
-        }).catch(err => {
-          console.log(err);
-        })
-      }).catch(() => {
-        this.$message({
-          type: 'info',
-          message: '已取消删除'
-        });
-      });
-    }
   },
 };
 </script>
@@ -136,18 +186,12 @@ export default {
   border-radius: 4px;
   margin: 16px;
 }
-
 .addpub {
   border: 1px solid #ccc;
   border-radius: 4px;
   margin: 16px;
 }
-
 .pubform {
   padding: 0 16px;
 }
-
-.avaImg {
-  border-radius: 50%;
-}
 </style>