客户需求
This commit is contained in:
225
src/views/dayPlan/Demand/components/createForm.vue
Normal file
225
src/views/dayPlan/Demand/components/createForm.vue
Normal file
@ -0,0 +1,225 @@
|
||||
<template>
|
||||
<a-spin :spinning="spinning" tip="加载中...">
|
||||
<div class="page-bg-wrap formViewStyle">
|
||||
<a-form ref="formRef" :model="formState" :rules="rules" v-bind="layout">
|
||||
<Card :title="title" :bordered="false" >
|
||||
<basicForm ref="basicFormRef" :formObj="formState" :list="dataList" :disable="currentRoute.query.type"></basicForm>
|
||||
</Card>
|
||||
<Card :title="title" :bordered="false" v-if="currentRoute.query.type=='compare'">
|
||||
<basicForm ref="basicFormRef" :formObj="formState" :list="dataList" :disable="currentRoute.query.type"></basicForm>
|
||||
</Card>
|
||||
</a-form>
|
||||
</div>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { Card } from 'ant-design-vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { FromPageType, RecordType } from '/@/enums/workflowEnum';
|
||||
import { ref, computed, onMounted, onBeforeMount, nextTick, defineAsyncComponent, reactive, defineComponent, watch} from 'vue';
|
||||
import { CheckCircleOutlined, StopOutlined, CloseOutlined, } from '@ant-design/icons-vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { useI18n } from '/@/hooks/web/useI18n';
|
||||
import { useMultipleTabStore } from '/@/store/modules/multipleTab';
|
||||
import useEventBus from '/@/hooks/event/useEventBus';
|
||||
import type { Rule } from 'ant-design-vue/es/form';
|
||||
import { getDictionary } from '/@/api/sales/Customer';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { getLngPngAppro,approveLngPngAppro } from '/@/api/dayPlan/PngAppro';
|
||||
import dayjs from 'dayjs';
|
||||
import { getAppEnvConfig } from '/@/utils/env';
|
||||
import { message } from 'ant-design-vue';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import basicForm from './basicForm.vue'
|
||||
|
||||
const userStore = useUserStore();
|
||||
const userInfo = userStore.getUserInfo;
|
||||
|
||||
const formType = ref('2'); // 0 新建 1 修改 2 查看
|
||||
const formRef = ref();
|
||||
const props = defineProps({
|
||||
disabled: false,
|
||||
id: ''
|
||||
|
||||
});
|
||||
const { bus, FORM_LIST_MODIFIED } = useEventBus();
|
||||
|
||||
const router = useRouter();
|
||||
const { currentRoute } = router;
|
||||
const isDisable = ref(false);
|
||||
const { formPath } = currentRoute.value.query;
|
||||
const pathArr = [];
|
||||
|
||||
const tabStore = useMultipleTabStore();
|
||||
const formProps = ref(null);
|
||||
const formId = ref(currentRoute.value?.params?.id);
|
||||
const pageType = ref(currentRoute.value.query?.type);
|
||||
const pageId = ref(currentRoute.value.query?.id)
|
||||
|
||||
const contractQty = ref()
|
||||
const spinning = ref(false);
|
||||
const curIdx = ref(null)
|
||||
const { notification } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const hasDel = ref(false)
|
||||
const formState = reactive({
|
||||
|
||||
});
|
||||
const [register, { openModal:openModal}] = useModal();
|
||||
const rules= reactive({
|
||||
// kNo: [{ required: true, message: "该项为必填项", trigger: 'change' }],
|
||||
});
|
||||
const layout = {
|
||||
labelCol: { span: 9 },
|
||||
wrapperCol: { span: 18 },
|
||||
}
|
||||
const title = ref('日计划审批')
|
||||
const dataList = ref([])
|
||||
const basicFormRef = ref()
|
||||
let optionSelect= reactive({
|
||||
approCodeList: [],
|
||||
});
|
||||
watch(
|
||||
() => props.id,
|
||||
(val) => {
|
||||
if (val) {
|
||||
getInfo(val)
|
||||
}
|
||||
},
|
||||
{
|
||||
immediate: true
|
||||
}
|
||||
);
|
||||
onMounted(() => {
|
||||
getOption()
|
||||
if (pageId.value) {
|
||||
getInfo(pageId.value)
|
||||
}
|
||||
|
||||
});
|
||||
async function getInfo(id) {
|
||||
spinning.value = true
|
||||
try {
|
||||
let data = await getLngPngAppro(id)
|
||||
spinning.value = false
|
||||
Object.assign(formState, {...data})
|
||||
Object.assign(dataList.value, formState.lngPngApproPurList || [{}])
|
||||
const startDate = dayjs(formState.datePlan);
|
||||
const endDate = dayjs(new Date());
|
||||
const diffInDays = endDate.diff(startDate, 'day');
|
||||
if (diffInDays == 0) {
|
||||
formState.dayDesc = '当日'
|
||||
} else if (diffInDays == 1) {
|
||||
formState.dayDesc = '次日'
|
||||
} else if (diffInDays > 1) {
|
||||
formState.dayDesc = diffInDays + '日后'
|
||||
} else {
|
||||
formState.dayDesc = ''
|
||||
}
|
||||
formState.qtyContractM3 = Number(formState.qtyContractM3)/10000
|
||||
formState.qtyPlanM3 = Number(formState.qtyPlanM3)/10000
|
||||
formState.qtyDemandM3 = Number(formState.qtyDemandM3)/10000
|
||||
formState.qtySalesM3 = Number(formState.qtySalesM3)/10000
|
||||
|
||||
dataList.value.forEach(v => {
|
||||
v.qtyDemandM3 = Number(v.qtyDemandM3)/10000
|
||||
v.qtySalesM3 = Number(v.qtySalesM3)/10000
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.log(error, 'error')
|
||||
spinning.value = false
|
||||
}
|
||||
}
|
||||
async function numChange () {
|
||||
let num = 0;
|
||||
let num1 = 1;
|
||||
dataList.value.forEach(v => {
|
||||
num+=(Number(v.qtySalesGj) || 0)
|
||||
num1+=(Number(v.qtySalesM3) || 0)
|
||||
})
|
||||
formState.qtySalesGj = num
|
||||
formState.qtySalesM3 = num1
|
||||
}
|
||||
async function getOption() {
|
||||
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
|
||||
|
||||
}
|
||||
function close() {
|
||||
tabStore.closeTab(currentRoute.value, router);
|
||||
}
|
||||
async function checkBtn(type) {
|
||||
let data = basicFormRef.value.getFormValue()
|
||||
console.log(data, 'data')
|
||||
let arr = JSON.parse(JSON.stringify(data.list))
|
||||
arr.forEach(v=> {
|
||||
v.qtyDemandM3 = Number(v.qtyDemandM3)*10000
|
||||
v.qtySalesM3 = Number(v.qtySalesM3)*10000
|
||||
})
|
||||
let obj = {
|
||||
...data.formInfo,
|
||||
qtyContractM3: Number(data.formInfo.qtyContractM3)*10000,
|
||||
qtyPlanM3: Number(data.formInfo.qtyPlanM3)*10000,
|
||||
qtyDemandM3: Number(data.formInfo.qtyDemandM3)*10000,
|
||||
qtySalesM3: Number(data.formInfo.qtySalesM3)*10000,
|
||||
lngPngApproPurList:arr
|
||||
}
|
||||
let params = {
|
||||
result: type == 'agree' ? 'C' : 'R',
|
||||
remark: formState.reply,
|
||||
data: obj
|
||||
}
|
||||
spinning.value = true;
|
||||
try {
|
||||
if (type == 'reject') {
|
||||
if (!formState.reply) {
|
||||
message.warn('请输入批复意见')
|
||||
return
|
||||
}
|
||||
}
|
||||
await approveLngPngAppro(params);
|
||||
spinning.value = false;
|
||||
notification.success({
|
||||
message: 'Tip',
|
||||
description: type == 'agree' ? '审批通过':'已驳回'
|
||||
}); //提示消息
|
||||
setTimeout(() => {
|
||||
bus.emit(FORM_LIST_MODIFIED, {});
|
||||
close();
|
||||
}, 500);
|
||||
}catch (errorInfo) {
|
||||
spinning.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.page-bg-wrap {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.top-toolbar {
|
||||
min-height: 44px;
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
.dot {
|
||||
margin-right: 10px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
i{
|
||||
padding: 5px;
|
||||
font-style: normal;
|
||||
}
|
||||
span{
|
||||
width: 10px !important;
|
||||
height: 10px !important;
|
||||
border-radius: 50%;
|
||||
background: red;
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user