Blame view

ant-design-vue-jeecg/src/views/system/receipt/modules/ReceiveModal.vue 6.25 KB
肖超群 authored
1
2
3
4
5
6
7
8
9
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
10
11
    cancelText="关闭"
  >
肖超群 authored
12
肖超群 authored
13
14
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
肖超群 authored
15
肖超群 authored
16
17
      </a-form-model>
    </a-spin>
肖超群 authored
18
19
20
21
22
    <a-table ref="table" rowKey="id" size="middle" :columns="columns" :dataSource="dataSource" :pagination="false">
      <span slot="action" slot-scope="text, record">
        <a-input-number placeholder="" v-model="record.taskQty" :value="text" />
      </span>
23
24
25
      <span slot="inventoryStatus" slot-scope="inventoryStatus">
肖超群 authored
26
27
28
29
        <a-tag :key="inventoryStatus" color="blue" :color="getStatusColor(inventoryStatus)">
          {{ solutionInvStatus(inventoryStatus) }}
        </a-tag>
      </span>
30
肖超群 authored
31
    </a-table>
32
    <select-inv-container-header ref="selectContainerForm" v-on:getContainer="getContainerCode"></select-inv-container-header>
肖超群 authored
33
  </j-modal>
34
肖超群 authored
35
36
37
</template>

<script>
38
39
40
41
42
43
import { httpAction } from '@/api/manage'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { filterMultiDictText } from '@/components/dict/JDictSelectUtil'
import { validateDuplicateValue } from '@/utils/util'
import { searchMaterialByCode } from '@/api/api'
肖超群 authored
44
import { listReceiveByReceiveId,ajaxGetDictItems } from '@/api/api'
45
import SelectInvContainerHeader from "./SelectInvContainerHeader";
肖超群 authored
46
肖超群 authored
47
export default {
48
  name: 'ReceiveModal',
49
  components: {SelectInvContainerHeader},
肖超群 authored
50
51
52
53
54
55
56
57
58
  props: {
    mainId: {
      type: String,
      required: false,
      default: ''
    }
  },
  data() {
    return {
59
      title: '操作',
肖超群 authored
60
61
62
63
64
      width: 800,
      visible: false,
      materialList: {},
      querySource: {},
      dataSource: [],
65
      invStatus:[],
肖超群 authored
66
67
      model: {},
      labelCol: {
68
69
        xs: { span: 24 },
        sm: { span: 5 }
肖超群 authored
70
71
      },
      wrapperCol: {
72
73
        xs: { span: 24 },
        sm: { span: 16 }
肖超群 authored
74
75
76
77
78
      },
      columns: [
        {
          title: '物料编码',
          dataIndex: 'materialCode',
79
80
          align: 'center',
          width: 124
肖超群 authored
81
        },
肖超群 authored
82
83
84
        {
          title: '物料名称',
          dataIndex: 'materialName',
85
86
          align: 'center',
          width: 96
肖超群 authored
87
        },
肖超群 authored
88
89
90
        {
          title: '库存状态',
          dataIndex: 'inventoryStatus',
91
          align: 'center',
92
93
          width: 96,
          scopedSlots: {customRender: 'inventoryStatus'}
肖超群 authored
94
95
96
97
        },
        {
          title: '批次',
          dataIndex: 'batch',
98
          align: 'center'
肖超群 authored
99
        },
肖超群 authored
100
101
102
        {
          title: '可收数量',
          dataIndex: 'qty',
103
104
          align: 'center',
          width: 80
肖超群 authored
105
106
107
108
        },
        {
          title: '收货数量',
          dataIndex: 'action',
109
110
111
          align: 'center',
          key: 'action',
          scopedSlots: { customRender: 'action' }
112
        },
肖超群 authored
113
114
115
      ],
      confirmLoading: false,
      validatorRules: {
116
        containerCode: [{ required: true, message: '请输入容器编码!' }]
肖超群 authored
117
      },
118
119
      dictOptions: {},
      superFieldList:[],
肖超群 authored
120
      url: {
肖超群 authored
121
        add: '/receipt/receiveHeader/receive',
122
        edit: '/receipt/receiptHeader/editReceiptDetail'
肖超群 authored
123
      }
肖超群 authored
124
125
126
    }
  },
  created() {
肖超群 authored
127
    //备份model原始值
128
129
    this.getSuperFieldList()
    // this.modelDefault = JSON.parse(JSON.stringify(this.model))
130
    this.loadFrom();
肖超群 authored
131
132
  },
  methods: {
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
    loadFrom(){
      ajaxGetDictItems('inventory_status').then((res) => {
        if (res.success) {
          this.invStatus = res.result
        }
      })
    },
    getStatusColor(status) {
      const colors = {
        'good ': 'green',
        'defective': 'red',
        'discussed	': 'grey',
        'scrap': 'purple',
        default: 'blue'
      };
      return colors[status] || colors.default;
    },
150
151
152
153
154
155
    getContainerCode(e){
      this.$nextTick(function (){
        let  record={containerCode: e}
        this.model = Object.assign({}, record)
      })
    },
156
157
158
159
160
161
162
163
164
165
    solutionInvStatus(value) {
      var actions = []
      Object.keys(this.invStatus).some(key => {
        if (this.invStatus[key].value == '' + value) {
          actions.push(this.invStatus[key].text)
          return true
        }
      })
      return actions.join('')
    },
166
167
168
169
    // add() {
    //   this.edit(this.modelDefault)
    //   this.model.inventoryStatus = 'good'
    // },
肖超群 authored
170
    edit(record) {
171
172
      this.model = Object.assign({}, record)
      this.visible = true
肖超群 authored
173
      this.searchReceive();
肖超群 authored
174
    },
175
176
177
178
    // show(record) {
    //   this.model = Object.assign({}, record)
    //   this.visible = true
    // },
179
180
181
    selectContainer(record){
      this.$refs.selectContainerForm.edit(record);
    },
肖超群 authored
182
    close() {
183
184
185
      this.$emit('close')
      this.visible = false
      this.$refs.form.clearValidate()
肖超群 authored
186
187
    },
    searchReceive() {
188
      const that = this
肖超群 authored
189
190
      that.querySource.receiveId = that.model.id;
      listReceiveByReceiveId(that.querySource).then(res => {
191
        that.dataSource = res.result
肖超群 authored
192
193
      })
    },
194
195
196
197
198
199
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({type:'string',value:'inventoryStatus',text:'库存状态',dictCode:'inventory_status'})
      this.superFieldList = fieldList
    },
肖超群 authored
200
    handleOk() {
201
202
      console.log('handleOk')
      const that = this
肖超群 authored
203
204
205
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
          that.confirmLoading = true
          let httpurl = ''
          let method = ''
          httpurl += this.url.add
          method = 'post'
          if (this.dataSource[0] == null) {
            that.confirmLoading = false
            that.$message.warning('入库单没有详情!')
            return
          }
          this.dataSource[0].containerCode = this.model.containerCode
          httpAction(httpurl, this.dataSource, method)
            .then(res => {
              if (res.success) {
                that.$message.success(res.message)
                that.$emit('ok')
                that.close()
              } else {
                that.$message.warning(res.message)
              }
            })
            .finally(() => {
              that.confirmLoading = false
            })
肖超群 authored
230
231
232
233
234
235
236
        } else {
          return false
        }
      })
    },
    handleCancel() {
      this.close()
237
    }
肖超群 authored
238
  }
肖超群 authored
239
}
肖超群 authored
240
</script>