import { VALIDATE_NO_PASSED, validateFormAndTables } from '@/utils/JEditableTableUtil' import {findBySelectSup,findBySelectCus,findBySelectRetail,findBySelectOrgan,findStockByDepotAndBarCode,getAccount,getPersonByType,findInOutItemByParam} from '@/api/api' import { getAction,putAction } from '@/api/manage' import { getMpListShort, getNowFormatDateTime } from "@/utils/util" import { USER_INFO } from "@/store/mutation-types" import Vue from 'vue' export const FinancialModalMixin = { data() { return { action: '', supList: [], cusList: [], retailList: [], organList: [], personList: [], accountList: [], billStatus: '0', isCanCheck: true, isTenant: false, spans: { labelCol1: {span: 2}, wrapperCol1: {span: 22}, //1_5: 分为1.5列(相当于占了2/3) labelCol1_5: { span: 3 }, wrapperCol1_5: { span: 21 }, labelCol2: {span: 4}, wrapperCol2: {span: 20}, labelCol3: {span: 6}, wrapperCol3: {span: 18}, labelCol6: {span: 12}, wrapperCol6: {span: 12} }, }; }, created () { let userInfo = Vue.ls.get(USER_INFO) this.isTenant = userInfo.id === userInfo.tenantId? true:false let realScreenWidth = window.screen.width this.width = realScreenWidth<1500?'1200px':'1550px' this.minWidth = realScreenWidth<1500?1150:1500 }, computed: { readOnly: function() { return this.action !== "add" && this.action !== "edit"; } }, methods: { addInit(amountNum) { getAction('/sequence/buildNumber').then((res) => { if (res && res.code === 200) { this.form.setFieldsValue({'billNo':amountNum + res.data.defaultNumber}) } }) this.$nextTick(() => { this.form.setFieldsValue({'billTime':getNowFormatDateTime(), 'totalPrice': 0, 'discountMoney': 0, 'changeAmount': 0}) }) this.$nextTick(() => { getAccount({}).then((res)=>{ if(res && res.code === 200) { for (const item of res.data.accountList) { if(item.isDefault){ this.form.setFieldsValue({'accountId': item.id}) } } } }) }) }, initSupplier() { let that = this; findBySelectSup({}).then((res)=>{ if(res) { that.supList = res; } }); }, initCustomer() { let that = this; findBySelectCus({}).then((res)=>{ if(res) { that.cusList = res; } }); }, initOrgan() { let that = this; findBySelectOrgan({}).then((res)=>{ if(res) { that.organList = res; } }); }, initRetail() { let that = this; findBySelectRetail({}).then((res)=>{ if(res) { that.retailList = res; } }); }, initPerson() { let that = this; getPersonByType({type:'财务员'}).then((res)=>{ if(res && res.code === 200) { that.personList = res.data.personList; } }) }, initInOutItem(type) { let that = this; findInOutItemByParam({type:type}).then((res)=>{ if(res) { for(let item of that.accountTable.columns){ if(item.key == 'inOutItemId') { item.options = [] for(let i=0; i{ if(res && res.code === 200) { that.accountList = res.data.accountList; } }) }, //账户-用于明细 initDetailAccount(){ let that = this; getAccount({}).then((res)=>{ if(res && res.code === 200) { let list = res.data.accountList; for(let item of that.accountTable.columns){ if(item.key == 'accountId') { item.options = [] for(let i=0; i { this.form.setFieldsValue({'totalPrice':allEachAmount, 'changeAmount':changeAmount}) }); }, //改变优惠金额 onKeyUpDiscountMoney(e) { const value = e.target.value-0 let totalPrice = this.form.getFieldValue('totalPrice')-0 let changeAmount = (totalPrice-value).toFixed(2) this.$nextTick(() => { this.form.setFieldsValue({'changeAmount':changeAmount}) }); }, //选择欠款单据 debtBillListOk(selectBillRows) { if(selectBillRows && selectBillRows.length>0) { this.requestSubTableDataEx(selectBillRows, this.accountTable); } }, /** 查询某个tab的数据,给明细里面的金额赋值 */ requestSubTableDataEx(selectBillRows, tab, success) { tab.loading = true let listEx = [] let changeAmount = 0 for(let i=0; i { this.form.setFieldsValue({'totalPrice':changeAmount, 'changeAmount':changeAmount}) }); typeof success === 'function' ? success(res) : '' tab.loading = false }, //保存并审核 handleOkAndCheck() { this.billStatus = '1' this.handleOk() }, } }