1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336 |
- <template>
- <div>
- <by-bill ref="bill" :propConfig="config" @search="search" @onSmt="onSmt" @onAdd="onAdd" @onDelete="onDelete"
- @onDispatch="onDispatch" @onRefresh="resert" @detail="openEdit" @onSave="onSave" @clickTab="clickTab"
- @onChangeRow="onChangeRow" @pagination="pagination" @onReturnSmt="onReturnSmt2"
- @getSupplierModal="getSupplierModal" @resert="resert">
- </by-bill>
- <!-- 选择物料 -->
- <productModal ref="product" :mulit="true" @confirm="confirmProduct" />
- <!-- 选择机构名称 -->
- <supplier-modal ref="supplierModal" @confirm="confirmSupplier" />
- </div>
- </template>
- <script lang="ts">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import api from "@/api/order";
- import Assembly from "@/components/Assembly/order.vue";
- import productModal from "./components/productModal.vue";
- import Focus from "./components/focus.vue";
- @Component({ components: { productModal } })
- export default class OrderTask extends Vue {
- // 左边
- tabType : any = 'all';
- isAdd : any = false
- supplierSelectData : any = {}
- baseInfo : any = {}
- isSubmit : any = false
- isChange : any = false
- // 右边
- supplierInfo : any = {} // 机构信息
- tableData : any = []
- mergeObj : any = []
- setStatusData : any = ''
- timeNum = 0;
- timer : any = null
- config : any = {
- attr: {
- activeName: 'all'
- },
- // 单据
- bill: {
- tool: {
- tools: {
- save: true,
- }
- },
- form: {
- attr: {
- size: 'medium',
- readonly: false,
- },
- columns: [
- [
- {
- span: 8,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- readonly: true
- },
- }
- },
- {
- span: 8,
- label: '机构名称',
- prop: 'organizationName',
- component: Focus,
- },
- {
- span: 8,
- label: '联系方式',
- prop: 'deliveryPhone',
- component: 'by-input',
- },
- {
- span: 8,
- label: '交货人',
- prop: 'delivery',
- component: 'by-input',
- },
- {
- span: 8,
- label: '交货时间',
- prop: 'deliveryData',
- component: 'by-date-picker',
- compConfig: {
- format: 'yyyy-MM-dd hh:ss:mm',
- type: 'datetime',
- }
- },
- {
- span: 8,
- label: '交货地点',
- prop: 'deliveryAddress',
- component: 'by-input',
- },
- {
- span: 8,
- label: '交货方式',
- prop: 'deliveryWay',
- component: 'by-input',
- },
- ],
- [
- {
- span: 28,
- label: '备注',
- slot: true,
- prop: 'remark',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- placeholder: '请输入备注',
- type: 'textarea'
- },
- }
- },
- ]
- ]
- },
- tableConfig: [
- {
- tool: {
- tools: {
- add: true
- }
- },
- table: {
- attr: {
- size: 'mini',
- height: 500,
- align: 'center',
- readonly: true
- },
- columns:
- [{
- width: 300,
- title: '物料名称',
- field: 'materialName',
- },
- {
- width: 140,
- title: '单位',
- field: 'unit',
- },
- {
- width: 140,
- title: '数量',
- field: 'number',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- defaultValue: 1,
- },
- }
- },
- {
- width: 140,
- title: '已交付数量',
- field: 'deliveryNumber',
- },
- {
- width: 140,
- title: '单价',
- field: 'unitPrice',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- },
- }
- },
- {
- width: 140,
- title: '实际金额',
- field: 'realityPrice',
- },
- {
- width: 140,
- title: '优惠金额',
- field: 'prePrice',
- component: 'by-input',
- compConfig: {
- attr: {
- size: 'mini',
- type: 'number',
- defaultValue: 0,
- },
- }
- },
- {
- width: 140,
- 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: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '机构名称',
- prop: 'organizationName',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入机构名称',
- clearable: true
- },
- },
- },
- {
- span: 6,
- label: '交货时间',
- prop: 'deliveryData',
- component: 'by-date-picker',
- compConfig: {
- format: 'yyyy-MM-dd hh:ss:mm',
- type: 'datetime'
- }
- },
- {
- span: 6,
- label: '状态',
- prop: 'status',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择状态',
- clearable: true,
- data: [{
- value: 0,
- label: '未接单'
- }, {
- value: 1,
- label: '已接单'
- }]
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- columns: [
- {
- width: 160,
- title: '单据编号',
- field: 'orderNumber',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 120,
- title: '机构名称',
- field: 'organizationName',
- },
- {
- width: 80,
- title: '来源类型',
- field: 'sourceType',
- },
- {
- width: 90,
- title: '交货人',
- field: 'delivery',
- },
- {
- width: 150,
- title: '交货时间',
- field: 'deliveryData',
- },
- {
- width: 200,
- title: '交货地点',
- field: 'deliveryAddress',
- },
- {
- width: 130,
- title: '联系方式',
- field: 'deliveryPhone',
- },
- {
- width: 130,
- title: '交货方式',
- field: 'deliveryWay',
- },
- {
- width: 80,
- title: '状态',
- field: 'status',
- component: Assembly,
- },
- {
- 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).onReturnSmt(item)
- }
- }]
- }
- ]
- }
- },
- // 草稿箱
- draftsBox: {
- search: {
- attr: {
- size: 'mini',
- },
- columns: [
- [
- {
- span: 6,
- label: '单据编号',
- prop: 'orderNumber',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入单据编号',
- clearable: true
- }
- }
- },
- {
- span: 6,
- label: '机构名称',
- prop: 'organizationName',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入机构名称',
- clearable: true
- },
- },
- },
- {
- span: 6,
- label: '交货时间',
- prop: 'deliveryData',
- component: 'by-date-picker',
- compConfig: {
- format: 'yyyy-MM-dd hh:ss:mm',
- type: 'datetime'
- }
- },
- {
- span: 6,
- label: '状态',
- prop: 'status',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择状态',
- clearable: true,
- data: [{
- value: 0,
- label: '未接单'
- }, {
- value: 1,
- label: '已接单'
- }]
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- smt: true,
- delete: true,
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- columns: [
- {
- width: 160,
- title: '单据编号',
- field: 'orderNumber',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 120,
- title: '机构名称',
- field: 'organizationName',
- },
- {
- width: 80,
- title: '来源类型',
- field: 'sourceType',
- },
- {
- width: 90,
- title: '交货人',
- field: 'delivery',
- },
- {
- width: 150,
- title: '交货时间',
- field: 'deliveryData',
- },
- {
- width: 200,
- title: '交货地点',
- field: 'deliveryAddress',
- },
- {
- width: 130,
- title: '联系方式',
- field: 'deliveryPhone',
- },
- {
- width: 130,
- title: '交货方式',
- field: 'deliveryWay',
- },
- {
- width: 80,
- title: '状态',
- field: 'status',
- component: Assembly,
- },
- {
- 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
- }
- }
- },
- {
- span: 6,
- label: '机构名称',
- prop: 'organizationName',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入机构名称',
- clearable: true
- },
- },
- },
- {
- span: 6,
- label: '交货时间',
- prop: 'deliveryData',
- component: 'by-date-picker',
- compConfig: {
- format: 'yyyy-MM-dd hh:ss:mm',
- type: 'datetime'
- }
- },
- {
- span: 6,
- label: '状态',
- prop: 'status',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择状态',
- clearable: true,
- data: [{
- value: 0,
- label: '未接单'
- }, {
- value: 1,
- label: '已接单'
- }]
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- add: true,
- dispatch: true,
- delete: true,
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- columns: [
- {
- width: 160,
- title: '单据编号',
- field: 'orderNumber',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 120,
- title: '机构名称',
- field: 'organizationName',
- },
- {
- width: 80,
- title: '来源类型',
- field: 'sourceType',
- },
- {
- width: 90,
- title: '交货人',
- field: 'delivery',
- },
- {
- width: 150,
- title: '交货时间',
- field: 'deliveryData',
- },
- {
- width: 200,
- title: '交货地点',
- field: 'deliveryAddress',
- },
- {
- width: 130,
- title: '联系方式',
- field: 'deliveryPhone',
- },
- {
- width: 130,
- title: '交货方式',
- field: 'deliveryWay',
- },
- {
- width: 80,
- title: '状态',
- field: 'submitState',
- component: Assembly,
- },
- {
- width: 110,
- title: '操作',
- action: true,
- plugins: [
- {
- // icon: 'el-icon-edit',
- name: '编辑',
- audit: '',
- event: {
- show: (item : any) => {
- return item.sourceType == '手工输入' && item.submitState == 0
- },
- click: (e : any) => {
- (this as any).openEdit(e)
- }
- }
- },
- {
- name: '查看',
- event: {
- show: (item : any) => {
- return item.sourceType != '手工输入' || item.submitState == 1
- },
- 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
- }
- }
- },
- {
- span: 6,
- label: '机构名称',
- prop: 'organizationName',
- component: 'by-input',
- compConfig: {
- attr: {
- placeholder: '请输入机构名称',
- clearable: true
- },
- },
- },
- {
- span: 6,
- label: '交货时间',
- prop: 'deliveryData',
- component: 'by-date-picker',
- compConfig: {
- format: 'yyyy-MM-dd hh:ss:mm',
- type: 'datetime'
- }
- },
- {
- span: 6,
- label: '状态',
- prop: 'status',
- component: 'by-select',
- compConfig: {
- attr: {
- placeholder: '请选择状态',
- clearable: true,
- data: [{
- value: 0,
- label: '未接单'
- }, {
- value: 1,
- label: '已接单'
- }]
- }
- }
- },
- ],
- ]
- },
- tool: {
- tools: {
- search: true,
- refresh: true
- }
- },
- table: {
- attr: {
- height: 620,
- size: 'mini',
- seq: true,
- align: 'left',
- checkbox: true
- },
- columns: [
- {
- width: 160,
- title: '单据编号',
- field: 'orderNumber',
- isDetail: true,
- fixed: 'left'
- },
- {
- width: 120,
- title: '机构名称',
- field: 'organizationName',
- },
- {
- width: 80,
- title: '来源类型',
- field: 'sourceType',
- },
- {
- width: 90,
- title: '交货人',
- field: 'delivery',
- },
- {
- width: 150,
- title: '交货时间',
- field: 'deliveryData',
- },
- {
- width: 200,
- title: '交货地点',
- field: 'deliveryAddress',
- },
- {
- width: 130,
- title: '联系方式',
- field: 'deliveryPhone',
- },
- {
- width: 130,
- title: '交货方式',
- field: 'deliveryWay',
- },
- {
- width: 80,
- title: '状态',
- field: 'status',
- component: Assembly,
- },
- {
- width: 110,
- title: '操作',
- action: true,
- plugins: [{
- // icon: 'el-icon-edit',
- name: '查看',
- audit: '',
- event: {
- click: (e : any) => {
- (this as any).openEdit(e)
- }
- }
- }]
- }
- ]
- }
- }
- }
- created() {
- this.timer = setInterval(() => {
- this.getDataList()
- }, 500)
- }
- // 保存
- onSave() {
- console.log('保存tabType ==>', this.tabType);
- (this as any).$refs.bill.$refs.billForm.validate().then(() => {
- let query = (this.$refs.bill as any).getBillFormValue(); // 获取单据数据
- // 供应商数据
- if (!query.organizationName) query.organizationName = this.supplierInfo.name;
- if (!query.organizationId) query.organizationId = this.supplierInfo.id;
- if (!query.organizationName) return this.$message.warning('请选择机构名称');
- // 子表数据
- query.suborderList = this.tableData;
- if (query.suborderList.length > 0) {
- for (let v of query.suborderList) {
- if (!v.number || v.number <= 0) return this.$message.warning('请输入正确物料数量');
- if (!v.unitPrice || v.unitPrice <= 0) return this.$message.warning('请输入正确物料单价');
- if (!v.prePrice || v.prePrice < 0) return this.$message.warning('请输入正确优惠金额');
- v.taskOrderId = query.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);
- if (this.isAdd) {
- api.saveList(query, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- // this.isAdd = false;
- // this.isChange = false;
- // this.isSubmit = true;
- this.getDataList();
- this.$message.success('保存成功');
- (this.$refs.bill as any).showTab = 'all';
- } else this.$message.error(res.msg);
- })
- } else if (this.tabType === 'all' || this.tabType === 'draftsBox') {
- api.updateList(query, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('保存成功');
- this.isChange = false;
- this.isSubmit = true;
- } else this.$message.error(res.msg);
- })
- };
- })
- }
- // 打开新增
- onAdd(e : any) {
- console.log('新增tabType ==>', this.tabType);
- if (e === 'billTable_0') {
- (this.$refs.product as any).setShow(true); // 打开sku弹窗
- let obj = (this.$refs.bill as any).getBillFormValue();
- if (!this.tableData) this.tableData = obj.suborderList;
- console.log('this.tableData ==> ', this.tableData);
- (this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
- } else {
- let billConfig = (this as any).$lodash.cloneDeep(this.config.bill);
- billConfig.form.attr.readonly = false; // 设置只读
- billConfig.tool.tools = { save: true, };
- // if (e === 'all') {
- // billConfig.tool.tools = { save: true, smt: true };
- // this.tableData = [];
- // (this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
- // }
- billConfig.tableConfig[0].tool.tools = { add: true };
- this.isAdd = true;
- (this.$refs.bill as any).setBillConfig(billConfig);
- (this.$refs.bill as any).setBillFormValue({}); // 设置单据表单数据
- };
- (this.$refs.bill as any).showTab = 'bill';
- }
- // 打开编辑
- openEdit(e : any) {
- e = e.row ? e.row : e;
- console.log('编辑tabType ==>', this.tabType);
- console.log('编辑 ==>', e);
- let loading = this.$loading({ target: '.main-container' });
- api.single({ id: e.id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- let parentData = res.data ? res.data : e;
- this.baseInfo = parentData;
- if (parentData.sourceType === '手工输入') {
- // 已提交
- if (parentData.submitState === 1) {
- loading.close();
- return this.setReadonly(parentData,true)
- };
- // 回收站
- if(this.tabType === 'recycleBin' ){
- loading.close();
- return this.setReadonly(parentData,false)
- };
- let data = parentData.suborderList
- data.map((v : any, i : any) => {
- v.dataIndex = i;
- if (!v.prePrice) v.prePrice = '0';
- });
- 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 (parentData.submitState === 0) billConfig.tool.tools = { save: true, smt: true };
- billConfig.tableConfig[0].tool.tools = { add: true };
- this.tableData = data;
- (this.$refs.bill as any).setBillConfig(billConfig);
- (this.$refs.bill as any).setBillFormValue(parentData);// 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
- this.isAdd = false;
- (this.$refs.bill as any).showTab = 'bill';
- loading.close();
- } else {
- loading.close();
- this.setReadonly(parentData,false);
- };
- }
- })
- }
- // 设置只读
- setReadonly(e : any,isReturn:any) {
- let readonly = (this as any).$lodash.cloneDeep(this.config.bill);
- readonly.form.attr.readonly = true; // 设置只读
- readonly.tool.tools = {};
- if (isReturn) readonly.tool.tools = { returnSmt: true };
- readonly.tableConfig[0].table.columns = readonly.tableConfig[0].table.columns.filter((v : any) => v.title != '操作');
- readonly.tableConfig[0].tool.tools = {};
- let data = e.suborderList;
- (this.$refs.bill as any).setBillConfig(readonly);
- (this.$refs.bill as any).setBillFormValue(e);// 设置单据表单数据
- (this.$refs.bill as any).setBillTableValue(data, 0);// 设置第1张单据表格数据
- this.isAdd = false;
- (this.$refs.bill as any).showTab = 'bill';
- }
- // 工具栏提交
- 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(() => {
- api.submitTo({ id: selectData[0].id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('提交成功');
- this.clickTab('draftsBox');
- } else this.$message.error(res.msg)
- })
- }).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(() => {
- api.submitTo({ id: this.baseInfo.id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('提交成功');
- this.clickTab(this.tabType);
- this.isSubmit = false;
- (this.$refs.bill as any).showTab = this.tabType;
- } else this.$message.error(res.msg)
- })
- }).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(() => {
- // console.log(this.baseInfo.id);
- api.submitTo({ id: this.baseInfo.id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('提交成功');
- this.clickTab(this.tabType);
- (this.$refs.bill as any).showTab = this.tabType;
- } else this.$message.error(res.msg)
- })
- }).catch(() => this.$message.info('已取消提交'));
- }
- }
- }
- }
- // 操作反提交
- onReturnSmt(e : any) {
- console.log('反提交 ==>', e);
- this.$confirm('确定反提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- if (this.tabType === 'smt') {
- api.cancelSubmission({ id: e.id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('反提交成功');
- this.clickTab(this.tabType);
- } else this.$message.error(res.msg)
- })
- }
- }).catch(() => this.$message.info('已取消反提交'));
- }
- // 工具栏反提交
- onReturnSmt2() {
- console.log('工具栏反提交 ==>', this.baseInfo);
- this.$confirm('确定反提交吗!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- if (this.tabType === 'smt') {
- api.cancelSubmission({ id: this.baseInfo.id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('反提交成功');
- this.clickTab(this.tabType);
- (this.$refs.bill as any).showTab = 'smt';
- } else this.$message.error(res.msg)
- })
- }
- }).catch(() => this.$message.info('已取消反提交'));
- }
- // 获取机构数据
- getSupplierModal(e : any) {
- // console.log('获取机构数据 ==> ', e);
- this.supplierInfo = e;
- }
- // 监听表格数据变化
- onChangeRow(e : any) {
- this.isChange = true;
- this.isSubmit = false;
- e.realityPrice = parseFloat((e.number * e.unitPrice).toFixed(2));
- e.totalPrice = e.realityPrice - e.prePrice;
- }
- // 确定商品新增
- confirmProduct(e : any) {
- let contents : any = [], goodsData = e, newArr : any = [], obj : any = {};
- goodsData = goodsData.map((item : any) => {
- item.materialName = item.skuTitle
- item.prePrice = 0
- item.unitPrice = item.price
- item.materialSku = item.id
- const { id, ...newData } = item
- return newData
- })
- this.tableData = this.tableData.concat(goodsData);
- newArr = this.tableData.reduce((prev : any, current : any) => {
- obj[current.materialSku] ? contents.push(current.materialName) : (obj[current.materialSku] = true && prev.push(current))
- return prev
- }, []);
- this.tableData = newArr;
- this.tableData.map((v : any, i : any) => {
- v.dataIndex = i;
- if (!v.prePrice) v.prePrice = '0';
- });
- if (contents.length > 0) {
- this.$alert('商品 “' + contents + '” 已存在!', '提示', {
- confirmButtonText: '确定',
- });
- };
- (this.$refs.bill as any).setBillTableValue(this.tableData, 0);// 设置第1张单据表格数据
- }
- // 派单
- onDispatch(e : any) {
- console.log('派单 ==>', e);
- this.supplierSelectData = (this.$refs.bill as any).getTableSelectData(this.tabType); // 获取表格选中数据
- if (this.supplierSelectData.length <= 0) return this.$message.warning('请选择派单数据');
- if (this.supplierSelectData.length > 1) return this.$message.warning('只能派单一条数据');
- (this.$refs.supplierModal as any).setShow(true);
- }
- // 派单确认
- confirmSupplier(e : any) {
- if (e.length > 0) {
- console.log(e);
- console.log(this.supplierSelectData);
- let query : any = (this as any).$lodash.cloneDeep(this.supplierSelectData)[0];
- query.organizationName = e[0].name;
- query.organizationId = e[0].id;
- api.updateList(query, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.$message.success('派单成功');
- this.getDataList();
- (this.$refs.bill as any).showTab = 'all';
- } else this.$message.error(res.msg);
- })
- }
- }
- // 切换tab栏
- clickTab(e : any) {
- this.tabType = e;
- // submitState: 提交状态
- 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({}) // 回收站数据
- }
- // 初始化
- getDataList() {
- if (!this.$refs.bill) {
- if (this.timeNum > 5) {
- clearInterval(this.timer)
- }
- this.timeNum++;
- return
- }
- clearInterval(this.timer)
- this.getPageList({}, 'all'); // 综合数据
- }
- // 获取分页数据
- getPageList(query : any, type : any) {
- api.pageList(query, 'supplyTaskOrder').then((res : any) => {
- 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)
- })
- }
- // 分页
- pagination(e : any) {
- let query : any = (this as any).$refs.bill.getSearchValue(e.type);
- query.pageNo = e.page.pageNum;
- query.pageSize = e.page.pageSize;
- console.log('分页 ==> ', query);
- let loading = this.$loading({ target: '.main-container' });
- if (e.type === 'recycleBin') {
- api.selectDeleteList(query, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- (this.$refs.bill as any).setTabTableValue('recycleBin', res.data.records);
- loading.close()
- } else this.$message.error(res.msg)
- });
- } else {
- console.log(this.tabType);
- if (this.tabType == 'draftsBox') query.submitState = 0;
- if (this.tabType == 'smt') query.submitState = 1;
- api.pageList(query, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- (this.$refs.bill as any).setTabTableValue(e.type, res.data.records);
- loading.close()
- } else this.$message.error(res.msg)
- })
- }
- }
- // 回收站数据
- getSelectDeleteList(query : any) {
- api.selectDeleteList(query, 'supplyTaskOrder').then((res : any) => {
- 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)
- });
- }
- // 搜索
- search(parames : any) {
- let loading = this.$loading({ target: '.main-container' });
- let query = parames.value;
- if (parames.type === 'draftsBox') query.submitState = 0 // 草稿箱数据
- if (parames.type === 'smt') query.submitState = 1 // 已提交数据
- console.log('搜索 ==> ', query);
- if (this.tabType === 'recycleBin') {
- this.getSelectDeleteList(query); // 回收站分页数据
- loading.close()
- } else {
- this.getPageList(query, parames.type) // 获取分页数据
- loading.close()
- }
- }
- // 刷新/重置
- resert(e : any) {
- let data : any = e.type ? e.type : e;
- (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(() => {
- this.tableData[item.dataIndex].isDeleted = 1;
- let newData = this.tableData.filter((res : any) => res.isDeleted === 0);
- console.log('原表格数据 ==> ', this.tableData);
- console.log('新表格数据 ==> ', newData);
- (this.$refs.bill as any).setBillTableValue(newData, 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 : any = [];
- if (selectData.length > 0) {
- selectData.map((v : any) => {
- ids.push(v.id)
- })
- } else return this.$message({ type: 'warning', message: '请选择删除数据' })
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- api.deleteList(ids, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.clickTab(this.tabType);
- this.$message.success('删除成功!');
- } else this.$message.error(res.msg)
- })
- }).catch(() => this.$message.info('已取消删除'));
- }
- // 操作删除
- doDelete2(item : any) {
- this.$confirm('确定删除吗,此操作不能撤销!', '注意', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning',
- center: true
- }).then(() => {
- api.deleteList({ ids: item.id }, 'supplyTaskOrder').then((res : any) => {
- if (res.code === 200) {
- this.clickTab(this.tabType);
- this.$message.success('删除成功!');
- } else this.$message.error(res.msg)
- })
- }).catch(() => this.$message.info('已取消删除'));
- }
- }
- </script>
|