| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963 |
- <template>
- <div>
- <el-form ref="form" :model="form" :rules="rules" label-width="120px">
- <headerTitle title="订单信息"></headerTitle>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="项目名称"
- prop="projectName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.projectName"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="采购计划单名称" prop="planCode">
- <el-input
- @click.native="handPurchasePlan"
- v-model="form.purchasePlanName"
- placeholder="请选择"
- ></el-input>
- </el-form-item>
- <el-form-item
- label="订单类型"
- prop="sourceType"
- style="margin-bottom: 22px"
- >
- <DictSelection
- dictName="需求来源类型"
- clearable
- v-model="form.sourceType"
- :disabled="isFlag"
- >
- <!-- v-if="form.sourceType != 1" -->
- </DictSelection>
- </el-form-item>
- <el-form-item
- label="需求部门"
- prop="requireDeptId"
- style="margin-bottom: 22px"
- >
- <ele-tree-select
- clearable
- :data="groupTreeData"
- v-model="form.requireDeptId"
- valueKey="id"
- labelKey="name"
- placeholder="请选择"
- @change="change_principalDep"
- default-expand-all
- />
- </el-form-item>
- <!-- <el-form-item
- label="计价方式"
- prop="pricingWay"
- style="margin-bottom: 22px"
- >
- <el-radio-group
- v-model="form.pricingWay"
- @change="changePricingWay"
- :disabled="!!form.contractId"
- >
- <el-radio v-for="item in pricingWayList" :label="item.id">{{
- item.name
- }}</el-radio>
- </el-radio-group>
- </el-form-item> -->
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="选择合同"
- prop="contractName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.contractName"
- @click.native="handleContractBtn"
- @clear="clearContrcat"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item label="结算方式" prop="settlementMode">
- <DictSelection
- dictName="结算方式"
- clearable
- @itemChange="settlementModeChange"
- v-model="form.settlementMode"
- >
- </DictSelection>
- </el-form-item>
- <el-form-item label="需求人" prop="requireUserId">
- <personSelect
- ref="directorRef"
- v-model="form.requireUserId"
- @selfChange="salesmanChange"
- :init="false"
- />
- </el-form-item>
- <el-form-item prop="orderFiles" label="附件">
- <fileMain v-model="form.orderFiles"></fileMain>
-
- </el-form-item>
- </el-col>
- </el-row>
- <headerTitle title="基本信息"></headerTitle>
- <el-row>
- <el-col :span="12">
- <el-form-item
- label="采购方名称"
- prop="partaName"
- style="margin-bottom: 22px"
- >
- <el-input clearable v-model="form.partaName" placeholder="请输入" />
- </el-form-item>
- <el-form-item
- label="采购方统一社会信用代码"
- prop="partaUnifiedSocialCreditCode"
- label-width="180px"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaUnifiedSocialCreditCode"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="采购方联系人"
- prop="partaLinkName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaLinkName"
- @click.native="handHead"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="采购方电话"
- prop="partaTel"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- :maxlength="20"
- v-model="form.partaTel"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="采购方传真"
- prop="partaFax"
- style="margin-bottom: 22px"
- >
- <el-input clearable v-model="form.partaFax" placeholder="请输入" />
- </el-form-item>
- <el-form-item
- label=" 采购方Email"
- prop="partaEmail"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="采购方地址"
- prop="partaAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partaAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="供应商名称"
- prop="partbName"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbName"
- @click.native="handParent"
- :disabled="!!form.contractId"
- placeholder="请选择"
- />
- </el-form-item>
- <el-form-item
- label="供应商统一社会信用代码"
- prop="partbUnifiedSocialCreditCode"
- label-width="170px"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbUnifiedSocialCreditCode"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="供应商联系人"
- prop="partbLinkName"
- style="margin-bottom: 22px"
- >
- <el-select
- v-model="form.partbLinkName"
- placeholder="请选择"
- @change="onchangeLink"
- @focus="selectFocus"
- >
- <el-option
- v-for="item in linkNameOptions"
- :key="item.id"
- :label="item.linkName"
- :value="item.id"
- >
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item prop="partbTel" label="供应商联系电话">
- <el-input clearable v-model="form.partbTel" placeholder="请输入" />
- </el-form-item>
- <el-form-item prop="partbFax" label="供应商传真">
- <el-input clearable v-model="form.partbFax" placeholder="请输入" />
- </el-form-item>
- <el-form-item
- label="供应商Email"
- prop="partbEmail"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbEmail"
- placeholder="请输入"
- />
- </el-form-item>
- <el-form-item
- label="供应商地址"
- prop="partbAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.partbAddress"
- placeholder="请输入"
- />
- </el-form-item>
- </el-col>
- </el-row>
- <el-tabs v-model="activeName" style="margin-top: 15px" type="border-card">
- <el-tab-pane label="物品清单" name="1">
- <inventoryTable
- ref="inventoryTable"
- @orderDiscountAmount="orderDiscountAmount"
- :pricingWay="form.pricingWay"
- :is-show-supplier-mark="true"
- :isContractId="!!form.contractId"
- >
- </inventoryTable>
- </el-tab-pane>
- <el-tab-pane
- label="带料清单"
- name="2"
- v-if="orderSourceType.includes(form.sourceType)"
- >
- <inventoryTable
- ref="rawDetailListRef"
- :pricingWay="form.pricingWay"
- :is-show-supplier-mark="true"
- :isContractId="!!form.contractId"
- :detailType="1"
- >
- </inventoryTable>
- </el-tab-pane>
- <el-tab-pane
- label="产出清单"
- name="2"
- v-if="orderSourceType.includes(form.sourceType)"
- >
- <inventoryTable
- ref="outputDetailListRef"
- :pricingWay="form.pricingWay"
- :is-show-supplier-mark="true"
- :isContractId="!!form.contractId"
- :detailType="2"
- >
- </inventoryTable>
- </el-tab-pane>
- </el-tabs>
- <el-row style="margin-top: 20px">
- <el-col :span="12">
- <el-form-item
- label="优惠总金额"
- prop="payAmount"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- v-model="form.payAmount"
- :disabled="!!form.contractId || !allcountAmount"
- type="number"
- @blur="discountInput"
- placeholder="请输入"
- >
- <template slot="append">元</template>
- </el-input>
- </el-form-item>
- <el-form-item label="备注" prop="remark" style="margin-bottom: 22px">
- <el-input
- clearable
- type="textarea"
- v-model="form.remark"
- placeholder="请输入"
- />
- </el-form-item>
- <!-- <el-form-item
- label="收货地址"
- prop="receiveAddress"
- style="margin-bottom: 22px"
- >
- <el-input
- clearable
- type="textarea"
- v-model="form.receiveAddress"
- placeholder="请输入"
- />
- </el-form-item> -->
- </el-col>
- <el-col :span="12">
- <el-form-item
- label="总金额"
- prop="totalAmount"
- style="margin-bottom: 22px"
- >
- {{ allcountAmount || 0 }}元
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <parentList ref="parentRef" @changeParent="changeParent"></parentList>
- <head-list ref="headRef" @changeParent="changePersonel"></head-list>
- <contractListDialog
- ref="selectContractRef"
- @changeParent="changeContract"
- :type="2"
- ></contractListDialog>
- <inquiryManageList
- ref="inquiryManageRef"
- @changeInquiryManageList="changeInquiryManageList"
- ></inquiryManageList>
- </div>
- </template>
- <script>
- import { emailReg, numberReg } from 'ele-admin';
- import inventoryTable from './inventoryTable.vue';
- import fileUpload from '@/components/upload/fileUpload';
- import dictMixins from '@/mixins/dictMixins';
- import personSelect from '@/components/CommomSelect/person-select.vue';
- import parentList from '@/views/bpm/handleTask/components/quotation/parentList.vue';
- import { getDetail } from '@/api/bpm/components/contractManage/contractBook';
- import headList from '@/components/headList';
- import { getpurchaseorderDetail } from '@/api/bpm/components/purchasingManage/purchaseOrder';
- import { getcontactlink } from '@/api/bpm/components/saleManage/businessOpportunity.js';
- import contractListDialog from '@/views/bpm/handleTask/components/saleOrder/contractListDialog.vue';
- import { listOrganizations } from '@/api/system/organization';
- import { copyObj } from '@/utils/util';
- import { getpurchaseinquiry } from '@/api/bpm/components/purchasingManage/inquiryManage';
- import InquiryManageList from '@/views/bpm/handleTask/components/inquiryManage/inquiryManage-list.vue';
- import {
- getplanDetail,
- getPurchasePlanByContractIdAPI
- } from '@/api/bpm/components/purchasingManage/purchasePlanManage';
- import fileMain from '@/components/addDoc/index.vue';
- import { orderSourceType, outsourceSceneList } from '@/enum/dict';
- export default {
- mixins: [dictMixins],
- components: {
- fileMain,
- InquiryManageList,
- fileUpload,
- contractListDialog,
- inventoryTable,
- parentList,
- personSelect,
- headList
- },
- props: {
- businessId: {
- default: ''
- }
- },
- data() {
- let formDef = {
- id: '',
- contractId: '',
- orderFiles: [],
- contractName: '',
- deliveryDate: '',
- payAmount: '',
- projectName: '',
- projectId: '',
- receiveAddress: '',
- sourceType: '',
- sourceTypeName: '',
- pricingWay: 1,
- remark: '',
- saleType: '',
- saleTypeName: '',
- totalAmount: '',
- settlementMode: '',
- settlementModeName: '',
- partaUnifiedSocialCreditCode: '',
- partbUnifiedSocialCreditCode: '',
- partaAddress: '',
- partaEmail: '',
- partaFax: '',
- partaId: '',
- partaLinkId: '',
- partaLinkName: '',
- partaName: '',
- partaTel: '',
- partbAddress: '',
- partbEmail: '',
- partbFax: '',
- partbId: '',
- partbLinkId: '',
- partbLinkName: '',
- partbName: '',
- partbTel: '',
- purchasePlanId: '',
- purchasePlanNo: '',
- purchasePlanName: ''
- };
- return {
- orderSourceType,
- outsourceSceneList,
- clearing: false, //是否清除合同
- isFlag: false, //需求类型是否可以修改
- payWayOptions: [],
- delDetailIds: [],
- linkNameOptions: [],
- visible: false,
- title: '',
- row: {},
- activeName: 'base',
- pricingWayList: [
- { id: 1, name: '按数量计价' },
- { id: 2, name: '按重量计价' }
- ],
- formDef,
- form: copyObj(formDef),
- tableBankData: [],
- tableLinkData: [],
- // 组织机构树形结构数据
- groupTreeData: [],
- groupData: [],
- rules: {
- deliveryDate: [
- { required: true, message: '请选择交货日期', trigger: 'change' }
- ],
- // purchaseType: [
- // {required: true, message: '请选择采购订单类型', trigger: 'change'}
- // ],
- settlementMode: [
- { required: true, message: '请选择结算方式', trigger: 'change' }
- ],
- partaName: [
- { required: true, message: '请选择供应商名称', trigger: 'change' }
- ],
- partaLinkName: [
- { required: true, message: '请选择供应商联系人', trigger: 'change' }
- ],
- acceptUnpack: [
- { required: true, message: '请选择是否接受', trigger: 'change' }
- ],
- sourceType: [
- { required: true, message: '请选择需求类型', trigger: 'change' }
- ],
- partaTel: [
- {
- required: true,
- pattern: numberReg,
- message: '请输入供应商联系电话',
- trigger: 'blur'
- }
- ],
- partbName: [
- { required: true, message: '请输入供采购方名称', trigger: 'change' }
- ],
- partbLinkName: [
- {
- required: true,
- message: '请输入供采购方联系人',
- trigger: 'change'
- }
- ],
- partbTel: [
- {
- required: true,
- pattern: numberReg,
- message: '请输入供采购方联系电话',
- trigger: 'blur'
- }
- ],
- partaEmail: [
- { pattern: emailReg, message: '邮箱格式不正确', trigger: 'blur' }
- ]
- },
- // 提交状态
- loading: false,
- // 是否是修改
- isUpdate: false
- };
- },
- computed: {
- allcountAmount() {
- return this.$store.state.order.allcountAmount;
- }
- },
- created() {
- this.getpurchaseorderDetail(this.businessId);
- this.getGroupAll();
- },
- methods: {
- // 选择负责人部门
- change_principalDep(id) {
- const info = this.groupData.find((e) => e.id == id);
- this.form.requireDeptName = info.name;
- // this.form.requireUserId = '';
- // this.form.requireUserName = '';
- this.$set(this.form, 'requireUserId', '');
- this.$set(this.form, 'requireUserName', '');
- // 根据部门获取人员
- this.getrequireUser(id);
- },
- //切换计价方式重新算费用
- changePricingWay() {
- this.$refs.inventoryTable.getTotalPrice();
- },
- //选择采购计划
- handPurchasePlan() {
- this.$refs.inquiryManageRef.open(this.form.planCode);
- },
- //选择采购计划回调
- async changeInquiryManageList(data) {
- this.form.purchasePlanId = data.id;
- this.form.purchasePlanNo = data.planCode;
- this.form.purchasePlanName = data.planName;
- let info = await getplanDetail(data.id);
- let cusInfo = {};
- this.$set(this.form, 'purchasePlanName', data.planName);
- this.$set(this.form, 'purchasePlanId', data.id);
- this.$set(this.form, 'purchasePlanNo', data.planCode);
- let form = {
- contractVO: {
- ...this.form
- },
- productList: info.detailList || []
- };
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(form.productList);
- await this.getLinkInfo(cusInfo.base.id);
- },
- // //选择需求来源类型
- // chaengSource(data) {
- // this.form.sourceType = data?.dictValue;
- // },
- getrequireUser(groupId) {
- if (groupId) {
- this.$refs.directorRef.getList({ groupId });
- }
- },
- salesmanChange(val, info) {
- this.$set(this.form, 'requireUserId', val);
- this.$set(this.form, 'requireUserName', info.name);
- // this.form.requireUserName = info.name;
- },
- // 获取公司数据
- getGroupAll() {
- listOrganizations().then((list) => {
- this.groupData = list;
- this.groupTreeData = this.$util.toTreeData({
- data: list,
- idField: 'id',
- parentIdField: 'parentId'
- });
- });
- },
- discountInput() {
- this.$refs.inventoryTable.discountInputByOrder(this.form.payAmount);
- },
- //产品清单修改单价或者数量重置优惠金额
- orderDiscountAmount(val = 0) {
- this.form.payAmount = val;
- },
- //选择供应商
- changeSupplier(obj) {
- this.form = Object.assign({}, this.form, {
- partbId: obj.id,
- partbName: obj.name,
- partbAddress: obj.addressName + obj.address,
- partbLinkId: '',
- partbLinkName: '',
- partbEmail: '',
- partbTel: ''
- });
- this.getLinkInfo(obj.id);
- },
- //选择合同获取合同的详情
- async getDetailData(id) {
- this.loading = true;
- const data = await getDetail(id);
- this.loading = false;
- if (data) {
- this.$nextTick(() => {
- let { contractVO } = data;
- // this.form=contractVOform.receiveAddress
- let {
- partaAddress,
- partaEmail,
- partaFax,
- partaId,
- partaLinkId,
- partaLinkName,
- partaName,
- partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- discountTotalPrice,
- partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- settlementMode,
- settlementModeName,
- pricingWay
- } = contractVO;
- this.form = Object.assign({}, this.form, {
- partaAddress,
- partaEmail,
- partaFax,
- partaId,
- partaLinkId,
- partaLinkName,
- partaName,
- partaTel,
- partbAddress,
- partbEmail,
- partbFax,
- partbId,
- partbLinkId,
- partbLinkName,
- partbName,
- partbTel,
- totalPrice,
- discountTotalPrice,
- partaUnifiedSocialCreditCode,
- partbUnifiedSocialCreditCode,
- pricingWay,
- totalAmount: totalPrice,
- payAmount: discountTotalPrice,
- receiveAddress: partaAddress,
- settlementMode,
- settlementModeName
- });
- this.getLinkInfo(partaId);
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(
- data.productList,
- contractVO.contractStartDate
- );
- this.$store.commit('order/setAllcountAmount', totalPrice);
- });
- }
- },
- //获取订单详情
- async getpurchaseorderDetail(id) {
- this.loading = true;
- const data = await getpurchaseorderDetail(id);
- this.loading = false;
- if (data) {
- this.$nextTick(() => {
- this.form = data;
- this.$refs.inventoryTable &&
- this.$refs.inventoryTable.putTableValue(data.productList);
- this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.putTableValue(data.rawDetailList); //原料
- this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.putTableValue(
- data.outputDetailList
- ); //产成品
- this.getLinkInfo(data.partaId);
- this.getrequireUser(this.form.requireDeptId);
- this.$store.commit('order/setAllcountAmount', data.totalAmount);
- this.$store.commit('order/setContractId', data.contractId);
- });
- }
- },
- //更新联系人数据
- async getLinkInfo(contactId) {
- const data = await getcontactlink({ contactId });
- if (data && data?.length) {
- this.linkNameOptions = data;
- }
- },
- selectFocus() {
- if (this.linkNameOptions.length === 0) {
- return this.$message.error('请先选择名称');
- }
- },
- //选择下拉框
- onchangeLink(selectedOptions) {
- const option = this.linkNameOptions.find(
- (opt) => opt.id === selectedOptions
- );
- this.form = Object.assign({}, this.form, {
- partbEmail: option?.email,
- partbLinkName: option?.linkName || '',
- partbTel: option?.mobilePhone || option?.phone || '',
- partbLinkId: option?.id
- });
- },
- handHead() {
- let item = {
- id: this.form.partaLinkId
- };
- this.$refs.headRef.open(item);
- },
- //选择供采购方人回调
- changePersonel(obj) {
- this.$set(this.form, 'partaLinkId', obj.id);
- this.$set(this.form, 'partaLinkName', obj.name);
- this.$set(this.form, 'partaTel', obj.phone);
- this.$set(this.form, 'partaEmail', obj.email);
- },
- //选择供应商回调
- changeParent(obj) {
- this.form = Object.assign({}, this.form, {
- partbId: obj.id,
- partbName: obj.name,
- partbAddress: obj.addressName + obj.address,
- partbLinkId: '',
- partbLinkName: '',
- partbEmail: '',
- partbTel: ''
- });
- this.getLinkInfo(obj.id);
- },
- //选择合同回调
- changeContract(obj) {
- this.form = Object.assign({}, this.form, {
- contractId: obj.id,
- contractName: obj.contractName,
- contractNo: obj.contractNo
- });
- this.getDetailData(obj.id);
- // //采购询价表
- // this.getPurchaseinquiry(obj.sourceId);
- //获取合同采购计划
- this.getPlanInfo(this.form.contractId);
- this.$store.commit('order/setContractId', obj.id);
- },
- async getPlanInfo(id) {
- let res = await getPurchasePlanByContractIdAPI(id);
- this.form = Object.assign({}, this.form, {
- purchasePlanId: res.data?.id,
- purchasePlanName: res.data?.planName,
- purchasePlanNo: res.data?.planCode,
- sourceType: res.data?.sourceType,
- sourceTypeName: res.data?.sourceTypeName
- });
- },
- //选择合同弹框
- handleContractBtn() {
- if (this.clearing) return;
- let item = {
- id: this.form.contractId
- };
- this.$refs.selectContractRef.open(item);
- },
- //清除合同
- clearContrcat() {
- this.clearing = true;
- this.isFlag = false;
- let {
- id,
- projectName,
- saleType,
- saleTypeName,
- deliveryDate,
- orderFiles,
- remark
- } = this.form;
- this.form = Object.assign({}, copyObj(this.formDef), {
- id,
- projectName,
- saleType,
- saleTypeName,
- deliveryDate,
- orderFiles,
- remark
- });
- this.$store.commit('order/setContractId', '');
- this.$store.commit('order/setAllcountAmount', 0);
- this.$refs.inventoryTable.putTableValue([]);
- setTimeout(() => {
- this.clearing = false;
- }, 500);
- },
- handParent() {
- if (this.form.contractId) {
- return this.$message.error('选择了合同不能更改供应商名称');
- }
- let item = {
- id: this.form.contactId
- };
- this.$refs.parentRef.open(item);
- },
- settlementModeChange(info) {
- this.form.settlementModeName = info.dictValue;
- },
- ifChiefChange(value, idx) {
- if (value === 1) {
- this.tableLinkData.forEach((e) => (e.ifChief = 0));
- this.tableLinkData[idx].ifChief = 1;
- }
- },
- getValidate() {
- return Promise.all([
- new Promise((resolve, reject) => {
- this.$refs.form.validate((valid) => {
- if (!valid) {
- reject(false);
- } else {
- resolve(true);
- }
- });
- }),
- new Promise((resolve, reject) => {
- this.$refs.inventoryTable.validateForm((valid) => {
- if (!valid) {
- reject(false);
- } else {
- resolve(true);
- }
- });
- })
- ]);
- },
- async getTableValue() {
- try {
- await this.getValidate();
- // 表单验证通过,执行保存操作
- this.loading = true;
- if (!this.form.contractId) {
- this.form.totalAmount = this.allcountAmount;
- }
- const rawDetailList =
- (this.$refs.rawDetailListRef &&
- this.$refs.rawDetailListRef.getTableValue()) ||
- [];
- const outputDetailList =
- (this.$refs.outputDetailListRef &&
- this.$refs.outputDetailListRef.getTableValue()) ||
- [];
- let commitData = Object.assign({}, this.form, {
- productList: [
- ...this.$refs.inventoryTable.getTableValue(),
- ...rawDetailList,
- ...outputDetailList
- ],
- // purchaseTypeName: this.getDictValue(
- // '采购订单类型',
- // this.form.purchaseType
- // ),
- sourceTypeName: this.getDictValue(
- '需求来源类型',
- this.form.sourceType
- )
- });
- return commitData;
- } catch (error) {
- console.log(error);
- // 表单验证未通过,不执行保存操作
- }
- },
- //查找合同分类对应name
- findNameById(tree, targetId) {
- for (let i = 0; i < tree.length; i++) {
- const node = tree[i];
- if (node.id === targetId) {
- return node.name;
- }
- if (node.children && node.children.length > 0) {
- const name = this.findNameById(node.children, targetId);
- if (name) {
- return name;
- }
- }
- }
- return null;
- }
- }
- };
- </script>
- <style scoped lang="scss">
- .TotalAmount {
- font-size: 16px;
- padding-right: 30px;
- }
- </style>
|