系统管理模块台站部分 新增和修改窗口 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 = '') { handleInput(e = '') {
console.log('qweq', e)
let val let val
if (Object.keys(e).includes('target')) { if (Object.keys(e).includes('target')) {
val = e.target.value val = e.target.value
} else { } else {
val = e val = e
} }
console.log(val)
this.$emit('change', val ? val : undefined) this.$emit('change', val ? val : undefined)
//LOWCOD-2146 SQL //LOWCOD-2146 SQL
this.$emit('input', val ? val : undefined) this.$emit('input', val ? val : undefined)

View File

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