|
@@ -1,6 +1,28 @@
|
|
|
<template>
|
|
|
- <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
|
|
|
- <BasicForm @register="registerForm" ref="formRef" name="EquipmentAcceptForm"/>
|
|
|
+ <BasicModal
|
|
|
+ v-bind="$attrs"
|
|
|
+ @register="registerModal"
|
|
|
+ destroyOnClose
|
|
|
+ :title="title"
|
|
|
+ :width="1200"
|
|
|
+ :bodyStyle="{
|
|
|
+ padding: '20px 20px 0',
|
|
|
+ }"
|
|
|
+ @ok="handleSubmit"
|
|
|
+ >
|
|
|
+ <BasicForm @register="registerForm" ref="formRef" name="EquipmentAcceptForm">
|
|
|
+ <!-- 选择采购申请 --->
|
|
|
+ <template #purchaseApplicationId="{ model, field }">
|
|
|
+ <el-api-select v-model:value="model[field]" :api="applyList" :params="applyParams" labelField="purchaseTitle" placeholder="请选择采购申请" />
|
|
|
+ </template>
|
|
|
+ <!-- 选择前置验收单 --->
|
|
|
+ <template #preAcceptForm="{ model, field }">
|
|
|
+ <el-api-select v-model:value="model[field]" :api="acceptList" :params="params" placeholder="请选择前置验收单" />
|
|
|
+ </template>
|
|
|
+ <template #arrivalAcceptForm="{ model, field }">
|
|
|
+ <el-api-select v-model:value="model[field]" :api="acceptList" :params="arrivalParams" placeholder="请选择到货验收单" />
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
<!-- 子表单区域 -->
|
|
|
<a-tabs v-model:activeKey="activeKey" animated @change="handleChangeTabs">
|
|
|
<a-tab-pane tab="设备相关文件" key="equipmentRelatedFile" :forceRender="true">
|
|
@@ -16,7 +38,7 @@
|
|
|
:rowSelection="true"
|
|
|
:disabled="formDisabled"
|
|
|
:toolbar="true"
|
|
|
- />
|
|
|
+ />
|
|
|
</a-tab-pane>
|
|
|
<a-tab-pane tab="设备信息" key="equipmentInfo" :forceRender="true">
|
|
|
<JVxeTable
|
|
@@ -31,103 +53,145 @@
|
|
|
:rowSelection="true"
|
|
|
:disabled="formDisabled"
|
|
|
:toolbar="true"
|
|
|
- />
|
|
|
+ />
|
|
|
</a-tab-pane>
|
|
|
</a-tabs>
|
|
|
</BasicModal>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
- import {ref, computed, unref,reactive} from 'vue';
|
|
|
- import {BasicModal, useModalInner} from '/@/components/Modal';
|
|
|
- import {BasicForm, useForm} from '/@/components/Form/index';
|
|
|
- import { JVxeTable } from '/@/components/jeecg/JVxeTable'
|
|
|
- import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods.ts'
|
|
|
- import {formSchema,equipmentRelatedFileColumns,equipmentInfoColumns} from '../EquipmentAccept.data';
|
|
|
- import {saveOrUpdate,equipmentRelatedFileList,equipmentInfoList} from '../EquipmentAccept.api';
|
|
|
- import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'
|
|
|
- // Emits声明
|
|
|
- const emit = defineEmits(['register','success']);
|
|
|
- const isUpdate = ref(true);
|
|
|
- const formDisabled = ref(false);
|
|
|
- const refKeys = ref(['equipmentRelatedFile', 'equipmentInfo', ]);
|
|
|
- const activeKey = ref('equipmentRelatedFile');
|
|
|
- const equipmentRelatedFile = ref();
|
|
|
- const equipmentInfo = ref();
|
|
|
- const tableRefs = {equipmentRelatedFile, equipmentInfo, };
|
|
|
- const equipmentRelatedFileTable = reactive({
|
|
|
- loading: false,
|
|
|
- dataSource: [],
|
|
|
- columns:equipmentRelatedFileColumns
|
|
|
- })
|
|
|
- const equipmentInfoTable = reactive({
|
|
|
- loading: false,
|
|
|
- dataSource: [],
|
|
|
- columns:equipmentInfoColumns
|
|
|
- })
|
|
|
- //表单配置
|
|
|
- const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = useForm({
|
|
|
- labelWidth: 150,
|
|
|
- schemas: formSchema,
|
|
|
- showActionButtonGroup: false,
|
|
|
- baseColProps: {span: 24}
|
|
|
- });
|
|
|
- //表单赋值
|
|
|
- const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
|
|
|
- //重置表单
|
|
|
- await reset();
|
|
|
- setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter});
|
|
|
- isUpdate.value = !!data?.isUpdate;
|
|
|
- formDisabled.value = !data?.showFooter;
|
|
|
- if (unref(isUpdate)) {
|
|
|
- //表单赋值
|
|
|
- await setFieldsValue({
|
|
|
- ...data.record,
|
|
|
- });
|
|
|
- requestSubTableData(equipmentRelatedFileList, {id:data?.record?.id}, equipmentRelatedFileTable)
|
|
|
- requestSubTableData(equipmentInfoList, {id:data?.record?.id}, equipmentInfoTable)
|
|
|
- }
|
|
|
- // 隐藏底部时禁用整个表单
|
|
|
- setProps({ disabled: !data?.showFooter })
|
|
|
- });
|
|
|
- //方法配置
|
|
|
- const [handleChangeTabs,handleSubmit,requestSubTableData,formRef] = useJvxeMethod(requestAddOrEdit,classifyIntoFormData,tableRefs,activeKey,refKeys);
|
|
|
+ import { ref, computed, unref, reactive } from 'vue';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
+ import { JVxeTable } from '/@/components/jeecg/JVxeTable';
|
|
|
+ import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods';
|
|
|
+ import { formSchema, equipmentRelatedFileColumns, equipmentInfoColumns } from '../EquipmentAccept.data';
|
|
|
+ import { saveOrUpdate, equipmentRelatedFileList, equipmentInfoList } from '../EquipmentAccept.api';
|
|
|
+ import { useUserStore } from '/@/store/modules/user';
|
|
|
+ import { list as applyList } from '../../apply/PurchaseApplication.api';
|
|
|
+ import { list as acceptList } from '../EquipmentAccept.api';
|
|
|
+ import ElApiSelect from '/@/views/equipmentLifecycle/components/ElApiSelect.vue';
|
|
|
|
|
|
- //设置标题
|
|
|
- const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(formDisabled) ? '编辑' : '详情'));
|
|
|
+ const userStore = useUserStore();
|
|
|
+ // Emits声明
|
|
|
+ const emit = defineEmits(['register', 'success']);
|
|
|
+ const isUpdate = ref(true);
|
|
|
+ const formDisabled = ref(false);
|
|
|
+ const refKeys = ref(['equipmentRelatedFile', 'equipmentInfo']);
|
|
|
+ const activeKey = ref('equipmentRelatedFile');
|
|
|
+ const equipmentRelatedFile = ref();
|
|
|
+ const equipmentInfo = ref();
|
|
|
+ const tableRefs = { equipmentRelatedFile, equipmentInfo };
|
|
|
+ const equipmentRelatedFileTable = reactive({
|
|
|
+ loading: false,
|
|
|
+ dataSource: [],
|
|
|
+ columns: equipmentRelatedFileColumns,
|
|
|
+ });
|
|
|
+ const equipmentInfoTable = reactive({
|
|
|
+ loading: false,
|
|
|
+ dataSource: [],
|
|
|
+ columns: equipmentInfoColumns,
|
|
|
+ });
|
|
|
+ //表单配置
|
|
|
+ const [registerForm, { setProps, resetFields, setFieldsValue }] = useForm({
|
|
|
+ labelWidth: 130,
|
|
|
+ schemas: formSchema,
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ baseColProps: { span: 24 },
|
|
|
+ });
|
|
|
|
|
|
- async function reset(){
|
|
|
- await resetFields();
|
|
|
- activeKey.value = 'equipmentRelatedFile';
|
|
|
- equipmentRelatedFileTable.dataSource = [];
|
|
|
- equipmentInfoTable.dataSource = [];
|
|
|
+ const info = ref<any>({});
|
|
|
+ const params = ref<any>(null);
|
|
|
+ const arrivalParams = ref<any>(null);
|
|
|
+ const applyParams = ref<any>({ approvalStatus: 1 });
|
|
|
+ //表单赋值
|
|
|
+ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
|
|
+ //重置表单
|
|
|
+ await reset();
|
|
|
+ setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter });
|
|
|
+ isUpdate.value = !!data?.isUpdate;
|
|
|
+ formDisabled.value = !data?.showFooter;
|
|
|
+ info.value = data.record || {};
|
|
|
+ if (unref(isUpdate)) {
|
|
|
+ //表单赋值
|
|
|
+ await setFieldsValue({
|
|
|
+ ...data.record,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (typeof requestSubTableData === 'function') {
|
|
|
+ requestSubTableData(equipmentRelatedFileList, { id: data?.record?.id }, equipmentRelatedFileTable);
|
|
|
+ requestSubTableData(equipmentInfoList, { id: data?.record?.id }, equipmentInfoTable);
|
|
|
+ }
|
|
|
+
|
|
|
+ params.value = {
|
|
|
+ superQueryMatchType: 'and',
|
|
|
+ superQueryParams: encodeURIComponent(JSON.stringify([{ field: 'id', rule: 'ne', val: data.record?.id, type: 'text', dbType: 'string' }])),
|
|
|
+ };
|
|
|
+
|
|
|
+ arrivalParams.value = {
|
|
|
+ superQueryMatchType: 'and',
|
|
|
+ superQueryParams: encodeURIComponent(
|
|
|
+ JSON.stringify([
|
|
|
+ { field: 'id', rule: 'ne', val: data.record?.id, type: 'text', dbType: 'string' },
|
|
|
+ { field: 'acceptType', rule: 'eq', val: '1', type: 'text', dbType: 'string' },
|
|
|
+ ])
|
|
|
+ ),
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ await setFieldsValue({
|
|
|
+ accepter: userStore.getUserInfo.username,
|
|
|
+ });
|
|
|
}
|
|
|
- function classifyIntoFormData(allValues) {
|
|
|
- let main = Object.assign({}, allValues.formValue)
|
|
|
- return {
|
|
|
- ...main, // 展开
|
|
|
- equipmentRelatedFileList: allValues.tablesValue[0].tableData,
|
|
|
- equipmentInfoList: allValues.tablesValue[1].tableData,
|
|
|
- }
|
|
|
- }
|
|
|
- //表单提交事件
|
|
|
- async function requestAddOrEdit(values) {
|
|
|
- try {
|
|
|
- setModalProps({confirmLoading: true});
|
|
|
- //提交表单
|
|
|
- await saveOrUpdate(values, isUpdate.value);
|
|
|
- //关闭弹窗
|
|
|
- closeModal();
|
|
|
- //刷新列表
|
|
|
- emit('success');
|
|
|
- } finally {
|
|
|
- setModalProps({confirmLoading: false});
|
|
|
- }
|
|
|
+ // 隐藏底部时禁用整个表单
|
|
|
+ setProps({ disabled: !data?.showFooter });
|
|
|
+ });
|
|
|
+ //方法配置
|
|
|
+ const [handleChangeTabs, handleSubmit, requestSubTableData, formRef] = useJvxeMethod(
|
|
|
+ requestAddOrEdit,
|
|
|
+ classifyIntoFormData,
|
|
|
+ tableRefs,
|
|
|
+ activeKey,
|
|
|
+ refKeys
|
|
|
+ );
|
|
|
+
|
|
|
+ //设置标题
|
|
|
+ const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(formDisabled) ? '编辑' : '详情'));
|
|
|
+
|
|
|
+ async function reset() {
|
|
|
+ await resetFields();
|
|
|
+ activeKey.value = 'equipmentRelatedFile';
|
|
|
+ equipmentRelatedFileTable.dataSource = [];
|
|
|
+ equipmentInfoTable.dataSource = [];
|
|
|
+ }
|
|
|
+ function classifyIntoFormData(allValues) {
|
|
|
+ let main = Object.assign({}, allValues.formValue);
|
|
|
+ return {
|
|
|
+ ...main, // 展开
|
|
|
+ equipmentRelatedFileList: allValues.tablesValue[0].tableData,
|
|
|
+ equipmentInfoList: allValues.tablesValue[1].tableData,
|
|
|
+ };
|
|
|
+ }
|
|
|
+ //表单提交事件
|
|
|
+ async function requestAddOrEdit(values) {
|
|
|
+ console.log(values);
|
|
|
+
|
|
|
+ return;
|
|
|
+ try {
|
|
|
+ setModalProps({ confirmLoading: true });
|
|
|
+ //提交表单
|
|
|
+ await saveOrUpdate(values, isUpdate.value);
|
|
|
+ //关闭弹窗
|
|
|
+ closeModal();
|
|
|
+ //刷新列表
|
|
|
+ emit('success');
|
|
|
+ } finally {
|
|
|
+ setModalProps({ confirmLoading: false });
|
|
|
}
|
|
|
+ }
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
- /** 时间和数字输入框样式 */
|
|
|
+ /** 时间和数字输入框样式 */
|
|
|
:deep(.ant-input-number) {
|
|
|
width: 100%;
|
|
|
}
|
|
@@ -135,4 +199,4 @@
|
|
|
:deep(.ant-calendar-picker) {
|
|
|
width: 100%;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|