From 771e0da9c6082c78a28f5286f89f4f36b05689d3 Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期二, 27 十二月 2022 14:31:45 +0800
Subject: [PATCH] 默认更改列表

---
 src/views/contractor/unitManage/index.vue |  100 ++++++++++++++++++++++++++++++--------------------
 1 files changed, 60 insertions(+), 40 deletions(-)

diff --git a/src/views/contractor/unitManage/index.vue b/src/views/contractor/unitManage/index.vue
index 28654bb..3f1390e 100644
--- a/src/views/contractor/unitManage/index.vue
+++ b/src/views/contractor/unitManage/index.vue
@@ -56,7 +56,7 @@
                 <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width">
                     <template slot-scope="scope">
                         <el-button type="text" @click="showUnitForm(scope.row,'编辑')">编辑</el-button>
-                        <el-button type="text" style="color: red" @click="deleteById(scope.row)">删除</el-button>
+<!--                        <el-button type="text" style="color: red" @click="deleteById(scope.row)">删除</el-button>-->
                         <el-button type="text" style="color: red" @click="addBlack(scope.row)">黑名单</el-button>
                     </template>
                 </el-table-column>
@@ -77,11 +77,11 @@
             <br>
         </div>
         <el-dialog :title="title" :visible.sync="unitFormVisible" :modal-append-to-body="false" :close-on-click-modal="false" width="40%">
-            <el-form ref="dataForm" :rules="unitFormRules" :model="unitForm" label-position="right" label-width="100px" style="margin-left:50px;width:500px;">
-                <el-form-item label="单位名称">
+            <el-form ref="unitForm" :rules="unitFormRules" :model="unitForm" label-position="right" label-width="100px" style="margin-left:50px;width:500px;">
+                <el-form-item label="单位名称" prop="company">
                     <el-input v-model="unitForm.company"></el-input>
                 </el-form-item>
-                <el-form-item label="单位代码">
+                <el-form-item label="单位代码" prop="code">
                     <el-input v-model="unitForm.code"></el-input>
                 </el-form-item>
                 <el-form-item label="是否为主体单位:" prop="ismain">
@@ -95,10 +95,10 @@
                         </el-option>
                     </el-select>
                 </el-form-item>
-                <el-form-item label="联系人">
+                <el-form-item label="联系人" prop="contactname">
                     <el-input v-model="unitForm.contactname"></el-input>
                 </el-form-item>
-                <el-form-item label="联系电话">
+                <el-form-item label="联系电话" prop="contactphone">
                     <el-input v-model="unitForm.contactphone"></el-input>
                 </el-form-item>
                 <el-form-item label="省">
@@ -210,7 +210,6 @@
                 company:'',
                 code:'',
                 unitFormVisible:false,
-                unitFormRules:{},
                 unitForm:{
                     id:'',
                     company:'',
@@ -223,6 +222,13 @@
                     town:'',
                     committee:'',
                     isbanned:'',
+                },
+                unitFormRules:{
+                    company: [{ required: true, message: '单位名称不能为空', trigger: 'change' }],
+                    code: [{ required: true, message: '单位代码不能为空', trigger: 'change' }],
+                    ismain: [{ required: true, message: '是否为主体单位不能为空', trigger: 'blur' }],
+                    contactname: [{ required: true, message: '联系人不能为空', trigger: 'change' }],
+                    contactphone: [{ required: true, message: '联系电话不能为空', trigger: 'blur' }],
                 },
                 provinceList:[],
                 cityList:[],
@@ -243,6 +249,7 @@
                 params['pageIndex'] = this.currentPage
                 params['pageSize'] = this.pageSize
                 params['company'] = this.company
+                params['isMain'] = false
                 let res = await getUnitList(params)
                 if(res.data.code === '200'){
                     this.recordTotal = res.data.result.totalCount
@@ -260,6 +267,9 @@
             },
             showUnitForm(value,type){
                 this.unitFormVisible = true
+                this.$nextTick(() =>{
+                    this.$refs["unitForm"].clearValidate()
+                })
                 if(type === '新增'){
                     this.title = '新增'
                     this.unitForm = {
@@ -281,43 +291,53 @@
                 }
             },
             submitUnit(){
-                if(this.title === '新增'){
-                    addUnit(this.unitForm).then((res)=>{
-                        if(res.data.code === '200'){
-                            this.unitFormVisible = false
-                            this.getUnitData()
-                            this.$notify({
-                                type:'success',
-                                duration:2000,
-                                message:'新增成功',
-                                title:'成功'
+                this.$refs["unitForm"].validate(valid =>{
+                    if(valid){
+                        if(this.title === '新增'){
+                            addUnit(this.unitForm).then((res)=>{
+                                if(res.data.code === '200'){
+                                    this.unitFormVisible = false
+                                    this.getUnitData()
+                                    this.$notify({
+                                        type:'success',
+                                        duration:2000,
+                                        message:'新增成功',
+                                        title:'成功'
+                                    })
+                                }else{
+                                    this.$message({
+                                        type:'warning',
+                                        message:res.data.message
+                                    })
+                                }
                             })
                         }else{
-                            this.$message({
-                                type:'warning',
-                                message:res.data.message
+                            updateUnit(this.unitForm).then((res)=>{
+                                if(res.data.code === '200'){
+                                    this.unitFormVisible = false
+                                    this.getUnitData()
+                                    this.$notify({
+                                        type:'success',
+                                        duration:2000,
+                                        title:'成功',
+                                        message:'编辑成功'
+                                    })
+                                }else{
+                                    this.$message({
+                                        type:'warning',
+                                        message:res.data.message
+                                    })
+                                }
                             })
                         }
-                    })
-                }else{
-                    updateUnit(this.unitForm).then((res)=>{
-                        if(res.data.code === '200'){
-                            this.unitFormVisible = false
-                            this.getUnitData()
-                            this.$notify({
-                                type:'success',
-                                duration:2000,
-                                title:'成功',
-                                message:'编辑成功'
-                            })
-                        }else{
-                            this.$message({
-                                type:'warning',
-                                message:res.data.message
-                            })
-                        }
-                    })
-                }
+                    }else{
+                        this.$message({
+                            type:'warning',
+                            message:'请完善基本信息'
+                        })
+                    }
+                })
+
             },
             deleteById(val){
                 this.$confirm('删除此条信息,是否继续','提示',{

--
Gitblit v1.9.2