12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094 |
- <template>
- <view style="padding-top: 1rpx;">
- <u--form labelPosition="left" :labelStyle="{color: '#fd4b09'}" :model="form" ref="form" labelWidth="150rpx"
- style="margin-top: 10rpx;padding-bottom: 130rpx;">
- <view style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;">
- <u-cell-group :border="false">
- <u-cell :border="false" center title="基础信息" arrow-direction="down">
- <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
- </u-cell>
- </u-cell-group>
- <view style="padding: 0 10rpx;">
- <u-form-item label="客户名称" prop="cname" borderBottom @click="selectCustomer">
- <u-input v-model="form.corpsName" inputAlign="right" border="none" placeholder="请选择" disabled
- disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="送货地址" prop="cname" borderBottom>
- <u-input v-model="form.arrivalAddress" inputAlign="right" border="none" placeholder="请选择"
- :disabled="form.confirmStatus == 1" disabledColor="#ffffff">
- <template slot="suffix">
- <u-icon name="map" color="#fd4b09" @tap="getMap"></u-icon>
- </template>
- </u-input>
- </u-form-item>
- <u-form-item label="销售日期" prop="cname" borderBottom
- @click="filterAll(['businesDate','businesDate'])">
- <u-input v-model="form.businesDate" inputAlign="right" border="none" placeholder="请选择" disabled
- disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="送货日期" prop="cname" borderBottom
- @click="filterAll(['requiredDeliveryDate','requiredDeliveryDate'])">
- <u-input v-model="form.requiredDeliveryDate" inputAlign="right" border="none" placeholder="请选择"
- disabled disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="计划收款日期" labelWidth="190rpx" prop="cname" borderBottom
- @click="filterAll(['advanceCollectionDate','advanceCollectionDate'])">
- <u-input v-model="form.advanceCollectionDate" inputAlign="right" border="none" placeholder="请选择"
- disabled disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="销售单号" prop="cname" borderBottom>
- <u-input v-model="form.sysNo" border="none" inputAlign="right" placeholder="请输入" disabled
- disabledColor="#ffffff" />
- </u-form-item>
- </view>
- </view>
- <view
- style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
- <u-cell-group :border="false">
- <u-cell :border="false" center @click="selectProduct">
- <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
- <view slot="title">
- <view style="display: flex;">
- <view>产品列表({{form.orderItemsList.length}})</view>
- <u-icon v-if="form.confirmStatus == 0" name="plus-circle" color="#fd4b09" size="18"
- style="margin-left: 20rpx;"></u-icon>
- </view>
- </view>
- <view slot="value">
- <view style="font-size: 14rpx;">总金额¥<view
- style="display: initial;font-size: 28rpx;font-weight: bold">{{amountNumber.amount}}
- </view>
- </view>
- </view>
- <u-icon slot="right-icon" name="arrow-right"></u-icon>
- </u-cell>
- </u-cell-group>
- <view style="padding: 0 10rpx;">
- <view
- style="display: flex;font-size: 12rpx;text-align: center;padding: 10rpx 0;border-top: 1rpx solid #ccc;">
- <view>
- <view>销售总数量</view>
- <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.saleAll}}</view>
- </view>
- <view style="margin: 0 50rpx;">|</view>
- <view>
- <view>送货总数量</view>
- <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.deliveryAll}}</view>
- </view>
- <view style="margin: 0 50rpx;">|</view>
- <view>
- <view>总数</view>
- <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.saleAll}}</view>
- </view>
- </view>
- <view
- style="display: flex;font-size: 12rpx;text-align: center;padding: 10rpx 0;border-top: 1rpx solid #ccc;border-bottom: 1rpx solid #ccc;">
- <view>
- <view>成本</view>
- <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.cost?amountNumber.cost.toFixed(2):'0.00'}}</view>
- </view>
- <view style="margin: 0 50rpx;">|</view>
- <view>
- <view>毛利</view>
- <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.grossProfit?amountNumber.grossProfit.toFixed(2):'0.00'}}</view>
- </view>
- <view style="margin: 0 50rpx;">|</view>
- <view>
- <view>送货</view>
- <view style="font-size: 16rpx;font-weight: bold;">{{amountNumber.delivery}}</view>
- </view>
- </view>
- <u-cell v-for="(item,index) in form.orderItemsList" :key="index">
- <view slot="label">
- <!-- customStyle="margin-bottom: 10px" -->
- <u-row>
- <u-col span="2.9">
- <u--image :showLoading="true"
- :src="item.url?item.url:'../../../static/images/404.png'" width="80px"
- height="80px" radius="10">
- </u--image>
- </u-col>
- <u-col span="9.1">
- <view
- style="font-size: 36rpx;width: 530rpx;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
- {{item.cname}}
- </view>
- <view style="display: flex;justify-content: space-between;">
- <view style="color: #707070;">单价:¥{{item.price}}</view>
- <view style="color: #707070;">数量:{{item.storageInQuantity?parseInt(item.storageInQuantity):item.storageInQuantity}}</view>
- </view>
- <view style="display: flex;justify-content: space-between;">
- <view style="color: #707070;">金额:¥{{item.amount}}</view>
- <view v-if="form.confirmStatus == 0" style="color: #707070; color: red;"
- @click="deleteProduct(index)">
- <u-button type="error" size="mini" text="删除"></u-button>
- </view>
- </view>
- </u-col>
- </u-row>
- </view>
- </u-cell>
- </view>
- </view>
- <view
- style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
- <u-cell-group :border="false">
- <u-cell :border="false" center title="费用信息" arrow-direction="down">
- <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
- </u-cell>
- </u-cell-group>
- <view style="padding: 0 10rpx;">
- <!-- <u-form-item label="订单金额" prop="mailbox" borderBottom>
- <u-input v-model="form.purchaseAmount" inputAlign="right" border="none" placeholder="请输入"
- disabled disabledColor="#ffffff" />
- </u-form-item> -->
- <!-- <u-form-item label="优惠金额" prop="mailbox" borderBottom>
- <u-input v-model="form.thisUsedProfit" inputAlign="right" border="none" placeholder="请输入"
- :disabled="form.confirmStatus == 1" disabledColor="#ffffff" @change="calculationContract" />
- </u-form-item> -->
- <u-form-item label="订单金额" prop="mailbox" borderBottom>
- <u-input v-model="form.purchaseAmount" inputAlign="right" border="none" placeholder="请输入" disabled
- disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="优惠金额" prop="mailbox" borderBottom>
- <u-input v-model="form.thisUsedProfit" inputAlign="right" border="none" placeholder="请输入"
- :disabled="false" disabledColor="#ffffff" @change="calculationContract"/>
- </u-form-item>
- <u-form-item label="应收金额" prop="mailbox" borderBottom>
- <u-input v-model="form.orderAmount" inputAlign="right" border="none" placeholder="请输入" disabled
- disabledColor="#ffffff" />
- </u-form-item>
- <view v-if="form.confirmStatus == 1">
- <u-form-item label="已收金额" @click="filterAll(['settlmentAmount','settlmentAmount'])"
- prop="mailbox" borderBottom>
- <u-input v-model="form.settlmentAmount" inputAlign="right" border="none" placeholder="请输入"
- disabled disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="本次收款" prop="mailbox" borderBottom>
- <u-input type="number" clearable v-model="form.currentAmount" inputAlign="right"
- border="none" placeholder="请输入"
- :disabled="form.confirmStatus == 0 || (form.orderAmount - form.settlmentAmount) == 0"
- disabledColor="#ffffff" />
- </u-form-item>
- <u-form-item label="收款账户" prop="mailbox" borderBottom @click="filterAll(['account','account'])">
- <u-input v-model="form.account" inputAlign="right" border="none" placeholder="请选择" disabled
- disabledColor="#ffffff">
- <template slot="suffix" style="text-align: center;">
- <u-icon name="plus-circle" size="18" @click.native.stop="newCompany()"></u-icon>
- </template>
- </u-input>
- </u-form-item>
- <u-form-item label="收款单号" prop="mailbox" borderBottom>
- <u-input v-model="form.receiptNo" inputAlign="right" border="none" disabled
- disabledColor="#ffffff" />
- </u-form-item>
- </view>
- </view>
- </view>
- <view
- style="width: calc(96%);margin: 0 auto;background-color: #fff;border-radius: 20rpx;margin-top: 20rpx;">
- <u-cell-group :border="false">
- <u-cell :border="false" center title="图片信息" arrow-direction="down">
- <view slot="icon" style="width: 10rpx;height: 35rpx;background-color: #fd4b09;"></view>
- <view slot="value">
- <view v-if="form.confirmStatus == 1" @click.stop="saveAttachment"
- style="padding: 2rpx 20rpx;border:1rpx solid #FD4B09;border-radius: 100rpx;color: #FD4B09;">
- 保存
- </view>
- </view>
- </u-cell>
- </u-cell-group>
- <view style="padding: 0 10rpx;">
- <u-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple
- :maxCount="10"></u-upload>
- </view>
- </view>
- </u--form>
- <view style="width: 100%;position: fixed;bottom: 0;background-color: #fff;border-top: 1rpx solid #ccc;">
- <view style="width: 100%;display: flex;font-size: 24rpx;">
- <view
- style="width: 20%;display: grid;justify-items: center;padding: 10rpx 0;border-right: 1rpx solid #ccc;"
- @click="deleteDoc">
- <u-icon name="trash"></u-icon>
- <view>删除</view>
- </view>
- <view @click="copyDocument" style="width: 20%;display: grid;justify-items: center;">
- <u-icon name="file-text"></u-icon>
- <view>复制新增</view>
- </view>
- <view @click="conserve" v-if="form.confirmStatus == 0"
- style="width: 30%;background-color: #5ac725;display: grid;justify-items: center;">
- <u-icon name="edit-pen" color="#fff"></u-icon>
- <view style="color: #fff;">保存</view>
- </view>
- <view v-if="form.confirmStatus == 0" @click="submit(0)"
- style="width: 30%;background-color: #fd4b09;display: grid;justify-items: center;">
- <u-icon name="checkmark" color="#fff"></u-icon>
- <view style="color: #fff;">提交</view>
- </view>
- <view v-if="form.confirmStatus == 1" @click="submit(1)"
- style="width: 20%;background-color: #fd4b09;display: grid;justify-items: center;">
- <u-icon name="close" color="#fff"></u-icon>
- <view style="color: #fff;">撤销提交</view>
- </view>
- <view v-if="form.confirmStatus == 1" style="width: 40%;">
- <view @click="confirmReceipt" v-if="(form.orderAmount - form.settlmentAmount) > 0"
- style="background-color: #5ac725;display: grid;justify-items: center;height: 100%;">
- <u-icon name="checkmark" color="#fff"></u-icon>
- <view style="color: #fff;">确认收款</view>
- </view>
- <view v-else style="background-color: #b3b3b3;display: grid;justify-items: center;height: 100%;">
- <u-icon name="checkmark" color="#fff"></u-icon>
- <view style="color: #fff;">已全部收款</view>
- </view>
- </view>
- </view>
- </view>
- <view v-if="choice" class="mask" @touchmove.stop.prevent="moveHandle" @click="choice = !choice">
- <view class="choice">
- <view style="display: flex;;justify-content: right;margin-right: 5rpx;">
- <view
- style="width: 40rpx;height: 40rpx;background-color: #fff;border-radius: 10rpx;transform: rotate(45deg);margin-top: -8rpx;z-index: -1;">
- </view>
- </view>
- <view style="margin-top: -25rpx;z-index: 99;background-color: #fff;">
- <u-cell-group :border="false">
- <u-cell icon="edit-pen" :title="connected?'打印':'未连接'" @click.native.stop="connectingDevices"></u-cell>
- <u-cell icon="photo" title="保存图片" :border="false" @click.native.stop="generatePictures">
- </u-cell>
- </u-cell-group>
- </view>
- </view>
- </view>
- <u-datetime-picker :show="timeOpen" v-model="datetime" mode="date" @cancel="timeOpen = false"
- @confirm="confirmTiem"></u-datetime-picker>
- <u-picker :show="showOpen" :columns="columns" keyName="dictValue" @cancel="showOpen = false"
- @confirm="showPicker"></u-picker>
- </view>
- </template>
- <script>
- import {
- typeSave,
- removeFile,
- submitApp,
- remind,
- confirm,
- revoke,
- removeItem,
- removeId,
- copyOrder,
- collectPayment,
- saveAtta
- } from '@/api/views/sale/salesOrderDetails.js'
- import http from '@/http/api.js'
- import {
- clientId,
- clientSecret
- } from '@/common/setting'
- import {
- dateFormat
- } from '@/common/dateFormat'
- // #ifdef APP-PLUS
- const HanyinPlugin = uni.requireNativePlugin('Hanyin-Plugin'); //汉印
- import printConnect from "@/common/print.js"; //引入打印机模板文件
- let print;
- // #endif
- import {
- GET_REQUEST_DATA
- } from "@/store/gettersType.js";
- import {
- mapGetters,
- mapActions
- } from 'vuex';
- import {
- DX
- } from '@/common/dateFormat.js';
- export default {
- data() {
- return {
- form: {
- orderItemsList: []
- },
- datetime: Number(new Date()),
- timeOpen: false,
- fileList1: [],
- screen: [],
- showOpen: false,
- choice: false,
- columns: [],
- connected:false,
- amountNumber: {
- deliveryAll: 0,
- cost: 0,
- grossProfit: 0,
- delivery: 0,
- saleAll: 0,
- amount: 0
- }
- }
- },
- onLoad(data) {
- this.refresh(data.id)
- },
- computed: {
- ...mapGetters([GET_REQUEST_DATA])
- },
- onShow() {
- this.choice = false
- let this_ = this
- // #ifdef APP-PLUS
- HanyinPlugin.IsOpened(res => {
- this_.connected = res.state
- if(this_.GET_REQUEST_DATA.length == 0){
- this_.connected = false
- print = new printConnect({},1); //打印机连接
- }
- });
- // #endif
- },
- onNavigationBarButtonTap(e) {
- this.choice = !this.choice
- },
- methods: {
- //跳转连接设备
- connectingDevices() {
- if(this.connected){
- this.senBleLabel()
- }else{
- uni.$u.route('/pages/views/bluetooth/index', {
- data: JSON.stringify(this.form)
- });
- }
- },
- senBleLabel() {
- // if (!print) return;
- console.log(this.$Mock.printTemplate.pagConfig)
- this.$Mock.printTemplate.pagConfig = 0
- let data = []
- let i = 0
- for (let item of this.form.orderItemsList) {
- data.push({
- "top": Number(i * 40 + 90),
- "left": "0",
- "textAlign": "start",
- "width": "270",
- "fontSize": 9,
- "text": item.cname,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 110),
- "left": "140",
- "textAlign": "start",
- "width": "40",
- "fontSize": 8,
- "text": Number(item.storageInQuantity),
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 110),
- "left": "160",
- "textAlign": "start",
- "width": "50",
- "fontSize": 8,
- "text": item.price,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 110),
- "left": "210",
- "textAlign": "start",
- "width": "60",
- "fontSize": 8,
- "text": item.amount,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- i++
- }
- data.push({
- "top": Number(i * 40 + 90),
- "left": "20",
- "textAlign": "start",
- "width": "270",
- "fontSize": 9,
- "text": "合计:",
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 90),
- "left": "140",
- "textAlign": "start",
- "width": "40",
- "fontSize": 8,
- "text": this.amountNumber.saleAll,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 90),
- "left": "210",
- "textAlign": "start",
- "width": "60",
- "fontSize": 8,
- "text": this.form.orderAmount,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
-
- data.push({
- "top": Number(i * 40 + 110),
- "left": "20",
- "textAlign": "start",
- "width": "270",
- "fontSize": 9,
- "text": "产品合计:",
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 110),
- "left": "70",
- "textAlign": "start",
- "width": "70",
- "fontSize": 8,
- "text": this.amountNumber.amount,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 110),
- "left": "140",
- "textAlign": "start",
- "width": "60",
- "fontSize": 8,
- "text": "合计金额:",
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 110),
- "left": "190",
- "textAlign": "start",
- "width": "80",
- "fontSize": 8,
- "text": DX(this.amountNumber.amount),
- "type": "text",
- "fontWeight": "400",
- "height": "40"
- })
-
-
- data.push({
- "top": Number(i * 40 + 130),
- "left": "20",
- "textAlign": "start",
- "width": "270",
- "fontSize": 9,
- "text": "订货电话:" + this.form.clientAttn,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 150),
- "left": "20",
- "textAlign": "start",
- "width": "270",
- "fontSize": 9,
- "text": "制单人:" + this.form.client,
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- data.push({
- "top": Number(i * 40 + 150),
- "left": "140",
- "textAlign": "start",
- "width": "80",
- "fontSize": 8,
- "text": "收货人(签字):",
- "type": "text",
- "fontWeight": "400",
- "height": "20"
- })
- print.startPrint({
- SALES_SLIP: this.form.sysNo,
- CUSTOMER_NAME: this.form.corpsName,
- SALES_DATE: this.form.businesDate.slice(0, 10)
- }, {
- pageHeight: (this.form.orderItemsList.length * 40) / 3
- }, data);
- },
- generatePictures() {
- uni.$u.route('/pages/views/bluetooth/salesSlipTable', {
- data: JSON.stringify(this.form)
- });
- },
- //遮罩层禁止点击空方法
- moveHandle() {},
- newCompany() {
- uni.$u.route('/pages/views/product/createCompany', {
- code: "account",
- title: "收款账户"
- });
- },
- calculationContract() {
- let data = {
- purchaseAmount: this.form.purchaseAmount ? Number(this.form.purchaseAmount) : 0,
- thisUsedProfit: this.form.thisUsedProfit ? Number(this.form.thisUsedProfit) : 0
- }
- this.form.orderAmount = data.purchaseAmount - data.thisUsedProfit;
- this.form.currentAmount = this.form.orderAmount;
- },
- getMap() {
- let this_ = this
- uni.chooseLocation({
- success: function(res) {
- this_.$set(this_.form, "arrivalAddress", res.address)
- }
- });
- },
- copyDocument() {
- let form = {
- ...this.form,
- orderFilesList: this.fileList1
- }
- if (form.orderFilesList.length > 0) {
- form.orderFilesList.forEach(item => delete item.status)
- }
- let this_ = this
- uni.showModal({
- title: '提示',
- content: "是否确认复制新增",
- success: function(rest) {
- if (rest.confirm == true) {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- copyOrder(form).then(res => {
- uni.hideLoading();
- uni.showToast({
- icon: "none",
- title: '复制新增成功',
- mask: true
- });
- this_.form = res.data
- this_.fileList1 = res.data.orderFilesList
- this_.amountNumber = {
- deliveryAll: 0, //送货总数量
- cost: 0, //成本
- grossProfit: 0, //毛利
- delivery: 0, //送货
- saleAll: 0, //销售数量
- amount: 0
- }
- for (let item of this_.form.orderItemsList) {
- this_.amountNumber.saleAll += Number(item.storageInQuantity)
- this_.amountNumber.cost += Number(item.storageInQuantity) * Number(
- item.purchasePrice)
- this_.amountNumber.delivery += Number(item.actualQuantity)
- this_.amountNumber.deliveryAll += Number(item.actualQuantity)
- this_.amountNumber.amount += Number(item.amount)
- this_.amountNumber.grossProfit += Number(item.amount) - (item
- .purchasePrice ? Number(item.storageInQuantity) * Number(
- item.purchasePrice) : 0)
- }
- this.form.purchaseAmount = this.amountNumber.amount
- })
- }
- }
- })
- },
- deleteDoc() {
- if (this.form.id) {
- let this_ = this
- if (this_.form.confirmStatus == 1) {
- return uni.showToast({
- icon: "none",
- title: '禁止删除',
- mask: true
- });
- }
- uni.showModal({
- title: '提示',
- content: "是否确认删除",
- success: function(rest) {
- if (rest.confirm == true) {
- removeId({
- id: this_.form.id
- }).then(res => {
- uni.showToast({
- icon: "none",
- title: '删除成功',
- mask: true
- });
- setTimeout(function() {
- uni.navigateBack()
- }, 1000);
- })
- }
- }
- })
- } else {
- uni.showToast({
- icon: "none",
- title: '未保存',
- mask: true
- });
- }
- },
- deleteProduct(index) {
- let this_ = this
- if (this_.form.orderItemsList[index].id) {
- uni.showModal({
- title: '提示',
- content: "是否确认删除",
- success: function(rest) {
- if (rest.confirm == true) {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- removeItem({
- itemId: this_.form.orderItemsList[index].id
- }).then(res => {
- uni.hideLoading();
- uni.showToast({
- icon: "none",
- title: '删除成功',
- mask: true
- });
- this_.form.orderItemsList.splice(index, 1)
- }).catch(err => {
- uni.hideLoading();
- })
- }
- }
- })
- } else {
- this_.form.orderItemsList.splice(index, 1)
- }
- },
- //时间确认选择
- confirmTiem(e) {
- this.form[this.screen[1]] = dateFormat(new Date(e.value), "YYYY-MM-DD HH:mm:ss")
- this.timeOpen = false
- },
- // 下拉选择
- showPicker(e) {
- this.form[this.screen[1]] = e.value[0].dictValue
- this.showOpen = false
- },
- //集合筛选条件
- filterAll(screen) {
- if (screen[1] == "account") {
- if (this.form.confirmStatus == 0) {
- return uni.showToast({
- icon: "none",
- title: '禁止操作',
- mask: true
- });
- } else if ((this.form.orderAmount - this.form.settlmentAmount) == 0) {
- return uni.showToast({
- icon: "none",
- title: '禁止操作',
- mask: true
- });
- }
- } else {
- if (screen[1] !== "settlmentAmount") {
- if (this.form.confirmStatus == 1) {
- return uni.showToast({
- icon: "none",
- title: '禁止操作',
- mask: true
- });
- }
- }
- }
- this.screen = screen
- switch (screen[1]) {
- case "businesDate":
- this.timeOpen = true
- break;
- case "requiredDeliveryDate":
- this.timeOpen = true
- break;
- case "advanceCollectionDate":
- this.timeOpen = true
- break;
- case "account":
- this.$u.api.getWorkDicts('account').then(res => {
- this.columns = [res.data]
- this.showOpen = true
- })
- break;
- case "settlmentAmount":
- uni.$u.route('/pages/views/salesSlip/collectionList', this.form);
- break;
- }
- },
- refresh(id) {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- typeSave({
- id: id
- }).then(res => {
- this.form = res.data
- this.fileList1 = res.data.orderFilesList
- this.amountNumber = {
- deliveryAll: 0, //送货总数量
- cost: 0, //成本
- grossProfit: 0, //毛利
- delivery: 0, //送货
- saleAll: 0, //销售数量
- amount: 0
- }
- for (let item of this.form.orderItemsList) {
- this.amountNumber.saleAll += Number(item.storageInQuantity)
- this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
- this.amountNumber.delivery += Number(item.actualQuantity)
- this.amountNumber.deliveryAll += Number(item.actualQuantity)
- this.amountNumber.amount += Number(item.amount)
- this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
- .storageInQuantity) * Number(item.purchasePrice) : 0)
- }
- this.form.purchaseAmount = this.amountNumber.amount
- setTimeout(function() {
- uni.hideLoading();
- }, 500);
- })
- },
- //确认收款
- confirmReceipt() {
- let this_ = this
- let form = {
- ...this_.form,
- orderFilesList: this_.fileList1
- }
- if (form.orderFilesList.length > 0) {
- form.orderFilesList.forEach(item => delete item.status)
- }
- if (!form.currentAmount) {
- return uni.showToast({
- icon: "none",
- title: '本次收款金额不能为空',
- mask: true,
- duration: 2000
- });
- }
- if (!form.account) {
- return uni.showToast({
- icon: "none",
- title: '未选择收款账户',
- mask: true,
- duration: 2000
- });
- }
- uni.showModal({
- title: '是否确认收款',
- content: '本次收款金额' + form.currentAmount,
- success: function(rest) {
- if (rest.confirm == true) {
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- collectPayment(form).then(res => {
- uni.showToast({
- icon: "none",
- title: '收款成功',
- mask: true,
- duration: 2000
- });
- setTimeout(function() {
- uni.hideLoading();
- this_.refresh(res.data.id)
- }, 1000);
- })
- }
- }
- })
- },
- //保存附件
- saveAttachment() {
- let form = {
- pid: this.form.id,
- orderFilesList: this.fileList1
- }
- if (form.orderFilesList.length > 0) {
- form.orderFilesList.forEach(item => delete item.status)
- }
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- saveAtta(form).then(res => {
- uni.showToast({
- icon: "none",
- title: '保存成功',
- mask: true
- });
- let _this = this
- setTimeout(function() {
- uni.hideLoading();
- _this.refresh(res.data.id)
- }, 1000);
- })
- },
- //保存
- conserve() {
- let form = {
- ...this.form,
- orderFilesList: this.fileList1
- }
- if (form.orderFilesList.length > 0) {
- form.orderFilesList.forEach(item => delete item.status)
- }
- uni.showLoading({
- title: '加载中',
- mask: true
- });
- submitApp(form).then(res => {
- uni.showToast({
- icon: "none",
- title: '保存成功',
- mask: true
- });
- let _this = this
- setTimeout(function() {
- uni.hideLoading();
- _this.refresh(res.data.id)
- }, 1000);
- })
- },
- //提交
- submit(type) {
- let form = {
- ...this.form,
- orderFilesList: this.fileList1
- }
- let this_ = this
- uni.showLoading({
- title: '提交中',
- mask: true
- });
- if (type == 0) {
- remind(form).then(res => {
- uni.hideLoading();
- if (res.data) {
- uni.showModal({
- title: '提示',
- content: res.data,
- success: function(rest) {
- if (rest.confirm == true) {
- uni.showLoading({
- title: '提交中',
- mask: true
- });
- confirm(form).then(resth => {
- uni.showToast({
- icon: "none",
- title: '提交成功',
- mask: true
- });
- setTimeout(function() {
- // uni.hideLoading();
- this_.refresh(resth.data.id)
- }, 1000);
- })
- }
- }
- })
- } else {
- uni.showLoading({
- title: '提交中',
- mask: true
- });
- confirm(form).then(rest => {
- uni.showToast({
- icon: "none",
- title: '提交成功',
- mask: true
- });
- setTimeout(function() {
- uni.hideLoading();
- this_.refresh(rest.data.id)
- }, 1000);
- })
- }
- })
- } else if (type == 1) {
- revoke(form).then(res => {
- uni.showToast({
- icon: "none",
- title: '撤销成功',
- mask: true
- });
- setTimeout(function() {
- uni.hideLoading();
- this_.refresh(res.data.id)
- }, 1000);
- })
- }
- },
- //客户选择返回触发
- otherFun(customer) {
- this.form.corpsName = customer.cname
- this.form.corpId = customer.id
- },
- selectProduct() {
- if (this.form.confirmStatus == 0) {
- this.$u.route('/pages/views/salesSlip/selectProduct', this.form);
- }
- },
- //商品选择返回
- getProduct(dataList) {
- for (let item of dataList) {
- this.form.orderItemsList.push({
- ...item
- })
- }
- this.amountNumber = {
- deliveryAll: 0, //送货总数量
- cost: 0, //成本
- grossProfit: 0, //毛利
- delivery: 0, //送货
- saleAll: 0, //销售数量
- amount: 0
- }
- for (let item of this.form.orderItemsList) {
- this.amountNumber.saleAll += Number(item.storageInQuantity)
- this.amountNumber.cost += Number(item.storageInQuantity) * Number(item.purchasePrice)
- this.amountNumber.delivery += Number(item.actualQuantity)
- this.amountNumber.deliveryAll += item.actualQuantity ? Number(item.actualQuantity) : 0
- this.amountNumber.amount += Number(item.amount)
- this.amountNumber.grossProfit += Number(item.amount) - (item.purchasePrice ? Number(item
- .storageInQuantity) * Number(item.purchasePrice) : 0)
- }
- this.form.purchaseAmount = this.amountNumber.amount
- },
- selectCustomer() {
- this.$u.route('/pages/views/salesSlip/selectCustomer', {
- corpType: 'KH'
- });
- },
- // 新增图片
- async afterRead(event) {
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- let lists = [].concat(event.file)
- let fileListLen = this[`fileList${event.name}`].length
- lists.map((item) => {
- this[`fileList${event.name}`].push({
- ...item,
- status: 'uploading',
- message: '上传中'
- })
- })
- for (let i = 0; i < lists.length; i++) {
- const result = await this.uploadFilePromise(lists[i].url)
- let item = this[`fileList${event.name}`][fileListLen]
- this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
- status: 'success',
- sort: this.fileList1.length,
- fileName: JSON.parse(result).data.originalName,
- url: JSON.parse(result).data.link
- }))
- fileListLen++
- }
- },
- uploadFilePromise(url) {
- return new Promise((resolve, reject) => {
- let a = uni.uploadFile({
- url: http.config.baseURL +
- '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
- filePath: url,
- name: 'file',
- formData: {
- user: 'test'
- },
- header: {
- // 客户端认证参数
- 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
- clientSecret),
- 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
- },
- success: (res) => {
- setTimeout(() => {
- resolve(res.data)
- }, 1000)
- }
- });
- })
- },
- // 删除图片
- deletePic(event) {
- let this_ = this
- uni.showModal({
- title: '提示',
- content: '是否确认删除',
- success: function(rest) {
- if (rest.confirm == true) {
- if (this_[`fileList${event.name}`][event.index].id) {
- removeFile({
- ids: this_[`fileList${event.name}`][event.index].id
- }).then(res => {
- this_[`fileList${event.name}`].splice(event.index, 1)
- })
- } else {
- this_[`fileList${event.name}`].splice(event.index, 1)
- }
- }
- }
- })
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep .u-cell__body {
- padding: 20rpx 10rpx;
- }
- .choice {
- position: fixed;
- right: 10rpx;
- border-radius: 10rpx;
- padding: 0 10rpx 10rpx 10rpx;
- background-color: #fff;
- // #ifdef H5
- top: calc(var(--status-bar-height) + 44px + 20rpx);
- // #endif
- // #ifdef APP-PLUS
- top: 30rpx,
- // #endif
- }
- .mask {
- width: 100%;
- height: 100%;
- position: fixed;
- top: 0;
- bottom: 0;
- background-color: rgba(1, 1, 1, 0.3);
- }
- </style>
|