价格采购申请

This commit is contained in:
‘huanghaiixia’
2026-03-06 17:56:04 +08:00
parent 1b24d0284e
commit 1405bfebdf
7 changed files with 1192 additions and 68 deletions

View File

@ -9,12 +9,22 @@ enum Api {
Info = '/price/pricePurPngApp/info', Info = '/price/pricePurPngApp/info',
LngPricePurPngApp = '/price/pricePurPngApp', LngPricePurPngApp = '/price/pricePurPngApp',
udpagePage = '/magic-api/price/pricePurPngApp/udpage',
DataLog = '/price/pricePurPngApp/datalog', DataLog = '/price/pricePurPngApp/datalog',
} }
export async function getLngPriceContractPurPng(params: LngPricePurPngAppPageParams, mode: ErrorMessageMode = 'modal') {
return defHttp.get<LngPricePurPngAppPageResult>(
{
url: Api.udpagePage,
params,
},
{
errorMessageMode: mode,
},
);
}
/** /**
* @description: 查询LngPricePurPngApp分页列表 * @description: 查询LngPricePurPngApp分页列表
*/ */

View File

@ -0,0 +1,133 @@
<template>
<div>
<BasicModal v-bind="$attrs" @register="registerModal" width="60%" :title="getTitle" @ok="handleSubmit"
@visible-change="handleVisibleChange" >
<BasicTable @register="registerTable" class="ContractPurIntListModal"></BasicTable>
</BasicModal>
</div>
</template>
<script lang="ts" setup>
import { ref, computed, unref, nextTick } from 'vue';
import { BasicModal, useModalInner, useModal } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form/index';
import { BasicTable, useTable, FormSchema, BasicColumn, TableAction } from '/@/components/Table';
import { useMessage } from '/@/hooks/web/useMessage';
import { useI18n } from '/@/hooks/web/useI18n';
import { getLngPriceContractPurPng} from '/@/api/price/PricePurPngApp';
const { t } = useI18n();
const comId = ref('')
const codeFormSchema: FormSchema[] = [
{
field: 'dateFrom',
label: '有效期',
component: 'RangePicker',
componentProps: {
format: 'YYYY-MM-DD',
style: { width: '100%' },
getPopupContainer: () => document.body,
},
},
];
const columns: BasicColumn[] = [
{ title: t('合同号'), dataIndex: 'kNo', },
{ title: t('合同名称'), dataIndex: 'kName', },
{ title: t('供应商'), dataIndex: 'suName' ,},
{ title: '有效期开始',dataIndex: 'dateFrom', width: 120,},
{ title: '有效期结束',dataIndex: 'dateTo', width: 120},
{ title: t('合同主体'), dataIndex: 'comName', },
{ title: t('上载点'), dataIndex: 'pointUpName'},
];
const emit = defineEmits(['success', 'register']);
const { notification } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
const selectedKeys = ref<string[]>([]);
const selectedValues = ref([]);
const props = defineProps({
selectType: { type: String, default: 'checkbox' },
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
comId.value = data.comId
});
const [registerTable, { getDataSource, setTableData, updateTableDataRecord, reload }] = useTable({
title: t('管道气采购合同列表'),
api: getLngPriceContractPurPng,
columns,
bordered: true,
pagination: true,
canResize: false,
formConfig: {
labelCol:{span: 9, offSet:10},
schemas: codeFormSchema,
fieldMapToTime: [['dateFrom', ['startDate', 'endDate'], 'YYYY-MM-DD']],
showResetButton: true,
},
immediate: false, // 设置为不立即调用
beforeFetch: (params) => {
return { ...params,page:params.limit, comId: comId.value};
},
rowSelection: {
type: props.selectType,
onChange: onSelectChange
},
});
const handleVisibleChange = (visible: boolean) => {
if (visible) {
nextTick(() => {
reload();
});
}
};
function onSelectChange(rowKeys: string[], e) {
selectedKeys.value = rowKeys;
selectedValues.value = e
}
const getTitle = computed(() => (!unref(isUpdate) ? t('管道气采购合同列表') : t('')));
async function handleSubmit() {
if (!selectedValues.value.length) {
notification.warning({
message: t('提示'),
description: t('请选择合同')
});
return
}
closeModal();
emit('success', selectedValues.value);
}
</script>
<style >
.ContractPurIntListModal .basicCol{
position: inherit !important;
top: 0;
}
</style>
<style lang="less" scoped>
:deep( .ant-col-8:nth-child(1)) {
width: 360px !important;
max-width: 360px !important;;
}
:deep(.ant-col-8:nth-child(1) .ant-form-item-label) {
width: 80px !important;
}
</style>

View File

@ -0,0 +1,269 @@
<template>
<Card :bordered="false" >
<template #title>
<div style="display: flex; align-items: center;">
<span style="margin-left: 8px;">供应价格信息</span>
<a-button type="primary" style="margin: 0 10px" @click="handleAdd" v-if="!isDisable">新增价格</a-button>
</div>
</template>
<div v-for="(item, idx) in dataListPrice" class="tbStyle">
<a-button type="primary" style="margin-bottom: 10px;" @click="handleDelete(idx)" v-if="!isDisable">删除</a-button>
<a-row>
<a-col :span="8">
<a-form-item name="kName">
<template #label>
<span><span style="color:red">*</span>合同</span>
</template>
<a-input-search v-model:value="item.kName" :disabled="isDisable" placeholder="请选择合同" readonly @search="onContract(idx)"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item name="dateFrom">
<template #label>
<span><span style="color:red">*</span>价格生效年月</span>
</template>
<a-date-picker v-model:value="item.dateFrom" style="width: 100%" :disabled="isDisable" placeholder="请选择日期" />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="供应商" name="suName">
<a-input v-model:value="item.suName" style="width: 100%" disabled/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="上载点" name="pointUpName">
<a-input v-model:value="item.pointUpName" style="width: 100%" disabled />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="交割点" name="pointDelyName">
<a-input v-model:value="item.pointDelyName" style="width: 100%" disabled />
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="计量单位" name="uomName">
<a-input v-model:value="item.uomName" style="width: 100%" disabled />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="价格组成" name="priceDesc">
<a-textarea v-model:value="item.priceDesc" disabled :auto-size="{ minRows: 1, maxRows: 5 }"/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注" name="note" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="item.note" :disabled="isDisable" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
<div style="width: 100%">
<a-button type="primary" style="margin-bottom: 10px" @click="addPrice(idx)" v-if="!isDisable">新增行</a-button>
<a-table style="width: 100%" :columns="columnsPrice" :data-source="item.lngPricePurPngAppSuDtlList" :pagination="false">
<template #headerCell="{ column }">
<template v-if="column.dataIndex == 'priceCode'">
<span><span style="color: red">*</span>基础量/增量</span>
</template>
</template>
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'priceCode'">
<a-select v-model:value="record.priceCode" :disabled="isDisable" style="width: 100%" allow-clear @change="numCount(record, idx, 'rateQtyGj')">
<a-select-option v-for="item in optionSelect.baseIncList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</template>
<template v-if="column.dataIndex === 'sort'">
<input-number v-model:value="record.sort" :disabled="isDisable" :digits="0" :min="0" style="width: 100%" />
</template>
<template v-if="column.dataIndex === 'rateQtyGj'">
<input-number v-model:value="record.rateQtyGj" :disabled="isDisable" :min="0" :digits="3" @change="numCount(record, idx, 'rateQtyGj')" style="width: 100%"/>
</template>
<template v-if="column.dataIndex === 'rateQtyM3'">
<input-number v-model:value="record.rateQtyM3" :disabled="isDisable" :min="0" :digits="3" @change="numCount(record, idx, 'rateQtyM3')" style="width: 100%"/>
</template>
<template v-if="column.dataIndex === 'priceGj'">
<input-number v-model:value="record.priceGj" :disabled="isDisable" :min="0" :digits="4" @change="numCount(record, idx, 'priceGj')" style="width: 100%"/>
</template>
<template v-if="column.dataIndex === 'priceM3'">
<input-number v-model:value="record.priceM3" :disabled="isDisable" :min="0" :digits="4" @change="numCount(record, idx, 'priceM3')" style="width: 100%"/>
</template>
<template v-if="column.dataIndex === 'note'">
<a-input v-model:value="record.note" :disabled="isDisable" />
</template>
<template v-if="column.dataIndex === 'operation'">
<a v-if="!isDisable" @click="deletePrice(idx,index)">删除</a>
</template>
</template>
</a-table>
</div>
</div>
<contractPurPngtListModal @register="registerPur" @success="handleSuccessPur" selectType="radio"/>
</Card>
</template>
<script lang="ts" setup>
import { Card } from 'ant-design-vue';
import { reactive, ref, watch} from 'vue';
import { useRouter } from 'vue-router';
import { useI18n } from '/@/hooks/web/useI18n';
import { Modal } from 'ant-design-vue';
import { useModal } from '/@/components/Modal';
import { message } from 'ant-design-vue';
import contractPurPngtListModal from '/@/components/common/contractPurPngtListModal.vue';
const router = useRouter();
const { t } = useI18n();
const dataListPrice = ref([])
const curIdx = ref('')
const columnsPrice= ref([
{ title: t('序号'), dataIndex: 'index', key: 'index', customRender: (column) => `${column.index + 1}` ,width: 50},
{ title: t('基础量/增量'), dataIndex: 'priceCode', width: 150},
{ title: t('优先级'), dataIndex: 'sort', width: 150},
{ title: t('数量(吉焦)'), dataIndex: 'rateQtyGj', width: 150},
{ title: t('数量(方)'), dataIndex: 'rateQtyM3', width: 150},
{ title: t('采购价格(元/方)'), dataIndex: 'priceGj', width: 150},
{ title: t('采购价格(元/吉焦)'), dataIndex: 'priceM3', width: 150},
{ title: t('备注'), dataIndex: 'note'},
{ title: t('操作'), dataIndex: 'operation', width: 80, fixed: 'right',align: 'center'},
]);
const [registerPur, { openModal:openModalPur}] = useModal();
const props = defineProps({
isDisable: Boolean,
list: Array,
formState: Object,
pageType: String,
rateCode: Number || String,
optionSelect: Object
});
const emit = defineEmits(['change']);
const numCount = (record, idx, k)=> {
let uomCode = dataListPrice.value[idx].uomCode
if (uomCode == 'GJ' && k == 'rateQtyGj') {
record.rateQtyM3 = record.rateM3Gj ? (Number(record.rateQtyGj || 0)/ Number(record.rateM3Gj)).toFixed(4) : ''
}
if (uomCode == 'GJ' && k == 'priceGj') {
record.priceM3 = record.rateM3Gj ? (Number(record.priceGj || 0) / Number(record.rateM3Gj)).toFixed(4) : ''
}
if (uomCode == 'M3' && k == 'rateQtyM3') {
record.rateQtyGj = (Number(record.rateQtyM3 || 0)*Number(record.rateM3Gj || 0)).toFixed(3)
}
if (uomCode == 'M3' && k == 'priceM3') {
record.priceGj = (Number(record.priceM3 || 0)*Number(record.rateM3Gj || 0)).toFixed(3)
}
updatePriceDesc(idx)
}
const updatePriceDesc = (idx) => {
let uomCode = dataListPrice.value[idx].uomCode
let priceDesc = ''
dataListPrice.value[idx].lngPricePurPngAppSuDtlList.forEach(v=> {
let a = v.priceCode ? (props.optionSelect.baseIncList.find(i=>i.code == v.priceCode) ||{}).name : ''
let b = ''
if (uomCode == 'GJ' ) {
b=a+(v.rateQtyGj || '')+dataListPrice.value[idx].uomName + ',单价'+(v.priceGj ||'')+';'
}
if (uomCode == 'M3' ) {
b=a+(v.rateQtyM3 || '')+dataListPrice.value[idx].uomName + ',单价'+(v.priceM3 || '')+';'
}
priceDesc+=b
})
dataListPrice.value[idx].priceDesc = priceDesc
}
const addPrice = (idx) => {
if (!dataListPrice.value[idx].kName) {
message.warn('请选择合同')
return
}
dataListPrice.value[idx].lngPricePurPngAppSuDtlList.push({rateM3Gj: props.rateCode,priceGj: '',priceM3: '',rateQtyM3: '',rateQtyGj: ''})
}
const deletePrice= (idx, index) => {
dataListPrice.value[idx].lngPricePurPngAppSuDtlList.splice(index, 1)
updatePriceDesc(idx)
}
const handleAdd = ()=> {
if (!props.formState.comId) {
message.warn('请选择交易主体')
return
}
dataListPrice.value.push({
kName: '',
suName: '',
pointDelyName: '',
pointUpName: '',
lngPricePurPngAppSuDtlList: []
})
}
const handleDelete= (index) => {
dataListPrice.value.splice(index, 1)
emit('change', dataListPrice.value)
}
const onContract = (val)=> {
curIdx.value = val
openModalPur(true,{isUpdate: false, comId: props.formState.comId})
}
const handleSuccessPur = (val) => {
dataListPrice.value[curIdx.value].kId = val[0].kId
dataListPrice.value[curIdx.value].kName = val[0].kName
dataListPrice.value[curIdx.value].suCode = val[0].suCode
dataListPrice.value[curIdx.value].suName = val[0].suName
dataListPrice.value[curIdx.value].kpppId = val[0].kpppId
dataListPrice.value[curIdx.value].pointUpCode = val[0].pointUpCode
dataListPrice.value[curIdx.value].pointUpName = val[0].pointUpName
dataListPrice.value[curIdx.value].pointDelyCode = val[0].pointDelyCode
dataListPrice.value[curIdx.value].pointDelyName = val[0].pointDelyName
dataListPrice.value[curIdx.value].uomCode = val[0].uomCode
dataListPrice.value[curIdx.value].uomName = val[0].uomName
dataListPrice.value[curIdx.value].kpppsId = val[0].id
dataListPrice.value[curIdx.value].transSign = val[0].transSign
dataListPrice.value[curIdx.value].lngPricePurPngAppSuDtlList = []
dataListPrice.value[curIdx.value].priceDesc = ''
}
const getList = () => {
return dataListPrice.value
}
watch(
() => props.pageType,
(val) => {
if (val) {
}
},
{
immediate: true,
deep: true,
}
);
watch(
() => props.disabled,
(val) => {
if (val) {
let idx2 = columnsPrice.value.findIndex(v =>v.dataIndex == 'operation')
idx2>-1 && columnsPrice.value.splice(idx2, 1)
}
},
{
immediate: true,
deep: true,
}
);
watch(
() => props.list,
async (val) => {
dataListPrice.value = val || []
},
{
immediate: true,
deep: true,
}
);
defineExpose({
getList,
});
</script>
<style lang="less" scoped>
.btnBox {
span {
margin: 0 30px;
}
}
</style>

View File

@ -0,0 +1,290 @@
<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="价格申请" :bordered="false" >
<a-row>
<a-col :span="16">
<a-form-item label="申请说明" name="appName" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.appName" placeholder="请输入" :disabled="isDisable"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="定价类型" name="priceTypeCode">
<a-select v-model:value="formState.priceTypeCode" :disabled="isDisable" placeholder="请选择" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.priceTypeCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="交易主体" name="comId">
<a-select v-model:value="formState.comId" :disabled="isDisable || dataListPrice.length" placeholder="请选择" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.comIdList" :key="item.id" :value="item.id">
{{ item.shortName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="状态" name="approCode">
<a-select v-model:value="formState.approCode" disabled style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.approCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="说明" name="priceDesc" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.priceDesc" :disabled="isDisable" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
</Card>
<priceInfoList :list="dataListPrice" :formState="formState" :optionSelect="optionSelect" ref="priceRef" pageType="pur" :isDisable="isDisable" :rateCode="rateCode" @change="priceChange"/>
<Card title="附件信息" :bordered="false" >
<UploadList :disabled="isDisable" :list="dataFile" :value="formState.filePath" :tableName="tableName" :columnName="columnName" @change="uploadListChange"/>
</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 { 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 { addLngPricePurPngApp,updateLngPricePurPngApp, getLngPricePurPngApp } from '/@/api/price/PricePurPngApp';
import dayjs from 'dayjs';
import { h } from 'vue';
import { SearchOutlined } from '@ant-design/icons-vue';
import { getAppEnvConfig } from '/@/utils/env';
import { message } from 'ant-design-vue';
import UploadList from '/@/components/Form/src/components/UploadList.vue';
import priceInfoList from '/@/components/common/priceInfoList.vue';
import { useUserStore } from '/@/store/modules/user';
import { getParameter } from '/@/api/contract/ContractProc';
import { DataFormat, FormatOption, DATE_FORMAT, FormatType } from '/@/utils/dataFormat';
import { getAllCom} from '/@/api/contract/ContractPurInt';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const tableName = 'PricePurPngApp';
const columnName = 'PricePurPngApp'
const formType = ref('2'); // 0 新建 1 修改 2 查看
const formRef = ref();
const priceRef = 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 spinning = ref(false);
const curIdx = ref(null)
const rateCode = ref()
const { notification } = useMessage();
const { t } = useI18n();
const formState = reactive({
approCode: 'WTJ',
});
const [registerPur, { openModal:openModalPur}] = useModal();
const rules= reactive({
appName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
priceTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
comId: [{ required: true, message: "该项为必填项", trigger: 'change' }],
});
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
}
const dataFile = ref([]);
let optionSelect= reactive({
approCodeList: [],
priceTypeCodeList: [],
comIdList: [],
baseIncList: []
});
const dataListPrice = ref([
// {
// lngPricePurPngAppSuDtlList: []
// }
])
watch(
() => props.id,
(val) => {
if (val) {
getInfo(val)
}
},
{
immediate: true
}
);
watch(
() => props.disabled,
(val) => {
isDisable.value = val
},
{
immediate: true
}
);
onMounted(async() => {
getOption()
if (pageId.value) {
getInfo(pageId.value)
}
let a = await getParameter({code: 'RATE_M3_GJ'})||[]
rateCode.value = a[0]?.valueNum1
});
const priceChange = (val) => {
dataListPrice.value = val
}
const uploadListChange = (val) => {
dataFile.value = val
}
async function getInfo(id) {
spinning.value = true
try {
let data = await getLngPricePurPngApp(id)
spinning.value = false
Object.assign(formState, {...data})
Object.assign(dataFile.value, formState.lngFileUploadList || [])
Object.assign(dataListPrice.value, formState.lngPricePurPngAppSuList || [])
dataListPrice.value.forEach(v=> {
v.dateFrom = v.dateFrom ? dayjs(v.dateFrom) : null
})
} catch (error) {
spinning.value = false
}
}
async function getOption() {
optionSelect.priceTypeCodeList = await getDictionary('LNG_PRC_T')
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
optionSelect.baseIncList = await getDictionary('LNG_BASE')
optionSelect.comIdList = await getAllCom() || []
}
async function getFormValue() {
return formState
}
async function handleSubmit(type) {
try {
await formRef.value.validateFields();
let priceList = priceRef.value.getList()
for(let i=0; i<priceList.length; i++) {
let isFlag = !priceList[i].kName || !priceList[i].dateFrom
if (isFlag) {
message.warn('请完善供应商价格信息必选项')
return
}
let arr = priceList[i].lngPricePurPngAppSuDtlList || []
for(let i=0; i<arr.length; i++) {
if (!arr[i].priceCode) {
message.warn('请完善供应商价格信息必选项')
return
}
}
}
let obj = {
...formState,
lngPricePurPngAppSuList: priceList,
lngFileUploadList: dataFile.value,
approCode: pageType.value=='update' ? 'WTJ' : formState.approCode
}
spinning.value = true;
let request = !formState.id ? addLngPricePurPngApp :updateLngPricePurPngApp
try {
const data = await request(obj);
// 新增保存
if (data?.id) {
getInfo(data?.id)
}
// 同意保存不提示
if (!type) {
notification.success({
message: '提示',
description: data?.id ? t('新增成功') : t('修改成功')
}); //提示消息
}
return data?.id ? data : obj
} finally {
spinning.value = false;
}
} catch (errorInfo) {
spinning.value = false;
errorInfo?.errorFields?.length && notification.warning({
message: '提示',
description: '请完善信息'
});
return false
}
}
defineExpose({
handleSubmit,
getFormValue
});
</script>
<style lang="less" scoped>
:deep(.ant-form-item .ant-form-item-label) {
width: 135px !important;
max-width: 135px !important;
}
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar {
min-height: 44px;
margin-bottom: 12px;
border-bottom: 1px solid #eee;
}
.redStyle {
color: red;
}
.tbStyle {
border: 1px dashed #d9d9d9;
padding: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -59,6 +59,9 @@
import useEventBus from '/@/hooks/event/useEventBus'; import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus(); const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
@ -159,7 +162,9 @@
query: { query: {
taskId: taskIds[0], taskId: taskIds[0],
formName: formName, formName: formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
id: record.id,
readonly: 1,
} }
}); });
} else if (schemaId && !taskIds && processId) { } else if (schemaId && !taskIds && processId) {
@ -169,19 +174,33 @@
readonly: 1, readonly: 1,
taskId: '', taskId: '',
formName: formName, formName: formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
id: record.id,
} }
}); });
} else { } else {
if (schemaIdComputedRef.value) {
router.push({ router.push({
path: '/form/PricePurPngApp/' + record.id + '/viewForm', path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: { query: {
formPath: 'price/PricePurPngApp', formPath: 'price/PricePurPngApp',
formName: formName, formName: "查看"+formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
type:'',
id: record.id,
disabled: 1,
} }
}); });
} }
// router.push({
// path: '/form/PricePurPngApp/' + record.id + '/viewForm',
// query: {
// formPath: 'price/PricePurPngApp',
// formName: formName,
// formId:currentRoute.value.meta.formId
// }
// });
}
} }
function buttonClick(code) { function buttonClick(code) {
@ -196,7 +215,11 @@
function handleAdd() { function handleAdd() {
if (schemaIdComputedRef.value) { if (schemaIdComputedRef.value) {
router.push({ router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow' path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'price/PricePurPngApp',
formName: "新建"+formName,
}
}); });
} else { } else {
router.push({ router.push({
@ -211,7 +234,18 @@
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'price/PricePurPngApp',
formName: "编辑"+formName,
formId:currentRoute.value.meta.formId,
type:'edit',
id: record.id
}
});
} else {
router.push({ router.push({
path: '/form/PricePurPngApp/' + record.id + '/updateForm', path: '/form/PricePurPngApp/' + record.id + '/updateForm',
query: { query: {
@ -221,8 +255,20 @@
} }
}); });
} }
}
function handleApprove(record: Recordable) { function handleApprove(record: Recordable) {
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: "审批"+formName,
formId:currentRoute.value.meta.formId,
id: record.id
}
});
}
} }
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
deleteList([record.id]); deleteList([record.id]);
@ -283,9 +329,10 @@
let actionsList: ActionItem[] = []; let actionsList: ActionItem[] = [];
let editAndDelBtn: ActionItem[] = []; let editAndDelBtn: ActionItem[] = [];
let approveBtn: ActionItem[] = [];
let hasFlowRecord = false; let hasFlowRecord = false;
actionButtonConfig.value?.map((button) => { actionButtonConfig.value?.map((button) => {
if (['view', 'copyData'].includes(button.code)) { if (['view', 'copyData', 'datalog'].includes(button.code)) {
actionsList.push({ actionsList.push({
icon: button?.icon, icon: button?.icon,
tooltip: button?.name, tooltip: button?.name,
@ -300,21 +347,42 @@
onClick: btnEvent[button.code].bind(null, record), onClick: btnEvent[button.code].bind(null, record),
}); });
} }
if (['approve'].includes(button.code)) {
approveBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
if (button.code === 'flowRecord') hasFlowRecord = true; if (button.code === 'flowRecord') hasFlowRecord = true;
}); });
if (record.workflowData?.enabled) { // 未提交或已驳回
//与工作流有关联的表单 if (record.approCode == 'WTJ' || record.approCode == 'YBH' ) {
if (record.workflowData.status) {
actionsList.unshift(setIndexFlowStatus(record.workflowData))
} else {
actionsList = actionsList.concat(editAndDelBtn);
}
} else {
if (!record.workflowData?.processId) {
//与工作流没有关联的表单并且在当前页面新增的数据 如选择编辑、删除按钮则加上
actionsList = actionsList.concat(editAndDelBtn); actionsList = actionsList.concat(editAndDelBtn);
if (record.createUserId !== userInfo.id) {
let idx = actionsList.findIndex(v =>v.tooltip == '删除')
idx > -1 && actionsList.splice(idx, 1)
} }
} }
// 审批中SPZ
if (record.workflowData?.editable) {
actionsList = actionsList.concat(approveBtn);
}
// if (record.workflowData?.enabled) {
// //与工作流有关联的表单
// if (record.workflowData.status) {
// actionsList.unshift(setIndexFlowStatus(record.workflowData))
// } else {
// actionsList = actionsList.concat(editAndDelBtn);
// }
// } else {
// if (!record.workflowData?.processId) {
// //与工作流没有关联的表单并且在当前页面新增的数据 如选择编辑、删除按钮则加上
// actionsList = actionsList.concat(editAndDelBtn);
// }
// }
return actionsList; return actionsList;
} }
function handleStartwork(record: Recordable) { function handleStartwork(record: Recordable) {

View File

@ -0,0 +1,287 @@
<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="价格申请" :bordered="false" >
<a-row>
<a-col :span="16">
<a-form-item label="申请说明" name="appName" :label-col="{ span: 4 }" :wrapper-col="{ span: 24 }">
<a-input v-model:value="formState.appName" placeholder="请输入" :disabled="isDisable"/>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="定价类型" name="priceTypeCode">
<a-select v-model:value="formState.priceTypeCode" :disabled="isDisable" placeholder="请选择" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.priceTypeCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="交易主体" name="comId">
<a-select v-model:value="formState.comId" :disabled="isDisable || dataListPrice.length" placeholder="请选择" style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.comIdList" :key="item.id" :value="item.id">
{{ item.shortName }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="8">
<a-form-item label="状态" name="approCode">
<a-select v-model:value="formState.approCode" disabled style="width: 100%" allow-clear>
<a-select-option v-for="item in optionSelect.approCodeList" :key="item.code" :value="item.code">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="说明" name="priceDesc" :label-col="{ span: 3 }" :wrapper-col="{ span: 24 }">
<a-textarea v-model:value="formState.priceDesc" :disabled="isDisable" placeholder="请输入备注" :auto-size="{ minRows: 2, maxRows: 5 }"/>
</a-form-item>
</a-col>
</a-row>
</Card>
<priceInfoList :list="dataListPrice" :formState="formState" :optionSelect="optionSelect" ref="priceRef" pageType="pur" :isDisable="isDisable" :rateCode="rateCode" @change="priceChange"/>
<Card title="附件信息" :bordered="false" >
<UploadList :disabled="isDisable" :list="dataFile" :value="formState.filePath" :tableName="tableName" :columnName="columnName" @change="uploadListChange"/>
</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 { 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 { addLngPricePurPngApp,updateLngPricePurPngApp, getLngPricePurPngApp } from '/@/api/price/PricePurPngApp';
import dayjs from 'dayjs';
import { h } from 'vue';
import { SearchOutlined } from '@ant-design/icons-vue';
import { getAppEnvConfig } from '/@/utils/env';
import { message } from 'ant-design-vue';
import UploadList from '/@/components/Form/src/components/UploadList.vue';
import priceInfoList from '/@/components/common/priceInfoList.vue';
import { useUserStore } from '/@/store/modules/user';
import { getParameter } from '/@/api/contract/ContractProc';
import { DataFormat, FormatOption, DATE_FORMAT, FormatType } from '/@/utils/dataFormat';
import { getAllCom} from '/@/api/contract/ContractPurInt';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const tableName = 'PricePurPngApp';
const columnName = 'PricePurPngApp'
const formType = ref('2'); // 0 新建 1 修改 2 查看
const formRef = ref();
const priceRef = 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 spinning = ref(false);
const curIdx = ref(null)
const rateCode = ref()
const { notification } = useMessage();
const { t } = useI18n();
const formState = reactive({
approCode: 'WTJ',
});
const [registerPur, { openModal:openModalPur}] = useModal();
const rules= reactive({
appName: [{ required: true, message: "该项为必填项", trigger: 'change' }],
priceTypeCode: [{ required: true, message: "该项为必填项", trigger: 'change' }],
comId: [{ required: true, message: "该项为必填项", trigger: 'change' }],
});
const layout = {
labelCol: { span: 8 },
wrapperCol: { span: 16 },
}
const dataFile = ref([]);
let optionSelect= reactive({
approCodeList: [],
priceTypeCodeList: [],
comIdList: [],
baseIncList: []
});
const dataListPrice = ref([
// {
// lngPricePurPngAppSuDtlList: []
// }
])
watch(
() => props.id,
(val) => {
if (val) {
getInfo(val)
}
},
{
immediate: true
}
);
watch(
() => props.disabled,
(val) => {
isDisable.value = val
},
{
immediate: true
}
);
onMounted(async() => {
getOption()
if (pageId.value) {
getInfo(pageId.value)
}
let a = await getParameter({code: 'RATE_M3_GJ'})||[]
rateCode.value = a[0]?.valueNum1
});
const priceChange = (val) => {
dataListPrice.value = val
}
const uploadListChange = (val) => {
dataFile.value = val
}
async function getInfo(id) {
spinning.value = true
try {
let data = await getLngPricePurPngApp(id)
spinning.value = false
Object.assign(formState, {...data})
Object.assign(dataFile.value, formState.lngFileUploadList || [])
Object.assign(dataListPrice.value, formState.lngPricePurPngAppSuList || [])
} catch (error) {
spinning.value = false
}
}
async function getOption() {
optionSelect.priceTypeCodeList = await getDictionary('LNG_PRC_T')
optionSelect.approCodeList = await getDictionary('LNG_APPRO')
optionSelect.baseIncList = await getDictionary('LNG_BASE')
optionSelect.comIdList = await getAllCom() || []
}
async function getFormValue() {
return formState
}
async function handleSubmit(type) {
try {
await formRef.value.validateFields();
let priceList = priceRef.value.getList()
for(let i=0; i<priceList.length; i++) {
let isFlag = !priceList[i].kName || !priceList[i].dateFrom
if (isFlag) {
message.warn('请完善供应商价格信息必选项')
return
}
let arr = priceList[i].lngPricePurPngAppSuDtlList || []
for(let i=0; i<arr.length; i++) {
if (!arr[i].priceCode) {
message.warn('请完善供应商价格信息必选项')
return
}
}
}
let obj = {
...formState,
lngPricePurPngAppSuList: priceList,
lngFileUploadList: dataFile.value,
approCode: pageType.value=='update' ? 'WTJ' : formState.approCode
}
spinning.value = true;
let request = !formState.id ? addLngPricePurPngApp :updateLngPricePurPngApp
try {
const data = await request(obj);
// 新增保存
if (data?.id) {
getInfo(data?.id)
}
// 同意保存不提示
if (!type) {
notification.success({
message: '提示',
description: data?.id ? t('新增成功') : t('修改成功')
}); //提示消息
}
return data?.id ? data : obj
} finally {
spinning.value = false;
}
} catch (errorInfo) {
spinning.value = false;
errorInfo?.errorFields?.length && notification.warning({
message: '提示',
description: '请完善信息'
});
return false
}
}
defineExpose({
handleSubmit,
getFormValue
});
</script>
<style lang="less" scoped>
:deep(.ant-form-item .ant-form-item-label) {
width: 135px !important;
max-width: 135px !important;
}
.page-bg-wrap {
background-color: #fff;
}
.top-toolbar {
min-height: 44px;
margin-bottom: 12px;
border-bottom: 1px solid #eee;
}
.redStyle {
color: red;
}
.tbStyle {
border: 1px dashed #d9d9d9;
padding: 10px;
margin-bottom: 10px;
}
</style>

View File

@ -59,6 +59,9 @@
import useEventBus from '/@/hooks/event/useEventBus'; import useEventBus from '/@/hooks/event/useEventBus';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
import { useUserStore } from '/@/store/modules/user';
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus(); const { bus, CREATE_FLOW, FLOW_PROCESSED, FORM_LIST_MODIFIED } = useEventBus();
@ -159,7 +162,9 @@
query: { query: {
taskId: taskIds[0], taskId: taskIds[0],
formName: formName, formName: formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
id: record.id,
readonly: 1,
} }
}); });
} else if (schemaId && !taskIds && processId) { } else if (schemaId && !taskIds && processId) {
@ -169,19 +174,33 @@
readonly: 1, readonly: 1,
taskId: '', taskId: '',
formName: formName, formName: formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
id: record.id,
} }
}); });
} else { } else {
if (schemaIdComputedRef.value) {
router.push({ router.push({
path: '/form/PriceSalesPngApp/' + record.id + '/viewForm', path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: { query: {
formPath: 'price/PriceSalesPngApp', formPath: 'price/PriceSalesPngApp',
formName: formName, formName: "查看"+formName,
formId:currentRoute.value.meta.formId formId:currentRoute.value.meta.formId,
type:'',
id: record.id,
disabled: 1,
} }
}); });
} }
// router.push({
// path: '/form/PriceSalesPngApp/' + record.id + '/viewForm',
// query: {
// formPath: 'price/PriceSalesPngApp',
// formName: formName,
// formId:currentRoute.value.meta.formId
// }
// });
}
} }
function buttonClick(code) { function buttonClick(code) {
@ -196,7 +215,11 @@
function handleAdd() { function handleAdd() {
if (schemaIdComputedRef.value) { if (schemaIdComputedRef.value) {
router.push({ router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow' path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'price/PriceSalesPngApp',
formName: "新建"+formName,
}
}); });
} else { } else {
router.push({ router.push({
@ -211,7 +234,18 @@
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
if (schemaIdComputedRef.value) {
router.push({
path: '/flow/' + schemaIdComputedRef.value + '/0/createFlow',
query: {
formPath: 'price/PriceSalesPngApp',
formName: "编辑"+formName,
formId:currentRoute.value.meta.formId,
type:'edit',
id: record.id
}
});
} else {
router.push({ router.push({
path: '/form/PriceSalesPngApp/' + record.id + '/updateForm', path: '/form/PriceSalesPngApp/' + record.id + '/updateForm',
query: { query: {
@ -221,8 +255,20 @@
} }
}); });
} }
}
function handleApprove (record: Recordable) { function handleApprove (record: Recordable) {
const { processId, taskIds, schemaId } = record.workflowData || {};
if (taskIds && taskIds.length) {
router.push({
path: '/flow/' + schemaId + '/' + (processId || '') + '/approveFlow',
query: {
taskId: taskIds[0],
formName: "审批"+formName,
formId:currentRoute.value.meta.formId,
id: record.id
}
});
}
} }
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
deleteList([record.id]); deleteList([record.id]);
@ -283,9 +329,10 @@
let actionsList: ActionItem[] = []; let actionsList: ActionItem[] = [];
let editAndDelBtn: ActionItem[] = []; let editAndDelBtn: ActionItem[] = [];
let approveBtn: ActionItem[] = [];
let hasFlowRecord = false; let hasFlowRecord = false;
actionButtonConfig.value?.map((button) => { actionButtonConfig.value?.map((button) => {
if (['view', 'copyData'].includes(button.code)) { if (['view', 'copyData','datalog'].includes(button.code)) {
actionsList.push({ actionsList.push({
icon: button?.icon, icon: button?.icon,
tooltip: button?.name, tooltip: button?.name,
@ -300,21 +347,41 @@
onClick: btnEvent[button.code].bind(null, record), onClick: btnEvent[button.code].bind(null, record),
}); });
} }
if (['approve'].includes(button.code)) {
approveBtn.push({
icon: button?.icon,
tooltip: button?.name,
onClick: btnEvent[button.code].bind(null, record),
});
}
if (button.code === 'flowRecord') hasFlowRecord = true; if (button.code === 'flowRecord') hasFlowRecord = true;
}); });
if (record.workflowData?.enabled) { // 未提交或已驳回
//与工作流有关联的表单 if (record.approCode == 'WTJ' || record.approCode == 'YBH' ) {
if (record.workflowData.status) {
actionsList.unshift(setIndexFlowStatus(record.workflowData))
} else {
actionsList = actionsList.concat(editAndDelBtn);
}
} else {
if (!record.workflowData?.processId) {
//与工作流没有关联的表单并且在当前页面新增的数据 如选择编辑、删除按钮则加上
actionsList = actionsList.concat(editAndDelBtn); actionsList = actionsList.concat(editAndDelBtn);
if (record.createUserId !== userInfo.id) {
let idx = actionsList.findIndex(v =>v.tooltip == '删除')
idx > -1 && actionsList.splice(idx, 1)
} }
} }
// 审批中SPZ
if (record.workflowData?.editable) {
actionsList = actionsList.concat(approveBtn);
}
// if (record.workflowData?.enabled) {
// //与工作流有关联的表单
// if (record.workflowData.status) {
// actionsList.unshift(setIndexFlowStatus(record.workflowData))
// } else {
// actionsList = actionsList.concat(editAndDelBtn);
// }
// } else {
// if (!record.workflowData?.processId) {
// //与工作流没有关联的表单并且在当前页面新增的数据 如选择编辑、删除按钮则加上
// actionsList = actionsList.concat(editAndDelBtn);
// }
// }
return actionsList; return actionsList;
} }
function handleStartwork(record: Recordable) { function handleStartwork(record: Recordable) {