BillModalMixin.js 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233
  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. this.getAllTable()
  379. .then((tables) => {
  380. return getListData(this.form, tables)
  381. })
  382. .then((allValues) => {
  383. //获取单据明细列表信息
  384. let detailArr = allValues.tablesValue[0].values
  385. let batchNumbers = ''
  386. for (let detail of detailArr) {
  387. batchNumbers += detail.batchNumber + ','
  388. }
  389. if (batchNumbers) {
  390. batchNumbers = batchNumbers.substring(0, batchNumbers.length - 1)
  391. }
  392. let param = {
  393. batchNumber: batchNumbers,
  394. organId: this.form.getFieldValue('organId'),
  395. depotId: depotId,
  396. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  397. prefixNo: this.prefixNo,
  398. }
  399. getMaterialByBatchNumber(param).then((res) => {
  400. if (res && res.code === 200) {
  401. let mList = res.data
  402. //构造新的列表数组,用于存放单据明细信息
  403. let newDetailArr = []
  404. if (mList && mList.length) {
  405. for (let i = 0; i < detailArr.length; i++) {
  406. let item = detailArr[i]
  407. item.depotId = depotId
  408. for (let j = 0; j < mList.length; j++) {
  409. if (mList[j].batchNumber === item.batchNumber) {
  410. item.stock = mList[j].stock
  411. }
  412. }
  413. newDetailArr.push(item)
  414. }
  415. } else {
  416. for (let i = 0; i < detailArr.length; i++) {
  417. let item = detailArr[i]
  418. item.depotId = depotId
  419. newDetailArr.push(item)
  420. }
  421. }
  422. this.materialTable.dataSource = newDetailArr
  423. }
  424. })
  425. })
  426. },
  427. depotModalFormOk() {
  428. this.initDepot()
  429. },
  430. accountModalFormOk() {
  431. this.initAccount(1)
  432. },
  433. workflowModalFormOk() {
  434. this.close()
  435. },
  436. onAdded(event) {
  437. let that = this
  438. const { row, target } = event
  439. target.setValues([{ rowKey: row.id, values: { operNumber: 0 } }])
  440. //自动下滑到最后一行
  441. setTimeout(function () {
  442. that.$refs.materialDataTable.resetScrollTop((target.rows.length + 1) * that.$refs.materialDataTable.rowHeight)
  443. }, 1000)
  444. if (this.currentSelectDepotId) {
  445. //如果单据选择过仓库,则直接从当前选择的仓库加载
  446. target.setValues([{ rowKey: row.id, values: { depotId: this.currentSelectDepotId } }])
  447. } else {
  448. getAction('/depot/findDepotByCurrentUser').then((res) => {
  449. if (res.code === 200) {
  450. let arr = res.data
  451. if (arr.length === 1) {
  452. target.setValues([{ rowKey: row.id, values: { depotId: arr[0].id + '' } }])
  453. } else {
  454. for (let i = 0; i < arr.length; i++) {
  455. if (arr[i].isDefault) {
  456. target.setValues([{ rowKey: row.id, values: { depotId: arr[i].id + '' } }])
  457. }
  458. }
  459. }
  460. }
  461. })
  462. }
  463. },
  464. //单元值改变一个字符就触发一次
  465. onValueChange(event) {
  466. let that = this
  467. const { type, row, column, value, target } = event
  468. let param, snList, batchNumber, operNumber, unitPrice, allPrice, taxRate, taxMoney, taxLastMoney
  469. switch (column.key) {
  470. case 'depotId':
  471. that.currentSelectDepotId = row.depotId
  472. if (row.barCode) {
  473. that.getStockByDepotBarCode(row, target)
  474. }
  475. break
  476. case 'batchNumber':
  477. param = {
  478. batchNumber: value,
  479. organId: this.form.getFieldValue('organId'),
  480. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  481. prefixNo: this.prefixNo,
  482. }
  483. getMaterialByBatchNumber(param).then((res) => {
  484. if (res && res.code === 200) {
  485. let mList = res.data
  486. if (value.indexOf(',') > -1) {
  487. //多个条码
  488. this.$refs.materialDataTable.getValues((error, values) => {
  489. values.pop() //移除最后一行数据
  490. let mArr = values
  491. for (let i = 0; i < mList.length; i++) {
  492. let mInfo = mList[i]
  493. if (mInfo.unitId) {
  494. mInfo.unitList = JSON.stringify(mInfo.unitList)
  495. }
  496. this.changeColumnShow(mInfo)
  497. let mObj = this.parseInfoToObj(mInfo)
  498. mObj.depotId = mInfo.depotId
  499. mObj.stock = mInfo.stock
  500. mArr.push(mObj)
  501. }
  502. let allPriceTotal = 0
  503. let taxLastMoneyTotal = 0
  504. for (let j = 0; j < mArr.length; j++) {
  505. allPriceTotal += mArr[j].allPrice - 0
  506. taxLastMoneyTotal += mArr[j].taxLastMoney - 0
  507. //组合和拆分单据给商品类型进行重新赋值
  508. if (j === 0) {
  509. mArr[0].mType = '组合件'
  510. } else {
  511. mArr[j].mType = '普通子件'
  512. }
  513. }
  514. this.materialTable.dataSource = mArr
  515. if (this.prefixNo === 'LSCK' || this.prefixNo === 'LSTH') {
  516. target.statisticsColumns.allPrice = allPriceTotal
  517. } else {
  518. target.statisticsColumns.taxLastMoney = taxLastMoneyTotal
  519. }
  520. that.autoChangePrice(target)
  521. //强制渲染
  522. target.$forceUpdate()
  523. })
  524. } else {
  525. //单个条码
  526. let depotIdSelected = this.prefixNo !== 'CGDD' && this.prefixNo !== 'XSDD' ? row.depotId : ''
  527. findStockByDepotAndBarCode({ depotId: depotIdSelected, barCode: row.batchNumber }).then((res) => {
  528. if (res && res.code === 200) {
  529. let mArr = []
  530. let mInfo = mList[0]
  531. if (mInfo.unitId) {
  532. mInfo.unitList = JSON.stringify(mInfo.unitList)
  533. }
  534. this.changeColumnShow(mInfo)
  535. let mInfoEx = this.parseInfoToObj(mInfo)
  536. mInfoEx.stock = res.data.stock
  537. let mObj = {
  538. rowKey: row.id,
  539. values: mInfoEx,
  540. }
  541. mArr.push(mObj)
  542. target.setValues(mArr)
  543. target.recalcAllStatisticsColumns()
  544. that.autoChangePrice(target)
  545. target.autoSelectBySpecialKey('operNumber', row.orderNum)
  546. //强制渲染
  547. target.$forceUpdate()
  548. }
  549. })
  550. }
  551. }
  552. })
  553. break
  554. case 'snList':
  555. snList = value
  556. if (snList) {
  557. snList = snList.replaceAll(',', ',')
  558. let snArr = snList.split(',')
  559. operNumber = snArr.length
  560. taxRate = row.taxRate - 0 //税率
  561. unitPrice = row.unitPrice - 0 //单价
  562. allPrice = (unitPrice * operNumber).toFixed(2) - 0
  563. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  564. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  565. target.setValues([
  566. {
  567. rowKey: row.id,
  568. values: { operNumber: operNumber, allPrice: allPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney },
  569. },
  570. ])
  571. target.recalcAllStatisticsColumns()
  572. that.autoChangePrice(target)
  573. }
  574. break
  575. // case 'batchNumber':
  576. // console.log('====================adasdas', column)
  577. // batchNumber = value
  578. // let depotItemId = ''
  579. // if (this.model.id) {
  580. // //只有在保存之后的编辑页面下才获取明细id
  581. // let rowId = row.id
  582. // if (rowId.length <= 19) {
  583. // depotItemId = rowId - 0
  584. // }
  585. // }
  586. // getBatchNumberList({
  587. // name: '',
  588. // depotItemId: depotItemId,
  589. // depotId: row.depotId,
  590. // barCode: row.barCode,
  591. // batchNumber: batchNumber,
  592. // }).then((res) => {
  593. // if (res && res.code === 200) {
  594. // if (res.data && res.data.rows) {
  595. // let info = res.data.rows[0]
  596. // operNumber = info.totalNum
  597. // taxRate = row.taxRate - 0 //税率
  598. // unitPrice = row.unitPrice - 0 //单价
  599. // allPrice = (unitPrice * operNumber).toFixed(2) - 0
  600. // taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  601. // taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  602. // target.setValues([
  603. // {
  604. // rowKey: row.id,
  605. // values: {
  606. // expirationDate: info.expirationDateStr,
  607. // operNumber: operNumber,
  608. // allPrice: allPrice,
  609. // taxMoney: taxMoney,
  610. // taxLastMoney: taxLastMoney,
  611. // },
  612. // },
  613. // ])
  614. // target.recalcAllStatisticsColumns()
  615. // that.autoChangePrice(target)
  616. // }
  617. // }
  618. // })
  619. // break
  620. case 'operNumber':
  621. operNumber = value - 0
  622. taxRate = row.taxRate - 0 //税率
  623. unitPrice = row.unitPrice - 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 'unitPrice':
  634. operNumber = row.operNumber - 0 //数量
  635. unitPrice = value - 0 //单价
  636. taxRate = row.taxRate - 0 //税率
  637. allPrice = (unitPrice * 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: { allPrice: allPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney } },
  642. ])
  643. target.recalcAllStatisticsColumns()
  644. that.autoChangePrice(target)
  645. break
  646. case 'allPrice':
  647. operNumber = row.operNumber - 0 //数量
  648. taxRate = row.taxRate - 0 //税率
  649. allPrice = value - 0
  650. unitPrice = (allPrice / operNumber).toFixed(2) - 0 //单价
  651. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  652. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  653. target.setValues([
  654. { rowKey: row.id, values: { unitPrice: unitPrice, taxMoney: taxMoney, taxLastMoney: taxLastMoney } },
  655. ])
  656. target.recalcAllStatisticsColumns()
  657. that.autoChangePrice(target)
  658. break
  659. case 'taxRate':
  660. operNumber = row.operNumber - 0 //数量
  661. allPrice = row.allPrice - 0
  662. unitPrice = row.unitPrice - 0
  663. taxRate = value - 0 //税率
  664. taxMoney = (taxRate * 0.01 * allPrice).toFixed(2) - 0
  665. taxLastMoney = (allPrice + taxMoney).toFixed(2) - 0
  666. target.setValues([{ rowKey: row.id, values: { taxMoney: taxMoney, taxLastMoney: taxLastMoney } }])
  667. target.recalcAllStatisticsColumns()
  668. that.autoChangePrice(target)
  669. break
  670. case 'taxLastMoney':
  671. operNumber = row.operNumber - 0 //数量
  672. taxLastMoney = value - 0
  673. taxRate = row.taxRate - 0 //税率
  674. if (taxRate) {
  675. unitPrice = (taxLastMoney / operNumber / (1 + taxRate * 0.01)).toFixed(2) - 0
  676. allPrice = (unitPrice * operNumber).toFixed(2) - 0
  677. taxMoney = (taxLastMoney - allPrice).toFixed(2) - 0
  678. } else {
  679. //税率为0的情况,特殊处理
  680. allPrice = taxLastMoney
  681. unitPrice = (allPrice / operNumber).toFixed(2) - 0 //单价
  682. taxMoney = 0
  683. }
  684. target.setValues([
  685. { rowKey: row.id, values: { unitPrice: unitPrice, allPrice: allPrice, taxMoney: taxMoney } },
  686. ])
  687. target.recalcAllStatisticsColumns()
  688. that.autoChangePrice(target)
  689. break
  690. case 'unit':
  691. // row.actualQuantityInStorage=
  692. if (row.unitId) {
  693. let arr = row.unitList
  694. if (!Array.isArray(arr)) {
  695. arr = JSON.parse(arr)
  696. }
  697. // for (let i of arr) {
  698. // if (i.name === value) {
  699. // target.setValues([{ rowKey: row.id, values: { unitName: i.name } }])
  700. // }
  701. // }
  702. }
  703. target.$forceUpdate()
  704. }
  705. },
  706. //转为商品对象
  707. parseInfoToObj(mInfo) {
  708. return {
  709. barCode: mInfo.barCode,
  710. batchNumber: mInfo.batchNumber,
  711. name: mInfo.name,
  712. standard: mInfo.standard,
  713. model: mInfo.model,
  714. color: mInfo.color,
  715. brand: mInfo.brand,
  716. mfrs: mInfo.mfrs,
  717. materialOther: mInfo.materialOther,
  718. unit: mInfo.commodityUnit,
  719. sku: mInfo.sku,
  720. operNumber: 1,
  721. unitPrice: mInfo.billPrice,
  722. allPrice: mInfo.billPrice,
  723. taxRate: 0,
  724. taxMoney: 0,
  725. taxLastMoney: mInfo.billPrice,
  726. productionDate: mInfo.productionDate,
  727. expiryNum: mInfo.expiryNum,
  728. position: mInfo.position,
  729. unitName: mInfo.unitName,
  730. actualQuantityInStorage: mInfo.actualQuantityInStorage,
  731. warehousingVariance: mInfo.warehousingVariance,
  732. warehousingUser: mInfo.warehousingUser,
  733. warehousingTime: mInfo.warehousingTime,
  734. unitId: mInfo.unitId,
  735. unitList: mInfo.unitList,
  736. }
  737. },
  738. //使得型号、颜色、扩展信息、sku等为隐藏
  739. changeColumnHide() {
  740. this.changeFormTypes(this.materialTable.columns, 'model', 0)
  741. this.changeFormTypes(this.materialTable.columns, 'color', 0)
  742. this.changeFormTypes(this.materialTable.columns, 'brand', 0)
  743. this.changeFormTypes(this.materialTable.columns, 'mfrs', 0)
  744. this.changeFormTypes(this.materialTable.columns, 'materialOther', 0)
  745. this.changeFormTypes(this.materialTable.columns, 'sku', 0)
  746. },
  747. //使得sku、序列号、批号、到期日等为显示
  748. changeColumnShow(info) {
  749. // if (info.util) {
  750. // this.changeUnitType(this.materialTable.columns, info, 'unit')
  751. // }
  752. if (info.model) {
  753. this.changeFormTypes(this.materialTable.columns, 'model', 1)
  754. }
  755. if (info.color) {
  756. this.changeFormTypes(this.materialTable.columns, 'color', 1)
  757. }
  758. if (info.brand) {
  759. this.changeFormTypes(this.materialTable.columns, 'brand', 1)
  760. }
  761. if (info.mfrs) {
  762. this.changeFormTypes(this.materialTable.columns, 'mfrs', 1)
  763. }
  764. if (info.materialOther) {
  765. this.changeFormTypes(this.materialTable.columns, 'materialOther', 1)
  766. }
  767. if (info.sku) {
  768. this.changeFormTypes(this.materialTable.columns, 'sku', 1)
  769. }
  770. if (info.enableSerialNumber === '1') {
  771. //如果开启出入库管理,并且类型等于采购、采购退货、销售、销售退货,则跳过
  772. if (
  773. this.inOutManageFlag &&
  774. (this.prefixNo === 'CGRK' || this.prefixNo === 'CGTH' || this.prefixNo === 'XSCK' || this.prefixNo === 'XSTH')
  775. ) {
  776. //跳过
  777. } else {
  778. this.changeFormTypes(this.materialTable.columns, 'snList', 1)
  779. }
  780. }
  781. if (info.enableBatchNumber === '1') {
  782. //如果开启出入库管理,并且类型等于采购、采购退货、销售、销售退货,则跳过
  783. if (
  784. this.inOutManageFlag &&
  785. (this.prefixNo === 'CGRK' || this.prefixNo === 'CGTH' || this.prefixNo === 'XSCK' || this.prefixNo === 'XSTH')
  786. ) {
  787. //跳过
  788. } else {
  789. this.changeFormTypes(this.materialTable.columns, 'batchNumber', 1)
  790. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 1)
  791. }
  792. }
  793. },
  794. //删除一行或多行的时候触发
  795. onDeleted(ids, target) {
  796. target.recalcAllStatisticsColumns()
  797. this.autoChangePrice(target)
  798. },
  799. //根据仓库和条码查询库存
  800. getStockByDepotBarCode(row, target) {
  801. findStockByDepotAndBarCode({ depotId: row.depotId, barCode: row.batchNumber }).then((res) => {
  802. if (res && res.code === 200) {
  803. target.setValues([{ rowKey: row.id, values: { stock: res.data.stock } }])
  804. target.recalcAllStatisticsColumns()
  805. }
  806. })
  807. },
  808. //改变优惠、本次付款、欠款的值
  809. autoChangePrice(target) {
  810. let allTaxLastMoney = target.statisticsColumns.taxLastMoney - 0
  811. let discount = this.form.getFieldValue('discount') - 0
  812. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  813. let deposit = this.form.getFieldValue('deposit')
  814. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  815. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  816. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  817. if (deposit) {
  818. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  819. }
  820. this.$nextTick(() => {
  821. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  822. this.form.setFieldsValue({
  823. discount: discount,
  824. discountMoney: discountMoney,
  825. discountLastMoney: discountLastMoney,
  826. changeAmount: changeAmountNew,
  827. debt: 0,
  828. })
  829. })
  830. },
  831. //改变优惠率
  832. onChangeDiscount(e) {
  833. const value = e.target.value - 0
  834. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  835. let deposit = this.form.getFieldValue('deposit')
  836. let allTaxLastMoney = this.$refs.materialDataTable.statisticsColumns.taxLastMoney - 0
  837. let discountMoneyNew = (allTaxLastMoney * value * 0.01).toFixed(2) - 0
  838. let discountLastMoneyNew = (allTaxLastMoney - discountMoneyNew).toFixed(2) - 0
  839. let changeAmountNew = (discountLastMoneyNew + otherMoney).toFixed(2) - 0
  840. if (deposit) {
  841. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  842. }
  843. this.$nextTick(() => {
  844. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  845. this.form.setFieldsValue({
  846. discountMoney: discountMoneyNew,
  847. discountLastMoney: discountLastMoneyNew,
  848. changeAmount: changeAmountNew,
  849. debt: 0,
  850. })
  851. })
  852. },
  853. //改变付款优惠
  854. onChangeDiscountMoney(e) {
  855. const value = e.target.value - 0
  856. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  857. let deposit = this.form.getFieldValue('deposit')
  858. let allTaxLastMoney = this.$refs.materialDataTable.statisticsColumns.taxLastMoney - 0
  859. let discountNew = ((value / allTaxLastMoney) * 100).toFixed(2) - 0
  860. let discountLastMoneyNew = (allTaxLastMoney - value).toFixed(2) - 0
  861. let changeAmountNew = (discountLastMoneyNew + otherMoney).toFixed(2) - 0
  862. if (deposit) {
  863. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  864. }
  865. this.$nextTick(() => {
  866. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  867. this.form.setFieldsValue({
  868. discount: discountNew,
  869. discountLastMoney: discountLastMoneyNew,
  870. changeAmount: changeAmountNew,
  871. debt: 0,
  872. })
  873. })
  874. },
  875. //其它费用
  876. onChangeOtherMoney(e) {
  877. const value = e.target.value - 0
  878. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  879. let deposit = this.form.getFieldValue('deposit')
  880. let changeAmountNew = (discountLastMoney + value).toFixed(2) - 0
  881. if (deposit) {
  882. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  883. }
  884. this.$nextTick(() => {
  885. this.form.setFieldsValue({ changeAmount: changeAmountNew, debt: 0 })
  886. })
  887. },
  888. //改变扣除订金
  889. onChangeDeposit(e) {
  890. const value = e.target.value - 0
  891. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  892. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  893. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  894. if (value) {
  895. changeAmountNew = (changeAmountNew - value).toFixed(2) - 0
  896. }
  897. this.$nextTick(() => {
  898. this.form.setFieldsValue({ changeAmount: changeAmountNew, debt: 0 })
  899. })
  900. },
  901. //改变本次付款
  902. onChangeChangeAmount(e) {
  903. const value = e.target.value - 0
  904. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  905. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  906. let deposit = this.form.getFieldValue('deposit')
  907. let debtNew = (discountLastMoney + otherMoney - value).toFixed(2) - 0
  908. if (deposit) {
  909. debtNew = (debtNew - deposit).toFixed(2) - 0
  910. }
  911. this.$nextTick(() => {
  912. this.form.setFieldsValue({ debt: debtNew })
  913. })
  914. },
  915. //切换客户信息改变商品单价
  916. handleOrganChange(value) {
  917. let organId = value
  918. this.getAllTable()
  919. .then((tables) => {
  920. return getListData(this.form, tables)
  921. })
  922. .then((allValues) => {
  923. let detailArr = allValues.tablesValue[0].values
  924. let batchNumberStr = ''
  925. for (let detail of detailArr) {
  926. if (detail.batchNumber) {
  927. batchNumberStr += detail.batchNumber + ','
  928. }
  929. }
  930. if (batchNumberStr) {
  931. let param = {
  932. batchNumber: batchNumberStr,
  933. organId: organId,
  934. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  935. prefixNo: this.prefixNo,
  936. }
  937. getMaterialByBatchNumber(param).then((res) => {
  938. if (res && res.code === 200) {
  939. let allLastMoney = 0
  940. let allTaxLastMoney = 0
  941. //获取单据明细列表信息
  942. let detailArr = allValues.tablesValue[0].values
  943. //构造新的列表数组,用于存放单据明细信息
  944. let newDetailArr = []
  945. for (let detail of detailArr) {
  946. if (detail.batchNumber) {
  947. //如果条码重复,就在给原来的数量加1
  948. let mList = res.data
  949. for (let i = 0; i < mList.length; i++) {
  950. if (detail.batchNumber === mList[i].batchNumber) {
  951. //由于改变了商品单价,需要同时更新相关金额和价税合计
  952. let taxRate = detail.taxRate - 0 //税率
  953. detail.unitPrice = mList[i].billPrice - 0 //单价
  954. detail.allPrice = (detail.unitPrice * detail.operNumber).toFixed(2) - 0
  955. detail.taxMoney = (taxRate * 0.01 * detail.allPrice).toFixed(2) - 0
  956. detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2) - 0
  957. }
  958. }
  959. newDetailArr.push(detail)
  960. }
  961. }
  962. this.materialTable.dataSource = newDetailArr
  963. //更新优惠后金额、本次付款等信息
  964. for (let newDetail of newDetailArr) {
  965. allLastMoney = allLastMoney + (newDetail.allPrice - 0)
  966. allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney - 0)
  967. }
  968. let discount = this.form.getFieldValue('discount') - 0
  969. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  970. let deposit = this.form.getFieldValue('deposit')
  971. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  972. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  973. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  974. if (deposit) {
  975. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  976. }
  977. this.$nextTick(() => {
  978. changeAmountNew = this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  979. this.form.setFieldsValue({
  980. discount: discount,
  981. discountMoney: discountMoney,
  982. discountLastMoney: discountLastMoney,
  983. changeAmount: changeAmountNew,
  984. debt: 0,
  985. })
  986. })
  987. }
  988. })
  989. }
  990. })
  991. },
  992. scanEnter() {
  993. this.scanStatus = false
  994. this.$nextTick(() => {
  995. this.$refs.scanBarCode.focus()
  996. })
  997. },
  998. //扫码之后回车
  999. scanPressEnter() {
  1000. let that = this
  1001. if (this.scanBarCode) {
  1002. this.getAllTable()
  1003. .then((tables) => {
  1004. return getListData(this.form, tables)
  1005. })
  1006. .then((allValues) => {
  1007. let param = {
  1008. barCode: this.scanBarCode.trim(),
  1009. organId: this.form.getFieldValue('organId'),
  1010. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  1011. prefixNo: this.prefixNo,
  1012. }
  1013. getMaterialByBatchNumber(param).then((res) => {
  1014. if (res && res.code === 200) {
  1015. let hasFinished = false
  1016. let allLastMoney = 0
  1017. let allTaxLastMoney = 0
  1018. //获取单据明细列表信息
  1019. let detailArr = allValues.tablesValue[0].values
  1020. //构造新的列表数组,用于存放单据明细信息
  1021. let newDetailArr = []
  1022. let hasAdd = false
  1023. for (let detail of detailArr) {
  1024. if (detail.barCode) {
  1025. //如果扫码结果和条码重复,就在给原来的数量加1
  1026. if (detail.barCode === this.scanBarCode.trim() && !hasAdd) {
  1027. detail.operNumber = detail.operNumber - 0 + 1
  1028. //由于改变了商品数量,需要同时更新相关金额和价税合计
  1029. let taxRate = detail.taxRate - 0 //税率
  1030. let unitPrice = detail.unitPrice - 0 //单价
  1031. detail.allPrice = (unitPrice * detail.operNumber).toFixed(2) - 0
  1032. detail.taxMoney = (taxRate * 0.01 * detail.allPrice).toFixed(2) - 0
  1033. detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2) - 0
  1034. hasFinished = true
  1035. hasAdd = true
  1036. }
  1037. //如果扫码结果和序列号重复,就直接跳过
  1038. if (detail.snList === this.scanBarCode.trim()) {
  1039. this.$message.warning('抱歉,已经扫描过该序列号!')
  1040. hasFinished = true
  1041. }
  1042. newDetailArr.push(detail)
  1043. }
  1044. }
  1045. if (!hasFinished) {
  1046. //将扫码的条码对应的商品加入列表
  1047. let item = {}
  1048. let mList = res.data
  1049. if (mList && mList.length > 0) {
  1050. let mInfo = mList[0]
  1051. this.changeColumnShow(mInfo)
  1052. item.depotId = mInfo.depotId
  1053. item.barCode = mInfo.mBarCode
  1054. item.name = mInfo.name
  1055. item.standard = mInfo.standard
  1056. item.model = mInfo.model
  1057. item.color = mInfo.color
  1058. item.materialOther = mInfo.materialOther
  1059. item.stock = mInfo.stock
  1060. item.unit = mInfo.commodityUnit
  1061. item.sku = mInfo.sku
  1062. if (mInfo.mBarCode !== this.scanBarCode.trim()) {
  1063. if (
  1064. this.prefixNo === 'LSCK' ||
  1065. this.prefixNo === 'CGTH' ||
  1066. this.prefixNo === 'XSCK' ||
  1067. this.prefixNo === 'QTCK'
  1068. ) {
  1069. //此时给序列号赋值
  1070. item.snList = this.scanBarCode.trim()
  1071. }
  1072. }
  1073. item.operNumber = 1
  1074. item.unitPrice = mInfo.billPrice
  1075. item.allPrice = mInfo.billPrice
  1076. item.taxRate = 0
  1077. item.taxMoney = 0
  1078. item.taxLastMoney = mInfo.billPrice
  1079. newDetailArr.push(item)
  1080. } else {
  1081. this.$message.warning('抱歉,此条码不存在商品信息!')
  1082. }
  1083. }
  1084. //组合和拆分单据给商品类型进行重新赋值
  1085. for (let i = 0; i < newDetailArr.length; i++) {
  1086. if (i === 0) {
  1087. newDetailArr[0].mType = '组合件'
  1088. } else {
  1089. newDetailArr[i].mType = '普通子件'
  1090. }
  1091. }
  1092. this.materialTable.dataSource = newDetailArr
  1093. //更新优惠后金额、本次付款等信息
  1094. for (let newDetail of newDetailArr) {
  1095. allLastMoney = allLastMoney + (newDetail.allPrice - 0)
  1096. allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney - 0)
  1097. }
  1098. let discount = this.form.getFieldValue('discount') - 0
  1099. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  1100. let deposit = this.form.getFieldValue('deposit')
  1101. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  1102. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  1103. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  1104. if (deposit) {
  1105. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  1106. }
  1107. if (this.prefixNo === 'LSCK' || this.prefixNo === 'LSTH') {
  1108. this.$nextTick(() => {
  1109. this.form.setFieldsValue({ changeAmount: allLastMoney, getAmount: allLastMoney, backAmount: 0 })
  1110. })
  1111. } else {
  1112. this.$nextTick(() => {
  1113. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  1114. this.form.setFieldsValue({
  1115. discount: discount,
  1116. discountMoney: discountMoney,
  1117. discountLastMoney: discountLastMoney,
  1118. changeAmount: changeAmountNew,
  1119. debt: 0,
  1120. })
  1121. })
  1122. }
  1123. //置空扫码的内容
  1124. this.scanBarCode = ''
  1125. this.$refs.scanBarCode.focus()
  1126. //自动下滑到最后一行
  1127. setTimeout(function () {
  1128. that.$refs.materialDataTable.resetScrollTop(
  1129. (newDetailArr.length + 1) * that.$refs.materialDataTable.rowHeight
  1130. )
  1131. }, 1000)
  1132. }
  1133. })
  1134. })
  1135. }
  1136. },
  1137. stopScan() {
  1138. this.scanStatus = true
  1139. this.scanBarCode = ''
  1140. },
  1141. onImport(prefixNo) {
  1142. this.$refs.importItemModalForm.add(prefixNo)
  1143. },
  1144. importItemModalFormOk(data) {
  1145. this.materialTable.dataSource = data
  1146. this.$nextTick(() => {
  1147. let discountLastMoney = 0
  1148. for (let i = 0; i < data.length; i++) {
  1149. discountLastMoney += data[i].taxLastMoney
  1150. this.changeColumnShow(data[i])
  1151. }
  1152. this.form.setFieldsValue({ discountLastMoney: discountLastMoney })
  1153. })
  1154. },
  1155. //保存并审核
  1156. handleOkAndCheck() {
  1157. this.billStatus = '1'
  1158. this.handleOk()
  1159. },
  1160. //发起流程
  1161. handleWorkflow() {
  1162. if (this.model && this.model.number) {
  1163. getPlatformConfigByKey({ platformKey: 'send_workflow_url' }).then((res) => {
  1164. if (res && res.code === 200) {
  1165. let sendWorkflowUrl = res.data.platformValue + '&no=' + this.model.number + '&type=1'
  1166. this.$refs.modalWorkflow.show(this.model, sendWorkflowUrl, this.model.number, 1, 320)
  1167. this.$refs.modalWorkflow.title = '发起流程'
  1168. }
  1169. })
  1170. } else {
  1171. this.$message.warning('请先保存单据后再提交流程!')
  1172. }
  1173. },
  1174. //三联打印预览
  1175. handlePrint(billType) {
  1176. if (this.model.id) {
  1177. getPlatformConfigByKey({ platformKey: 'bill_print_url' }).then((res) => {
  1178. if (res && res.code === 200) {
  1179. let billPrintUrl = res.data.platformValue + '?no=' + this.model.number
  1180. let billPrintHeight = this.materialTable.dataSource.length * 50 + 600
  1181. this.$refs.modalPrint.show(this.model, billPrintUrl, billPrintHeight)
  1182. this.$refs.modalPrint.title = billType + '-三联打印预览'
  1183. }
  1184. })
  1185. } else {
  1186. this.$message.warning('请先保存单据后再打印!')
  1187. }
  1188. },
  1189. //加载平台配置信息
  1190. initPlatform() {
  1191. getPlatformConfigByKey({ platformKey: 'bill_print_flag' }).then((res) => {
  1192. if (res && res.code === 200) {
  1193. this.billPrintFlag = res.data.platformValue === '1' ? true : false
  1194. }
  1195. })
  1196. },
  1197. //加载快捷按钮:供应商、客户、会员、结算账户、仓库
  1198. initQuickBtn() {
  1199. let btnStrList = Vue.ls.get('winBtnStrList') //按钮功能列表 JSON字符串
  1200. if (btnStrList) {
  1201. for (let i = 0; i < btnStrList.length; i++) {
  1202. if (btnStrList[i].btnStr) {
  1203. this.quickBtn.vendor =
  1204. btnStrList[i].url === '/system/vendor' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.vendor
  1205. this.quickBtn.customer =
  1206. btnStrList[i].url === '/system/customer' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.customer
  1207. this.quickBtn.member =
  1208. btnStrList[i].url === '/system/member' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.member
  1209. this.quickBtn.account =
  1210. btnStrList[i].url === '/system/account' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.account
  1211. this.quickBtn.depot =
  1212. btnStrList[i].url === '/system/depot' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.depot
  1213. }
  1214. }
  1215. }
  1216. },
  1217. //获取出入库人
  1218. getCreatorSpinnerList() {
  1219. creatorSpinnerList().then((res) => {
  1220. this.currentUserList = res.data
  1221. })
  1222. },
  1223. },
  1224. }