materialJS.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import repostCurd from '@/business/platform/form/utils/custom/joinCURD.js'
  2. export default {
  3. methods: {
  4. /* 唤醒扫码*/
  5. openRedar(type) {
  6. this.redar = true //扫码图标
  7. this.visible = false //结果列表
  8. this.$refs.redarInput.focus(); //聚焦input
  9. this.listData = [] //清空列表
  10. },
  11. facilityData(id) {
  12. if (!id) return // 无参直接反
  13. for (let item of this.listData) { //判断是否重复,重复扫码不查询
  14. if (item.id_ == id) {
  15. item.cao_zuo_shu_liang = item.cao_zuo_shu_liang+1
  16. this.facilityId = ''
  17. return
  18. }
  19. }
  20. this.redar=false
  21. this.loadData(id)
  22. //开始查询设备
  23. this.facilityId = ''
  24. },
  25. /* 获取数据 ,开始查阅记录 */
  26. loadData(id) {
  27. repostCurd('select',
  28. '{"tableName": "t_wlgl","paramWhere":{"id_":"' + id + '"}}'
  29. ).then(response => {
  30. if (response.variables.data && response.variables.data.length > 0) {
  31. response.variables.data[0].cao_zuo_shu_liang = 1
  32. this.listData.push(response.variables.data[0])
  33. }
  34. })
  35. },
  36. /* 列表市区焦点*/
  37. handleChange(){
  38. this.$refs.redarInput.focus(); //聚焦input
  39. },
  40. /* 关闭弹出列表框*/
  41. closeDialog() {
  42. this.remRedar()
  43. //回传关闭事件。隐藏当前组件。
  44. },
  45. handleClose(){
  46. this.handleChange()
  47. this.$confirm('确认关闭扫码列表页面?').then(_ => {
  48. this.closeDialog();
  49. }).catch(_ => {
  50. });
  51. },
  52. submitData(type) {
  53. //回传关闭事件。隐藏当前组件。
  54. let judge = true;
  55. if(type =='入库确认'){
  56. this.$confirm('请再次确认 [入库操作]').then(_ => {
  57. for (let item of this.listData) { //入库操作时,给每个物料增加数量
  58. item.sheng_yu_shu_lian = Number(item.sheng_yu_shu_lian) + Number(item.cao_zuo_shu_liang)//调用axios修改数量
  59. }
  60. this.commitData(this.listData)
  61. }).catch(_ => {});
  62. }else{
  63. this.$confirm('请再次确认 [出库操作]').then(_ => {
  64. for(let item of this.listData) { //出库操作时,给每个物料减少数量,若数量错误,取消执行,并报错。
  65. if(Number(item.cao_zuo_shu_liang) <= Number(item.sheng_yu_shu_lian)){
  66. item.sheng_yu_shu_lian = Number(item.sheng_yu_shu_lian) - Number(item.cao_zuo_shu_liang)//调用axios修改数量
  67. }else{
  68. this.$message.error('操作失败,['+item.wu_liao_ming_chen+'] 出库数量不得大于剩余数量。')
  69. judge = false
  70. }
  71. }
  72. if(judge){
  73. this.commitData(this.listData)
  74. }
  75. }).catch(_ => {});
  76. }
  77. },
  78. /* 去除一行*/
  79. deleteData(val){
  80. this.listData = this.listData.filter((data) =>{
  81. return data.id_!=val
  82. })
  83. if(this.listData.length ==0){
  84. this.remRedar()
  85. }
  86. },
  87. /* 提交数据*/
  88. commitData(val){
  89. for(let item of val) {
  90. this.Update('t_wlgl',{"id_":item.id_},{"sheng_yu_shu_lian":item.sheng_yu_shu_lian}).then(response => {
  91. this.remRedar()
  92. this.$message({
  93. message: '物料操作成功!',
  94. type: 'success'
  95. });
  96. })
  97. }
  98. },
  99. Update (name,where,cond) {
  100. let cont = {}
  101. cont['tableName'] = name
  102. cont['paramWhere'] = where
  103. cont['paramCond'] = cond
  104. return repostCurd('update',JSON.stringify(cont))
  105. },
  106. /* 关闭*/
  107. remRedar() {
  108. this.visible = false
  109. this.listData = [] //清空列表
  110. this.redar = false
  111. this.$emit('scanOff',false)
  112. },
  113. }
  114. }