nanshan 2 년 전
부모
커밋
875249c938
3개의 변경된 파일231개의 추가작업 그리고 53개의 파일을 삭제
  1. 27 2
      src/api/publisher/publish.js
  2. 120 34
      src/views/publishers/addPublisher.vue
  3. 84 17
      src/views/publishers/publisherList.vue

+ 27 - 2
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,6 +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",
+  });
+}
+
+// 修改发行人
+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
+  });
+}

+ 120 - 34
src/views/publishers/addPublisher.vue

@@ -2,7 +2,13 @@
   <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>
@@ -24,19 +30,32 @@
           </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,18 @@
 </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: "",
@@ -60,6 +85,7 @@ export default {
         issuerAddress: "",
         headPortrait: "",
         remark: "",
+        issuerId: "",
       },
 
       rules: {
@@ -69,46 +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",
+        })
+      }
     },
   },
 };
@@ -140,7 +226,7 @@ export default {
 }
 
 .avatar-uploader .el-upload:hover {
-  border-color: #409EFF;
+  border-color: #409eff;
 }
 
 .avatar-uploader-icon {

+ 84 - 17
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>
@@ -41,12 +45,24 @@
         :cell-style="{ 'text-align': 'center' }"
       >
         <el-table-column prop="issuerId" label="ID"> </el-table-column>
-        <el-table-column prop="headPortraits" label="头像"> </el-table-column>
+        <el-table-column prop="headPortrait" label="头像">
+          <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="操作">
-          <el-button type="text">修改</el-button>
-          <el-button type="text">删除</el-button>
+          <template slot-scope="scope">
+            <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' }">
@@ -67,7 +83,7 @@
 
 <script>
 import { publishList } from "@/api/publisher/publish";
-import { searchPublish } from "@/api/publisher/publish";
+import { searchPublish, deletePublish,selectpublish } from "@/api/publisher/publish";
 export default {
   name: "publisherList",
   data() {
@@ -79,24 +95,75 @@ export default {
       },
       tableData: [], // 具体数据
       total: 1, // 数据个数
+      issuerID: "", //发行商ID
 
-      issuerID:'' //发行商ID
-
+      value1:''
     };
   },
   created() {
     this.getpublishList();
   },
+  watch: {
+    $route(to, from) {
+      //这里可以加你监听到路由改变时要触发的方法
+      // console.log(to.path);
+      // console.log(from.path);
+      this.getpublishList();
+    },
+  },
   methods: {
-    empty(){
-      this.issuerID=''
+    
+    
+    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.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() {
       this.$router.push("./addPublisher");