Commit 4a06e5a0c2e085a7ab055b53e0d17a4ebd0021d4
1 parent
94604b5d
feat: 审批页增加表单必填校验方法-通用&&补货单-审批(特殊角色&正常角色)
Showing
3 changed files
with
74 additions
and
11 deletions
| @@ -251,6 +251,11 @@ export default { | @@ -251,6 +251,11 @@ export default { | ||
| 251 | ...vals, | 251 | ...vals, |
| 252 | } | 252 | } |
| 253 | }, | 253 | }, |
| 254 | + // 校验表单 默认通过 | ||
| 255 | + basicRefCheck() { | ||
| 256 | + const ref = this.$refs.basicRef | ||
| 257 | + return ref && typeof ref.checkForm === 'function' ? ref.checkForm() : true | ||
| 258 | + }, | ||
| 254 | // 驳回 | 259 | // 驳回 |
| 255 | onReject() { | 260 | onReject() { |
| 256 | this.approveType = 'REFUSE' | 261 | this.approveType = 'REFUSE' |
| @@ -260,6 +265,11 @@ export default { | @@ -260,6 +265,11 @@ export default { | ||
| 260 | // 通过 | 265 | // 通过 |
| 261 | // 在这里增加业务判断 比如 资信管理,判断有没有填写客户信息、公司评审(这些是不同角色进行操作的) | 266 | // 在这里增加业务判断 比如 资信管理,判断有没有填写客户信息、公司评审(这些是不同角色进行操作的) |
| 262 | onPass() { | 267 | onPass() { |
| 268 | + // 校验表单 | ||
| 269 | + if (!this.basicRefCheck()) { | ||
| 270 | + return | ||
| 271 | + } | ||
| 272 | + console.log('onPass'); | ||
| 263 | console.log('审核__roles&&bizFlag', this.roleCodes, this.auditCtx.bizFlag); | 273 | console.log('审核__roles&&bizFlag', this.roleCodes, this.auditCtx.bizFlag); |
| 264 | // 客户资信的审核 | 274 | // 客户资信的审核 |
| 265 | if (this.auditCtx.bizFlag === 'CUSTOMER_CREDIT_EDIT') { | 275 | if (this.auditCtx.bizFlag === 'CUSTOMER_CREDIT_EDIT') { |
| @@ -14,12 +14,13 @@ | @@ -14,12 +14,13 @@ | ||
| 14 | <view class="row"><text class="label">购货单位</text><text class="value">{{ form.customerName }}</text> | 14 | <view class="row"><text class="label">购货单位</text><text class="value">{{ form.customerName }}</text> |
| 15 | </view> | 15 | </view> |
| 16 | <view class="row"><text class="label">原计划发货日期</text><text class="value">{{ form.originPlanShipDate | 16 | <view class="row"><text class="label">原计划发货日期</text><text class="value">{{ form.originPlanShipDate |
| 17 | - }}</text></view> | 17 | + }}</text></view> |
| 18 | </view> | 18 | </view> |
| 19 | 19 | ||
| 20 | <!-- 产品 --> | 20 | <!-- 产品 --> |
| 21 | <view class="section2"> | 21 | <view class="section2"> |
| 22 | - <Product mode="approve" :list="initPurchaseOrderLineList" @change="purchaseOrderLineListChange"/> | 22 | + <Product mode="approve" :list="initPurchaseOrderLineList" |
| 23 | + :canEditSupplementary="canEditSupplementary" @change="purchaseOrderLineListChange" /> | ||
| 23 | </view> | 24 | </view> |
| 24 | <view class="section3"> | 25 | <view class="section3"> |
| 25 | <view class="view-total"> | 26 | <view class="view-total"> |
| @@ -35,7 +36,7 @@ | @@ -35,7 +36,7 @@ | ||
| 35 | <view class="row"> | 36 | <view class="row"> |
| 36 | <view class="row2"> | 37 | <view class="row2"> |
| 37 | <text class="label">需求补货</text><text class="value">{{ form.totalSupplementaryQuantity | 38 | <text class="label">需求补货</text><text class="value">{{ form.totalSupplementaryQuantity |
| 38 | - }}</text> | 39 | + }}</text> |
| 39 | </view> | 40 | </view> |
| 40 | </view> | 41 | </view> |
| 41 | </view> | 42 | </view> |
| @@ -58,6 +59,8 @@ export default { | @@ -58,6 +59,8 @@ export default { | ||
| 58 | return { | 59 | return { |
| 59 | form: {}, | 60 | form: {}, |
| 60 | initPurchaseOrderLineList: [], | 61 | initPurchaseOrderLineList: [], |
| 62 | + roleCodes: [], | ||
| 63 | + canEditSupplementary: false | ||
| 61 | } | 64 | } |
| 62 | }, | 65 | }, |
| 63 | computed: { | 66 | computed: { |
| @@ -67,13 +70,25 @@ export default { | @@ -67,13 +70,25 @@ export default { | ||
| 67 | immediate: true, | 70 | immediate: true, |
| 68 | handler(val) { | 71 | handler(val) { |
| 69 | const v = (val !== undefined && val !== null) ? String(val) : '' | 72 | const v = (val !== undefined && val !== null) ? String(val) : '' |
| 70 | - if (v) this.loadDetail(v) | 73 | + if (v) { |
| 74 | + this.loadDetail(v); | ||
| 75 | + this.getRoleInfo(); | ||
| 76 | + } | ||
| 71 | } | 77 | } |
| 72 | } | 78 | } |
| 73 | }, | 79 | }, |
| 74 | onLoad(query) { | 80 | onLoad(query) { |
| 81 | + | ||
| 75 | }, | 82 | }, |
| 76 | methods: { | 83 | methods: { |
| 84 | + getRoleInfo() { | ||
| 85 | + this.roleCodes = this.$store.getters.roleCodes || []; | ||
| 86 | + console.log('roleCodes', this.roleCodes) | ||
| 87 | + // 一分厂经营办计划员/二分厂经营办计划员/三分厂经营办计划员/四分厂经营办计划员 | ||
| 88 | + const allowed = ['yfcjybjhy', 'efcjybjhy', 'sfcjybjhy', 'ztfcjybjhy']; | ||
| 89 | + this.canEditSupplementary = allowed.some((code) => this.roleCodes.includes(code)); | ||
| 90 | + console.log('canEditSupplementary', this.canEditSupplementary) | ||
| 91 | + }, | ||
| 77 | async loadDetail(id) { | 92 | async loadDetail(id) { |
| 78 | try { | 93 | try { |
| 79 | const res = await getDetailApi(id) | 94 | const res = await getDetailApi(id) |
| @@ -119,6 +134,38 @@ export default { | @@ -119,6 +134,38 @@ export default { | ||
| 119 | this.form.purchaseOrderLineList = list | 134 | this.form.purchaseOrderLineList = list |
| 120 | this.calculateSummary(list) | 135 | this.calculateSummary(list) |
| 121 | }, | 136 | }, |
| 137 | + getFormValues() { | ||
| 138 | + const m = this.form || {} | ||
| 139 | + return JSON.parse(JSON.stringify(m)) | ||
| 140 | + }, | ||
| 141 | + // 审批-通过:校验表单 | ||
| 142 | + checkForm() { | ||
| 143 | + if (this.canEditSupplementary) { | ||
| 144 | + const list = Array.isArray(this.form.purchaseOrderLineList) ? this.form.purchaseOrderLineList : []; | ||
| 145 | + console.log('checkForm__list', list) | ||
| 146 | + if (list.length === 0) { | ||
| 147 | + uni.showToast({ title: '请先添加产品', icon: 'none' }) | ||
| 148 | + return false | ||
| 149 | + } | ||
| 150 | + const fields = [ | ||
| 151 | + { key: 'supplementaryQuantity', label: '需求补货数量' }, | ||
| 152 | + ] | ||
| 153 | + for (let i = 0; i < list.length; i++) { | ||
| 154 | + const it = list[i] || {} | ||
| 155 | + for (const f of fields) { | ||
| 156 | + const v = it && it[f.key] | ||
| 157 | + if (v === undefined || v === null || String(v).trim() === '') { | ||
| 158 | + uni.showToast({ title: `产品第${i + 1}条:${f.label}不能为空!`, icon: 'none' }) | ||
| 159 | + return false | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + return true | ||
| 164 | + } else { | ||
| 165 | + return true | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + } | ||
| 122 | } | 169 | } |
| 123 | } | 170 | } |
| 124 | </script> | 171 | </script> |
| @@ -201,11 +248,13 @@ export default { | @@ -201,11 +248,13 @@ export default { | ||
| 201 | font-weight: 600; | 248 | font-weight: 600; |
| 202 | } | 249 | } |
| 203 | } | 250 | } |
| 251 | + | ||
| 204 | .section3 { | 252 | .section3 { |
| 205 | padding: 0 32rpx; | 253 | padding: 0 32rpx; |
| 206 | background-color: #fff; | 254 | background-color: #fff; |
| 207 | margin-top: 20rpx; | 255 | margin-top: 20rpx; |
| 208 | } | 256 | } |
| 257 | + | ||
| 209 | .view-total { | 258 | .view-total { |
| 210 | padding: 20rpx 0; | 259 | padding: 20rpx 0; |
| 211 | 260 |
| @@ -347,14 +347,12 @@ | @@ -347,14 +347,12 @@ | ||
| 347 | </template> | 347 | </template> |
| 348 | </uni-list-item> | 348 | </uni-list-item> |
| 349 | <uni-list-item title="需求补货数量(kg)"> | 349 | <uni-list-item title="需求补货数量(kg)"> |
| 350 | - <!-- <template v-slot:footer> | ||
| 351 | - <text class="value">{{ item.supplementaryQuantity }}</text> | ||
| 352 | - </template> --> | ||
| 353 | <template v-slot:footer> | 350 | <template v-slot:footer> |
| 354 | - <uni-easyinput type="digit" v-model="item.supplementaryQuantity" | 351 | + <uni-easyinput v-if="canEditSupplementary" type="digit" v-model="item.supplementaryQuantity" |
| 355 | placeholder="请输入需求补货数量kg" :inputBorder="false" | 352 | placeholder="请输入需求补货数量kg" :inputBorder="false" |
| 356 | @input="onNonNegativeNumberInput($event, item, idx, 'supplementaryQuantity')" | 353 | @input="onNonNegativeNumberInput($event, item, idx, 'supplementaryQuantity')" |
| 357 | @blur="onNonNegativeNumberBlur(item, idx, 'supplementaryQuantity')" /> | 354 | @blur="onNonNegativeNumberBlur(item, idx, 'supplementaryQuantity')" /> |
| 355 | + <text v-else class="value">{{ item.supplementaryQuantity }}</text> | ||
| 358 | </template> | 356 | </template> |
| 359 | </uni-list-item> | 357 | </uni-list-item> |
| 360 | <uni-list-item class="amount-item" title="单价(元/kg)"> | 358 | <uni-list-item class="amount-item" title="单价(元/kg)"> |
| @@ -475,12 +473,14 @@ export default { | @@ -475,12 +473,14 @@ export default { | ||
| 475 | totalQuantity: { type: Number, default: 0 }, | 473 | totalQuantity: { type: Number, default: 0 }, |
| 476 | totalShippedQuantity: { type: Number, default: 0 }, | 474 | totalShippedQuantity: { type: Number, default: 0 }, |
| 477 | totalSupplementaryQuantity: { type: Number, default: 0 }, | 475 | totalSupplementaryQuantity: { type: Number, default: 0 }, |
| 478 | - orderDate: { type: String, default: '' } | 476 | + orderDate: { type: String, default: '' }, |
| 477 | + canEditSupplementary: { type: Boolean, default: false } | ||
| 479 | }, | 478 | }, |
| 480 | data() { | 479 | data() { |
| 481 | return { | 480 | return { |
| 482 | items: [], | 481 | items: [], |
| 483 | collapsedView: false, | 482 | collapsedView: false, |
| 483 | + roleCodes: [], | ||
| 484 | } | 484 | } |
| 485 | }, | 485 | }, |
| 486 | computed: { | 486 | computed: { |
| @@ -498,7 +498,11 @@ export default { | @@ -498,7 +498,11 @@ export default { | ||
| 498 | const mm = String(dt.getMonth() + 1).padStart(2, '0') | 498 | const mm = String(dt.getMonth() + 1).padStart(2, '0') |
| 499 | const dd = String(dt.getDate()).padStart(2, '0') | 499 | const dd = String(dt.getDate()).padStart(2, '0') |
| 500 | return `${yy}/${mm}/${dd}` | 500 | return `${yy}/${mm}/${dd}` |
| 501 | - } | 501 | + }, |
| 502 | + // roleCodes() { | ||
| 503 | + // const g = this.$store && this.$store.getters | ||
| 504 | + // return (g && g.roleCodes) || []; | ||
| 505 | + // }, | ||
| 502 | }, | 506 | }, |
| 503 | watch: { | 507 | watch: { |
| 504 | items: { | 508 | items: { |
| @@ -518,7 +522,7 @@ export default { | @@ -518,7 +522,7 @@ export default { | ||
| 518 | }, | 522 | }, |
| 519 | created() { | 523 | created() { |
| 520 | const init = Array.isArray(this.list) && this.list.length > 0 ? this.list.map(v => ({ ...this.defaultItem(), ...v, collapsed: false })) : [{ ...this.defaultItem(), collapsed: false }] | 524 | const init = Array.isArray(this.list) && this.list.length > 0 ? this.list.map(v => ({ ...this.defaultItem(), ...v, collapsed: false })) : [{ ...this.defaultItem(), collapsed: false }] |
| 521 | - this.items = init | 525 | + this.items = init; |
| 522 | }, | 526 | }, |
| 523 | methods: { | 527 | methods: { |
| 524 | defaultItem() { | 528 | defaultItem() { |