Commit 6dda009e authored by 石建新(贵阳日报)'s avatar 石建新(贵阳日报)
parents 7974e8e0 56dc57e2
...@@ -5,6 +5,8 @@ export const getUploadToken = params => instance.post("/common/file/getUploadTok ...@@ -5,6 +5,8 @@ export const getUploadToken = params => instance.post("/common/file/getUploadTok
export const getDictDataApi = params => instance.post("/common/dict/getDictData", params); export const getDictDataApi = params => instance.post("/common/dict/getDictData", params);
// 获取省市区树状数据 // 获取省市区树状数据
export const getTreeListApi = params => instance.postForm("/dict/dictProvinceCityDistrict/getTreeList", params); export const getTreeListApi = params => instance.postForm("/dict/dictProvinceCityDistrict/getTreeList", params);
// 懒加载省市区(province,city,district,street)
export const getAreaListApi = ({ type, code }) => instance.post(`dict/area/list/${type}/${code}`);
// 获取岗位列表 // 获取岗位列表
export const dictJobTypeApi = params => instance.post("/dict/dictJobType/getTree", params); export const dictJobTypeApi = params => instance.post("/dict/dictJobType/getTree", params);
// 获取岗位列表类型(1职位,2政策,3动态) // 获取岗位列表类型(1职位,2政策,3动态)
......
...@@ -12,15 +12,16 @@ ...@@ -12,15 +12,16 @@
<wd-col-picker <wd-col-picker
v-model="cityValue" v-model="cityValue"
:columns="cityOpstion" :columns="cityOpstion"
style="width: 100%;" style="width: 100%"
value-key="code" value-key="code"
label-key="name" label-key="name"
:column-change="columnChangeCity" :column-change="columnChangeCity"
@confirm="handleConfirmCity" @confirm="handleConfirmCity"
use-default-slot use-default-slot
> >
<p :class="{ placeholder: !cityText }" class="text-single" style="width: 100%;">{{ cityText || "请选择公司所在地" }}</p> <p :class="{ placeholder: !cityText }" class="text-single" style="width: 100%">
{{ cityText || "请选择公司所在地" }}
</p>
</wd-col-picker> </wd-col-picker>
<view class="arrow"></view> <view class="arrow"></view>
</view> </view>
...@@ -42,37 +43,62 @@ ...@@ -42,37 +43,62 @@
<script setup> <script setup>
import { ref } from "vue"; import { ref } from "vue";
import AddressSelect from "@/components/form/address-select.vue"; import AddressSelect from "@/components/form/address-select.vue";
import { getTreeListApi } from "@/api/common"; import { getTreeListApi, getAreaListApi } from "@/api/common";
import { useReleasePostionStore } from "./store"; import { useReleasePostionStore } from "./store";
import town from "@/assets/town.json"; import town from "@/assets/town.json";
/* tab */ /* tab */
const pinias = useReleasePostionStore(); const pinias = useReleasePostionStore();
const showTab = ref(true); const showTab = ref(true);
import { validateForm } from "@/utils/utils"; import { validateForm } from "@/utils/utils";
getAreaListApi({ type: "street", code: "520112" }).then(res => {
// 地区选择 console.log(res);
});
// 地区接口地址
const keys = ["district", "street"];
/* 获取省市区 */ /* 获取省市区 */
const cityOpstion = ref([]); const cityOpstion = ref([]);
const cityValue = ref([]); const cityValue = ref([]);
const cityText = ref(""); const cityText = ref("");
let citySelectedItems = []; let citySelectedItems = [];
getTreeListApi({ provinceName: "贵州省" }).then(res => {
getAreaListApi({ type: "city", code: "5201" }).then(res => {
cityOpstion.value.push(res.data);
});
const columnChangeCity = ({ selectedItem, resolve, index, finish }) => {
console.log(selectedItem.code);
console.log(index);
const type = keys[index];
if (type) {
getAreaListApi({ type, code: selectedItem.code }).then(res => {
resolve(res.data);
});
} else {
finish();
}
};
/* getTreeListApi({ provinceName: "贵州省" }).then(res => {
cityOpstion.value.push(res.data[0].children); cityOpstion.value.push(res.data[0].children);
}); });
const columnChangeCity = ({ selectedItem, resolve, finish }) => { const columnChangeCity = ({ selectedItem, resolve, finish }) => {
console.log(selectedItem);
if (selectedItem.children) { if (selectedItem.children) {
console.log(selectedItem.children);
resolve(selectedItem.children); resolve(selectedItem.children);
} else { } else {
// 选择街道 // 加载街道
if (!town[selectedItem.code]) {
console.log("code:", selectedItem.code, "名字:", selectedItem.name);
}
if (selectedItem.children === null && town[selectedItem.code]) { if (selectedItem.children === null && town[selectedItem.code]) {
if (!town[selectedItem.code]) {
console.log("code:", selectedItem.code, "名字:", selectedItem.name);
}
resolve(town[selectedItem.code].map((v, i) => ({ ...v, code: i }))); resolve(town[selectedItem.code].map((v, i) => ({ ...v, code: i })));
} else { } else {
finish(); finish();
} }
} }
}; }; */
const handleConfirmCity = ({ selectedItems }) => { const handleConfirmCity = ({ selectedItems }) => {
cityText.value = selectedItems.map(v => v.name || "").join("-"); cityText.value = selectedItems.map(v => v.name || "").join("-");
citySelectedItems = selectedItems; citySelectedItems = selectedItems;
......
import axios from "axios"; import axios from "axios";
import { getToken, removeToken } from "@/utils/token"; import { getToken, removeToken } from "@/utils/token";
const baseURL = "https://lygsh-api.wjzpgz.com/"; // const baseURL = "https://lygsh-api.wjzpgz.com/";
// const baseURL = "http://192.168.11.48:8080/"; const baseURL = "http://192.168.11.48:8080/";
// 创建一个 axios 实例 // 创建一个 axios 实例
const instance = axios.create({ const instance = axios.create({
baseURL, // 设置基础 URL baseURL, // 设置基础 URL
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment