Commit 0ddea150475a72bba98bce6f744737b16d6f7a3f

Authored by 杨泽宇
1 parent 7fa2931e

工单 报修项目 本地数据改接口

src/views/repair/edit.vue
... ... @@ -2,9 +2,10 @@
2 2 import { reactive, ref, getCurrentInstance, onMounted } from "vue";
3 3 import { useRoute } from "vue-router";
4 4 import { getTableList } from "@/api/community/residence";
  5 +import { getTableList as getProject } from '@/api/notify/maintain';
5 6 import { repairAdd, repairDetail } from "@/api/notify/repair";
6 7 import { back } from "@/utils/tool";
7   -import { projects } from "./config";
  8 +import * as store from "@/pinia/index";
8 9 import type { ElForm } from "element-plus";
9 10 let instance: ComponentInternalInstance | null = getCurrentInstance();
10 11 let form = reactive({
... ... @@ -21,7 +22,7 @@ let form = reactive({
21 22 },
22 23 neighborhoods: [],
23 24 checkList: [],
24   - projects: projects,
  25 + projects: [],
25 26 loading: false,
26 27 dataType: "",
27 28 });
... ... @@ -147,8 +148,28 @@ const getNeighborhoods = async (pageSize: number = 20) => {
147 148 console.log(e);
148 149 }
149 150 };
  151 +/**
  152 + * 获取维修项目
  153 + * @param {number} pageSize 一页数据条数
  154 + */
  155 +const getProjects = async (pageSize: number = 20) => {
  156 + try {
  157 + const res = await getProject({
  158 + page: 1,
  159 + pageSize: pageSize,
  160 + oid:store?.family?.loginStore()?.organizationId??0
  161 + });
  162 + form.projects = res?.data?.data?.list;
  163 + if (res?.data?.data?.total > pageSize) {
  164 + getProjects(res?.data?.data?.total);
  165 + }
  166 + } catch (e) {
  167 + console.log(e);
  168 + }
  169 +}
150 170 onMounted(() => {
151 171 getNeighborhoods();
  172 + getProjects();
152 173 form.data = useRoute().query;
153 174 if (JSON.stringify(form.data) === "{}") {
154 175 form.dataType = "add";
... ... @@ -223,8 +244,8 @@ onMounted(() => {
223 244 <el-checkbox
224 245 v-for="(item, index) in form.projects"
225 246 :key="index"
226   - :label="item.value"
227   - >{{ item.label }}</el-checkbox
  247 + :label="item.id"
  248 + >{{ item.name }}</el-checkbox
228 249 >
229 250 </el-checkbox-group>
230 251 <span class="tip" v-else>暂无报修项</span>
... ...
src/views/repair/index.vue
1 1 <script setup lang="ts">
2 2 import { reactive, ref, onMounted, getCurrentInstance } from "vue";
3 3 import { repairList } from "@/api/notify/repair";
  4 +import { getTableList } from "@/api/notify/maintain.ts";
4 5 import { parseTime, globalFilters } from "@/utils/tool";
5 6 import Pagination from "@/components/Pagination/index.vue";
6 7 import { ElMessageBox } from "element-plus";
7   -import { status, projects } from "./config";
  8 +import * as store from "@/pinia/index";
  9 +import { status } from "./config";
8 10 interface Form {
9 11 page: number;
10 12 pageSize: number;
... ... @@ -30,7 +32,7 @@ interface Data {
30 32 const value1 = ref([]);
31 33 let data: Data = reactive({
32 34 list: [],
33   - projects: projects,
  35 + projects: [],
34 36 status: status,
35 37 loading: false,
36 38 params: {
... ... @@ -73,6 +75,25 @@ const handleTimeChange = (value: array) =&gt; {
73 75 getList();
74 76 };
75 77 /**
  78 + * 获取维修项目
  79 + * @param {number} pageSize 一页数据条数
  80 + */
  81 +const getProjects = async (pageSize: number = 20) => {
  82 + try {
  83 + const res = await getTableList({
  84 + page: 1,
  85 + pageSize: pageSize,
  86 + oid:store?.family?.loginStore()?.organizationId??0
  87 + });
  88 + data.projects = res?.data?.data?.list;
  89 + if (res?.data?.data?.total > pageSize) {
  90 + getProjects(res?.data?.data?.total);
  91 + }
  92 + } catch (e) {
  93 + console.log(e);
  94 + }
  95 +}
  96 +/**
76 97 * 获取维修项目名
77 98 * @param {string} ids 维修项目id串
78 99 */
... ... @@ -80,9 +101,9 @@ const getProjectNames = (ids: string) =&gt; {
80 101 let result: array = [];
81 102 if (ids) {
82 103 ids.split(",").map((item) => {
83   - projects.map((i) => {
84   - if (~~i.value === ~~item) {
85   - result.push(i.label);
  104 + data.projects.map((i) => {
  105 + if (~~i.id === ~~item) {
  106 + result.push(i.name);
86 107 }
87 108 });
88 109 });
... ... @@ -99,6 +120,7 @@ enum payTypeEnum {
99 120 "支付宝",
100 121 }
101 122 onMounted(() => {
  123 + getProjects();
102 124 getList();
103 125 });
104 126 </script>
... ... @@ -152,8 +174,8 @@ onMounted(() =&gt; {
152 174 @change="getList"
153 175 >
154 176 <el-option
155   - :label="item.label"
156   - :value="item.value"
  177 + :label="item.name"
  178 + :value="item.id"
157 179 v-for="(item, index) in data.projects"
158 180 :key="index"
159 181 ></el-option>
... ...