Browse Source

10221151fyryk

liuhj 7 months ago
parent
commit
73ef97eead
1 changed files with 117 additions and 44 deletions
  1. 117 44
      src/components/Resource/TranslatorBase.vue

+ 117 - 44
src/components/Resource/TranslatorBase.vue

@@ -1,6 +1,6 @@
 <template>
     <div class="TranslatorBase-all">
-        <el-dialog width="1000px" title="翻译人员信息" :visible.sync="TranslatorBaseform">
+        <el-dialog top="8vh" width="1000px" title="翻译人员信息" :visible.sync="TranslatorBaseform">
             <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm form-style">
                 <el-form-item label="所在地区" prop="area">
                     <el-input v-model="ruleForm.area"></el-input>
@@ -50,7 +50,7 @@
                     </el-select>
                 </el-form-item>
                 <el-form-item></el-form-item>
-                <el-form-item label="简历/证书" >
+                <el-form-item style="width:100%" label="简历/证书" >
                     <el-upload
                     class="upload-demo"
                     ref="upload"
@@ -139,10 +139,21 @@
                 <el-table-column label="操作" width="180">
                     <template slot-scope="scope">
                         <el-button @click="edittib(scope.$index, scope.row)" size="mini" >编辑</el-button>
-                        <el-button size="mini" type="danger" >删除</el-button>
+                        <el-button @click="TranslatorLibraryDel(scope.row)" size="mini" type="danger" >删除</el-button>
                     </template>
                 </el-table-column>
             </el-table>
+            <div class="block">
+                <el-pagination
+                  @size-change="handleSizeChange"
+                  @current-change="handleCurrentChange"
+                  :current-page="currentPage"
+                  :page-sizes="[5, 10, 20, 50]"
+                  :page-size="currentsize"
+                  layout="total, sizes, prev, pager, next, jumper"
+                  :total="total">
+                </el-pagination>
+              </div>
         </div>
     </div>
 </template>
@@ -153,8 +164,12 @@ export default {
             token:'',
             input: '',
             tableData: [],
+            currentPage:1,
+            currentsize:10,
+            total:0,
             TranslatorBaseform: false,
             Id:0,
+            ruleForms:new FormData(),
             ruleForm: {
                 area:'',
                 name: '',
@@ -235,6 +250,8 @@ export default {
         },
         //表单初始化
         formInitialization(){
+            this.imageUrl='';
+            this.fileList=[];
             this.ruleForm= {
                 area:'',
                 name: '',
@@ -252,6 +269,39 @@ export default {
                 region: '',
             }
         },
+        //删除
+        TranslatorLibraryDel(val){
+            this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
+                confirmButtonText: '确定',
+                cancelButtonText: '取消',
+            type: 'warning'
+            }).then(() => {
+                var that = this;
+                var url = "/api/Resource/TranslatorLibraryDel/id?id="+val.id
+                this.$axios({
+                    method: 'delete',
+                    url: url,
+                    headers: {
+                        Authorization: 'Bearer '+that.token,
+                    },
+                }).then(function (res) {
+                    if (res.data.code == 200) {
+                        that.$message({
+                            message: res.data.msg,
+                            type: 'success'
+                        });
+                        that.TranslatorLibraryItem();
+                    } else {
+                        that.$message.error(res.data.msg);
+                    }
+                })
+            }).catch(() => {
+                this.$message({
+                    type: 'info',
+                    message: '已取消删除'
+                });          
+            });
+        },
         //新增
         abbtlbBtn(){
             this.Id=0;
@@ -264,7 +314,6 @@ export default {
         edittib(index,val){
             this.formInitialization();
             this.opStatus=2;
-            this.imageUrl=''
             // this.$nextTick(() => {  this.$refs['ruleForm'].clearValidate();});
             this.TranslatorBaseform=true;
             console.log(val);
@@ -287,21 +336,13 @@ export default {
                     that.ruleForm.price=res.data.data.price;
                     that.ruleForm.currency=res.data.data.currency;
                     that.ruleForm.photo=res.data.data.photo;
-                    console.log(that.ruleForm.photo);
+                    that.ruleForm.remark=res.data.data.remark;
                     that.imageUrl=res.data.data.photo;
-                    console.log(res.data.data.files);
-                    var files=JSON.parse(res.data.data.files)
-                    console.log(files);
-                    
-                    if (res.data.data.files!="") {
-                        for(let i=0;i<files.length;i++){
-                            that.fileList.push({'name':files[i]})
+                    if (res.data.data.filePaths!=[]) {
+                        for(let i=0;i<res.data.data.filePaths.length;i++){
+                            that.fileList.push({'name':res.data.data.filePaths[i].fileName,'url':res.data.data.filePaths[i].filePathName})
                         }
-                        console.log(that.ruleForm.files);
                     }
-                    
-                    // that.ruleForm.files
-                    // console.log();
                 } else {
                     that.$message.error(res.data.msg);
                 }
@@ -334,18 +375,27 @@ export default {
                 url: url,
                 data:{
                     portType:1,
-                    pageIndex: 1,
-                    pageSize: 10,
+                    pageIndex: that.currentPage,
+                    pageSize:  that.currentsize,
                     name: that.input
                 }
             }).then(function (res) {
                 if (res.data.code == 200) {
                     that.tableData=res.data.data;
+                    that.total=res.data.count;
                 } else {
                     that.$message.error(res.data.msg);
                 }
             })
         },
+        handleSizeChange(val) {
+            this.currentsize=val;
+            this.TranslatorLibraryItem();
+        },
+        handleCurrentChange(val) {
+            this.currentPage=val;
+            this.TranslatorLibraryItem();
+        },
         submitForm(formName) {
             this.$refs[formName].validate((valid) => {
                 if (valid) {
@@ -395,18 +445,44 @@ export default {
         handleChange(file, fileList) {
             console.log(fileList);
             
-            if (file.status !== 'ready') return;
             this.fileList = fileList;
-            const formData = []
-            this.fileList.forEach((file) => {
-                if(file.raw!=undefined){
-                    formData.push(file.raw);
-                }
-            })
-            this.ruleForm.files=formData
+            // if (file.status !== 'ready') return;
+            // this.ruleForms = new FormData()
+            // this.fileList.forEach((file) => {
+            //     if(file.raw!=undefined){
+            //         this.ruleForms.append('files',file.raw);
+            //     }
+            // })
+            // console.log(formData);
+            // this.ruleForm.files=formData
+            console.log(this.ruleForms);
+ 
         },
         //保存
         TranslatorLibraryOp(){
+            var ruleForms=new FormData();
+            ruleForms.append('portType',1);
+            ruleForms.append('status',this.opStatus);
+            ruleForms.append('id',this.Id);
+            ruleForms.append('area',this.ruleForm.area);
+            ruleForms.append('name',this.ruleForm.name);
+            ruleForms.append('sex',this.ruleForm.sex=='男'?1:2);
+            ruleForms.append('photo',this.ruleForm.photo);
+            ruleForms.append('tel',this.ruleForm.tel);
+            ruleForms.append('email',this.ruleForm.email);
+            ruleForms.append('wechatNo',this.ruleForm.wechatNo);
+            ruleForms.append('otherSocialAccounts',this.ruleForm.otherSocialAccounts);
+            ruleForms.append('language',this.ruleForm.language);
+            ruleForms.append('price',this.ruleForm.price);
+            ruleForms.append('currency',this.ruleForm.currency);
+            ruleForms.append('remark',this.ruleForm.remark);
+            this.fileList.forEach((file) => {
+                if (file.status == 'ready') {
+                    if(file.raw!=undefined){
+                        ruleForms.append('files',file.raw);
+                    }
+                }
+            })
             var that = this;
             var url = "api/Resource/TranslatorLibraryOp"
             this.$axios({
@@ -416,24 +492,8 @@ export default {
                     Authorization: 'Bearer '+that.token,
                     'Content-Type':'multipart/form-data'
                 },
-                data:{
-                    portType:1,
-                    status:that.opStatus,
-                    id:that.Id,
-                    area:that.ruleForm.area,
-                    name:that.ruleForm.name,
-                    sex:that.ruleForm.sex=='男'?1:2,
-                    photo:that.ruleForm.photo,
-                    tel:that.ruleForm.tel,
-                    email:that.ruleForm.email,
-                    wechatNo:that.ruleForm.wechatNo,
-                    otherSocialAccounts:that.ruleForm.otherSocialAccounts,
-                    language:that.ruleForm.language,
-                    price:that.ruleForm.price,
-                    currency:that.ruleForm.currency,
-                    files:that.ruleForm.files,
-                    remark:that.ruleForm.remark,
-                }
+                data:ruleForms
+                    
             }).then(function (res) {
                 if (res.data.code == 200) {
                     that.$message({
@@ -454,6 +514,7 @@ export default {
             console.log(file, fileList);
         },
         handlePreview(file) {
+            window.open(file.url)
             console.log(file);
         }
     },
@@ -530,6 +591,18 @@ export default {
 .form-style .el-input-number{
     width: 100%;
 }
+.form-style .el-upload-list{
+    display: flex;
+    flex-wrap: wrap;
+    align-items: center;
+}
+.form-style .el-upload-list__item{
+    width: 50%;
+}
+.TranslatorBase-table .block{
+    text-align: center;
+    margin-top: 15px;
+}
 .pj-form{
     width:66.5%;
     display: flex;