12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382 |
- <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">
- </by-bill>
- <!-- 选择物料 -->
- <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
- </div>
- </template>
- <script lang="ts">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import api from "@/api/order";
- import productModal from "../orderTask/components/productModal.vue";
- import BusinessType from "../warehousing/components/businessType.vue";
- import towInOne from "../warehousing/components/towInOne.vue";
- @Component({ components: { productModal } })
- export default class OrderTask extends Vue {
- // 左边
- tabType : any = 'all';
- isAdd : any = false;
- baseInfo : any = {};
- isSubmit : any = false
- isChange : any = false
- dataId : any = ''
- // 右边
- supplierInfo : any = {} // 机构信息
- businessType : any = '' // 业务类型
- tableData : any = []
- timeNum = 0;
- timer : any = null
- config : any = {
- attr: {
- activeName: 'all'
- },
- // 引单
- 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: {
- height: 600,
- size: 'mini',
- seq: true,
- align: 'left',
- radio: true,
- triggerRowCheck: 'row'
- },
- columns: [
- {
- width: 144,
- title: '单据编号',
- field: 'orderNumber',
- },
- {
- width: 120,
- title: '收货人',
- field: 'consignee',
- },
- {
- width: 120,
- title: '联系方式',
- field: 'phone',
- },
- {
- width: 150,
- title: '计划交货时间',
- field: 'planDeliveryData',
- },
- {
- width: 150,
- title: '确定交货时间',
- field: 'affirmDeliveryData',
- },
- {
- width: 150,
- title: '交货地点',
- field: 'address',
- }
- ]
- }
- },
- ],
- // 单据
- bill: {
- tool: {
- tools: {
- save: true,
- }
- },
- log: {
- request: {
- url: '/supply/supplyOutOrderOperateLog/page',
- method: 'GET'
- }
- },
- form: {
- attr: {
- size: 'medium',
- readonly: false,
- rules: {
- operator: [{
- 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: 'WMS编号',
- prop: 'wmsId',
- component: 'by-input',
- },
- {
- span: 8,
- label: '业务类型',
- prop: 'businessType',
- component: BusinessType,
- },
- ],
- [
- {
- span: 28,
- label: '备注',
- slot: true,
- prop: 'remark',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入备注',
- type: 'textarea'
- },
- }
- },
- ]
- ]
- },
- tableConfig: [
- {
- table: {
- attr: {
- size: 'mini',
- height: 500,
- align: 'left',
- readonly: true,
- },
- columns:
- [{
- width: 278,
- title: '物料名称',
- field: 'materialName',
- },
- {
- width: 200,
- title: '仓库,仓位',
- field: 'towInOne',
- component: towInOne,
- compConfig: {
- isSelect: true
- }
- },
- {
- width: 100,
- title: '单位',
- field: 'unit',
- },
- {
- width: 100,
- title: '库存',
- field: 'inventory',
- },
- {
- width: 100,
- title: '数量',
- field: 'number',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- defaultValue: 1,
- },
- }
- },
- {
- width: 100,
- title: '应出数量',
- field: 'deliveryNumber',
- },
- {
- width: 110,
- title: '出库数量',
- field: 'outNumber',
- },
- {
- width: 100,
- title: '单价',
- field: 'unitPrice',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- },
- }
- },
- {
- width: 100,
- title: '优惠金额',
- field: 'prePrice',
- },
- {
- width: 100,
- title: '合计金额',
- field: 'totalPrice',
- },
- {
- width: 90,
- 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: 'outOrderNo',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '财务系统单据',
- prop: 'financeOrderId',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入财务系统单据',
- clearable: true
- },
- },
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- 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: 120,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 120,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 120,
- 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: 'outOrderNo',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '财务系统单据',
- prop: 'financeOrderId',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入财务系统单据',
- clearable: true
- },
- },
- },
- ],
- ]
- },
- tool: {
- tools: {
- smt: true,
- delete: true,
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- 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: 120,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 120,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 120,
- 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: 'outOrderNo',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '财务系统单据',
- prop: 'financeOrderId',
- 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).outbound()
- }
- }
- },
- {
- name: '删除', icon: 'el-icon-delete', audit: [''], event: {
- click: () => {
- (this as any).onDelete('all')
- }
- }
- }
- ]
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- 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: 120,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 120,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 120,
- title: '业务类型',
- field: 'businessType',
- },
- {
- width: 120,
- 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: 'outOrderNo',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '财务系统单据',
- prop: 'financeOrderId',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入财务系统单据',
- clearable: true
- },
- },
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- 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: 120,
- title: '收货地址',
- field: 'receiveAddress',
- },
- {
- width: 120,
- title: '联系方式',
- field: 'receivePhone',
- },
- {
- width: 120,
- title: '业务类型',
- field: 'businessType',
- },
- {
- width: 110,
- title: '操作',
- action: true,
- plugins: [{
- name: '查看',
- audit: '',
- event: {
- click: (e : any) => {
- (this as any).openEdit(e)
- }
- }
- }]
- }
- ]
- }
- }
- }
- created() {
- this.timer = setInterval(() => {
- this.getDataList()
- }, 500)
- }
- // 引单
- citationOrder(e : any) {
- 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;
- parentData = parentData.map((item : any, i : any) => {
- item.receiveAddress = item.address
- item.receive = item.consignee
- item.receivePhone = item.phone
- item.outOrderNo = item.orderNumber
- const { ...newData } = item
- return newData
- })
- let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
- parentData[0].suborderList.map((v : any) => {
- v.deliveryNumber = v.number - v.outNumber;
- if (v.deliveryNumber < v.number) v.number = v.deliveryNumber;
- });
- this.tableData = parentData[0];
- billConfig.tool.tools = { save: true, smt: true };
- // console.log('this.tableData ==> ', this.tableData);
- // billConfig.tool.tools = { save: true };
- 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.prePrice;
- }
- // 保存
- onSave(e : any) {
- console.log('保存 ==>', this.tabType);
- (this as any).$refs.bill.$refs.billForm.validate().then(() => {
- let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
- // 子表数据
- // query.suborderList = this.tableData;
- 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('出库数据不能大于库存数量');
- v.taskOrderId = query.id;
- v.purchaseSuborderId = v.id;
- }
- };
- // 表格删除
- query.suborderList.map((v : any, i : any) => {
- if (v.isDeleted === 1 && !v.id) {
- query.suborderList.splice(i, 1)
- }
- });
- if (query.deliveryData) query.deliveryData = query.deliveryData + ' 00:00:00';
- 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;
- 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());
- };
- })
- }
- // 切换tab栏
- clickTab(e : any) {
- console.log('切换tab ==> ', e);
- this.tabType = e;
- (this.$refs.bill as any).showTab = e;
- // submitState: 提交状态
- if (e === 'source') { 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) {
- console.log('编辑this.tabType ==>', this.tabType);
- console.log('编辑 ==>', e);
- 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) {
- this.setReadonly(parentData)
- return loading.close();
- }
- 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)
- }
- }
- }]
- })
- };
- billConfig.form.attr.readonly = false; // 设置只读
- billConfig.tool.tools = { save: true, };
- if (this.tabType === 'draftsBox' || parentData.submitState === 0) billConfig.tool.tools = { save: true, smt: true };
- let data : any = parentData.suborderList;
- let array : any = [];
- data.map((v : any) => {
- v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
- array.push({
- storidId: v.storingLocationId,
- skuid: v.materialSku,
- })
- });
- console.log('array', array);
- // 查库存
- api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
- if (res.code === 200) {
- console.log(res);
- let newData : any = [];
- res.data.map((v : any, i : any) => {
- newData.push(Object.assign(data[i], v))
- })
- console.log('newData', newData);
- 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 {
- this.setReadonly(parentData);
- };
- }
- }).catch(() => loading.close());
- }
- // 设置只读
- setReadonly(e : any) {
- 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 = {};
- if (this.tabType != 'recycleBin') {
- if (e.submitState === 1) readonly.tool.tools = { returnSmt: true };
- }
- readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
- let data = e.suborderList;
- let array : any = [];
- data.map((v : any) => {
- v.towInOne = v.storehouseName + ',' + v.storingLocationName; // 仓库仓位
- array.push({
- storidId: v.storingLocationId,
- skuid: v.materialSku,
- })
- });
- console.log('array', array);
- // 查库存
- api.getInventoryByStoridsAndSkuids(array).then((res : any) => {
- loading.close();
- if (res.code === 200) {
- let newData : any = []
- res.data.map((v : any, i : any) => {
- newData.push(Object.assign(data[i], v))
- })
- console.log('newData', newData);
- this.tableData = newData;
- (this.$refs.bill as any).setBillConfig(readonly);
- (this.$refs.bill as any).setBillFormValue(e);// 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(newData, 0);// 设置第1张单据表格数据
- this.isAdd = false;
- (this.$refs.bill as any).showTab = 'bill';
- }
- }).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 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.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 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.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) {
- 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);
- 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 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());
- }
- // 搜索
- 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({}) // 回收站数据
- }
- }
- // 确定商品新增
- confirmProduct(e : any) {
- let nowData = (this.$refs.bill as any).getBillTableData(0);
- let names = '';
- if (e.length > 0) {
- for (const item of e) {
- let t = true;
- for (const t_item of nowData) {
- if (item.id == t_item.materialSku) {
- if (!names) {
- names = item.skuTitle
- } else {
- names = names + ',' + item.skuTitle
- }
- t = false;
- break;
- }
- }
- if (t) {
- let obj : any = {};
- obj.materialName = item.skuTitle
- obj.materialId = item.materialId
- obj.prePrice = 0
- obj.unitPrice = item.price
- obj.materialSku = item.id
- obj.unit = item.unit
- obj.prePrice = "0"
- obj.isDeleted = 0
- this.tableData.push(obj);
- nowData.push(obj);
- }
- }
- (this.$refs.bill as any).setBillTableValue(nowData, 0);// 设置第1张单据表格数据
- if (names) {
- this.$alert('商品 “' + names + '”已存在!', '提示', {
- confirmButtonText: '确定',
- });
- }
- }
- }
- // 单据表格删除
- 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
- }
- };
- 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) {
- console.log('工具栏删除 ==> ', e);
- 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>
|