系统管理模块台站部分 新增和修改窗口 status增加必填校验,

状态字段设置默认值及校验提示增加
This commit is contained in:
任珮宇 2024-03-06 15:41:25 +08:00
parent a20853ad51
commit ada699cc13
2 changed files with 54 additions and 46 deletions

View File

@ -105,14 +105,12 @@ export default {
})
},
handleInput(e = '') {
console.log('qweq', e)
let val
if (Object.keys(e).includes('target')) {
val = e.target.value
} else {
val = e
}
console.log(val)
this.$emit('change', val ? val : undefined)
//LOWCOD-2146 SQL
this.$emit('input', val ? val : undefined)

View File

@ -79,7 +79,11 @@
<a-textarea v-model="model.description" :rows="3"></a-textarea>
</a-form-model-item>
<a-form-model-item label="Status" prop="status">
<j-dict-select-tag v-model="model.status" dictCode="STATION_STATUS"></j-dict-select-tag>
<j-dict-select-tag
v-model="model.status"
dictCode="STATION_STATUS"
@change="handleStatus"
></j-dict-select-tag>
</a-form-model-item>
</a-form-model>
</custom-modal>
@ -99,76 +103,76 @@ const columns = [
align: 'left',
width: 100,
scopedSlots: {
customRender: 'index'
customRender: 'index',
},
customHeaderCell: () => {
return {
style: {
'padding-left': '60px !important'
}
'padding-left': '60px !important',
},
}
},
customCell: () => {
return {
style: {
'padding-left': '60px !important'
}
'padding-left': '60px !important',
},
}
}
},
},
{
title: 'STATION ID',
align: 'left',
dataIndex: 'stationId',
width: 100
width: 100,
},
{
title: 'STATION CODE',
align: 'left',
width: 100,
dataIndex: 'stationCode'
dataIndex: 'stationCode',
},
{
title: 'COUNTRY CODE',
align: 'left',
width: 100,
dataIndex: 'countryCode'
dataIndex: 'countryCode',
},
{
title: 'TYPE',
align: 'left',
width: 100,
dataIndex: 'type'
dataIndex: 'type',
},
{
title: 'LON',
align: 'left',
width: 100,
dataIndex: 'lon'
dataIndex: 'lon',
},
{
title: 'LAT',
align: 'left',
width: 100,
dataIndex: 'lat'
dataIndex: 'lat',
},
{
title: 'ELEVATION',
width: 100,
dataIndex: 'elevation'
dataIndex: 'elevation',
},
{
title: 'DESCRIPTION',
width: 100,
dataIndex: 'description',
ellipsis: true
ellipsis: true,
},
{
title: 'STATUS',
align: 'left',
width: 100,
dataIndex: 'status'
}
dataIndex: 'status',
},
]
export default {
@ -188,10 +192,9 @@ export default {
}
const validateCountryCode = (_, value, callback) => {
if(!value) {
if (!value) {
callback(new Error('Please Enter Country Code'))
}
else if (value.length > 2) {
} else if (value.length > 2) {
callback(new Error('Country Code Limit 2 Char'))
} else {
callback()
@ -202,27 +205,34 @@ export default {
rules: {
stationId: [{ required: true, message: 'Please Enter Station Id' }],
stationCode: [{ required: true, validator: validateStationCode }],
countryCode: [{ required: true, validator: validateCountryCode }]
countryCode: [{ required: true, validator: validateCountryCode }],
status: [{ required: true, message: 'Please Select Status', trigger: 'change' }],
},
url: {
list: '/gardsStations/findPage',
delete: '/gardsStations/deleteById',
add: '/gardsStations/create',
edit: '/gardsStations/update'
edit: '/gardsStations/update',
},
countryCodeList: [],
typeList: []
typeList: [],
}
},
created() {
this.getTypeList()
this.getCountryCodeList()
},
mounted() {
this.$set(this.model, 'status', 'Operating')
},
methods: {
handleStatus(val) {
this.model.status = val
},
async getTypeList() {
try {
const res = await getAction('/gardsStations/findType')
this.typeList = res.filter(item => item).map(item => ({ label: item, value: item }))
this.typeList = res.filter((item) => item).map((item) => ({ label: item, value: item }))
} catch (error) {
console.error(error)
}
@ -231,7 +241,7 @@ export default {
async getCountryCodeList() {
try {
const res = await getAction('/gardsStations/findCountryCode')
this.countryCodeList = res.filter(item => item).map(item => ({ label: item, value: item }))
this.countryCodeList = res.filter((item) => item).map((item) => ({ label: item, value: item }))
} catch (error) {
console.error(error)
}
@ -243,14 +253,14 @@ export default {
onAdd() {
this.isAdd = true
this.model = {}
// this.model = {}
this.visible = true
},
onEdit() {
if (this.selectedRowKeys && this.selectedRowKeys.length) {
this.isAdd = false
this.visible = true
const find = this.dataSource.find(item => item.stationId === this.selectedRowKeys[0])
const find = this.dataSource.find((item) => item.stationId === this.selectedRowKeys[0])
this.model = cloneDeep(find)
} else {
this.$message.warn('Please Select An Item To Edit')
@ -264,12 +274,12 @@ export default {
cancelText: 'Cancel',
onOk: () => {
this.handleDelete(this.selectedRowKeys[0], 'stationId')
}
},
})
} else {
this.$message.warn('Please Select An Item To Delete')
}
}
},
},
computed: {
formItems() {
@ -284,12 +294,12 @@ export default {
showSearch: true,
filterOption: this.filterOption,
style: {
width: '261px'
}
width: '261px',
},
},
style: {
width: 'auto'
}
width: 'auto',
},
},
{
label: 'Type',
@ -301,12 +311,12 @@ export default {
showSearch: true,
filterOption: this.filterOption,
style: {
width: '261px'
}
width: '261px',
},
},
style: {
width: 'auto'
}
width: 'auto',
},
},
{
label: 'Status',
@ -318,16 +328,16 @@ export default {
return document.body
},
style: {
width: '261px'
}
width: '261px',
},
},
style: {
width: 'auto'
}
}
width: 'auto',
},
},
]
}
}
},
},
}
</script>