Commit c4f632519befc2019f729f7c71513682c479a5e9

Authored by gesilong
1 parent 09609131

commit: 设备台账联调补充

1 1 export default {
2 2 listText: '工单列表',
3 3 nameText: '方案名称',
  4 + situationImg: '图片',
4 5 time: '报修时间',
5 6 nameDetail: '方案明细',
6 7 deviceNameText: '设备',
... ...
... ... @@ -61,7 +61,7 @@
61 61 selectedKeys.value = [];
62 62 }
63 63
64   - const foldFlag = ref(false);
  64 + const foldFlag = ref(true);
65 65 const handleFold = () => {
66 66 foldFlag.value = !unref(foldFlag);
67 67 };
... ... @@ -78,11 +78,12 @@
78 78 };
79 79
80 80 onMounted(async () => {
  81 + console.log(attrs,'attrs')
81 82 if (attrs?.isOpen) {
82 83 foldFlag.value = false;
83   - treeStyle.value.height = '50vh'
  84 + treeStyle.value.maxHeight = '50vh'
84 85 }else {
85   - treeStyle.value.height = '100vh'
  86 + treeStyle.value.maxHeight = '100vh'
86 87 }
87 88 let api:any;
88 89 if (attrs?.listType === 'equipment') {
... ...
... ... @@ -12,12 +12,42 @@
12 12 @close="handleClose"
13 13 >
14 14 <BasicForm @register="registerForm">
15   -
16 15 </BasicForm>
  16 + <div style="display: flex;width: 70%;margin-left: 70px">
  17 + <div style="width: 122px;text-align: center">
  18 + 报修人
  19 + </div>
  20 + <a-input
  21 + placeholder="请选择"
  22 + :disabled="true"
  23 + v-model:value="selectedUsername"
  24 + >
  25 + </a-input>
  26 + <a-button type="primary" @click="goChoose">选人</a-button>
  27 + </div>
  28 + <a-modal
  29 + v-model:visible="userVisible"
  30 + :title="userModalTitle"
  31 + width="60vw"
  32 + height="50vh"
  33 + @ok="handleUserOk"
  34 + @cancel="handleUserCancel"
  35 + >
  36 + <div style="padding: 20px;display: flex">
  37 + <OrganizationIdTree @select="handleSelect" ref="organizationIdTreeRef" isOpen="true"/>
  38 + <div style="margin-top: 20px;margin-left: 30px">
  39 + <a-radio-group v-model:value="selectedItem">
  40 + <template v-for="item in Options" :key="`${item.id}`">
  41 + <a-radio :style="radioStyle" :value="item">{{ item.username }}</a-radio>
  42 + </template>
  43 + </a-radio-group>
  44 + </div>
  45 + </div>
  46 + </a-modal>
17 47 </BasicDrawer>
18 48 </template>
19 49 <script setup lang="ts">
20   -import {nextTick, reactive, ref} from "vue";
  50 +import {computed, nextTick, reactive, ref} from "vue";
21 51 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
22 52 import { SchemaFiled} from "../../config/enum";
23 53 import {BasicForm,useForm} from "/@/components/Form";
... ... @@ -28,6 +58,7 @@ import {useUserStore} from "/@/store/modules/user";
28 58 import {useThrottleFn} from "@vueuse/shared/index";
29 59 import {useMessage} from "/@/hooks/web/useMessage";
30 60 import {useI18n} from "/@/hooks/web/useI18n";
  61 +import { useResetOrganizationTree, OrganizationIdTree } from '/@/views/common/organizationIdTree';
31 62 const {
32 63 setDefaultTime,
33 64 disableCustomWeekly,
... ... @@ -40,6 +71,29 @@ const restData = reactive({
40 71 });
41 72 const { createMessage } = useMessage();
42 73 const { t } = useI18n();
  74 +
  75 +// 定义人员选项
  76 +const Options = ref([]);
  77 +const searchInfo = reactive<Recordable>({});
  78 +const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo);
  79 +const userVisible = ref(false);
  80 +const userModalTitle = ref('选人');
  81 +const selectedItem = ref<{ id: string; username: string } | null>(null);
  82 +const radioStyle = reactive({
  83 + display: 'block',
  84 + height: '30px',
  85 + lineHeight: '30px',
  86 +});
  87 +// 计算属性实现双向绑定
  88 +const selectedUsername = computed({
  89 + get: () => selectedItem.value?.username || '',
  90 + set: (value) => {
  91 + if (selectedItem.value) {
  92 + selectedItem.value.username = value;
  93 + }
  94 + },
  95 +});
  96 +
43 97 const emits = defineEmits(['success', 'register']);
44 98 const [registerForm, { validate, resetFields, setFieldsValue, updateSchema, setProps }] = useForm(
45 99 {
... ... @@ -49,42 +103,6 @@ const [registerForm, { validate, resetFields, setFieldsValue, updateSchema, setP
49 103 fieldMapToTime: [[SchemaFiled.DATE_RANGE, [SchemaFiled.START_TS, SchemaFiled.END_TS]]],
50 104 }
51 105 );
52   -// 定义人员选项
53   -const userOptions = ref<any[]>([]);
54   -
55   -// 监听 org 字段的变化
56   -const handleOrgChange = async (orgId: string) => {
57   - if (!orgId) {
58   - userOptions.value = []; // 清空人员选项
59   - updateSchema({
60   - field: 'directorId',
61   - componentProps: { options: [] },
62   - });
63   - return;
64   - }
65   - const _data = {
66   - page: '1',
67   - pageSize: '999',
68   - tenantId: userInfo.getUserInfo.tenantId!,
69   - organizationId: orgId
70   - }
71   - // 调用接口 B 获取人员数据
72   - const userList = await getUserListByOrg(_data);
73   - console.log(userList,'userList')
74   - userOptions.value = userList?.items.map(user => ({
75   - label: user.username,
76   - value: user.id,
77   - }));
78   -
79   - // 更新 user 字段的选项
80   - updateSchema({
81   - field: 'directorId',
82   - componentProps: { options: userOptions.value },
83   - });
84   -};
85   -
86   -
87   -
88 106
89 107 const businessText = ref('');
90 108 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
... ... @@ -92,13 +110,11 @@ const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (
92 110 await nextTick();
93 111 handleClose();
94 112 businessText.value = data.text;
95   - // 更新 formSchema 中的 org 字段,绑定 change 事件
96   - updateSchema({
97   - field: 'org',
98   - componentProps: {
99   - onChange: handleOrgChange,
100   - },
101   - });
  113 + if (!selectedItem.value) {
  114 + selectedItem.value = { id: '', username: '' };
  115 + }
  116 + selectedItem.value.username = data?.record?.reportByName || '';
  117 + selectedItem.value.id = data?.record?.reportBy || '';
102 118 setFieldsValue(setDefaultTime());
103 119 updateSchema(disableCustomWeekly(0));
104 120 setDrawerProps(setPropsForModal(businessText.value));
... ... @@ -141,6 +157,7 @@ const getValue = async () => {
141 157 productDate: values.productDate?.format('YYYY-MM-DD hh:mm:ss'),
142 158 receiveDate: values.receiveDate?.format('YYYY-MM-DD hh:mm:ss'),
143 159 registeDate: values.registeDate?.format('YYYY-MM-DD hh:mm:ss'),
  160 + directorId: selectedItem.value?.id || '',
144 161 };
145 162 removeFields.forEach((item) => {
146 163 Reflect.deleteProperty(data, item);
... ... @@ -160,5 +177,37 @@ const getValue = async () => {
160 177 setDrawerProps({ confirmLoading: false });
161 178 }
162 179 };
  180 +const goChoose = () => {
  181 + userVisible.value = true;
  182 + selectedItem.value = null;
  183 +}
  184 +
  185 +// 确认按钮的回调
  186 +const handleUserOk = () => {
  187 + if (!selectedItem.value) {
  188 + createMessage.warning('请选择一个用户');
  189 + return;
  190 + }
  191 +
  192 + userVisible.value = false; // 关闭弹框
  193 +};
  194 +
  195 +const handleUserCancel = () => {
  196 + selectedItem.value = null;
  197 + userVisible.value = false;
  198 +};
  199 +
  200 +const handleSelect = async (organizationId: string) => {
  201 + searchInfo.organizationId = organizationId;
  202 + const _data = {
  203 + page: '1',
  204 + pageSize: '999',
  205 + tenantId: userInfo.getUserInfo.tenantId!,
  206 + organizationId: organizationId
  207 + }
  208 + const response = await getUserListByOrg(_data); // 调用接口
  209 + Options.value = response.items;
  210 +
  211 +};
163 212
164 213 </script>
... ...
... ... @@ -50,31 +50,6 @@ export const formSchema: BFormSchema[] = [
50 50 },
51 51 },
52 52 {
53   - field: 'org',
54   - component: 'OrgTreeSelect',
55   - label: '负责人组织',
56   - required: true,
57   - colProps: { span: 24 },
58   - componentProps: {
59   - // 添加 change 事件
60   - onChange: (value: string) => {
61   - // 这里需要触发加载人员数据的逻辑
62   - console.log(value,'value')
63   - },
64   - },
65   - },
66   - {
67   - field: 'directorId',
68   - component: 'Select',
69   - label: '负责人',
70   - required: true,
71   - colProps: { span: 24 },
72   - componentProps: {
73   - // 动态加载的选项
74   - options: [], // 初始为空,后续动态加载
75   - },
76   - },
77   - {
78 53 field: 'isOnline',
79 54 component: 'Select',
80 55 label: '是否联网',
... ...
... ... @@ -6,6 +6,11 @@ const { t } = useI18n();
6 6
7 7 export const columns: BasicColumn[] = [
8 8 {
  9 + title: t('repair.history.photo'),
  10 + dataIndex: 'situationImg',
  11 + slots: { customRender: 'situationImg' },
  12 + },
  13 + {
9 14 title: t('repair.history.orderCode'),
10 15 dataIndex: 'code',
11 16 },
... ... @@ -34,13 +39,7 @@ export const columns: BasicColumn[] = [
34 39 return record.tkRepairOrderDTO?.reportByName || '-' || text;
35 40 },
36 41 },
37   - {
38   - title: t('repair.history.photo'),
39   - dataIndex: 'tkRepairOrderDTO',
40   - format: (text, record) => {
41   - return record.tkRepairOrderDTO?.situationImg || '-' || text;
42   - },
43   - },
  42 +
44 43 {
45 44 title: t('repair.history.description'),
46 45 dataIndex: 'description',
... ...
1 1 <template>
2 2 <div>
3 3 <BasicTable style="flex: auto" @register="registerTable">
4   - <template #toolbar> </template>
  4 + <template #situationImg="{ record }">
  5 + <TableImg
  6 + :size="30"
  7 + :showBadge="false"
  8 + :simpleShow="true"
  9 + :imgList="
  10 + typeof record?.tkRepairOrderDTO?.situationImg !== 'undefined' && record?.tkRepairOrderDTO?.situationImg !== '' && record?.tkRepairOrderDTO?.situationImg != null
  11 + ? [record?.tkRepairOrderDTO?.situationImg]
  12 + : null
  13 + "
  14 + />
  15 + </template>
5 16 </BasicTable>
6 17 </div>
7 18 </template>
8 19 <script setup lang="ts">
9   - import { BasicTable, useTable } from '/@/components/Table';
  20 + import { BasicTable, useTable, TableImg } from '/@/components/Table';
10 21 import { getRepairHistoryList } from '/@/api/repair/history';
11   - import { columns, searchFormSchema } from './index';
  22 + import { columns, searchFormSchema } from "./index"
12 23 import { useI18n } from '/@/hooks/web/useI18n';
13 24 const { t } = useI18n();
14 25 const [
... ...
... ... @@ -11,28 +11,81 @@
11 11 >
12 12 <div>
13 13 <BasicForm @register="registerForm" />
  14 + <div style="display: flex;width: 70%;margin-left: 70px">
  15 + <div style="width: 122px;text-align: center">
  16 + 报修人
  17 + </div>
  18 + <a-input
  19 + placeholder="请选择"
  20 + :disabled="true"
  21 + v-model:value="selectedUsername"
  22 + >
  23 + </a-input>
  24 + <a-button type="primary" @click="goChoose">选人</a-button>
  25 + </div>
14 26 </div>
  27 + <a-modal
  28 + v-model:visible="userVisible"
  29 + :title="userModalTitle"
  30 + width="60vw"
  31 + height="50vh"
  32 + @ok="handleUserOk"
  33 + @cancel="handleUserCancel"
  34 + >
  35 + <div style="padding: 20px;display: flex">
  36 + <OrganizationIdTree @select="handleSelect" ref="organizationIdTreeRef" isOpen="true"/>
  37 + <div style="margin-top: 20px;margin-left: 30px">
  38 + <a-radio-group v-model:value="selectedItem">
  39 + <template v-for="item in Options" :key="`${item.id}`">
  40 + <a-radio :style="radioStyle" :value="item">{{ item.username }}</a-radio>
  41 + </template>
  42 + </a-radio-group>
  43 + </div>
  44 + </div>
  45 + </a-modal>
15 46 </BasicModal>
16 47 </div>
17 48 </template>
18 49 <script setup lang="ts">
19 50 import {BasicModal, useModalInner} from "/@/components/Modal";
20 51 import {BasicForm, useForm} from "/@/components/Form";
21   -import {computed, ref, unref} from "vue";
  52 +import {computed, reactive, ref, unref} from "vue";
22 53 import {useI18n} from "/@/hooks/web/useI18n";
23 54 import {schemas} from "../index";
24 55 import {getUserListByOrg} from "/@/api/equipment/ledger";
25 56 import {useUserStore} from "/@/store/modules/user";
26 57 import {saveOrder} from "/@/api/repair/order";
27 58 import {useMessage} from "/@/hooks/web/useMessage";
  59 +import { useResetOrganizationTree, OrganizationIdTree } from '/@/views/common/organizationIdTree';
28 60 const { t } = useI18n();
29 61 const isUpdate = ref<Boolean>(false);
30 62 const recordInfo = ref<any>({});
31 63 // 定义人员选项
32   -const userOptions = ref<any[]>([]);
33 64 const userInfo = useUserStore();
34 65 const { createMessage } = useMessage();
35 66
  67 +const userOptions = ref([]);
  68 +const Options = ref([]);
  69 +const searchInfo = reactive<Recordable>({});
  70 +const { organizationIdTreeRef, resetFn } = useResetOrganizationTree(searchInfo);
  71 +const userVisible = ref(false);
  72 +const userModalTitle = ref('选人');
  73 +const selectedItem = ref<{ id: string; username: string } | null>(null);
  74 +const radioStyle = reactive({
  75 + display: 'block',
  76 + height: '30px',
  77 + lineHeight: '30px',
  78 +});
  79 +// 计算属性实现双向绑定
  80 +const selectedUsername = computed({
  81 + get: () => selectedItem.value?.username || '',
  82 + set: (value) => {
  83 + if (selectedItem.value) {
  84 + selectedItem.value.username = value;
  85 + }
  86 + },
  87 +});
  88 +
36 89 const emit = defineEmits(['handleReload', 'register']);
37 90
38 91 const getTitle = computed(() =>
... ... @@ -54,9 +107,13 @@ const [register, { closeModal, setModalProps }] = useModalInner(async (data) =>
54 107 setModalProps({ confirmLoading: false, loading: true });
55 108 isUpdate.value = data?.isUpdate;
56 109 recordInfo.value = data?.record;
57   - // 更新 formSchema 中的 org 字段,绑定 change 事件
  110 + if (!selectedItem.value) {
  111 + selectedItem.value = { id: '', username: '' };
  112 + }
  113 + selectedItem.value.username = data?.record?.reportByName || '';
  114 + selectedItem.value.id = data?.record?.reportBy || '';
58 115 updateSchema({
59   - field: 'org',
  116 + field: 'situationImg',
60 117 componentProps: {
61 118 onChange: handleOrgChange,
62 119 },
... ... @@ -67,12 +124,13 @@ const [register, { closeModal, setModalProps }] = useModalInner(async (data) =>
67 124 setModalProps({ loading: false });
68 125 });
69 126
  127 +
70 128 // 监听 org 字段的变化
71 129 const handleOrgChange = async (orgId: string) => {
72 130 if (!orgId) {
73 131 userOptions.value = []; // 清空人员选项
74 132 updateSchema({
75   - field: 'reportBy',
  133 + field: 'report',
76 134 componentProps: { options: [] },
77 135 });
78 136 return;
... ... @@ -92,12 +150,11 @@ const handleOrgChange = async (orgId: string) => {
92 150
93 151 // 更新 user 字段的选项
94 152 updateSchema({
95   - field: 'reportBy',
  153 + field: 'report',
96 154 componentProps: { options: userOptions.value },
97 155 });
98 156 };
99 157
100   -
101 158 const handleCancel = () => {
102 159 closeModal();
103 160 };
... ... @@ -106,9 +163,9 @@ const handleOk = async () => {
106 163 await validate();
107 164 let values = getFieldsValue();
108 165 if (unref(isUpdate)) {
109   - values = { ...values, id: unref(recordInfo).id, situationImg: values.situationImg?.[0]?.url};
  166 + values = { ...values, id: unref(recordInfo).id, situationImg: values.situationImg?.[0]?.url, reportBy: selectedItem.value?.id || ''};
110 167 }else {
111   - values = { ...values, situationImg: values.situationImg?.[0]?.url};
  168 + values = { ...values, situationImg: values.situationImg?.[0]?.url, reportBy: selectedItem.value?.id || ''};
112 169 }
113 170 await saveOrder(values);
114 171 createMessage.success(t('common.operationSuccessText'));
... ... @@ -116,4 +173,37 @@ const handleOk = async () => {
116 173 handleCancel();
117 174 };
118 175
  176 +const goChoose = () => {
  177 + userVisible.value = true;
  178 + selectedItem.value = null;
  179 +}
  180 +
  181 +// 确认按钮的回调
  182 +const handleUserOk = () => {
  183 + if (!selectedItem.value) {
  184 + createMessage.warning('请选择一个用户');
  185 + return;
  186 + }
  187 +
  188 + userVisible.value = false; // 关闭弹框
  189 +};
  190 +
  191 +const handleUserCancel = () => {
  192 + selectedItem.value = null;
  193 + userVisible.value = false;
  194 +};
  195 +
  196 +const handleSelect = async (organizationId: string) => {
  197 + searchInfo.organizationId = organizationId;
  198 + const _data = {
  199 + page: '1',
  200 + pageSize: '999',
  201 + tenantId: userInfo.getUserInfo.tenantId!,
  202 + organizationId: organizationId
  203 + }
  204 + const response = await getUserListByOrg(_data); // 调用接口
  205 + Options.value = response.items;
  206 +
  207 +};
  208 +
119 209 </script>
... ...
... ... @@ -20,6 +20,11 @@ const emergencyOptions = [
20 20
21 21 export const columns: BasicColumn[] = [
22 22 {
  23 + title: t('repair.order.situationImg'),
  24 + dataIndex: 'situationImg',
  25 + slots: { customRender: 'situationImg' },
  26 + },
  27 + {
23 28 title: t('repair.order.nameCode'),
24 29 dataIndex: 'orderCode',
25 30 },
... ... @@ -143,31 +148,6 @@ export const schemas: FormSchema[] = [
143 148 },
144 149 },
145 150 {
146   - field: 'org',
147   - component: 'OrgTreeSelect',
148   - label: '报修人组织',
149   - required: true,
150   - colProps: { span: 24 },
151   - componentProps: {
152   - // 添加 change 事件
153   - onChange: (value: string) => {
154   - // 这里需要触发加载人员数据的逻辑
155   - console.log(value,'value')
156   - },
157   - },
158   - },
159   - {
160   - field: 'reportBy',
161   - component: 'Select',
162   - label: '报修人',
163   - required: true,
164   - colProps: { span: 21 },
165   - componentProps: {
166   - // 动态加载的选项
167   - options: [], // 初始为空,后续动态加载
168   - },
169   - },
170   - {
171 151 field: 'reportDate',
172 152 label: t('repair.order.time'),
173 153 component: 'DatePicker',
... ...
... ... @@ -8,6 +8,18 @@
8 8 </Button>
9 9 </Authority>
10 10 </template>
  11 + <template #situationImg="{ record }">
  12 + <TableImg
  13 + :size="30"
  14 + :showBadge="false"
  15 + :simpleShow="true"
  16 + :imgList="
  17 + typeof record.situationImg !== 'undefined' && record.situationImg !== '' && record.situationImg != null
  18 + ? [record.situationImg]
  19 + : null
  20 + "
  21 + />
  22 + </template>
11 23 <template #deviceId="{ record }">
12 24 <span>{{ record?.deviceInfo?.name }}</span>
13 25 </template>
... ... @@ -33,12 +45,6 @@
33 45 <template #action="{ record }">
34 46 <TableAction
35 47 :actions="[
36   - // {
37   - // label: t('common.detailText'),
38   - // icon: 'ant-design:eye-outlined',
39   - // auth: 'api:yt:product:category:get',
40   - // onClick: handleDetail.bind(null, record),
41   - // },
42 48 {
43 49 label: t('common.editText'),
44 50 auth: 'api:yt:product:category:update',
... ... @@ -67,7 +73,7 @@
67 73 </template>
68 74 <script setup lang="ts">
69 75 import { orderModal } from "./components/index"
70   - import { BasicTable, TableAction } from '/@/components/Table';
  76 + import { BasicTable, TableAction, TableImg } from '/@/components/Table';
71 77 import { useTable } from '/@/components/Table';
72 78 import { getRepairOrderList } from '/@/api/repair/order';
73 79 import { columns, searchFormSchema } from './index';
... ...