123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062 |
- <template>
- <div style="width: 100%; padding: 0px 15px">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="formDom">
- <template #btn>
- <div>
- <el-button type="primary" v-if="
- [30].includes(route.query.processType) || !route.query.processType
- " @click="clickCopy(1)">复制合同</el-button>
- </div>
- </template>
- <template #seller>
- <div style="width: 100%">
- <el-form-item prop="buyCorporationId" label="买方信息" class="wid100">
- <el-select v-model="formData.data.buyCorporationId" placeholder="请选择买方公司" style="width: 100%" @change="buyCorporationIdChange" filterable>
- <el-option v-for="item in corporationList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- <el-form-item label="地址" class="wid100">
- <el-row style="width:100%">
- <el-col :span="8">
- <el-form-item label="" prop="buyCountryName" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.buyCountryName" placeholder="请输入国家" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="" prop="buyProvinceName" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.buyProvinceName" placeholder="请输入省/州" />
- </el-form-item>
- </el-col>
- <el-col :span="8">
- <el-form-item label="" prop="buyCityName" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.buyCityName" placeholder="请输入城市" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form-item>
- <el-form-item label="详细地址" prop="buyAddress" class="wid100">
- <el-input v-model="formData.data.buyAddress" type="textarea">
- </el-input>
- </el-form-item>
- <el-form-item label="联系人" class="wid100">
- <el-row style="width:100%">
- <el-col :span="8">
- <el-form-item label="" prop="buyContactName" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.buyContactName" placeholder="请输入联系人" />
- </el-form-item>
- </el-col>
- <el-col :span="16">
- <el-form-item label="" prop="buyContactNumber" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.buyContactNumber" placeholder="请输入联系人电话" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form-item>
- </div>
- </template>
- <template #buyer>
- <div style="width: 100%">
- <el-form-item label="卖方信息" prop="sellCorporationId" class="wid100">
- <el-select v-model="formData.data.sellCorporationId" filterable remote reserve-keyword placeholder="请输入关键字" remote-show-suffix
- :remote-method="remoteMethod" :loading="loadingSearch" @input="remoteMethod" style="width: 100%" @change="changeSupplier" v-if="
- [30].includes(route.query.processType) ||
- !route.query.processType
- ">
- <el-option v-for="item in supplierList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- <el-select v-model="formData.data.sellCorporationName" disabled v-else style="width: 100%">
- </el-select>
- </el-form-item>
- <el-form-item label="地址" class="wid100" required>
- <el-row style="width: 100%">
- <el-col :span="6">
- <el-form-item label="" prop="countryId" class="margin-b-0">
- <el-select v-model="formData.data.countryId" placeholder="国家" filterable @change="(val) => getCityData(val, '20', true)">
- <el-option v-for="item in countryData" :label="item.name" :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="" prop="provinceName" class="margin-b-0">
- <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" class="margin-b-0">
- <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="sellPostalCode" class="margin-b-0">
- <el-input v-model="formData.data.sellPostalCode" placeholder="请输入邮编" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form-item>
- <el-form-item label="详细地址" prop="sellAddress" class="wid100">
- <el-input v-model="formData.data.sellAddress" type="textarea">
- </el-input>
- </el-form-item>
- <el-form-item label="联系人" class="wid100" required>
- <el-row style="width: 100%">
- <el-col :span="8">
- <el-form-item label="" prop="sellContactName" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.sellContactName" clearable placeholder="请输入联系人">
- </el-input>
- </el-form-item>
- </el-col>
- <el-col :span="16">
- <el-form-item label="" prop="sellContactNumber" label-width="0px" class="margin-b-0 wid100">
- <el-input v-model="formData.data.sellContactNumber" placeholder="请输入联系人电话" />
- </el-form-item>
- </el-col>
- </el-row>
- </el-form-item>
- </div>
- </template>
- <template #commodity>
- <div style="width: 100%">
- <el-table :data="formData.data.purchaseProductList" style="width: 100%; ">
- <el-table-column label="商品图片" width="80">
- <template #default="{ row }">
- <div v-if="row.fileUrl">
- <img :src="row.fileUrl" class="pic" @click="onPicture(row.fileUrl)" />
- </div>
- <div v-else></div>
- </template>
- </el-table-column>
- <el-table-column prop="productName" label="商品名称" min-width="130" />
- <el-table-column prop="productCode" label="商品编码" width="130" />
- <el-table-column label="尺寸 cm*cm*cm" width="180">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- {{row.productLength}} * {{row.productWidth}} * {{row.productHeight}}
- </div>
- </template>
- </el-table-column>
- <el-table-column label="数量" prop="subscribeCount" width="100" v-if="route.query.ids" />
- <el-table-column label="已采购数量" prop="purchaseCount" width="100" v-if="route.query.ids" />
- <el-table-column label="采购数量" width="150">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'purchaseProductList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true"
- class="margin-b-0 wid100">
- <el-input-number onmousewheel="return false;" v-model="row.quantity" placeholder="请输入" style="width: 100%" :precision="0"
- :controls="false" :min="0" @change="calculationAmount('quantity')" />
- </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="'purchaseProductList.' + $index + '.price'" :rules="rules.price" :inline-message="true"
- class="margin-b-0 wid100">
- <div style="display:flex;">
- <el-input-number onmousewheel="return false;" v-model="row.price" placeholder="请输入" style="width: 100%" :precision="2"
- :controls="false" :min="0" @change="calculationAmount()" />
- <el-popover placement="top-start" :width="400" trigger="hover" @show="showEcharts(row,$index)">
- <template #default>
- <div>
- <div>
- <img src="@/assets/images/money1.png" alt="" class="img" />
- <span style="font-size:14px;font-weight:700;color:#000"> 该供应商近期采购单价:</span>
- <div style="padding:5px 0px 0px 20px">
- <div v-for="(item,index) in row.supplyPurchaseProductPriceList" :key="index">
- <span>{{item.createTime.slice(0,10)}} </span>
- <span style="margin-left:40px">CNY {{moneyFormat(item.price,2)}} </span>
- </div>
- </div>
- </div>
- <div style="margin-top:15px">
- <img src="@/assets/images/money2.png" alt="" class="img" />
- <span style="font-size:14px;font-weight:700;color:#000"> 供货推荐:</span>
- <div style="padding:5px 0px 0px 20px">
- <div v-for="(item,index) in row.topPriceList " :key="index">
- <span>{{item.supplierName}} </span>
- <span style="margin-left:40px"> CNY {{moneyFormat(item.price,2)}} </span>
- </div>
- </div>
- </div>
- <div style="margin-top:15px">
- <img src="@/assets/images/money3.png" alt="" class="img" />
- <span style="font-size:14px;font-weight:700;color:#000"> 近期采购单价:</span>
- <div style="padding:5px 0px 0px 20px">
- <div v-for="(item,index) in row.purchaseProductPriceList " :key="index">
- <span>{{item.createTime.slice(0,10)}} </span>
- <span style="margin-left:40px"> CNY {{moneyFormat(item.price,2)}} </span>
- </div>
- </div>
- </div>
- <div :ref="row.productId+$index" :id="row.productId+$index" style="height:180px">
- </div>
- </div>
- </template>
- <template #reference>
- <div style="margin-left:10px;cursor:pointer;position:relative;top:4px">
- <el-icon :size="20" color="#85c1a6">
- <WarningFilled />
- </el-icon>
- </div>
- </template>
- </el-popover>
- </div>
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column prop="amount" label="小计" width="120" />
- <el-table-column label="操作" width="120" align="center" fixed="right" v-if="!judgeStatus()">
- <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()" plain style="margin-bottom: 16px" v-if="!judgeStatus()">添加行</el-button>
- <el-table :data="formData.data.purchaseProjectList" style="width: 100%;">
- <el-table-column label="收费项目" width="220">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'purchaseProjectList.' + $index + '.payName'" :rules="rules.payName" :inline-message="true"
- class="margin-b-0 wid100">
- <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="备注">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'purchaseProjectList.' + $index + '.remark'" class="margin-b-0 wid100">
- <el-input v-model="row.remark" placeholder="请输入备注" />
- </el-form-item>
- </div>
- </template>
- </el-table-column>
- <el-table-column :label="'金额'" width="130">
- <template #default="{ row, $index }">
- <div style="width: 100%">
- <el-form-item :prop="'purchaseProjectList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true"
- class="margin-b-0 wid100">
- <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="操作" width="60" align="center" fixed="right" v-if="!judgeStatus()">
- <template #default="{ $index }">
- <el-button type="primary" link @click="handleDelete($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <template #contractClause>
- <div style="width: 100%">
- <el-row style=" width: 100%">
- <el-col :span="8">
- <el-form-item label="合同模板" prop="contractTemplateId" class="wid100">
- <el-select v-model="formData.data.contractTemplateId" style="width: 100%" @change="changeContractTemplate">
- <el-option v-for="item in templateList" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- </el-row>
- <div style=" width: 100%">
- <el-form-item label="条款内容" prop="remark" class="margin-b-0 wid100">
- <Editor style="width: 100%" :value="formData.data.remark" @updateValue="updateContent" :readOnly="judgeStatus()" ref="remarkEditor" />
- </el-form-item>
- </div>
- </div>
- </template>
- </byForm>
- </div>
- </template>
- <script setup>
- import byForm from "@/components/byForm/index";
- import selectCity from "@/components/selectCity/index.vue";
- import { useRoute } from "vue-router";
- import Editor from "@/components/Editor/index.vue";
- import * as echarts from "echarts";
- import $bus from "@/bus/index.js";
- const route = useRoute();
- const { proxy } = getCurrentInstance();
- // 接收父组件的传值
- const props = defineProps({
- queryData: Object,
- });
- const invoiceType = computed(
- () => proxy.useUserStore().allDict["invoice_type"]
- );
- const fundsPaymentMethod = computed(
- () => proxy.useUserStore().allDict["funds_payment_method"]
- );
- const shippingMethod = computed(
- () => proxy.useUserStore().allDict["shipping_method"]
- );
- // const companyId = computed(() => proxy.useUserStore().user.companyId);
- const deliveryType = ref([
- {
- label: "买方地址",
- value: "1",
- },
- {
- label: "工厂交付",
- value: "2",
- },
- {
- label: "其他",
- value: "3",
- },
- ]);
- const supplierList = ref([]);
- const corporationList = ref([]);
- const templateList = ref([]);
- const customerUserList = ref([]);
- const countryData = ref([]);
- const provinceData = ref([]);
- const cityData = ref([]);
- const openProductCompany = ref(false);
- const copyType = ref(1);
- const copyContract = ref(false);
- const formData = reactive({
- data: {
- remark: "",
- },
- });
- const uploadData = ref({});
- const formDom = ref(null);
- const judgeStatus = () => {
- if (route.query.processType == 20 || route.query.processType == 10) {
- return true;
- }
- 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,
- disabled: false,
- });
- const formConfig = computed(() => {
- return [
- // {
- // type: "slot",
- // slotName: "btn",
- // label: "",
- // itemWidth: 50,
- // },
- {
- type: "title",
- title: "贸易信息",
- haveLine: false,
- },
- {
- type: "slot",
- slotName: "seller",
- label: "",
- itemWidth: 50,
- },
- {
- type: "slot",
- slotName: "buyer",
- label: "",
- itemWidth: 50,
- },
- {
- type: "title",
- title: "付款信息",
- haveLine: true,
- },
- {
- type: "select",
- prop: "paymentMethod",
- label: "付款方式",
- data: fundsPaymentMethod.value,
- itemWidth: 25,
- },
- {
- type: "select",
- prop: "invoiceType",
- label: "发票类型",
- data: invoiceType.value,
- itemWidth: 25,
- },
- {
- type: "title",
- title: "交付信息",
- haveLine: true,
- },
- // {
- // type: "radio",
- // prop: "ss",
- // label: "交货类型",
- // border: true,
- // data: deliveryType.value,
- // itemWidth: 50,
- // },
- {
- type: "select",
- prop: "deliveryType",
- label: "交货类型",
- border: true,
- data: deliveryType.value,
- itemWidth: 50,
- },
- {
- type: "input",
- prop: "address",
- itemType: "textarea",
- label: "详细地址",
- itemWidth: 50,
- },
- {
- type: "date",
- itemType: "date",
- prop: "deliveryTime",
- label: "交付日期",
- itemWidth: 50,
- },
- {
- type: "number",
- prop: "warranty",
- label: "质保期 (天)",
- precision: 0,
- min: 0,
- controls: false,
- itemWidth: 50,
- },
- // {
- // type: "select",
- // prop: "transportMethod",
- // label: "运输方式",
- // data: shippingMethod.value,
- // itemWidth: 50,
- // },
- // {
- // type: "slot",
- // slotName: "delivery",
- // label: "",
- // },
- {
- type: "title",
- title: "采购明细",
- haveLine: true,
- },
- {
- type: "slot",
- slotName: "commodity",
- label: "",
- },
- {
- type: "title",
- title: "其他收费项目",
- haveLine: true,
- },
- {
- type: "slot",
- slotName: "otherCharge",
- label: "",
- },
- {
- type: "title",
- title: "合同总金额",
- haveLine: true,
- },
- {
- type: "input",
- prop: "amount",
- label: "合同总金额",
- itemWidth: 25,
- disabled: true,
- },
- {
- type: "title",
- title: "合同条款",
- haveLine: true,
- },
- {
- type: "slot",
- slotName: "contractClause",
- label: "",
- },
- ];
- });
- const rules = ref({
- buyCorporationId: [
- { required: true, message: "请选择买方公司", trigger: "change" },
- ],
- buyAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
- buyContactName: [
- { required: true, message: "请输入联系人", trigger: ["change", "blur"] },
- ],
- buyContactNumber: [
- { required: true, message: "请输入联系电话", trigger: "blur" },
- ],
- sellCorporationId: [
- { required: true, message: "请选择卖方公司", trigger: "change" },
- ],
- countryId: [{ required: true, message: "请选择国家", trigger: "change" }],
- sellAddress: [{ required: true, message: "请输入详细地址", trigger: "blur" }],
- sellContactName: [
- { required: true, message: "请输入联系人", trigger: ["change", "blur"] },
- ],
- sellContactNumber: [
- { required: true, message: "请输入联系电话", trigger: "blur" },
- ],
- quantity: [{ required: true, message: "请输入数量", trigger: "blur" }],
- price: [{ required: true, message: "请输入单价", trigger: "blur" }],
- invoiceType: [
- { required: true, message: "请选择发票类型", trigger: "change" },
- ],
- paymentMethod: [
- { required: true, message: "请选择付款方式", trigger: "change" },
- ],
- deliveryType: [
- { required: true, message: "请选择交货类型", trigger: "change" },
- ],
- address: [{ required: true, message: "请输入详细地址", trigger: ["blur"] }],
- deliveryTime: [
- { required: true, message: "请选择交付日期", trigger: "change" },
- ],
- warranty: [{ required: true, message: "请选择质保期 (天)", trigger: "blur" }],
- payName: [{ required: true, message: "请输入收费项目", trigger: ["blur"] }],
- amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
- remark: [{ required: true, message: "请输入条款内容", trigger: "blur" }],
- });
- const getDict = () => {
- proxy
- .post("/supplierInfo/page", {
- pageNum: 1,
- pageSize: 50,
- })
- .then((res) => {
- supplierList.value = res.rows.map((x) => ({
- ...x,
- label: x.name,
- value: x.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("/contractTemplate/page", { pageNum: 1, pageSize: 999 })
- .then((res) => {
- templateList.value = res.rows.map((item) => {
- return {
- ...item,
- label: item.templateName,
- value: item.id,
- };
- });
- });
- };
- 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;
- }
- });
- };
- getDict();
- getCityData("0");
- const buyCorporationIdChange = (val) => {
- if (val) {
- proxy.post("/corporation/detail", { id: val }).then((res) => {
- formData.data.buyCountryName = res.countryName;
- formData.data.buyProvinceName = res.provinceName;
- formData.data.buyCityName = res.cityName;
- formData.data.buyAddress = res.address;
- });
- }
- };
- const changeSupplier = (val) => {
- changeProductPrice();
- formData.data.countryId = "";
- formData.data.provinceId = "";
- formData.data.cityId = "";
- formData.data.sellAddress = "";
- formData.data.sellContactName = "";
- formData.data.sellContactNumber = "";
- if (val) {
- let data = supplierList.value.filter((item) => item.id === val);
- if (data && data.length > 0) {
- formData.data.countryId = data[0].countryId;
- formData.data.provinceId = data[0].provinceId;
- formData.data.cityId = data[0].cityId;
- formData.data.sellAddress = data[0].areaDetail;
- formData.data.sellContactName = data[0].contactPerson;
- formData.data.sellContactNumber = data[0].contactNumber;
- if (formData.data.countryId) {
- getCityData(formData.data.countryId, "20");
- }
- if (formData.data.provinceId) {
- getCityData(formData.data.provinceId, "30");
- }
- }
- }
- };
- const changeProductPrice = () => {
- let productIds = formData.data.purchaseProductList.map((x) => x.productId);
- if (productIds && productIds.length > 0) {
- proxy
- .post("/ehsdPurchase/getProductPriceInfo", {
- productIds: productIds,
- sellCorporationId: formData.data.sellCorporationId
- ? formData.data.sellCorporationId
- : "",
- })
- .then((resOne) => {
- for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
- const iele = formData.data.purchaseProductList[i];
- for (const key in resOne) {
- if (iele.productId == key) {
- iele.purchaseProductPriceList = resOne[key].purchaseProductList
- .map((x) => ({
- createTime: x.createTime || "",
- price: x.price,
- }))
- .filter((y, index) => index < 3);
- iele.purchaseProductPriceListOne = resOne[
- key
- ].purchaseProductList.map((x) => ({
- createTime: x.createTime || "",
- price: x.price,
- }));
- iele.topPriceList = resOne[key].topPriceList
- .map((x) => ({
- supplierName: x.supplierName,
- price: x.price,
- }))
- .filter((y, index) => index < 3);
- iele.supplyPurchaseProductPriceList = resOne[
- key
- ].supplyPurchaseProductList
- .map((x) => ({
- createTime: x.createTime || "",
- price: x.price,
- }))
- .filter((y, index) => index < 3);
- }
- }
- }
- });
- }
- };
- const onPicture = (path) => {
- window.open(path, "_blank");
- };
- const handleRemove = (index) => {
- formData.data.purchaseProductList.splice(index, 1);
- totalAmount();
- };
- const calculationAmount = (att = "") => {
- nextTick(() => {
- if (
- formData.data.purchaseProductList &&
- formData.data.purchaseProductList.length > 0
- ) {
- for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
- let money = 0;
- money = parseFloat(
- Number(formData.data.purchaseProductList[i].quantity) *
- Number(formData.data.purchaseProductList[i].price)
- ).toFixed(2);
- formData.data.purchaseProductList[i].amount = money;
- }
- }
- nextTick(() => {
- totalAmount();
- });
- });
- };
- const totalAmount = () => {
- let money = 0;
- if (
- formData.data.purchaseProductList &&
- formData.data.purchaseProductList.length > 0
- ) {
- for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
- if (formData.data.purchaseProductList[i].amount) {
- money = parseFloat(
- Number(money) + Number(formData.data.purchaseProductList[i].amount)
- ).toFixed(2);
- }
- }
- }
- if (
- formData.data.purchaseProjectList &&
- formData.data.purchaseProjectList.length > 0
- ) {
- for (let i = 0; i < formData.data.purchaseProjectList.length; i++) {
- if (formData.data.purchaseProjectList[i].amount) {
- money = parseFloat(
- Number(money) + Number(formData.data.purchaseProjectList[i].amount)
- ).toFixed(2);
- }
- }
- }
- formData.data.amount = money;
- };
- const clickAdd = () => {
- if (
- formData.data.purchaseProjectList &&
- formData.data.purchaseProjectList.length > 0
- ) {
- formData.data.purchaseProjectList.push({
- payName: "",
- amount: null,
- remark: "",
- });
- } else {
- formData.data.purchaseProjectList = [
- { payName: "", amount: null, remark: "" },
- ];
- }
- };
- const handleDelete = (index) => {
- formData.data.purchaseProjectList.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 loadingSearch = ref(false);
- const remoteMethod = (keyword) => {
- if (keyword && typeof keyword === "string") {
- loadingSearch.value = true;
- proxy.post("/supplierInfo/page", { keyword }).then((res) => {
- supplierList.value = res.rows.map((x) => ({
- ...x,
- label: x.name,
- value: x.id,
- }));
- loadingSearch.value = false;
- });
- }
- return;
- };
- const handleSubmit = async () => {
- let flag = await formDom.value.handleSubmit(() => {});
- if (flag) {
- return true;
- } else {
- setTimeout(() => {
- const errorDiv = document.getElementsByClassName("is-error");
- errorDiv[0].scrollIntoView();
- }, 0);
- }
- return flag;
- };
- const updateContent = (val) => {
- formData.data.remark = val;
- };
- const remarkEditor = ref(null);
- const changeContractTemplate = (val) => {
- if (val) {
- proxy.post("/contractTemplate/detail", { id: val }).then((res) => {
- remarkEditor.value.changeHtml(res.templateContent);
- });
- }
- };
- const getFormData = () => {
- return proxy.deepClone(formData.data);
- };
- // 向父组件暴露
- defineExpose({
- getFormData,
- handleSubmit,
- });
- const getAllData = (businessId) => {
- if (businessId) {
- proxy.post("/ehsdPurchase/detail", { id: businessId }).then((res) => {
- res.countryId = res.sellCountryId;
- res.provinceId = res.sellProvinceId;
- res.cityId = res.sellCityId;
- if (res.grossProfitInfoList && res.grossProfitInfoList.length > 0) {
- $bus.emit("getGrossData", res.grossProfitInfoList);
- }
- for (let key in res) {
- if (!["ehsdPurchaseProductList", "purchaseArrivalList"].includes(key)) {
- formData.data[key] = res[key];
- }
- }
- remarkEditor.value.changeHtml(formData.data.remark);
- if (
- formData.data.purchaseProductList &&
- formData.data.purchaseProductList.length > 0
- ) {
- let ids = formData.data.purchaseProductList.map((x) => x.productId);
- proxy
- .post("/fileInfo/getList", {
- businessIdList: ids,
- })
- .then((fileObj) => {
- for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
- const e = formData.data.purchaseProductList[i];
- for (const key in fileObj) {
- if (e.productId === key) {
- e.fileList = fileObj[key] || [];
- if (e.fileList && e.fileList.length > 0) {
- e.fileUrl = e.fileList[0].fileUrl;
- }
- }
- }
- }
- });
- changeProductPrice();
- }
- if (formData.data.countryId) {
- getCityData(formData.data.countryId, "20");
- }
- if (formData.data.provinceId) {
- getCityData(formData.data.provinceId, "30");
- }
- });
- }
- };
- const getProductList = (ids) => {
- if (ids && ids.length > 0) {
- proxy.post("/subscribeDetail/detail", { ids }).then((res) => {
- if (res && res.length > 0) {
- formData.data.purchaseProductList = res.map((item) => {
- let dataResourceId =
- item.dataType == 0 ? item.id : item.contractDetailId;
- return {
- productId: item.productId,
- contractId: item.contractId,
- productName: item.productName,
- productCode: item.productCustomCode,
- productLength: item.productLength,
- productWidth: item.productWidth,
- productHeight: item.productHeight,
- subscribeCount: item.count || 0,
- purchaseCount: item.purchaseCount || 0,
- quantity: null,
- price: "",
- amount: "",
- remark: "",
- fileUrl: "",
- dataResource: item.dataType,
- dataResourceId: dataResourceId,
- subscribeDetailId: item.id,
- };
- });
- formData.data.dataResource =
- formData.data.purchaseProductList[0].dataResource;
- formData.data.dataResourceId = res[0].contractId;
- let productIdList = res.map((x) => x.productId);
- proxy
- .post("/fileInfo/getList", {
- businessIdList: productIdList,
- })
- .then((fileObj) => {
- for (let i = 0; i < formData.data.purchaseProductList.length; i++) {
- const e = formData.data.purchaseProductList[i];
- for (const key in fileObj) {
- if (e.productId === key) {
- if (fileObj[key] && fileObj[key].length > 0) {
- e.fileUrl = fileObj[key][0].fileUrl;
- }
- }
- }
- }
- });
- changeProductPrice();
- }
- });
- }
- };
- onMounted(() => {
- formOption.disabled = judgeStatus();
- if (route.query && route.query.ids) {
- let ids = route.query.ids.split(",");
- getProductList(ids);
- }
- if (route.query.businessId && route.query.processType) {
- getAllData(route.query.businessId);
- }
- });
- // watch(
- // () => props.queryData,
- // (val) => {
- // nextTick(() => {
- // formOption.disabled = judgeStatus();
- // });
- // if (val.businessId && val.processType) {
- // getAllData(val.businessId);
- // }
- // },
- // {
- // deep: true,
- // immediate: true,
- // }
- // );
- const optionTwo = reactive({
- data: {
- tooltip: {
- trigger: "axis",
- },
- // legend: {
- // data: ["价格"],
- // },
- grid: {
- left: "3%",
- right: "4%",
- top: "10%",
- bottom: "3%",
- containLabel: true,
- },
- // toolbox: {
- // feature: {
- // saveAsImage: {},
- // },
- // },
- xAxis: {
- type: "category",
- boundaryGap: false,
- data: [],
- },
- yAxis: {
- type: "value",
- },
- series: [
- {
- name: "价格",
- type: "line",
- data: [],
- },
- ],
- },
- });
- const showEcharts = (row, index) => {
- let myChart = null;
- myChart = echarts.init(document.getElementById(row.productId + index));
- window.addEventListener("resize", () => {
- myChart.resize();
- });
- if (
- row.purchaseProductPriceListOne &&
- row.purchaseProductPriceListOne.length > 0
- ) {
- optionTwo.data.xAxis.data = row.purchaseProductPriceListOne.map((item) => {
- return item.createTime.slice(0, 10);
- });
- optionTwo.data.series[0].data = row.purchaseProductPriceListOne.map(
- (item) => {
- return item.price;
- }
- );
- } else {
- optionTwo.data.xAxis.data = [];
- optionTwo.data.series[0].data = [];
- }
- myChart.setOption(optionTwo.data);
- myChart.resize();
- };
- const clickCopy = (type) => {
- copyType.value = type;
- copyContract.value = true;
- };
- </script>
- <style lang="scss" scoped>
- .img {
- object-fit: contain;
- width: 16px;
- height: 16px;
- vertical-align: middle;
- }
- .pic {
- object-fit: contain;
- width: 50px;
- height: 50px;
- cursor: pointer;
- vertical-align: middle;
- }
- .ql-editor {
- padding: 0px;
- }
- </style>
|