BillModalMixin.js 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182
  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. } from '@/api/api'
  14. import { getAction } from '@/api/manage'
  15. import { getCheckFlag, getMpListShort, getNowFormatDateTime } from '@/utils/util'
  16. import { USER_INFO } from '@/store/mutation-types'
  17. import Vue from 'vue'
  18. export const BillModalMixin = {
  19. data() {
  20. return {
  21. action: '',
  22. manyAccountBtnStatus: false,
  23. supList: [],
  24. cusList: [],
  25. retailList: [],
  26. personList: {
  27. options: [],
  28. value: '',
  29. },
  30. currentSelectDepotId: '',
  31. depotList: [],
  32. accountList: [],
  33. accountIdList: [],
  34. accountMoneyList: [],
  35. billUnitPirce: '',
  36. scanBarCode: '',
  37. scanStatus: true,
  38. billStatus: '0',
  39. minWidth: 1100,
  40. isCanCheck: true,
  41. quickBtn: {
  42. vendor: false,
  43. customer: false,
  44. member: false,
  45. account: false,
  46. depot: false,
  47. },
  48. billPrintFlag: false,
  49. /* 是否显示打印按钮 */
  50. isShowPrintBtn: true,
  51. /* 原始审核是否开启 */
  52. checkFlag: true,
  53. validatorRules: {
  54. price: {
  55. rules: [{ pattern: /^(([0-9][0-9]*)|([0]\.\d{0,4}|[0-9][0-9]*\.\d{0,4}))$/, message: '金额格式不正确!' }],
  56. },
  57. },
  58. spans: {
  59. labelCol1: { span: 2 },
  60. wrapperCol1: { span: 22 },
  61. //1_5: 分为1.5列(相当于占了2/3)
  62. labelCol1_5: { span: 3 },
  63. wrapperCol1_5: { span: 21 },
  64. labelCol2: { span: 4 },
  65. wrapperCol2: { span: 20 },
  66. labelCol3: { span: 6 },
  67. wrapperCol3: { span: 18 },
  68. labelCol6: { span: 12 },
  69. wrapperCol6: { span: 12 },
  70. },
  71. }
  72. },
  73. created() {
  74. let realScreenWidth = window.screen.width
  75. this.width = realScreenWidth < 1500 ? '1200px' : '1550px'
  76. this.minWidth = realScreenWidth < 1500 ? 1150 : 1500
  77. },
  78. mounted() {
  79. document.getElementById(this.prefixNo).addEventListener('keydown', this.handleOkKey)
  80. },
  81. beforeDestroy() {
  82. document.getElementById(this.prefixNo).removeEventListener('keydown', this.handleOkKey)
  83. },
  84. computed: {
  85. readOnly: function () {
  86. return this.action !== 'add' && this.action !== 'edit'
  87. },
  88. },
  89. methods: {
  90. // 快捷键
  91. handleOkKey(e) {
  92. const key = window.event.keyCode ? window.event.keyCode : window.event.which
  93. if (key === 83 && e.ctrlKey) {
  94. //保存 CTRL+S
  95. this.handleOk()
  96. e.preventDefault()
  97. }
  98. },
  99. addInit(amountNum) {
  100. getAction('/sequence/buildNumber').then((res) => {
  101. if (res && res.code === 200) {
  102. this.model.defaultNumber = amountNum + res.data.defaultNumber
  103. this.form.setFieldsValue({ number: amountNum + res.data.defaultNumber })
  104. }
  105. })
  106. this.$nextTick(() => {
  107. this.form.setFieldsValue({
  108. operTime: getNowFormatDateTime(),
  109. discount: 0,
  110. discountMoney: 0,
  111. discountLastMoney: 0,
  112. otherMoney: 0,
  113. changeAmount: 0,
  114. debt: 0,
  115. })
  116. })
  117. this.$nextTick(() => {
  118. getAccount({}).then((res) => {
  119. if (res && res.code === 200) {
  120. for (const item of res.data.accountList) {
  121. if (item.isDefault) {
  122. this.form.setFieldsValue({ accountId: item.id })
  123. }
  124. }
  125. }
  126. })
  127. })
  128. this.accountIdList = []
  129. this.accountMoneyList = []
  130. this.manyAccountBtnStatus = false
  131. },
  132. copyAddInit(amountNum) {
  133. getAction('/sequence/buildNumber').then((res) => {
  134. if (res && res.code === 200) {
  135. this.form.setFieldsValue({ number: amountNum + res.data.defaultNumber })
  136. }
  137. })
  138. this.$nextTick(() => {
  139. this.form.setFieldsValue({ operTime: getNowFormatDateTime() })
  140. })
  141. },
  142. /** 查询某个tab的数据 */
  143. requestSubTableData(url, params, tab, success) {
  144. tab.loading = true
  145. getAction(url, params)
  146. .then((res) => {
  147. if (res && res.code === 200) {
  148. tab.dataSource = res.data.rows
  149. for (let i = 0; i < tab.dataSource.length; i++) {
  150. let info = tab.dataSource[i]
  151. info.isEdit = this.model.id ? 1 : 0
  152. this.changeColumnShow(info)
  153. }
  154. typeof success === 'function' ? success(res) : ''
  155. }
  156. })
  157. .finally(() => {
  158. tab.loading = false
  159. })
  160. },
  161. //改变字段的状态,1-显示 0-隐藏
  162. changeFormTypes(columns, key, type) {
  163. for (let i = 0; i < columns.length; i++) {
  164. if (columns[i].key === key) {
  165. if (type) {
  166. if (key === 'snList' || key === 'batchNumber') {
  167. if (
  168. this.prefixNo === 'LSCK' ||
  169. this.prefixNo === 'CGTH' ||
  170. this.prefixNo === 'XSCK' ||
  171. this.prefixNo === 'QTCK' ||
  172. this.prefixNo === 'DBCK'
  173. ) {
  174. columns[i].type = FormTypes.popupJsh //显示
  175. } else {
  176. if (key === 'snList') {
  177. columns[i].type = FormTypes.popupJsh //显示
  178. } else {
  179. columns[i].type = FormTypes.input //显示
  180. }
  181. }
  182. } else if (key === 'expirationDate') {
  183. if (
  184. this.prefixNo === 'LSTH' ||
  185. this.prefixNo === 'CGRK' ||
  186. this.prefixNo === 'XSTH' ||
  187. this.prefixNo === 'QTRK'
  188. ) {
  189. columns[i].type = FormTypes.date //显示
  190. } else {
  191. columns[i].type = FormTypes.input //显示
  192. }
  193. } else {
  194. columns[i].type = FormTypes.normal //显示
  195. }
  196. } else {
  197. columns[i].type = FormTypes.hidden //隐藏
  198. }
  199. }
  200. }
  201. },
  202. initSystemConfig() {
  203. getCurrentSystemConfig().then((res) => {
  204. if (res.code === 200 && res.data) {
  205. let multiBillType = res.data.multiBillType
  206. let multiLevelApprovalFlag = res.data.multiLevelApprovalFlag
  207. this.checkFlag = getCheckFlag(multiBillType, multiLevelApprovalFlag, this.prefixNo)
  208. this.purchaseBySaleFlag = res.data.purchaseBySaleFlag === '1' ? true : false
  209. this.inOutManageFlag = res.data.inOutManageFlag === '1' ? true : false
  210. if (res.data.auditPrintFlag === '1') {
  211. if (this.model.status === '0' || this.model.status === '9') {
  212. this.isShowPrintBtn = false
  213. } else {
  214. this.isShowPrintBtn = true
  215. }
  216. } else {
  217. this.isShowPrintBtn = true
  218. }
  219. }
  220. })
  221. },
  222. initSupplier(isChecked) {
  223. let that = this
  224. findBySelectSup({}).then((res) => {
  225. if (res) {
  226. that.supList = res
  227. if (isChecked && res.length > 0) {
  228. that.form.setFieldsValue({ organId: res[0].id })
  229. }
  230. }
  231. })
  232. },
  233. initCustomer(isChecked) {
  234. let that = this
  235. findBySelectCus({}).then((res) => {
  236. if (res) {
  237. that.cusList = res
  238. if (isChecked && res.length > 0) {
  239. that.form.setFieldsValue({ organId: res[0].id })
  240. }
  241. }
  242. })
  243. },
  244. initRetail(isChecked) {
  245. let that = this
  246. findBySelectRetail({}).then((res) => {
  247. if (res) {
  248. that.retailList = res
  249. if (isChecked && res.length > 0) {
  250. that.form.setFieldsValue({ organId: res[0].id })
  251. }
  252. }
  253. })
  254. },
  255. initSalesman() {
  256. let that = this
  257. getPersonByNumType({ type: 1 }).then((res) => {
  258. if (res) {
  259. that.personList.options = res
  260. }
  261. })
  262. },
  263. initDepot() {
  264. let that = this
  265. getAction('/depot/findDepotByCurrentUser').then((res) => {
  266. if (res.code === 200) {
  267. let arr = res.data
  268. for (let item of that.materialTable.columns) {
  269. if (item.key == 'depotId' || item.key == 'anotherDepotId') {
  270. item.options = []
  271. for (let i = 0; i < arr.length; i++) {
  272. let depotInfo = {}
  273. depotInfo.value = arr[i].id + '' //注意-此处value必须为字符串格式
  274. depotInfo.text = arr[i].depotName
  275. depotInfo.title = arr[i].depotName
  276. item.options.push(depotInfo)
  277. }
  278. }
  279. }
  280. }
  281. })
  282. },
  283. initAccount(isChecked) {
  284. let that = this
  285. getAccount({}).then((res) => {
  286. if (res && res.code === 200) {
  287. let list = res.data.accountList
  288. let lastId = list.length > 0 ? list[0].id : ''
  289. getCurrentSystemConfig().then((res) => {
  290. if (res.code === 200 && res.data) {
  291. let multiAccountFlag = res.data.multiAccountFlag
  292. if (multiAccountFlag === '1') {
  293. list.splice(0, 0, { id: 0, name: '多账户' })
  294. }
  295. }
  296. that.accountList = list
  297. if (isChecked) {
  298. that.form.setFieldsValue({ accountId: lastId })
  299. }
  300. })
  301. }
  302. })
  303. },
  304. handleManyAccount() {
  305. this.selectAccount(0)
  306. },
  307. selectAccount(value) {
  308. if (value === 0) {
  309. //多账户
  310. this.$refs.manyAccountModalForm.edit(this.accountIdList, this.accountMoneyList)
  311. this.$refs.manyAccountModalForm.title = '多账户结算'
  312. this.manyAccountBtnStatus = true
  313. } else {
  314. this.accountIdList = []
  315. this.accountMoneyList = []
  316. this.manyAccountBtnStatus = false
  317. }
  318. },
  319. manyAccountModalFormOk(idList, moneyList, allPrice) {
  320. this.accountIdList = idList
  321. this.accountMoneyList = moneyList
  322. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  323. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  324. let debt = (discountLastMoney + otherMoney - allPrice).toFixed(2)
  325. this.$nextTick(() => {
  326. this.form.setFieldsValue({ changeAmount: allPrice, debt: debt })
  327. })
  328. },
  329. addSupplier() {
  330. this.$refs.vendorModalForm.add()
  331. this.$refs.vendorModalForm.title = '新增供应商'
  332. this.$refs.vendorModalForm.disableSubmit = false
  333. },
  334. addCustomer() {
  335. this.$refs.customerModalForm.add()
  336. this.$refs.customerModalForm.title =
  337. '新增客户(提醒:如果找不到新添加的客户,请到用户管理检查是否分配了该客户权限)'
  338. this.$refs.customerModalForm.disableSubmit = false
  339. },
  340. addMember() {
  341. this.$refs.memberModalForm.add()
  342. this.$refs.memberModalForm.title = '新增会员'
  343. this.$refs.memberModalForm.disableSubmit = false
  344. },
  345. handleBatchSetDepot() {
  346. console.log('11111111111111111111')
  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. }
  678. },
  679. //转为商品对象
  680. parseInfoToObj(mInfo) {
  681. return {
  682. barCode: mInfo.mBarCode,
  683. batchNumber: mInfo.batchNumber,
  684. name: mInfo.name,
  685. standard: mInfo.standard,
  686. model: mInfo.model,
  687. color: mInfo.color,
  688. brand: mInfo.brand,
  689. mfrs: mInfo.mfrs,
  690. materialOther: mInfo.materialOther,
  691. unit: mInfo.commodityUnit,
  692. sku: mInfo.sku,
  693. operNumber: 1,
  694. unitPrice: mInfo.billPrice,
  695. allPrice: mInfo.billPrice,
  696. taxRate: 0,
  697. taxMoney: 0,
  698. taxLastMoney: mInfo.billPrice,
  699. }
  700. },
  701. //使得型号、颜色、扩展信息、sku等为隐藏
  702. changeColumnHide() {
  703. this.changeFormTypes(this.materialTable.columns, 'model', 0)
  704. this.changeFormTypes(this.materialTable.columns, 'color', 0)
  705. this.changeFormTypes(this.materialTable.columns, 'brand', 0)
  706. this.changeFormTypes(this.materialTable.columns, 'mfrs', 0)
  707. this.changeFormTypes(this.materialTable.columns, 'materialOther', 0)
  708. this.changeFormTypes(this.materialTable.columns, 'sku', 0)
  709. },
  710. //使得sku、序列号、批号、到期日等为显示
  711. changeColumnShow(info) {
  712. if (info.model) {
  713. this.changeFormTypes(this.materialTable.columns, 'model', 1)
  714. }
  715. if (info.color) {
  716. this.changeFormTypes(this.materialTable.columns, 'color', 1)
  717. }
  718. if (info.brand) {
  719. this.changeFormTypes(this.materialTable.columns, 'brand', 1)
  720. }
  721. if (info.mfrs) {
  722. this.changeFormTypes(this.materialTable.columns, 'mfrs', 1)
  723. }
  724. if (info.materialOther) {
  725. this.changeFormTypes(this.materialTable.columns, 'materialOther', 1)
  726. }
  727. if (info.sku) {
  728. this.changeFormTypes(this.materialTable.columns, 'sku', 1)
  729. }
  730. if (info.enableSerialNumber === '1') {
  731. //如果开启出入库管理,并且类型等于采购、采购退货、销售、销售退货,则跳过
  732. if (
  733. this.inOutManageFlag &&
  734. (this.prefixNo === 'CGRK' || this.prefixNo === 'CGTH' || this.prefixNo === 'XSCK' || this.prefixNo === 'XSTH')
  735. ) {
  736. //跳过
  737. } else {
  738. this.changeFormTypes(this.materialTable.columns, 'snList', 1)
  739. }
  740. }
  741. if (info.enableBatchNumber === '1') {
  742. //如果开启出入库管理,并且类型等于采购、采购退货、销售、销售退货,则跳过
  743. if (
  744. this.inOutManageFlag &&
  745. (this.prefixNo === 'CGRK' || this.prefixNo === 'CGTH' || this.prefixNo === 'XSCK' || this.prefixNo === 'XSTH')
  746. ) {
  747. //跳过
  748. } else {
  749. this.changeFormTypes(this.materialTable.columns, 'batchNumber', 1)
  750. this.changeFormTypes(this.materialTable.columns, 'expirationDate', 1)
  751. }
  752. }
  753. },
  754. //删除一行或多行的时候触发
  755. onDeleted(ids, target) {
  756. target.recalcAllStatisticsColumns()
  757. this.autoChangePrice(target)
  758. },
  759. //根据仓库和条码查询库存
  760. getStockByDepotBarCode(row, target) {
  761. findStockByDepotAndBarCode({ depotId: row.depotId, barCode: row.batchNumber }).then((res) => {
  762. if (res && res.code === 200) {
  763. target.setValues([{ rowKey: row.id, values: { stock: res.data.stock } }])
  764. target.recalcAllStatisticsColumns()
  765. }
  766. })
  767. },
  768. //改变优惠、本次付款、欠款的值
  769. autoChangePrice(target) {
  770. let allTaxLastMoney = target.statisticsColumns.taxLastMoney - 0
  771. let discount = this.form.getFieldValue('discount') - 0
  772. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  773. let deposit = this.form.getFieldValue('deposit')
  774. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  775. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  776. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  777. if (deposit) {
  778. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  779. }
  780. this.$nextTick(() => {
  781. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  782. this.form.setFieldsValue({
  783. discount: discount,
  784. discountMoney: discountMoney,
  785. discountLastMoney: discountLastMoney,
  786. changeAmount: changeAmountNew,
  787. debt: 0,
  788. })
  789. })
  790. },
  791. //改变优惠率
  792. onChangeDiscount(e) {
  793. const value = e.target.value - 0
  794. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  795. let deposit = this.form.getFieldValue('deposit')
  796. let allTaxLastMoney = this.$refs.materialDataTable.statisticsColumns.taxLastMoney - 0
  797. let discountMoneyNew = (allTaxLastMoney * value * 0.01).toFixed(2) - 0
  798. let discountLastMoneyNew = (allTaxLastMoney - discountMoneyNew).toFixed(2) - 0
  799. let changeAmountNew = (discountLastMoneyNew + otherMoney).toFixed(2) - 0
  800. if (deposit) {
  801. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  802. }
  803. this.$nextTick(() => {
  804. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  805. this.form.setFieldsValue({
  806. discountMoney: discountMoneyNew,
  807. discountLastMoney: discountLastMoneyNew,
  808. changeAmount: changeAmountNew,
  809. debt: 0,
  810. })
  811. })
  812. },
  813. //改变付款优惠
  814. onChangeDiscountMoney(e) {
  815. const value = e.target.value - 0
  816. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  817. let deposit = this.form.getFieldValue('deposit')
  818. let allTaxLastMoney = this.$refs.materialDataTable.statisticsColumns.taxLastMoney - 0
  819. let discountNew = ((value / allTaxLastMoney) * 100).toFixed(2) - 0
  820. let discountLastMoneyNew = (allTaxLastMoney - value).toFixed(2) - 0
  821. let changeAmountNew = (discountLastMoneyNew + otherMoney).toFixed(2) - 0
  822. if (deposit) {
  823. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  824. }
  825. this.$nextTick(() => {
  826. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  827. this.form.setFieldsValue({
  828. discount: discountNew,
  829. discountLastMoney: discountLastMoneyNew,
  830. changeAmount: changeAmountNew,
  831. debt: 0,
  832. })
  833. })
  834. },
  835. //其它费用
  836. onChangeOtherMoney(e) {
  837. const value = e.target.value - 0
  838. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  839. let deposit = this.form.getFieldValue('deposit')
  840. let changeAmountNew = (discountLastMoney + value).toFixed(2) - 0
  841. if (deposit) {
  842. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  843. }
  844. this.$nextTick(() => {
  845. this.form.setFieldsValue({ changeAmount: changeAmountNew, debt: 0 })
  846. })
  847. },
  848. //改变扣除订金
  849. onChangeDeposit(e) {
  850. const value = e.target.value - 0
  851. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  852. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  853. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  854. if (value) {
  855. changeAmountNew = (changeAmountNew - value).toFixed(2) - 0
  856. }
  857. this.$nextTick(() => {
  858. this.form.setFieldsValue({ changeAmount: changeAmountNew, debt: 0 })
  859. })
  860. },
  861. //改变本次付款
  862. onChangeChangeAmount(e) {
  863. const value = e.target.value - 0
  864. let discountLastMoney = this.form.getFieldValue('discountLastMoney') - 0
  865. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  866. let deposit = this.form.getFieldValue('deposit')
  867. let debtNew = (discountLastMoney + otherMoney - value).toFixed(2) - 0
  868. if (deposit) {
  869. debtNew = (debtNew - deposit).toFixed(2) - 0
  870. }
  871. this.$nextTick(() => {
  872. this.form.setFieldsValue({ debt: debtNew })
  873. })
  874. },
  875. //切换客户信息改变商品单价
  876. handleOrganChange(value) {
  877. let organId = value
  878. this.getAllTable()
  879. .then((tables) => {
  880. return getListData(this.form, tables)
  881. })
  882. .then((allValues) => {
  883. let detailArr = allValues.tablesValue[0].values
  884. let batchNumberStr = ''
  885. for (let detail of detailArr) {
  886. if (detail.batchNumber) {
  887. batchNumberStr += detail.batchNumber + ','
  888. }
  889. }
  890. console.log('=================', batchNumberStr)
  891. if (batchNumberStr) {
  892. let param = {
  893. batchNumber: batchNumberStr,
  894. organId: organId,
  895. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  896. prefixNo: this.prefixNo,
  897. }
  898. getMaterialByBatchNumber(param).then((res) => {
  899. if (res && res.code === 200) {
  900. let allLastMoney = 0
  901. let allTaxLastMoney = 0
  902. //获取单据明细列表信息
  903. let detailArr = allValues.tablesValue[0].values
  904. //构造新的列表数组,用于存放单据明细信息
  905. let newDetailArr = []
  906. for (let detail of detailArr) {
  907. if (detail.batchNumber) {
  908. //如果条码重复,就在给原来的数量加1
  909. let mList = res.data
  910. for (let i = 0; i < mList.length; i++) {
  911. if (detail.batchNumber === mList[i].batchNumber) {
  912. //由于改变了商品单价,需要同时更新相关金额和价税合计
  913. let taxRate = detail.taxRate - 0 //税率
  914. detail.unitPrice = mList[i].billPrice - 0 //单价
  915. detail.allPrice = (detail.unitPrice * detail.operNumber).toFixed(2) - 0
  916. detail.taxMoney = (taxRate * 0.01 * detail.allPrice).toFixed(2) - 0
  917. detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2) - 0
  918. }
  919. }
  920. newDetailArr.push(detail)
  921. }
  922. }
  923. this.materialTable.dataSource = newDetailArr
  924. //更新优惠后金额、本次付款等信息
  925. for (let newDetail of newDetailArr) {
  926. allLastMoney = allLastMoney + (newDetail.allPrice - 0)
  927. allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney - 0)
  928. }
  929. let discount = this.form.getFieldValue('discount') - 0
  930. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  931. let deposit = this.form.getFieldValue('deposit')
  932. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  933. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  934. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  935. if (deposit) {
  936. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  937. }
  938. this.$nextTick(() => {
  939. changeAmountNew = this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  940. this.form.setFieldsValue({
  941. discount: discount,
  942. discountMoney: discountMoney,
  943. discountLastMoney: discountLastMoney,
  944. changeAmount: changeAmountNew,
  945. debt: 0,
  946. })
  947. })
  948. }
  949. })
  950. }
  951. })
  952. },
  953. scanEnter() {
  954. this.scanStatus = false
  955. this.$nextTick(() => {
  956. this.$refs.scanBarCode.focus()
  957. })
  958. },
  959. //扫码之后回车
  960. scanPressEnter() {
  961. let that = this
  962. if (this.scanBarCode) {
  963. this.getAllTable()
  964. .then((tables) => {
  965. return getListData(this.form, tables)
  966. })
  967. .then((allValues) => {
  968. let param = {
  969. barCode: this.scanBarCode.trim(),
  970. organId: this.form.getFieldValue('organId'),
  971. mpList: getMpListShort(Vue.ls.get('materialPropertyList')), //扩展属性
  972. prefixNo: this.prefixNo,
  973. }
  974. getMaterialByBatchNumber(param).then((res) => {
  975. if (res && res.code === 200) {
  976. let hasFinished = false
  977. let allLastMoney = 0
  978. let allTaxLastMoney = 0
  979. //获取单据明细列表信息
  980. let detailArr = allValues.tablesValue[0].values
  981. //构造新的列表数组,用于存放单据明细信息
  982. let newDetailArr = []
  983. let hasAdd = false
  984. for (let detail of detailArr) {
  985. if (detail.barCode) {
  986. //如果扫码结果和条码重复,就在给原来的数量加1
  987. if (detail.barCode === this.scanBarCode.trim() && !hasAdd) {
  988. detail.operNumber = detail.operNumber - 0 + 1
  989. //由于改变了商品数量,需要同时更新相关金额和价税合计
  990. let taxRate = detail.taxRate - 0 //税率
  991. let unitPrice = detail.unitPrice - 0 //单价
  992. detail.allPrice = (unitPrice * detail.operNumber).toFixed(2) - 0
  993. detail.taxMoney = (taxRate * 0.01 * detail.allPrice).toFixed(2) - 0
  994. detail.taxLastMoney = (detail.allPrice + detail.taxMoney).toFixed(2) - 0
  995. hasFinished = true
  996. hasAdd = true
  997. }
  998. //如果扫码结果和序列号重复,就直接跳过
  999. if (detail.snList === this.scanBarCode.trim()) {
  1000. this.$message.warning('抱歉,已经扫描过该序列号!')
  1001. hasFinished = true
  1002. }
  1003. newDetailArr.push(detail)
  1004. }
  1005. }
  1006. if (!hasFinished) {
  1007. //将扫码的条码对应的商品加入列表
  1008. let item = {}
  1009. let mList = res.data
  1010. if (mList && mList.length > 0) {
  1011. let mInfo = mList[0]
  1012. this.changeColumnShow(mInfo)
  1013. item.depotId = mInfo.depotId
  1014. item.barCode = mInfo.mBarCode
  1015. item.name = mInfo.name
  1016. item.standard = mInfo.standard
  1017. item.model = mInfo.model
  1018. item.color = mInfo.color
  1019. item.materialOther = mInfo.materialOther
  1020. item.stock = mInfo.stock
  1021. item.unit = mInfo.commodityUnit
  1022. item.sku = mInfo.sku
  1023. if (mInfo.mBarCode !== this.scanBarCode.trim()) {
  1024. if (
  1025. this.prefixNo === 'LSCK' ||
  1026. this.prefixNo === 'CGTH' ||
  1027. this.prefixNo === 'XSCK' ||
  1028. this.prefixNo === 'QTCK'
  1029. ) {
  1030. //此时给序列号赋值
  1031. item.snList = this.scanBarCode.trim()
  1032. }
  1033. }
  1034. item.operNumber = 1
  1035. item.unitPrice = mInfo.billPrice
  1036. item.allPrice = mInfo.billPrice
  1037. item.taxRate = 0
  1038. item.taxMoney = 0
  1039. item.taxLastMoney = mInfo.billPrice
  1040. newDetailArr.push(item)
  1041. } else {
  1042. this.$message.warning('抱歉,此条码不存在商品信息!')
  1043. }
  1044. }
  1045. //组合和拆分单据给商品类型进行重新赋值
  1046. for (let i = 0; i < newDetailArr.length; i++) {
  1047. if (i === 0) {
  1048. newDetailArr[0].mType = '组合件'
  1049. } else {
  1050. newDetailArr[i].mType = '普通子件'
  1051. }
  1052. }
  1053. this.materialTable.dataSource = newDetailArr
  1054. //更新优惠后金额、本次付款等信息
  1055. for (let newDetail of newDetailArr) {
  1056. allLastMoney = allLastMoney + (newDetail.allPrice - 0)
  1057. allTaxLastMoney = allTaxLastMoney + (newDetail.taxLastMoney - 0)
  1058. }
  1059. let discount = this.form.getFieldValue('discount') - 0
  1060. let otherMoney = this.form.getFieldValue('otherMoney') ? this.form.getFieldValue('otherMoney') - 0 : 0
  1061. let deposit = this.form.getFieldValue('deposit')
  1062. let discountMoney = (discount * 0.01 * allTaxLastMoney).toFixed(2) - 0
  1063. let discountLastMoney = (allTaxLastMoney - discountMoney).toFixed(2) - 0
  1064. let changeAmountNew = (discountLastMoney + otherMoney).toFixed(2) - 0
  1065. if (deposit) {
  1066. changeAmountNew = (changeAmountNew - deposit).toFixed(2) - 0
  1067. }
  1068. if (this.prefixNo === 'LSCK' || this.prefixNo === 'LSTH') {
  1069. this.$nextTick(() => {
  1070. this.form.setFieldsValue({ changeAmount: allLastMoney, getAmount: allLastMoney, backAmount: 0 })
  1071. })
  1072. } else {
  1073. this.$nextTick(() => {
  1074. changeAmountNew = this.prefixNo === 'CGDD' || this.prefixNo === 'XSDD' ? 0 : changeAmountNew
  1075. this.form.setFieldsValue({
  1076. discount: discount,
  1077. discountMoney: discountMoney,
  1078. discountLastMoney: discountLastMoney,
  1079. changeAmount: changeAmountNew,
  1080. debt: 0,
  1081. })
  1082. })
  1083. }
  1084. //置空扫码的内容
  1085. this.scanBarCode = ''
  1086. this.$refs.scanBarCode.focus()
  1087. //自动下滑到最后一行
  1088. setTimeout(function () {
  1089. that.$refs.materialDataTable.resetScrollTop(
  1090. (newDetailArr.length + 1) * that.$refs.materialDataTable.rowHeight
  1091. )
  1092. }, 1000)
  1093. }
  1094. })
  1095. })
  1096. }
  1097. },
  1098. stopScan() {
  1099. this.scanStatus = true
  1100. this.scanBarCode = ''
  1101. },
  1102. onImport(prefixNo) {
  1103. this.$refs.importItemModalForm.add(prefixNo)
  1104. },
  1105. importItemModalFormOk(data) {
  1106. this.materialTable.dataSource = data
  1107. this.$nextTick(() => {
  1108. let discountLastMoney = 0
  1109. for (let i = 0; i < data.length; i++) {
  1110. discountLastMoney += data[i].taxLastMoney
  1111. this.changeColumnShow(data[i])
  1112. }
  1113. this.form.setFieldsValue({ discountLastMoney: discountLastMoney })
  1114. })
  1115. },
  1116. //保存并审核
  1117. handleOkAndCheck() {
  1118. this.billStatus = '1'
  1119. this.handleOk()
  1120. },
  1121. //发起流程
  1122. handleWorkflow() {
  1123. if (this.model && this.model.number) {
  1124. getPlatformConfigByKey({ platformKey: 'send_workflow_url' }).then((res) => {
  1125. if (res && res.code === 200) {
  1126. let sendWorkflowUrl = res.data.platformValue + '&no=' + this.model.number + '&type=1'
  1127. this.$refs.modalWorkflow.show(this.model, sendWorkflowUrl, this.model.number, 1, 320)
  1128. this.$refs.modalWorkflow.title = '发起流程'
  1129. }
  1130. })
  1131. } else {
  1132. this.$message.warning('请先保存单据后再提交流程!')
  1133. }
  1134. },
  1135. //三联打印预览
  1136. handlePrint(billType) {
  1137. if (this.model.id) {
  1138. getPlatformConfigByKey({ platformKey: 'bill_print_url' }).then((res) => {
  1139. if (res && res.code === 200) {
  1140. let billPrintUrl = res.data.platformValue + '?no=' + this.model.number
  1141. let billPrintHeight = this.materialTable.dataSource.length * 50 + 600
  1142. this.$refs.modalPrint.show(this.model, billPrintUrl, billPrintHeight)
  1143. this.$refs.modalPrint.title = billType + '-三联打印预览'
  1144. }
  1145. })
  1146. } else {
  1147. this.$message.warning('请先保存单据后再打印!')
  1148. }
  1149. },
  1150. //加载平台配置信息
  1151. initPlatform() {
  1152. getPlatformConfigByKey({ platformKey: 'bill_print_flag' }).then((res) => {
  1153. if (res && res.code === 200) {
  1154. this.billPrintFlag = res.data.platformValue === '1' ? true : false
  1155. }
  1156. })
  1157. },
  1158. //加载快捷按钮:供应商、客户、会员、结算账户、仓库
  1159. initQuickBtn() {
  1160. let btnStrList = Vue.ls.get('winBtnStrList') //按钮功能列表 JSON字符串
  1161. if (btnStrList) {
  1162. for (let i = 0; i < btnStrList.length; i++) {
  1163. if (btnStrList[i].btnStr) {
  1164. this.quickBtn.vendor =
  1165. btnStrList[i].url === '/system/vendor' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.vendor
  1166. this.quickBtn.customer =
  1167. btnStrList[i].url === '/system/customer' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.customer
  1168. this.quickBtn.member =
  1169. btnStrList[i].url === '/system/member' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.member
  1170. this.quickBtn.account =
  1171. btnStrList[i].url === '/system/account' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.account
  1172. this.quickBtn.depot =
  1173. btnStrList[i].url === '/system/depot' ? btnStrList[i].btnStr.indexOf(1) > -1 : this.quickBtn.depot
  1174. }
  1175. }
  1176. }
  1177. },
  1178. },
  1179. }