Browse Source

fix:财务管理新增出入账增加校验

lazy 7 months ago
parent
commit
28147dc281

+ 1 - 1
src/views/financialManagement/addAccounts.vue

@@ -9,8 +9,8 @@
       <div class="tempalte-content" style="min-height: auto; padding: 0px 20px ">
         <add-accounts-content ref="addAccountsContent" />
         <div class="submit-btn">
-          <el-button style="width: 150px;" type="primary" @click="onSubmit">确定</el-button>
           <el-button style="width: 150px;" @click="() => { $router.go(-1) }">取消</el-button>
+          <el-button style="width: 150px;" type="primary" @click="onSubmit">确定</el-button>
         </div>
       </div>
     </div>

+ 53 - 6
src/views/financialManagement/components/AddAccountsContent.vue

@@ -17,13 +17,13 @@
           />
         </el-select>
       </el-form-item>
-      <cy-info-title>出入账信息</cy-info-title>
+      <cy-info-title style="margin-top: 10px">出入账信息</cy-info-title>
       <el-form-item label="账户归属" prop="attributionOfAccountId">
         <el-radio-group v-model="ruleForm.attributionOfAccountId" @change="attributionOfAccountChange(ruleForm.companyOwnershipId)">
           <el-radio v-for="item in attributionOfAccountList" :key="item.id" :label="item.id">{{ item.name }}</el-radio>
         </el-radio-group>
       </el-form-item>
-      <el-form-item label="公司归属">
+      <el-form-item label="公司归属" prop="companyOwnershipId" class="form-required">
         <el-select
           v-if="!isCapital(ruleForm.attributionOfAccountId)"
           v-model="ruleForm.companyOwnershipId"
@@ -53,7 +53,7 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item v-if="isCapital(ruleForm.attributionOfAccountId)" label="业务类型">
+      <el-form-item v-if="isCapital(ruleForm.attributionOfAccountId)" label="业务类型" class="form-required">
         <el-select
           v-model="ruleForm.businessTypeId"
           filterable
@@ -68,7 +68,7 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item label="开户银行名称">
+      <el-form-item label="开户银行名称" prop="bankName">
         <el-select
           v-if="!isCapital(ruleForm.attributionOfAccountId)"
           v-model="ruleForm.bankName"
@@ -98,7 +98,7 @@
           />
         </el-select>
       </el-form-item>
-      <el-form-item label="账号">
+      <el-form-item label="账号" prop="bankCardNo">
         <el-input
           v-model="ruleForm.bankCardNo"
           placeholder="请输入账号"
@@ -121,6 +121,7 @@
         v-if="ruleForm.type === 'entryType_cash'"
         label="入账金额"
         prop="incomeAmount"
+        class="form-required"
       >
         <cy-amount-input v-model="ruleForm.incomeAmount" class="one-form-item" />
       </el-form-item>
@@ -223,6 +224,24 @@ export default {
       rules: {
         billType: [
           { required: true, message: '请选择出入账类型', trigger: 'change' }
+        ],
+        companyId: [
+          { required: true, message: '请选择企业名称', trigger: 'change' }
+        ],
+        attributionOfAccountId: [
+          { required: true, message: '请选择账户归属', trigger: 'change' }
+        ],
+        bankName: [
+          { required: true, message: '请选择开户银行名称', trigger: 'blur' }
+        ],
+        bankCardNo: [
+          { required: true, message: '请选择开户行账号', trigger: 'blur' }
+        ],
+        type: [
+          { required: true, message: '请选择类型', trigger: 'change' }
+        ],
+        incomeDate: [
+          { required: true, message: '请选择入账日期', trigger: 'blur' }
         ]
       },
       corporateNameList: [],
@@ -418,6 +437,30 @@ export default {
       return new Promise((resolve, reject) => {
         const { companyId, attributionOfAccountId, companyOwnershipId, refinancingManagementId, bankCardNoId, businessTypeId, businessNumberId, type, incomeDate, incomeAmount, invoiceAmount, realAmount, remark, bankName, bankCardNo, id } = this.ruleForm
 
+        // 账户归属选择为资方的时候校验公司归属和业务类型
+        if (this.isCapital(attributionOfAccountId)) {
+          if (!refinancingManagementId) {
+            this.$message.warning('请选择公司归属')
+            return
+          }
+          if (!businessTypeId) {
+            this.$message.warning('请选择业务类型')
+            return
+          }
+        }
+        if (!this.isCapital(attributionOfAccountId)) {
+          if (!companyOwnershipId) {
+            this.$message.warning('请选择公司归属')
+            return
+          }
+        }
+        // 当类型为现金时校验入账金额
+        if (type === 'entryType_cash') {
+          if (!incomeAmount) {
+            this.$message.warning('请输入账金额据金额')
+            return
+          }
+        }
         // 当类型为票据贴现时校验票据金额和实际金额
         if (type === 'entryType_bills_discounted') {
           if (!invoiceAmount) {
@@ -451,7 +494,11 @@ export default {
           param.invoiceAmount = invoiceAmount
           param.realAmount = realAmount
         }
-        resolve(param)
+        this.$refs.ruleForm.validate((valid) => {
+          if (valid) {
+            resolve(param)
+          }
+        })
       })
     }
   }

+ 9 - 9
src/views/financialManagement/indexTable.js

@@ -124,7 +124,8 @@ export default {
                 msg: '修改',
                 icon: 'iconfont icon-xiugai',
                 power: 'editFinancial',
-                category: 'edit'
+                category: 'edit',
+                rowPower: ['4']
               },
               {
                 msg: '删除',
@@ -135,7 +136,7 @@ export default {
             ]
             const options = btnList.map(item => {
               return (
-                <el-tooltip class='item' effect='dark' content={item.msg} placement='top' >
+                this.tablePower({ item, tab: this.activeName, row }) && <el-tooltip class='item' effect='dark' content={item.msg} placement='top' >
                   <span class='table-icon-box' v-power={item.power}>
                     <i class={item.icon} onClick={() => { this.handlerOperate(item.category, row, item.msg) }}></i>
                   </span>
@@ -156,16 +157,15 @@ export default {
       }
     },
     tablePower() {
-      return ({ item, tab, row }) => {
-        const { tabPower, rowPower } = item
+      return ({ item, row }) => {
+        const { rowPower } = item
         if (rowPower) {
-          if (tabPower.includes(tab) && rowPower.includes(row.statusName)) {
-            return true
+          if (rowPower.includes(row.cashStatus)) {
+            return false
           }
+          return true
         } else {
-          if (tabPower.includes(tab)) {
-            return true
-          }
+          return true
         }
       }
     }