Showing
10 changed files
with
571 additions
and
36 deletions
src/api/equipment/chenkPlan.ts
0 → 100644
| 1 | +import { defHttp } from '/@/utils/http/axios'; | ||
| 2 | +import {omit} from "lodash-es"; | ||
| 3 | + | ||
| 4 | +/** | ||
| 5 | + * 获取列表 | ||
| 6 | + */ | ||
| 7 | +export const getPlanList = (params) => { | ||
| 8 | + const { page, pageSize } = params; | ||
| 9 | + const otherParams = omit(params, ['page', 'pageSize']); | ||
| 10 | + return defHttp.get<any>({ | ||
| 11 | + url: `/checkPlan?page=${page}&pageSize=${pageSize}`, | ||
| 12 | + params: otherParams, | ||
| 13 | + }); | ||
| 14 | +}; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * 新增 | ||
| 18 | + */ | ||
| 19 | +export const equipmentPlanCategory = (params) => { | ||
| 20 | + return defHttp.post<any>({ | ||
| 21 | + url: `/checkPlan/save`, | ||
| 22 | + params, | ||
| 23 | + }); | ||
| 24 | +}; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * 删除 | ||
| 28 | + */ | ||
| 29 | +export const deleteEquipmentPlan = (params) => { | ||
| 30 | + return defHttp.get<any>({ | ||
| 31 | + url: `/checkPlan/delete`, | ||
| 32 | + params, | ||
| 33 | + }); | ||
| 34 | +}; |
| 1 | +export default { | ||
| 2 | + listText: '方案列表', | ||
| 3 | + nameText: '方案名称', | ||
| 4 | + nameDetail: '方案明细', | ||
| 5 | + nameCode: '方案编号', | ||
| 6 | + typeText: '方案类型', | ||
| 7 | + inspectionText: '巡检方案', | ||
| 8 | + maintenanceText: '保养方案', | ||
| 9 | + INSPECTION: '巡检方案', | ||
| 10 | + MAINTENANCE: '保养方案', | ||
| 11 | + planDetails: '方案明细', | ||
| 12 | + statusText: '状态', | ||
| 13 | + enableText: '启用', | ||
| 14 | + disabledText: '停用', | ||
| 15 | + createCategoryText: '创建方案', | ||
| 16 | + editCategoryText: '编辑方案', | ||
| 17 | + detailText: '查看详情', | ||
| 18 | +} |
| 1 | +import { FormSchema } from '/@/components/Form'; | ||
| 2 | +import { useI18n } from '/@/hooks/web/useI18n'; | ||
| 3 | + | ||
| 4 | +export enum FormFieldsEnum { | ||
| 5 | + CODE = 'code', | ||
| 6 | + CATEGORY_NAME = 'name', | ||
| 7 | + CATEGORY_STATUS = 'status', | ||
| 8 | + CATEGORY_TYPE = 'type', | ||
| 9 | + CATEGORY_DETAILS = 'planDetails', | ||
| 10 | +} | ||
| 11 | + | ||
| 12 | +const { t } = useI18n(); | ||
| 13 | +const statusOptions = [ | ||
| 14 | + { label: t('equipment.checkPlan.enableText'), value: 'ENABLE' }, | ||
| 15 | + { label: t('equipment.checkPlan.disabledText'), value: 'DISABLE' }, | ||
| 16 | +]; | ||
| 17 | +const typeOptions = [ | ||
| 18 | + { label: t('equipment.checkPlan.inspectionText'), value: 'INSPECTION' }, | ||
| 19 | + { label: t('equipment.checkPlan.maintenanceText'), value: 'MAINTENANCE' }, | ||
| 20 | +]; | ||
| 21 | +export const formSchema: FormSchema[] = [ | ||
| 22 | + { | ||
| 23 | + field: FormFieldsEnum.CODE, | ||
| 24 | + label: t('equipment.checkPlan.nameCode'), | ||
| 25 | + component: 'Input', | ||
| 26 | + componentProps() { | ||
| 27 | + return { | ||
| 28 | + disabled: 'disabled', | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + }, | ||
| 32 | + { | ||
| 33 | + field: FormFieldsEnum.CATEGORY_NAME, | ||
| 34 | + label: t('equipment.checkPlan.nameText'), | ||
| 35 | + component: 'Input', | ||
| 36 | + componentProps() { | ||
| 37 | + return { | ||
| 38 | + disabled: 'disabled', | ||
| 39 | + }; | ||
| 40 | + }, | ||
| 41 | + }, | ||
| 42 | + { | ||
| 43 | + field: FormFieldsEnum.CATEGORY_STATUS, | ||
| 44 | + label: t('equipment.checkPlan.statusText'), | ||
| 45 | + component: 'Select', | ||
| 46 | + componentProps: { | ||
| 47 | + options: statusOptions, | ||
| 48 | + disabled: 'disabled', | ||
| 49 | + }, | ||
| 50 | + }, | ||
| 51 | + { | ||
| 52 | + field: FormFieldsEnum.CATEGORY_TYPE, | ||
| 53 | + label: t('equipment.checkPlan.typeText'), | ||
| 54 | + component: 'Select', | ||
| 55 | + componentProps: { | ||
| 56 | + options: typeOptions, | ||
| 57 | + disabled: 'disabled', | ||
| 58 | + }, | ||
| 59 | + }, | ||
| 60 | + { | ||
| 61 | + field: FormFieldsEnum.CATEGORY_DETAILS, | ||
| 62 | + label: t('equipment.checkPlan.nameDetail'), | ||
| 63 | + component: 'InputTextArea', | ||
| 64 | + componentProps() { | ||
| 65 | + return { | ||
| 66 | + disabled: 'disabled', | ||
| 67 | + }; | ||
| 68 | + }, | ||
| 69 | + }, | ||
| 70 | +]; |
| 1 | +export { default as FormDrawer } from './index.vue'; |
| 1 | +<script lang="ts" setup> | ||
| 2 | + import { nextTick, ref, unref, computed } from 'vue'; | ||
| 3 | + import { BasicForm, useForm } from '/@/components/Form'; | ||
| 4 | + import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | ||
| 5 | + import { formSchema } from './config'; | ||
| 6 | + import { useMessage } from '/@/hooks/web/useMessage'; | ||
| 7 | + import { useI18n } from '/@/hooks/web/useI18n'; | ||
| 8 | + import { JSONEditor } from '/@/components/CodeEditor'; | ||
| 9 | + import { ApplicationApiItemType } from '/@/api/application/model/api'; | ||
| 10 | + | ||
| 11 | + const emits = defineEmits(['success', 'register']); | ||
| 12 | + | ||
| 13 | + const { t } = useI18n(); | ||
| 14 | + | ||
| 15 | + const { createMessage } = useMessage(); | ||
| 16 | + | ||
| 17 | + const handleCount = ref<Number>(); // 0 新增 1 编辑 2 详情 | ||
| 18 | + | ||
| 19 | + const recordData = ref<ApplicationApiItemType>(); | ||
| 20 | + | ||
| 21 | + const [registerForm, { resetFields, validate, setFieldsValue, setProps }] = useForm({ | ||
| 22 | + labelWidth: 120, | ||
| 23 | + schemas: formSchema, | ||
| 24 | + showActionButtonGroup: false, | ||
| 25 | + }); | ||
| 26 | + | ||
| 27 | + const cacheTitle = computed(() => | ||
| 28 | + unref(handleCount) === 0 | ||
| 29 | + ? t('application.api.action.create') | ||
| 30 | + : unref(handleCount) === 1 | ||
| 31 | + ? t('application.api.action.edit') | ||
| 32 | + : t('application.api.action.detail') | ||
| 33 | + ); | ||
| 34 | + | ||
| 35 | + const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | ||
| 36 | + setDrawerProps({ loading: true }); | ||
| 37 | + await resetFields(); | ||
| 38 | + handleCount.value = data.isUpdate; | ||
| 39 | + recordData.value = data.record; | ||
| 40 | + if (unref(handleCount) === 2) { | ||
| 41 | + setProps({ disabled: true }); | ||
| 42 | + } else { | ||
| 43 | + setProps({ disabled: false }); | ||
| 44 | + } | ||
| 45 | + try { | ||
| 46 | + await nextTick(); | ||
| 47 | + setFieldsValue(data.record); | ||
| 48 | + } finally { | ||
| 49 | + setDrawerProps({ loading: false }); | ||
| 50 | + } | ||
| 51 | + }); | ||
| 52 | + | ||
| 53 | + | ||
| 54 | +</script> | ||
| 55 | + | ||
| 56 | +<template> | ||
| 57 | + <div> | ||
| 58 | + <BasicDrawer | ||
| 59 | + destroyOnClose | ||
| 60 | + v-bind="$attrs" | ||
| 61 | + :showFooter="handleCount !== 2" | ||
| 62 | + :title="cacheTitle" | ||
| 63 | + width="30%" | ||
| 64 | + :maskClosable="true" | ||
| 65 | + @register="registerDrawer" | ||
| 66 | + > | ||
| 67 | + <BasicForm @register="registerForm"> | ||
| 68 | + <template #interfaceParamsSlot="{ model, field }"> | ||
| 69 | + <JSONEditor v-model:value="model[field]" /> | ||
| 70 | + </template> | ||
| 71 | + </BasicForm> | ||
| 72 | + </BasicDrawer> | ||
| 73 | + </div> | ||
| 74 | +</template> | ||
| 75 | + | ||
| 76 | +<style lang="less" scoped></style> |
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <BasicModal | ||
| 4 | + v-bind="$attrs" | ||
| 5 | + width="30rem" | ||
| 6 | + :title="getTitle" | ||
| 7 | + @register="register" | ||
| 8 | + @cancel="handleCancel" | ||
| 9 | + @ok="handleOk" | ||
| 10 | + destroyOnClose | ||
| 11 | + > | ||
| 12 | + <div> | ||
| 13 | + <BasicForm @register="registerForm" /> | ||
| 14 | + </div> | ||
| 15 | + </BasicModal> | ||
| 16 | + </div> | ||
| 17 | +</template> | ||
| 18 | +<script setup lang="ts"> | ||
| 19 | +import {BasicModal, useModalInner} from "/@/components/Modal"; | ||
| 20 | +import {BasicForm, useForm} from "/@/components/Form"; | ||
| 21 | +import {computed, ref, unref} from "vue"; | ||
| 22 | +import {useI18n} from "/@/hooks/web/useI18n"; | ||
| 23 | +import {schemas} from "../index"; | ||
| 24 | +import {equipmentPlanCategory} from "/@/api/equipment/chenkPlan"; | ||
| 25 | +import {useMessage} from "/@/hooks/web/useMessage"; | ||
| 26 | +const { t } = useI18n(); | ||
| 27 | +const { createMessage } = useMessage(); | ||
| 28 | + | ||
| 29 | +const emit = defineEmits(['handleReload', 'register']); | ||
| 30 | +const recordInfo = ref<any>({}); | ||
| 31 | +const isUpdate = ref<Boolean>(false); | ||
| 32 | +const getTitle = computed(() => | ||
| 33 | + !unref(isUpdate) | ||
| 34 | + ? t('equipment.checkPlan.createCategoryText') | ||
| 35 | + : t('equipment.checkPlan.editCategoryText') | ||
| 36 | +); | ||
| 37 | +const [registerForm, { getFieldsValue, setFieldsValue, validate }] = useForm({ | ||
| 38 | + labelWidth: 140, | ||
| 39 | + schemas, | ||
| 40 | + actionColOptions: { | ||
| 41 | + span: 14, | ||
| 42 | + }, | ||
| 43 | + showActionButtonGroup: false, | ||
| 44 | +}); | ||
| 45 | + | ||
| 46 | +const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { | ||
| 47 | + setModalProps({ confirmLoading: false, loading: true }); | ||
| 48 | + isUpdate.value = data?.isUpdate; | ||
| 49 | + recordInfo.value = data?.record; | ||
| 50 | + if (data?.record) { | ||
| 51 | + setFieldsValue(data?.record); | ||
| 52 | + } | ||
| 53 | + setModalProps({ loading: false }); | ||
| 54 | +}); | ||
| 55 | + | ||
| 56 | +const handleCancel = () => { | ||
| 57 | + closeModal(); | ||
| 58 | +}; | ||
| 59 | + | ||
| 60 | +const handleOk = async () => { | ||
| 61 | + await validate(); | ||
| 62 | + let values = getFieldsValue(); | ||
| 63 | + if (unref(isUpdate)) { | ||
| 64 | + values = { ...values, id: unref(recordInfo).id }; | ||
| 65 | + } | ||
| 66 | + await equipmentPlanCategory(values); | ||
| 67 | + createMessage.success(t('common.operationSuccessText')); | ||
| 68 | + emit('handleReload'); | ||
| 69 | + handleCancel(); | ||
| 70 | +}; | ||
| 71 | + | ||
| 72 | +</script> |
src/views/equipment/checkPlan/index.ts
0 → 100644
| 1 | +import {FormSchema} from "/@/components/Form"; | ||
| 2 | +import {useI18n} from "/@/hooks/web/useI18n"; | ||
| 3 | +import {BasicColumn} from "/@/components/Table"; | ||
| 4 | +const { t } = useI18n(); | ||
| 5 | + | ||
| 6 | + | ||
| 7 | +const statusOptions = [ | ||
| 8 | + { label: t('equipment.checkPlan.enableText'), value: 'ENABLE' }, | ||
| 9 | + { label: t('equipment.checkPlan.disabledText'), value: 'DISABLE' }, | ||
| 10 | +]; | ||
| 11 | +const typeOptions = [ | ||
| 12 | + { label: t('equipment.checkPlan.inspectionText'), value: 'INSPECTION' }, | ||
| 13 | + { label: t('equipment.checkPlan.maintenanceText'), value: 'MAINTENANCE' }, | ||
| 14 | +]; | ||
| 15 | + | ||
| 16 | +export const columns: BasicColumn[] = [ | ||
| 17 | + { | ||
| 18 | + title: t('equipment.checkPlan.nameCode'), | ||
| 19 | + dataIndex: 'code', | ||
| 20 | + }, | ||
| 21 | + { | ||
| 22 | + title: t('equipment.checkPlan.nameText'), | ||
| 23 | + dataIndex: 'name', | ||
| 24 | + }, | ||
| 25 | + { | ||
| 26 | + title: t('equipment.checkPlan.typeText'), | ||
| 27 | + dataIndex: 'type', | ||
| 28 | + slots: { customRender: 'type' }, | ||
| 29 | + }, | ||
| 30 | + { | ||
| 31 | + title: t('equipment.checkPlan.statusText'), | ||
| 32 | + dataIndex: 'status', | ||
| 33 | + slots: { customRender: 'status' }, | ||
| 34 | + }, | ||
| 35 | + { | ||
| 36 | + title: t('equipment.checkPlan.planDetails'), | ||
| 37 | + dataIndex: 'planDetails', | ||
| 38 | + }, | ||
| 39 | +]; | ||
| 40 | + | ||
| 41 | +export const searchFormSchema: FormSchema[] = [ | ||
| 42 | + { | ||
| 43 | + field: 'name', | ||
| 44 | + label: t('equipment.checkPlan.nameText'), | ||
| 45 | + component: 'Input', | ||
| 46 | + colProps: { span: 6 }, | ||
| 47 | + componentProps: { | ||
| 48 | + maxLength: 255, | ||
| 49 | + }, | ||
| 50 | + }, | ||
| 51 | + | ||
| 52 | + { | ||
| 53 | + field: 'type', | ||
| 54 | + label: t('equipment.checkPlan.typeText'), | ||
| 55 | + component: 'Select', | ||
| 56 | + colProps: { span: 6 }, | ||
| 57 | + componentProps: { | ||
| 58 | + options: typeOptions, | ||
| 59 | + }, | ||
| 60 | + }, | ||
| 61 | + { | ||
| 62 | + field: 'status', | ||
| 63 | + label: t('equipment.checkPlan.statusText'), | ||
| 64 | + component: 'Select', | ||
| 65 | + colProps: { span: 6 }, | ||
| 66 | + componentProps: { | ||
| 67 | + options: statusOptions, | ||
| 68 | + }, | ||
| 69 | + } | ||
| 70 | +]; | ||
| 71 | + | ||
| 72 | +export const schemas: FormSchema[] = [ | ||
| 73 | + { | ||
| 74 | + field: 'code', | ||
| 75 | + label: t('equipment.checkPlan.nameCode'), | ||
| 76 | + component: 'Input', | ||
| 77 | + colProps: { span: 21 }, | ||
| 78 | + required: true, | ||
| 79 | + componentProps: { | ||
| 80 | + maxLength: 20, | ||
| 81 | + }, | ||
| 82 | + }, | ||
| 83 | + { | ||
| 84 | + field: 'name', | ||
| 85 | + label: t('equipment.checkPlan.nameText'), | ||
| 86 | + component: 'Input', | ||
| 87 | + colProps: { span: 21 }, | ||
| 88 | + required: true, | ||
| 89 | + componentProps: { | ||
| 90 | + maxLength: 20, | ||
| 91 | + }, | ||
| 92 | + }, | ||
| 93 | + { | ||
| 94 | + field: 'type', | ||
| 95 | + label: t('equipment.checkPlan.typeText'), | ||
| 96 | + component: 'RadioButtonGroup', | ||
| 97 | + defaultValue: 'INSPECTION', | ||
| 98 | + componentProps: { | ||
| 99 | + options: typeOptions, | ||
| 100 | + }, | ||
| 101 | + }, | ||
| 102 | + { | ||
| 103 | + field: 'status', | ||
| 104 | + label: t('equipment.checkPlan.statusText'), | ||
| 105 | + component: 'RadioButtonGroup', | ||
| 106 | + defaultValue: 'ENABLE', | ||
| 107 | + componentProps: { | ||
| 108 | + options: statusOptions, | ||
| 109 | + }, | ||
| 110 | + }, | ||
| 111 | + { | ||
| 112 | + field: 'planDetails', | ||
| 113 | + label: t('equipment.checkPlan.nameDetail'), | ||
| 114 | + component: 'InputTextArea', | ||
| 115 | + colProps: { span: 21 }, | ||
| 116 | + required: true, | ||
| 117 | + componentProps: { | ||
| 118 | + maxLength: 200, | ||
| 119 | + }, | ||
| 120 | + }, | ||
| 121 | +]; |
src/views/equipment/checkPlan/index.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div> | ||
| 3 | + <BasicTable style="flex: auto" @register="registerTable"> | ||
| 4 | + <template #toolbar> | ||
| 5 | + <Authority value="api:yt:product:category:post"> | ||
| 6 | + <Button type="primary" @click="handleCreate"> | ||
| 7 | + {{ t('equipment.checkPlan.createCategoryText') }} | ||
| 8 | + </Button> | ||
| 9 | + </Authority> | ||
| 10 | + </template> | ||
| 11 | + <template #type="{ record }"> | ||
| 12 | + <Tag | ||
| 13 | + :color=" | ||
| 14 | + record.type == 'INSPECTION' | ||
| 15 | + ? 'blue' | ||
| 16 | + : record.type == 'MAINTENANCE' | ||
| 17 | + ? 'green' | ||
| 18 | + : 'error' | ||
| 19 | + " | ||
| 20 | + class="ml-2" | ||
| 21 | + > | ||
| 22 | + {{ t(`equipment.checkPlan.${record.type}`) }} | ||
| 23 | + </Tag> | ||
| 24 | + </template> | ||
| 25 | + <template #status="{ record }"> | ||
| 26 | + | ||
| 27 | + <Switch | ||
| 28 | + @click="(e) => handleSwitch(e, record)" | ||
| 29 | + :loading="switchLoading" | ||
| 30 | + v-model:checked="record.status" | ||
| 31 | + checkedValue="ENABLE" | ||
| 32 | + unCheckedValue="DISABLE" | ||
| 33 | + /> | ||
| 34 | + </template> | ||
| 35 | + <template #action="{ record }"> | ||
| 36 | + <TableAction | ||
| 37 | + :actions="[ | ||
| 38 | + { | ||
| 39 | + label: t('common.detailText'), | ||
| 40 | + icon: 'ant-design:eye-outlined', | ||
| 41 | + auth: 'api:yt:product:category:get', | ||
| 42 | + onClick: handleDetail.bind(null, record), | ||
| 43 | + }, | ||
| 44 | + { | ||
| 45 | + label: t('common.editText'), | ||
| 46 | + auth: 'api:yt:product:category:update', | ||
| 47 | + icon: 'clarity:note-edit-line', | ||
| 48 | + onClick: handleEdit.bind(null, record), | ||
| 49 | + }, | ||
| 50 | + { | ||
| 51 | + label: t('common.delText'), | ||
| 52 | + auth: 'api:yt:product:category:delete', | ||
| 53 | + icon: 'ant-design:delete-outlined', | ||
| 54 | + color: 'error', | ||
| 55 | + popConfirm: { | ||
| 56 | + title: t('common.deleteConfirmText'), | ||
| 57 | + confirm: handleDelete.bind(null, record), | ||
| 58 | + }, | ||
| 59 | + }, | ||
| 60 | + ]" | ||
| 61 | + /> | ||
| 62 | + </template> | ||
| 63 | + </BasicTable> | ||
| 64 | + <planModal @register="registerModal" @handleReload="handleReload" /> | ||
| 65 | + <FormDrawer | ||
| 66 | + @register="registerApplicationApiFormDrawer" | ||
| 67 | + /> | ||
| 68 | + </div> | ||
| 69 | +</template> | ||
| 70 | +<script setup lang="ts"> | ||
| 71 | +import {BasicTable, TableAction} from '/@/components/Table'; | ||
| 72 | +import {useTable} from "/@/components/Table"; | ||
| 73 | +import {columns, searchFormSchema} from "./index"; | ||
| 74 | +import {useI18n} from "/@/hooks/web/useI18n"; | ||
| 75 | +import {getPlanList} from "/@/api/equipment/chenkPlan"; | ||
| 76 | +import { planModal } from './components/index'; | ||
| 77 | +import {Button, Popconfirm, Switch, Tag} from "ant-design-vue"; | ||
| 78 | +import Icon from "/@/components/Icon"; | ||
| 79 | +import {Authority} from "/@/components/Authority"; | ||
| 80 | +import {useModal} from "/@/components/Modal"; | ||
| 81 | +import {deleteEquipmentPlan} from "/@/api/equipment/chenkPlan"; | ||
| 82 | +import {useMessage} from "/@/hooks/web/useMessage"; | ||
| 83 | +import {ref} from "vue"; | ||
| 84 | +const { t } = useI18n(); | ||
| 85 | +const [registerModal, { openModal }] = useModal(); | ||
| 86 | +const { createMessage } = useMessage(); | ||
| 87 | +const switchLoading = ref<boolean>(false); | ||
| 88 | +import {equipmentPlanCategory} from "/@/api/equipment/chenkPlan"; | ||
| 89 | +import {FormDrawer} from "./components/FormDrawer/index"; | ||
| 90 | +import {useDrawer} from "/@/components/Drawer"; | ||
| 91 | +const [registerApplicationApiFormDrawer, { openDrawer }] = useDrawer(); | ||
| 92 | +const [ | ||
| 93 | + registerTable, | ||
| 94 | + { reload, setLoading, getSelectRowKeys, setSelectedRowKeys, getRowSelection }, | ||
| 95 | +] = useTable({ | ||
| 96 | + title: t('equipment.checkPlan.listText'), | ||
| 97 | + api: getPlanList, | ||
| 98 | + columns, | ||
| 99 | + formConfig: { | ||
| 100 | + labelWidth: 100, | ||
| 101 | + schemas: searchFormSchema, | ||
| 102 | + }, | ||
| 103 | + immediate: true, | ||
| 104 | + useSearchForm: true, | ||
| 105 | + showTableSetting: true, | ||
| 106 | + bordered: true, | ||
| 107 | + showIndexColumn: false, | ||
| 108 | + clickToRowSelect: false, | ||
| 109 | + rowKey: 'id', | ||
| 110 | + actionColumn: { | ||
| 111 | + width: 230, | ||
| 112 | + title: t('common.actionText'), | ||
| 113 | + slots: { customRender: 'action' }, | ||
| 114 | + fixed: 'right', | ||
| 115 | + }, | ||
| 116 | + rowSelection: { | ||
| 117 | + type: 'checkbox', | ||
| 118 | + getCheckboxProps: (record: any) => {}, | ||
| 119 | + }, | ||
| 120 | +}); | ||
| 121 | + | ||
| 122 | +const handleReload = () => { | ||
| 123 | + setSelectedRowKeys([]); | ||
| 124 | + reload(); | ||
| 125 | +}; | ||
| 126 | + | ||
| 127 | +// 新增 | ||
| 128 | +const handleCreate = () => { | ||
| 129 | + openModal(true, { | ||
| 130 | + isUpdate: false, | ||
| 131 | + }); | ||
| 132 | +}; | ||
| 133 | + | ||
| 134 | +// 编辑 | ||
| 135 | +const handleEdit = (record?: any) => { | ||
| 136 | + openModal(true, { | ||
| 137 | + isUpdate: true, | ||
| 138 | + record, | ||
| 139 | + }); | ||
| 140 | +}; | ||
| 141 | + | ||
| 142 | +const handleDelete = async (record?: any) => { | ||
| 143 | + let id = record.id; | ||
| 144 | + try { | ||
| 145 | + setLoading(true); | ||
| 146 | + await deleteEquipmentPlan({ id }); | ||
| 147 | + createMessage.success(t('common.deleteSuccessText')); | ||
| 148 | + handleReload(); | ||
| 149 | + } catch (error) { | ||
| 150 | + throw error; | ||
| 151 | + } finally { | ||
| 152 | + setLoading(false); | ||
| 153 | + } | ||
| 154 | +}; | ||
| 155 | + | ||
| 156 | +// 状态->编辑 | ||
| 157 | +const handleSwitch = async (e: any, record: any) => { | ||
| 158 | + switchLoading.value = true; | ||
| 159 | + await equipmentPlanCategory({ ...record, status: e }); | ||
| 160 | + setTimeout(() => { | ||
| 161 | + switchLoading.value = false; | ||
| 162 | + }, 1500); | ||
| 163 | + createMessage.success( | ||
| 164 | + `${!e ? t('common.disableText') : t('common.enableText')}${t('common.successText')}` | ||
| 165 | + ); | ||
| 166 | + handleReload(); | ||
| 167 | +}; | ||
| 168 | + | ||
| 169 | +const handleDetail = (record?: any) => { | ||
| 170 | + openDrawer(true, { | ||
| 171 | + isUpdate: 2, | ||
| 172 | + record, | ||
| 173 | + }); | ||
| 174 | +}; | ||
| 175 | + | ||
| 176 | +</script> |
| @@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
| 6 | import { useMessage } from '/@/hooks/web/useMessage'; | 6 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 7 | import { useI18n } from '/@/hooks/web/useI18n'; | 7 | import { useI18n } from '/@/hooks/web/useI18n'; |
| 8 | import { JSONEditor } from '/@/components/CodeEditor'; | 8 | import { JSONEditor } from '/@/components/CodeEditor'; |
| 9 | - import { createApplicationApi, editApplicationApi } from '/@/api/application/api'; | ||
| 10 | import { ApplicationApiItemType } from '/@/api/application/model/api'; | 9 | import { ApplicationApiItemType } from '/@/api/application/model/api'; |
| 11 | 10 | ||
| 12 | const emits = defineEmits(['success', 'register']); | 11 | const emits = defineEmits(['success', 'register']); |
| @@ -19,8 +18,6 @@ | @@ -19,8 +18,6 @@ | ||
| 19 | 18 | ||
| 20 | const recordData = ref<ApplicationApiItemType>(); | 19 | const recordData = ref<ApplicationApiItemType>(); |
| 21 | 20 | ||
| 22 | - const jsonIsValid = ref(true); | ||
| 23 | - | ||
| 24 | const [registerForm, { resetFields, validate, setFieldsValue, setProps }] = useForm({ | 21 | const [registerForm, { resetFields, validate, setFieldsValue, setProps }] = useForm({ |
| 25 | labelWidth: 120, | 22 | labelWidth: 120, |
| 26 | schemas: formSchema, | 23 | schemas: formSchema, |
| @@ -53,38 +50,6 @@ | @@ -53,38 +50,6 @@ | ||
| 53 | } | 50 | } |
| 54 | }); | 51 | }); |
| 55 | 52 | ||
| 56 | - const getValue = async () => { | ||
| 57 | - const values = await validate(); | ||
| 58 | - if (!values) return; | ||
| 59 | - try { | ||
| 60 | - JSON.parse(values['param']); | ||
| 61 | - jsonIsValid.value = true; | ||
| 62 | - } catch (e) { | ||
| 63 | - jsonIsValid.value = false; | ||
| 64 | - console.error(e); | ||
| 65 | - } | ||
| 66 | - if (!jsonIsValid.value) return; | ||
| 67 | - const mergeValue = { | ||
| 68 | - ...recordData.value, | ||
| 69 | - ...values, | ||
| 70 | - }; | ||
| 71 | - if (handleCount.value === 0) { | ||
| 72 | - Reflect.set(values, 'param', JSON.parse(values['param'])); | ||
| 73 | - await createApplicationApi(values); | ||
| 74 | - } else { | ||
| 75 | - Reflect.set(mergeValue, 'param', JSON.parse(mergeValue['param'])); | ||
| 76 | - await editApplicationApi(mergeValue); | ||
| 77 | - } | ||
| 78 | - createMessage.success( | ||
| 79 | - unref(handleCount) === 0 ? t('common.createSuccessText') : t('common.editSuccessText') | ||
| 80 | - ); | ||
| 81 | - closeDrawer(); | ||
| 82 | - setTimeout(() => { | ||
| 83 | - emits('success'); | ||
| 84 | - }, 500); | ||
| 85 | - }; | ||
| 86 | - | ||
| 87 | - const handleSubmit = () => getValue(); | ||
| 88 | </script> | 53 | </script> |
| 89 | 54 | ||
| 90 | <template> | 55 | <template> |
| @@ -97,7 +62,6 @@ | @@ -97,7 +62,6 @@ | ||
| 97 | width="30%" | 62 | width="30%" |
| 98 | :maskClosable="true" | 63 | :maskClosable="true" |
| 99 | @register="registerDrawer" | 64 | @register="registerDrawer" |
| 100 | - @ok="handleSubmit" | ||
| 101 | > | 65 | > |
| 102 | <BasicForm @register="registerForm"> | 66 | <BasicForm @register="registerForm"> |
| 103 | <template #interfaceParamsSlot="{ model, field }"> | 67 | <template #interfaceParamsSlot="{ model, field }"> |