BillModalMixin.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227
  1. import { FormTypes, getListData } from '@/utils/JEditableTableUtil'
  2. import {
  3. findBySelectCus,
  4. findBySelectRetail,
  5. findBySelectSup,
  6. findStockByDepotAndBarCode,
  7. getAccount,
  8. getBatchNumberList,
  9. getCurrentSystemConfig,
  10. getMaterialByBatchNumber,
  11. getMaterialByBarCode,
  12. getMaterialBySelect,
  13. getPersonByNumType,
  14. getPlatformConfigByKey,
  15. getUnitInfo,
  16. creatorSpinnerList,
  17. } from '@/api/api'
  18. import { getAction } from '@/api/manage'
  19. import { getCheckFlag, getMpListShort, getNowFormatDateTime } from '@/utils/util'
  20. import { USER_INFO } from '@/store/mutation-types'
  21. import Vue from 'vue'
  22. export const BillModalMixin = {
  23. data() {
  24. return {
  25. action: '',
  26. manyAccountBtnStatus: false,
  27. supList: [],
  28. cusList: [],
  29. retailList: [],
  30. // unitList: [],
  31. personList: {
  32. options: [],
  33. value: '',
  34. },
  35. depotList: [],
  36. accountList: [],
  37. accountIdList: [],
  38. accountMoneyList: [],
  39. billUnitPirce: '',
  40. scanBarCode: '',
  41. scanStatus: true,
  42. billStatus: '0',
  43. minWidth: 1100,
  44. isCanCheck: true,
  45. quickBtn: {
  46. vendor: false,
  47. customer: false,
  48. member: false,
  49. account: false,
  50. depot: false,
  51. },
  52. billPrintFlag: false,
  53. /* 是否显示打印按钮 */
  54. isShowPrintBtn: true,
  55. /* 原始审核是否开启 */
  56. checkFlag: true,
  57. validatorRules: {
  58. price: {
  59. rules: [{ pattern: /^(([0-9][0-9]*)|([0]\.\d{0,4}|[0-9][0-9]*\.\d{0,4}))$/, message: '金额格式不正确!' }],
  60. },
  61. },
  62. spans: {
  63. labelCol1: { span: 2 },
  64. wrapperCol1: { span: 22 },
  65. //1_5: 分为1.5列(相当于占了2/3)
  66. labelCol1_5: { span: 3 },
  67. wrapperCol1_5: { span: 21 },
  68. labelCol2: { span: 4 },
  69. wrapperCol2: { span: 20 },
  70. labelCol3: { span: 6 },
  71. wrapperCol3: { span: 18 },
  72. labelCol6: { span: 12 },
  73. wrapperCol6: { span: 12 },
  74. },
  75. currentUserList: [],
  76. }
  77. },
  78. created() {
  79. let realScreenWidth = window.screen.width
  80. this.width = realScreenWidth < 1500 ? '1200px' : '1550px'
  81. this.minWidth = realScreenWidth < 1500 ? 1150 : 1500
  82. },
  83. watch:{
  84. $route(to, from) {
  85. if(this.handleCancel){
  86. this.handleCancel()
  87. }
  88. this.visible = false
  89. }
  90. },
  91. mounted() {
  92. document.getElementById(this.prefixNo).addEventListener('keydown', this.handleOkKey)
  93. this.getCreatorSpinnerList()
  94. },
  95. beforeDestroy() {
  96. document.getElementById(this.prefixNo).removeEventListener('keydown', this.handleOkKey)
  97. },
  98. computed: {
  99. readOnly: function () {
  100. return this.action !== 'add' && this.action !== 'edit'
  101. },
  102. },
  103. methods: {
  104. // 快捷键
  105. handleOkKey(e) {
  106. const key = window.event.keyCode ? window.event.keyCode : window.event.which
  107. if (key === 83 && e.ctrlKey) {
  108. //保存 CTRL+S
  109. this.handleOk()
  110. e.preventDefault()
  111. }
  112. },
  113. addInit(amountNum) {
  114. getAction('/sequence/buildNumber').then((res) => {
  115. if (res && res.code === 200) {
  116. this.model.defaultNumber = amountNum + res.data.defaultNumber
  117. this.form.setFieldsValue({ number: amountNum + res.data.defaultNumber })
  118. }
  119. })
  120. this.$nextTick(() => {
  121. this.form.setFieldsValue({
  122. operTime: getNowFormatDateTime(),
  123. discount: 0,
  124. discountMoney: 0,
  125. discountLastMoney: 0,
  126. otherMoney: 0,
  127. changeAmount: 0,
  128. debt: 0,
  129. })
  130. })
  131. this.$nextTick(() => {
  132. getAccount({}).then((res) => {
  133. if (res && res.code === 200) {
  134. for (const item of res.data.accountList) {
  135. if (item.isDefault) {
  136. this.form.setFieldsValue({ accountId: item.id })
  137. }
  138. }
  139. }
  140. })
  141. })
  142. this.accountIdList = []
  143. this.accountMoneyList = []
  144. this.manyAccountBtnStatus = false
  145. },
  146. copyAddInit(amountNum) {
  147. getAction('/sequence/buildNumber').then((res) => {
  148. if (res && res.code === 200) {
  149. this.form.setFieldsValue({ number: amountNum + res.data.defaultNumber })
  150. }
  151. })
  152. this.$nextTick(() => {
  153. this.form.setFieldsValue({ operTime: getNowFormatDateTime() })
  154. })
  155. },
  156. /** 查询某个tab的数据 */
  157. requestSubTableData(url, params, tab, success) {
  158. tab.loading = true
  159. getAction(url, params)
  160. .then((res) => {
  161. if (res && res.code === 200) {
  162. tab.dataSource = res.data.rows
  163. for (let i = 0; i < tab.dataSource.length; i++) {
  164. let info = tab.dataSource[i]
  165. info.isEdit = this.model.id ? 1 : 0
  166. if (info.unitId) {
  167. info.unitList = JSON.stringify(info.unitList)
  168. }
  169. this.changeColumnShow(info)
  170. }
  171. typeof success === 'function' ? success(res) : ''
  172. }
  173. })
  174. .finally(() => {
  175. tab.loading = false
  176. })
  177. },
  178. //改变字段的状态,1-显示 0-隐藏
  179. changeFormTypes(columns, key, type) {
  180. for (let i = 0; i < columns.length; i++) {
  181. if (columns[i].key === key) {
  182. if (type) {
  183. if (key === 'snList' || key === 'batchNumber') {
  184. if (
  185. this.prefixNo === 'LSCK' ||
  186. this.prefixNo === 'CGTH' ||
  187. this.prefixNo === 'XSCK' ||
  188. this.prefixNo === 'QTCK' ||
  189. this.prefixNo === 'DBCK'
  190. ) {
  191. columns[i].type = FormTypes.popupJsh //显示
  192. } else {
  193. if (key === 'snList') {
  194. columns[i].type = FormTypes.popupJsh //显示
  195. } else {
  196. columns[i].type = FormTypes.input //显示
  197. }
  198. }
  199. } else if (key === 'expirationDate') {
  200. if (
  201. this.prefixNo === 'LSTH' ||
  202. this.prefixNo === 'CGRK' ||
  203. this.prefixNo === 'XSTH' ||
  204. this.prefixNo === 'QTRK'
  205. ) {
  206. columns[i].type = FormTypes.date //显示
  207. } else {
  208. columns[i].type = FormTypes.input //显示
  209. }
  210. } else {
  211. columns[i].type = FormTypes.normal //显示
  212. }
  213. } else {
  214. columns[i].type = FormTypes.hidden //隐藏
  215. }
  216. }
  217. }
  218. },
  219. initSystemConfig() {
  220. getCurrentSystemConfig().then((res) => {
  221. if (res.code === 200 && res.data) {
  222. let multiBillType = res.data.multiBillType
  223. let multiLevelApprovalFlag = res.data.multiLevelApprovalFlag
  224. this.checkFlag = getCheckFlag(multiBillType, multiLevelApprovalFlag, this.prefixNo)
  225. this.purchaseBySaleFlag = res.data.purchaseBySaleFlag === '1' ? true : false
  226. this.inOutManageFlag = res.data.inOutManageFlag === '1' ? true : false
  227. if (res.data.auditPrintFlag === '1') {
  228. if (this.model.status === '0' || this.model.status === '9') {
  229. this.isShowPrintBtn = false
  230. } else {
  231. this.isShowPrintBtn = true
  232. }
  233. } else {
  234. this.isShowPrintBtn = true
  235. }
  236. }
  237. })
  238. },
  239. initSupplier(isChecked) {
  240. let that = this
  241. findBySelectSup({}).then((res) => {
  242. if (res) {
  243. that.supList = res
  244. if (isChecked && res.length > 0) {
  245. that.form.setFieldsValue({ organId: res[0].id })
  246. }
  247. }
  248. })
  249. },
  250. initCustomer(isChecked) {
  251. let that = this
  252. findBySelectCus({}).then((res) => {
  253. if (res) {
  254. that.cusList = res
  255. if (isChecked && res.length > 0) {
  256. that.form.setFieldsValue({ organId: res[0].id })
  257. }
  258. }
  259. })
  260. },
  261. initRetail(isChecked) {
  262. let that = this
  263. findBySelectRetail({}).then((res) => {
  264. if (res) {
  265. that.retailList = res
  266. if (isChecked && res.length > 0) {
  267. that.form.setFieldsValue({ organId: res[0].id })
  268. }
  269. }
  270. })
  271. },
  272. initSalesman() {
  273. let that = this
  274. getPersonByNumType({ type: 1 }).then((res) => {
  275. if (res) {
  276. that.personList.options = res
  277. }
  278. })
  279. },
  280. initDepot() {
  281. let that = this
  282. getAction('/depot/findDepotByCurrentUser').then((res) => {
  283. if (res.code === 200) {
  284. let arr = res.data
  285. this.depotList = res.data.map(item => {
  286. return {
  287. ...item,
  288. value: item.id,
  289. label: item.depotName,
  290. }
  291. })
  292. for (let item of that.materialTable.columns) {
  293. if (item.key == 'depotId' || item.key == 'anotherDepotId') {
  294. item.options = []
  295. for (let i = 0; i < arr.length; i++) {
  296. let depotInfo = {}
  297. depotInfo.value = arr[i].id + '' //注意-此处value必须为字符串格式
  298. depotInfo.text = arr[i].depotName
  299. depotInfo.title = arr[i].depotName
  300. item.options.push(depotInfo)
  301. }
  302. }
  303. }
  304. }
  305. })
  306. },
  307. initAccount(isChecked) {
  308. let that = this
  309. getAccount({}).then((res) => {
  310. if (res && res.code === 200) {
  311. let list = res.data.accountList
  312. let lastId = list.length > 0 ? list[0].id : ''
  313. getCurrentSystemConfig().then((res) => {
  314. if (res.code === 200 && res.data) {
  315. let multiAccountFlag = res.data.multiAccountFlag
  316. if (multiAccountFlag === '1') {
  317. list.splice(0, 0, { id: 0, name: '多账户' })
  318. }
  319. }
  320. that.accountList = list
  321. if (isChecked) {
  322. that.form.setFieldsValue({ accountId: lastId })
  323. }
  324. })
  325. }
  326. })
  327. },
  328. handleManyAccount() {
  329. this.selectAccount(0)
  330. },
  331. selectAccount(value) {
  332. if (value === 0) {
  333. //多账户
  334. this.$refs.manyAccountModalForm.edit(this.accountIdList, this.accountMoneyList)
  335. this.$refs.manyAccountModalForm.title = '多账户结算'
  336. this.manyAccountBtnStatus = true
  337. } else {
  338. this.accountIdList = []
  339. this.accountMoneyList = []
  340. this.manyAccountBtnStatus = false
  341. }
  342. },
  343. manyAccountModalFormOk(idList, moneyList, allPrice) {
  344. this.accountIdList = idList
  345. this.accountMoneyList = moneyList
  346. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  347. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  348. let debt = (discountLastMoney + otherMoney - allPrice).toFixed(2)
  349. this.$nextTick(() => {
  350. this.form.setFieldsValue({ changeAmount: allPrice, debt: debt })
  351. })
  352. },
  353. addSupplier() {
  354. this.$refs.vendorModalForm.add()
  355. this.$refs.vendorModalForm.title = '新增供应商'
  356. this.$refs.vendorModalForm.disableSubmit = false
  357. },
  358. addCustomer() {
  359. this.$refs.customerModalForm.add()
  360. this.$refs.customerModalForm.title =
  361. '新增客户(提醒:如果找不到新添加的客户,请到用户管理检查是否分配了该客户权限)'
  362. this.$refs.customerModalForm.disableSubmit = false
  363. },
  364. addMember() {
  365. this.$refs.memberModalForm.add()
  366. this.$refs.memberModalForm.title = '新增会员'
  367. this.$refs.memberModalForm.disableSubmit = false
  368. },
  369. handleBatchSetDepot() {
  370. this.$refs.batchSetDepotModalForm.add()
  371. this.$refs.batchSetDepotModalForm.title = '批量切换仓库'
  372. this.$refs.batchSetDepotModalForm.disableSubmit = false
  373. },
  374. addDepot() {
  375. this.$refs.depotModalForm.add()
  376. this.$refs.depotModalForm.title = '新增仓库'
  377. this.$refs.depotModalForm.disableSubmit = false
  378. },
  379. addAccount() {
  380. this.$refs.accountModalForm.add()
  381. this.$refs.accountModalForm.title = '新增结算账户'
  382. this.$refs.accountModalForm.disableSubmit = false
  383. },
  384. vendorModalFormOk() {
  385. this.initSupplier(1)
  386. },
  387. customerModalFormOk() {
  388. this.initCustomer(1)
  389. },
  390. memberModalFormOk() {
  391. this.initRetail(1)
  392. },
  393. batchSetDepotModalFormOk(depotId) {
  394. this.getAllTable()
  395. .then((tables) => {
  396. return getListData(this.form, tables)
  397. })
  398. .then((allValues) => {
  399. //获取单据明细列表信息
  400. let detailArr = allValues.tablesValue[0].values
  401. console.log('detailArr=======',detailArr)
  402. // let batchNumbers = ''
  403. // for (let detail of detailArr) {
  404. // batchNumbers += detail.batchNumber + ','
  405. // }
  406. // if (batchNumbers) {
  407. // batchNumbers = batchNumbers.substring(0, batchNumbers.length - 1)
  408. // }
  409. // let param = {
  410. // batchNumber: batchNumbers,
  411. // organId: this.form.getFieldValue('organId'),
  412. // depotId: depotId,
  413. // mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  414. // prefixNo: this.prefixNo,
  415. // }
  416. // getMaterialByBatchNumber(param).then((res) => {
  417. // if (res && res.code === 200) {
  418. // let mList = res.data
  419. // //构造新的列表数组,用于存放单据明细信息
  420. // let newDetailArr = []
  421. // if (mList && mList.length) {
  422. // for (let i = 0; i < detailArr.length; i++) {
  423. // let item = detailArr[i]
  424. // item.depotId = depotId
  425. // for (let j = 0; j < mList.length; j++) {
  426. // if (mList[j].batchNumber === item.batchNumber) {
  427. // item.stock = mList[j].stock
  428. // }
  429. // }
  430. // newDetailArr.push(item)
  431. // }
  432. // } else {
  433. // for (let i = 0; i < detailArr.length; i++) {
  434. // let item = detailArr[i]
  435. // item.depotId = depotId
  436. // newDetailArr.push(item)
  437. // }
  438. // }
  439. // this.materialTable.dataSource = newDetailArr
  440. // }
  441. // })
  442. })
  443. },
  444. depotModalFormOk() {
  445. this.initDepot()
  446. },
  447. accountModalFormOk() {
  448. this.initAccount(1)
  449. },
  450. workflowModalFormOk() {
  451. this.close()
  452. },
  453. onAdded(event) {
  454. let that = this
  455. const { row, target } = event
  456. target.setValues([{ rowKey: row.id, values: { operNumber: 0 } }])
  457. //自动下滑到最后一行
  458. setTimeout(function () {
  459. that.$refs.materialDataTable.resetScrollTop((target.rows.length + 1) * that.$refs.materialDataTable.rowHeight)
  460. }, 1000)
  461. },
  462. //根据仓库名、商品条码带出对应的仓位货架、库存数量
  463. // async setProPosition(barCode, depotId, event){
  464. // const { row, column, value, target } = event
  465. // findStockByDepotAndBarCode({ depotId: depotId, barCode: barCode }).then(res => {
  466. // const {position='',stock} = res.data
  467. // target.setValues([
  468. // {
  469. // rowKey: row.id,
  470. // values: { position:position,inventory: stock },
  471. // },
  472. // ])
  473. // target.$forceUpdate()
  474. // })
  475. // },
  476. // 选择供应商、客户带出税率
  477. getTatRate(id){
  478. getAction('/supplier/info', { id }).then((res) => {
  479. if (res && res.code === 200) {
  480. let info = res.data.info
  481. const taxRate = info.taxRate?(info.taxRate - 0) : 0
  482. this.form.setFieldsValue({
  483. taxRate
  484. })
  485. const target = this.$refs[this.refKeys[0]]
  486. if(target){
  487. this.autoCalcPrice(target,taxRate)
  488. }
  489. }
  490. })
  491. },
  492. // 自动计算表格价格
  493. autoCalcPrice(editTableVm,taxRate){
  494. const that = this
  495. editTableVm.getValues((error, values) => {
  496. const updateRows = []
  497. console.log('9999999------',values)
  498. for(let row of values){
  499. const allPrice = row.allPrice - 0
  500. const taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  501. const taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  502. updateRows.push({
  503. rowKey: row.id,
  504. values: { taxRate, taxMoney: taxMoney, taxLastMoney: taxLastMoney },
  505. })
  506. }
  507. editTableVm.setValues(updateRows)
  508. editTableVm.recalcAllStatisticsColumns()
  509. that.autoChangePrice(editTableVm)
  510. editTableVm.$forceUpdate()
  511. })
  512. },
  513. //默认采购价、销售价与当前采购价、销售价不一致
  514. getDefaultWholesaleDecimal(index,key,value){
  515. if(this.materialTable.dataSource[index]&&this.materialTable.dataSource[index][key]){
  516. return this.materialTable.dataSource[index][key] != value
  517. }
  518. return false
  519. },
  520. onChangePrice(e,callback){
  521. const { value } = e.target;
  522. callback(value)
  523. },
  524. // 仓库名移动到基础表单
  525. async changeDepot(depotId,editTableRefName){
  526. const target = this.$refs[`${editTableRefName}`]
  527. if(!target){
  528. return
  529. }
  530. target.getValues(async (error, values) => {
  531. const rows = values
  532. const updateRows = []
  533. for (let row of rows) {
  534. const barCode = row.barCode
  535. if(depotId&&barCode){
  536. const res = await findStockByDepotAndBarCode({ depotId: depotId, barCode: barCode })
  537. const {position='',stock=0} = res.data
  538. updateRows.push({
  539. rowKey: row.id,
  540. values: { position:position,inventory: stock, stock,depotId },
  541. })
  542. }
  543. }
  544. target.setValues(updateRows)
  545. target.$forceUpdate()
  546. })
  547. },
  548. //单元值改变一个字符就触发一次
  549. onValueChange(event) {
  550. let that = this
  551. const { type, row, column, value, target } = event
  552. let param, snList, batchNumber, operNumber, unitPrice, allPrice, taxRate, taxMoney, taxLastMoney
  553. switch (column.key) {
  554. // case 'depotId':
  555. // console.log('row========', row)
  556. // // // 选择商品自动带出barCode、商品ID
  557. // if(row.depotId&&row.barCode&&type=='select'){
  558. // // // 根据仓库id自动带出仓位货架(若有)参数:商品id、仓库id
  559. // this.setProPosition(row.barCode, row.depotId, event)
  560. // }
  561. // break
  562. case 'barCode':
  563. param = {
  564. barCode: value,
  565. organId: this.form.getFieldValue('organId'),
  566. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  567. prefixNo: this.prefixNo,
  568. }
  569. const formDepotId = that.form.getFieldValue('depotId')
  570. const formTaxRate = that.form.getFieldValue('taxRate')
  571. getMaterialByBarCode(param).then(async (res) => {
  572. if (res && res.code === 200) {
  573. let mList = res.data
  574. let mArr = await target.getValuesPromise(false)
  575. const clickRowIndex = mArr.findIndex(item => item.id === row.id)
  576. for(let i = 0; i < mList.length; i++){
  577. const rawInfo = mList[i]
  578. const mObj = that.parseInfoToObj(rawInfo)
  579. mObj.allPrice = ((mObj.unitPrice - 0)* (mObj.operNumber))
  580. mObj.taxRate = formTaxRate || 0
  581. mObj.taxMoney = (mObj.taxRate * 0.01 * mObj.allPrice)
  582. mObj.taxLastMoney = (mObj.allPrice + mObj.taxMoney)
  583. mObj.depotId = formDepotId
  584. mObj.position = ''
  585. if(formDepotId){
  586. const res = await findStockByDepotAndBarCode({ depotId: formDepotId, barCode: mObj.barCode })
  587. const {position='',stock=0} = res.data
  588. mObj.stock = stock
  589. mObj.inventory = stock
  590. mObj.position = position
  591. }
  592. mArr.splice(clickRowIndex,0,mObj)
  593. }
  594. this.materialTable.dataSource = mArr.filter(item => item.id !== row.id)
  595. target.$nextTick(() => {
  596. target.recalcAllStatisticsColumns()
  597. setTimeout(() => {
  598. that.autoChangePrice(target)
  599. },100)
  600. })
  601. }
  602. })
  603. break
  604. case 'snList':
  605. snList = value
  606. if (snList) {
  607. snList = snList.replaceAll(',', ',')
  608. let snArr = snList.split(',')
  609. operNumber = snArr.length
  610. taxRate = row.taxRate - 0 //税率
  611. unitPrice = row.unitPrice - 0 //单价
  612. allPrice = (unitPrice * operNumber).toFixed(2) - 0
  613. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  614. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  615. target.setValues([
  616. {
  617. rowKey: row.id,
  618. values: { operNumber: operNumber, allPrice: allPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney },
  619. },
  620. ])
  621. target.recalcAllStatisticsColumns()
  622. that.autoChangePrice(target)
  623. }
  624. break
  625. case 'operNumber':
  626. operNumber = value - 0
  627. taxRate = row.taxRate - 0 //税率
  628. unitPrice = row.unitPrice - 0 //单价
  629. allPrice = (unitPrice * operNumber).toFixed(2) - 0
  630. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  631. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  632. target.setValues([
  633. { rowKey: row.id, values: { allPrice: allPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney } },
  634. ])
  635. target.recalcAllStatisticsColumns()
  636. that.autoChangePrice(target)
  637. break
  638. case 'unitPrice':
  639. operNumber = row.operNumber - 0 //数量
  640. unitPrice = value - 0 //单价
  641. taxRate = row.taxRate - 0 //税率
  642. allPrice = (unitPrice * operNumber).toFixed(2) - 0
  643. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  644. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  645. target.setValues([
  646. { rowKey: row.id, values: { allPrice: allPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney } },
  647. ])
  648. target.recalcAllStatisticsColumns()
  649. that.autoChangePrice(target)
  650. break
  651. case 'allPrice':
  652. operNumber = row.operNumber - 0 //数量
  653. taxRate = row.taxRate - 0 //税率
  654. allPrice = value - 0
  655. unitPrice = (allPrice / operNumber).toFixed(2) - 0 //单价
  656. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  657. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  658. target.setValues([
  659. { rowKey: row.id, values: { unitPrice: unitPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney } },
  660. ])
  661. target.recalcAllStatisticsColumns()
  662. that.autoChangePrice(target)
  663. break
  664. // case 'taxRate':
  665. // operNumber = row.operNumber - 0 //数量
  666. // allPrice = row.allPrice - 0
  667. // unitPrice = row.unitPrice - 0
  668. // taxRate = value - 0 //税率
  669. // taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  670. // taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  671. // target.setValues([{ rowKey: row.id, values: { taxMoney: taxMoney, taxLastMoney: taxLastMoney } }])
  672. // target.recalcAllStatisticsColumns()
  673. // that.autoChangePrice(target)
  674. // break
  675. // case 'taxLastMoney':
  676. // console.log('taxLastMoney---------')
  677. // operNumber = row.operNumber - 0 //数量
  678. // taxLastMoney = value - 0
  679. // taxRate = row.taxRate - 0 //税率
  680. // if (taxRate) {
  681. // unitPrice = (taxLastMoney / operNumber / (1 + taxRate * 0.01)).toFixed(2) - 0
  682. // allPrice = (unitPrice * operNumber).toFixed(2) - 0
  683. // taxMoney = (taxLastMoney - allPrice).toFixed(2) - 0
  684. // } else {
  685. // //税率为0的情况,特殊处理
  686. // allPrice = taxLastMoney
  687. // unitPrice = (allPrice / operNumber).toFixed(2) - 0 //单价
  688. // taxMoney = 0
  689. // }
  690. // target.setValues([
  691. // { rowKey: row.id, values: { unitPrice: unitPrice, allPrice: allPrice, taxMoney: taxMoney } },
  692. // ])
  693. // target.recalcAllStatisticsColumns()
  694. // that.autoChangePrice(target)
  695. // break
  696. case 'unit':
  697. // row.actualQuantityInStorage=
  698. if (row.unitId) {
  699. let arr = row.unitList
  700. if (!Array.isArray(arr)) {
  701. arr = JSON.parse(arr)
  702. }
  703. // for (let i of arr) {
  704. // if (i.name === value) {
  705. // target.setValues([{ rowKey: row.id, values: { unitName: i.name } }])
  706. // }
  707. // }
  708. }
  709. target.$forceUpdate()
  710. }
  711. },
  712. //转为商品对象
  713. parseInfoToObj(mInfo) {
  714. return {
  715. barCode: mInfo.barCode,
  716. name: mInfo.name,
  717. standard: mInfo.standard,
  718. model: mInfo.model,
  719. color: mInfo.color,
  720. brand: mInfo.brand,
  721. materialOther: mInfo.materialOther,
  722. unit: mInfo.commodityUnit,
  723. sku: mInfo.sku,
  724. operNumber: 1,
  725. unitPrice: mInfo.billPrice * (mInfo.ratio||1), //单价
  726. wholesaleDecimal:mInfo.defaultWholesaleDecimal, //销售价
  727. defaultWholesaleDecimal: mInfo.defaultWholesaleDecimal, //默认销售价 不展示
  728. defaultPurchaseDecimal: mInfo.defaultPurchaseDecimal, //默认采购价 不展示
  729. productionDate: mInfo.productionDate,
  730. expiryNum: mInfo.expiryNum,
  731. position: mInfo.position,
  732. unitName: mInfo.unitName,
  733. actualQuantityInStorage: mInfo.actualQuantityInStorage,
  734. warehousingVariance: mInfo.warehousingVariance,
  735. warehousingUser: mInfo.warehousingUser,
  736. warehousingTime: mInfo.warehousingTime,
  737. unitId: mInfo.unitId,
  738. unitList: mInfo.unitList,
  739. depotId: mInfo.depotId,
  740. inventory: mInfo.inventory,
  741. ratio: mInfo.ratio,
  742. }
  743. },
  744. //使得型号、颜色、扩展信息、sku等为隐藏
  745. changeColumnHide() {
  746. this.changeFormTypes(this.materialTable.columns, 'model', 0)
  747. this.changeFormTypes(this.materialTable.columns, 'color', 0)
  748. this.changeFormTypes(this.materialTable.columns, 'brand', 0)
  749. this.changeFormTypes(this.materialTable.columns, 'mfrs', 0)
  750. this.changeFormTypes(this.materialTable.columns, 'materialOther', 0)
  751. this.changeFormTypes(this.materialTable.columns, 'sku', 0)
  752. },
  753. //使得sku、序列号、批号、到期日等为显示
  754. changeColumnShow(info) {
  755. // if (info.util) {
  756. // this.changeUnitType(this.materialTable.columns, info, 'unit')
  757. // }
  758. if (info.model) {
  759. this.changeFormTypes(this.materialTable.columns, 'model', 1)
  760. }
  761. if (info.color) {
  762. this.changeFormTypes(this.materialTable.columns, 'color', 1)
  763. }
  764. if (info.brand) {
  765. this.changeFormTypes(this.materialTable.columns, 'brand', 1)
  766. }
  767. if (info.mfrs) {
  768. this.changeFormTypes(this.materialTable.columns, 'mfrs', 1)
  769. }
  770. if (info.materialOther) {
  771. this.changeFormTypes(this.materialTable.columns, 'materialOther', 1)
  772. }
  773. if (info.sku) {
  774. this.changeFormTypes(this.materialTable.columns, 'sku', 1)
  775. }
  776. if (info.enableSerialNumber === '1') {
  777. //如果开启出入库管理,并且类型等于采购、采购退货、销售、销售退货,则跳过
  778. if (
  779. this.inOutManageFlag &&
  780. (this.prefixNo === 'CGRK' || this.prefixNo === 'CGTH' || this.prefixNo === 'XSCK' || this.prefixNo === 'XSTH')
  781. ) {
  782. //跳过
  783. } else {
  784. this.changeFormTypes(this.materialTable.columns, 'snList', 1)
  785. }
  786. }
  787. if (info.enableBatchNumber === '1') {
  788. //如果开启出入库管理,并且类型等于采购、采购退货、销售、销售退货,则跳过
  789. if (
  790. this.inOutManageFlag &&
  791. (this.prefixNo === 'CGRK' || this.prefixNo === 'CGTH' || this.prefixNo === 'XSCK' || this.prefixNo === 'XSTH')
  792. ) {
  793. //跳过
  794. } else {
  795. this.changeFormTypes(this.materialTable.columns, 'batchNumber', 1)
  796. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 1)
  797. }
  798. }
  799. },
  800. //删除一行或多行的时候触发
  801. onDeleted(ids, target) {
  802. target.recalcAllStatisticsColumns()
  803. this.autoChangePrice(target)
  804. },
  805. //改变优惠、本次付款、欠款的值
  806. autoChangePrice(target) {
  807. let allTaxLastMoney = target.getStatisticsValue('taxLastMoney')||0
  808. let discount = this.form.getFieldValue('discount') ? this.form.getFieldValue('discount') - 0 : 0
  809. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  810. let deposit = this.form.getFieldValue('deposit') ? this.form.getFieldValue('deposit') - 0 : 0
  811. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  812. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  813. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  814. if (deposit) {
  815. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  816. }
  817. this.$nextTick(() => {
  818. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  819. this.form.setFieldsValue({
  820. discount: discount,
  821. discountMoney: discountMoney,
  822. discountLastMoney: discountLastMoney,
  823. changeAmount: changeAmountNew,
  824. debt: (discountLastMoney + (otherMoney || 0) - deposit - changeAmountNew).toFixed(2),
  825. })
  826. })
  827. },
  828. //改变优惠率
  829. onChangeDiscount(e) {
  830. const value = e.target.value - 0
  831. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  832. let deposit = this.form.getFieldValue('deposit')
  833. let allTaxLastMoney = this.$refs.materialDataTable.getStatisticsValue('taxLastMoney') - 0
  834. let discountMoneyNew = (allTaxLastMoney * value * 0.01).toFixed(2) - 0
  835. let discountLastMoneyNew = (allTaxLastMoney - discountMoneyNew).toFixed(2) - 0
  836. let changeAmountNew = (discountLastMoneyNew + otherMoney).toFixed(2) - 0
  837. if (deposit) {
  838. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  839. }
  840. this.$nextTick(() => {
  841. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  842. this.form.setFieldsValue({
  843. discountMoney: discountMoneyNew,
  844. discountLastMoney: discountLastMoneyNew,
  845. changeAmount: changeAmountNew,
  846. debt: 0,
  847. })
  848. })
  849. },
  850. //改变付款优惠
  851. onChangeDiscountMoney(e) {
  852. const value = e.target.value - 0
  853. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  854. let deposit = this.form.getFieldValue('deposit')
  855. let allTaxLastMoney = this.$refs.materialDataTable.getStatisticsValue('taxLastMoney') - 0
  856. let discountNew = ((value / allTaxLastMoney) * 100).toFixed(2) - 0
  857. let discountLastMoneyNew = (allTaxLastMoney - value).toFixed(2) - 0
  858. let changeAmountNew = (discountLastMoneyNew + otherMoney).toFixed(2) - 0
  859. if (deposit) {
  860. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  861. }
  862. this.$nextTick(() => {
  863. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  864. this.form.setFieldsValue({
  865. discount: discountNew,
  866. discountLastMoney: discountLastMoneyNew,
  867. changeAmount: changeAmountNew,
  868. debt: 0,
  869. })
  870. })
  871. },
  872. //其它费用
  873. onChangeOtherMoney(e) {
  874. const value = e.target.value - 0
  875. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  876. let deposit = this.form.getFieldValue('deposit')
  877. let changeAmountNew = (discountLastMoney + value).toFixed(2) - 0
  878. if (deposit) {
  879. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  880. }
  881. this.$nextTick(() => {
  882. this.form.setFieldsValue({ changeAmount: changeAmountNew, debt: 0 })
  883. })
  884. },
  885. //改变扣除订金
  886. onChangeDeposit(e) {
  887. const value = e.target.value - 0
  888. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  889. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  890. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  891. if (value) {
  892. changeAmountNew = (changeAmountNew - value).toFixed(2) - 0
  893. }
  894. this.$nextTick(() => {
  895. this.form.setFieldsValue({ changeAmount: changeAmountNew, debt: 0 })
  896. })
  897. },
  898. //改变本次付款
  899. onChangeChangeAmount(e) {
  900. const value = e.target.value - 0
  901. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  902. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  903. let deposit = this.form.getFieldValue('deposit')
  904. let debtNew = (discountLastMoney + otherMoney - value).toFixed(2) - 0
  905. if (deposit) {
  906. debtNew = (debtNew - deposit).toFixed(2) - 0
  907. }
  908. this.$nextTick(() => {
  909. this.form.setFieldsValue({ debt: debtNew })
  910. })
  911. },
  912. //切换客户信息改变商品单价
  913. handleOrganChange(value) {
  914. let organId = value
  915. this.getAllTable()
  916. .then((tables) => {
  917. return getListData(this.form, tables)
  918. })
  919. .then((allValues) => {
  920. console.log(1233444,allValues)
  921. let detailArr = allValues.tablesValue[0].values
  922. let batchNumberStr = ''
  923. for (let detail of detailArr) {
  924. if (detail.batchNumber) {
  925. batchNumberStr += detail.batchNumber + ','
  926. }
  927. }
  928. if (batchNumberStr) {
  929. let param = {
  930. batchNumber: batchNumberStr,
  931. organId: organId,
  932. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  933. prefixNo: this.prefixNo,
  934. }
  935. getMaterialByBatchNumber(param).then((res) => {
  936. if (res && res.code === 200) {
  937. let allLastMoney = 0
  938. let allTaxLastMoney = 0
  939. //获取单据明细列表信息
  940. let detailArr = allValues.tablesValue[0].values
  941. //构造新的列表数组,用于存放单据明细信息
  942. let newDetailArr = []
  943. for (let detail of detailArr) {
  944. if (detail.batchNumber) {
  945. //如果条码重复,就在给原来的数量加1
  946. let mList = res.data
  947. for (let i = 0; i < mList.length; i++) {
  948. if (detail.batchNumber === mList[i].batchNumber) {
  949. //由于改变了商品单价,需要同时更新相关金额和价税合计
  950. let taxRate = detail.taxRate - 0 //税率
  951. detail.unitPrice = mList[i].billPrice - 0 //单价
  952. detail.allPrice = (detail.unitPrice * detail.operNumber).toFixed(2) - 0
  953. detail.taxMoney = (taxRate * 0.01 * detail.allPrice).toFixed(2) - 0
  954. detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2) - 0
  955. }
  956. }
  957. newDetailArr.push(detail)
  958. }
  959. }
  960. this.materialTable.dataSource = newDetailArr
  961. //更新优惠后金额、本次付款等信息
  962. for (let newDetail of newDetailArr) {
  963. allLastMoney = allLastMoney + (newDetail.allPrice - 0)
  964. allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney - 0)
  965. }
  966. let discount = this.form.getFieldValue('discount') - 0
  967. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  968. let deposit = this.form.getFieldValue('deposit')
  969. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  970. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  971. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  972. if (deposit) {
  973. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  974. }
  975. this.$nextTick(() => {
  976. changeAmountNew = this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  977. this.form.setFieldsValue({
  978. discount: discount,
  979. discountMoney: discountMoney,
  980. discountLastMoney: discountLastMoney,
  981. changeAmount: changeAmountNew,
  982. debt: 0,
  983. })
  984. })
  985. }
  986. })
  987. }
  988. })
  989. },
  990. scanEnter() {
  991. this.scanStatus = false
  992. this.$nextTick(() => {
  993. this.$refs.scanBarCode.focus()
  994. })
  995. },
  996. //扫码之后回车
  997. scanPressEnter() {
  998. let that = this
  999. if (this.scanBarCode) {
  1000. this.getAllTable()
  1001. .then((tables) => {
  1002. return getListData(this.form, tables)
  1003. })
  1004. .then((allValues) => {
  1005. let param = {
  1006. barCode: this.scanBarCode.trim(),
  1007. organId: this.form.getFieldValue('organId'),
  1008. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  1009. prefixNo: this.prefixNo,
  1010. }
  1011. getMaterialByBatchNumber(param).then((res) => {
  1012. if (res && res.code === 200) {
  1013. let hasFinished = false
  1014. let allLastMoney = 0
  1015. let allTaxLastMoney = 0
  1016. //获取单据明细列表信息
  1017. let detailArr = allValues.tablesValue[0].values
  1018. //构造新的列表数组,用于存放单据明细信息
  1019. let newDetailArr = []
  1020. let hasAdd = false
  1021. for (let detail of detailArr) {
  1022. if (detail.barCode) {
  1023. //如果扫码结果和条码重复,就在给原来的数量加1
  1024. if (detail.barCode === this.scanBarCode.trim() && !hasAdd) {
  1025. detail.operNumber = detail.operNumber - 0 + 1
  1026. //由于改变了商品数量,需要同时更新相关金额和价税合计
  1027. let taxRate = detail.taxRate - 0 //税率
  1028. let unitPrice = detail.unitPrice - 0 //单价
  1029. detail.allPrice = (unitPrice * detail.operNumber).toFixed(2) - 0
  1030. detail.taxMoney = (taxRate * 0.01 * detail.allPrice).toFixed(2) - 0
  1031. detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2) - 0
  1032. hasFinished = true
  1033. hasAdd = true
  1034. }
  1035. //如果扫码结果和序列号重复,就直接跳过
  1036. if (detail.snList === this.scanBarCode.trim()) {
  1037. this.$message.warning('抱歉,已经扫描过该序列号!')
  1038. hasFinished = true
  1039. }
  1040. newDetailArr.push(detail)
  1041. }
  1042. }
  1043. if (!hasFinished) {
  1044. //将扫码的条码对应的商品加入列表
  1045. let item = {}
  1046. let mList = res.data
  1047. if (mList && mList.length > 0) {
  1048. let mInfo = mList[0]
  1049. this.changeColumnShow(mInfo)
  1050. item.depotId = mInfo.depotId
  1051. item.barCode = mInfo.mBarCode
  1052. item.name = mInfo.name
  1053. item.standard = mInfo.standard
  1054. item.model = mInfo.model
  1055. item.color = mInfo.color
  1056. item.materialOther = mInfo.materialOther
  1057. item.stock = mInfo.stock
  1058. item.unit = mInfo.commodityUnit
  1059. item.sku = mInfo.sku
  1060. if (mInfo.mBarCode !== this.scanBarCode.trim()) {
  1061. if (
  1062. this.prefixNo === 'LSCK' ||
  1063. this.prefixNo === 'CGTH' ||
  1064. this.prefixNo === 'XSCK' ||
  1065. this.prefixNo === 'QTCK'
  1066. ) {
  1067. //此时给序列号赋值
  1068. item.snList = this.scanBarCode.trim()
  1069. }
  1070. }
  1071. item.operNumber = 1
  1072. item.unitPrice = mInfo.billPrice
  1073. item.allPrice = mInfo.billPrice
  1074. item.taxRate = 0
  1075. item.taxMoney = 0
  1076. item.taxLastMoney = mInfo.billPrice
  1077. newDetailArr.push(item)
  1078. } else {
  1079. this.$message.warning('抱歉,此条码不存在商品信息!')
  1080. }
  1081. }
  1082. //组合和拆分单据给商品类型进行重新赋值
  1083. for (let i = 0; i < newDetailArr.length; i++) {
  1084. if (i === 0) {
  1085. newDetailArr[0].mType = '组合件'
  1086. } else {
  1087. newDetailArr[i].mType = '普通子件'
  1088. }
  1089. }
  1090. this.materialTable.dataSource = newDetailArr
  1091. //更新优惠后金额、本次付款等信息
  1092. for (let newDetail of newDetailArr) {
  1093. allLastMoney = allLastMoney + (newDetail.allPrice - 0)
  1094. allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney - 0)
  1095. }
  1096. let discount = this.form.getFieldValue('discount') - 0
  1097. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  1098. let deposit = this.form.getFieldValue('deposit')
  1099. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  1100. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  1101. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  1102. if (deposit) {
  1103. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  1104. }
  1105. if (this.prefixNo === 'LSCK' || this.prefixNo === 'LSTH') {
  1106. this.$nextTick(() => {
  1107. this.form.setFieldsValue({ changeAmount: allLastMoney, getAmount: allLastMoney, backAmount: 0 })
  1108. })
  1109. } else {
  1110. this.$nextTick(() => {
  1111. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  1112. this.form.setFieldsValue({
  1113. discount: discount,
  1114. discountMoney: discountMoney,
  1115. discountLastMoney: discountLastMoney,
  1116. changeAmount: changeAmountNew,
  1117. debt: 0,
  1118. })
  1119. })
  1120. }
  1121. //置空扫码的内容
  1122. this.scanBarCode = ''
  1123. this.$refs.scanBarCode.focus()
  1124. //自动下滑到最后一行
  1125. setTimeout(function () {
  1126. that.$refs.materialDataTable.resetScrollTop(
  1127. (newDetailArr.length + 1) * that.$refs.materialDataTable.rowHeight
  1128. )
  1129. }, 1000)
  1130. }
  1131. })
  1132. })
  1133. }
  1134. },
  1135. stopScan() {
  1136. this.scanStatus = true
  1137. this.scanBarCode = ''
  1138. },
  1139. onImport(prefixNo) {
  1140. this.$refs.importItemModalForm.add(prefixNo)
  1141. },
  1142. importItemModalFormOk(data) {
  1143. this.materialTable.dataSource = data
  1144. this.$nextTick(() => {
  1145. let discountLastMoney = 0
  1146. for (let i = 0; i < data.length; i++) {
  1147. discountLastMoney += data[i].taxLastMoney
  1148. this.changeColumnShow(data[i])
  1149. }
  1150. this.form.setFieldsValue({ discountLastMoney: discountLastMoney })
  1151. })
  1152. },
  1153. //保存并审核
  1154. handleOkAndCheck() {
  1155. this.billStatus = '1'
  1156. this.handleOk()
  1157. },
  1158. //发起流程
  1159. handleWorkflow() {
  1160. if (this.model && this.model.number) {
  1161. getPlatformConfigByKey({ platformKey: 'send_workflow_url' }).then((res) => {
  1162. if (res && res.code === 200) {
  1163. let sendWorkflowUrl = res.data.platformValue + '&no=' + this.model.number + '&type=1'
  1164. this.$refs.modalWorkflow.show(this.model, sendWorkflowUrl, this.model.number, 1, 320)
  1165. this.$refs.modalWorkflow.title = '发起流程'
  1166. }
  1167. })
  1168. } else {
  1169. this.$message.warning('请先保存单据后再提交流程!')
  1170. }
  1171. },
  1172. //三联打印预览
  1173. handlePrint(billType) {
  1174. if (this.model.id) {
  1175. getPlatformConfigByKey({ platformKey: 'bill_print_url' }).then((res) => {
  1176. if (res && res.code === 200) {
  1177. let billPrintUrl = res.data.platformValue + '?no=' + this.model.number
  1178. let billPrintHeight = this.materialTable.dataSource.length * 50 + 600
  1179. this.$refs.modalPrint.show(this.model, billPrintUrl, billPrintHeight)
  1180. this.$refs.modalPrint.title = billType + '-三联打印预览'
  1181. }
  1182. })
  1183. } else {
  1184. this.$message.warning('请先保存单据后再打印!')
  1185. }
  1186. },
  1187. //加载平台配置信息
  1188. initPlatform() {
  1189. getPlatformConfigByKey({ platformKey: 'bill_print_flag' }).then((res) => {
  1190. if (res && res.code === 200) {
  1191. this.billPrintFlag = res.data.platformValue === '1' ? true : false
  1192. }
  1193. })
  1194. },
  1195. //加载快捷按钮:供应商、客户、会员、结算账户、仓库
  1196. initQuickBtn() {
  1197. let btnStrList = Vue.ls.get('winBtnStrList') //按钮功能列表 JSON字符串
  1198. if (btnStrList) {
  1199. for (let i = 0; i < btnStrList.length; i++) {
  1200. if (btnStrList[i].btnStr) {
  1201. this.quickBtn.vendor =
  1202. btnStrList[i].url === '/system/vendor' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.vendor
  1203. this.quickBtn.customer =
  1204. btnStrList[i].url === '/system/customer' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.customer
  1205. this.quickBtn.member =
  1206. btnStrList[i].url === '/system/member' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.member
  1207. this.quickBtn.account =
  1208. btnStrList[i].url === '/system/account' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.account
  1209. this.quickBtn.depot =
  1210. btnStrList[i].url === '/system/depot' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.depot
  1211. }
  1212. }
  1213. }
  1214. },
  1215. //获取出入库人
  1216. getCreatorSpinnerList() {
  1217. creatorSpinnerList().then((res) => {
  1218. this.currentUserList = res.data
  1219. })
  1220. },
  1221. },
  1222. }