123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191 |
- <template>
- <div>
- <div class="borderless">
- <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">返回列表
- </el-button>
- </div>
- <div class="add-customer-btn">
- <el-button v-if="detailData.check" type="primary" size="small" class="el-button--small-yh"
- @click.stop="openCheckDialog">
- 审批
- </el-button>
- <!--<el-button type="primary" size="small" v-if="form.confirmStatus == 1" @click="newAddfun">新建销售单-->
- <!--</el-button>-->
- <el-button type="warning" size="small" :disabled="form.debitAmount == form.settlmentAmount" v-if="form.confirmStatus == 1" @click.stop="clickPayment">收款
- </el-button>
- <el-button type="info" icon="el-icon-printer" size="small" @click.stop="openReport()">报表打印
- </el-button>
- <el-button type="primary" size="small" v-if="detailData.status == 1 && form.confirmStatus == 0"
- class="el-button--small-yh " @click.stop="openEdit">编辑
- </el-button>
- <el-button type="primary" size="small" v-if="!form.id && detailData.status != 1" @click="editCustomer">
- 保存数据
- </el-button>
- <!--<el-button type="primary" size="small" v-if="form.id && detailData.status != 1 && form.confirmStatus == 0"-->
- <!-- @click="fixSave">-->
- <!-- 保存数据-->
- <!--</el-button>-->
- <el-button type="primary" size="small" v-if="form.id && detailData.status != 1 && form.confirmStatus == 0"
- @click="submit">
- 提交
- </el-button>
- <el-button type="primary" size="small" v-if="form.confirmStatus == 1" @click="revokeOrder">
- 撤销
- </el-button>
- </div>
- </div>
- <!-- <containerTitle title="基础资料" style="margin-top: 60px"></containerTitle> -->
- <trade-card title="基础资料" style="margin-top: 60px" v-loading="loadingBtn">
- <avue-form ref="form" class="trading-form" v-model="form" :option="option">
- <template slot="corpId">
- <crop-select v-model="form.corpId" corpType="KH" :disabled="detailData.status == 1"
- @getCorpData="getCorpData"></crop-select>
- </template>
- <template slot="storageId">
- <el-select v-model="form.storageId" placeholder="请选择" size="small" filterable @change="storageChange"
- :disabled="detailData.status == 1 || data.length > 0">
- <el-option v-for="item in storageoptions" :key="item.id" :label="item.cname" :value="item.id">
- </el-option>
- </el-select>
- </template>
- </avue-form>
- </trade-card>
- <trade-card title="商品信息" v-loading="loadingBtn">
- <avue-form ref="option2form" class="trading-form" v-model="form" :option="option2">
- <template slot="thisUsedProfit">
- <el-input-number v-model="jsthisUsedProfit" disabled
- placeholder="请输入" size="small" :controls="false" style="width:100%;"
- ></el-input-number>
- <!--@change="amountChange"-->
- </template>
- <template slot="memberBalance">
- <el-input-number v-model="form.memberBalance" disabled style="width: 100%"
- placeholder="请输入" size="small" :controls="false"></el-input-number>
- <!--<span style="margin-left: 10px;border: 1px solid #E4E7ED;padding: 6px;border-radius: 4px">-->
- <!-- 余额:{{balanceAmounts}}-->
- <!--</span>-->
- </template>
- </avue-form>
- <avue-crud ref="crud" :option="optionList" :data="data" :table-loading="loading" @saveColumn="saveColumn"
- @resetColumn="resetColumn" :cell-style="cellStyle">
- <template slot="headerSerial">
- <el-button type="primary" icon="el-icon-plus" size="mini" @click.stop="addRow"
- :disabled="detailData.status == 1" circle></el-button>
- </template>
- <template slot="cname" slot-scope="{ row, index }">
- <el-select v-if="row.$cellEdit" v-model="row.cname" placeholder="请选择" size="small" filterable
- @change="cnameChange(row, index)">
- <el-option v-for="item in goodsoptions" :key="item.itemId" :label="item.cname" :value="item.cname"
- :disabled="item.status == 1">
- </el-option>
- </el-select>
- <span v-else>{{ row.cname }}</span>
- </template>
- <template slot="unitHeader" slot-scope="{column}">
- <span style="color: #409EFF;cursor: pointer" @click.stop="$refs.dictbiz.open()">单位
- </span>
- </template>
- <template slot="storageInQuantity" slot-scope="{ row, index }">
- <el-input-number v-if="row.$cellEdit" v-model="row.storageInQuantity" @change="countChange(row)"
- placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input-number>
- <span v-else>{{ row.storageInQuantity }}</span>
- </template>
- <template slot="price" slot-scope="{ row, index }">
- <el-input-number v-if="row.$cellEdit" v-model="row.price" @change="countChange(row)" placeholder="请输入"
- size="small" :controls="false" style="width:100%;"></el-input-number>
- <span v-else>{{ row.price }}</span>
- </template>
- <template slot="purchaseAmount" slot-scope="{ row, index }">
- <el-input-number v-if="row.$cellEdit" v-model="row.purchaseAmount" @change="countChange(row)"
- placeholder="请输入" size="small" :controls="false" style="width:100%;"></el-input-number>
- <span v-else>{{ row.purchaseAmount }}</span>
- </template>
- <template slot="menu" slot-scope="{ row, index }">
- <el-button size="small" type="text" :disabled="detailData.status == 1" @click="rowCell(row, index)">{{
- row.$cellEdit ? "保存" : "修改"
- }}</el-button>
- <el-button size="small" type="text" :disabled="detailData.status == 1" @click="rowDel(row, index)">删除
- </el-button>
- </template>
- </avue-crud>
- </trade-card>
- <fee-info ref="feeInfo" :data="settlementList" :form="form" :detailData="detailData" @getPay="getPay"
- v-loading="loadingBtn">
- </fee-info>
- <containerTitle title="上传附件"></containerTitle>
- <c-upload v-loading="loadingBtn" typeUpload="CD"
- deleteUrl="/api/trade-purchase/woodHarvestingCloud/removeByFileId" :data="orderFilesList" display
- :enumerationValue="35.1" :disabled="detailData.status == 1"></c-upload>
- <el-dialog :title="addressTitle" v-dialogDrag :visible.sync="addressVisible" class="avue-dialog avue-dialog--top"
- width="50%" append-to-body>
- <span>
- <el-tabs v-model="activeName">
- <el-tab-pane label="客户地址" name="first">
- <avue-form class="trading-form" v-model="form2" :option="optiontabs1"></avue-form>
- </el-tab-pane>
- <el-tab-pane label="物流地址" name="second">
- <avue-form class="trading-form" v-model="form3" :option="optiontabs2"></avue-form>
- </el-tab-pane>
- </el-tabs>
- </span>
- <div class="avue-dialog__footer">
- <el-button @click="addressVisible = false">取 消</el-button>
- <el-button @click="addressVisible = false" type="primary">确 定</el-button>
- </div>
- </el-dialog>
- <dictbiz-dialog ref="dictbiz" title="添加单位" code="unit" parentId="1585962784498225154"
- @closed="getAllWorkDicts">
- </dictbiz-dialog>
- <report-dialog :switchDialog="switchDialog" :reportId="form.id" reportName="配件系统-销售单" @onClose="onClose()">
- </report-dialog>
- </div>
- <el-dialog append-to-body title="审批" class="el-dialogDeep" :visible.sync="checkDialog" width="50%"
- :close-on-click-modal="false" :destroy-on-close="true" :close-on-press-escape="false" v-dialog-drag>
- <check :checkData="checkData" :checkDetail="false" :idList="[]" @choceCheckFun="choceCheckFun">
- </check>
- </el-dialog>
- <!--付款的弹窗-->
- <el-dialog
- title="收款台"
- :visible.sync="paymentVisible"
- append-to-body
- :close-on-click-modal="false"
- :destroy-on-close="true"
- :close-on-press-escape="false"
- v-dialog-drag
- width="35%"
- v-loading="loadingBtn"
- :before-close="paymentClose">
- <div>
- <!--<div style="font-size: 16px">金额:{{zhifdingdan}}</div>-->
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">订单金额:</div>
- <el-input style="width: calc(100% - 90px)" type="number" v-model="form.orderAmount" disabled
- placeholder="请输入" size="small" :controls="false"
- @change="thisUsedchange" >
- </el-input>
- </div>
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">优惠金额:</div>
- <el-input style="width: calc(100% - 90px)" type="number" v-model="form.thisUsedProfit" :disabled="jsthisUsedProfit != 0"
- placeholder="请输入" size="small" :controls="false"
- @change="thisUsedchange" >
- </el-input>
- </div>
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">应收金额:</div>
- <el-input style="width: calc(100% - 90px)" type="number" v-model="form.debitAmount" disabled
- placeholder="请输入" size="small" :controls="false"
- @change="thisUsedchange" >
- </el-input>
- </div>
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">已收金额:</div>
- <el-input style="width: calc(100% - 90px)" type="number" v-model="form.settlmentAmount" disabled
- placeholder="请输入" size="small" :controls="false"
- @change="thisUsedchange" >
- </el-input>
- </div>
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">会员卡:</div>
- <div style="display: flex;width: calc(100% - 90px)">
- <el-input type="number" v-model="form.memberAmout" size="small" placeholder="请输入会员卡金额"
- @change="memberchange">
- <template slot="append">
- <span>余额:{{balanceAmounts}}</span>
- </template>
- </el-input>
- </div>
- </div>
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">账户:</div>
- <div style="width: calc(100% - 90px)">
- <el-select style="width: 100%" v-model="form.account" size="small" placeholder="请选择">
- <el-option
- v-for="item in accountdata"
- :key="item.dictKey"
- :label="item.dictValue"
- :value="item.dictKey">
- </el-option>
- </el-select>
- </div>
- </div>
- <div style="display: flex;align-items: center;margin-top: 20px">
- <div style="margin-right: 10px;width: 90px;text-align: right">收款金额:</div>
- <div style="width: calc(100% - 90px)">
- <el-input type="number" v-model="form.currentAmount" size="small" placeholder="请输入支付金额"
- @change="currentchange"
- ></el-input>
- </div>
- </div>
- </div>
- <span slot="footer" style="text-align: left" class="dialog-footer">
- <el-button @click="paymentClose">取 消</el-button>
- <el-button type="primary" @click="querenfun">确 定</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import {optionList} from "./js/optionList";
- import {
- getDetails,
- submit,
- getCorpDetails,
- remove,
- getAllgoods,
- save,
- fixSave,
- revoke,
- collectPayment,
- getStoragelist,
- offset,
- obtainPrice
- } from "@/api/basicData/salesOrder";
- import feeInfo from "./components/feeInfo.vue";
- import reportDialog from "@/components/report-dialog/main";
- import { multiply, sum, subtract } from "@/util/calculate";
- import {fdatasync} from "fs";
- import check from "@/components/check/check";
- export default {
- name: "index",
- data() {
- return {
- jsthisUsedProfit:0,
- jsdebitAmount:0,
- // 收款账户
- accountdata:[],
- // 付款的弹窗开启和关闭
- paymentVisible:false,
- checkDialog: false,
- checkData: {},
- switchDialog: false,
- activeName: 'first',
- loadingBtn: false,
- addressTitle: null,
- addressVisible: false,
- form: {},
- form2: {},
- form3: {},
- data: [],
- option: {
- menuBtn: false,
- labelWidth: 90,
- disabled: false,
- column: [
- {
- label: "客户名称",
- prop: "corpId",
- rules: [
- {
- required: true,
- message: "",
- trigger: "blur"
- }
- ],
- span: 8,
- },
- {
- label: "销售单号",
- prop: "sysNo",
- disabled: true,
- span: 8,
- },
- {
- label: "退款单号",
- prop: "srcOrderNo",
- disabled: true,
- span: 8,
- }, {
- label: "订单来源",
- prop: "orderSource",
- disabled: true,
- type: 'select',
- dataType: 'number',
- dicData: [
- {
- label: "APP/PC",
- value: 1
- },
- {
- label: "小程序",
- value: 2
- }],
- props: {
- label: 'label',
- value: 'value'
- },
- span: 8,
- }, {
- label: "联系人",
- prop: "corpAttn",
- disabled: true,
- span: 8,
- }, {
- label: "联系电话",
- prop: "corpTel",
- disabled: true,
- span: 8,
- }, {
- label: "送货地址",
- prop: "arrivalAddress",
- type: 'select',
- dicData: [],
- props: {
- label: 'detailedAddress',
- value: 'detailedAddress'
- },
- allowCreate: true,
- filterable: true,
- span: 16,
- }, {
- label: "销售日期",
- prop: "businesDate",
- type: "datetime",
- format: "yyyy-MM-dd HH:mm:ss",
- valueFormat: "yyyy-MM-dd HH:mm:ss",
- span: 8,
- }, {
- label: "计划收款日期",
- prop: "advanceCollectionDate",
- type: "date",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd HH:mm:ss",
- span: 8,
- }, {
- label: "送货日期",
- prop: "requiredDeliveryDate",
- type: "date",
- format: "yyyy-MM-dd",
- valueFormat: "yyyy-MM-dd 00:00:00",
- span: 8,
- }, {
- label: "快递公司",
- prop: "courierCorporation",
- disabled: true,
- span: 8,
- },
- {
- label: "快递单号",
- prop: "courierNumber",
- disabled: true,
- span: 8,
- },
- {
- label: "仓库",
- prop: "storageId",
- rules: [
- {
- required: true,
- message: "",
- trigger: "blur"
- }
- ],
- span: 8,
- },
- {
- label: "备注",
- prop: "orderRemark",
- placeholder: "打印时显示",
- type: "textarea",
- minRows: 3,
- span: 24,
- }
- ]
- },
- option2: {
- menuBtn: false,
- labelWidth: 80,
- disabled: false,
- column: [
- {
- label: "订单金额",
- prop: "orderAmount",
- disabled: true,
- span: 4,
- },
- {
- label: "优惠金额",
- prop: "thisUsedProfit",
- span: 4,
- },
- {
- label: "应收金额",
- prop: "debitAmount",
- disabled: true,
- span: 8,
- },
- {
- label: "会员卡金额",
- prop: "memberBalance",
- span: 8,
- },
- {
- label: "成本",
- prop: "costAmount",
- disabled: true,
- span: 4,
- },
- {
- label: "毛利",
- prop: "grossProfit",
- disabled: true,
- span: 4,
- },
- {
- label: "税率",
- prop: "exchangeRate",
- type: "select",
- props: {
- label: "dictValue",
- value: "dictKey"
- },
- dicUrl: "/api/blade-system/dict-biz/dictionary?code=tax_rate_xin",
- span: 4,
- },
- {
- label: "销售总数量",
- prop: "storageQuantity",
- disabled: true,
- span: 4,
- },
- {
- label: "已收金额",
- prop: "settlmentAmount",
- disabled: true,
- span: 8,
- }
- ]
- },
- optiontabs1: {
- menuBtn: false,
- labelWidth: 90,
- column: [
- {
- label: "简称",
- prop: "a",
- type: "select",
- span: 24,
- },
- {
- label: "地址",
- prop: "b",
- type: "select",
- span: 24,
- },
- {
- label: "详细地址",
- prop: "c",
- span: 24,
- },
- {
- label: "邮编",
- prop: "d",
- span: 24,
- },
- {
- label: "备注",
- prop: "e",
- type: 'textarea',
- minRows: 3,
- span: 24,
- },
- {
- label: "地址智能识别",
- prop: "ad",
- placeholder: "例:上海市徐汇区枫林街道斜土路100号",
- type: "textarea",
- minRows: 3,
- span: 24,
- }
- ]
- },
- optiontabs2: {
- menuBtn: false,
- labelWidth: 80,
- column: [
- {
- label: "目的地",
- prop: "a",
- type: "select",
- rules: [
- {
- required: true,
- message: "",
- trigger: "blur"
- }
- ],
- span: 24,
- },
- {
- label: "物流公司",
- prop: "b",
- span: 24,
- },
- {
- label: "电话",
- prop: "c",
- span: 24,
- },
- {
- label: "地址",
- prop: "d",
- span: 24,
- },
- {
- label: "详细地址",
- prop: "e",
- span: 24,
- },
- {
- label: "邮编",
- prop: "f",
- span: 24,
- },
- {
- label: "备注",
- prop: "remarks",
- type: "textarea",
- minRows: 3,
- span: 24,
- },
- {
- label: "地址智能识别",
- prop: "g",
- type: "textarea",
- minRows: 3,
- span: 24,
- }
- ]
- },
- optionList: {},
- goodsoptions: [],
- settlementList: [],
- orderFilesList: [],
- storageoptions: [],
- // 会员卡余额
- balanceAmounts:0,
- // 付款弹窗的支付订单
- zhifdingdan:0
- };
- },
- props: {
- detailData: {
- type: Object
- }
- },
- components: {
- feeInfo,
- check,
- reportDialog
- },
- async created() {
- // console.log(this.detailData)
- this.optionList = await this.getColumnData(
- this.getColumnName(212),
- optionList
- );
- if (this.detailData.id) {
- this.getDetail(this.detailData.id);
- }
- if (this.detailData.status == 1) {
- this.option.disabled = true;
- this.option2.disabled = true;
- }
- this.getAllWorkDicts()
- getAllgoods().then(res => {
- this.goodsoptions = []
- res.data.data.map(item=>{
- if(item.status != 1) {
- this.goodsoptions.push(item)
- }
- })
- // this.goodsoptions = res.data.data
- });
- },
- methods: {
- // // 会员卡支付金额的监听
- // memberBalancechange(){
- // if (Number(this.form.memberBalance) < 0) {
- // this.form.memberBalance = 0
- // }
- // this.form.wechatpayAmount = this.form.purchaseAmount - this.form.memberBalance
- // },
- // 优惠金额的监听
- thisUsedchange(){
- if(Number(this.form.thisUsedProfit) < 0) {
- this.$nextTick(()=>{
- this.$message.error('优惠金额不能小于零');
- this.form.thisUsedProfit = 0
- })
- }
- if (Number(this.form.thisUsedProfit) > Number(this.form.orderAmount)){
- this.$nextTick(()=>{
- this.$message.error('优惠金额不能大于未收金额');
- this.form.thisUsedProfit = 0
- })
- }
- this.$nextTick(()=>{
- this.form.debitAmount = this.form.orderAmount - this.form.thisUsedProfit
- this.form.currentAmount = this.form.debitAmount - this.form.settlmentAmount - this.form.memberAmout
- })
- },
- // 会员卡金额的监听
- memberchange(){
- // change事件发生后触发了dom更新,
- // 而数据更改变化是在dom更新之后,
- // 这就导致了dom当中挂载的数据值还是更新之前的值,
- // 并且此后无刷新控制dom重新渲染的指令,使得chhange方法失效。
- // 用$nextTick函数对绑定值进行更改,
- // 即在dom初次完成渲染挂载后,修改其值再次触发dom渲染挂载。
- this.form.thisUsedProfit = this.form.thisUsedProfit?this.form.thisUsedProfit:0
- this.form.memberAmout = this.form.memberAmout?this.form.memberAmout:0
- if (this.form.memberAmout < 0) {
- this.$nextTick(()=>{
- this.$message.error('会员卡不能小于零');
- this.form.memberAmout = 0
- let a = Number(this.form.debitAmount) - Number(this.form.settlmentAmount)
- this.$set(this.form,'currentAmount',a)
- })
- }
- // if (this.form.memberAmout > Number(this.balanceAmounts)) {
- // this.$nextTick(()=>{
- // this.form.memberAmout = Number(this.balanceAmounts)
- // })
- // }
- this.form.settlmentAmount = this.form.settlmentAmount?this.form.settlmentAmount:0
- let sum = this.form.debitAmount - this.form.settlmentAmount
- if (this.form.memberAmout > sum) {
- this.$nextTick(()=>{
- this.form.memberAmout = 0
- this.$delete(this.form, 'currentAmount')
- this.$set(this.form,'currentAmount',sum - this.form.memberAmout)
- })
- }
- this.$delete(this.form, 'currentAmount')
- this.$set(this.form,'currentAmount',sum - this.form.memberAmout)
- console.log(this.form.currentAmount,666)
- },
- // 本次金额监听
- currentchange(){
- if (this.form.currentAmount < 0) {
- this.$message.error('收款金额不能小于零');
- this.form.currentAmount = 0
- }
- this.form.memberAmout = this.form.memberAmout?this.form.memberAmout:0
- // if ((Number(this.form.currentAmount) + Number(this.form.memberAmout)) > this.zhifdingdan) {
- // this.form.currentAmount = this.zhifdingdan
- // this.form.memberAmout = 0
- // }
- },
- // 收款点击事件
- clickPayment(){
- // // 和删除一样的接口 显示要收款的现金
- // this.$prompt(`本次收款需要支付金额为${this.form.currentAmount}`, '提示', {
- // confirmButtonText: '确定',
- // cancelButtonText: '取消',
- // inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
- // inputType:'select',
- // inputErrorMessage: '请选择收款账户',
- // type: 'warning'
- // }).then(()=>{
- //
- // let form = {
- // ...this.form,
- // orderFilesList: this.orderFilesList
- // }
- // collectPayment(form).then(res=>{
- // this.$message.success('收款成功');
- // this.getDetail(this.detailData.id);
- // })
- // })
- this.getWorkDicts("account").then(res => {
- this.accountdata = res.data.data;
- });
- this.zhifdingdan = Number(this.form.orderAmount) - Number(this.form.settlmentAmount)
- this.form.memberAmout = this.form.memberAmout?this.form.memberAmout:0
- this.form.currentAmount = this.form.currentAmount?this.form.currentAmount:0
- this.paymentVisible = true
- },
- // 收款弹窗的确认
- querenfun(){
- // if(this.form.currentAmount < 0){
- // return this.$message.error('支付金额不能负数');
- // }
- // if (this.form.memberAmout < 0) {
- // return this.$message.error('会员卡金额不能为负数');
- // }
- // 判断本次收款和会员卡收款不能为空
- if (!this.form.currentAmount || this.form.currentAmount == 0) {
- if (!this.form.memberAmout || this.form.memberAmout == 0) {
- this.$message.error('本次收款金额或会员卡金额不能为空或零');
- }
- }
- let balance = Number(this.form.debitAmount) - Number(this.form.settlmentAmount)
- if(this.form.currentAmount > balance){
- return this.$message.error('支付金额不能大于未收金额');
- }
- let form = {
- ...this.form,
- orderFilesList: this.orderFilesList
- }
- this.loadingBtn = true
- collectPayment(form).then(res=>{
- this.$message.success('收款成功');
- this.paymentVisible = false
- this.loadingBtn = false
- console.log(this.form.id,741)
- this.getDetail(this.form.id);
- })
- },
- // // 付款弹窗的关闭
- paymentClose(){
- this.$set(this.form,'memberAmout',0)
- this.$set(this.form,'currentAmount',0)
- this.$set(this.form,'thisUsedProfit',this.jsthisUsedProfit)
- this.$set(this.form,'debitAmount',this.jsdebitAmount)
- this.paymentVisible = false
- },
- //打开审核
- openCheckDialog() {
- this.checkData = this.detailData.check;
- this.checkDialog = true;
- },
- //关闭审核
- choceCheckFun() {
- this.checkDialog = false;
- },
- openReport() {
- this.switchDialog = !this.switchDialog;
- },
- onClose(val) {
- this.switchDialog = val;
- },
- getAllWorkDicts() {
- this.getWorkDicts("unit").then(res => {
- this.findObject(this.optionList.column, "unit").dicData = res.data.data;
- });
- getStoragelist().then(res => {
- this.storageoptions = res.data;
- this.findObject(this.optionList.column, "storageId").dicData = res.data;
- })
- this.$refs.crud.init();
- },
- cellStyle() {
- return "padding:0;height:40px;";
- },
- cnameChange(row) {
- console.log(row,668)
- if (row.cname) {
- this.goodsoptions.forEach(e => {
- if (e.cname == row.cname) {
- console.log(e,679)
- row.itemId = e.id
- row.unit = e.unit
- // row.price = e.standardPrice
- row.storageInQuantity = 1
- row.amount = e.standardPrice
- row.purchasePrice = e.purchasePrice
- row.storageAmount = e.purchasePrice
- }
- })
- // // 根据产品ID和客户id获取产品单价
- obtainPrice({
- corpId:this.form.corpId,
- goodsId:row.itemId
- }).then(res=>{
- row.price = res.data.data.salesPrice
- // purchaseAmount
- row.amount = row.price
- this.countChange(row)
- })
- } else {
- row.itemId = null
- row.unit = null
- row.price = null
- row.storageInQuantity = null
- row.amount = null
- row.purchasePrice = null
- row.storageAmount = null
- this.countChange(row)
- }
- },
- // 之前的优惠金额的监听
- amountChange() {
- let val = 0
- this.data.forEach(e => {
- val = sum(val, e.amount)
- this.form.purchaseAmount = val
- this.form.orderAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
- })
- },
- countChange(row) {
- row.amount = multiply(row.price, row.storageInQuantity)
- row.storageAmount = multiply(row.purchaseAmount, row.storageInQuantity)
- let val = 0
- this.data.forEach(e => {
- val = sum(val, e.amount)
- console.log(val,'val')
- this.form.purchaseAmount = val
- this.form.orderAmount = val
- this.form.debitAmount = subtract(this.form.purchaseAmount, this.form.thisUsedProfit)
- })
- this.$refs.crud.refreshTable();
- },
- getDetail(id) {
- this.loadingBtn = true
- getDetails({ id: id })
- .then(res => {
- this.form = res.data.data;
- // // 深拷贝优惠金额
- // this.jsonmemberBalance = JSON.parse(JSON.stringify(this.form.memberBalance))
- this.jsthisUsedProfit = JSON.parse(JSON.stringify(this.form.thisUsedProfit))
- // 深拷贝应收金额
- this.jsdebitAmount = JSON.parse(JSON.stringify(this.form.debitAmount))
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList;
- this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
- this.getAddress(res.data.data)
- }).finally(() => {
- this.loadingBtn = false;
- });
- },
- getCorpData(row) {
- if (row) {
- this.form.corpsName = row.cname
- this.form.corpTel = row.tel
- getCorpDetails({ id: row.id }).then(res => {
- this.balanceAmounts = res.data.data.balanceAmounts
- this.findObject(this.option.column, "arrivalAddress").dicData = res.data.data.corpsAddrList;
- })
- } else {
- this.form.corpsName = null
- this.form.corpTel = null
- this.findObject(this.option.column, "arrivalAddress").dicData = []
- }
- },
- storageChange(row) {
- // console.log(row)
- },
- getAddress(row) {
- getCorpDetails({ id: row.corpId }).then(res => {
- this.balanceAmounts = res.data.data.balanceAmounts
- this.findObject(this.option.column, "arrivalAddress").dicData = res.data.data.corpsAddrList;
- })
- if (this.form.billType == "XS"){
- this.findObject(this.option.column, "sysNo").label = "销售单号";
- this.findObject(this.option.column, "srcOrderNo").label = "退款单号";
- }else if (this.form.billType == "XSTH"){
- this.findObject(this.option.column, "sysNo").label = "退款单号";
- this.findObject(this.option.column, "srcOrderNo").label = "销售单号";
- }
- },
- addRow() {
- this.$refs["form"].validate((valid, done) => {
- done();
- if (valid) {
- this.data.push({ $cellEdit: true, storageId: this.form.storageId })
- } else {
- return false;
- }
- });
- },
- 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) {
- remove(row.id).then(res => {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.data.splice(index, 1);
- });
- } else {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.data.splice(index, 1);
- }
- });
- },
- getPay(row) {
- // this.form = row;
- // this.data = row.orderItemsList;
- // this.settlementList = row.settlementList
- this.getDetail(row.id);
- },
- // 新建销售单
- newAddfun(){
- // delete this.form.id
- this.$refs.form.resetFields()
- this.form = {}
- this.$nextTick(() => {
- this.$refs.option2form.resetFields()
- });
- this.data = [];
- this.form.confirmStatus = null
- this.detailData = []
- this.detailData.status = 2
- this.settlementList = [];
- this.orderFilesList = [];
- this.balanceAmount = 0
- this.option.disabled = false;
- this.option2.disabled = false;
- this.$refs.crud.refreshTable();
- this.$refs.feeInfo.refreshTable();
- // // this.$refs.option2form.resetFields()这个做法其实是重置表单到初始值,不是清空表单,
- // // 当表单第一次在页面中渲染时所用的数据就是初始数据,如果修改对象的表单赋值没有放在nextTick中,
- // // 就会在表单渲染时就会将这个修改对象作为初始值,
- // // 所以出现无效了。
- // // 使用nextTick保证表单在第一次渲染时是空值就可以了。
- // this.xinjianfasle = true
- this.$forceUpdate()
- },
- //修改提交触发
- editCustomer() {
- this.$refs["form"].validate((valid, done) => {
- done();
- if (valid) {
- if (this.data.length == 0) {
- return this.$message.error('请添加一条商品信息');
- }
- if (this.settlementList.length > 0) {
- for (let i = 0; i < this.settlementList.length; i++) {
- if (!this.settlementList[i].id) {
- return this.$message.error(`请保存第${i + 1}行的费用明细`);
- }
- }
- }
- this.form.currentAmount = 0
- this.form.whetherIntegral = 0 //为了区分是否是积分支付还是会员卡支付
- this.loadingBtn = true;
- save({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList, orderFilesList: this.orderFilesList })
- .then(res => {
- this.$message.success("保存成功");
- this.form = res.data.data;
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList;
- this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
- this.detailData.status = 1
- this.option.disabled = true;
- this.option2.disabled = true;
- this.$refs.crud.refreshTable();
- this.$refs.feeInfo.refreshTable();
- this.getDetail(this.form.id);
- })
- .finally(() => {
- this.loadingBtn = false;
- });
- } else {
- return false;
- }
- });
- },
- fixSave() {
- this.$refs["form"].validate((valid, done) => {
- done();
- if (valid) {
- if (this.data.length == 0) {
- return this.$message.error('请添加一条商品信息');
- }
- if (this.settlementList.length > 0) {
- for (let i = 0; i < this.settlementList.length; i++) {
- if (!this.settlementList[i].id) {
- return this.$message.error(`请保存第${i + 1}行的费用明细`);
- }
- }
- }
- this.loadingBtn = true;
- fixSave({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList, orderFilesList: this.orderFilesList })
- .then(res => {
- this.$message.success("修改成功");
- this.form = res.data.data;
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList
- this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
- })
- .finally(() => {
- this.loadingBtn = false;
- });
- } else {
- return false;
- }
- });
- },
- submit() {
- this.$refs["form"].validate((valid, done) => {
- done();
- if (valid) {
- if (this.data.length == 0) {
- return this.$message.error('请添加一条商品信息');
- }
- if (this.settlementList.length > 0) {
- for (let i = 0; i < this.settlementList.length; i++) {
- if (!this.settlementList[i].id) {
- return this.$message.error(`请保存第${i + 1}行的费用明细`);
- }
- }
- }
- this.loadingBtn = true;
- this.form.currentAmount = 0
- submit({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList, orderFilesList: this.orderFilesList })
- .then(res => {
- this.$message.success("提交成功");
- this.form = res.data.data;
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList;
- this.orderFilesList = res.data.data.orderFilesList ? res.data.data.orderFilesList : [];
- // this.$emit("goBack");
- })
- .finally(() => {
- this.loadingBtn = false;
- });
- } else {
- return false;
- }
- });
- },
- revokeOrder() {
- this.$confirm('此操作将会撤销单子, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.loadingBtn = true;
- this.form.currentAmount = 0
- revoke({ ...this.form, billType: 'XS', tradeType: 'YPJ', orderItemsList: this.data, settlementList: this.settlementList })
- .then(res => {
- this.$message.success("撤销成功");
- this.form = res.data.data;
- this.data = res.data.data.orderItemsList;
- this.settlementList = res.data.data.settlementList
- this.openEdit()
- })
- .finally(() => {
- this.loadingBtn = false;
- });
- }).catch(() => {
- });
- },
- async saveColumn() {
- const inSave = await this.saveColumnData(
- this.getColumnName(212),
- this.optionList
- );
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.crud.doLayout();
- });
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- async resetColumn() {
- this.optionList = optionList;
- const inSave = await this.delColumnData(
- this.getColumnName(212),
- optionList
- );
- if (inSave) {
- this.$nextTick(() => {
- this.$refs.crud.doLayout();
- });
- this.getAllWorkDicts()
- this.$message.success("重置成功");
- this.$refs.crud.$refs.dialogColumn.columnBox = false;
- }
- },
- openEdit() {
- this.detailData.status = 2
- this.option = this.$options.data().option;
- this.option2 = this.$options.data().option2;
- this.$refs.crud.refreshTable();
- this.$refs.feeInfo.refreshTable();
- },
- //返回列表
- backToList() {
- this.$emit("goBack");
- }
- },
- };
- </script>
- <style lang="scss" scoped>
- .trading-form ::v-deep .el-form-item {
- margin-bottom: 8px !important;
- }
- ::v-deep .el-dialog__body {
- padding: 0px 20px 15px 20px;
- }
- ::v-deep .el-form-item__error {
- display: none !important;
- }
- .img-form ::v-deep .el-form-item {
- height: 150px;
- line-height: 150px;
- margin-bottom: 8px !important;
- }
- .img-form ::v-deep .avue-upload__icon {
- font-size: 20px;
- width: 150px;
- height: 150px;
- line-height: 150px;
- }
- ::v-deep .el-table .cell {
- padding: 0 2px !important;
- }
- ::v-deep .avue-crud .el-table .el-form-item__label {
- left: -1px;
- }
- .addressTabs {
- display: flex;
- justify-content: center;
- span {
- width: 100px;
- font-size: 18px;
- font-weight: 600;
- text-align: center;
- }
- }
- </style>
|