Browse Source

表单组件清除自动验证

caojunjie 4 years ago
parent
commit
2b13ded386
3 changed files with 269 additions and 112 deletions
  1. 6 0
      src/combination/formComponent.vue
  2. 138 41
      src/views/purchaseIssue/index.vue
  3. 125 71
      src/views/purchaseRequest/index.vue

+ 6 - 0
src/combination/formComponent.vue

@@ -80,6 +80,12 @@ export default {
     change(name,list,id){
       this.$emit('selectTrigger',name,list,id)
     },
+    //清除表单验证
+    clearVerification(){
+      this.$nextTick(()=>{
+        this.$refs['form'].clearValidate();
+      })
+    },
     //表单验证
     submitForm(form) {
       this.$refs["form"].validate((valid) => {

+ 138 - 41
src/views/purchaseIssue/index.vue

@@ -41,6 +41,22 @@
       </el-pagination>
     </div>
     <div v-else class="app-container">
+      <div style="display: flex;margin-bottom: 10px">
+        <el-breadcrumb>
+          <el-breadcrumb-item style="font-weight: 700">采购申请</el-breadcrumb-item>
+          <el-breadcrumb-item style="font-weight: 700">采购申请详情页</el-breadcrumb-item>
+          <el-breadcrumb-item style="margin-top: -7px;">
+            <el-button
+              style="margin-left: 10px"
+              size="mini"
+              type="danger" plain
+              @click="backToList"
+              icon="el-icon-arrow-left">
+              返回列表</el-button>
+          </el-breadcrumb-item>
+        </el-breadcrumb>
+      </div>
+      <h1 style="text-align: center;margin-top: -42px">销售出库单</h1>
       <formComponent
         v-if="searchWhether"
         :formOption="contentOption"
@@ -102,7 +118,7 @@
             <div style="width: 200px;height: 20px;font-size: 14px;">出库日期:{{formList.fBsdate}}</div>
           </div>
           <div style="display: flex;justify-content: space-between;margin-bottom: 10px">
-            <div style="width: 200px;height: 20px;font-size: 14px;">录入人:{{formList.createBy}}</div>
+            <div style="width: 200px;height: 20px;font-size: 14px;">录入明细人:{{formList.createBy}}</div>
             <div style="width: 200px;height: 20px;font-size: 14px;">公司电话:{{formList.fsbuTel}}</div>
             <div style="width: 200px;height: 20px;font-size: 14px;">编号:{{formList.fBillno}}</div>
           </div>
@@ -214,6 +230,7 @@ export default {
       contentList: [],
       inDex: 4,
       tableData: [],
+      selection:[],
       tableList: [],
       isItHidden: true,
       listStyle: [
@@ -447,7 +464,7 @@ export default {
           type: 'primary',
           size: 'mini',
           icon: 'el-icon-edit',
-          name: '新',
+          name: '新',
           disabled: false,
           hasPermi: ['anpin:stockControl:anPingApply']
         },
@@ -469,23 +486,16 @@ export default {
           type: 'success',
           size: 'mini',
           icon: 'el-icon-c-scale-to-original',
-          name: '复制新',
+          name: '复制新',
           disabled: false,
           hasPermi: ['anpin:stockControl:generateReceipts']
         }
       ],
-      contentButton: [
-        {
-          type: 'danger',
-          size: 'mini',
-          icon: 'el-icon-arrow-left',
-          name: '返回列表',
-          disabled: false
-        }, {
+      contentButton: [{
           type: 'primary',
           size: 'mini',
           icon: 'el-icon-plus',
-          name: '录入',
+          name: '录入明细',
           disabled: false
         }, {
           type: 'primary',
@@ -500,6 +510,22 @@ export default {
           icon: 'el-icon-edit',
           name: '修改',
           disabled: false
+        }, {
+          type: 'primary',
+          size: 'mini',
+          icon: 'el-icon-plus',
+          name: '新单',
+          nameTwo:'详情页',
+          plain: true,
+          disabled: false
+        },{
+          type: 'primary',
+          size: 'mini',
+          icon: 'el-icon-plus',
+          name: '复制新单',
+          nameTwo:'详情页',
+          plain: true,
+          disabled: false
         },
         {
           type: 'primary',
@@ -1079,14 +1105,14 @@ export default {
           }
           for (let li in this.contentButton) {
             if (this.$refs.avatar.form.fBillstatus < 4) {
-              if (this.contentButton[li].name == '录入' || this.contentButton[li].name == '保存'||
+              if (this.contentButton[li].name == '录入明细' || this.contentButton[li].name == '保存'||
                 this.contentButton[li].name == '请核') {
                 this.contentButton[li].disabled = true
               } else {
                 this.contentButton[li].disabled = false
               }
             } else {
-              if (this.contentButton[li].name == '录入' || this.contentButton[li].name == '保存'||
+              if (this.contentButton[li].name == '录入明细' || this.contentButton[li].name == '保存'||
                 this.contentButton[li].name == '请核' || this.contentButton[li].name == '修改') {
                 this.contentButton[li].disabled = true
               } else {
@@ -1107,6 +1133,7 @@ export default {
       this.contentOption.forEach(item => item.disabled = true)
       this.contentStyle.forEach(item => item.disabled = true)
       viewSingle(scope.row.fId).then(res => {
+        console.log(res)
         if (res.code === 200) {
           let data = {
             tableName: this.purchaseList.tableName,
@@ -1193,7 +1220,7 @@ export default {
     selectionbox(selection) {
       if (selection.length > 1){
         this.customButton.forEach(item =>{
-          if (item.name === '复制新'){
+          if (item.name === '复制新'){
             item.disabled = true
           }else {
             item.disabled = false
@@ -1260,41 +1287,90 @@ export default {
     Printing() {
       this.$print(this.$refs.print)
     },
-
-    //所以按钮
-    buttonList(row) {
+    //返回列表
+    backToList(){
       let data
-      switch (row.name) {
-        case '新增':
-          this.contentList = []
-          this.contentButton = this.$options.data().contentButton
+      if (!this.$refs.avatar.form.fId && this.contentList !== 0 || this.$refs.avatar.form.fBillstatus >= 4 && !this.$route.query.data) {
+        data = {
+          tableName: this.queryList.tableName,
+          userId: Cookies.get('userName')
+        }
+        this.getRow(data)
+        this.query(this.formDataList)
+      } else if (this.$route.query.data) {
+        this.cancelTwo()
+        this.$router.push({ path: '/index' })
+      } else {
+        this.$confirm('当前数据未保存是否保存?', '提示', {
+          confirmButtonText: '保存',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.submitAndSave(2)
+        }).catch(() => {
           data = {
-            tableName: this.purchaseList.tableName,
+            tableName: this.queryList.tableName,
             userId: Cookies.get('userName')
           }
-          this.$refs.avatar.form = {}
           this.getRow(data)
-
-          this.contentOption.forEach(item => {
-            if (item.label == 'personNaem' || item.label == 'corpsName' || item.label == 'fBillno') {
-              item.disabled = true
-            } else {
-              item.disabled = false
+          this.query(this.formDataList)
+        })
+      }
+    },
+    //所以按钮
+    buttonList(row) {
+      let data
+      switch (row.name) {
+        case '新单':
+          if (row.nameTwo === '详情页'){
+            this.contentList = []
+            data = {
+              tableName: this.purchaseList.tableName,
+              userId: Cookies.get('userName')
             }
-          })
-          this.contentButton.forEach(item => item.disabled = false)
-          this.contentStyle.forEach(item => item.disabled = false)
-          // this.$refs.avatar.form.createBy = Cookies.get('userName')
+            this.$refs.avatar.form = {}
+            this.getRow(data)
+            this.$refs.avatar.clearVerification()
+            this.contentOption.forEach(item => {
+              if (item.label == 'personNaem' || item.label == 'corpsName' || item.label == 'createBy' || item.label == 'fBillno') {
+                item.disabled = true
+              } else {
+                item.disabled = false
+              }
+            })
+            this.contentButton.forEach(item => item.disabled = false)
+            this.contentStyle.forEach(item => item.disabled = false)
+          }else {
+            this.contentList = []
+            this.contentButton = this.$options.data().contentButton
+            data = {
+              tableName: this.purchaseList.tableName,
+              userId: Cookies.get('userName')
+            }
+            this.$refs.avatar.form = {}
+            this.getRow(data)
+
+            this.contentOption.forEach(item => {
+              if (item.label == 'personNaem' || item.label == 'corpsName' || item.label == 'fBillno') {
+                item.disabled = true
+              } else {
+                item.disabled = false
+              }
+            })
+            this.contentButton.forEach(item => item.disabled = false)
+            this.contentStyle.forEach(item => item.disabled = false)
+          }
           break
-        case '复制新增':
-          if (this.selection.length > 0){
+        case '复制新单':
+          if (row.nameTwo === '详情页'){
+            console.log(this.$refs.avatar.form)
             let datae = {
-              fId:this.selection[0].fId,
-              fBilltype:'XS'
+              fId:this.$refs.avatar.form.fId,
+              fBilltype:'SQ'
             }
             copyNew(datae).then(res=>{
               this.$message({
-                message: '复制新增成功',
+                message: '复制新成功',
                 type: 'success',
                 showClose:true
               });
@@ -1307,7 +1383,28 @@ export default {
               this.viewMethod(scope)
             })
           }else {
-            this.$message.warning('未选择列表,请选择后再点击');
+            if (this.selection.length > 0){
+              let datae = {
+                fId:this.selection[0].fId,
+                fBilltype:'SQ'
+              }
+              copyNew(datae).then(res=>{
+                this.$message({
+                  message: '复制新单成功',
+                  type: 'success',
+                  showClose:true
+                });
+                let scope = {
+                  row:{
+                    fId:res.data
+                  }
+                }
+                this.query(this.formDataList)
+                this.viewMethod(scope)
+              })
+            }else {
+              this.$message.warning('未选择列表,请选择后再点击');
+            }
           }
           break
         case '保存':
@@ -1343,7 +1440,7 @@ export default {
             }
           })
           break
-        case '录入':
+        case '录入明细':
           this.contentList.push({
             fFeeid: '',
             fUnitprice: '',

+ 125 - 71
src/views/purchaseRequest/index.vue

@@ -39,6 +39,22 @@
       </el-pagination>
     </div>
     <div v-else class="app-container">
+      <div style="display: flex;margin-bottom: 10px">
+        <el-breadcrumb>
+          <el-breadcrumb-item style="font-weight: 700">采购申请</el-breadcrumb-item>
+          <el-breadcrumb-item style="font-weight: 700">采购申请详情页</el-breadcrumb-item>
+          <el-breadcrumb-item style="margin-top: -7px;">
+            <el-button
+              style="margin-left: 10px"
+              size="mini"
+              type="danger" plain
+              @click="backToList"
+              icon="el-icon-arrow-left">
+              返回列表</el-button>
+          </el-breadcrumb-item>
+        </el-breadcrumb>
+      </div>
+      <h1 style="text-align: center;margin-top: -42px">采购申请单</h1>
       <formComponent
         v-if="searchWhether"
         :formOption="contentOption"
@@ -440,7 +456,7 @@ export default {
           type: 'primary',
           size: 'mini',
           icon: 'el-icon-edit',
-          name: '新',
+          name: '新',
           disabled: false,
           hasPermi:['anpin:stockControl:anPingApply']
         },
@@ -462,23 +478,16 @@ export default {
           type: 'success',
           size: 'mini',
           icon: 'el-icon-c-scale-to-original',
-          name: '复制新',
+          name: '复制新',
           disabled: false,
           hasPermi:['anpin:stockControl:generateReceipts']
         }
       ],
-      contentButton: [
-        {
-          type: 'danger',
-          size: 'mini',
-          icon: 'el-icon-arrow-left',
-          name: '返回列表',
-          disabled: false
-        }, {
+      contentButton: [{
           type: 'primary',
           size: 'mini',
           icon: 'el-icon-plus',
-          name: '录入',
+          name: '录入明细',
           disabled: false
         }, {
           type: 'primary',
@@ -491,14 +500,16 @@ export default {
           type: 'primary',
           size: 'mini',
           icon: 'el-icon-plus',
-          name: '新增(详情页)',
+          name: '新单',
+          nameTwo:'详情页',
           plain: true,
           disabled: false
         },{
           type: 'primary',
           size: 'mini',
           icon: 'el-icon-plus',
-          name: '复制新增(行)',
+          name: '复制新单',
+          nameTwo:'详情页',
           plain: true,
           disabled: false
         },{
@@ -1018,13 +1029,13 @@ export default {
           }
           this.contentButton.forEach(item =>{
             if(this.$refs.avatar.form.fBillstatus < 4){
-              if (item.name == '录入' || item.name == '保存' || item.name == '请核'){
+              if (item.name == '录入明细' || item.name == '保存' || item.name == '请核'){
                 item.disabled = true
               }else {
                 item.disabled = false
               }
             }else{
-              if (item.name == '录入' || item.name == '保存' || item.name == '请核' || item.name == '修改'){
+              if (item.name == '录入明细' || item.name == '保存' || item.name == '请核' || item.name == '修改'){
                 item.disabled = true
               }else {
                 item.disabled = false
@@ -1043,7 +1054,7 @@ export default {
       this.contentStyle.forEach(item => item.disabled = true)
       console.log(this.contentStyle)
       // this.contentButton.forEach(item =>{
-      //   if (item.name == '录入' || item.name == '保存' || item.name == '请核'){
+      //   if (item.name == '录入明细' || item.name == '保存' || item.name == '请核'){
       //     item.disabled = true
       //   }else {
       //     item.disabled = false
@@ -1097,7 +1108,7 @@ export default {
     selectionbox(selection) {
       if (selection.length > 1){
         this.customButton.forEach(item =>{
-          if (item.name === '复制新'){
+          if (item.name === '复制新'){
             item.disabled = true
           }else {
             item.disabled = false
@@ -1151,35 +1162,84 @@ export default {
     Printing(){
       this.$print(this.$refs.print)
     },
-    //所以按钮
-    buttonList(row) {
-      console.log(row)
+    //返回列表
+    backToList(){
       let data
-      switch (row.name) {
-        case '新增':
-          this.contentList = []
+      if (!this.$refs.avatar.form.fId && this.contentList !== 0 || this.$refs.avatar.form.fBillstatus > 3 && !this.$route.query.data) {
+        data = {
+          tableName: this.queryList.tableName,
+          userId: Cookies.get('userName')
+        }
+        this.getRow(data)
+        this.query(this.formDataList)
+      } else if(this.$route.query.data){
+        this.cancelTwo();
+        this.$router.push({path:'/index'})
+      }else {
+        this.$confirm('当前数据未保存是否保存?', '提示', {
+          confirmButtonText: '保存',
+          cancelButtonText: '取消',
+          type: 'warning'
+        }).then(() => {
+          this.submitAndSave(2)
+        }).catch(() => {
           data = {
-            tableName: this.purchaseList.tableName,
+            tableName: this.queryList.tableName,
             userId: Cookies.get('userName')
           }
-          this.$refs.avatar.form = {}
           this.getRow(data)
-          this.contentOption.forEach(item => {
-            if (item.label == 'personNaem' || item.label == 'corpsName' || item.label == 'createBy' || item.label == 'fBillno') {
-              item.disabled = true
-            } else {
-              item.disabled = false
+          this.query(this.formDataList)
+        })
+      }
+    },
+    //所以按钮
+    buttonList(row) {
+      console.log(row)
+      let data
+      switch (row.name) {
+        case '新单':
+          if (row.nameTwo === '详情页'){
+            this.contentList = []
+            data = {
+              tableName: this.purchaseList.tableName,
+              userId: Cookies.get('userName')
             }
-          })
-          this.contentButton.forEach(item => item.disabled = false)
-          this.contentStyle.forEach(item => item.disabled = false)
-          this.$refs.avatar.form.createBy = Cookies.get('userName')
+            this.$refs.avatar.form = {}
+            this.getRow(data)
+            this.$refs.avatar.clearVerification()
+            this.contentOption.forEach(item => {
+              if (item.label == 'personNaem' || item.label == 'corpsName' || item.label == 'createBy' || item.label == 'fBillno') {
+                item.disabled = true
+              } else {
+                item.disabled = false
+              }
+            })
+            this.contentButton.forEach(item => item.disabled = false)
+            this.contentStyle.forEach(item => item.disabled = false)
+            this.$refs.avatar.form.createBy = Cookies.get('userName')
+          }else {
+            this.contentList = []
+            data = {
+              tableName: this.purchaseList.tableName,
+              userId: Cookies.get('userName')
+            }
+            this.$refs.avatar.form = {}
+            this.getRow(data)
+            this.contentOption.forEach(item => {
+              if (item.label == 'personNaem' || item.label == 'corpsName' || item.label == 'createBy' || item.label == 'fBillno') {
+                item.disabled = true
+              } else {
+                item.disabled = false
+              }
+            })
+            this.contentButton.forEach(item => item.disabled = false)
+            this.contentStyle.forEach(item => item.disabled = false)
+            this.$refs.avatar.form.createBy = Cookies.get('userName')
+          }
           break
         case '保存':
           this.$refs.avatar.submitForm('submit')
           break
-        case '新增(详情页)':
-          break
         case '打印':
           console.log(this.listData.fFeeid,this.contentList)
           for (let item in this.contentList){
@@ -1227,7 +1287,7 @@ export default {
             }
           })
           break
-        case '录入':
+        case '录入明细':
           this.contentList.push({
             fFeeid: '',
             fUnitprice: '',
@@ -1249,35 +1309,6 @@ export default {
         case '审批':
           this.addOrUpdateHand()
           break
-        case '返回列表':
-          console.log(this.$route.query.data)
-          if (!this.$refs.avatar.form.fId && this.contentList !== 0 || this.$refs.avatar.form.fBillstatus > 3 && !this.$route.query.data) {
-            data = {
-              tableName: this.queryList.tableName,
-              userId: Cookies.get('userName')
-            }
-            this.getRow(data)
-            this.query(this.formDataList)
-          } else if(this.$route.query.data){
-            this.cancelTwo();
-            this.$router.push({path:'/index'})
-          }else {
-            this.$confirm('当前数据未保存是否保存?', '提示', {
-              confirmButtonText: '保存',
-              cancelButtonText: '取消',
-              type: 'warning'
-            }).then(() => {
-              this.submitAndSave(2)
-            }).catch(() => {
-              data = {
-                tableName: this.queryList.tableName,
-                userId: Cookies.get('userName')
-              }
-              this.getRow(data)
-              this.query(this.formDataList)
-            })
-          }
-          break
         case '请核':
           if (this.$refs.avatar.form.fBillstatus < 4){
             this.$refs.avatar.submitForm('check')
@@ -1324,15 +1355,17 @@ export default {
             });
           })
           break
-        case '复制新增':
-          if (this.selection.length > 0){
+        case '复制新单':
+
+          if (row.nameTwo === '详情页'){
+            console.log(this.$refs.avatar.form)
             let datae = {
-              fId:this.selection[0].fId,
+              fId:this.$refs.avatar.form.fId,
               fBilltype:'SQ'
             }
             copyNew(datae).then(res=>{
               this.$message({
-                message: '复制新成功',
+                message: '复制新成功',
                 type: 'success',
                 showClose:true
               });
@@ -1345,7 +1378,28 @@ export default {
               this.viewMethod(scope)
             })
           }else {
-            this.$message.warning('未选择列表,请选择后再点击');
+            if (this.selection.length > 0){
+              let datae = {
+                fId:this.selection[0].fId,
+                fBilltype:'SQ'
+              }
+              copyNew(datae).then(res=>{
+                this.$message({
+                  message: '复制新单成功',
+                  type: 'success',
+                  showClose:true
+                });
+                let scope = {
+                  row:{
+                    fId:res.data
+                  }
+                }
+                this.query(this.formDataList)
+                this.viewMethod(scope)
+              })
+            }else {
+              this.$message.warning('未选择列表,请选择后再点击');
+            }
           }
           break
         case '撤销审批':