66eb78ed
wuxw
开发采购功能
|
1
|
<template>
|
3d077e99
wuxw
开发完成采购物品功能
|
2
|
<el-dialog :title="$t('resourceStoreSpecificationManage.addSpec')" :visible.sync="visible" width="50%"
|
66eb78ed
wuxw
开发采购功能
|
3
|
@close="handleClose">
|
3d077e99
wuxw
开发完成采购物品功能
|
4
5
6
|
<el-form :model="form" :rules="rules" ref="formRef" label-width="120px">
<el-form-item :label="$t('resourceStoreSpecificationManage.specName')" prop="specName">
<el-input v-model="form.specName" :placeholder="$t('resourceStoreSpecificationManage.specNamePlaceholder')">
|
66eb78ed
wuxw
开发采购功能
|
7
8
|
</el-input>
</el-form-item>
|
3d077e99
wuxw
开发完成采购物品功能
|
9
10
|
<el-form-item :label="$t('resourceStoreSpecificationManage.itemType')" prop="parentRstId"
|
66eb78ed
wuxw
开发采购功能
|
11
12
|
class="item-type-form-item">
<el-col :span="11">
|
3d077e99
wuxw
开发完成采购物品功能
|
13
14
15
|
<el-select v-model="form.parentRstId" :placeholder="$t('resourceStoreSpecificationManage.selectItemType')"
@change="handleParentTypeChange" style="width:100%">
<el-option v-for="item in resourceStoreTypes" :key="item.rstId" :label="item.name" :value="item.rstId">
|
66eb78ed
wuxw
开发采购功能
|
16
17
18
19
|
</el-option>
</el-select>
</el-col>
<el-col :span="11" :offset="2">
|
3d077e99
wuxw
开发完成采购物品功能
|
20
|
<el-select v-model="form.rstId" :placeholder="$t('resourceStoreSpecificationManage.selectSubCategory')"
|
66eb78ed
wuxw
开发采购功能
|
21
|
style="width:100%">
|
3d077e99
wuxw
开发完成采购物品功能
|
22
|
<el-option v-for="item in sonResourceStoreTypes" :key="item.rstId" :label="item.name" :value="item.rstId">
|
66eb78ed
wuxw
开发采购功能
|
23
24
25
26
|
</el-option>
</el-select>
</el-col>
</el-form-item>
|
3d077e99
wuxw
开发完成采购物品功能
|
27
28
29
30
|
<el-form-item :label="$t('resourceStoreSpecificationManage.description')" prop="description">
<el-input type="textarea" v-model="form.description"
:placeholder="$t('resourceStoreSpecificationManage.descriptionPlaceholder')" :rows="3">
|
66eb78ed
wuxw
开发采购功能
|
31
32
33
|
</el-input>
</el-form-item>
</el-form>
|
3d077e99
wuxw
开发完成采购物品功能
|
34
|
|
66eb78ed
wuxw
开发采购功能
|
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
<div slot="footer" class="dialog-footer">
<el-button @click="visible = false">
{{ $t('resourceStoreSpecificationManage.cancel') }}
</el-button>
<el-button type="primary" @click="submitForm">
{{ $t('resourceStoreSpecificationManage.save') }}
</el-button>
</div>
</el-dialog>
</template>
<script>
import { saveResourceStoreSpecification, listResourceStoreTypes } from '@/api/resource/resourceStoreSpecificationManageApi'
export default {
name: 'AddResourceStoreSpecification',
data() {
return {
visible: false,
form: {
specName: '',
parentRstId: '',
rstId: '',
description: ''
},
resourceStoreTypes: [],
sonResourceStoreTypes: [],
rules: {
specName: [
{ required: true, message: this.$t('common.requiredField'), trigger: 'blur' },
{ max: 255, message: this.$t('common.maxLength', { num: 255 }), trigger: 'blur' }
],
parentRstId: [
{ required: true, message: this.$t('common.requiredField'), trigger: 'change' }
],
rstId: [
{ required: true, message: this.$t('common.requiredField'), trigger: 'change' }
],
description: [
{ max: 512, message: this.$t('common.maxLength', { num: 512 }), trigger: 'blur' }
]
}
}
},
methods: {
open() {
this.visible = true
this.getResourceStoreTypes()
},
|
3d077e99
wuxw
开发完成采购物品功能
|
84
|
|
66eb78ed
wuxw
开发采购功能
|
85
86
87
88
89
90
91
|
async getResourceStoreTypes() {
try {
const params = {
page: 1,
row: 100,
parentId: '0'
}
|
3d077e99
wuxw
开发完成采购物品功能
|
92
|
|
66eb78ed
wuxw
开发采购功能
|
93
94
95
96
97
98
|
const res = await listResourceStoreTypes(params)
this.resourceStoreTypes = res.data
} catch (error) {
console.error('Failed to get item types:', error)
}
},
|
3d077e99
wuxw
开发完成采购物品功能
|
99
|
|
66eb78ed
wuxw
开发采购功能
|
100
101
102
103
104
105
106
107
|
async getResourceStoreSonTypes(parentRstId) {
try {
const params = {
page: 1,
row: 100,
rstId: parentRstId,
flag: "0"
}
|
3d077e99
wuxw
开发完成采购物品功能
|
108
|
|
66eb78ed
wuxw
开发采购功能
|
109
110
111
112
113
114
|
const res = await listResourceStoreTypes(params)
this.sonResourceStoreTypes = res.data
} catch (error) {
console.error('Failed to get sub item types:', error)
}
},
|
3d077e99
wuxw
开发完成采购物品功能
|
115
|
|
66eb78ed
wuxw
开发采购功能
|
116
117
118
119
120
121
122
123
|
handleParentTypeChange(val) {
this.form.rstId = ''
if (!val) {
this.sonResourceStoreTypes = []
return
}
this.getResourceStoreSonTypes(val)
},
|
3d077e99
wuxw
开发完成采购物品功能
|
124
|
|
66eb78ed
wuxw
开发采购功能
|
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
submitForm() {
this.$refs.formRef.validate(async valid => {
if (valid) {
try {
await saveResourceStoreSpecification(this.form)
this.$message.success(this.$t('common.saveSuccess'))
this.visible = false
this.$emit('success')
} catch (error) {
console.error('Failed to add specification:', error)
this.$message.error(this.$t('common.saveFailed'))
}
}
})
},
|
3d077e99
wuxw
开发完成采购物品功能
|
140
|
|
66eb78ed
wuxw
开发采购功能
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
handleClose() {
this.$refs.formRef.resetFields()
this.form = {
specName: '',
parentRstId: '',
rstId: '',
description: ''
}
this.sonResourceStoreTypes = []
}
}
}
</script>
<style scoped>
.item-type-form-item {
margin-bottom: 22px;
}
</style>
|