refactor: 统一 Vben 表单弹窗模式为 formType 并更新规范
parent
3acc821de5
commit
44b62e14ac
|
|
@ -10,8 +10,11 @@ import { getSupplierSimpleList } from '#/api/erp/purchase/supplier';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增付款单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑付款单 */
|
||||
function handleEdit(row: ErpFinancePaymentApi.FinancePayment) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除付款单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpFinancePaymentApi.FinancePayment) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpFinancePaymentApi } from '#/api/erp/finance/payment';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -40,7 +42,7 @@ const formData = ref<
|
|||
status: 0,
|
||||
});
|
||||
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -145,8 +147,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ import { getCustomerSimpleList } from '#/api/erp/sale/customer';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增收款单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑收款单 */
|
||||
function handleEdit(row: ErpFinanceReceiptApi.FinanceReceipt) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除收款单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpFinanceReceiptApi.FinanceReceipt) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpFinanceReceiptApi } from '#/api/erp/finance/receipt';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -40,7 +42,7 @@ const formData = ref<
|
|||
status: 0,
|
||||
});
|
||||
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -159,8 +161,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增采购入库 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑采购入库 */
|
||||
function handleEdit(row: ErpPurchaseInApi.PurchaseIn) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除采购入库 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpPurchaseInApi.PurchaseIn) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpPurchaseInApi } from '#/api/erp/purchase/in';
|
||||
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
|
||||
|
||||
|
|
@ -46,7 +48,7 @@ const formData = ref<
|
|||
otherPrice: 0,
|
||||
items: [],
|
||||
});
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -175,8 +177,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,11 @@ import { getSupplierSimpleList } from '#/api/erp/purchase/supplier';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增采购订单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑采购订单 */
|
||||
function handleEdit(row: ErpPurchaseOrderApi.PurchaseOrder) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除采购订单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpPurchaseOrderApi.PurchaseOrder) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -21,7 +23,7 @@ import PurchaseOrderItemForm from './item-form.vue';
|
|||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpPurchaseOrderApi.PurchaseOrder>();
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof PurchaseOrderItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -124,8 +126,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -45,17 +45,17 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 新增采购退货 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑采购退货 */
|
||||
function handleEdit(row: ErpPurchaseReturnApi.PurchaseReturn) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpPurchaseReturnApi.PurchaseReturn) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除采购退货 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpPurchaseOrderApi } from '#/api/erp/purchase/order';
|
||||
import type { ErpPurchaseReturnApi } from '#/api/erp/purchase/return';
|
||||
|
||||
|
|
@ -46,7 +48,7 @@ const formData = ref<
|
|||
otherPrice: 0,
|
||||
items: [],
|
||||
});
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
/* eslint-disable unicorn/no-nested-ternary */
|
||||
|
|
@ -175,8 +177,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,11 @@ import { getCustomerSimpleList } from '#/api/erp/sale/customer';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增销售订单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑销售订单 */
|
||||
function handleEdit(row: ErpSaleOrderApi.SaleOrder) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除销售订单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpSaleOrderApi.SaleOrder) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -21,7 +23,7 @@ import ItemForm from './item-form.vue';
|
|||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpSaleOrderApi.SaleOrder>();
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -114,8 +116,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增销售出库 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑销售出库 */
|
||||
function handleEdit(row: ErpSaleOutApi.SaleOut) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除销售出库 */
|
||||
|
|
@ -91,7 +91,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpSaleOutApi.SaleOut) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
|
||||
import type { ErpSaleOutApi } from '#/api/erp/sale/out';
|
||||
|
||||
|
|
@ -42,7 +44,7 @@ const formData = ref<
|
|||
otherPrice: 0,
|
||||
items: [],
|
||||
});
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
/* eslint-disable unicorn/no-nested-ternary */
|
||||
|
|
@ -170,8 +172,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增销售退货 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑销售退货 */
|
||||
function handleEdit(row: ErpSaleReturnApi.SaleReturn) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除销售退货 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpSaleReturnApi.SaleReturn) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpSaleOrderApi } from '#/api/erp/sale/order';
|
||||
import type { ErpSaleReturnApi } from '#/api/erp/sale/return';
|
||||
|
||||
|
|
@ -46,7 +48,7 @@ const formData = ref<
|
|||
otherPrice: 0,
|
||||
items: [],
|
||||
});
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -175,8 +177,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增库存盘点单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑库存盘点单 */
|
||||
function handleEdit(row: ErpStockCheckApi.StockCheck) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除库存盘点单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpStockCheckApi.StockCheck) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpStockCheckApi } from '#/api/erp/stock/check';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -20,7 +22,7 @@ import ItemForm from './item-form.vue';
|
|||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpStockCheckApi.StockCheck>();
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -93,8 +95,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增其它入库单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑其它入库单 */
|
||||
function handleEdit(row: ErpStockInApi.StockIn) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除其它入库单 */
|
||||
|
|
@ -91,7 +91,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpStockInApi.StockIn) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpStockInApi } from '#/api/erp/stock/in';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -16,7 +18,7 @@ import ItemForm from './item-form.vue';
|
|||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpStockInApi.StockIn>();
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -89,8 +91,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增库存调拨单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑库存调拨单 */
|
||||
function handleEdit(row: ErpStockMoveApi.StockMove) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除库存调拨单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpStockMoveApi.StockMove) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpStockMoveApi } from '#/api/erp/stock/move';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -20,7 +22,7 @@ import ItemForm from './item-form.vue';
|
|||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpStockMoveApi.StockMove>();
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -93,8 +95,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ import { getWarehouseSimpleList } from '#/api/erp/stock/warehouse';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'edit';
|
||||
|
||||
/** 表单的配置项 */
|
||||
export function useFormSchema(formType: string): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ async function handleExport() {
|
|||
|
||||
/** 新增其它出库单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑其它出库单 */
|
||||
function handleEdit(row: ErpStockOutApi.StockOut) {
|
||||
formModalApi.setData({ type: 'edit', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'edit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除其它出库单 */
|
||||
|
|
@ -94,7 +94,7 @@ function handleRowCheckboxChange({
|
|||
|
||||
/** 查看详情 */
|
||||
function handleDetail(row: ErpStockOutApi.StockOut) {
|
||||
formModalApi.setData({ type: 'detail', id: row.id }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { ErpStockOutApi } from '#/api/erp/stock/out';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -20,7 +22,7 @@ import ItemForm from './item-form.vue';
|
|||
|
||||
const emit = defineEmits(['success']);
|
||||
const formData = ref<ErpStockOutApi.StockOut>();
|
||||
const formType = ref(''); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const formType = ref<FormType>('create'); // 表单类型:'create' | 'edit' | 'detail'
|
||||
const itemFormRef = ref<InstanceType<typeof ItemForm>>();
|
||||
|
||||
const getTitle = computed(() => {
|
||||
|
|
@ -93,8 +95,8 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type: string }>();
|
||||
formType.value = data.type;
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
formApi.updateSchema(useFormSchema(formType.value));
|
||||
if (!data || !data.id) {
|
||||
|
|
|
|||
|
|
@ -34,12 +34,12 @@ function handleRefresh() {
|
|||
|
||||
/** 创建固件 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData(null).open();
|
||||
}
|
||||
|
||||
/** 编辑固件 */
|
||||
function handleEdit(row: IoTOtaFirmwareApi.Firmware) {
|
||||
formModalApi.setData({ type: 'update', id: row.id }).open();
|
||||
formModalApi.setData({ id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除固件 */
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import {
|
|||
MesCalShiftTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改排班计划的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建排班计划 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看排班计划 */
|
||||
function handleDetail(row: MesCalPlanApi.Plan) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑排班计划 */
|
||||
function handleEdit(row: MesCalPlanApi.Plan) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除排班计划 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesCalPlanApi } from '#/api/mes/cal/plan';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -16,21 +18,19 @@ import { useFormSchema } from '../data';
|
|||
import ShiftList from './shift-list.vue';
|
||||
import PlanTeamList from './team-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('shift'); // 当前资源页签
|
||||
const formData = ref<MesCalPlanApi.Plan>();
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const canConfirm = computed(
|
||||
() => formMode.value === 'update' && formData.value?.status === MesCalPlanStatusEnum.PREPARE,
|
||||
() => formType.value === 'update' && formData.value?.status === MesCalPlanStatusEnum.PREPARE,
|
||||
); // 是否可确认计划
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['排班计划']);
|
||||
}
|
||||
return formMode.value === 'update'
|
||||
return formType.value === 'update'
|
||||
? $t('ui.actionTitle.edit', ['排班计划'])
|
||||
: $t('ui.actionTitle.create', ['排班计划']);
|
||||
});
|
||||
|
|
@ -86,11 +86,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesCalPlanApi.Plan;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createPlan(data);
|
||||
formData.value = { ...data, id: id as number, status: MesCalPlanStatusEnum.PREPARE };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updatePlan(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -109,10 +109,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'shift';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -132,15 +132,15 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="shift" tab="班次">
|
||||
<ShiftList :form-type="formMode" :plan-id="formData.id" />
|
||||
<ShiftList :form-type="formType" :plan-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="team" tab="班组">
|
||||
<PlanTeamList :form-type="formMode" :plan-id="formData.id" />
|
||||
<PlanTeamList :form-type="formType" :plan-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<template #prepend-footer>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesCalPlanShiftApi } from '#/api/mes/cal/plan/shift';
|
||||
|
||||
|
|
@ -16,7 +18,7 @@ import {
|
|||
} from '#/api/mes/cal/plan/shift';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
const props = withDefaults(defineProps<{ formType?: string; planId: number }>(), {
|
||||
const props = withDefaults(defineProps<{ formType?: FormType; planId: number }>(), {
|
||||
formType: 'update',
|
||||
});
|
||||
const isEditable = computed(() => props.formType !== 'detail'); // 是否可编辑
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesCalPlanTeamApi } from '#/api/mes/cal/plan/team';
|
||||
import type { MesCalTeamApi } from '#/api/mes/cal/team';
|
||||
|
|
@ -14,7 +16,7 @@ import { getTeamMemberListByTeam } from '#/api/mes/cal/team/member';
|
|||
import { $t } from '#/locales';
|
||||
import { CalTeamSelectDialog } from '#/views/mes/cal/team/components';
|
||||
|
||||
const props = withDefaults(defineProps<{ formType?: string; planId: number }>(), {
|
||||
const props = withDefaults(defineProps<{ formType?: FormType; planId: number }>(), {
|
||||
formType: 'update',
|
||||
});
|
||||
const isEditable = computed(() => props.formType !== 'detail'); // 是否可编辑
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import { z } from '#/adapter/form';
|
|||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改班组的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建班组 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看班组 */
|
||||
function handleDetail(row: MesCalTeamApi.Team) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑班组 */
|
||||
function handleEdit(row: MesCalTeamApi.Team) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除班组 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesCalTeamApi } from '#/api/mes/cal/team';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -15,18 +17,16 @@ import { useFormSchema } from '../data';
|
|||
import MemberList from './member-list.vue';
|
||||
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('member'); // 当前资源页签
|
||||
const formData = ref<MesCalTeamApi.Team>();
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['班组']);
|
||||
}
|
||||
return formMode.value === 'update'
|
||||
return formType.value === 'update'
|
||||
? $t('ui.actionTitle.edit', ['班组'])
|
||||
: $t('ui.actionTitle.create', ['班组']);
|
||||
});
|
||||
|
|
@ -62,11 +62,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesCalTeamApi.Team;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createTeam(data);
|
||||
formData.value = { ...data, id: id as number };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updateTeam(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -85,10 +85,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'member';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -108,12 +108,12 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="member" tab="班组成员">
|
||||
<MemberList :form-type="formMode" :team-id="formData.id" />
|
||||
<MemberList :form-type="formType" :team-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</Modal>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesCalTeamMemberApi } from '#/api/mes/cal/team/member';
|
||||
|
||||
|
|
@ -16,7 +18,7 @@ import {
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
const props = withDefaults(defineProps<{ formType?: string; teamId: number }>(), {
|
||||
const props = withDefaults(defineProps<{ formType?: FormType; teamId: number }>(), {
|
||||
formType: 'update',
|
||||
});
|
||||
const isEditable = computed(() => ['create', 'update'].includes(props.formType)); // 是否可编辑
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import {
|
|||
MesDvSubjectTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改点检保养方案的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -34,17 +34,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建点检计划 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看点检计划 */
|
||||
function handleDetail(row: MesDvCheckPlanApi.CheckPlan) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑点检计划 */
|
||||
function handleEdit(row: MesDvCheckPlanApi.CheckPlan) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除点检计划 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesDvCheckPlanApi } from '#/api/mes/dv/checkplan';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -16,18 +18,16 @@ import { useFormSchema } from '../data';
|
|||
import MachineryList from './machinery-list.vue';
|
||||
import SubjectList from './subject-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create');
|
||||
const formType = ref<FormType>('create');
|
||||
const subTabsName = ref('machinery');
|
||||
const formData = ref<MesDvCheckPlanApi.CheckPlan>();
|
||||
const isDetail = computed(() => formMode.value === 'detail');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看点检保养方案';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改点检保养方案' : '新增点检保养方案';
|
||||
return formType.value === 'update' ? '修改点检保养方案' : '新增点检保养方案';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -61,11 +61,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesDvCheckPlanApi.CheckPlan;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createCheckPlan(data);
|
||||
formData.value = { ...data, id: id as number, status: MesDvCheckPlanStatusEnum.PREPARE };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updateCheckPlan(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -84,10 +84,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'machinery';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -106,15 +106,15 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="machinery" tab="设备">
|
||||
<MachineryList :form-type="formMode" :plan-id="formData.id" />
|
||||
<MachineryList :form-type="formType" :plan-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="subject" tab="项目">
|
||||
<SubjectList :form-type="formMode" :plan-id="formData.id" :plan-type="formData.type" />
|
||||
<SubjectList :form-type="formType" :plan-id="formData.id" :plan-type="formData.type" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
</Modal>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesDvCheckPlanMachineryApi } from '#/api/mes/dv/checkplan/machinery';
|
||||
|
||||
|
|
@ -17,7 +19,7 @@ import { $t } from '#/locales';
|
|||
import { DvMachinerySelect } from '#/views/mes/dv/machinery/components';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ formType?: string; planId: number; planType?: number }>(),
|
||||
defineProps<{ formType?: FormType; planId: number; planType?: number }>(),
|
||||
{ formType: 'update', planType: undefined },
|
||||
);
|
||||
const isEditable = computed(() => props.formType !== 'detail');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesDvCheckPlanSubjectApi } from '#/api/mes/dv/checkplan/subject';
|
||||
|
||||
|
|
@ -19,7 +21,7 @@ import { $t } from '#/locales';
|
|||
import { DvSubjectSelect } from '#/views/mes/dv/subject/components';
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{ formType?: string; planId: number; planType?: number }>(),
|
||||
defineProps<{ formType?: FormType; planId: number; planType?: number }>(),
|
||||
{ formType: 'update', planType: undefined },
|
||||
);
|
||||
const isEditable = computed(() => props.formType !== 'detail');
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ import {
|
|||
MesDvSubjectTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改点检记录的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -27,17 +27,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建点检记录 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看点检记录 */
|
||||
function handleDetail(row: MesDvCheckRecordApi.CheckRecord) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑点检记录 */
|
||||
function handleEdit(row: MesDvCheckRecordApi.CheckRecord) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除点检记录 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesDvCheckRecordApi } from '#/api/mes/dv/checkrecord';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -20,20 +22,18 @@ import { MesDvCheckRecordStatusEnum } from '#/views/mes/utils/constants';
|
|||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create');
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesDvCheckRecordApi.CheckRecord>();
|
||||
const isDetail = computed(() => formMode.value === 'detail');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canSubmit = computed(
|
||||
() => formMode.value === 'update' && formData.value?.status === MesDvCheckRecordStatusEnum.DRAFT,
|
||||
() => formType.value === 'update' && formData.value?.status === MesDvCheckRecordStatusEnum.DRAFT,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看点检记录';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改点检记录' : '新增点检记录';
|
||||
return formType.value === 'update' ? '修改点检记录' : '新增点检记录';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -83,11 +83,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesDvCheckRecordApi.CheckRecord;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createCheckRecord(data);
|
||||
formData.value = { ...data, id: id as number, status: MesDvCheckRecordStatusEnum.DRAFT };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updateCheckRecord(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -105,10 +105,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
}
|
||||
await formApi.resetForm();
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
import type { Ref } from 'vue';
|
||||
|
||||
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesDvMachineryApi } from '#/api/mes/dv/machinery';
|
||||
|
|
@ -18,8 +16,11 @@ import { MesAutoCodeRuleCode, MesDvMachineryStatusEnum } from '#/views/mes/utils
|
|||
|
||||
import { DvMachineryTypeSelect } from './type/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改设备的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi, formMode?: Ref<string>): VbenFormSchema[] {
|
||||
export function useFormSchema(formType: FormType, formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
{
|
||||
fieldName: 'id',
|
||||
|
|
@ -125,7 +126,7 @@ export function useFormSchema(formApi?: VbenFormApi, formMode?: Ref<string>): Vb
|
|||
},
|
||||
dependencies: {
|
||||
triggerFields: ['id'],
|
||||
show: () => formMode?.value === 'detail',
|
||||
show: () => formType === 'detail',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
@ -141,7 +142,7 @@ export function useFormSchema(formApi?: VbenFormApi, formMode?: Ref<string>): Vb
|
|||
},
|
||||
dependencies: {
|
||||
triggerFields: ['id'],
|
||||
show: () => formMode?.value === 'detail',
|
||||
show: () => formType === 'detail',
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,17 +37,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建设备 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看设备 */
|
||||
function handleDetail(row: MesDvMachineryApi.Machinery) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑设备 */
|
||||
function handleEdit(row: MesDvMachineryApi.Machinery) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除设备 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesDvMachineryApi } from '#/api/mes/dv/machinery';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -18,19 +20,17 @@ import CheckRecordList from './check-record-list.vue';
|
|||
import MaintenRecordList from './mainten-record-list.vue';
|
||||
import RepairList from './repair-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('check'); // 当前资源页签
|
||||
const formData = ref<MesDvMachineryApi.Machinery>();
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看设备';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改设备' : '新增设备';
|
||||
return formType.value === 'update' ? '修改设备' : '新增设备';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -48,7 +48,7 @@ const [Form, formApi] = useVbenForm({
|
|||
});
|
||||
|
||||
/** 表单 schema 需要 formApi 引用,所以通过 setState 设置 schema */
|
||||
formApi.setState({ schema: useFormSchema(formApi, formMode) });
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
|
||||
/** 查看设备条码 */
|
||||
function handleBarcode() {
|
||||
|
|
@ -94,10 +94,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'check';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -117,7 +118,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ import {
|
|||
MesDvSubjectTypeEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改保养记录的表单 */
|
||||
export function useFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -31,17 +31,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建保养记录 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看保养记录 */
|
||||
function handleDetail(row: MesDvMaintenRecordApi.MaintenRecord) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑保养记录 */
|
||||
function handleEdit(row: MesDvMaintenRecordApi.MaintenRecord) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除保养记录 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesDvMaintenRecordApi } from '#/api/mes/dv/maintenrecord';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -21,22 +23,20 @@ import { MesDvMaintenRecordStatusEnum } from '#/views/mes/utils/constants';
|
|||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const userStore = useUserStore();
|
||||
const formMode = ref<FormMode>('create');
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesDvMaintenRecordApi.MaintenRecord>();
|
||||
const isDetail = computed(() => formMode.value === 'detail');
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
formMode.value === 'update' && formData.value?.status === MesDvMaintenRecordStatusEnum.PREPARE,
|
||||
formType.value === 'update' && formData.value?.status === MesDvMaintenRecordStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看保养记录';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改保养记录' : '新增保养记录';
|
||||
return formType.value === 'update' ? '修改保养记录' : '新增保养记录';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -86,7 +86,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesDvMaintenRecordApi.MaintenRecord;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createMaintenRecord(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
|
|
@ -94,7 +94,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
status: MesDvMaintenRecordStatusEnum.PREPARE,
|
||||
};
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updateMaintenRecord(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -112,10 +112,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
}
|
||||
await formApi.resetForm();
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
await formApi.setFieldValue('userId', userStore.userInfo?.id);
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import { getSimpleUserList } from '#/api/system/user';
|
|||
import { getRangePickerDefaultProps } from '#/utils';
|
||||
import { DvMachinerySelect } from '#/views/mes/dv/machinery/components';
|
||||
import { MesAutoCodeRuleCode, MesDvRepairStatusEnum } from '#/views/mes/utils/constants';
|
||||
/** 表单类型 */
|
||||
export type FormType = 'confirm' | 'create' | 'detail' | 'finish' | 'update';
|
||||
|
||||
/** 新增/修改维修工单的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -27,27 +27,27 @@ function handleRefresh() {
|
|||
|
||||
/** 创建维修工单 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看维修工单 */
|
||||
function handleDetail(row: MesDvRepairApi.Repair) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑维修工单 */
|
||||
function handleEdit(row: MesDvRepairApi.Repair) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 完成维修 */
|
||||
function handleConfirm(row: MesDvRepairApi.Repair) {
|
||||
formModalApi.setData({ id: row.id, type: 'confirm' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'confirm' }).open();
|
||||
}
|
||||
|
||||
/** 验收维修 */
|
||||
function handleFinish(row: MesDvRepairApi.Repair) {
|
||||
formModalApi.setData({ id: row.id, type: 'finish' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'finish' }).open();
|
||||
}
|
||||
|
||||
/** 删除维修工单 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesDvRepairApi } from '#/api/mes/dv/repair';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -22,15 +24,13 @@ import { MesDvRepairResultEnum, MesDvRepairStatusEnum } from '#/views/mes/utils/
|
|||
import { useFormSchema } from '../data';
|
||||
import LineList from './line-list.vue';
|
||||
|
||||
type FormMode = 'confirm' | 'create' | 'detail' | 'finish' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create');
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesDvRepairApi.Repair>();
|
||||
const isDetail = computed(() => formMode.value === 'detail');
|
||||
const isReadonly = computed(() => ['confirm', 'detail', 'finish'].includes(formMode.value));
|
||||
const isDetail = computed(() => formType.value === 'detail');
|
||||
const isReadonly = computed(() => ['confirm', 'detail', 'finish'].includes(formType.value));
|
||||
const canSubmit = computed(
|
||||
() => formMode.value === 'update' && formData.value?.status === MesDvRepairStatusEnum.PREPARE,
|
||||
() => formType.value === 'update' && formData.value?.status === MesDvRepairStatusEnum.PREPARE,
|
||||
);
|
||||
const getTitle = computed(
|
||||
() =>
|
||||
|
|
@ -40,7 +40,7 @@ const getTitle = computed(
|
|||
confirm: '完成维修',
|
||||
finish: '验收维修',
|
||||
detail: '查看维修工单',
|
||||
})[formMode.value],
|
||||
})[formType.value],
|
||||
);
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -132,7 +132,7 @@ async function doFinish(result: number) {
|
|||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (isDetail.value || formMode.value === 'confirm' || formMode.value === 'finish') {
|
||||
if (isDetail.value || formType.value === 'confirm' || formType.value === 'finish') {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
|
|
@ -144,11 +144,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesDvRepairApi.Repair;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createRepair(data);
|
||||
formData.value = { ...data, id: id as number, status: MesDvRepairStatusEnum.PREPARE };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updateRepair(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -166,10 +166,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
}
|
||||
await formApi.resetForm();
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(isReadonly.value);
|
||||
modalApi.setState({ showConfirmButton: ['create', 'update'].includes(formMode.value) });
|
||||
modalApi.setState({ showConfirmButton: ['create', 'update'].includes(formType.value) });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -198,21 +198,21 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Button type="primary">提交</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
v-if="formMode === 'confirm'"
|
||||
v-if="formType === 'confirm'"
|
||||
title="确认完成维修?完成后进入待验收。"
|
||||
@confirm="handleConfirm"
|
||||
>
|
||||
<Button type="primary">完成维修</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
v-if="formMode === 'finish'"
|
||||
v-if="formType === 'finish'"
|
||||
title="确认完成验收?"
|
||||
@confirm="handleFinish(MesDvRepairResultEnum.PASS)"
|
||||
>
|
||||
<Button type="primary">验收通过</Button>
|
||||
</Popconfirm>
|
||||
<Popconfirm
|
||||
v-if="formMode === 'finish'"
|
||||
v-if="formType === 'finish'"
|
||||
title="确认完成验收?"
|
||||
@confirm="handleFinish(MesDvRepairResultEnum.FAIL)"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import { z } from '#/adapter/form';
|
|||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MesAutoCodeRuleCode, MesDvSubjectTypeEnum } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改点检保养项目的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -26,17 +26,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建点检保养项目 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看点检保养项目 */
|
||||
function handleDetail(row: MesDvSubjectApi.Subject) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑点检保养项目 */
|
||||
function handleEdit(row: MesDvSubjectApi.Subject) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除点检保养项目 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesDvSubjectApi } from '#/api/mes/dv/subject';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -13,16 +15,14 @@ import { $t } from '#/locales';
|
|||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看点检保养项目';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改点检保养项目' : '新增点检保养项目';
|
||||
return formType.value === 'update' ? '修改点检保养项目' : '新增点检保养项目';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -71,10 +71,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
}
|
||||
await formApi.resetForm();
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import { z } from '#/adapter/form';
|
|||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改客户的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -32,17 +32,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建客户 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看客户 */
|
||||
function handleDetail(row: MesMdClientApi.Client) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑客户 */
|
||||
function handleEdit(row: MesMdClientApi.Client) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除客户 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdClientApi } from '#/api/mes/md/client';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -15,19 +17,17 @@ import { useFormSchema } from '../data';
|
|||
import ClientProductSalesLineList from './product-sales-line-list.vue';
|
||||
import ClientProductSalesList from './product-sales-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('productSalesLine'); // 当前子表页签
|
||||
const formData = ref<MesMdClientApi.Client>();
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看客户';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改客户' : '新增客户';
|
||||
return formType.value === 'update' ? '修改客户' : '新增客户';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -78,10 +78,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'productSalesLine';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -101,7 +101,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const [ItemFormModal, itemFormModalApi] = useVbenModal({
|
|||
|
||||
/** 查看物料详情 */
|
||||
function handleViewItem(row: MesWmProductSalesLineApi.ProductSalesLine) {
|
||||
itemFormModalApi.setData({ id: row.itemId, type: 'detail' }).open();
|
||||
itemFormModalApi.setData({ id: row.itemId, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -16,6 +16,9 @@ import { MdItemTypeSelect } from '#/views/mes/md/item/type/components';
|
|||
import { MdUnitMeasureSelect } from '#/views/mes/md/unitmeasure/components';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改物料产品的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -46,17 +46,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建物料 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看物料 */
|
||||
function handleDetail(row: MesMdItemApi.Item) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑物料 */
|
||||
function handleEdit(row: MesMdItemApi.Item) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除物料 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdItemApi } from '#/api/mes/md/item';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -19,20 +21,18 @@ import ProductBomForm from './product-bom-form.vue';
|
|||
import ProductSipForm from './product-sip-form.vue';
|
||||
import ProductSopForm from './product-sop-form.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('bom'); // 当前子表页签
|
||||
const formData = ref<MesMdItemApi.Item>();
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看物料/产品';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改物料/产品' : '新增物料/产品';
|
||||
return formType.value === 'update' ? '修改物料/产品' : '新增物料/产品';
|
||||
});
|
||||
const currentItemOrProduct = computed(
|
||||
() => formData.value?.itemOrProduct || '',
|
||||
|
|
@ -82,11 +82,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesMdItemApi.Item;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createItem(data);
|
||||
formData.value = { ...data, id };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
message.success($t('ui.actionMessage.operationSuccess'));
|
||||
} else {
|
||||
await updateItem(data);
|
||||
|
|
@ -106,10 +106,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'bom';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -129,16 +129,16 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="bom" tab="BOM 组成">
|
||||
<ProductBomForm :form-type="formMode" :item-id="formData.id" />
|
||||
<ProductBomForm :form-type="formType" :item-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane v-if="formData.batchFlag" key="batch" tab="批次属性">
|
||||
<ItemBatchConfigForm
|
||||
:form-type="formMode"
|
||||
:form-type="formType"
|
||||
:item-id="formData.id"
|
||||
:item-or-product="currentItemOrProduct"
|
||||
/>
|
||||
|
|
@ -147,10 +147,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Empty description="替代品(待实现)" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="sip" tab="SIP">
|
||||
<ProductSipForm :form-type="formMode" :item-id="formData.id" />
|
||||
<ProductSipForm :form-type="formType" :item-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="sop" tab="SOP">
|
||||
<ProductSopForm :form-type="formMode" :item-id="formData.id" />
|
||||
<ProductSopForm :form-type="formType" :item-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<template #prepend-footer>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdItemBatchConfigApi } from '#/api/mes/md/item/batchConfig';
|
||||
|
||||
import { computed, ref, watch } from 'vue';
|
||||
|
|
@ -13,7 +15,7 @@ import { MesItemOrProductEnum } from '#/views/mes/utils/constants';
|
|||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
itemId: number;
|
||||
itemOrProduct?: string;
|
||||
}>(),
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdItemApi } from '#/api/mes/md/item';
|
||||
import type { MesMdProductBomApi } from '#/api/mes/md/item/productBom';
|
||||
|
|
@ -22,7 +24,7 @@ import { useProductBomGridColumns } from '../data';
|
|||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
itemId: number;
|
||||
}>(),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdProductSipApi } from '#/api/mes/md/item/productSip';
|
||||
import type { MesMdProductSopApi } from '#/api/mes/md/item/productSop';
|
||||
|
||||
|
|
@ -36,7 +38,7 @@ type MediaItem = MesMdProductSipApi.ProductSip | MesMdProductSopApi.ProductSop;
|
|||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
itemId: number;
|
||||
kind: MediaKind;
|
||||
}>(),
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import ProductMediaList from './product-media-list.vue';
|
||||
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
itemId: number;
|
||||
}>();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import ProductMediaList from './product-media-list.vue';
|
||||
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
itemId: number;
|
||||
}>();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ import { z } from '#/adapter/form';
|
|||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改供应商的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -32,17 +32,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建供应商 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看供应商 */
|
||||
function handleDetail(row: MesMdVendorApi.Vendor) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑供应商 */
|
||||
function handleEdit(row: MesMdVendorApi.Vendor) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除供应商 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdVendorApi } from '#/api/mes/md/vendor';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -15,19 +17,17 @@ import { useFormSchema } from '../data';
|
|||
import VendorItemReceiptLineList from './item-receipt-line-list.vue';
|
||||
import VendorItemReceiptList from './item-receipt-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('itemReceiptLine'); // 当前子表页签
|
||||
const formData = ref<MesMdVendorApi.Vendor>();
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['供应商']);
|
||||
}
|
||||
return formMode.value === 'update'
|
||||
return formType.value === 'update'
|
||||
? $t('ui.actionTitle.edit', ['供应商'])
|
||||
: $t('ui.actionTitle.create', ['供应商']);
|
||||
});
|
||||
|
|
@ -80,10 +80,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'itemReceiptLine';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const [ItemFormModal, itemFormModalApi] = useVbenModal({
|
|||
|
||||
/** 查看物料详情 */
|
||||
function handleViewItem(row: MesWmItemReceiptLineApi.ItemReceiptLine) {
|
||||
itemFormModalApi.setData({ id: row.itemId, type: 'detail' }).open();
|
||||
itemFormModalApi.setData({ id: row.itemId, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
const [Grid] = useVbenVxeGrid({
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
|||
|
||||
import { MdWorkshopSelect } from './components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改工作站的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建工作站 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看工作站 */
|
||||
function handleDetail(row: MesMdWorkstationApi.Workstation) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑工作站 */
|
||||
function handleEdit(row: MesMdWorkstationApi.Workstation) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除工作站 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdWorkstationApi } from '#/api/mes/md/workstation';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -22,20 +24,18 @@ import MachineList from './machine-list.vue';
|
|||
import ToolList from './tool-list.vue';
|
||||
import WorkerList from './worker-list.vue';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const subTabsName = ref('machine'); // 当前资源页签
|
||||
const formData = ref<MesMdWorkstationApi.Workstation>();
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看工作站';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改工作站' : '新增工作站';
|
||||
return formType.value === 'update' ? '修改工作站' : '新增工作站';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -82,11 +82,11 @@ const [Modal, modalApi] = useVbenModal({
|
|||
// 提交表单
|
||||
const data = (await formApi.getValues()) as MesMdWorkstationApi.Workstation;
|
||||
try {
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createWorkstation(data);
|
||||
formData.value = { ...data, id };
|
||||
await formApi.setFieldValue('id', id);
|
||||
formMode.value = 'update';
|
||||
formType.value = 'update';
|
||||
} else {
|
||||
await updateWorkstation(data);
|
||||
formData.value = { ...formData.value, ...data };
|
||||
|
|
@ -105,10 +105,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
await formApi.resetForm();
|
||||
subTabsName.value = 'machine';
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -128,18 +128,18 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<Modal :title="getTitle" class="w-4/5">
|
||||
<Form class="mx-4" />
|
||||
<Tabs
|
||||
v-if="formMode !== 'create' && formData?.id"
|
||||
v-if="formType !== 'create' && formData?.id"
|
||||
v-model:active-key="subTabsName"
|
||||
class="mx-4 mt-4"
|
||||
>
|
||||
<Tabs.TabPane key="machine" tab="设备资源">
|
||||
<MachineList :form-type="formMode" :workstation-id="formData.id" />
|
||||
<MachineList :form-type="formType" :workstation-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="tool" tab="工装夹具">
|
||||
<ToolList :form-type="formMode" :workstation-id="formData.id" />
|
||||
<ToolList :form-type="formType" :workstation-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
<Tabs.TabPane key="worker" tab="人力资源">
|
||||
<WorkerList :form-type="formMode" :workstation-id="formData.id" />
|
||||
<WorkerList :form-type="formType" :workstation-id="formData.id" />
|
||||
</Tabs.TabPane>
|
||||
</Tabs>
|
||||
<template #prepend-footer>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationMachineApi } from '#/api/mes/md/workstation/machine';
|
||||
|
||||
|
|
@ -20,7 +22,7 @@ defineOptions({ name: 'MesMdWorkstationMachineList' });
|
|||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationToolApi } from '#/api/mes/md/workstation/tool';
|
||||
|
||||
|
|
@ -21,7 +23,7 @@ defineOptions({ name: 'MesMdWorkstationToolList' });
|
|||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||
import type { MesMdWorkstationWorkerApi } from '#/api/mes/md/workstation/worker';
|
||||
|
||||
|
|
@ -21,7 +23,7 @@ defineOptions({ name: 'MesMdWorkstationWorkerList' });
|
|||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
formType?: string;
|
||||
formType?: FormType;
|
||||
workstationId: number;
|
||||
}>(),
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
|||
import { getSimpleUserList } from '#/api/system/user';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改车间的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
|
|
@ -28,17 +28,17 @@ function handleRefresh() {
|
|||
|
||||
/** 创建车间 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 查看车间 */
|
||||
function handleDetail(row: MesMdWorkshopApi.Workshop) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 编辑车间 */
|
||||
function handleEdit(row: MesMdWorkshopApi.Workshop) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 删除车间 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesMdWorkshopApi } from '#/api/mes/md/workstation/workshop';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -19,19 +21,17 @@ import { BarcodeDetail } from '#/views/mes/wm/barcode/components';
|
|||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式
|
||||
const formType = ref<FormType>('create'); // 表单模式
|
||||
const formData = ref<MesMdWorkshopApi.Workshop>();
|
||||
const barcodeDetailRef = ref<InstanceType<typeof BarcodeDetail>>(); // 条码详情弹窗
|
||||
|
||||
const isDetail = computed(() => formMode.value === 'detail'); // 是否查看模式
|
||||
const isDetail = computed(() => formType.value === 'detail'); // 是否查看模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return '查看车间';
|
||||
}
|
||||
return formMode.value === 'update' ? '修改车间' : '新增车间';
|
||||
return formType.value === 'update' ? '修改车间' : '新增车间';
|
||||
});
|
||||
|
||||
const [Form, formApi] = useVbenForm({
|
||||
|
|
@ -94,10 +94,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||
}
|
||||
await formApi.resetForm();
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setDisabled(formMode.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formMode.value !== 'detail' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setDisabled(formType.value === 'detail');
|
||||
modalApi.setState({ showConfirmButton: formType.value !== 'detail' });
|
||||
if (!data?.id) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ import { MesProWorkOrderStatusEnum } from '#/views/mes/utils/constants';
|
|||
|
||||
import { AndonConfigSelect } from '../config/components';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
@ -132,7 +135,7 @@ export function useGridColumns(): VxeTableGridOptions<MesProAndonRecordApi.Andon
|
|||
* - detail:所有字段只读
|
||||
*/
|
||||
export function useFormSchema(
|
||||
formType: string,
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
const isCreate = formType === 'create';
|
||||
|
|
|
|||
|
|
@ -36,17 +36,17 @@ function handleRefresh() {
|
|||
|
||||
/** 新增记录 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 处置记录 */
|
||||
function handleHandle(row: MesProAndonRecordApi.AndonRecord) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'update' }).open();
|
||||
}
|
||||
|
||||
/** 详情 */
|
||||
function handleDetail(row: MesProAndonRecordApi.AndonRecord) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ id: row.id, formType: 'detail' }).open();
|
||||
}
|
||||
|
||||
/** 删除 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesProAndonRecordApi } from '#/api/mes/pro/andon/record';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -19,19 +21,17 @@ import { MesProAndonStatusEnum } from '#/views/mes/utils/constants';
|
|||
|
||||
import { useFormSchema } from '../data';
|
||||
|
||||
type FormMode = 'create' | 'detail' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create'); // 表单模式:新增 / 处置 / 详情
|
||||
const formType = ref<FormType>('create'); // 表单模式:新增 / 处置 / 详情
|
||||
const formData = ref<MesProAndonRecordApi.AndonRecord>();
|
||||
const userStore = useUserStore();
|
||||
|
||||
const isUpdate = computed(() => formMode.value === 'update'); // 是否处置模式
|
||||
const isUpdate = computed(() => formType.value === 'update'); // 是否处置模式
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['安灯呼叫']);
|
||||
}
|
||||
return formMode.value === 'update'
|
||||
return formType.value === 'update'
|
||||
? $t('ui.actionTitle.edit', ['安灯呼叫'])
|
||||
: $t('ui.actionTitle.create', ['安灯呼叫']);
|
||||
});
|
||||
|
|
@ -50,7 +50,7 @@ const [Form, formApi] = useVbenForm({
|
|||
});
|
||||
|
||||
/** 表单 schema 需要 formApi 引用,所以通过 setState 设置 schema */
|
||||
formApi.setState({ schema: useFormSchema(formMode.value, formApi) });
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
|
||||
/** 处置:保存(保持 ACTIVE 状态) */
|
||||
async function handleSave() {
|
||||
|
|
@ -104,7 +104,7 @@ async function handleFinish() {
|
|||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
|
|
@ -132,12 +132,12 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setState({ schema: useFormSchema(formMode.value, formApi) });
|
||||
modalApi.setState({ showConfirmButton: formMode.value === 'create' });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
modalApi.setState({ showConfirmButton: formType.value === 'create' });
|
||||
await formApi.resetForm();
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
// 新增时,发起人默认为当前用户
|
||||
await formApi.setValues({ userId: userStore.userInfo?.id });
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ import {
|
|||
MesProWorkOrderStatusEnum,
|
||||
} from '#/views/mes/utils/constants';
|
||||
|
||||
/** 生产报工表单类型 */
|
||||
export type FormType = 'approve' | 'create' | 'detail' | 'submit' | 'update';
|
||||
|
||||
/** 列表的搜索表单 */
|
||||
export function useGridFormSchema(): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
@ -173,7 +176,7 @@ export function useGridColumns(): VxeTableGridOptions<MesProFeedbackApi.Feedback
|
|||
* - 质检工序:只填报工数量(视为待检数量)
|
||||
*/
|
||||
export function useFormSchema(
|
||||
formType: string,
|
||||
formType: FormType,
|
||||
formApi?: VbenFormApi,
|
||||
): VbenFormSchema[] {
|
||||
const isHeaderReadonly = ['approve', 'detail', 'submit'].includes(formType);
|
||||
|
|
|
|||
|
|
@ -35,27 +35,27 @@ function handleRefresh() {
|
|||
|
||||
/** 创建生产报工 */
|
||||
function handleCreate() {
|
||||
formModalApi.setData({ type: 'create' }).open();
|
||||
formModalApi.setData({ formType: 'create' }).open();
|
||||
}
|
||||
|
||||
/** 编辑生产报工 */
|
||||
function handleEdit(row: MesProFeedbackApi.Feedback) {
|
||||
formModalApi.setData({ id: row.id, type: 'update' }).open();
|
||||
formModalApi.setData({ formType: 'update', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 提交生产报工 */
|
||||
function handleSubmit(row: MesProFeedbackApi.Feedback) {
|
||||
formModalApi.setData({ id: row.id, type: 'submit' }).open();
|
||||
formModalApi.setData({ formType: 'submit', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 审批生产报工 */
|
||||
function handleApprove(row: MesProFeedbackApi.Feedback) {
|
||||
formModalApi.setData({ id: row.id, type: 'approve' }).open();
|
||||
formModalApi.setData({ formType: 'approve', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 详情生产报工 */
|
||||
function handleDetail(row: MesProFeedbackApi.Feedback) {
|
||||
formModalApi.setData({ id: row.id, type: 'detail' }).open();
|
||||
formModalApi.setData({ formType: 'detail', id: row.id }).open();
|
||||
}
|
||||
|
||||
/** 删除生产报工 */
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<script lang="ts" setup>
|
||||
import type { FormType } from '../data';
|
||||
|
||||
import type { MesProFeedbackApi } from '#/api/mes/pro/feedback';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
|
@ -29,25 +31,21 @@ import { useFormSchema } from '../data';
|
|||
import ItemConsumeList from './item-consume-list.vue';
|
||||
import ProductProduceList from './product-produce-list.vue';
|
||||
|
||||
// TODO @AI:formType?
|
||||
type FormMode = 'approve' | 'create' | 'detail' | 'submit' | 'update';
|
||||
|
||||
const emit = defineEmits(['success']);
|
||||
const formMode = ref<FormMode>('create');
|
||||
const formType = ref<FormType>('create');
|
||||
const formData = ref<MesProFeedbackApi.Feedback>();
|
||||
const userStore = useUserStore();
|
||||
const subTabsName = ref('itemConsume');
|
||||
|
||||
const isEditable = computed(() =>
|
||||
['create', 'submit', 'update'].includes(formMode.value),
|
||||
['create', 'submit', 'update'].includes(formType.value),
|
||||
);
|
||||
// TODO @AI:是不是都是 isXXXX 风格?
|
||||
const canSubmitDirectly = computed(
|
||||
const canSubmit = computed(
|
||||
() =>
|
||||
isEditable.value &&
|
||||
formData.value?.status === MesProFeedbackStatusEnum.PREPARE,
|
||||
);
|
||||
const canApprove = computed(() => formMode.value === 'approve');
|
||||
const canApprove = computed(() => formType.value === 'approve');
|
||||
const showSubTabs = computed(
|
||||
() =>
|
||||
!!formData.value?.id &&
|
||||
|
|
@ -55,16 +53,16 @@ const showSubTabs = computed(
|
|||
formData.value?.status !== MesProFeedbackStatusEnum.APPROVING,
|
||||
);
|
||||
const getTitle = computed(() => {
|
||||
if (formMode.value === 'detail') {
|
||||
if (formType.value === 'detail') {
|
||||
return $t('ui.actionTitle.view', ['生产报工']);
|
||||
}
|
||||
if (formMode.value === 'approve') {
|
||||
if (formType.value === 'approve') {
|
||||
return '审批生产报工';
|
||||
}
|
||||
if (formMode.value === 'submit') {
|
||||
if (formType.value === 'submit') {
|
||||
return '提交生产报工';
|
||||
}
|
||||
return formMode.value === 'update'
|
||||
return formType.value === 'update'
|
||||
? $t('ui.actionTitle.edit', ['生产报工'])
|
||||
: $t('ui.actionTitle.create', ['生产报工']);
|
||||
});
|
||||
|
|
@ -84,7 +82,7 @@ const [Form, formApi] = useVbenForm({
|
|||
});
|
||||
|
||||
/** 表单 schema 需要 formApi 引用,所以通过 setState 设置 schema */
|
||||
formApi.setState({ schema: useFormSchema(formMode.value, formApi) });
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
|
||||
/** 提交前对齐数量:根据 checkFlag 决定 uncheck/合格/不良归零策略 */
|
||||
function alignQuantity(data: MesProFeedbackApi.Feedback) {
|
||||
|
|
@ -112,15 +110,15 @@ async function handleSave() {
|
|||
try {
|
||||
const data = (await formApi.getValues()) as MesProFeedbackApi.Feedback;
|
||||
alignQuantity(data);
|
||||
if (formMode.value === 'create') {
|
||||
if (formType.value === 'create') {
|
||||
const id = await createFeedback(data);
|
||||
formData.value = {
|
||||
...data,
|
||||
id,
|
||||
status: MesProFeedbackStatusEnum.PREPARE,
|
||||
};
|
||||
formMode.value = 'update';
|
||||
formApi.setState({ schema: useFormSchema(formMode.value, formApi) });
|
||||
formType.value = 'update';
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
await formApi.setFieldValue('id', id);
|
||||
message.success($t('common.createSuccess'));
|
||||
} else {
|
||||
|
|
@ -145,7 +143,7 @@ async function handleSubmit() {
|
|||
const data = (await formApi.getValues()) as MesProFeedbackApi.Feedback;
|
||||
alignQuantity(data);
|
||||
let id = formData.value?.id;
|
||||
if (formMode.value === 'create' || !id) {
|
||||
if (formType.value === 'create' || !id) {
|
||||
id = await createFeedback(data);
|
||||
} else {
|
||||
await updateFeedback(data);
|
||||
|
|
@ -209,7 +207,7 @@ async function resolveCheckFlag(routeId?: number, processId?: number) {
|
|||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
async onConfirm() {
|
||||
if (formMode.value === 'detail' || formMode.value === 'approve') {
|
||||
if (formType.value === 'detail' || formType.value === 'approve') {
|
||||
await modalApi.close();
|
||||
return;
|
||||
}
|
||||
|
|
@ -222,16 +220,16 @@ const [Modal, modalApi] = useVbenModal({
|
|||
return;
|
||||
}
|
||||
// 加载数据
|
||||
const data = modalApi.getData<{ id?: number; type?: FormMode }>();
|
||||
formMode.value = data?.type || 'create';
|
||||
formApi.setState({ schema: useFormSchema(formMode.value, formApi) });
|
||||
const data = modalApi.getData<{ formType: FormType; id?: number }>();
|
||||
formType.value = data.formType;
|
||||
formApi.setState({ schema: useFormSchema(formType.value, formApi) });
|
||||
// 审批/详情整表禁用,避免审核人误改未提交的字段
|
||||
formApi.setDisabled(
|
||||
formMode.value === 'approve' || formMode.value === 'detail',
|
||||
formType.value === 'approve' || formType.value === 'detail',
|
||||
);
|
||||
modalApi.setState({
|
||||
showConfirmButton:
|
||||
formMode.value !== 'detail' && formMode.value !== 'approve',
|
||||
formType.value !== 'detail' && formType.value !== 'approve',
|
||||
});
|
||||
await formApi.resetForm();
|
||||
if (!data?.id) {
|
||||
|
|
@ -281,7 +279,7 @@ const [Modal, modalApi] = useVbenModal({
|
|||
<template #prepend-footer>
|
||||
<div class="flex flex-auto items-center justify-end gap-2">
|
||||
<Popconfirm
|
||||
v-if="canSubmitDirectly"
|
||||
v-if="canSubmit"
|
||||
title="确认提交该报工单?提交后将不能修改。"
|
||||
@confirm="handleSubmit"
|
||||
>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
// TODO @AI:换行风格???
|
||||
if (!props.feedbackId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
|
|
@ -38,9 +37,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
},
|
||||
},
|
||||
},
|
||||
// TODO @AI:换行风格;
|
||||
rowConfig: { isHover: true, keyField: 'id' },
|
||||
toolbarConfig: { refresh: false, search: false },
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: false,
|
||||
search: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmItemConsumeLineApi.ItemConsumeLine>,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
// TODO @AI:换行风格???
|
||||
if (!props.feedbackId) {
|
||||
return { list: [], total: 0 };
|
||||
}
|
||||
|
|
@ -49,9 +48,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||
},
|
||||
},
|
||||
},
|
||||
// TODO @AI:换行风格;
|
||||
rowConfig: { isHover: true, keyField: 'id' },
|
||||
toolbarConfig: { refresh: false, search: false },
|
||||
rowConfig: {
|
||||
keyField: 'id',
|
||||
isHover: true,
|
||||
},
|
||||
toolbarConfig: {
|
||||
refresh: false,
|
||||
search: false,
|
||||
},
|
||||
} as VxeTableGridOptions<MesWmProductProduceLineApi.ProductProduceLine>,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,9 @@ import { z } from '#/adapter/form';
|
|||
import { generateAutoCode } from '#/api/mes/md/autocode/record';
|
||||
import { MesAutoCodeRuleCode } from '#/views/mes/utils/constants';
|
||||
|
||||
/** 表单类型 */
|
||||
export type FormType = 'create' | 'detail' | 'update';
|
||||
|
||||
/** 新增/修改生产工序的表单 */
|
||||
export function useFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
|
||||
return [
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue