系统管理模块台站部分 新增和编辑弹窗增加CATEGORY字段

增加/sys/dict/getltems接口及联调
保存和修改接口增加请求字段
This commit is contained in:
任珮宇 2024-03-06 16:25:37 +08:00
parent ada699cc13
commit 1c1e5d2f26

View File

@ -85,6 +85,18 @@
@change="handleStatus" @change="handleStatus"
></j-dict-select-tag> ></j-dict-select-tag>
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="Category" prop="category">
<a-select
v-model="model.category"
:options="categoryOptions"
show-arrow
allowClear
placeholder="select..."
@change="onCategoryChange"
>
<img slot="suffixIcon" src="@/assets/images/global/select-down.png" alt="" />
</a-select>
</a-form-model-item>
</a-form-model> </a-form-model>
</custom-modal> </custom-modal>
<!-- 新增/编辑 结束 --> <!-- 新增/编辑 结束 -->
@ -201,12 +213,14 @@ export default {
} }
} }
return { return {
categoryOptions: [],
queryParam: {}, queryParam: {},
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' }], status: [{ required: true, message: 'Please Select Status', trigger: 'change' }],
category: [{ required: true, message: 'Please Select Category', trigger: 'change' }],
}, },
url: { url: {
list: '/gardsStations/findPage', list: '/gardsStations/findPage',
@ -226,6 +240,23 @@ export default {
this.$set(this.model, 'status', 'Operating') this.$set(this.model, 'status', 'Operating')
}, },
methods: { methods: {
async getCategoryItem() {
try {
const res = await getAction('/sys/dict/getItems', { dictCode: 'Station Category' })
console.log(res)
this.categoryOptions = res.map((item) => {
return {
label: item.text,
value: item.value,
}
})
} catch (error) {
console.error(error)
}
},
onCategoryChange(val) {
console.log(val)
},
handleStatus(val) { handleStatus(val) {
this.model.status = val this.model.status = val
}, },
@ -252,15 +283,20 @@ export default {
}, },
onAdd() { onAdd() {
this.getCategoryItem()
this.isAdd = true this.isAdd = true
// this.model = {} // this.model = {}
this.visible = true this.visible = true
}, },
onEdit() { onEdit() {
this.getCategoryItem()
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])
if (find) {
find.category = find.category.toString()
}
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')