413 lines
18 KiB
Vue
413 lines
18 KiB
Vue
<template>
|
|
<div class="edit-popup">
|
|
<popup ref="popupRef" :title="popupTitle" :async="true" width="80%" @confirm="handleSubmit" @close="handleClose">
|
|
<el-form ref="formRef" :model="formData" label-width="120px" :rules="formRules">
|
|
<el-row>
|
|
<el-col :span="8">
|
|
<el-form-item label="合同编号" prop="contract_no">
|
|
<el-input v-model="formData.contract_no" clearable placeholder="请输入合同编号" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="供应商合同号" prop="supplier_contract_no">
|
|
<el-input v-model="formData.supplier_contract_no" clearable placeholder="请输入供应商合同号" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="供应商名称" prop="supplier_contract_no">
|
|
<el-input v-model="formData.supplier_contract_no" clearable placeholder="请输入供应商合同号" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="供应商编码" prop="supplier_contract_no">
|
|
<el-input v-model="formData.supplier_contract_no" clearable placeholder="请输入供应商合同号" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="供应商编码" prop="supplier_contract_no">
|
|
<el-input v-model="formData.supplier_contract_no" clearable placeholder="请输入供应商合同号" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="项目名称" prop="supplier_contract_no">
|
|
<el-input v-model="formData.supplier_contract_no" clearable placeholder="请输入供应商合同号" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="项目编码" prop="supplier_contract_no">
|
|
<el-input v-model="formData.supplier_contract_no" clearable placeholder="请输入供应商合同号" />
|
|
</el-form-item> </el-col>
|
|
|
|
|
|
<el-col :span="24">
|
|
|
|
|
|
<el-form-item label="合同类型" prop="contract_type">
|
|
<el-radio-group v-model="formData.contract_type" placeholder="请选择合同类型">
|
|
<el-radio v-for="(item, index) in dictData.procurement_contract_type" :key="index" :label="parseInt(item.value)">
|
|
{{ item.name }}
|
|
</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="签订日期" prop="signing_date">
|
|
<el-date-picker class="flex-1 !flex" v-model="formData.signing_date" clearable type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="选择签订日期">
|
|
</el-date-picker>
|
|
</el-form-item>
|
|
</el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="合同金额" prop="amount">
|
|
<el-input v-model="formData.amount" clearable placeholder="请输入合同金额" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="24">
|
|
<el-form-item label="付款方式" prop="pay_type">
|
|
<el-radio-group v-model="formData.pay_type" placeholder="请选择付款方式">
|
|
<el-radio v-for="(item, index) in dictData.pay_type" :key="index" :label="parseInt(item.value)">
|
|
{{ item.name }}
|
|
</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item> </el-col>
|
|
<el-col :span="24">
|
|
<el-form-item label="账期" prop="account_period">
|
|
<el-radio-group v-model="formData.account_period" placeholder="请选择账期">
|
|
<el-radio v-for="(item, index) in dictData.account_period" :key="index" :label="parseInt(item.value)">
|
|
{{ item.name }}
|
|
</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item> </el-col>
|
|
|
|
<el-col :span="8">
|
|
<el-form-item label="不含税金额" prop="amount_excluding_tax">
|
|
<el-input v-model="formData.amount_excluding_tax" clearable placeholder="请输入不含税金额" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="金额大写" prop="amount_daxie">
|
|
<el-input v-model="formData.amount_daxie" clearable placeholder="请输入金额大写" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="质保金比例" prop="retention_money_rate">
|
|
<el-input v-model="formData.retention_money_rate" clearable placeholder="请输入质保金比例" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="质保金" prop="retention_money">
|
|
<el-input v-model="formData.retention_money" clearable placeholder="请输入质保金" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="8">
|
|
<el-form-item label="备注" prop="remark">
|
|
<el-input v-model="formData.remark" clearable placeholder="请输入备注" />
|
|
</el-form-item> </el-col>
|
|
<el-col :span="24">
|
|
<el-form-item label="附件" prop="field127">
|
|
<el-upload accept="doc, docx, xls, xlsx, ppt, pptx, pdf, txt, zip, rar, tar, jpg, png, gif, jpeg, webp, wmv, avi, mpg, mpeg, 3gp, mov, mp4, flv, f4v, rmvb, mkv" class="upload-demo" :show-file-list="false" aria-hidden="true" :headers="{ Token: userStore.token }" :action="base_url + '/upload/file'" :on-success="handleAvatarSuccess_four" ref="upload">
|
|
<el-button type="primary">
|
|
上传
|
|
</el-button>
|
|
</el-upload>
|
|
|
|
<div>
|
|
<div v-for="(item, index) in formDataannex" style="margin-left: 5px;display: block;">
|
|
<a style="margin-left: 10px; color: #4a5dff; align-self: flex-start" :href="item.uri" target="_blank">{{ item.name }}</a>
|
|
<span style="cursor: pointer;margin-left: 5px;" @click="delFileFn(index)">x</span>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-row>
|
|
<div style="margin-bottom: 30px;">采购合同明细</div>
|
|
<div style="margin-bottom: 30px;">
|
|
<el-table :data="formData.material">
|
|
<el-table-column label="序号">
|
|
<template #default="{ row }">
|
|
<el-button @click="handleAdd1(row)">+</el-button>
|
|
<el-button @click="handleDelete1(row)">-</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="采购申请单号" prop="material_procurement_application_id">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.material_procurement_application_id" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="材料名称" prop="material_procurement_application_id">
|
|
<template #default="{ row }"> <el-input v-model="row.material_procurement_application_id" /> </template></el-table-column>
|
|
<el-table-column label="材料编码" prop="material_procurement_application_id">
|
|
<template #default="{ row }"> <el-input v-model="row.material_procurement_application_id" /> </template></el-table-column>
|
|
|
|
<el-table-column label="规格型号" prop="material_procurement_application_id">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.material_procurement_application_id" />
|
|
</template>
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column label="数量" prop="product_num">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.product_num" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="单位" prop="tax_rate">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.tax_rate" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="数量" prop="num">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.num" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="含税单价" prop="unit_price_including_tax">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.unit_price_including_tax" />
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="税率" prop="tax_rate">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.tax_rate" />
|
|
</template>
|
|
</el-table-column>
|
|
|
|
<el-table-column label="不含税金额" prop="amount_excluding_tax">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.amount_excluding_tax" />
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="含税金额" prop="amount_including_tax">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.amount_including_tax" />
|
|
</template>
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
</div>
|
|
<div style="margin-bottom: 30px;">付款计划</div>
|
|
<div style="margin-bottom: 30px;">
|
|
<el-table :data="formData.pay_plan">
|
|
<el-table-column label="序号">
|
|
<template #default="{ row }">
|
|
<el-button @click="handleAdd(row)">+</el-button>
|
|
<el-button @click="handleDelete(row)">-</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="期次" prop="name1">
|
|
<template #default="{ row }">
|
|
<el-select v-model="row.period" clearable placeholder="请选择期次">
|
|
<el-option v-for="(item, index) in dictData.pay_period " :key="index" :label="item.name" :value="item.id" />
|
|
</el-select>
|
|
</template>
|
|
</el-table-column>
|
|
<el-table-column label="计划付款日期" prop="pay_date">
|
|
<template #default="{ row }">
|
|
<el-date-picker v-model="row.pay_date" clearable type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="选择签订日期">
|
|
</el-date-picker>
|
|
</template></el-table-column>
|
|
<el-table-column label="金额" prop="pay_amount">
|
|
<template #default="{ row }"> <el-input v-model="row.pay_amount" /> </template></el-table-column>
|
|
|
|
<el-table-column label="备注" prop="remark">
|
|
<template #default="{ row }">
|
|
<el-input v-model="row.remark" />
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
</div>
|
|
</el-form>
|
|
</popup>
|
|
<el-dialog v-model="showDialog" title="选择项目" width="70%">
|
|
<procurementTable @customEvent="customEvent"></procurementTable>
|
|
</el-dialog>
|
|
|
|
</div>
|
|
</template>
|
|
|
|
<script lang="ts" setup name="procurementContractEdit">
|
|
import type { FormInstance } from 'element-plus'
|
|
import Popup from '@/components/popup/index.vue'
|
|
|
|
import procurementTable from '@/components/procurement/index.vue'
|
|
import { apiProcurementAdd, apiProcurementEdit, apiProcurementDetail } from '@/api/procurement_changes'
|
|
import { timeFormat } from '@/utils/util'
|
|
import type { PropType } from 'vue'
|
|
defineProps({
|
|
dictData: {
|
|
type: Object as PropType<Record<string, any[]>>,
|
|
default: () => ({})
|
|
}
|
|
})
|
|
const emit = defineEmits(['success', 'close'])
|
|
const formRef = shallowRef<FormInstance>()
|
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
|
const mode = ref('add')
|
|
const showDialog = ref(false)
|
|
const showDialog1 = ref(false)
|
|
const project_name = ref('')
|
|
const project_code = ref('')
|
|
const formDataannex = reactive([])
|
|
const tableData = reactive([])
|
|
const tableData1 = reactive([])
|
|
import feedback from '@/utils/feedback'
|
|
import configs from "@/config"
|
|
const base_url = configs.baseUrl + configs.urlPrefix
|
|
import useUserStore from "@/stores/modules/user";
|
|
const userStore = useUserStore();
|
|
// 上传文件
|
|
const handleAvatarSuccess_four = (
|
|
response,
|
|
uploadFile
|
|
) => {
|
|
if (response.code == 0) {
|
|
feedback.msgError(response.msg);
|
|
return;
|
|
}
|
|
formDataannex.push(
|
|
{ uri: response.data.uri, name: response.data.name }
|
|
|
|
);
|
|
};
|
|
// 删除上传的文件
|
|
const delFileFn = (index: number) => {
|
|
formDataannex.splice(index, 1)
|
|
}
|
|
const handleAdd = (row: any) => {
|
|
// 在 row 后面插入一行数据
|
|
const index = tableData.indexOf(row);
|
|
tableData.splice(index + 1, 0, {});
|
|
};
|
|
|
|
const handleDelete = (row: any) => {
|
|
// 删除 row
|
|
const index = tableData.indexOf(row);
|
|
tableData.splice(index, 1);
|
|
}
|
|
const handleDelete1 = (row: any) => {
|
|
// 删除 row
|
|
const index = formData.pay_plan.indexOf(row);
|
|
formData.material.splice(index, 1);
|
|
};
|
|
// 弹窗标题
|
|
const popupTitle = computed(() => {
|
|
return mode.value == 'edit' ? '编辑采购变更' : '新增采购变更'
|
|
})
|
|
|
|
// 表单数据
|
|
const formData = reactive({
|
|
id: '',
|
|
supplier_id: '',
|
|
approve_id: '',
|
|
procurement_contract_id: '',
|
|
contract_no: '',
|
|
supplier_contract_no: '',
|
|
contract_type: '',
|
|
signing_date: '',
|
|
pay_type: '',
|
|
account_period: '',
|
|
amount: '',
|
|
amount_excluding_tax: '',
|
|
amount_daxie: '',
|
|
retention_money_rate: '',
|
|
retention_money: '',
|
|
remark: '',
|
|
annex: '',
|
|
material: [{
|
|
material_procurement_application_id: 2222,
|
|
num: 0,
|
|
unit_price_including_tax: 0,
|
|
tax_rate: "",
|
|
amount_excluding_tax: 0,
|
|
amount_including_tax: 0
|
|
}],
|
|
pay_plan: [{
|
|
period: '',
|
|
pay_date: '',
|
|
pay_amount: '',
|
|
remark: ''
|
|
}]
|
|
})
|
|
const customEvent = (e: any) => {
|
|
project_name.value = e.name
|
|
formData.project_id = e.id
|
|
project_code.value = e.project_code
|
|
showDialog.value = false;
|
|
showDialog.value = false;
|
|
};
|
|
const customEvent1 = (e: any) => {
|
|
|
|
|
|
showDialog1.value = false;
|
|
};
|
|
|
|
// 表单验证
|
|
const formRules = reactive<any>({
|
|
|
|
})
|
|
|
|
|
|
// 获取详情
|
|
const setFormData = async (data: Record<any, any>) => {
|
|
if (data.annex && data.annex.length > 0) {
|
|
if (data.annex.includes(",")) {
|
|
const arry1 = data.annex.split(',').map((item: any, index: any) => {
|
|
return {
|
|
name: `文件${index + 1}`,
|
|
uri: item
|
|
};
|
|
});
|
|
Object.assign(formDataannex, arry1)
|
|
} else {
|
|
const arry1 = [{ name: `文件1`, uri: data.annex[0] }]
|
|
Object.assign(formDataannex, arry1)
|
|
|
|
}
|
|
}
|
|
project_name.value = data.project.name
|
|
project_code.value = data.project.project_code
|
|
|
|
for (const key in formData) {
|
|
if (data[key] != null && data[key] != undefined) {
|
|
//@ts-ignore
|
|
formData[key] = data[key]
|
|
}
|
|
}
|
|
|
|
//@ts-ignore
|
|
formData.signing_date = timeFormat(formData.signing_date, 'yyyy-mm-dd hh:MM:ss')
|
|
}
|
|
|
|
const getDetail = async (row: Record<string, any>) => {
|
|
const data = await apiProcurementDetail({
|
|
id: row.id
|
|
})
|
|
setFormData(data)
|
|
}
|
|
|
|
|
|
// 提交按钮
|
|
const handleSubmit = async () => {
|
|
if (formDataannex.length > 0) {
|
|
formData.annex = formDataannex.map((item) => item.uri).toString()
|
|
}
|
|
await formRef.value?.validate()
|
|
const data = { ...formData, }
|
|
mode.value == 'edit'
|
|
? await apiProcurementEdit(data)
|
|
: await apiProcurementAdd(data)
|
|
popupRef.value?.close()
|
|
emit('success')
|
|
}
|
|
|
|
//打开弹窗
|
|
const open = (type = 'add') => {
|
|
mode.value = type
|
|
popupRef.value?.open()
|
|
}
|
|
|
|
// 关闭回调
|
|
const handleClose = () => {
|
|
emit('close')
|
|
}
|
|
|
|
|
|
|
|
defineExpose({
|
|
open,
|
|
setFormData,
|
|
getDetail
|
|
})
|
|
</script>
|