Commit c1c6b945 authored by 高宇's avatar 高宇

1.弹框标题去掉管理两个字

2.提交时校验paramsItem的值
3.修改params 添加和删除的样式
parent 204223cb
...@@ -31,16 +31,6 @@ ...@@ -31,16 +31,6 @@
style="width: 150px" style="width: 150px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态: " prop="flag">
<el-select v-model="queryParams.flag" placeholder="请选择状态" clearable size="small">
<el-option
v-for="dict in statusOptions"
:key="dict.dictValue"
:label="dict.dictLabel"
:value="dict.dictValue"
/>
</el-select>
</el-form-item>
<el-form-item> <el-form-item>
<el-button <el-button
:class="commonField.queryClass" :class="commonField.queryClass"
...@@ -121,7 +111,7 @@ ...@@ -121,7 +111,7 @@
<span>{{ scope.row.createDate | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span> <span>{{ scope.row.createDate | transformDateByFormat('YYYY-MM-DD HH:mm') }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" class-name="small-padding fixed-width" width="200px"> <el-table-column label="操作" class-name="small-padding fixed-width" width="100px">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
:class="commonField.updateClass" :class="commonField.updateClass"
...@@ -163,19 +153,19 @@ ...@@ -163,19 +153,19 @@
</el-form-item> </el-form-item>
<el-form-item label="params: " prop="params"> <el-form-item label="params: " prop="params">
<el-row v-for="(item, index) in paramsItems" :key="index" class="params"> <el-row v-for="(item, index) in paramsItems" :key="index" class="params">
<el-col :span="9"> <el-col :span="10">
<el-form-item label="key: " label-width="40" prop="key" :rules="getKeyRules(item)"> <el-form-item label="key: " label-width="40">
<el-input v-model="item.key" /> <el-input v-model="item.key" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="9"> <el-col :span="10">
<el-form-item label="value: " label-width="40" prop="value" :rules="getValueRules(item)"> <el-form-item label="value: " label-width="40">
<el-input v-model="item.value" /> <el-input v-model="item.value" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="5" class="btn-container"> <el-col :span="4" class="btn-container">
<el-button type="primary" class="el-icon-plus" @click="addFormItem(index)" circle></el-button> <i class="el-icon-plus" style="cursor: pointer;font-size: 16px;color: #25C7E3FF" @click="addFormItem(index)"></i>
<el-button v-if="paramsItems.length > 1" type="primary" class="el-icon-minus" @click="removeFormItem(index)" circle></el-button> <i v-if="index > 0" style="cursor: pointer;font-size: 16px;margin-left: 6px;color: red;" class="el-icon-minus" @click="removeFormItem(index)"></i>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
...@@ -191,7 +181,7 @@ ...@@ -191,7 +181,7 @@
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button class="cancelBtn" @click="cancel">取 消</el-button> <el-button class="cancelBtn" @click="cancel">取 消</el-button>
<el-button class="submitBtn" type="primary" @click="submitForm">确 定</el-button> <el-button :loading="addLoading" class="submitBtn" type="primary" @click="submitForm">确 定</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
...@@ -210,6 +200,8 @@ export default { ...@@ -210,6 +200,8 @@ export default {
name: 'IncomeWmsLabel', name: 'IncomeWmsLabel',
data() { data() {
return { return {
// 新增确认按钮loading
addLoading: false,
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 总条数 // 总条数
...@@ -268,15 +260,26 @@ export default { ...@@ -268,15 +260,26 @@ export default {
this.getList() // 列表查询 this.getList() // 列表查询
}, },
methods: { methods: {
getKeyRules(item) { /**
return [ * @description: 提交时校验parms中的数据
{ required: !!item.value && !item.key, message: '请输入key的值', trigger: 'blur' } * @author: gaoyu
] * @param: list
}, * @return: filteredArray
getValueRules(item) { **/
return [ filterArray(list) {
{ required: !!item.key && !item.value, message: '请输入value的值', trigger: 'blur' } /**
] * 1.将数组转换为map
* 2.将map转换为数组
* **/
// 校验并处理数组
let resultMap = new Map();
for (let obj of list) {
if (obj.key !== '') {
resultMap.set(obj.key, obj);
}
}
let filteredArray = Array.from(resultMap.values());
return filteredArray
}, },
addFormItem(index) { addFormItem(index) {
this.paramsItems.splice(index + 1, 0, { key: '', value: '' }) this.paramsItems.splice(index + 1, 0, { key: '', value: '' })
...@@ -350,7 +353,8 @@ export default { ...@@ -350,7 +353,8 @@ export default {
handleAdd() { handleAdd() {
this.reset() this.reset()
this.open = true this.open = true
this.title = '添加标签管理' // 1.弹框标题去掉管理两个字
this.title = '添加标签'
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
...@@ -370,7 +374,8 @@ export default { ...@@ -370,7 +374,8 @@ export default {
} }
} }
this.open = true this.open = true
this.title = '修改标签管理' // 1.弹框标题去掉管理两个字
this.title = '修改标签'
}) })
}, },
// 改变状态 // 改变状态
...@@ -395,25 +400,38 @@ export default { ...@@ -395,25 +400,38 @@ export default {
submitForm: function() { submitForm: function() {
this.$refs['form'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
if (this.paramsItems.length > 0) {
if (this.paramsItems.length === 1 && this.paramsItems[0].key === '') { if (this.paramsItems.length === 1 && this.paramsItems[0].key === '') {
this.form.params = undefined this.form.params = undefined
} else { } else {
this.form.params = JSON.stringify(this.paramsItems.reduce((obj, item) => { // 4.校验paramsItems的值
let list = this.filterArray(this.paramsItems)
this.form.params = JSON.stringify(list.reduce((obj, item) => {
obj[item.key] = item.value obj[item.key] = item.value
return obj return obj
}, {})) }, {}))
} }
}
if (this.form.businessId !== undefined) { if (this.form.businessId !== undefined) {
this.addLoading = true
updateIncomeWmsLabel(this.form).then(response => { updateIncomeWmsLabel(this.form).then(response => {
this.msgSuccess('修改成功') this.msgSuccess('修改成功')
this.open = false this.open = false
this.getList() this.getList()
this.addLoading = false
}).catch(() => {
this.addLoading = false
}) })
} else { } else {
this.addLoading = true
addIncomeWmsLabel(this.form).then(response => { addIncomeWmsLabel(this.form).then(response => {
this.msgSuccess('新增成功') this.msgSuccess('新增成功')
this.open = false this.open = false
this.getList() this.getList()
this.addLoading = false
}).catch(() => {
this.addLoading = false
}) })
} }
} }
...@@ -486,9 +504,12 @@ export default { ...@@ -486,9 +504,12 @@ export default {
} }
} }
.btn-container{ .btn-container{
display: flex;
height: 60px;
align-items: center;
.el-button{ .el-button{
margin-left: 6%; margin-left: 6%;
margin-top: 15%; //margin-top: 15%;
width: 35%; width: 35%;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment