BillModalMixin.js 46 KB

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