|
@@ -0,0 +1,195 @@
|
|
|
+<template>
|
|
|
+ <BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="800" @ok="handleSubmit">
|
|
|
+ <BasicForm @register="registerForm">
|
|
|
+ <template #heatNo="{ model }">
|
|
|
+ <JSearchSelect v-model:value="model.heatNo" @change="getLastBillet" :options="heatNoOptions" placeholder="请选择" />
|
|
|
+ </template>
|
|
|
+ <template #num="{ model }">
|
|
|
+ <a-input-number v-if="Number(ccmNo) === 5" :defaultValue="1" :step="1" v-model:value="model.num" :min="1" />
|
|
|
+ <a-input-number v-else :defaultValue="4" :step="4" v-model:value="model.num" :min="4" @change="handleChangeNum" />
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template #belongTable="{ model }">
|
|
|
+ <JSearchSelect v-model:value="model.belongTable" :options="belongTableOPtions" placeholder="请选择" />
|
|
|
+ </template>
|
|
|
+ </BasicForm>
|
|
|
+ </BasicModal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts" setup>
|
|
|
+ import { ref, computed, unref } from 'vue';
|
|
|
+ import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
+ import { BasicForm, useForm } from '/@/components/Form/index';
|
|
|
+ import { supplementFormSchema } from '../BilletBasicInfo.data';
|
|
|
+ import { saveOrUpdate, list as billetList } from '../BilletBasicInfo.api';
|
|
|
+ import { list } from '../../heatsActuals/HeatsActuals.api';
|
|
|
+ import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
|
|
|
+ import { configAll5, configAll6 } from '../../hotDelivery/common.data';
|
|
|
+
|
|
|
+ // Emits声明
|
|
|
+ const emit = defineEmits(['register', 'success']);
|
|
|
+ const isUpdate = ref(true);
|
|
|
+ const ccmNo = ref(6);
|
|
|
+ const heatNoOptions = ref([]);
|
|
|
+ const belongTableOPtions = ref<any[]>([]);
|
|
|
+ //表单配置
|
|
|
+ const [registerForm, { setProps, resetFields, setFieldsValue, validate, getFieldsValue }] = useForm({
|
|
|
+ //labelWidth: 150,
|
|
|
+ schemas: supplementFormSchema,
|
|
|
+ showActionButtonGroup: false,
|
|
|
+ baseColProps: { span: 24 },
|
|
|
+ });
|
|
|
+ //表单赋值
|
|
|
+ const [registerModal, { setModalProps, closeModal, changeLoading }] = useModalInner(async (data) => {
|
|
|
+ //重置表单
|
|
|
+ await resetFields();
|
|
|
+ setModalProps({ confirmLoading: false, showCancelBtn: !!data?.showFooter, showOkBtn: !!data?.showFooter });
|
|
|
+ isUpdate.value = !!data?.isUpdate;
|
|
|
+
|
|
|
+ ccmNo.value = data?.ccmNo;
|
|
|
+
|
|
|
+ const belongTable = Number(data?.ccmNo) === 5 ? 'roll_club_one' : 'roll_height';
|
|
|
+ belongTableOPtions.value = (Number(data?.ccmNo) === 5 ? configAll5 : configAll6)
|
|
|
+ .filter((val) => val.belongTable === belongTable)
|
|
|
+ .map((item: any) => {
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ label: item.typeName,
|
|
|
+ value: item.belongTable,
|
|
|
+ belongTable: item.belongTable,
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ // 查询当天的炉号
|
|
|
+ // 获取当前时间
|
|
|
+ const now = new Date();
|
|
|
+ // 格式化时间
|
|
|
+ const year = now.getFullYear();
|
|
|
+ const month = String(now.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(now.getDate()).padStart(2, '0');
|
|
|
+ const formattedDate = `${year}-${month}-${day}`;
|
|
|
+ // const formattedDate = `2025-04-16`;
|
|
|
+ await getTodayBillet(formattedDate);
|
|
|
+ // 隐藏底部时禁用整个表单
|
|
|
+ setProps({ disabled: !data?.showFooter });
|
|
|
+ });
|
|
|
+ //设置标题
|
|
|
+ const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑'));
|
|
|
+ //表单提交事件
|
|
|
+ async function handleSubmit() {
|
|
|
+ try {
|
|
|
+ let values = await validate();
|
|
|
+ setModalProps({ confirmLoading: true });
|
|
|
+ // 查询当前目的地
|
|
|
+ const nudidi = belongTableOPtions.value.find((item) => item.value === values.belongTable);
|
|
|
+ values.belongTable = nudidi ? nudidi?.belongTable : undefined;
|
|
|
+ values.bhtcId = nudidi ? nudidi?.id : undefined;
|
|
|
+ console.log('111111111111111111111', values);
|
|
|
+ //提交表单
|
|
|
+ // await saveOrUpdate(values, isUpdate.value);
|
|
|
+ //关闭弹窗
|
|
|
+ closeModal();
|
|
|
+ //刷新列表
|
|
|
+ emit('success');
|
|
|
+ } finally {
|
|
|
+ setModalProps({ confirmLoading: false });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取某一路炉最后一条钢坯信息
|
|
|
+ const getLastBillet = async (casterCode) => {
|
|
|
+ try {
|
|
|
+ changeLoading(true);
|
|
|
+ const res = await billetList({
|
|
|
+ column: 'createTime',
|
|
|
+ order: 'desc',
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 1,
|
|
|
+ ccmNo: ccmNo.value,
|
|
|
+ heatNo: casterCode,
|
|
|
+ });
|
|
|
+
|
|
|
+ const { records } = res;
|
|
|
+
|
|
|
+ if (records && records.length > 0) {
|
|
|
+ const { heatNo, ccmNo, ladleNo, grade, length, width, thickness, spec, weight } = records[0];
|
|
|
+ const values = {
|
|
|
+ heatNo,
|
|
|
+ num: 1,
|
|
|
+ ccmNo,
|
|
|
+ ladleNo,
|
|
|
+ grade,
|
|
|
+ length,
|
|
|
+ width,
|
|
|
+ thickness,
|
|
|
+ spec,
|
|
|
+ weight,
|
|
|
+ belongTable: Number(ccmNo) === 5 ? 'roll_club_one' : 'roll_height',
|
|
|
+ };
|
|
|
+
|
|
|
+ console.log('values', values);
|
|
|
+
|
|
|
+ await setFieldsValue(values);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error', error);
|
|
|
+ } finally {
|
|
|
+ changeLoading(false);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取当天的炉次实绩
|
|
|
+ const getTodayBillet = async (date) => {
|
|
|
+ try {
|
|
|
+ changeLoading(true);
|
|
|
+ const res = await list({
|
|
|
+ column: 'createTime',
|
|
|
+ order: 'desc',
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 200,
|
|
|
+ createTime_begin: date,
|
|
|
+ createTime_end: date,
|
|
|
+ casterCode: ccmNo.value,
|
|
|
+ });
|
|
|
+
|
|
|
+ const { records } = res;
|
|
|
+
|
|
|
+ if (records && records.length > 0) {
|
|
|
+ heatNoOptions.value = records.map((item) => {
|
|
|
+ return {
|
|
|
+ label: item.heatsCode,
|
|
|
+ value: item.heatsCode,
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ await getLastBillet(records[0].heatsCode);
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.log('error', error);
|
|
|
+ } finally {
|
|
|
+ changeLoading(false);
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // 如果是去高线必须是4的倍数
|
|
|
+ const handleChangeNum = async (value) => {
|
|
|
+ if (Number(ccmNo.value) === 6) {
|
|
|
+ if (value % 4 !== 0) {
|
|
|
+ setFieldsValue({
|
|
|
+ num: value - (value % 4),
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less" scoped>
|
|
|
+ /** 时间和数字输入框样式 */
|
|
|
+ :deep(.ant-input-number) {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+
|
|
|
+ :deep(.ant-calendar-picker) {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+</style>
|