|
@@ -217,14 +217,10 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
|
+import request from '@/utils/request'
|
|
|
|
|
+
|
|
|
export default {
|
|
export default {
|
|
|
name: 'LimitPurchaseRule',
|
|
name: 'LimitPurchaseRule',
|
|
|
- props: {
|
|
|
|
|
- axiosInstance: {
|
|
|
|
|
- type: Object,
|
|
|
|
|
- default: null
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
|
// 列表数据
|
|
// 列表数据
|
|
@@ -274,16 +270,10 @@ export default {
|
|
|
this.fetchProvinces()
|
|
this.fetchProvinces()
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- http() {
|
|
|
|
|
- // 默认用全局 axios,如果父组件传入则优先用父组件的
|
|
|
|
|
- return this.axiosInstance || this.$axios || this.$http
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
// 获取省份数据
|
|
// 获取省份数据
|
|
|
async fetchProvinces() {
|
|
async fetchProvinces() {
|
|
|
- if (!this.http()) return
|
|
|
|
|
try {
|
|
try {
|
|
|
- const response = await this.http().get('/limit_purchase/region/province')
|
|
|
|
|
|
|
+ const response = await request.get('/limit_purchase/region/province')
|
|
|
this.provinces = response.data || []
|
|
this.provinces = response.data || []
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error('获取省份数据失败:', e)
|
|
console.error('获取省份数据失败:', e)
|
|
@@ -293,10 +283,9 @@ export default {
|
|
|
|
|
|
|
|
// ========== 列表相关 ==========
|
|
// ========== 列表相关 ==========
|
|
|
async fetchRuleList() {
|
|
async fetchRuleList() {
|
|
|
- if (!this.http()) return
|
|
|
|
|
this.loading.list = true
|
|
this.loading.list = true
|
|
|
try {
|
|
try {
|
|
|
- const { page } = await this.http().get('/limit_purchase/rule', {
|
|
|
|
|
|
|
+ const { page } = await request.get('/limit_purchase/rule', {
|
|
|
params: {
|
|
params: {
|
|
|
page: this.pagination.page,
|
|
page: this.pagination.page,
|
|
|
limit: this.pagination.pageSize
|
|
limit: this.pagination.pageSize
|
|
@@ -375,12 +364,12 @@ export default {
|
|
|
|
|
|
|
|
submitRuleForm() {
|
|
submitRuleForm() {
|
|
|
this.$refs.ruleFormRef.validate(async (valid) => {
|
|
this.$refs.ruleFormRef.validate(async (valid) => {
|
|
|
- if (!valid || !this.http()) return
|
|
|
|
|
|
|
+ if (!valid) return
|
|
|
this.loading.saveRule = true
|
|
this.loading.saveRule = true
|
|
|
try {
|
|
try {
|
|
|
if (this.ruleForm.id) {
|
|
if (this.ruleForm.id) {
|
|
|
// 更新:名称 + 是否默认 + 状态 + 限购地区
|
|
// 更新:名称 + 是否默认 + 状态 + 限购地区
|
|
|
- await this.http().put(`/limit_purchase/rule/${this.ruleForm.id}`, {
|
|
|
|
|
|
|
+ await request.put(`/limit_purchase/rule/${this.ruleForm.id}`, {
|
|
|
name: this.ruleForm.name,
|
|
name: this.ruleForm.name,
|
|
|
is_default: this.ruleForm.is_default,
|
|
is_default: this.ruleForm.is_default,
|
|
|
status: this.ruleForm.status,
|
|
status: this.ruleForm.status,
|
|
@@ -389,7 +378,7 @@ export default {
|
|
|
this.$message.success('更新成功')
|
|
this.$message.success('更新成功')
|
|
|
} else {
|
|
} else {
|
|
|
// 创建:名称 + 是否默认 + 状态 + 限购地区
|
|
// 创建:名称 + 是否默认 + 状态 + 限购地区
|
|
|
- await this.http().post('/limit_purchase/rule', {
|
|
|
|
|
|
|
+ await request.post('/limit_purchase/rule', {
|
|
|
name: this.ruleForm.name,
|
|
name: this.ruleForm.name,
|
|
|
is_default: this.ruleForm.is_default,
|
|
is_default: this.ruleForm.is_default,
|
|
|
status: this.ruleForm.status,
|
|
status: this.ruleForm.status,
|
|
@@ -409,13 +398,12 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handleDeleteRule(row) {
|
|
handleDeleteRule(row) {
|
|
|
- if (!this.http()) return
|
|
|
|
|
this.$confirm(`确认删除规则「${row.name}」吗?`, '提示', {
|
|
this.$confirm(`确认删除规则「${row.name}」吗?`, '提示', {
|
|
|
type: 'warning'
|
|
type: 'warning'
|
|
|
})
|
|
})
|
|
|
.then(async () => {
|
|
.then(async () => {
|
|
|
try {
|
|
try {
|
|
|
- const {code,msg} = await this.http().delete(`/limit_purchase/rule/${row.id}`)
|
|
|
|
|
|
|
+ const {code, msg} = await request.delete(`/limit_purchase/rule/${row.id}`)
|
|
|
if (code === 0 || code === 200) {
|
|
if (code === 0 || code === 200) {
|
|
|
this.$message.success('删除成功')
|
|
this.$message.success('删除成功')
|
|
|
this.fetchRuleList()
|
|
this.fetchRuleList()
|
|
@@ -445,7 +433,7 @@ export default {
|
|
|
const province = this.provinces.find(p => p.name === this.selectedProvince)
|
|
const province = this.provinces.find(p => p.name === this.selectedProvince)
|
|
|
if (province) {
|
|
if (province) {
|
|
|
// 获取城市数据
|
|
// 获取城市数据
|
|
|
- const response = await this.http().get(`/limit_purchase/region/city/${province.code}`)
|
|
|
|
|
|
|
+ const response = await request.get(`/limit_purchase/region/city/${province.code}`)
|
|
|
this.cities = response.data || []
|
|
this.cities = response.data || []
|
|
|
}
|
|
}
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
@@ -466,7 +454,7 @@ export default {
|
|
|
if (province) {
|
|
if (province) {
|
|
|
const city = this.cities.find(c => c.name === this.selectedCity)
|
|
const city = this.cities.find(c => c.name === this.selectedCity)
|
|
|
if (city) {
|
|
if (city) {
|
|
|
- const response = await this.http().get(`/limit_purchase/region/area/${city.code}`)
|
|
|
|
|
|
|
+ const response = await request.get(`/limit_purchase/region/area/${city.code}`)
|
|
|
this.areas = response.data || []
|
|
this.areas = response.data || []
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -647,4 +635,4 @@ export default {
|
|
|
margin-top: 5px;
|
|
margin-top: 5px;
|
|
|
margin-bottom: 15px;
|
|
margin-bottom: 15px;
|
|
|
}
|
|
}
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|