BillModalMixin.js 47 KB

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