Commit 63572aaa by chenwq

fix(销售日报配置): 添加表单验证规则并修复保存逻辑

为日报人员名单和抽检人员名单添加必填验证规则
重构保存逻辑,在验证通过后才执行保存操作
1 parent f8e2a6e9
......@@ -5,7 +5,7 @@
销售日报配置
</div>
<div class="config-wrap gl-form-page" v-loading="loading">
<glsx-combi-form ref="showSearch" labelWidth="130px" :isBlock="true" :formObj="editForm" :formData="editFormData"></glsx-combi-form>
<glsx-combi-form ref="showSearch" labelWidth="130px" :isBlock="true" :formRules="rules" :formRef="editChildRef" :formObj="editForm" :formData="editFormData"></glsx-combi-form>
</div>
<!--
<el-form ref="form" :model="form" label-width="154px">
......@@ -32,6 +32,11 @@ export default {
dailyReportStaffList: [],
randomCheckStaffList: []
},
editChildRef: 'editChildRef',
rules: {
dailyReportStaffList: [{ required: true, message: '请选择日报人员名单', trigger: 'change' }],
randomCheckStaffList: [{ required: true, message: '请选择抽检人员名单', trigger: 'change' }]
},
editFormData: [
{
label: '所属企业',
......@@ -135,31 +140,35 @@ export default {
if (this.loading) {
return true
}
this.loading = true
var params = {
dailyReportStaffList: [],
randomCheckStaffList: []
}
const attrList = ['dailyReportStaffList', 'randomCheckStaffList']
attrList.forEach(item => {
this.editForm[item].forEach(k => {
params[item].push({
staffUuid: k,
staffName: this.baseData.staffList.find(n => n.staffUuid == k).staffName
this.$refs.showSearch.$refs[this.editChildRef].validate(valid => {
if (valid) {
this.loading = true
var params = {
dailyReportStaffList: [],
randomCheckStaffList: []
}
const attrList = ['dailyReportStaffList', 'randomCheckStaffList']
attrList.forEach(item => {
this.editForm[item].forEach(k => {
params[item].push({
staffUuid: k,
staffName: this.baseData.staffList.find(n => n.staffUuid == k).staffName
})
})
})
})
})
console.log(params, 'params')
this.$apis.salesDaily.saveSalesDailyConfig(params).then(res => {
console.log(res)
this.$message({
message: res.code == '0' ? '配置成功!' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
console.log(params, 'params')
this.$apis.salesDaily.saveSalesDailyConfig(params).then(res => {
console.log(res)
this.$message({
message: res.code == '0' ? '配置成功!' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
})
.finally(() => {
this.loading = false
})
}
})
.finally(() => {
this.loading = false
})
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!