1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639 |
- <template>
- <div class="borderless" v-loading="pageLoading">
- <div class="customer-head">
- <div class="customer-back">
- <el-button
- type="danger"
- style="border: none;background: none;color: red"
- icon="el-icon-arrow-left"
- @click="backToList"
- :loading="btnLoading"
- >返回列表</el-button>
- </div>
- <div class="add-customer-btn">
- <el-button
- type="primary"
- size="small"
- class="el-button--small-yh"
- @click.stop="openEdit"
- v-if="form.id && disabled"
- >编 辑</el-button>
- <el-button
- type="primary"
- size="small"
- style="margin-right: 8px;"
- @click="dealerSubmit"
- :disabled="disabled"
- :loading="btnLoading"
- v-if="form.id"
- >
- {{ form.status == 0? '确认订单': form.status == 3? '撤销订单': '' }}
- </el-button>
- <el-dropdown style="margin-right: 8px;">
- <el-button type="warning" size="small">账单处理<i class="el-icon-arrow-down el-icon--right"></i></el-button>
- <el-dropdown-menu slot="dropdown">
- <el-dropdown-item
- @click.native="applySettlement('收费')"
- :disabled="disabled"
- >生成账单
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- <el-button
- type="success"
- :disabled="!form.id"
- size="small"
- @click="copyDoc"
- :loading="btnLoading"
- >
- 复制单据
- </el-button>
- <el-button
- type="primary"
- @click="editCustomer"
- size="small"
- :loading="btnLoading"
- :disabled="disabled"
- >保存数据
- </el-button>
- </div>
- </div>
- <div class="customer-main">
- <containerTitle title="基础信息"/>
- <basic-container :showBtn="true">
- <avue-form
- ref="form"
- class="trading-form"
- v-model="form"
- :option="option"
- >
- <template slot="corpId">
- <crop-select
- v-model="form.corpId"
- @getCorpData="getCorpData"
- corpType="KH"
- :disabled="disabled || confirmDisabled"
- />
- </template>
- <template slot="belongToCorpId">
- <crop-select
- v-model="form.belongToCorpId"
- @getCorpData="getGSData"
- corpType="GS"
- :disabled="disabled || confirmDisabled"
- />
- </template>
- <template slot="storageId">
- <warehouse-select
- v-model="form.storageId"
- @returnBack="storageChange"
- :configuration="configurationWarehouse"
- :disabled="disabled || confirmDisabled"/>
- </template>
- <template slot="chargeMember">
- <el-select
- v-model="form.chargeMember"
- filterable
- clearable
- size="small"
- :disabled="disabled"
- >
- <el-option
- v-for="(item,index) in userList"
- :key="index"
- :label="item.realName"
- :value="item.realName"
- ></el-option>
- </el-select>
- </template>
- </avue-form>
- </basic-container>
- <containerTitle title="商品信息"/>
- <basic-container>
- <avue-crud
- ref="crud"
- :data="dataList"
- :option="tableOption"
- :cell-style="cellStyle"
- @saveColumn="saveColumn"
- @resetColumn="resetColumn"
- >
- <template slot="headerSerial" slot-scope="{column}">
- <el-button
- type="primary"
- icon="el-icon-circle-plus-outline"
- circle
- size="mini"
- :disabled="disabled || !form.storageId || confirmDisabled"
- @click="$refs.crud.rowCellAdd()"></el-button>
- </template>
- <template slot="menuLeft">
- <el-button
- type="primary"
- icon="el-icon-plus"
- size="small"
- @click.stop="newDetails"
- :disabled="disabled || !form.storageId || confirmDisabled"
- >录入明细</el-button>
- <el-button
- type="info"
- icon="el-icon-printer"
- size="small"
- @click.stop="openReport"
- >报表打印</el-button>
- <el-button
- type="primary"
- size="small"
- icon="el-icon-download"
- @click="downloadHandle"
- >下载模板</el-button>
- <el-upload
- :action="baseURL"
- :headers="headers"
- :disabled="disabled || confirmDisabled || !form.storageId"
- :on-progress="uploading"
- :show-file-list=false
- :data="uploadParam"
- accept=".xls,.xlsx"
- multiple
- :on-success="importTemplate"
- :on-error="uploadError"
- style="float: right"
- >
- <el-button
- type="primary"
- size="small"
- icon="el-icon-upload"
- :disabled="disabled || confirmDisabled || !form.storageId"
- >导 入</el-button>
- </el-upload>
- </template>
- <template slot="menu" slot-scope="{ row, index }">
- <el-button
- size="small"
- icon="el-icon-edit"
- type="text"
- @click="rowCell(row, index)"
- :disabled="disabled || confirmDisabled"
- >{{ row.$cellEdit ? "保存" : "修改" }}</el-button
- >
- <el-button
- size="small"
- icon="el-icon-delete"
- type="text"
- @click="rowDel(row, index)"
- :disabled="disabled || confirmDisabled"
- >删除</el-button
- >
- </template>
- <template slot="code" slot-scope="{ row, index }">
- <span v-if="row.$cellEdit" style="display:flex">
- <el-select
- v-model="row.code"
- placeholder="请选择"
- filterable
- size="small"
- style="width:60%"
- @change="codeChange(row, index)"
- :disabled="!form.storageId"
- >
- <el-option
- v-for="item in goodsoptions"
- :key="item.id"
- :label="item.code"
- :value="item.code"
- >
- </el-option>
- </el-select>
- <el-button
- icon="el-icon-search"
- size="small"
- @click="rePick(row, index)"
- ></el-button>
- </span>
- <span v-else> {{ row.code }}</span>
- </template>
- <template slot="cname" slot-scope="{ row, index }">
- <span v-if="row.$cellEdit" style="display:flex">
- <el-select
- v-model="row.itemId"
- placeholder="请选择"
- size="small"
- filterable
- style="width:60%"
- @change="cnameChange(row, index)"
- :disabled="!form.storageId"
- >
- <el-option
- v-for="item in goodsoptions"
- :key="item.id"
- :label="item.cname"
- :value="item.id"
- >
- </el-option>
- </el-select>
- <el-button
- icon="el-icon-search"
- size="small"
- @click="rePick(row, index)"
- ></el-button>
- </span>
- <span v-else> {{ row.cname }}</span>
- </template>
- <template slot="orderQuantity" slot-scope="{ row, index }">
- <el-input-number
- v-if="row.$cellEdit"
- v-model="row.orderQuantity"
- size="small"
- :controls="false"
- :precision="0"
- @input="amountChange(row)"
- :disabled="!form.storageId"
- style="width: 100%"
- />
- <span v-else>{{ row.orderQuantity | IntegerFormat }}</span>
- </template>
- <template slot="price" slot-scope="{ row, index }">
- <el-input-number
- v-if="row.$cellEdit"
- v-model="row.price"
- size="small"
- :controls="false"
- :precision="2"
- @input="amountChange(row)"
- style="width: 100%"
- :disabled="!form.storageId"
- ></el-input-number>
- <span v-else>{{ row.price }}</span>
- </template>
- <!-- 单位-->
- <template slot="unit" slot-scope="{ row, index }">
- <el-select
- v-if="row.$cellEdit"
- v-model="row.unit"
- size="small"
- clearable
- filterable
- :disabled="!form.storageId"
- >
- <el-option
- v-for="(item, index) in unitOption"
- :key="index"
- :label="item.dictValue"
- :value="item.dictValue"
- />
- </el-select>
- <span v-else>{{ row.unit }}</span>
- </template>
- <template slot="amount" slot-scope="{ row, index }">
- <span>{{ row.amount | decimalFormat }}</span>
- </template>
- <template slot="storageQuantity" slot-scope="{ row, index }">
- <span>{{ row.storageQuantity | IntegerFormat }}</span>
- </template>
- <template slot="lotNo" slot-scope="{ row, index }">
- <span v-if="row.batch == 1" style="color: #c90707;margin-right: 3px">*</span>
- <el-select
- v-if="row.$cellEdit"
- v-model="row.lotNo"
- size="small"
- filterable
- allow-create
- clearable
- @change="lotNoChange(row)"
- :disabled="!form.storageId"
- >
- <el-option
- v-for="(item, index) in row.arr"
- :key="index"
- :label="item.lotNo"
- :value="item.lotNo"
- />
- </el-select>
- <span v-else>{{ row.lotNo }}</span>
- </template>
- <template slot="newJob" slot-scope="{ row, index }">
- <span style="color: #1e9fff;cursor: pointer" @click="openHistory(row)">{{ row.newJob }}</span>
- </template>
- <template slot="remarks" slot-scope="{ row, index }">
- <el-input
- v-if="row.$cellEdit"
- v-model="row.remarks"
- size="small"
- :disabled="!form.storageId"
- />
- <span v-else>{{ row.remarks }}</span>
- </template>
- </avue-crud>
- </basic-container>
- <containerTitle title="详细信息"/>
- <basic-container :showBtn="true">
- <avue-form
- ref="form1"
- class="trading-form"
- v-model="form"
- :option="detailOption"
- ></avue-form>
- </basic-container>
- <containerTitle title="附件管理"></containerTitle>
- <c-upload
- :data="uploadData"
- deleteUrl="/api/blade-client/corpsbank/update"
- :enumerationValue="84"
- :disabled="disabled || confirmDisabled"
- />
- </div>
- <!-- 商品弹窗-->
- <el-dialog
- title="导入商品"
- append-to-body
- class="el-dialogDeep"
- :visible.sync="dialogVisible"
- width="80%"
- :close-on-click-modal="false"
- :destroy-on-close="true"
- :close-on-press-escape="false"
- @close="closeGoods"
- top="5vh"
- v-dialog-drag
- >
- <span>
- <el-row>
- <el-col :span="4">
- <div>
- <el-scrollbar>
- <basic-container>
- <avue-tree
- :option="treeOption"
- @node-click="nodeClick"
- :style="treeStyle"
- />
- </basic-container>
- </el-scrollbar>
- </div>
- </el-col>
- <el-col :span="20">
- <avue-crud
- :option="goodsOption"
- :table-loading="loading"
- :data="goodsListShow"
- ref="goodsCrud"
- :search.sync="search"
- @search-change="searchChange"
- @selection-change="selectionChange"
- @row-click="rowClick"
- :page.sync="page"
- @on-load="onLoad"
- @saveColumn="saveGoodsColumn"
- @resetColumn="resetGoodsColumn"
- :cell-style="cellStyle"
- >
- <template slot="menuLeft">
- <el-tabs v-model="activeName" @tab-click="tabHandle">
- <el-tab-pane label="查询结果" name="searchList"></el-tab-pane>
- <el-tab-pane label="已选定数据" name="importStaging"></el-tab-pane>
- </el-tabs>
- </template>
- <template slot-scope="scope" slot="menu">
- <el-button
- type="text"
- icon="el-icon-edit"
- size="small"
- @click.stop="importStagList(scope.row,scope.index)"
- v-if="activeName=='searchList'"
- :disabled="goodsListSave.findIndex(item => item.id == scope.row.id) !== -1"
- >选择
- </el-button>
- <el-button
- type="text"
- icon="el-icon-delete"
- size="small"
- @click.stop="removeStagList(scope.row,scope.index)"
- v-else
- >移除
- </el-button>
- </template>
- </avue-crud>
- </el-col>
- </el-row>
- </span>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">取 消</el-button>
- <el-button
- type="primary"
- @click="importGoods"
- :disabled="selectionList.length == 0 && goodsListSave.length == 0"
- >导入</el-button
- >
- </span>
- </el-dialog>
- <!-- 报表-->
- <report-dialog
- :switchDialog="switchDialog"
- :reportId="form.id"
- reportName="经销商-销售单"
- @onClose="onClose()"
- />
- <!-- 账单-->
- <el-dialog
- append-to-body
- title="账单"
- class="el-dialogDeep"
- :visible.sync="financialAccountDialog"
- width="70%"
- :close-on-click-modal="false"
- :destroy-on-close="true"
- :close-on-press-escape="false"
- v-dialog-drag
- >
- <financial-account
- :billType="billType"
- :billData="{}"
- :arrList="applyPaymentList"
- :belongCompany="form.belongToCorpId"
- @choceFun="choceFun"
- />
- </el-dialog>
- <!-- 历史记录-->
- <view-history
- v-if="historyVisible"
- ref="history"
- :params="historyParams"
- @closeDialog="closeDialog"
- />
- </div>
- </template>
- <script>
- import tableOption from "./config/customerContact.json";
- import goodsOption from "./config/commodity.json";
- import {getDeptLazyTree,
- getGoods,} from "@/api/basicData/customerInquiry";
- import {getUserInfo} from "@/api/system/user";
- import { gainUser } from "@/api/basicData/customerInquiry";
- import {selectGoodsNum} from "@/api/basicData/inventoryAccount"; // 库存查询
- import {detail as KHDetail} from "@/api/basicData/customerInformation";
- import {dataDetail, removeGoods, typeSave, getLotNo, dealerSubmit, historyPrice, itemDetail} from "@/api/dealer/sales";
- import reportDialog from "@/components/report-dialog/main";
- import {
- isDiscount,
- isPercentage,
- micrometerFormat,
- IntegerFormat
- } from "@/util/validate";
- import financialAccount from "../../../components/finance/financialAccount";
- import checkSchedule from "@/components/check/checkSchedule";
- import billApplication from "@/components/bill/billApplication";
- import { customerList as feeList } from "@/api/basicData/basicFeesDesc";
- import {getDetail} from "@/api/basicData/inventoryAccount";
- import { getToken } from "@/util/auth";
- import { getCurrentDate } from "@/util/date";
- import viewHistory from '../componet/history';
- import { getMarketPrice, getPurchasePrice } from "@/api/basicData/fees";
- import { contrastObj, contrastList } from "@/util/contrastData";
- export default {
- name: "detail",
- props: {
- detailData: {
- type: Object
- }
- },
- components: {
- reportDialog,
- billApplication,
- financialAccount,
- checkSchedule,
- viewHistory,
- },
- data() {
- return {
- orderNumber:true,
- pageLoading: false,
- btnLoading: false,
- disabled: false, // 编辑
- confirmDisabled: false, // 确认禁用
- form: {},
- option: {
- menuBtn: false,
- labelWidth: 100,
- column: [
- {
- label: "客户名称",
- prop: "corpId",
- rules: [
- {
- required: true,
- message: " ",
- trigger: "change"
- }
- ],
- span: 16,
- slot: true,
- },
- {
- label: "业务时间",
- prop: "businesDate",
- span: 8,
- type: "date",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd 00:00:00",
- rules: [
- {
- required: true,
- message: "",
- trigger: "blur"
- }
- ]
- },
- {
- label: "所属公司",
- prop: "belongToCorpId",
- rules: [
- {
- required: true,
- message: " ",
- trigger: "change"
- }
- ],
- span: 16,
- slot: true,
- },
- {
- label: "发货仓库",
- prop: "storageId",
- span: 8,
- rules: [
- {
- required: true,
- message: " ",
- trigger: "change"
- }
- ],
- },
- {
- label: "电话",
- prop: "corpTel",
- span: 8,
- },
- {
- label: "地址",
- prop: "arrivalAddress",
- span: 8,
- },
- {
- label: "业务员",
- prop: "chargeMember",
- span: 8,
- },
- {
- label: "结算方式",
- prop: "paymentType",
- span: 8,
- type: "select",
- dicUrl: "/api/blade-system/dict-biz/dictionary?code=payment_term",
- props: {
- label: "dictValue",
- value: "dictValue"
- },
- },
- {
- label: "配送方式",
- prop: "distributionMode",
- span: 8,
- },
- {
- label: "备注",
- prop: "orderRemark",
- type: "textarea",
- minRows: 2,
- span: 24,
- },
- ],
- },
- detailOption: {
- menuBtn: false,
- labelWidth: 100,
- column: [
- {
- label: "系统号",
- prop: "sysNo",
- span: 8,
- disabled: true
- },
- {
- label: "打印时间",
- prop: "printTime",
- span: 8,
- disabled: true
- },
- {
- label: "打印次数",
- prop: "printNumber",
- span: 8,
- disabled: true
- },
- {
- label: "客户欠款",
- prop: "corpDebt",
- span: 8,
- disabled: true
- },
- {
- label: "总数量",
- prop: "orderQuantity",
- span: 8,
- disabled: true
- },
- {
- label: "应收金额",
- prop: "debitAmount",
- span: 8,
- disabled: true
- },
- {
- label: "总金额",
- prop: "amount",
- span: 8,
- disabled: true
- },
- {
- label: "制单人",
- prop: "createUserName",
- span: 8,
- disabled: true,
- },
- ]
- },
- dataList: [],
- tableOption: {},
- dialogVisible: false,
- selectionList: [],
- treeDeptId: null,
- reData: null,
- treeOption: {
- nodeKey: "id",
- lazy: true,
- treeLoad: function(node, resolve) {
- const parentId = node.level === 0 ? 0 : node.data.id;
- getDeptLazyTree(parentId).then(res => {
- resolve(
- res.data.data.map(item => {
- return {
- ...item,
- leaf: !item.hasChildren
- };
- })
- );
- });
- },
- addBtn: false,
- menu: false,
- size: "small",
- props: {
- label: "title",
- value: "value",
- children: "children"
- }
- },
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- search: {},
- goodsList: [],
- loading: false,
- goodsOption: {},
- treeStyle: "height:" + (window.innerHeight - 315) + "px",
- goodsoptions: [],
- // 仓库配置
- configurationWarehouse: {
- multipleChoices: false,
- multiple: false,
- collapseTags: false,
- placeholder: "请点击右边按钮选择",
- dicData: [],
- },
- uploadData: [],
- goodData: [], // 存储所有商品信息
- switchDialog: false, // 报表弹窗控制
- userList: [],
- activeName: 'searchList',
- // 商品列表数据合计
- goodsListShow: [],
- // 商品列表暂存
- goodsListSave: [],
- pageList: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- applyPaymentList: [],
- billType:"收费", //账单类型
- billData:{}, //账单需要数据
- applySettlementDialog:false,//生成账单组件
- financialAccountDialog:false,
- feesOption: [],
- unitOption: [],
- baseURL: '/api/blade-purchase-sales/orderitems/importDealerOrder',
- headers: { "Blade-Auth": 'Bearer ' + getToken()},
- uploadParam: {},
- historyVisible: false,
- historyParams: {},
- oldForm: {},
- oldDataList: [],
- oldUploadData: [],
- }
- },
- async created() {
- this.getWorkDicts('unit').then(res => {
- this.unitOption = res.data.data;
- })
- this.tableOption = await this.getColumnData(
- this.getColumnName(79),
- tableOption
- );
- this.goodsOption = await this.getColumnData(
- this.getColumnName(80),
- goodsOption
- );
- getGoods(1, 10).then(res => {
- if (res.data.data.total > 0) {
- this.goodsoptions = res.data.data.records;
- if (Math.ceil(res.data.data.total / 10) > 1) {
- for (let i = 2; i <= Math.ceil(res.data.data.total / 10); i++) {
- getGoods(i, 10).then(e => {
- this.goodsoptions = this.goodsoptions.concat(e.data.data.records);
- });
- }
- }
- }
- });
- getUserInfo().then(res => {
- this.$set(this.form, 'createUserName', res.data.data.realName)
- this.$set(this.form, 'createUser', res.data.data.id)
- })
- gainUser().then(res => {
- this.userList = res.data.data;
- });
- feeList().then(res => {
- this.feesOption = res.data.data.records
- });
- this.$set(this.form, 'businesDate', getCurrentDate());
- this.$set(this.form, 'status', 0);
- if (this.detailData.query) {
- this.disabled = true;
- this.option.column.map(e => {
- this.$set(e, 'disabled', true)
- })
- this.queryData(this.detailData.id);
- } else {
- this.dataList = [
- {
- code: null,
- cname: null,
- typeno: null,
- brandItem: null,
- specsOne: null,
- specsTwo: null,
- unit: null,
- storageQuantity: 0,
- orderQuantity: 0,
- size: null,
- price: 0,
- amount: 0,
- $cellEdit: true
- }
- ]
- }
- },
- filters: {
- IntegerFormat(num) {
- return IntegerFormat(num);
- },
- decimalFormat(num) {
- return num ? Number(num).toFixed(2) : "0.00";
- }
- },
- methods: {
- // 查询
- queryData(id) {
- this.pageLoading = true;
- dataDetail(id).then(res => {
- this.form = res.data.data;
- this.form.amount = Number(this.form.amount).toFixed(2);
- if (this.form.storageId) {
- this.uploadParam = {
- storageId: this.form.storageId
- }
- }
- this.confirmDisabled = this.form.status == 3? true: false;
- if (this.confirmDisabled) {
- // this.option.column.map(e => {
- // this.$set(e, 'disabled', true)
- // })
- }
- this.dataList = this.form.orderItemsList? this.form.orderItemsList: [];
- this.uploadData = this.form.orderFilesList? this.form.orderFilesList: [];
- delete this.form.orderItemsList;
- delete this.form.orderFilesList;
- this.oldForm = {...this.form};
- this.oldDataList = [...this.dataList];
- this.oldUploadData = [...this.uploadData];
- this.dataList.forEach(async item => {
- if (item.batch == 1) {
- item.arr = await this.getLotNo({
- itemId: item.itemId,
- storageId: this.form.storageId,
- tradeType: 'JXS'
- });
- }
- })
- }).finally(() => {
- this.pageLoading = false;
- })
- },
- cellStyle() {
- return "padding:0;height:40px;";
- },
- openEdit() {
- this.disabled = false;
- this.option.column.map(e => {
- if (this.confirmDisabled) {
- if (e.prop == 'businesDate') {
- this.$set(e, 'disabled', true)
- } else {
- this.$set(e, 'disabled', false)
- }
- } else {
- this.$set(e, 'disabled', false)
- }
- })
- },
- copyDoc() {
- this.$emit("copyOrder", this.form.id);
- },
- getCorpData(row) {
- KHDetail(row.id).then(res => {
- if (res.data.data.belongtocompany) {
- this.$set(this.form, 'belongToCorpId', res.data.data.belongtocompany)
- } else {
- this.$set(this.form, 'belongToCorpId', null)
- }
- })
- },
- getGSData(row) {},
- //修改提交触发
- editCustomer(status) {
- this.$refs["form"].validate((valid, done) => {
- done();
- if (valid) {
- for (let item in this.dataList) {
- if (this.dataList[item].batch == 1 && !this.dataList[item].lotNo) {
- return this.$message.error('第' +( Number(item) + 1) + '行明细批次号未填写')
- }
- }
- // 总金额计算
- let amount = 0;
- this.dataList.forEach((item, index) => {
- if (item.batch == 1 && !item.lotNo) {
- }
- amount = Number(amount) + Number(item.amount)
- })
- this.$set(this.form, 'debitAmount', amount.toFixed(2));
- this.$set(this.form, 'amount', amount.toFixed(2));
- this.form.billType = 'XS';
- this.$set(this.form, 'orderItemsList', this.dataList);
- this.$set(this.form, 'orderFilesList', this.uploadData);
- this.btnLoading = true;
- typeSave(this.form).then(res => {
- this.$message({type: "success", message: this.form.id ? "修改成功!" : "新增成功!"});
- this.queryData(res.data.data.id);
- }).finally(() => {
- this.btnLoading = false;
- })
- } else {
- return false
- }
- })
- },
- //返回列表
- backToList() {
- this.$emit("goBack");
- },
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(79),
- this.tableOption
- );
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- this.$nextTick(() => {
- this.$refs.crud.doLayout()
- })
- }
- },
- async resetColumn() {
- this.tableOption = tableOption;
- const inSave = await this.delColumnData(
- this.getColumnName(79),
- tableOption
- );
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.crud.doLayout()
- })
- this.$message.success("重置成功");
- //关闭窗口
- setTimeout(() => {
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }, 1000);
- }
- },
- //商品明细导入
- newDetails() {
- this.$refs["form"].validate((valid) => {
- if (valid) {
- this.dialogVisible = !this.dialogVisible;
- }
- })
- },
- // 获得库存价
- async getStockInfo(data) {
- //tradeType JXS
- //goodsId
- //storageId
- //lotNo 批次号
- let form = {};
- await getDetail(data).then(res => {
- const a = res.data.data? res.data.data: {
- stock: 0,
- balanceAmount: 0,
- balanceQuantity: 0,
- };
- this.$set(form, 'purchaseAmount', a.balanceQuantity == 0? 0: (Number(a.balanceAmount) / Number(a.balanceQuantity)).toFixed(2));
- this.$set(form, 'stock', a.balanceQuantity);
- })
- return form;
- },
- // 获得批次号
- async getLotNo(data) {
- let arr = [];
- await getLotNo(data).then(res => {
- arr = res.data.data? res.data.data: []
- })
- return arr;
- },
- importGoods() {
- let form = {};
- if (this.reData) {
- if (this.selectionList.length != 1) {
- return this.$message.error("重新选择的时候只能选择一条数据");
- } else {
- this.selectionList.forEach(e => {
- this.dataList.forEach(async (item, index) => {
- if (index == this.reData.index) {
- getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
- if (response.data.data.length > 0) {
- this.$set(e, 'price', response.data.data[0].salePrice)
- } else {
- this.$set(e, 'price', '0')
- }
- })
- let historyData = await this.getHistoryData(e, 1); // 获得最新数据
- if (historyData.length > 0) {
- e.newJob = historyData[0].price;
- e.newDate = historyData[0].businesDate;
- } else {
- e.newJob = null;
- e.newDate = null;
- }
- if (e.batch == 0) {
- form = await this.getStockInfo({
- tradeType: 'JXS',
- goodsId: e.id,
- storageId: this.form.storageId,
- })
- item.storageQuantity = form.stock;
- item.purchaseAmount = form.purchaseAmount;
- } else {
- item.storageQuantity = 0
- item.purchaseAmount = 0;
- item.arr = await this.getLotNo({
- itemId: e.id,
- storageId: this.form.storageId,
- tradeType: 'JXS'
- });
- }
- item.itemId = e.id;
- item.code = e.code;
- item.cname = e.cname;
- item.corpId = e.corpId;
- item.corpName = e.corpName;
- item.brandItem = e.brandItem;
- item.specsOne = e.specsOne;
- item.specsTwo = e.specsTwo;
- item.typeno = e.typeno;
- item.unit = e.unit;
- item.size = e.size;
- item.priceCategory = e.goodsTypeName;
- item.purchaseAmount = e.purchaseAmount;
- item.batch = e.batch;
- item.newDate = e.newDate;
- item.newJob = e.newJob;
- item.price = e.price;
- item.$cellEdit = true;
- }
- });
- });
- }
- } else {
- if (this.goodsListSave.length > 0) { // 暂存的有数据
- this.goodsListSave.forEach(async e => {
- getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
- if (response.data.data.length > 0) {
- this.$set(e, 'price', response.data.data[0].salePrice)
- } else {
- this.$set(e, 'price', '0')
- }
- })
- let historyData = await this.getHistoryData(e, 1); // 获得最新数据
- if (historyData.length > 0) {
- e.newJob = historyData[0].price;
- e.newDate = historyData[0].businesDate;
- } else {
- e.newJob = null;
- e.newDate = null;
- }
- if (e.batch == 0) {
- form = await this.getStockInfo({
- tradeType: 'JXS',
- goodsId: e.id,
- storageId: this.form.storageId,
- })
- e.storageQuantity = form.stock;
- e.purchaseAmount = form.purchaseAmount;
- e.arr = [];
- } else {
- e.storageQuantity = 0
- e.purchaseAmount = 0;
- e.arr = await this.getLotNo({
- itemId: e.id,
- storageId: this.form.storageId,
- tradeType: 'JXS'
- });
- }
- this.dataList.push({
- itemId: e.id,
- code: e.code,
- cname: e.cname,
- brandItem: e.brandItem,
- specsOne: e.specsOne,
- specsTwo: e.specsTwo,
- typeno: e.typeno,
- corpId: e.corpId,
- corpName: e.corpName,
- unit: e.unit,
- size: e.size,
- price: e.price,
- amount: 0,
- orderQuantity: 0,
- storageQuantity: e.storageQuantity,
- purchaseAmount: e.purchaseAmount,
- batch: e.batch,
- arr: e.arr,
- newJob:e.newJob,
- newDate: e.newDate,
- $cellEdit: true
- });
- });
- } else {
- this.selectionList.forEach(async e => {
- getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
- if (response.data.data.length > 0) {
- this.$set(e, 'price', response.data.data[0].salePrice)
- } else {
- this.$set(e, 'price', '0')
- }
- })
- let historyData = await this.getHistoryData(e, 1); // 获得最新数据
- if (historyData.length > 0) {
- e.newJob = historyData[0].price;
- e.newDate = historyData[0].businesDate;
- } else {
- e.newJob = null;
- e.newDate = null;
- }
- if (e.batch == 0) {
- form = await this.getStockInfo({
- tradeType: 'JXS',
- goodsId: e.id,
- storageId: this.form.storageId,
- })
- e.storageQuantity = form.stock;
- e.purchaseAmount = form.purchaseAmount;
- e.arr = [];
- } else {
- e.storageQuantity = 0
- e.purchaseAmount = 0;
- e.arr = await this.getLotNo({
- itemId: e.id,
- storageId: this.form.storageId,
- tradeType: 'JXS'
- });
- }
- this.dataList.push({
- itemId: e.id,
- code: e.code,
- cname: e.cname,
- brandItem: e.brandItem,
- specsOne: e.specsOne,
- specsTwo: e.specsTwo,
- typeno: e.typeno,
- corpId: e.corpId,
- corpName: e.corpName,
- unit: e.unit,
- size: e.size,
- amount: 0,
- orderQuantity: 0,
- storageQuantity: e.storageQuantity,
- purchaseAmount: e.purchaseAmount,
- batch: e.batch,
- arr: e.arr,
- newJob: e.newJob,
- newDate: e.newDate,
- price: e.price,
- $cellEdit: true
- });
- });
- }
- }
- this.dialogVisible = false;
- },
- closeGoods() {
- this.selectionList = [];
- this.treeDeptId = "";
- this.reData = null;
- this.activeName = 'searchList';
- this.goodsListSave = [];
- },
- nodeClick(data) {
- this.treeDeptId = data.id;
- this.page.currentPage = 1;
- this.onLoad(this.page);
- },
- //商品查询
- onLoad(page, params = {}) {
- let obj = this.deepClone(Object.assign(params, this.search));
- this.loading = true;
- getGoods(page.currentPage, page.pageSize, this.treeDeptId, obj)
- .then(res => {
- const data = res.data.data;
- this.page.total = data.total;
- this.goodsList = data.records;
- this.pageList.total = data.total;
- this.goodsListShow = data.records;
- if (this.page.total) {
- this.goodsOption.height = window.innerHeight - 350;
- }
- })
- .finally(() => {
- this.loading = false;
- });
- },
- searchChange(params, done) {
- this.search = this.deepClone(params);
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- rowClick(row) {
- this.$refs.goodsCrud.toggleSelection([this.goodsList[row.$index]]);
- },
- async saveGoodsColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(80),
- this.goodsOption
- );
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
- this.$nextTick(() => {
- this.$refs.goodsCrud.doLayout()
- })
- }
- },
- async resetGoodsColumn() {
- this.goodsOption = goodsOption;
- const inSave = await this.delColumnData(
- this.getColumnName(80),
- goodsOption
- );
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.goodsCrud.doLayout()
- })
- this.$message.success("重置成功");
- //关闭窗口
- setTimeout(() => {
- this.$refs.goodsCrud.$refs.dialogColumn.columnBox = false;
- }, 1000);
- }
- },
- // 报表
- openReport() {
- this.switchDialog =! this.switchDialog;
- },
- // 报表关闭
- onClose(val) {
- this.switchDialog = val;
- },
- rowCell(row, index) {
- if (row.$cellEdit == true) {
- this.$set(row, "$cellEdit", false);
- } else {
- this.$set(row, "$cellEdit", true);
- }
- },
- rowDel(row, index) {
- this.$confirm("确定删除数据?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- if (row.id) {
- removeGoods(row.id).then(res => {
- this.$message({
- type: 'success',
- message: '删除成功!'
- })
- this.dataList.splice(row.$index, 1);
- })
- } else {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.dataList.splice(row.$index, 1);
- }
- });
- },
- codeChange(row) {
- let form = {};
- this.goodsoptions.forEach(async e => {
- if (e.code == row.code) {
- getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
- if (response.data.data.length > 0) {
- this.$set(e, 'price', response.data.data[0].salePrice)
- } else {
- this.$set(e, 'price', '0')
- }
- this.$set(row, 'amount', (Number(e.price) * Number(row.orderQuantity)).toFixed(2))
- })
- let historyData = await this.getHistoryData(e, 1); // 获得最新数据
- if (historyData.length > 0) {
- e.newJob = historyData[0].price;
- e.newDate = historyData[0].businesDate;
- } else {
- e.newJob = null;
- e.newDate = null;
- }
- if (e.batch == 0) {
- form = await this.getStockInfo({
- tradeType: 'JXS',
- goodsId: e.id,
- storageId: this.form.storageId,
- })
- e.storageQuantity = form.stock;
- e.purchaseAmount = form.purchaseAmount;
- e.arr = [];
- } else {
- e.storageQuantity = 0
- e.purchaseAmount = 0;
- e.arr = await this.getLotNo({
- itemId: e.id,
- storageId: this.form.storageId,
- tradeType: 'JXS'
- });
- }
- row.itemId = e.id;
- row.storageQuantity = e.storageQuantity;
- row.cname = e.cname;
- row.code = e.code;
- row.corpId = e.corpId;
- row.corpName = e.corpName;
- row.brandItem = e.brandItem;
- row.specsOne = e.specsOne;
- row.specsTwo = e.specsTwo;
- row.typeno = e.typeno;
- row.unit = e.unit;
- row.size = e.size;
- row.arr = e.arr;
- row.priceCategory = e.goodsTypeName;
- row.purchaseAmount = e.purchaseAmount;
- row.batch = e.batch;
- row.newJob = e.newJob;
- row.newDate = e.newDate;
- row.price = e.price;
- }
- });
- },
- cnameChange(row) {
- let form = {};
- this.goodsoptions.forEach(async e => {
- if (e.id == row.itemId) {
- getMarketPrice({code: e.code,isFreight: 0, isLabel: 0}).then(response => {
- if (response.data.data.length > 0) {
- this.$set(e, 'price', response.data.data[0].salePrice)
- } else {
- this.$set(e, 'price', '0')
- }
- this.$set(row, 'amount', (Number(e.price) * Number(row.orderQuantity)).toFixed(2))
- })
- let historyData = await this.getHistoryData(e, 1); // 获得最新数据
- if (historyData.length > 0) {
- e.newJob = historyData[0].price;
- e.newDate = historyData[0].businesDate;
- } else {
- e.newJob = null;
- e.newDate = null;
- }
- if (e.batch == 0) {
- form = await this.getStockInfo({
- tradeType: 'JXS',
- goodsId: e.id,
- storageId: this.form.storageId,
- })
- e.storageQuantity = form.stock;
- e.purchaseAmount = form.purchaseAmount;
- e.arr = [];
- } else {
- e.storageQuantity = 0
- e.purchaseAmount = 0;
- e.arr = await this.getLotNo({
- itemId: e.id,
- storageId: this.form.storageId,
- tradeType: 'JXS'
- });
- }
- row.storageQuantity = e.storageQuantity
- row.cname = e.cname;
- row.code = e.code;
- row.corpId = e.corpId;
- row.corpName = e.corpName;
- row.brandItem = e.brandItem;
- row.specsOne = e.specsOne;
- row.specsTwo = e.specsTwo;
- row.typeno = e.typeno;
- row.unit = e.unit;
- row.size = e.size;
- row.arr = e.arr;
- row.priceCategory = e.goodsTypeName;
- row.purchaseAmount = e.purchaseAmount;
- row.batch = e.batch;
- row.newDate = e.newDate;
- row.newJob = e.newJob;
- row.price = e.price;
- }
- });
- },
- rePick(row, index) {
- this.reData = {
- ...row,
- index: index
- };
- this.newDetails();
- },
- // 商品信息价格计算
- amountChange(row) {
- if (!row.orderQuantity) {
- row.orderQuantity = 0;
- }
- if (!row.price) {
- row.price = 0;
- }
- row.amount = Number(row.price) * Number(row.orderQuantity)
- },
- // 标签页切换
- tabHandle(data) {
- if (data.name == 'searchList') {
- this.goodsListShow = this.goodsList;
- this.page.total = this.pageList.total
- } else if (data.name == 'importStaging') {
- this.goodsListShow = this.goodsListSave;
- this.page.total = 0
- }
- },
- removeStagList(row, index) {
- this.goodsListSave.splice(row.$index, 1)
- },
- importStagList(row, index) {
- this.goodsListSave.push(row);
- },
- // 生成结算
- applySettlement(type) {
- this.beforeBillData(true,type)
- this.financialAccountDialog = true;
- },
- //生成账单 拿到主表信息
- beforeBillData(bool,type) {
- this.billType = type;
- this.applyPaymentList = [];
- this.dataList.map(e => {
- const form = {
- srcOrderno:this.form.orgOrderNo,
- srcParentId: this.form.id,
- itemType:"销售",
- corpsName:this.form.corpName,
- corpId:this.form.corpId,
- currency: 'CNY',
- exchangeRate: '1',
- taxRate: '0',
- accDate: this.form.businesDate,
- srcType: 1,
- chargeMember: this.form.chargeMember,
- parentId: this.form.id,
- tradeType: 'JXS',
- optionType: 'JXS',
- amount: e.amount,
- costType: this.feesOption.find(item => item.cname == '货款')? this.feesOption.find(item => item.cname == '货款').id: null,
- srcFeesId: e.id,
- goodName: e.cname,
- price: e.price,
- quantity: e.orderQuantity,
- unit: e.unit,
- }
- this.applyPaymentList.push(form);
- })
- },
- //关闭账单
- choceFun(){
- this.financialAccountDialog = false
- },
- // 批次号选择
- async lotNoChange(row) {
- if (row.lotNo) {
- const form = await this.getStockInfo({
- tradeType: 'JXS',
- goodsId: row.itemId,
- storageId: this.form.storageId,
- lotNo: row.lotNo
- })
- row.storageQuantity = form.stock;
- row.purchaseAmount = form.purchaseAmount;
- } else {
- row.storageQuantity = 0;
- row.purchaseAmount = 0;
- }
- },
- // 确认或者取消订单
- dealerSubmit() {
- if (this.verification()) {
- let dealer;
- if (this.form.status == 0) {
- dealer = 1;
- } else if (this.form.status == 3) {
- dealer = 2;
- }
- this.btnLoading = true;
- dealerSubmit({
- id: this.form.id,
- dealer
- }).then(res => {
- if (res.data.code == 200) {
- this.$message.success('操作成功')
- this.queryData(this.form.id)
- } else {
- this.$message.error(res.data.msg)
- }
- }).finally(() => {
- this.btnLoading = false;
- })
- }
- },
- // 下载模板
- downloadHandle() {
- this.$confirm('是否下载模板文件?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- window.open(
- `/api/blade-purchase-sales/orderitems/exportDealerOrder?${
- this.website.tokenHeader
- }=${getToken()}`
- );
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '已取消'
- });
- })
- },
- //文件上传时
- uploading(event, file, fileList) {
- this.openFullScreen(false, '文件正在解析中');
- },
- importTemplate(res, file) {
- this.openFullScreen(true)
- res.data.forEach(item => {
- })
- this.dataList = this.dataList.concat(res.data)
- },
- uploadError(err, file, fileList) {
- this.openFullScreen(true)
- this.$message.error(JSON.parse(err.message).msg)
- },
- //遮罩层
- openFullScreen(res, text) {
- const loading = this.$loading({
- lock: true,
- text: text,
- spinner: 'el-icon-loading',
- background: 'rgba(0, 0, 0, 0.7)'
- });
- if (res === true) loading.close();
- },
- // 仓库选择
- storageChange(value) {
- if (this.form.storageId) {
- this.uploadParam = {
- storageId: value
- }
- }
- },
- // 获得历史数据
- async getHistoryData(row, typeId = null) {
- let data;
- const params = {
- typeId,
- tradeType: 'JXS',
- billType: 'XS',
- itemId: row.id
- }
- await historyPrice(params).then(res => {
- data = res.data.data? res.data.data: [];
- })
- return data;
- },
- openHistory(row) {
- this.historyParams = {
- tradeType: 'JXS',
- billType: 'XS',
- itemId: row.itemId
- }
- this.historyVisible = true;
- this.$nextTick(() => {
- this.$refs.history.init();
- })
- },
- closeDialog() {
- this.historyVisible = false;
- },
- // 销售金额获取
- async getMarketPrice(row) {
- await getMarketPrice({code: row.code}).then(res => {
- this.salesPriceOtion = res.data.data
- })
- },
- // 验证新旧值对比
- verification() {
- if (contrastObj(this.form, this.oldForm) ||
- contrastList(this.dataList, this.oldDataList) ||
- contrastList(this.uploadData, this.oldUploadData)) {
- this.$confirm("数据发生变化未有提交记录, 是否提交?", "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- this.editCustomer();
- }).catch(() => {
- return false; //取消改动数据
- })
- } else {
- return true;
- }
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .trading-form ::v-deep .el-form-item {
- margin-bottom: 8px !important;
- }
- ::v-deep .el-form-item__error {
- display: none !important;
- }
- ::v-deep .select-component {
- display: flex !important;
- }
- </style>
|