|
|
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> |
...
|
...
|
|