|
@@ -2,12 +2,14 @@
|
|
|
<div class="limit-purchase-rule-container">
|
|
<div class="limit-purchase-rule-container">
|
|
|
<!-- 规则列表区域 -->
|
|
<!-- 规则列表区域 -->
|
|
|
<el-card class="rule-list-card">
|
|
<el-card class="rule-list-card">
|
|
|
- <div slot="header" class="card-header">
|
|
|
|
|
- <span>限购规则列表</span>
|
|
|
|
|
- <el-button type="primary" size="small" @click="handleCreateRule">
|
|
|
|
|
- 新建规则
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ <template #header>
|
|
|
|
|
+ <div class="card-header">
|
|
|
|
|
+ <span>限购规则列表</span>
|
|
|
|
|
+ <el-button type="primary" size="small" @click="handleCreateRule">
|
|
|
|
|
+ 新建规则
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
|
|
|
<el-table
|
|
<el-table
|
|
|
v-loading="loading.list"
|
|
v-loading="loading.list"
|
|
@@ -18,13 +20,13 @@
|
|
|
<el-table-column prop="id" label="ID" width="80" />
|
|
<el-table-column prop="id" label="ID" width="80" />
|
|
|
<el-table-column prop="name" label="规则名称" min-width="160" />
|
|
<el-table-column prop="name" label="规则名称" min-width="160" />
|
|
|
<el-table-column label="限购地区" min-width="260">
|
|
<el-table-column label="限购地区" min-width="260">
|
|
|
- <template slot-scope="scope">
|
|
|
|
|
|
|
+ <template #default="scope">
|
|
|
<div v-if="scope.row.regions && scope.row.regions.length">
|
|
<div v-if="scope.row.regions && scope.row.regions.length">
|
|
|
<el-tag
|
|
<el-tag
|
|
|
v-for="(region, index) in scope.row.regions"
|
|
v-for="(region, index) in scope.row.regions"
|
|
|
:key="index"
|
|
:key="index"
|
|
|
type="danger"
|
|
type="danger"
|
|
|
- size="mini"
|
|
|
|
|
|
|
+ size="small"
|
|
|
class="region-tag"
|
|
class="region-tag"
|
|
|
>
|
|
>
|
|
|
{{ formatRegionLabel(region) }}
|
|
{{ formatRegionLabel(region) }}
|
|
@@ -33,33 +35,48 @@
|
|
|
<span v-else class="text-muted">未设置</span>
|
|
<span v-else class="text-muted">未设置</span>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
|
|
+ <el-table-column prop="is_default" label="默认规则" width="100">
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <el-tag :type="scope.row.is_default ? 'success' : 'info'" size="small">
|
|
|
|
|
+ {{ scope.row.is_default ? '是' : '否' }}
|
|
|
|
|
+ </el-tag>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="status" label="状态" width="100">
|
|
<el-table-column prop="status" label="状态" width="100">
|
|
|
- <template slot-scope="scope">
|
|
|
|
|
|
|
+ <template #default="scope">
|
|
|
<el-tag :type="scope.row.status === 1 ? 'success' : 'info'" size="small">
|
|
<el-tag :type="scope.row.status === 1 ? 'success' : 'info'" size="small">
|
|
|
{{ scope.row.status === 1 ? '启用' : '停用' }}
|
|
{{ scope.row.status === 1 ? '启用' : '停用' }}
|
|
|
</el-tag>
|
|
</el-tag>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" width="200" fixed="right">
|
|
<el-table-column label="操作" width="200" fixed="right">
|
|
|
- <template slot-scope="scope">
|
|
|
|
|
- <el-button type="text" size="small" @click="handleEditRule(scope.row)">
|
|
|
|
|
|
|
+ <template #default="scope">
|
|
|
|
|
+ <el-button type="primary" link size="small" @click="handleEditRule(scope.row)">
|
|
|
编辑
|
|
编辑
|
|
|
</el-button>
|
|
</el-button>
|
|
|
- <el-button type="text" size="small" @click="handleEditRegions(scope.row)">
|
|
|
|
|
- 设置限购地区
|
|
|
|
|
- </el-button>
|
|
|
|
|
- <el-button type="text" size="small" class="danger-text" @click="handleDeleteRule(scope.row)">
|
|
|
|
|
|
|
+ <el-button type="danger" link size="small" @click="handleDeleteRule(scope.row)">
|
|
|
删除
|
|
删除
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 分页组件 -->
|
|
|
|
|
+ <el-pagination
|
|
|
|
|
+ v-if="pagination.total > 0"
|
|
|
|
|
+ layout="prev, pager, next"
|
|
|
|
|
+ :current-page="pagination.page"
|
|
|
|
|
+ :page-size="pagination.pageSize"
|
|
|
|
|
+ :total="pagination.total"
|
|
|
|
|
+ @current-change="handlePageChange"
|
|
|
|
|
+ style="margin-top: 20px; text-align: right;"
|
|
|
|
|
+ />
|
|
|
</el-card>
|
|
</el-card>
|
|
|
|
|
|
|
|
<!-- 规则表单弹窗:新建 / 编辑规则基本信息 -->
|
|
<!-- 规则表单弹窗:新建 / 编辑规则基本信息 -->
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
:title="ruleForm.id ? '编辑限购规则' : '新建限购规则'"
|
|
:title="ruleForm.id ? '编辑限购规则' : '新建限购规则'"
|
|
|
- :visible.sync="ruleDialog.visible"
|
|
|
|
|
|
|
+ v-model="ruleDialog.visible"
|
|
|
width="720px"
|
|
width="720px"
|
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
|
>
|
|
>
|
|
@@ -72,20 +89,30 @@
|
|
|
<el-form-item label="规则名称" prop="name">
|
|
<el-form-item label="规则名称" prop="name">
|
|
|
<el-input v-model="ruleForm.name" maxlength="64" show-word-limit />
|
|
<el-input v-model="ruleForm.name" maxlength="64" show-word-limit />
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
+ <el-form-item label="是否默认" prop="is_default">
|
|
|
|
|
+ <el-switch
|
|
|
|
|
+ v-model="ruleForm.is_default"
|
|
|
|
|
+ :active-value="1"
|
|
|
|
|
+ :inactive-value="0"
|
|
|
|
|
+ />
|
|
|
|
|
+ <div class="form-tip">设置默认后未设置限购规则的商品都使用该规则</div>
|
|
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="状态" prop="status">
|
|
<el-form-item label="状态" prop="status">
|
|
|
<el-switch
|
|
<el-switch
|
|
|
v-model="ruleForm.status"
|
|
v-model="ruleForm.status"
|
|
|
:active-value="1"
|
|
:active-value="1"
|
|
|
:inactive-value="0"
|
|
:inactive-value="0"
|
|
|
|
|
+ active-text="启用"
|
|
|
|
|
+ inactive-text="停用"
|
|
|
/>
|
|
/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 在新建 / 编辑规则里直接设置限购地区(本地省市区 JSON 级联) -->
|
|
<!-- 在新建 / 编辑规则里直接设置限购地区(本地省市区 JSON 级联) -->
|
|
|
<el-form-item label="限购地区">
|
|
<el-form-item label="限购地区">
|
|
|
<div class="region-selector-wrapper">
|
|
<div class="region-selector-wrapper">
|
|
|
- <el-form label-width="60px" class="region-form inner-region-form">
|
|
|
|
|
- <el-row :gutter="20" type="flex" align="middle">
|
|
|
|
|
- <el-col :span="6">
|
|
|
|
|
|
|
+ <el-form label-width="60px" class="region-form">
|
|
|
|
|
+ <el-row :gutter="20" align="middle">
|
|
|
|
|
+ <el-col :span="8">
|
|
|
<el-form-item label="省份">
|
|
<el-form-item label="省份">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="selectedProvince"
|
|
v-model="selectedProvince"
|
|
@@ -96,57 +123,60 @@
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="p in provinces"
|
|
v-for="p in provinces"
|
|
|
- :key="p.name"
|
|
|
|
|
|
|
+ :key="p.code"
|
|
|
:label="p.name"
|
|
:label="p.name"
|
|
|
:value="p.name"
|
|
:value="p.name"
|
|
|
/>
|
|
/>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
- <el-col :span="6">
|
|
|
|
|
- <el-form-item label="城市">
|
|
|
|
|
|
|
+ <el-col :span="8">
|
|
|
|
|
+ <el-form-item label="城市" v-show="!isMunicipalitySelected()">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="selectedCity"
|
|
v-model="selectedCity"
|
|
|
placeholder="请选择城市"
|
|
placeholder="请选择城市"
|
|
|
- :disabled="!selectedProvince"
|
|
|
|
|
|
|
+ :disabled="!selectedProvince || isMunicipalitySelected()"
|
|
|
filterable
|
|
filterable
|
|
|
clearable
|
|
clearable
|
|
|
@change="onCityChange"
|
|
@change="onCityChange"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="c in cities"
|
|
v-for="c in cities"
|
|
|
- :key="c.name"
|
|
|
|
|
|
|
+ :key="c.code"
|
|
|
:label="c.name"
|
|
:label="c.name"
|
|
|
:value="c.name"
|
|
:value="c.name"
|
|
|
/>
|
|
/>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
- <el-col :span="6">
|
|
|
|
|
|
|
+ <el-col :span="8">
|
|
|
<el-form-item label="区县">
|
|
<el-form-item label="区县">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="selectedArea"
|
|
v-model="selectedArea"
|
|
|
placeholder="请选择区县"
|
|
placeholder="请选择区县"
|
|
|
- :disabled="!selectedCity"
|
|
|
|
|
|
|
+ :disabled="!selectedProvince || (!selectedCity && !isMunicipalitySelected())"
|
|
|
filterable
|
|
filterable
|
|
|
clearable
|
|
clearable
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="a in areas"
|
|
v-for="a in areas"
|
|
|
- :key="a"
|
|
|
|
|
- :label="a"
|
|
|
|
|
- :value="a"
|
|
|
|
|
|
|
+ :key="a.code"
|
|
|
|
|
+ :label="a.name"
|
|
|
|
|
+ :value="a.name"
|
|
|
/>
|
|
/>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
- <el-col :span="6" class="text-right">
|
|
|
|
|
|
|
+ </el-row>
|
|
|
|
|
+ <el-row :gutter="20">
|
|
|
|
|
+ <el-col :span="24" class="text-right" style="margin-top: 10px;">
|
|
|
<el-button type="primary" @click="addRegion">
|
|
<el-button type="primary" @click="addRegion">
|
|
|
- <i class="el-icon-plus" /> 添加限购地区
|
|
|
|
|
|
|
+ 添加限购地区
|
|
|
</el-button>
|
|
</el-button>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
|
|
+ <div class="region-tip">注:可只选择到省或市层级</div>
|
|
|
|
|
|
|
|
<div class="limited-region-list">
|
|
<div class="limited-region-list">
|
|
|
<div class="list-title">已设置的限购地区</div>
|
|
<div class="list-title">已设置的限购地区</div>
|
|
@@ -160,9 +190,8 @@
|
|
|
>
|
|
>
|
|
|
<span>{{ formatRegionLabel(area) }}</span>
|
|
<span>{{ formatRegionLabel(area) }}</span>
|
|
|
<el-button
|
|
<el-button
|
|
|
- type="text"
|
|
|
|
|
- class="danger-text"
|
|
|
|
|
- icon="el-icon-delete"
|
|
|
|
|
|
|
+ type="danger"
|
|
|
|
|
+ link
|
|
|
@click="removeRegion(index)"
|
|
@click="removeRegion(index)"
|
|
|
>
|
|
>
|
|
|
删除
|
|
删除
|
|
@@ -173,186 +202,194 @@
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
|
|
|
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
|
|
- <el-button @click="ruleDialog.visible = false">取 消</el-button>
|
|
|
|
|
- <el-button type="primary" :loading="loading.saveRule" @click="submitRuleForm">
|
|
|
|
|
- 确 认
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </span>
|
|
|
|
|
|
|
+ <template #footer>
|
|
|
|
|
+ <span class="dialog-footer">
|
|
|
|
|
+ <el-button @click="ruleDialog.visible = false">取 消</el-button>
|
|
|
|
|
+ <el-button type="primary" :loading="loading.saveRule" @click="submitRuleForm">
|
|
|
|
|
+ 确 认
|
|
|
|
|
+ </el-button>
|
|
|
|
|
+ </span>
|
|
|
|
|
+ </template>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
|
|
|
- <!-- 地区设置弹窗:管理单条规则下的多个限购地区 -->
|
|
|
|
|
- <el-dialog
|
|
|
|
|
- title="设置限购地区"
|
|
|
|
|
- :visible.sync="regionDialog.visible"
|
|
|
|
|
- width="720px"
|
|
|
|
|
- :close-on-click-modal="false"
|
|
|
|
|
- >
|
|
|
|
|
- <div class="region-selector-wrapper">
|
|
|
|
|
- <div class="region-selector-title">
|
|
|
|
|
- <i class="el-icon-warning-outline text-danger" />
|
|
|
|
|
- <span> 设置限购地区</span>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
|
|
|
- <el-form label-width="60px" class="region-form">
|
|
|
|
|
- <el-row :gutter="20" type="flex" align="middle">
|
|
|
|
|
- <el-col :span="6">
|
|
|
|
|
- <el-form-item label="省份">
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="selectedProvince"
|
|
|
|
|
- placeholder="请选择省份"
|
|
|
|
|
- filterable
|
|
|
|
|
- clearable
|
|
|
|
|
- @change="onProvinceChange"
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="p in provinces"
|
|
|
|
|
- :key="p.name"
|
|
|
|
|
- :label="p.name"
|
|
|
|
|
- :value="p.name"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="6">
|
|
|
|
|
- <el-form-item label="城市">
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="selectedCity"
|
|
|
|
|
- placeholder="请选择城市"
|
|
|
|
|
- :disabled="!selectedProvince"
|
|
|
|
|
- filterable
|
|
|
|
|
- clearable
|
|
|
|
|
- @change="onCityChange"
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="c in cities"
|
|
|
|
|
- :key="c.name"
|
|
|
|
|
- :label="c.name"
|
|
|
|
|
- :value="c.name"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="6">
|
|
|
|
|
- <el-form-item label="区县">
|
|
|
|
|
- <el-select
|
|
|
|
|
- v-model="selectedArea"
|
|
|
|
|
- placeholder="请选择区县"
|
|
|
|
|
- :disabled="!selectedCity"
|
|
|
|
|
- filterable
|
|
|
|
|
- clearable
|
|
|
|
|
- >
|
|
|
|
|
- <el-option
|
|
|
|
|
- v-for="a in areas"
|
|
|
|
|
- :key="a"
|
|
|
|
|
- :label="a"
|
|
|
|
|
- :value="a"
|
|
|
|
|
- />
|
|
|
|
|
- </el-select>
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- <el-col :span="6" class="text-right">
|
|
|
|
|
- <el-button type="primary" @click="addRegion">
|
|
|
|
|
- <i class="el-icon-plus" /> 添加限购地区
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </el-col>
|
|
|
|
|
- </el-row>
|
|
|
|
|
- </el-form>
|
|
|
|
|
-
|
|
|
|
|
- <div class="limited-region-list">
|
|
|
|
|
- <div class="list-title">已设置的限购地区</div>
|
|
|
|
|
- <div v-if="currentRuleRegions.length === 0" class="empty-tip">
|
|
|
|
|
- 暂未添加限购地区
|
|
|
|
|
- </div>
|
|
|
|
|
- <div
|
|
|
|
|
- v-for="(area, index) in currentRuleRegions"
|
|
|
|
|
- :key="index"
|
|
|
|
|
- class="limited-area-item"
|
|
|
|
|
- >
|
|
|
|
|
- <span>{{ formatRegionLabel(area) }}</span>
|
|
|
|
|
- <el-button
|
|
|
|
|
- type="text"
|
|
|
|
|
- class="danger-text"
|
|
|
|
|
- icon="el-icon-delete"
|
|
|
|
|
- @click="removeRegion(index)"
|
|
|
|
|
- >
|
|
|
|
|
- 删除
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
-
|
|
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
|
|
- <el-button @click="regionDialog.visible = false">取 消</el-button>
|
|
|
|
|
- <el-button type="primary" :loading="loading.saveRegions" @click="submitRegions">
|
|
|
|
|
- 确 认 设置
|
|
|
|
|
- </el-button>
|
|
|
|
|
- </span>
|
|
|
|
|
- </el-dialog>
|
|
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
-// 前端内置省市区 JSON,不走接口
|
|
|
|
|
-// 这里只演示北京和天津两组数据,后续可按同样格式扩展
|
|
|
|
|
-const REGION_TREE = [
|
|
|
|
|
- {
|
|
|
|
|
- name: '北京市',
|
|
|
|
|
- city: [
|
|
|
|
|
- {
|
|
|
|
|
- name: '北京市',
|
|
|
|
|
- area: [
|
|
|
|
|
- '东城区',
|
|
|
|
|
- '西城区',
|
|
|
|
|
- '崇文区',
|
|
|
|
|
- '宣武区',
|
|
|
|
|
- '朝阳区',
|
|
|
|
|
- '丰台区',
|
|
|
|
|
- '石景山区',
|
|
|
|
|
- '海淀区',
|
|
|
|
|
- '门头沟区',
|
|
|
|
|
- '房山区',
|
|
|
|
|
- '通州区',
|
|
|
|
|
- '顺义区',
|
|
|
|
|
- '昌平区',
|
|
|
|
|
- '大兴区',
|
|
|
|
|
- '平谷区',
|
|
|
|
|
- '怀柔区',
|
|
|
|
|
- '密云县',
|
|
|
|
|
- '延庆县'
|
|
|
|
|
- ]
|
|
|
|
|
- }
|
|
|
|
|
- ]
|
|
|
|
|
- },
|
|
|
|
|
- {
|
|
|
|
|
- name: '天津市',
|
|
|
|
|
- city: [
|
|
|
|
|
- {
|
|
|
|
|
- name: '天津市',
|
|
|
|
|
- area: [
|
|
|
|
|
- '和平区',
|
|
|
|
|
- '河东区',
|
|
|
|
|
- '河西区',
|
|
|
|
|
- '南开区',
|
|
|
|
|
- '河北区',
|
|
|
|
|
- '红桥区',
|
|
|
|
|
- '塘沽区',
|
|
|
|
|
- '汉沽区',
|
|
|
|
|
- '大港区',
|
|
|
|
|
- '东丽区',
|
|
|
|
|
- '西青区',
|
|
|
|
|
- '津南区',
|
|
|
|
|
- '北辰区',
|
|
|
|
|
- '武清区',
|
|
|
|
|
- '宝坻区',
|
|
|
|
|
- '宁河县',
|
|
|
|
|
- '静海县',
|
|
|
|
|
- '蓟县'
|
|
|
|
|
- ]
|
|
|
|
|
- }
|
|
|
|
|
- ]
|
|
|
|
|
|
|
+// 省级数据
|
|
|
|
|
+const PROVINCES = [
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "110000",
|
|
|
|
|
+ "name": "北京市",
|
|
|
|
|
+ "province": "11"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "120000",
|
|
|
|
|
+ "name": "天津市",
|
|
|
|
|
+ "province": "12"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "130000",
|
|
|
|
|
+ "name": "河北省",
|
|
|
|
|
+ "province": "13"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "140000",
|
|
|
|
|
+ "name": "山西省",
|
|
|
|
|
+ "province": "14"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "150000",
|
|
|
|
|
+ "name": "内蒙古自治区",
|
|
|
|
|
+ "province": "15"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "210000",
|
|
|
|
|
+ "name": "辽宁省",
|
|
|
|
|
+ "province": "21"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "220000",
|
|
|
|
|
+ "name": "吉林省",
|
|
|
|
|
+ "province": "22"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "230000",
|
|
|
|
|
+ "name": "黑龙江省",
|
|
|
|
|
+ "province": "23"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "310000",
|
|
|
|
|
+ "name": "上海市",
|
|
|
|
|
+ "province": "31"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "320000",
|
|
|
|
|
+ "name": "江苏省",
|
|
|
|
|
+ "province": "32"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "330000",
|
|
|
|
|
+ "name": "浙江省",
|
|
|
|
|
+ "province": "33"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "340000",
|
|
|
|
|
+ "name": "安徽省",
|
|
|
|
|
+ "province": "34"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "350000",
|
|
|
|
|
+ "name": "福建省",
|
|
|
|
|
+ "province": "35"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "360000",
|
|
|
|
|
+ "name": "江西省",
|
|
|
|
|
+ "province": "36"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "370000",
|
|
|
|
|
+ "name": "山东省",
|
|
|
|
|
+ "province": "37"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "410000",
|
|
|
|
|
+ "name": "河南省",
|
|
|
|
|
+ "province": "41"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "420000",
|
|
|
|
|
+ "name": "湖北省",
|
|
|
|
|
+ "province": "42"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "430000",
|
|
|
|
|
+ "name": "湖南省",
|
|
|
|
|
+ "province": "43"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "440000",
|
|
|
|
|
+ "name": "广东省",
|
|
|
|
|
+ "province": "44"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "450000",
|
|
|
|
|
+ "name": "广西壮族自治区",
|
|
|
|
|
+ "province": "45"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "460000",
|
|
|
|
|
+ "name": "海南省",
|
|
|
|
|
+ "province": "46"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "500000",
|
|
|
|
|
+ "name": "重庆市",
|
|
|
|
|
+ "province": "50"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "510000",
|
|
|
|
|
+ "name": "四川省",
|
|
|
|
|
+ "province": "51"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "520000",
|
|
|
|
|
+ "name": "贵州省",
|
|
|
|
|
+ "province": "52"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "530000",
|
|
|
|
|
+ "name": "云南省",
|
|
|
|
|
+ "province": "53"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "540000",
|
|
|
|
|
+ "name": "西藏自治区",
|
|
|
|
|
+ "province": "54"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "610000",
|
|
|
|
|
+ "name": "陕西省",
|
|
|
|
|
+ "province": "61"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "620000",
|
|
|
|
|
+ "name": "甘肃省",
|
|
|
|
|
+ "province": "62"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "630000",
|
|
|
|
|
+ "name": "青海省",
|
|
|
|
|
+ "province": "63"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "640000",
|
|
|
|
|
+ "name": "宁夏回族自治区",
|
|
|
|
|
+ "province": "64"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "650000",
|
|
|
|
|
+ "name": "新疆维吾尔自治区",
|
|
|
|
|
+ "province": "65"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "710000",
|
|
|
|
|
+ "name": "台湾省",
|
|
|
|
|
+ "province": "71"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "810000",
|
|
|
|
|
+ "name": "香港特别行政区",
|
|
|
|
|
+ "province": "81"
|
|
|
|
|
+ },
|
|
|
|
|
+ {
|
|
|
|
|
+ "code": "820000",
|
|
|
|
|
+ "name": "澳门特别行政区",
|
|
|
|
|
+ "province": "82"
|
|
|
}
|
|
}
|
|
|
-]
|
|
|
|
|
|
|
+];
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
|
name: 'LimitPurchaseRule',
|
|
name: 'LimitPurchaseRule',
|
|
@@ -368,8 +405,15 @@ export default {
|
|
|
ruleList: [],
|
|
ruleList: [],
|
|
|
loading: {
|
|
loading: {
|
|
|
list: false,
|
|
list: false,
|
|
|
- saveRule: false,
|
|
|
|
|
- saveRegions: false
|
|
|
|
|
|
|
+ saveRule: false
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 分页数据
|
|
|
|
|
+ pagination: {
|
|
|
|
|
+ page: 1,
|
|
|
|
|
+ pageSize: 15,
|
|
|
|
|
+ total: 0,
|
|
|
|
|
+ hasMore: false
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 规则表单
|
|
// 规则表单
|
|
@@ -379,6 +423,7 @@ export default {
|
|
|
ruleForm: {
|
|
ruleForm: {
|
|
|
id: null,
|
|
id: null,
|
|
|
name: '',
|
|
name: '',
|
|
|
|
|
+ is_default: 0,
|
|
|
status: 1
|
|
status: 1
|
|
|
},
|
|
},
|
|
|
ruleRules: {
|
|
ruleRules: {
|
|
@@ -387,19 +432,18 @@ export default {
|
|
|
]
|
|
]
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // 地区相关
|
|
|
|
|
- regionDialog: {
|
|
|
|
|
- visible: false,
|
|
|
|
|
- ruleId: null
|
|
|
|
|
- },
|
|
|
|
|
|
|
+
|
|
|
// 使用本地省市区 JSON 级联
|
|
// 使用本地省市区 JSON 级联
|
|
|
- provinces: REGION_TREE,
|
|
|
|
|
|
|
+ provinces: PROVINCES,
|
|
|
cities: [],
|
|
cities: [],
|
|
|
areas: [],
|
|
areas: [],
|
|
|
selectedProvince: '',
|
|
selectedProvince: '',
|
|
|
selectedCity: '',
|
|
selectedCity: '',
|
|
|
selectedArea: '',
|
|
selectedArea: '',
|
|
|
- currentRuleRegions: [] // 当前规则下的地区数组
|
|
|
|
|
|
|
+ currentRuleRegions: [], // 当前规则下的地区数组
|
|
|
|
|
+
|
|
|
|
|
+ // 直辖市编码列表
|
|
|
|
|
+ municipalityCodes: ['11', '12', '31', '50'] // 北京、天津、上海、重庆
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
created() {
|
|
created() {
|
|
@@ -410,15 +454,45 @@ export default {
|
|
|
// 默认用全局 axios,如果父组件传入则优先用父组件的
|
|
// 默认用全局 axios,如果父组件传入则优先用父组件的
|
|
|
return this.axiosInstance || this.$axios || this.$http
|
|
return this.axiosInstance || this.$axios || this.$http
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ // 判断是否为直辖市
|
|
|
|
|
+ isMunicipality(provinceCode) {
|
|
|
|
|
+ if (!provinceCode) return false;
|
|
|
|
|
+ // 提取前两位作为省份编码进行判断
|
|
|
|
|
+ const provincePrefix = provinceCode.substring(0, 2);
|
|
|
|
|
+ return this.municipalityCodes.includes(provincePrefix);
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ // 判断当前选中的省份是否为直辖市
|
|
|
|
|
+ isMunicipalitySelected() {
|
|
|
|
|
+ if (!this.selectedProvince) return false;
|
|
|
|
|
+ const province = PROVINCES.find(p => p.name === this.selectedProvince);
|
|
|
|
|
+ return province ? this.isMunicipality(province.code) : false;
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
// ========== 列表相关 ==========
|
|
// ========== 列表相关 ==========
|
|
|
async fetchRuleList() {
|
|
async fetchRuleList() {
|
|
|
if (!this.http()) return
|
|
if (!this.http()) return
|
|
|
this.loading.list = true
|
|
this.loading.list = true
|
|
|
try {
|
|
try {
|
|
|
- const { data } = await this.http().get('/limit_purchase/rule')
|
|
|
|
|
- // 按项目通用返回结构处理
|
|
|
|
|
- this.ruleList = Array.isArray(data?.data) ? data.data : (data || [])
|
|
|
|
|
|
|
+ const { page } = await this.http().get('/limit_purchase/rule', {
|
|
|
|
|
+ params: {
|
|
|
|
|
+ page: this.pagination.page,
|
|
|
|
|
+ limit: this.pagination.pageSize
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 根据分页数据结构处理
|
|
|
|
|
+ if (page) {
|
|
|
|
|
+ this.ruleList = Array.isArray(page.data) ? page.data : []
|
|
|
|
|
+ this.pagination.total = page.total || 0
|
|
|
|
|
+ this.pagination.hasMore = page.has_more || false
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 兼容旧的数据结构
|
|
|
|
|
+ this.ruleList = []
|
|
|
|
|
+ this.pagination.total = 0
|
|
|
|
|
+ this.pagination.hasMore = false
|
|
|
|
|
+ }
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.error(e)
|
|
console.error(e)
|
|
|
this.$message.error('加载规则列表失败')
|
|
this.$message.error('加载规则列表失败')
|
|
@@ -426,11 +500,17 @@ export default {
|
|
|
this.loading.list = false
|
|
this.loading.list = false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+
|
|
|
|
|
+ handlePageChange(page) {
|
|
|
|
|
+ this.pagination.page = page
|
|
|
|
|
+ this.fetchRuleList()
|
|
|
|
|
+ },
|
|
|
|
|
|
|
|
handleCreateRule() {
|
|
handleCreateRule() {
|
|
|
this.ruleForm = {
|
|
this.ruleForm = {
|
|
|
id: null,
|
|
id: null,
|
|
|
name: '',
|
|
name: '',
|
|
|
|
|
+ is_default: 0,
|
|
|
status: 1
|
|
status: 1
|
|
|
}
|
|
}
|
|
|
// 新建规则时清空当前规则地区
|
|
// 新建规则时清空当前规则地区
|
|
@@ -443,7 +523,9 @@ export default {
|
|
|
|
|
|
|
|
this.ruleDialog.visible = true
|
|
this.ruleDialog.visible = true
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.ruleFormRef && this.$refs.ruleFormRef.clearValidate()
|
|
|
|
|
|
|
+ if (this.$refs.ruleFormRef && typeof this.$refs.ruleFormRef.clearValidate === 'function') {
|
|
|
|
|
+ this.$refs.ruleFormRef.clearValidate()
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -451,6 +533,7 @@ export default {
|
|
|
this.ruleForm = {
|
|
this.ruleForm = {
|
|
|
id: row.id,
|
|
id: row.id,
|
|
|
name: row.name,
|
|
name: row.name,
|
|
|
|
|
+ is_default: row.is_default || 0,
|
|
|
status: row.status
|
|
status: row.status
|
|
|
}
|
|
}
|
|
|
// 编辑规则时加载该规则已有的地区
|
|
// 编辑规则时加载该规则已有的地区
|
|
@@ -463,27 +546,31 @@ export default {
|
|
|
|
|
|
|
|
this.ruleDialog.visible = true
|
|
this.ruleDialog.visible = true
|
|
|
this.$nextTick(() => {
|
|
this.$nextTick(() => {
|
|
|
- this.$refs.ruleFormRef && this.$refs.ruleFormRef.clearValidate()
|
|
|
|
|
|
|
+ if (this.$refs.ruleFormRef && typeof this.$refs.ruleFormRef.clearValidate === 'function') {
|
|
|
|
|
+ this.$refs.ruleFormRef.clearValidate()
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
submitRuleForm() {
|
|
submitRuleForm() {
|
|
|
- this.$refs.ruleFormRef.validate(async valid => {
|
|
|
|
|
|
|
+ this.$refs.ruleFormRef.validate(async (valid) => {
|
|
|
if (!valid || !this.http()) return
|
|
if (!valid || !this.http()) 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 this.http().put(`/limit_purchase/rule/${this.ruleForm.id}`, {
|
|
|
name: this.ruleForm.name,
|
|
name: this.ruleForm.name,
|
|
|
|
|
+ is_default: this.ruleForm.is_default,
|
|
|
status: this.ruleForm.status,
|
|
status: this.ruleForm.status,
|
|
|
regions: this.currentRuleRegions
|
|
regions: this.currentRuleRegions
|
|
|
})
|
|
})
|
|
|
this.$message.success('更新成功')
|
|
this.$message.success('更新成功')
|
|
|
} else {
|
|
} else {
|
|
|
- // 创建:名称 + 状态 + 限购地区
|
|
|
|
|
|
|
+ // 创建:名称 + 是否默认 + 状态 + 限购地区
|
|
|
await this.http().post('/limit_purchase/rule', {
|
|
await this.http().post('/limit_purchase/rule', {
|
|
|
name: this.ruleForm.name,
|
|
name: this.ruleForm.name,
|
|
|
|
|
+ is_default: this.ruleForm.is_default,
|
|
|
status: this.ruleForm.status,
|
|
status: this.ruleForm.status,
|
|
|
regions: this.currentRuleRegions
|
|
regions: this.currentRuleRegions
|
|
|
})
|
|
})
|
|
@@ -518,85 +605,124 @@ export default {
|
|
|
.catch(() => {})
|
|
.catch(() => {})
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- // ========== 地区设置相关 ==========
|
|
|
|
|
|
|
|
|
|
- handleEditRegions(row) {
|
|
|
|
|
- if (!row || !row.id) return
|
|
|
|
|
- this.regionDialog.ruleId = row.id
|
|
|
|
|
- this.selectedProvince = ''
|
|
|
|
|
- this.selectedCity = ''
|
|
|
|
|
- this.selectedArea = ''
|
|
|
|
|
- this.cities = []
|
|
|
|
|
- this.areas = []
|
|
|
|
|
- this.currentRuleRegions = Array.isArray(row.regions) ? [...row.regions] : []
|
|
|
|
|
- this.regionDialog.visible = true
|
|
|
|
|
- },
|
|
|
|
|
|
|
|
|
|
- onProvinceChange() {
|
|
|
|
|
|
|
+ // 从网络接口获取城市数据
|
|
|
|
|
+ async onProvinceChange() {
|
|
|
this.selectedCity = ''
|
|
this.selectedCity = ''
|
|
|
this.selectedArea = ''
|
|
this.selectedArea = ''
|
|
|
this.areas = []
|
|
this.areas = []
|
|
|
- const province = REGION_TREE.find(p => p.name === this.selectedProvince)
|
|
|
|
|
- this.cities = province ? province.city : []
|
|
|
|
|
|
|
+ this.cities = []
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.selectedProvince) return
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const province = PROVINCES.find(p => p.name === this.selectedProvince)
|
|
|
|
|
+ if (province) {
|
|
|
|
|
+ // 判断是否为直辖市
|
|
|
|
|
+ if (this.isMunicipality(province.code)) {
|
|
|
|
|
+ // 直辖市直接获取区县数据,参数需要特殊处理
|
|
|
|
|
+ // 将110000转换为110100格式
|
|
|
|
|
+ const municipalityCode = province.code.substring(0, 2) + '0100';
|
|
|
|
|
+ const response = await this.http().get(`/limit_purchase/region/area/${municipalityCode}`)
|
|
|
|
|
+ this.areas = response.data || []
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 非直辖市获取城市数据
|
|
|
|
|
+ const response = await this.http().get(`/limit_purchase/region/city/${province.code}`)
|
|
|
|
|
+ this.cities = response.data || []
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('获取城市数据失败:', e)
|
|
|
|
|
+ this.$message.error('获取城市数据失败')
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- onCityChange() {
|
|
|
|
|
|
|
+ // 从网络接口获取区县数据
|
|
|
|
|
+ async onCityChange() {
|
|
|
this.selectedArea = ''
|
|
this.selectedArea = ''
|
|
|
- const province = REGION_TREE.find(p => p.name === this.selectedProvince)
|
|
|
|
|
- const city = province ? province.city.find(c => c.name === this.selectedCity) : null
|
|
|
|
|
- this.areas = city ? city.area : []
|
|
|
|
|
|
|
+ this.areas = []
|
|
|
|
|
+
|
|
|
|
|
+ if (!this.selectedCity || !this.selectedProvince) return
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const province = PROVINCES.find(p => p.name === this.selectedProvince)
|
|
|
|
|
+ if (province) {
|
|
|
|
|
+ const city = this.cities.find(c => c.name === this.selectedCity)
|
|
|
|
|
+ if (city) {
|
|
|
|
|
+ const response = await this.http().get(`/limit_purchase/region/area/${city.code}`)
|
|
|
|
|
+ this.areas = response.data || []
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.error('获取区县数据失败:', e)
|
|
|
|
|
+ this.$message.error('获取区县数据失败')
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
addRegion() {
|
|
addRegion() {
|
|
|
- if (!this.selectedProvince || !this.selectedCity || !this.selectedArea) {
|
|
|
|
|
- this.$message.warning('请选择省、市、区县')
|
|
|
|
|
|
|
+ if (!this.selectedProvince) {
|
|
|
|
|
+ this.$message.warning('请至少选择省份')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const region = {
|
|
|
|
|
- province_id: null,
|
|
|
|
|
|
|
+ // 查找选中的省市区对象
|
|
|
|
|
+ const provinceObj = PROVINCES.find(p => p.name === this.selectedProvince)
|
|
|
|
|
+ const cityObj = this.cities.find(c => c.name === this.selectedCity) || null
|
|
|
|
|
+ const areaObj = this.areas.find(a => a.name === this.selectedArea) || null
|
|
|
|
|
+
|
|
|
|
|
+ let region = {
|
|
|
|
|
+ province_id: provinceObj ? provinceObj.code : null,
|
|
|
province_name: this.selectedProvince,
|
|
province_name: this.selectedProvince,
|
|
|
- city_id: null,
|
|
|
|
|
- city_name: this.selectedCity,
|
|
|
|
|
- district_id: null,
|
|
|
|
|
- district_name: this.selectedArea
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ city_id: cityObj ? cityObj.code : null,
|
|
|
|
|
+ city_name: this.selectedCity || null,
|
|
|
|
|
+ district_id: areaObj ? areaObj.code : null,
|
|
|
|
|
+ district_name: this.selectedArea || null
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 去重:检查是否已经存在相同或更广范围的地区
|
|
|
|
|
+ const exists = this.currentRuleRegions.some(item => {
|
|
|
|
|
+ // 完全匹配检查
|
|
|
|
|
+ if (item.province_name !== region.province_name) return false;
|
|
|
|
|
+
|
|
|
|
|
+ // 如果当前添加的是省级规则
|
|
|
|
|
+ if (!region.city_name) {
|
|
|
|
|
+ return !item.city_name; // 匹配已有省级规则
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果当前添加的是市级规则
|
|
|
|
|
+ if (region.city_name && !region.district_name) {
|
|
|
|
|
+ return item.city_name === region.city_name && !item.district_name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 如果当前添加的是区级规则
|
|
|
|
|
+ if (region.city_name && region.district_name) {
|
|
|
|
|
+ return item.city_name === region.city_name && item.district_name === region.district_name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return false;
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
- // 去重:相同省市区不重复添加
|
|
|
|
|
- const exists = this.currentRuleRegions.some(item =>
|
|
|
|
|
- item.province_id === region.province_id &&
|
|
|
|
|
- item.city_id === region.city_id &&
|
|
|
|
|
- item.district_id === region.district_id
|
|
|
|
|
- )
|
|
|
|
|
if (exists) {
|
|
if (exists) {
|
|
|
this.$message.warning('该地区已在列表中')
|
|
this.$message.warning('该地区已在列表中')
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.currentRuleRegions.push(region)
|
|
this.currentRuleRegions.push(region)
|
|
|
|
|
+
|
|
|
|
|
+ // 清空已选项
|
|
|
|
|
+ this.selectedProvince = ''
|
|
|
|
|
+ this.selectedCity = ''
|
|
|
|
|
+ this.selectedArea = ''
|
|
|
|
|
+ this.cities = []
|
|
|
|
|
+ this.areas = []
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
removeRegion(index) {
|
|
removeRegion(index) {
|
|
|
this.currentRuleRegions.splice(index, 1)
|
|
this.currentRuleRegions.splice(index, 1)
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- async submitRegions() {
|
|
|
|
|
- if (!this.http() || !this.regionDialog.ruleId) return
|
|
|
|
|
- this.loading.saveRegions = true
|
|
|
|
|
- try {
|
|
|
|
|
- await this.http().post(`/limit_purchase/rule/${this.regionDialog.ruleId}/regions`, {
|
|
|
|
|
- regions: this.currentRuleRegions
|
|
|
|
|
- })
|
|
|
|
|
- this.$message.success('限购地区设置成功')
|
|
|
|
|
- this.regionDialog.visible = false
|
|
|
|
|
- this.fetchRuleList()
|
|
|
|
|
- } catch (e) {
|
|
|
|
|
- console.error(e)
|
|
|
|
|
- this.$message.error('保存限购地区失败')
|
|
|
|
|
- } finally {
|
|
|
|
|
- this.loading.saveRegions = false
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
|
|
+
|
|
|
|
|
|
|
|
// ========== 工具方法 ==========
|
|
// ========== 工具方法 ==========
|
|
|
formatRegionLabel(region) {
|
|
formatRegionLabel(region) {
|
|
@@ -634,10 +760,6 @@ export default {
|
|
|
color: #999;
|
|
color: #999;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-.danger-text {
|
|
|
|
|
- color: #f56c6c;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
.region-selector-wrapper {
|
|
.region-selector-wrapper {
|
|
|
padding: 10px 0 0;
|
|
padding: 10px 0 0;
|
|
|
}
|
|
}
|
|
@@ -696,4 +818,17 @@ export default {
|
|
|
.text-right {
|
|
.text-right {
|
|
|
text-align: right;
|
|
text-align: right;
|
|
|
}
|
|
}
|
|
|
-</style>
|
|
|
|
|
|
|
+
|
|
|
|
|
+.form-tip {
|
|
|
|
|
+ margin-left: 10px;
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+.region-tip {
|
|
|
|
|
+ font-size: 12px;
|
|
|
|
|
+ color: #999;
|
|
|
|
|
+ margin-top: 5px;
|
|
|
|
|
+ margin-bottom: 15px;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|