123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608 |
- <template>
- <div>
- <by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onDelete="onDelete" @onRefresh="resert"
- @resert="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab" @onChangeRow="onChangeRow"
- @pagination="pagination" @onReturnSmt="onReturnSmt2" @getSupplierModal="getSupplierModal"
- @printBefore="printBefore" @onReturn="onReturn">
- </by-bill>
- <SettingConfig ref="setForm" type="setCForm" title="出库单" />
- </div>
- </template>
- <script lang="ts">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import api from "@/api/order";
- import BusinessType from "./components/businessType.vue";
- import towInOne from "../warehousing/components/towInOne.vue";
- import stockLook from "./components/stockLook.vue";
- import SettingConfig from "../saleOrder/components/settingConfig.vue";
- import { add } from '@/benyun/utils/accuracy'
- import {getSingleData} from "@/api/omsOrder";
- @Component({ components: { SettingConfig } })
- export default class Outbound extends Vue {
- planDeliveryDate : any = null; //计划交货时间
-
- // 左边
- tabType : any = 'all';
- isAdd : any = false;
- baseInfo : any = {};
- isSubmit : any = false
- isChange : any = false
- dataId : any = ''
- // 右边
- supplierInfo : any = {} // 机构信息
- businessType : any = '' // 业务类型
- tableData : any = []
- timeNum = 0;
- calculateCount = 0;
- timer : any = null
- config : any = {
- attr: {
- activeName: 'all',
- calculateH: true
- },
- // 引单
- source: [
- {
- title: '销售订单',
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- {
- span: 6,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- },
- customTools: [
- {
- name: '引单出库', icon: 'el-icon-bottom', audit: [''], event: {
- click: () => {
- (this as any).citationOrder()
- }
- }
- },
- ]
- },
- table: {
- attr: {
- size: 'mini',
- seq: true,
- align: 'left',
- radio: true,
- triggerRowCheck: 'row',
- },
- columns: [
- {
- width: 144,
- title: '单据编号',
- field: 'orderNumber',
- },
- {
- width: 120,
- title: '收货人',
- field: 'consignee',
- },
- {
- width: 144,
- title: '财务编号',
- field: 'financeOrderId',
- },
- {
- width: 120,
- title: '联系方式',
- field: 'phone',
- },
- {
- width: 150,
- title: '计划交货时间',
- field: 'planDeliveryData',
- },
- {
- width: 150,
- title: '确定交货时间',
- field: 'affirmDeliveryData',
- },
- {
- width: 350,
- title: '交货地点',
- field: 'address',
- }
- ]
- }
- },
- ],
- // 单据
- bill: {
- tool: {
- tools: {
- save: true,
- return: true
- }
- },
- log: {
- request: {
- url: '/supply/supplyOutOrderOperateLog/page',
- method: 'GET'
- }
- },
- form: {
- attr: {
- size: 'medium',
- readonly: false,
- rules: {
- operator: [{
- required: true, message: '请输入经办人', trigger: 'blur'
- }],
- receivePhone: [{
- required: true, message: '请输入联系方式', trigger: 'blur'
- }],
- businessType: [{
- required: true, message: '请选择业务类型', trigger: 'change'
- }],
- }
- },
- columns: [
- [
- {
- span: 8,
- label: '单据编号',
- prop: 'outOrderNo',
- component: 'by-input',
- compConfig: {
- attr: {
- readonly: true
- },
- }
- },
- {
- span: 8,
- label: '经办人',
- prop: 'operator',
- component: 'by-input',
- },
- {
- span: 8,
- label: '收货人',
- prop: 'receive',
- component: 'by-input',
- },
- {
- span: 8,
- label: '收货地址',
- prop: 'receiveAddress',
- component: 'by-input',
- },
- {
- span: 8,
- label: '联系方式',
- prop: 'receivePhone',
- component: 'by-input',
- },
- {
- span: 8,
- label: '财务编号',
- prop: 'financeOrderId',
- component: 'by-input',
- compConfig: {
- attr: {
- readonly: true,
- },
- }
- },
- {
- span: 8,
- label: '业务类型',
- prop: 'businessType',
- component: BusinessType,
- },
- {
- span: 8,
- label: 'WMS编号',
- prop: 'wmsId',
- component: 'by-input',
- compConfig: {
- attr: {
- readonly: true,
- },
- }
- },
- ],
- [
- {
- span: 28,
- label: '备注',
- slot: true,
- prop: 'remark',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入备注',
- type: 'textarea'
- },
- }
- },
- ]
- ]
- },
- tableConfig: [
- {
- table: {
- attr: {
- size: 'mini',
- align: 'left',
- readonly: true,
- },
- columns:
- [{
- width: 200,
- title: '物料名称',
- field: 'materialName',
- fixed: 'left'
- },
- {
- width: 70,
- title: '库存查看',
- component: stockLook,
- },
- {
- width: 80,
- title: '财务编号',
- field: 'financeSuborderId',
- },
- {
- width: 200,
- title: '仓库,仓位',
- field: 'towInOne',
- component: towInOne,
- compConfig: {
- isSelect: true
- }
- },
- {
- width: 70,
- title: '单位',
- field: 'unit',
- },
- {
- width: 70,
- title: '单位编码',
- field: 'unitCode',
- },
- {
- width: 150,
- title: '批次号',
- field: 'batchNumber',
- component: 'by-input',
- },
- {
- width: 80,
- title: '库存',
- field: 'inventory',
- },
- {
- width: 90,
- title: '数量',
- field: 'number',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- defaultValue: 1,
- },
- }
- },
- {
- width: 80,
- title: '应出数量',
- field: 'deliveryNumber',
- },
- {
- width: 80,
- title: '出库数量',
- field: 'outNumber',
- },
- {
- width: 90,
- title: '单价',
- field: 'unitPrice',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- },
- }
- },
- // {
- // width: 80,
- // title: '优惠金额',
- // field: 'prePrice',
- // },
- {
- width: 90,
- title: '合计金额',
- field: 'totalPrice',
- },
- {
- width: 70,
- title: '操作',
- action: true,
- plugins: [{
- icon: 'el-icon-delete',
- name: '删除',
- audit: '',
- event: {
- click: (item : any) => {
- (this as any).changeTable(item)
- }
- }
- }]
- },
- ]
- }
- }
- ]
- },
- // 已提交
- smt: {
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- {
- span: 6,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- },
- customTools: [
- {
- name: '同步到财务系统', icon: 'el-icon-top', audit: [''], event: {
- click: () => {
- (this as any).syncSystem()
- }
- }
- },
- ]
- },
- table: {
- attr: {
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true,
- triggerRowCheck: 'row'
- },
- columns: [
- {
- width: 150,
- title: '单据编号',
- field: 'outOrderNo',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 150,
- title: '财务编号',
- field: 'financeOrderId',
- },
- {
- width: 150,
- title: 'WMS编号',
- field: 'wmsId',
- },
- {
- width: 120,
- title: '经办人',
- field: 'operator',
- },
- {
- width: 120,
- title: '收货人',
- field: 'receive',
- },
- {
- width: 250,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 100,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 70,
- title: '业务类型',
- field: 'businessType',
- },
- {
- width: 110,
- title: '操作',
- action: true,
- plugins: [{
- // icon: 'el-icon-edit',
- name: '查看',
- audit: '',
- event: {
- click: (e : any) => {
- (this as any).setReadonly(e)
- }
- }
- }, {
- name: '反提交',
- event: {
- click: (item : any) => (this as any).onReturnSmt(item)
- }
- }]
- }
- ]
- }
- },
- // 草稿箱
- draftsBox: {
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- {
- span: 6,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- smt: true,
- delete: true,
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true,
- triggerRowCheck: 'row'
- },
- columns: [
- {
- width: 150,
- title: '单据编号',
- field: 'outOrderNo',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 150,
- title: '财务编号',
- field: 'financeOrderId',
- },
- {
- width: 150,
- title: 'WMS编号',
- field: 'wmsId',
- },
- {
- width: 120,
- title: '经办人',
- field: 'operator',
- },
- {
- width: 120,
- title: '收货人',
- field: 'receive',
- },
- {
- width: 250,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 100,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 70,
- title: '业务类型',
- field: 'businessType',
- },
- {
- width: 110,
- title: '操作',
- action: true,
- plugins: [{
- icon: 'el-icon-edit',
- name: '编辑',
- audit: '',
- event: {
- click: (e : any) => {
- (this as any).openEdit(e)
- }
- }
- }, {
- name: '删除',
- event: {
- click: (item : any) => (this as any).doDelete2(item)
- }
- }]
- }
- ]
- }
- },
- // 综合
- all: {
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- {
- span: 6,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- },
- customTools: [
- {
- name: '引单出库', icon: 'el-icon-bottom', audit: [''], event: {
- click: () => {
- (this as any).outbound()
- }
- }
- },
- {
- name: '删除', icon: 'el-icon-delete', audit: [''], event: {
- click: () => {
- (this as any).onDelete('all')
- }
- }
- },
- {
- name: '同步到财务系统', icon: 'el-icon-top', audit: [''], event: {
- click: () => {
- (this as any).syncSystem()
- }
- }
- },
- {
- name: '参数配置', icon: 'el-icon-setting', audit: [''], event: {
- click: () => {
- (this as any).configuration()
- }
- }
- },
- ]
- },
- table: {
- attr: {
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true,
- triggerRowCheck: 'row',
- height: "620"
- },
- columns: [
- {
- width: 150,
- title: '单据编号',
- field: 'outOrderNo',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 150,
- title: '财务编号',
- field: 'financeOrderId',
- },
- {
- width: 150,
- title: 'WMS编号',
- field: 'wmsId',
- },
- {
- width: 120,
- title: '经办人',
- field: 'operator',
- },
- {
- width: 120,
- title: '收货人',
- field: 'receive',
- },
- {
- width: 250,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 100,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 70,
- title: '业务类型',
- field: 'businessType',
- },
- {
- width: 90,
- title: '操作',
- action: true,
- plugins: [{
- name: '查看',
- audit: '',
- event: {
- click: (e : any) => {
- (this as any).openEdit(e)
- }
- }
- }, {
- name: '删除',
- event: {
- click: (item : any) => (this as any).doDelete2(item)
- }
- }]
- }
- ]
- }
- },
- // 回收站
- recycleBin: {
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- {
- span: 6,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- size: 'mini',
- align: 'left',
- },
- columns: [
- {
- width: 150,
- title: '单据编号',
- field: 'outOrderNo',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 150,
- title: '财务编号',
- field: 'financeOrderId',
- },
- {
- width: 150,
- title: 'WMS编号',
- field: 'wmsId',
- },
- {
- width: 120,
- title: '经办人',
- field: 'operator',
- },
- {
- width: 120,
- title: '收货人',
- field: 'receive',
- },
- {
- width: 250,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 100,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 70,
- title: '业务类型',
- field: 'businessType',
- },
- {
- width: 90,
- title: '操作',
- action: true,
- plugins: [{
- name: '查看',
- audit: '',
- event: {
- click: (e : any) => {
- (this as any).openEdit(e)
- }
- }
- }]
- }
- ]
- }
- }
- }
- created() {
- this.timer = setInterval(() => {
- this.getDataList();
- this.initTable();
- }, 500)
- }
- // 计算高度
- initTable() {
- if (!this.$refs.bill) {
- this.calculateCount++;
- if (this.calculateCount > 5) return;
- setTimeout(() => {
- this.initTable()
- }, 500)
- return
- }
- this.config.smt.table.attr.height = window.innerHeight - 300;
- this.config.draftsBox.table.attr.height = window.innerHeight - 300;
- this.config.all.table.attr.height = window.innerHeight - 300;
- this.config.recycleBin.table.attr.height = window.innerHeight - 300;
- (this as any).$refs.bill.$refs.all.$refs.table.recalculate();
- }
- //打印前数据修改
- printBefore(params : any) {
- params.templateId = 12;
- let value = (this.$refs.bill as any).getBillFormValue();
- if (value) {
- let data : any = {};
- data.orderNumber = value.orderNumber;
- data.operator = value.operator;
- data.businessType = value.businessType;
- data.financeOrderId = value.financeOrderId;
- data.wmsId = value.wmsId;
- data.remark = value.remark;
- data.receivePhone = value.receivePhone;
- data.receiveAddress = value.receiveAddress;
- data.outOrderNo = value.outOrderNo;
- data.receive = value.receive;
- data.suborderList = [];
- if (value.suborderList) {
- data.totalNumber = 0;//总数量
- data.totalDeliveryNumber = 0; //总应出数量
- data.totalPri = 0;//总计金额
- data.totalOutNumber = 0; //总出库数量
- for (const item of value.suborderList) {
- let obj : any = {};
- obj.materialName = item.materialName;
- obj.financeSuborderId = item.financeSuborderId;
- obj.storehouseName = item.storehouseName;
- obj.storingLocationName = item.storingLocationName;
- obj.number = item.number;
- obj.deliveryNumber = item.deliveryNumber;
- obj.outNumber = item.outNumber;
- // obj.prePrice = item.prePrice;
- obj.unitPrice = item.unitPrice;
- obj.totalPrice = item.totalPrice;
- data.suborderList.push(obj);
- if (Number(item.number)) {
- data.totalNumber = add(data.totalNumber, Number(item.number))
- }
- if (Number(item.deliveryNumber)) {
- data.totalDeliveryNumber = add(data.totalDeliveryNumber, Number(item.deliveryNumber))
- }
- if (Number(item.totalPrice)) {
- data.totalPri = add(data.totalPri, Number(item.totalPrice));
- }
- if (Number(item.outNumber)) {
- data.totalOutNumber = add(data.totalOutNumber, Number(item.outNumber));
- }
- }
- }
- params.templateData = data;
- }
- }
- // 参数配置
- configuration() {
- (this as any).$refs.setForm.openSetting();
- }
- // 引单
- citationOrder() {
- let parentData : any = (this as any).$refs.bill.getSourceTableSelectData(0);
- if (parentData.length <= 0) return this.$message.warning('请选择引单数据');
- let loading = this.$loading({ target: '.main-container' });
- api.single({ id: parentData[0].id }, 'supplyPurchaseOrder').then((res : any) => {
- if (res.code === 200) {
- parentData = res.data ? [res.data] : parentData;
- // console.log(parentData);
- parentData = parentData.map((item : any) => {
- item.receiveAddress = item.address
- item.receive = item.consignee
- item.receivePhone = item.phone
- const { financeOrderId, ...newData } = item
- return newData
- })
- let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
- if (billConfig.tableConfig[0].table.columns.at(-1).title != '操作') {
- billConfig.tableConfig[0].table.columns.push({
- width: 90,
- title: '操作',
- action: true,
- plugins: [{
- icon: 'el-icon-delete',
- name: '删除',
- audit: '',
- event: {
- click: (item : any) => {
- (this as any).changeTable(item)
- }
- }
- }]
- })
- };
- parentData[0].suborderList = parentData[0].suborderList.filter((v : any) => (v.number - v.outNumber) > 0);
- parentData[0].suborderList.map((v : any) => {
- v.deliveryNumber = v.number - v.outNumber;
- if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
- });
- parentData[0].operator = (this as any).$store.getters.userInfo.userName;
- this.tableData = parentData[0].suborderList;
- billConfig.tool.tools = { save: true, smt: true };
- // console.log('this.tableData ==> ', this.tableData);
- this.isAdd = true;
- (this.$refs.bill as any).showTab = 'bill';
- loading.close();
- setTimeout(() => {
- (this.$refs.bill as any).setBillConfig(billConfig);
- (this.$refs.bill as any).setBillFormValue(parentData[0]); // 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(parentData[0].suborderList, 0);// 设置第1张单据表格数据
- }, 0)
- } else loading.close();
- }).catch(() => loading.close());
- }
- // 获取机构数据
- getSupplierModal(e : any) {
- this.supplierInfo = e;
- }
- // 监听表格数据变化
- onChangeRow(e : any) {
- this.isChange = true;
- this.isSubmit = false;
- // e.prePrice = e.prePrice ? e.prePrice : 0;
- e.realityPrice = parseFloat((e.number * e.unitPrice).toFixed(2));
- e.totalPrice = e.realityPrice;
- // e.totalPrice = e.realityPrice - e.prePrice;
- }
- // 获取当前时间
- getNowDate() {
- let date = new Date();
- let years : any = date.getFullYear();
- let months : any = date.getMonth() + 1;
- let days : any = date.getDate();
- let hours : any = date.getHours();
- let minutes : any = date.getMinutes();
- let seconds : any = date.getSeconds();
- months = months < 10 ? '0' + months : months;
- days = days < 10 ? '0' + days : days;
- hours = hours < 10 ? '0' + hours : hours;
- minutes = minutes < 10 ? '0' + minutes : minutes;
- seconds = seconds < 10 ? '0' + seconds : seconds;
- return `${years}-${months}-${days} ${hours}:${minutes}:${seconds}`;
- }
- // 同步出库单到财务系统
- syncSystem() {
- let selectData = (this as any).$refs.bill.getTableSelectData(this.tabType);
- if (selectData.length > 0) {
- if (selectData.length > 1) return this.$message.warning('只能同步一条数据');
- if (selectData[0].financeOrderId) return this.$message.warning('此数据已同步到财务系统');
- this.$confirm('确定同步订单吗', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.addOutStock({ ids: selectData[0].id}).then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('同步订单成功');
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消同步订单'));
- } else this.$message.warning('请选择同步数据');
- }
- // 保存
- onSave() {
- // console.log('保存 ==>', this.tabType);
- (this as any).$refs.bill.$refs.billForm.validate().then(() => {
- let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
- // 子表数据
- query.purchaseOrderId = query.id;
- query.suborderList = (this.$refs.bill as any).getBillTableData(0);
- if (query.suborderList.length > 0) {
- for (let v of query.suborderList) {
- if (!v.unitPrice || v.unitPrice <= 0) return this.$message.warning('请输入正确物料单价');
- if (v.deliveryNumber < v.number) return this.$message.warning('数量不能大于应出数量');
- if (v.number > v.inventory) return this.$message.warning('出库数量不能大于库存数量');
- if (v.totalPrice <= 0) return this.$message.warning('合计金额不能为负数');
- v.taskOrderId = query.id;
- v.purchaseSuborderId = v.id;
- }
- } else return this.$message.warning('此单出库的物料数量为0,不能保存');
- // 表格删除
- query.suborderList.map((v : any, i : any) => {
- if (v.isDeleted === 1 && !v.id) {
- query.suborderList.splice(i, 1)
- }
- });
- query.financeOrderId = "";
- // console.log('出库参数query ==> ', query);
- let loading = this.$loading({ target: '.main-container' });
- if (this.isAdd) {
- query.suborderList.map((v : any) => {
- delete v.id;
- });
- delete query.id;
- query.financeType = 'kingdee';
- api.outbound(query, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.isAdd = false;
- this.isChange = false;
- this.isSubmit = true;
- this.$message.success('保存成功');
- this.dataId = res.data;
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- } else {
- query.submitState = 0;
- api.updateList(query, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('保存成功');
- this.isChange = false;
- this.isSubmit = true;
- } else this.$message.error(res.msg);
- }).catch(() => loading.close());
- };
- }).catch(() => {});
- }
- // 切换tab栏
- clickTab(e : any) {
- // console.log('切换tab ==> ', e);
- this.tabType = e;
- (this.$refs.bill as any).showTab = e;
- // submitState: 提交状态
- if (e === 'source') {
- // this.config.source[0].table.attr.height = window.innerHeight - 200;
- // (this as any).$refs.bill.$refs.source_0[0].$refs.table.recalculate();
- this.getCitationList({})
- }; // 引单出库
- if (e === 'all') this.getPageList({}, 'all'); // 草稿箱数据
- if (e === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
- if (e === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
- if (e === 'recycleBin') this.getSelectDeleteList({}); // 回收站数据
- if (e === 'bill') {
- let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
- billConfig.tool.tools = {};
- billConfig.tool.customTools = [];
- (this.$refs.bill as any).setBillConfig(billConfig);
- }
- }
- // 出库打开引单
- outbound() {
- this.clickTab('source');
- }
- // 打开编辑
- openEdit(e : any) {
- e = e.row ? e.row : e;
- let loading = this.$loading({ target: '.main-container' });
- api.single({ id: e.id }, 'supplyOutOrder').then((res : any) => {
- if (res.code === 200) {
- let parentData = res.data ? res.data : e;
- this.baseInfo = parentData;
- if (this.tabType === 'all' || this.tabType === 'draftsBox') {
- if (parentData.submitState === 1) {
- loading.close();
- return this.setReadonly(parentData)
- }
- let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
- if (billConfig.tableConfig[0].table.columns.at(-1).title != '操作') {
- billConfig.tableConfig[0].table.columns.push({
- width: 90,
- title: '操作',
- action: true,
- plugins: [{
- icon: 'el-icon-delete',
- name: '删除',
- audit: '',
- event: {
- click: (item : any) => {
- (this as any).changeTable(item)
- }
- }
- }]
- })
- };
- console.log(billConfig.tableConfig[0].table.columns)
- billConfig.tableConfig[0].table.columns[6] = {
- width: 150,
- title: '批次号',
- field: 'batchNumber',
- component: 'by-input',
- }
- billConfig.tableConfig[0].table.columns[8] = {
- width: 120,
- title: '数量',
- field: 'number',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- defaultValue: 1,
- },
- }
- };
- billConfig.tableConfig[0].table.columns[11] = {
- width: 90,
- title: '单价',
- field: 'unitPrice',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- },
- }
- };
- billConfig.tool.tools = { return: true, save: true, smt: true };
- // 查销售订单数据
- if(e.purchaseOrderId){
- api.single({ id: e.purchaseOrderId }, 'supplyPurchaseOrder').then((val : any) => {
- if (val.code === 200) {
- parentData.suborderList.map((v : any, i : any) => {
- v.outNumber = val.data.suborderList[i].outNumber;
- });
- let data : any = parentData.suborderList;
- let array : any = [];
- data.map((v : any) => {
- v.deliveryNumber = v.number - v.outNumber;
- if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
- v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
- array.push({
- storidId: v.storingLocationId,
- skuid: v.materialSku,
- })
- });
- // 查库存
- api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
- if (res.code === 200) {
- let newData : any = [];
- res.data.map((v : any, i : any) => {
- newData.push(Object.assign(data[i], v))
- })
- this.tableData = newData;
- (this.$refs.bill as any).setBillConfig(billConfig);
- (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
- this.isAdd = false;
- this.dataId = '';
- (this.$refs.bill as any).showTab = 'bill';
- loading.close();
- } else loading.close();
- }).catch(() => loading.close());
- } else loading.close();
- }).catch(() => loading.close());
- }else{
- let data : any = parentData.suborderList;
- let array : any = [];
- data.map((v : any) => {
- v.deliveryNumber = v.number;
- // if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
- v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
- array.push({
- storidId: v.storingLocationId,
- skuid: v.materialSku,
- })
- });
- // 查库存
- api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
- if (res.code === 200) {
- let newData : any = [];
- res.data.map((v : any, i : any) => {
- newData.push(Object.assign(data[i], v))
- })
- this.tableData = newData;
- (this.$refs.bill as any).setBillConfig(billConfig);
- (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
- this.isAdd = false;
- this.dataId = '';
- (this.$refs.bill as any).showTab = 'bill';
- loading.close();
- } else loading.close();
- }).catch(() => loading.close());
- }
- } else {
- loading.close();
- this.setReadonly(parentData);
- };
- }
- }).catch(() => loading.close());
- }
- // 设置只读
- setReadonly(e : any) {
- let parentData : any = e;
- let loading = this.$loading({ target: '.main-container' });
- let readonly = (this as any).$lodash.cloneDeep(this.config.bill);
- readonly.form.attr.readonly = true; // 设置只读
- readonly.tool.tools = { return: true, };
- if (this.tabType != 'recycleBin') {
- if (parentData.submitState === 1) readonly.tool.tools = { return: true, returnSmt: true, print: true };
- }
- readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
- readonly.tableConfig[0].table.columns[6] = {
- width: 150,
- title: '批次号',
- field: 'batchNumber',
- };
- readonly.tableConfig[0].table.columns[8] = {
- width: 120,
- title: '数量',
- field: 'number',
- };
- readonly.tableConfig[0].table.columns[11] = {
- width: 90,
- title: '单价',
- field: 'unitPrice',
- };
- api.single({ id: e.purchaseOrderId }, 'supplyPurchaseOrder').then((val : any) => {
- if (val.code === 200) {
- // parentData.suborderList.map((v : any, i : any) => {
- // v.prePrice = val.data.suborderList[i].prePrice;
- // });
- let data = parentData.suborderList;
- let array : any = [];
- data.map((v : any) => {
- v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
- array.push({
- storidId: v.storingLocationId,
- skuid: v.materialSku,
- })
- });
- // 查库存
- api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
- if (res.code === 200) {
- let newData : any = []
- res.data.map((v : any, i : any) => {
- newData.push(Object.assign(data[i], v))
- })
- this.tableData = newData;
- (this.$refs.bill as any).setBillConfig(readonly);
- (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
- this.isAdd = false;
- loading.close();
- (this.$refs.bill as any).showTab = 'bill';
- } else loading.close();
- }).catch(() => loading.close());
- } else loading.close();
- }).catch(() => loading.close());
- }
- // 工具栏提交
- onSmt(e : any) {
- if (e === 'draftsBox') {
- let selectData = (this.$refs.bill as any).getTableSelectData('draftsBox'); // 获取表格选中数据
- if (selectData.length <= 0) return this.$message.warning('请选择提交数据');
- if (selectData.length > 1) return this.$message.warning('只能提交一条数据');
- this.$confirm('确定提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.submitTo({ id: selectData[0].id }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('提交成功');
- this.clickTab('draftsBox');
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消提交'));
- } else {
- if (this.isAdd) return this.$message.warning('新增数据必须先保存才能提交');
- // console.log('isChange ==> ', this.isChange);
- // console.log('isSubmit ==> ', this.isSubmit);
- if (this.isSubmit) {
- this.$confirm('确定提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let id = this.dataId ? this.dataId : this.baseInfo.id;
- let loading = this.$loading({ target: '.main-container' });
- api.submitTo({ id: id }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('提交成功');
- this.isSubmit = false;
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消提交'));
- } else {
- // 表单旧数据
- let oldbillForm : any = (this as any).$lodash.cloneDeep(this.baseInfo);
- if (oldbillForm.suborderList) delete oldbillForm.suborderList;
- oldbillForm = JSON.stringify(oldbillForm);
- // 表单新数据
- let newBillForm : any = (this as any).$refs.bill.getBillFormValue();
- if (newBillForm.suborderList) delete newBillForm.suborderList;
- newBillForm = JSON.stringify(newBillForm);
- // 表格旧数据
- this.baseInfo.suborderList.map((v : any) => {
- if (v._X_ROW_KEY) delete v._X_ROW_KEY;
- });
- let oldData : any = JSON.stringify(this.baseInfo.suborderList);
- // 表格新数据
- let newData : any = JSON.stringify((this as any).$refs.bill.getBillTableData(0));
- // 数据有变进保存
- if (this.isChange || oldbillForm != newBillForm || oldData != newData) {
- return this.$message.warning('数据变更必须先保存再提交');
- } else {
- this.$confirm('确定提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.submitTo({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('提交成功');
- this.dataId = '';
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消提交'));
- }
- }
- }
- }
- // 操作反提交
- onReturnSmt(e : any) {
- // console.log('反提交 ==>', e);
- this.$confirm('确定反提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.cancelSubmission({ id: e.id }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('反提交成功');
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消反提交'));
- }
- // 工具栏反提交
- onReturnSmt2() {
- // console.log('工具栏反提交 ==>', this.baseInfo);
- this.$confirm('确定反提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.cancelSubmission({ id: this.baseInfo.id }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('反提交成功');
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消反提交'));
- }
- // 初始化
- getDataList() {
- if (!this.$refs.bill) {
- if (this.timeNum > 5) {
- clearInterval(this.timer)
- }
- this.timeNum++;
- return
- }
- clearInterval(this.timer)
- this.getPageList({}, 'all'); // 综合数据
- }
- // 获取引单分页数据
- getCitationList(query : any) {
- query.status = 0
- let loading = this.$loading({ target: '.main-container' });
- api.pageList(query, 'supplyPurchaseOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- (this.$refs.bill as any).setSourceTableData(0, res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.bill as any).setSourcePage(0, page);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }
- // 获取分页数据
- getPageList(query : any, type : any) {
- let data = (this.$refs.bill as any).getTablePage(this.tabType);
- query.pageNo = data.pageNo;
- query.pageSize = data.pageSize;
- let loading = this.$loading({ target: '.main-container' });
- api.pageList(query, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- (this.$refs.bill as any).setTabTableValue(type, res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.bill as any).setTablePage(type, page);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }
- // 分页
- pagination(e : any) {
- // console.log('分页 ==> ', e);
- if (e.type === 'source_0') {
- let query : any = (this as any).$refs.bill.$refs.source_0[0].getSearchValue();
- query.pageNo = e.page.pageNum;
- query.pageSize = e.page.pageSize;
- this.getCitationList(query);
- } else {
- let query : any = (this as any).$refs.bill.getSearchValue(e.type);
- query.pageNo = e.page.pageNum;
- query.pageSize = e.page.pageSize;
- let loading = this.$loading({ target: '.main-container' });
- if (e.type === 'recycleBin') {
- api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- } else {
- api.pageList(query, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }
- }
- }
- // 回收站数据
- getSelectDeleteList(query : any) {
- let data = (this.$refs.bill as any).getTablePage(this.tabType);
- query.pageNo = data.pageNo;
- query.pageSize = data.pageSize;
- let loading = this.$loading({ target: '.main-container' });
- api.selectDeleteList(query, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
- let page = {
- pageNo: res.data.current, //当前页
- pageSize: res.data.size, //每页条数
- total: res.data.total //总条数
- };
- (this.$refs.bill as any).setTablePage('recycleBin', page)
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }
- // 返回
- onReturn() {
- this.clickTab(this.tabType);
- }
- // 搜索
- search(parames : any) {
- // console.log('搜索 ==> ', parames);
- let query = parames.value;
- if (parames.type === 'source_0') {
- this.getCitationList(query); // 引单数据
- } else {
- if (parames.type === 'recycleBin') {
- this.getSelectDeleteList(query); // 回收站分页数据
- } else {
- if (parames.type === 'draftsBox') query.submitState = 0;// 草稿箱数据
- if (parames.type === 'smt') query.submitState = 1; // 已提交数据
- this.getPageList(query, parames.type) // 获取分页数据
- }
- }
- }
- // 刷新/重置
- resert(e : any) {
- let data : any = e.type ? e.type : e;
- // console.log('刷新/重置 ==> ', data);
- if (data === 'source_0') {
- (this as any).$refs.bill.$refs.source_0[0].clearSearch();
- this.getCitationList({}); // 引单数据
- } else {
- (this as any).$refs.bill.$refs[data].clearSearch();
- if (data === 'all') this.getPageList({}, 'all'); // 综合数据
- if (data === 'draftsBox') this.getPageList({ submitState: 0 }, 'draftsBox'); // 草稿箱数据
- if (data === 'smt') this.getPageList({ submitState: 1 }, 'smt'); // 已提交数据
- if (data === 'recycleBin') this.getSelectDeleteList({}) // 回收站数据
- }
- }
- // 单据表格删除
- changeTable(item : any) {
- this.$confirm('确定删除吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let data = (this.$refs.bill as any).getBillTableData(0);
- let i = -1;
- let j = -1;
- for (const v of data) {
- i++;
- if (v.materialSku == item.materialSku) {
- break
- }
- };
- // console.log(this.tableData);
- for (const v of this.tableData) {
- j++;
- if (v.materialSku == item.materialSku && item.isDeleted === 0) {
- break
- }
- };
- this.tableData[j].isDeleted = 1;
- data.splice(i, 1);
- (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
- this.$message.success('删除成功');
- }).catch(() => this.$message.info('已取消删除'));
- }
- // 工具栏删除
- onDelete(e : any) {
- let selectData = (this.$refs.bill as any).getTableSelectData(e)
- let ids = '';
- if (selectData.length > 0) {
- selectData.map((v : any) => {
- ids += v.id + ','
- })
- } else return this.$message({ type: 'warning', message: '请选择删除数据' })
- ids = ids.slice(0, ids.length - 1);
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.deleteList({ ids: ids }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('删除成功');
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消删除'));
- }
- // 操作删除
- doDelete2(item : any) {
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- let loading = this.$loading({ target: '.main-container' });
- api.deleteList({ ids: item.id }, 'supplyOutOrder').then((res : any) => {
- loading.close();
- if (res.code === 200) {
- this.$message.success('删除成功');
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- }).catch(() => loading.close());
- }).catch(() => this.$message.info('已取消删除'));
- }
- }
- </script>
|