Showing
8 changed files
with
325 additions
and
30 deletions
... | ... | @@ -32,4 +32,22 @@ export const deleteRepairOrder = (params) => { |
32 | 32 | params, |
33 | 33 | }); |
34 | 34 | }; |
35 | +/** | |
36 | + * 更新状态 | |
37 | + */ | |
38 | +export const updateStatus = (params) => { | |
39 | + return defHttp.post<any>({ | |
40 | + url: `/repairOrder/updateStatus`, | |
41 | + params, | |
42 | + }); | |
43 | +}; | |
44 | +/** | |
45 | + * 维修 | |
46 | + */ | |
47 | +export const saveRecord = (params) => { | |
48 | + return defHttp.post<any>({ | |
49 | + url: `/repairRecord/save`, | |
50 | + params, | |
51 | + }); | |
52 | +}; | |
35 | 53 | ... | ... |
1 | +<template> | |
2 | + <a-modal | |
3 | + v-model:visible="visible" | |
4 | + title="维修" | |
5 | + @ok="handleOk" | |
6 | + @cancel="handleCancel" | |
7 | + > | |
8 | + <a-form style="padding: 20px" :model="form" :label-col="{ span: 6 }" :wrapper-col="{ span: 14 }" :rules="rules"> | |
9 | + <a-form-item label="维修人" name="repairByName"> | |
10 | + <div style="display: flex"> | |
11 | + <a-input | |
12 | + v-model:value="form.repairByName" | |
13 | + placeholder="请选择" | |
14 | + :disabled="true" | |
15 | + > | |
16 | + </a-input> | |
17 | + <a-button | |
18 | + type="primary" | |
19 | + @click="goChoose" | |
20 | + :disabled="isViewMode" | |
21 | + > | |
22 | + 选人 | |
23 | + </a-button> | |
24 | + </div> | |
25 | + </a-form-item> | |
26 | + <a-form-item label="维修时间" name="repairDate"> | |
27 | + <a-date-picker | |
28 | + v-model:value="form.repairDate" | |
29 | + placeholder="请选择维修时间" | |
30 | + style="width: 100%" | |
31 | + /> | |
32 | + </a-form-item> | |
33 | + <a-form-item label="维修情况说明" name="description"> | |
34 | + <a-textarea v-model:value="form.description" placeholder="请输入维修情况说明" /> | |
35 | + </a-form-item> | |
36 | + <a-form-item label="故障原因" name="malfunctionReasonId"> | |
37 | + <a-select | |
38 | + v-model:value="form.malfunctionReasonId" | |
39 | + :options="reasonOptions" | |
40 | + placeholder="请选择" | |
41 | + /> | |
42 | + </a-form-item> | |
43 | + </a-form> | |
44 | + </a-modal> | |
45 | + <a-modal | |
46 | + v-model:visible="userVisible" | |
47 | + :title="userModalTitle" | |
48 | + width="60vw" | |
49 | + height="50vh" | |
50 | + @ok="handleUserOk" | |
51 | + @cancel="handleUserCancel" | |
52 | + > | |
53 | + <div style="padding: 20px;display: flex"> | |
54 | + <OrganizationIdTree @select="handleSelect" ref="organizationIdTreeRef" isOpen="true"/> | |
55 | + <div style="margin-top: 20px;margin-left: 30px"> | |
56 | + <a-radio-group v-model:value="selectedItem"> | |
57 | + <template v-for="item in Options" :key="`${item.id}`"> | |
58 | + <a-radio :style="radioStyle" :value="item">{{ item.username }}</a-radio> | |
59 | + </template> | |
60 | + </a-radio-group> | |
61 | + </div> | |
62 | + </div> | |
63 | + </a-modal> | |
64 | +</template> | |
65 | + | |
66 | +<script setup lang="ts"> | |
67 | +import {onMounted, reactive, ref, watch} from 'vue'; | |
68 | +import {OrganizationIdTree, useResetOrganizationTree} from "/@/views/common/organizationIdTree"; | |
69 | +import {getUserListByOrg} from "/@/api/equipment/ledger"; | |
70 | +import {useUserStore} from "/@/store/modules/user"; | |
71 | +import {useMessage} from "/@/hooks/web/useMessage"; | |
72 | +import {getEquipmentErrorList} from "/@/api/equipment/errorReason"; | |
73 | + | |
74 | +const props = defineProps({ | |
75 | + initialData: { | |
76 | + type: Object, | |
77 | + default: () => ({ | |
78 | + form: { | |
79 | + orderId: '', | |
80 | + repairBy: '', | |
81 | + repairByName: '', | |
82 | + repairDate: '', | |
83 | + description: '', | |
84 | + malfunctionReasonId: '', | |
85 | + } | |
86 | + }), | |
87 | + }, | |
88 | + visible: { | |
89 | + type: Boolean, | |
90 | + default: false, | |
91 | + }, | |
92 | +}); | |
93 | + | |
94 | +const visible = ref(props.visible); | |
95 | +const emit = defineEmits(['update:visible', 'submit']); | |
96 | + | |
97 | +const searchInfo = reactive<Recordable>({}); | |
98 | +const { organizationIdTreeRef } = useResetOrganizationTree(searchInfo); | |
99 | +const userVisible = ref(false); | |
100 | +const userModalTitle = ref('选人'); | |
101 | +const selectedItem = ref<{ id: string; username: string } | null>(null); | |
102 | +const radioStyle = reactive({ | |
103 | + display: 'block', | |
104 | + height: '30px', | |
105 | + lineHeight: '30px', | |
106 | +}); | |
107 | +const form = ref({ | |
108 | + orderId: '', | |
109 | + repairBy: '', | |
110 | + repairByName: '', | |
111 | + repairDate: '', | |
112 | + description: '', | |
113 | + malfunctionReasonId: '', | |
114 | +}); | |
115 | +const { createMessage } = useMessage(); | |
116 | +const userInfo = useUserStore(); | |
117 | +const rules = { | |
118 | + repairByName: [{ required: true, message: '请输入维修人', trigger: 'blur' }], | |
119 | + description: [{ required: true, message: '请输入维修情况说明', trigger: 'blur' }], | |
120 | + malfunctionReasonId: [{ required: true, message: '请输入故障原因', trigger: 'blur' }], | |
121 | +}; | |
122 | +watch( | |
123 | + () => props.visible, | |
124 | + (newVal) => { | |
125 | + visible.value = newVal; | |
126 | + } | |
127 | +); | |
128 | + | |
129 | + | |
130 | +// 监听 visible 的变化并通知父组件 | |
131 | +watch( | |
132 | + () => visible.value, | |
133 | + (newVal) => { | |
134 | + emit('update:visible', newVal); | |
135 | + } | |
136 | +); | |
137 | + | |
138 | +// 监听 initialData 的变化 | |
139 | +watch( | |
140 | + () => props.initialData, | |
141 | + (newVal) => { | |
142 | + form.value = { ...newVal.form }; | |
143 | + }, | |
144 | + { deep: true } | |
145 | +); | |
146 | +const reasonOptions = ref([]); | |
147 | +const Options = ref([]); | |
148 | + | |
149 | +const handleOk = () => { | |
150 | + emit('submit', form.value); | |
151 | + resetForm(); | |
152 | +}; | |
153 | + | |
154 | +// 清空表单和表格数据 | |
155 | +const resetForm = () => { | |
156 | + form.value = { | |
157 | + orderId: '', | |
158 | + repairBy: '', | |
159 | + repairByName: '', | |
160 | + repairDate: '', | |
161 | + description: '', | |
162 | + malfunctionReasonId: '', | |
163 | + }; | |
164 | +}; | |
165 | + | |
166 | +const handleCancel = () => { | |
167 | + emit('update:visible', false); // 关闭模态框 | |
168 | +}; | |
169 | + | |
170 | + | |
171 | +const goChoose = () => { | |
172 | + userVisible.value = true; | |
173 | + selectedItem.value = null; | |
174 | +} | |
175 | + | |
176 | +onMounted(() => { | |
177 | + fetchAgeOptions(); | |
178 | +}); | |
179 | + | |
180 | +const fetchAgeOptions = async () => { | |
181 | + try { | |
182 | + const response = await getEquipmentErrorList({ page: 1, pageSize: 999 }); // 调用接口 | |
183 | + reasonOptions.value = response.items?.map((item: any) => { | |
184 | + return { | |
185 | + value: item?.id, | |
186 | + label: item?.reason | |
187 | + } | |
188 | + }); | |
189 | + } catch (error) { | |
190 | + console.error('失败:', error); | |
191 | + } | |
192 | +}; | |
193 | + | |
194 | +const handleSelect = async (organizationId: string) => { | |
195 | + searchInfo.organizationId = organizationId; | |
196 | + const _data = { | |
197 | + page: '1', | |
198 | + pageSize: '999', | |
199 | + tenantId: userInfo.getUserInfo.tenantId!, | |
200 | + organizationId: organizationId | |
201 | + } | |
202 | + const response = await getUserListByOrg(_data); // 调用接口 | |
203 | + Options.value = response.items; | |
204 | + | |
205 | +}; | |
206 | + | |
207 | +// 确认按钮的回调 | |
208 | +const handleUserOk = () => { | |
209 | + if (!selectedItem.value) { | |
210 | + createMessage.warning('请选择一个用户'); | |
211 | + return; | |
212 | + } | |
213 | + form.value.repairBy = selectedItem.value.id | |
214 | + form.value.repairByName = selectedItem.value.username | |
215 | + | |
216 | + userVisible.value = false; // 关闭弹框 | |
217 | +}; | |
218 | + | |
219 | +const handleUserCancel = () => { | |
220 | + selectedItem.value = null; | |
221 | + userVisible.value = false; | |
222 | +}; | |
223 | + | |
224 | +</script> | ... | ... |
... | ... | @@ -45,21 +45,26 @@ |
45 | 45 | <template #action="{ record }"> |
46 | 46 | <TableAction |
47 | 47 | :actions="[ |
48 | + { | |
49 | + label: t('common.maintenance'), | |
50 | + auth: 'api:yt:order:update', | |
51 | + icon: 'ant-design:caret-right-outlined', | |
52 | + ifShow: () => record.status === 'SCHEDULING', | |
53 | + onClick:recordSave.bind(null,record) | |
54 | + }, | |
48 | 55 | { |
49 | - label: t('common.editText'), | |
56 | + label: t('common.checkOK'), | |
50 | 57 | auth: 'api:yt:order:update', |
51 | - icon: 'clarity:note-edit-line', | |
52 | - onClick: handleEdit.bind(null, record), | |
58 | + icon: 'ant-design:caret-right-outlined', | |
59 | + ifShow: () => record.status === 'REPAIRFINISH', | |
60 | + onClick:handleUpdateStatus.bind(null, record, 'ACCEPTANCEPASSED') | |
53 | 61 | }, |
54 | 62 | { |
55 | - label: t('common.delText'), | |
56 | - auth: 'api:yt:order:delete', | |
57 | - icon: 'ant-design:delete-outlined', | |
58 | - color: 'error', | |
59 | - popConfirm: { | |
60 | - title: t('common.deleteConfirmText'), | |
61 | - confirm: handleDelete.bind(null, record), | |
62 | - }, | |
63 | + label: t('common.checkFail'), | |
64 | + auth: 'api:yt:order:update', | |
65 | + icon: 'ant-design:caret-right-outlined', | |
66 | + ifShow: () => record.status === 'REPAIRFINISH', | |
67 | + onClick:handleUpdateStatus.bind(null, record, 'SCHEDULING') | |
63 | 68 | }, |
64 | 69 | ]" |
65 | 70 | /> |
... | ... | @@ -69,13 +74,18 @@ |
69 | 74 | <FormDrawer |
70 | 75 | @register="registerApplicationApiFormDrawer" |
71 | 76 | /> |
77 | + <RepairFormModal | |
78 | + v-model:visible="modalVisible" | |
79 | + :initial-data="initialData" | |
80 | + @submit="handleSubmit" | |
81 | + /> | |
72 | 82 | </div> |
73 | 83 | </template> |
74 | 84 | <script setup lang="ts"> |
75 | - import { orderModal } from "./components/index" | |
85 | + import { orderModal, RepairFormModal } from "./components/index" | |
76 | 86 | import { BasicTable, TableAction, TableImg } from '/@/components/Table'; |
77 | 87 | import { useTable } from '/@/components/Table'; |
78 | - import { getRepairOrderList } from '/@/api/repair/order'; | |
88 | + import {getRepairOrderList, saveRecord, updateStatus} from '/@/api/repair/order'; | |
79 | 89 | import { columns, searchFormSchema } from './index'; |
80 | 90 | import { useI18n } from '/@/hooks/web/useI18n'; |
81 | 91 | import { Button, Tag } from 'ant-design-vue'; |
... | ... | @@ -85,11 +95,22 @@ |
85 | 95 | const [registerModal, { openModal }] = useModal(); |
86 | 96 | import {FormDrawer} from "./components/FormDrawer/index"; |
87 | 97 | import {useDrawer} from "/@/components/Drawer"; |
88 | - import {deleteRepairOrder} from "/@/api/repair/order"; | |
89 | 98 | import {useMessage} from "/@/hooks/web/useMessage"; |
99 | + import {ref} from "vue"; | |
100 | + import {dateFormat} from "/@/utils/common/compUtils"; | |
101 | + const modalVisible = ref(false); | |
90 | 102 | const [registerApplicationApiFormDrawer, { }] = useDrawer(); |
91 | 103 | const { createMessage } = useMessage(); |
92 | - | |
104 | + const initialData = ref({ | |
105 | + form: { | |
106 | + orderId:'', | |
107 | + repairBy: '', | |
108 | + repairByName: '', | |
109 | + repairDate: '', | |
110 | + description: '', | |
111 | + malfunctionReasonId: '', | |
112 | + }, | |
113 | + }); | |
93 | 114 | const [ |
94 | 115 | registerTable, |
95 | 116 | { reload, setLoading, setSelectedRowKeys }, |
... | ... | @@ -132,26 +153,54 @@ |
132 | 153 | }); |
133 | 154 | }; |
134 | 155 | |
135 | - // 编辑 | |
136 | - const handleEdit = (record?: any) => { | |
137 | - openModal(true, { | |
138 | - isUpdate: true, | |
139 | - record, | |
140 | - }); | |
141 | - }; | |
142 | 156 | |
143 | - const handleDelete = async (record?: any) => { | |
157 | + const handleUpdateStatus = async (record?: any,value?: string) => { | |
158 | + console.log(record,'record') | |
159 | + console.log(value,'value') | |
144 | 160 | let id = record.id; |
161 | + let status = value; | |
162 | + | |
145 | 163 | try { |
146 | 164 | setLoading(true); |
147 | - await deleteRepairOrder({ id }); | |
148 | - createMessage.success(t('common.deleteSuccessText')); | |
165 | + await updateStatus({ id,status }); | |
166 | + createMessage.success(t('common.editSuccessText')); | |
149 | 167 | handleReload(); |
150 | 168 | } catch (error) { |
151 | 169 | throw error; |
152 | 170 | } finally { |
153 | 171 | setLoading(false); |
154 | 172 | } |
155 | - }; | |
173 | + } | |
156 | 174 | |
175 | + const recordSave = async (record?: any) => { | |
176 | + modalVisible.value = true; | |
177 | + initialData.value = { | |
178 | + form: { | |
179 | + orderId: record?.id || '', | |
180 | + repairBy: '', | |
181 | + repairByName: '', | |
182 | + repairDate: '', | |
183 | + description: '', | |
184 | + malfunctionReasonId: '', | |
185 | + } | |
186 | + } | |
187 | + } | |
188 | + const handleSubmit = async (data) => { | |
189 | + const format = 'yyyy-MM-dd hh:mm:ss'; | |
190 | + const _data = { | |
191 | + ...data, | |
192 | + repairDate: dateFormat(data?.repairDate, format), | |
193 | + } | |
194 | + try { | |
195 | + setLoading(true); | |
196 | + await saveRecord(_data); // 提交维修表单数据 | |
197 | + createMessage.success(t('common.editSuccessText')); | |
198 | + handleReload(); | |
199 | + modalVisible.value = false; | |
200 | + } catch (error) { | |
201 | + throw error; | |
202 | + } finally { | |
203 | + setLoading(false); | |
204 | + } | |
205 | + }; | |
157 | 206 | </script> | ... | ... |