Commit 1850d162 by cwq0219

验证+scroll

1 parent 15f1e2c4
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<el-form-item <el-form-item
:prop="item.name" :prop="item.name"
:label="item.label" :label="item.label"
:id="item.name"
label-width="130px" label-width="130px"
class="dis-in-block" class="dis-in-block"
:style="{'margin-bottom': !item.type ? '0px' : '22px'}" :style="{'margin-bottom': !item.type ? '0px' : '22px'}"
...@@ -412,7 +413,13 @@ export default { ...@@ -412,7 +413,13 @@ export default {
}, },
handleAddPro(targetItem) { handleAddPro(targetItem) {
if (!this.formData[targetItem.relateAttr]) { if (!this.formData[targetItem.relateAttr]) {
this.notice.warningTips('请选择基础商品') // this.notice.warningTips('请选择基础商品')
this.$message({
message: '请选择基础商品',
type: 'warning',
showClose: true
})
this.jumpScroll(targetItem.relateAttr)
return true return true
} }
this.markTarget = targetItem this.markTarget = targetItem
...@@ -468,7 +475,8 @@ export default { ...@@ -468,7 +475,8 @@ export default {
if (!selectedData.length) { if (!selectedData.length) {
this.$message({ this.$message({
message: '请选择关联门店', message: '请选择关联门店',
type: 'warning' type: 'warning',
showClose: true
}) })
return true return true
} }
...@@ -491,8 +499,8 @@ export default { ...@@ -491,8 +499,8 @@ export default {
var formDataName = formItem.name var formDataName = formItem.name
var filterArr = this.formData[formDataName].filter(i => i[formItem.optionValue] !== item[formItem.optionValue]) var filterArr = this.formData[formDataName].filter(i => i[formItem.optionValue] !== item[formItem.optionValue])
this.formData[formDataName] = filterArr this.formData[formDataName] = filterArr
console.log(this.formData) // console.log(this.formData)
console.log(formDataName) // console.log(formDataName)
this.judgeIsDisable() this.judgeIsDisable()
}, },
// 图片 // 图片
...@@ -511,7 +519,7 @@ export default { ...@@ -511,7 +519,7 @@ export default {
const base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1] const base64 = fileInfo.name.split('.')[1] + '@' + imgFile.split(',')[1]
// console.log(base64) // console.log(base64)
uploadImg({ file: base64 }).then(res => { uploadImg({ file: base64 }).then(res => {
console.log(res) // console.log(res)
this.$refs[this.formRef + 'd2FormRuleForm'].clearValidate(targetItem.name) this.$refs[this.formRef + 'd2FormRuleForm'].clearValidate(targetItem.name)
if (targetItem.maxPhotoNum === 1) { if (targetItem.maxPhotoNum === 1) {
this.formData[targetItem.name] = [{ this.formData[targetItem.name] = [{
...@@ -524,7 +532,7 @@ export default { ...@@ -524,7 +532,7 @@ export default {
} else { } else {
this.formData[targetItem.name][subIndex].content = res this.formData[targetItem.name][subIndex].content = res
} }
console.log(this.formData[targetItem.name]) // console.log(this.formData[targetItem.name])
}) })
} }
}, },
...@@ -545,6 +553,9 @@ export default { ...@@ -545,6 +553,9 @@ export default {
handleClose() { handleClose() {
this.$emit('handleClose') this.$emit('handleClose')
}, },
jumpScroll(idName) {
document.getElementById(idName).scrollIntoView()
},
handleUp() { handleUp() {
// console.log(this.formData) // console.log(this.formData)
// const flag = true // const flag = true
...@@ -575,6 +586,25 @@ export default { ...@@ -575,6 +586,25 @@ export default {
} }
} }
this.$emit('handleAddConfirm', this.formData) this.$emit('handleAddConfirm', this.formData)
} else {
var needRuleList = Object.keys(this.rules)
// console.log(needRuleList)
for (var i in needRuleList) {
// needRuleList.forEach(item => {
const item = needRuleList[i]
if (Array.isArray(this.formData[item])) {
if (!this.formData[item].length) {
this.jumpScroll(item)
return true
}
} else {
if (!this.formData[item]) {
this.jumpScroll(item)
return true
}
}
}
// })
} }
}) })
// } // }
......
...@@ -128,7 +128,7 @@ export default { ...@@ -128,7 +128,7 @@ export default {
// console.log(this.editData) // console.log(this.editData)
// add - 新增;edit - 编辑 // add - 新增;edit - 编辑
this.addOrEdit = this.$route.params.addOrEdit this.addOrEdit = this.$route.params.addOrEdit
this.getGoodsListNoBase() this.getGoodsList()
if (this.addOrEdit === 'edit') { if (this.addOrEdit === 'edit') {
getGoodsInfoById({ id: this.$route.params.row.id }).then(res => { getGoodsInfoById({ id: this.$route.params.row.id }).then(res => {
// console.log(res) // console.log(res)
...@@ -166,9 +166,9 @@ export default { ...@@ -166,9 +166,9 @@ export default {
methods: { methods: {
...mapActions({ close: 'd2admin/page/close' }), ...mapActions({ close: 'd2admin/page/close' }),
// ...mapActions('d2admin/page', ['close']), // ...mapActions('d2admin/page', ['close']),
getGoodsListNoBase() { getGoodsList() {
var params = this.addOrEdit === 'edit' ? {} : { exceptBase: true } // var params = this.addOrEdit === 'edit' ? {} : { exceptBase: true }
getGoodsList(params).then(res => { getGoodsList({}).then(res => {
// console.log(res) // console.log(res)
this.editForm[0].formBlock[0].optionList = res this.editForm[0].formBlock[0].optionList = res
}) })
......
...@@ -192,7 +192,8 @@ export default { ...@@ -192,7 +192,8 @@ export default {
// this.notice.warningTips('请选择关联门店') // this.notice.warningTips('请选择关联门店')
this.$message({ this.$message({
message: '请选择关联门店', message: '请选择关联门店',
type: 'warning' type: 'warning',
showClose: true
}) })
return true return true
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!