This commit is contained in:
张良(004796)
2024-04-23 21:07:04 +08:00
parent 6f2de24106
commit 6ef6332a21
4 changed files with 158 additions and 35 deletions

View File

@@ -17,15 +17,6 @@ export function getAreaCode(code) {
}) })
} }
// 查询行政区划详细
export function getTreeAreaCode() {
return request({
url: '/xq/areaCode/tree',
method: 'get'
})
}
// 新增行政区划 // 新增行政区划
export function addAreaCode(data) { export function addAreaCode(data) {
return request({ return request({

View File

@@ -0,0 +1,87 @@
<template>
<el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" width="700px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="行政编号" prop="code">
<el-input v-model="form.code" disabled/>
</el-form-item>
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" />
</el-form-item>
<el-form-item label="状态" prop="enableStatus">
<el-select v-model="form.enableStatus" placeholder="状态" size="small">
<el-option
v-for="dict in enableStatusList"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button :loading="buttonLoading" type="primary" @click="submitForm"> </el-button>
<el-button @click="open = false"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { enableStatusList } from '@/constant/statusMap'
import { updateAreaCode } from '@/api/xq/areaCode'
export default {
components: {
},
data () {
return {
enableStatusList,
open: false,
title: '',
form:{
code: undefined,
name: undefined,
enableStatus: undefined,
},
// 表单校验
rules: {
name: [
{ required: true, message: "数据不能为空", trigger: "blur" }
],
enableStatus: [
{ required: true, message: "数据不能为空", trigger: "change" }
],
},
buttonLoading: false,
}
},
created() {
},
methods: {
init (row) {
this.title = "修改";
this.open = true;
this.$nextTick(() => {
this.form.code = row.code;
this.form.name = row.name;
this.form.enableStatus = row.enableStatus;
})
},
// 表单提交
submitForm () {
this.$refs['form'].validate((valid) => {
if (valid) {
this.buttonLoading = true;
updateAreaCode(this.form).then(data => {
this.$modal.msgSuccess("修改成功");
this.$modal.buttonLoading = false;
this.open = false
this.$emit('refreshDataList')
}).finally(() => {
this.buttonLoading = false;
});
}
})
},
}
}
</script>

View File

@@ -15,19 +15,42 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" :data="areaCodeList" @selection-change="handleSelectionChange"> <el-table
<el-table-column label="行政区编码" align="center" prop="code"/> v-loading="loading"
<el-table-column label="名字" align="center" prop="name" /> :data="areaCodeList"
row-key="code"
:tree-props="{children: 'children', hasChildren: 'hasChildren'}"
>
<el-table-column label="名字" align="left" prop="name" />
<el-table-column label="行政区划代码" align="center" prop="code"/>
<el-table-column label="级别" align="center" prop="level" > <el-table-column label="级别" align="center" prop="level" >
<template v-slot="scope"> <template v-slot="scope">
<cai-dict-tag :options="areaCodeLevelList" :value="scope.row.level"/> <cai-dict-tag :options="areaCodeLevelList" :value="scope.row.level"/>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="上级编码" align="center" prop="pcode" /> <el-table-column label="状态" align="center" prop="enableStatus" >
<el-table-column label="上级名称" align="center" prop="pname" /> <template v-slot="scope">
<el-table-column label="完整名字" align="center" prop="fullname" /> <cai-dict-tag :options="enableStatusList" :value="scope.row.enableStatus"/>
<el-table-column label="经度" align="center" prop="longitude" /> </template>
<el-table-column label="纬度" align="center" prop="latitude" /> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template v-slot="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['xq:areaCode:edit']"
>修改</el-button>
<!-- <el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['xq:areaCode:remove']"
>删除</el-button>-->
</template>
</el-table-column>
</el-table> </el-table>
<pagination <pagination
@@ -37,18 +60,26 @@
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<areacode-update-dialog v-if="areaCodeUpdateDialogVisible" ref="areaCodeUpdateDialog" @refreshDataList="getList" />
</div> </div>
</template> </template>
<script> <script>
import { listAreaCode } from '@/api/xq/areaCode' import { delAreaCode, listAreaCode } from '@/api/xq/areaCode'
import { areaCodeLevelList } from '@/constant/statusMap' import { areaCodeLevelList, enableStatusList } from '@/constant/statusMap'
import AreacodeUpdateDialog from '@/views/xq/areaCode/areacode-update-dialog.vue'
import BannerAddUpdateDialog from '@/views/xq/banner/banner-add-update-dialog.vue'
export default { export default {
name: "AreaCode", name: "AreaCode",
components: { BannerAddUpdateDialog, AreacodeUpdateDialog},
data() { data() {
return { return {
areaCodeLevelList, enableStatusList,areaCodeLevelList,
areaCodeUpdateDialogVisible: false,
// 按钮loading
buttonLoading: false,
// 遮罩层 // 遮罩层
loading: true, loading: true,
// 选中数组 // 选中数组
@@ -63,17 +94,16 @@ export default {
total: 0, total: 0,
// 行政区划表格数据 // 行政区划表格数据
areaCodeList: [], areaCodeList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
name: undefined, name: undefined,
level: undefined, enableStatus: undefined
pcode: undefined,
pname: undefined,
fullname: undefined,
longitude: undefined,
latitude: undefined
}, },
}; };
}, },
@@ -85,8 +115,7 @@ export default {
getList() { getList() {
this.loading = true; this.loading = true;
listAreaCode(this.queryParams).then(response => { listAreaCode(this.queryParams).then(response => {
this.areaCodeList = response.rows; this.areaCodeList = this.handleTree(response.data, "code","pcode");
this.total = response.total;
this.loading = false; this.loading = false;
}); });
}, },
@@ -100,11 +129,27 @@ export default {
this.resetForm("queryForm"); this.resetForm("queryForm");
this.handleQuery(); this.handleQuery();
}, },
// 多选框选中数据 /** 修改按钮操作 */
handleSelectionChange(selection) { handleUpdate(row) {
this.ids = selection.map(item => item.code) this.areaCodeUpdateDialogVisible = true
this.single = selection.length!==1 this.$nextTick(() => {
this.multiple = !selection.length this.$refs.areaCodeUpdateDialog.init(row)
})
},
/** 删除按钮操作 */
handleDelete(row) {
const codes = row.code || this.ids;
this.$modal.confirm('是否确认删除行政区划编号为"' + codes + '"的数据项?').then(() => {
this.loading = true;
return delAreaCode(codes);
}).then(() => {
this.loading = false;
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {
}).finally(() => {
this.loading = false;
});
}, },
} }
}; };

View File

@@ -35,8 +35,8 @@ module.exports = {
proxy: { proxy: {
// detail: https://cli.vuejs.org/config/#devserver-proxy // detail: https://cli.vuejs.org/config/#devserver-proxy
[process.env.VUE_APP_BASE_API]: { [process.env.VUE_APP_BASE_API]: {
// target: `http://localhost:8080`, target: `http://localhost:8080`,
target: `http://xq.qiqizl.com/prod-api`, // target: `http://xq.qiqizl.com/prod-api`,
changeOrigin: true, changeOrigin: true,
pathRewrite: { pathRewrite: {
['^' + process.env.VUE_APP_BASE_API]: '' ['^' + process.env.VUE_APP_BASE_API]: ''