123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 |
- <template>
- <div style="width: 100%; padding: 0px 15px">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
- <template #seller>
- <div style="width: 100%">
- <el-form-item prop="sellCorporationId">
- <el-select v-model="formData.data.sellCorporationId" style="width: 100%" disabled>
- <el-option v-for="item in corporationList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="8">
- <el-form-item label="地址" prop="sellCountryName">
- <el-input v-model="formData.data.sellCountryName" placeholder="请输入国家" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label=" " prop="sellProvinceName">
- <el-input v-model="formData.data.sellProvinceName" placeholder="请输入省/州" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label=" " prop="sellCityName">
- <el-input v-model="formData.data.sellCityName" placeholder="请输入城市" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="24">
- <el-form-item prop="sellAddress">
- <el-input v-model="formData.data.sellAddress" type="textarea"> </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="8">
- <el-form-item label="联系人" prop="sellContactName">
- <el-input v-model="formData.data.sellContactName" placeholder="请输入联系人" />
- </el-form-item>
- </el-col>
- <el-col :span="16">
- <el-form-item label=" " prop="sellContactNumber">
- <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </template>
- <template #buyer>
- <div style="width: 100%">
- <div style="width: 100%">
- <el-form-item prop="buyCorporationId">
- <el-select v-model="formData.data.buyCorporationId" style="width: 100%" @change="changeCustomer">
- <el-option v-for="item in customerList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="6">
- <el-form-item label="地址" prop="countryId">
- <el-select v-model="formData.data.countryId" placeholder="国家" filterable @change="(val) => getCityData(val, '20', true)">
- <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id"> </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label=" " prop="provinceName">
- <selectCity
- placeholder="省/洲"
- @change="(val) => getCityData(val, '30', true)"
- addressId="provinceId"
- addressName="provinceName"
- v-model="formData.data"
- :data="provinceData">
- </selectCity>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label=" " prop="cityName">
- <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData"> </selectCity>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label=" " prop="buyPostalCode">
- <el-input v-model="formData.data.buyPostalCode" placeholder="请输入邮编" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="24">
- <el-form-item prop="buyAddress">
- <el-input v-model="formData.data.buyAddress" type="textarea"> </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="8">
- <el-form-item label="联系人" prop="buyContactName">
- <el-autocomplete
- v-model="formData.data.buyContactName"
- :fetch-suggestions="querySearchPerson"
- clearable
- class="inline-input w-50"
- placeholder="请输入联系人"
- @select="handlePerson">
- </el-autocomplete>
- </el-form-item>
- </el-col>
- <el-col :span="16">
- <el-form-item label=" " prop="buyContactNumber">
- <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
- <template #commodity>
- <div style="width: 100%">
- <el-button @click="openProduct = true">添加商品</el-button>
- <el-table :data="formData.data.quotationProductList" style="width: 100%; margin-top: 16px">
- <el-table-column label="商品图片" width="80">
- <template #default="{ row }">
- <div v-if="row.productId">
- <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
- </div>
- <div v-else></div>
- </template>
- </el-table-column>
- <el-table-column prop="code" label="商品编码" width="120" />
- <el-table-column prop="name" label="商品中文名" width="160" />
- <el-table-column label="商品英文名" min-width="200">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationProductList.' + $index + '.productName'" :rules="rules.productName" :inline-message="true">
- <el-input v-model="row.productName" placeholder="请输入商品英文名" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="规格型号" width="180">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationProductList.' + $index + '.productModel'" :inline-message="true">
- <el-input v-model="row.productModel" placeholder="请输入规格型号" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="unit" label="单位" width="100" />
- <el-table-column label="数量" width="150">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
- <el-input-number
- onmousewheel="return false;"
- v-model="row.quantity"
- placeholder="请输入数量"
- style="width: 100%"
- :precision="0"
- :controls="false"
- :min="0"
- @change="calculationAmount()" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="单价" width="160">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true">
- <el-input-number
- onmousewheel="return false;"
- v-model="row.price"
- placeholder="请输入单价"
- style="width: 100%"
- :precision="2"
- :controls="false"
- :min="0"
- @change="calculationAmount()" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="amount" label="金额" width="100" />
- <el-table-column align="center" label="操作" width="80" fixed="right">
- <template #default="{ $index }">
- <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <template #otherCharge>
- <div style="width: 100%">
- <el-button type="primary" @click="clickAdd()">添加行</el-button>
- <el-table :data="formData.data.quotationPayList" style="width: 100%; margin-top: 16px">
- <el-table-column label="收费项目" width="220">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationPayList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true">
- <el-autocomplete v-model="row.payName" :fetch-suggestions="querySearch" clearable class="inline-input w-50" placeholder="请输入收费项目" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="金额" width="180">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationPayList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true">
- <el-input-number
- onmousewheel="return false;"
- v-model="row.amount"
- placeholder="请输入金额"
- style="width: 100%"
- :precision="2"
- :controls="false"
- :min="0"
- @change="totalAmount()" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="备注">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'quotationPayList.' + $index + '.remark'">
- <el-input v-model="row.remark" placeholder="请输入备注" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="80" fixed="right">
- <template #default="{ row, $index }">
- <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <template #offerMoney>
- <div style="width: 100%">
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="4">
- <el-form-item label="币种" prop="currency">
- <el-select v-model="formData.data.currency" placeholder="请选择币种" style="width: 100%">
- <el-option v-for="item in accountCurrency" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="合同总金额" prop="amount">
- <el-input v-model="formData.data.amount" placeholder="合同总金额" disabled />
- </el-form-item>
- </el-col>
- <el-col :span="4">
- <el-form-item label="报价有效期 (天)" prop="effective">
- <el-input-number
- onmousewheel="return false;"
- v-model="formData.data.effective"
- placeholder="请输入有效期"
- style="width: 100%"
- :precision="0"
- :controls="false"
- :min="0" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="7">
- <el-form-item label="付款方式" prop="paymentMethod">
- <el-select v-model="formData.data.paymentMethod" placeholder="请选择付款方式" style="width: 100%">
- <el-option v-for="item in fundsPaymentMethod" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="7">
- <el-form-item label="预付比例 (%)" prop="advanceRatio">
- <el-input-number
- onmousewheel="return false;"
- v-model="formData.data.advanceRatio"
- placeholder="请输入预付比例"
- style="width: 100%"
- :precision="2"
- :controls="false"
- :min="0"
- :max="100" />
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </template>
- <template #delivery>
- <div style="width: 100%">
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="7">
- <el-form-item label="贸易方式" prop="tradeMethods">
- <el-select v-model="formData.data.tradeMethods" placeholder="请选择贸易方式" style="width: 100%">
- <el-option v-for="item in tradeMethods" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="7">
- <el-form-item label="运输方式" prop="transportMethod">
- <el-select v-model="formData.data.transportMethod" placeholder="请选择运输方式" style="width: 100%">
- <el-option v-for="item in shippingMethod" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="7">
- <el-form-item label="运输说明" prop="transportRemark">
- <el-input v-model="formData.data.transportRemark" placeholder="请输入运输说明" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="14">
- <el-form-item label="付款条件" prop="remark">
- <el-input v-model="formData.data.remark" :rows="2" type="textarea" placeholder="请输入付款条件" />
- </el-form-item>
- </el-col>
- </el-row>
- <el-row style="margin-top: 20px; width: 100%">
- <el-col :span="7">
- <el-form-item label="质保期 (天)" prop="warranty">
- <el-input-number
- onmousewheel="return false;"
- v-model="formData.data.warranty"
- placeholder="请输入质保期"
- style="width: 100%"
- :precision="0"
- :controls="false"
- :min="0" />
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </template>
- </byForm>
- <el-dialog v-if="openProduct" v-model="openProduct" title="选择商品" width="70%" append-to-body>
- <SelectGoods :selectList="acquireSelectList()" @cancel="openProduct = false" @pushGoods="pushGoods"></SelectGoods>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import byForm from "@/components/byForm/index";
- import SelectGoods from "@/components/product/SelectGoods";
- import { ElMessage } from "element-plus";
- import selectCity from "@/components/selectCity/index.vue";
- import { useRoute } from "vue-router";
- const route = useRoute();
- const { proxy } = getCurrentInstance();
- const accountCurrency = ref([]);
- const fundsPaymentMethod = ref([]);
- const tradeMethods = ref([]);
- const shippingMethod = ref([]);
- const templateList = ref([]);
- const corporationList = ref([]);
- const customerList = ref([]);
- const countryData = ref([]);
- const provinceData = ref([]);
- const cityData = ref([]);
- const customerUserList = ref([]);
- const openProduct = ref(false);
- const formData = reactive({
- data: {
- amount: undefined,
- quotationProductList: [],
- quotationPayList: [],
- },
- });
- const submit = ref(null);
- const judgeStatus = () => {
- if (props.queryData.recordList && props.queryData.recordList.length > 0) {
- let data = props.queryData.recordList.filter((item) => item.status === 2 && item.nodeType !== 1);
- if (data && data.length > 0) {
- return true;
- }
- }
- return false;
- };
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- disabled: false,
- });
- const formConfig = computed(() => {
- return [
- {
- type: "title",
- title: "合同模板",
- label: "",
- },
- {
- type: "select",
- label: "选择合同模板",
- prop: "contractTemplateId",
- data: templateList.value,
- fn: (val) => {
- changeTemplate(val);
- },
- },
- {
- type: "slot",
- slotName: "seller",
- label: "卖方信息",
- itemWidth: 50,
- },
- {
- type: "slot",
- slotName: "buyer",
- label: "买方信息",
- itemWidth: 50,
- },
- {
- type: "slot",
- slotName: "commodity",
- label: "商品信息",
- },
- {
- type: "slot",
- slotName: "otherCharge",
- label: "其他收费项目",
- },
- {
- type: "slot",
- slotName: "offerMoney",
- label: "报价金额",
- },
- {
- type: "slot",
- slotName: "delivery",
- label: "交付信息",
- },
- ];
- });
- const rules = ref({
- contractTemplateId: [{ required: true, message: "请选择合同模板", trigger: "change" }],
- buyCorporationId: [{ required: true, message: "请选择公司", trigger: "change" }],
- countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
- sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
- buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
- buyContactName: [{ required: true, message: "请输入联系人", trigger: ["change", "blur"] }],
- buyContactNumber: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
- productName: [{ required: true, message: "请输入商品英文名", trigger: "blur" }],
- productModel: [{ required: true, message: "请输入规格型号", trigger: "blur" }],
- quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
- price: [{ required: true, message: "请输入单价", trigger: "blur" }],
- amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
- payName: [{ required: true, message: "请输入收费项目", trigger: ["change", "blur"] }],
- currency: [{ required: true, message: "请选择币种", trigger: "change" }],
- effective: [{ required: true, message: "请输入报价有效期", trigger: "blur" }],
- deliveryTime: [{ required: true, message: "请选择交货期限", trigger: "change" }],
- paymentMethod: [{ required: true, message: "请选择付款方式", trigger: "change" }],
- advanceRatio: [{ required: true, message: "请输入预付比例", trigger: "blur" }],
- tradeMethods: [{ required: true, message: "请选择贸易方式", trigger: "change" }],
- transportMethod: [{ required: true, message: "请选择运输方式", trigger: "change" }],
- transportRemark: [{ required: true, message: "请输入运输说明", trigger: "blur" }],
- remark: [{ required: true, message: "请输入付款条件", trigger: "blur" }],
- });
- const getDict = () => {
- proxy.getDictOne(["account_currency", "funds_payment_method", "trade_methods", "shipping_method"]).then((res) => {
- accountCurrency.value = res["account_currency"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- fundsPaymentMethod.value = res["funds_payment_method"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- tradeMethods.value = res["trade_methods"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- shippingMethod.value = res["shipping_method"].map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- proxy.post("/contractTemplate/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- templateList.value = res.rows.map((item) => {
- return {
- ...item,
- label: item.templateName,
- value: item.id,
- };
- });
- });
- proxy.post("/corporation/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- corporationList.value = res.rows.map((item) => {
- return {
- ...item,
- label: item.name,
- value: item.id,
- };
- });
- });
- proxy.post("/customer/page", { pageNum: 1, pageSize: 999 }).then((res) => {
- customerList.value = res.rows.map((item) => {
- return {
- ...item,
- label: item.name,
- value: item.id,
- };
- });
- });
- };
- getDict();
- const changeTemplate = (val) => {
- formData.data.sellCorporationId = "";
- formData.data.sellContactName = "";
- formData.data.sellContactNumber = "";
- formData.data.sellCountryName = "";
- formData.data.sellProvinceName = "";
- formData.data.sellCityName = "";
- formData.data.sellAddress = "";
- if (val) {
- proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
- formData.data.sellCorporationId = res.corporationId;
- if (res.corporationId) {
- proxy.post("/corporation/detail", { id: res.corporationId }).then((detailCorporation) => {
- proxy.post("/customizeArea/list", { parentId: "0" }).then((resCountry) => {
- let sellCountryData = resCountry.filter((item) => item.id === detailCorporation.countryId);
- if (sellCountryData && sellCountryData.length > 0) {
- formData.data.sellCountryName = sellCountryData[0].chineseName;
- } else {
- formData.data.sellCountryName = "";
- }
- });
- if (detailCorporation.countryId) {
- proxy.post("/customizeArea/list", { parentId: detailCorporation.countryId }).then((resProvince) => {
- let sellProvinceData = resProvince.filter((item) => item.id === detailCorporation.provinceId);
- if (sellProvinceData && sellProvinceData.length > 0) {
- formData.data.sellProvinceName = sellProvinceData[0].name;
- } else {
- formData.data.sellProvinceName = "";
- }
- });
- } else {
- formData.data.sellProvinceName = "";
- }
- if (detailCorporation.provinceId) {
- proxy.post("/customizeArea/list", { parentId: detailCorporation.provinceId }).then((resCity) => {
- let sellCityData = resCity.filter((item) => item.id === detailCorporation.cityId);
- if (sellCityData && sellCityData.length > 0) {
- formData.data.sellCityName = sellCityData[0].name;
- } else {
- formData.data.sellCityName = "";
- }
- });
- } else {
- formData.data.sellCityName = "";
- }
- formData.data.sellAddress = detailCorporation.address;
- });
- }
- formData.data.sellContactName = res.contactName;
- formData.data.sellContactNumber = res.contactNumber;
- });
- }
- };
- const getCityData = (id, type, isChange) => {
- proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
- if (type === "20") {
- provinceData.value = res;
- if (isChange) {
- formData.data.provinceId = "";
- formData.data.provinceName = "";
- formData.data.cityId = "";
- formData.data.cityName = "";
- }
- } else if (type === "30") {
- cityData.value = res;
- if (isChange) {
- formData.data.cityId = "";
- formData.data.cityName = "";
- }
- } else {
- countryData.value = res;
- }
- });
- };
- getCityData("0");
- const changeCustomer = (val) => {
- formData.data.buyContactName = "";
- formData.data.buyContactNumber = "";
- if (val) {
- proxy.post("/customer/detail", { id: val }).then(
- (res) => {
- if (res.customerUserList && res.customerUserList.length > 0) {
- formData.data.buyContactName = res.customerUserList[0].name;
- if (res.customerUserList[0].contactJson) {
- let contactJson = JSON.parse(res.customerUserList[0].contactJson);
- if (contactJson && contactJson.length > 0) {
- formData.data.buyContactNumber = contactJson[0].contactNo;
- }
- }
- customerUserList.value = res.customerUserList.map((item) => {
- return {
- ...item,
- value: item.name,
- };
- });
- }
- formData.data.countryId = res.countryId;
- formData.data.provinceId = res.provinceId;
- formData.data.cityId = res.cityId;
- formData.data.buyPostalCode = res.zipCode;
- formData.data.buyAddress = res.address;
- getCityData(formData.data.countryId, "20");
- if (formData.data.provinceId) {
- getCityData(formData.data.provinceId, "30");
- }
- },
- (err) => {
- console.log(err);
- formData.data.countryId = "";
- formData.data.provinceId = "";
- formData.data.cityId = "";
- formData.data.buyPostalCode = "";
- formData.data.buyAddress = "";
- }
- );
- } else {
- formData.data.countryId = "";
- formData.data.provinceId = "";
- formData.data.cityId = "";
- formData.data.buyPostalCode = "";
- formData.data.buyAddress = "";
- }
- };
- const createFilter = (queryString) => {
- return (restaurant) => {
- return restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0;
- };
- };
- const querySearchPerson = (queryString, callback) => {
- const results = queryString ? customerUserList.value.filter(createFilter(queryString)) : customerUserList.value;
- callback(results);
- };
- const handlePerson = (item) => {
- formData.data.buyContactNumber = item.phone;
- };
- const pushGoods = (goods) => {
- if (goods && goods.length > 0) {
- let afterFiltering = [];
- if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
- afterFiltering = goods.filter((item) => {
- let data = formData.data.quotationProductList.filter((itemProduct) => itemProduct.productId === item.id);
- if (data && data.length > 0) {
- return false;
- }
- return true;
- });
- } else {
- afterFiltering = goods;
- }
- formData.data.quotationProductList = formData.data.quotationProductList.concat(
- afterFiltering.map((item) => {
- let fileUrl = "";
- if (item.fileList && item.fileList.length > 0) {
- fileUrl = item.fileList[0].fileUrl;
- }
- return {
- fileUrl: fileUrl,
- code: item.code,
- productId: item.id,
- name: item.name,
- productName: item.name,
- productModel: item.spec,
- unit: item.unit,
- quantity: undefined,
- price: undefined,
- amount: "",
- remark: item.remark,
- };
- })
- );
- ElMessage({
- message: "添加成功!",
- type: "success",
- });
- openProduct.value = false;
- } else {
- ElMessage("请选择至少一件商品");
- }
- };
- const onPicture = (path) => {
- window.open(path, "_blank");
- };
- const handleRemove = async (index) => {
- await formData.data.quotationProductList.splice(index, 1);
- totalAmount();
- };
- const calculationAmount = () => {
- nextTick(() => {
- if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
- for (let i = 0; i < formData.data.quotationProductList.length; i++) {
- let money = 0;
- if (formData.data.quotationProductList[i].quantity && formData.data.quotationProductList[i].price) {
- money = parseFloat(Number(formData.data.quotationProductList[i].quantity) * Number(formData.data.quotationProductList[i].price)).toFixed(2);
- }
- formData.data.quotationProductList[i].amount = money;
- }
- }
- nextTick(() => {
- totalAmount();
- });
- });
- };
- const totalAmount = () => {
- let money = 0;
- if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
- for (let i = 0; i < formData.data.quotationProductList.length; i++) {
- if (formData.data.quotationProductList[i].amount) {
- money = parseFloat(Number(money) + Number(formData.data.quotationProductList[i].amount)).toFixed(2);
- }
- }
- }
- if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
- for (let i = 0; i < formData.data.quotationPayList.length; i++) {
- if (formData.data.quotationPayList[i].amount) {
- money = parseFloat(Number(money) + Number(formData.data.quotationPayList[i].amount)).toFixed(2);
- }
- }
- }
- formData.data.amount = money;
- };
- const clickAdd = () => {
- if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
- formData.data.quotationPayList.push({
- payName: "",
- amount: undefined,
- remark: "",
- });
- } else {
- formData.data.quotationPayList = [{ payName: "", amount: undefined, remark: "" }];
- }
- };
- const handleDelete = async (index) => {
- await formData.data.quotationPayList.splice(index, 1);
- totalAmount();
- };
- const querySearch = (queryString, callback) => {
- proxy.post("/quotationPay/page", { payName: queryString }).then((res) => {
- if (res.rows && res.rows.length > 0) {
- res.rows = res.rows.map((item) => {
- return {
- ...item,
- value: item.payName,
- };
- });
- callback(res.rows);
- } else {
- callback([]);
- }
- });
- };
- const handleSubmit = async () => {
- let status = await submit.value.handleSubmit(() => {});
- if (status) {
- if (!(formData.data.quotationProductList && formData.data.quotationProductList.length > 0)) {
- ElMessage("请添加至少一件商品");
- return false;
- }
- return true;
- } else {
- setTimeout(() => {
- const errorDiv = document.getElementsByClassName("is-error");
- errorDiv[0].scrollIntoView();
- }, 0);
- }
- return status;
- };
- // 接收父组件的传值
- const props = defineProps({
- queryData: Object,
- });
- watch(
- props.queryData,
- () => {
- formOption.disabled = judgeStatus();
- if (props.queryData && (route.query.processType == 10 || route.query.processType == 20)) {
- for (var text in props.queryData) {
- formData.data[text] = props.queryData[text];
- }
- if (formData.data.countryId) {
- getCityData(formData.data.countryId, "20");
- }
- if (formData.data.provinceId) {
- getCityData(formData.data.provinceId, "30");
- }
- }
- },
- {
- deep: true,
- }
- );
- onMounted(() => {
- if (props.queryData.priceSheetId) {
- proxy.post("/saleQuotation/detail", { id: props.queryData.priceSheetId }).then((res) => {
- res.countryId = res.buyCountryId;
- res.provinceId = res.buyProvinceId;
- res.cityId = res.buyCityId;
- for (var text in res) {
- formData.data[text] = res[text];
- }
- if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
- for (let i = 0; i < formData.data.quotationProductList.length; i++) {
- proxy.post("/productInfo/detail", { id: formData.data.quotationProductList[i].productId }).then((resProduct) => {
- formData.data.quotationProductList[i].code = resProduct.code;
- });
- }
- let fileIds = formData.data.quotationProductList.map((item) => item.productId);
- proxy.post("/fileInfo/getList", { businessIdList: fileIds }).then((resFile) => {
- for (let i = 0; i < formData.data.quotationProductList.length; i++) {
- if (resFile[formData.data.quotationProductList[i].productId] && resFile[formData.data.quotationProductList[i].productId].length > 0) {
- formData.data.quotationProductList[i].fileUrl = resFile[formData.data.quotationProductList[i].productId][0].fileUrl;
- }
- }
- });
- }
- delete formData.data.id;
- delete formData.data.code;
- getCityData(formData.data.countryId, "20");
- if (formData.data.provinceId) {
- getCityData(formData.data.provinceId, "30");
- }
- if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
- formData.data.quotationProductList = formData.data.quotationProductList.map((item) => {
- delete item.id;
- return {
- ...item,
- };
- });
- }
- if (formData.data.quotationPayList && formData.data.quotationPayList.length > 0) {
- formData.data.quotationPayList = formData.data.quotationPayList.map((item) => {
- delete item.id;
- return {
- ...item,
- };
- });
- }
- });
- }
- });
- const getFormData = () => {
- return formData.data;
- };
- // 向父组件暴露
- defineExpose({
- getFormData,
- handleSubmit,
- });
- const acquireSelectList = () => {
- let data = [];
- if (formData.data.quotationProductList && formData.data.quotationProductList.length > 0) {
- data = formData.data.quotationProductList.map((item) => {
- return {
- id: item.productId,
- name: item.name,
- };
- });
- }
- return data;
- };
- </script>
- <style lang="scss" scoped>
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- .pic {
- object-fit: contain;
- width: 50px;
- height: 50px;
- cursor: pointer;
- vertical-align: middle;
- }
- </style>
|