Commit 63572aaa by chenwq

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

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