Commit b3f5c1c1 by liuguorong93

获取本地json数据

parent 16a0b188
{
"code":200,
"data":{
"rows":[
{
"ids":"666666",
"label":"警务技术",
"codeType":"CODE_JWJXXL",
"text":"警务技术",
"pId":null,
"id":"1",
"isParent":false,
"children":[]
},
{
"ids":"666667",
"label":"执法勤务",
"codeType":"CODE_JWJXXL",
"text":"执法勤务",
"pId":null,
"id":"2",
"isParent":false,
"children":[]
},
{
"ids":"666668",
"label":"综合管理",
"codeType":"CODE_JWJXXL",
"text":"综合管理",
"pId":null,
"id":"3",
"isParent":false,
"children":[]
}
]
},
"success":true,
"message":"成功"
}
\ No newline at end of file
......@@ -19,18 +19,4 @@ var enumeration = {
code: '0'
}
],
jwjsxlOptions: [
{
name: '警务技术',
code: '1'
},
{
name: '执法勤务',
code: '2'
},
{
name: '综合管理',
code: '3'
}
]
}
// 获取本地json数据
export const getJsonDataApi = (fileName) => {
let datas
if (!fileName) return []
return new Promise((resolve) => {
axios.get(`JsonData/${fileName}.json`).then((res) => {
try {
datas = res.data.data.rows
resolve(datas)
} catch (e) {
datas = []
resolve(options)
}
}).catch((e) => {
datas = []
resolve(options)
})
})
}
......@@ -89,8 +89,8 @@
<el-option
v-for="(item, index) in jwjsxlOptions"
:key="index"
:label="item.name"
:value="item.code"
:label="item.label"
:value="item.id"
>
</el-option>
</el-select>
......@@ -280,6 +280,7 @@
<script>
import { getArtisanList } from "@/api/menuDataApi/artisanManageApi.js";
import { getJsonDataApi } from "@/utils/getJsonData.js";
export default {
name: "artisanManage",
......@@ -304,10 +305,11 @@ export default {
sexOptions: enumeration.sexOptions,
shifouOptions: enumeration.shifouOptions,
jwjsxlOptions: enumeration.jwjsxlOptions,
jwjsxlOptions: [],
};
},
mounted() {
async mounted() {
this.jwjsxlOptions = await getJsonDataApi("CODE_JWJXXL");
this.getLists(1);
},
methods: {
......@@ -356,7 +358,7 @@ export default {
this.tableData = res.data.data.records;
this.total = res.data.data.total;
this.tableLoading = false;
console.log(this.tableData);
// console.log(this.tableData);
return;
}
this.tableLoading = false;
......
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