|
@@ -0,0 +1,138 @@
|
|
|
+<template>
|
|
|
+ <el-dialog
|
|
|
+ :title="!dataForm.id ? '新增' : '修改'"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :visible.sync="visible">
|
|
|
+ <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
|
|
|
+<!-- <el-form-item label="编码" prop="code">-->
|
|
|
+<!-- <el-input v-model="dataForm.code" placeholder="编码"></el-input>-->
|
|
|
+<!-- </el-form-item>-->
|
|
|
+ <el-form-item label="名称" prop="materialName">
|
|
|
+ <el-input v-model="dataForm.materialName" placeholder="名称"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="类别" prop="materialTypeId">
|
|
|
+ <el-input v-model="dataForm.materialTypeId" placeholder="类别"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="规格" prop="specifications">
|
|
|
+ <el-input v-model="dataForm.specifications" placeholder="规格"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="单位" prop="unitName">
|
|
|
+ <el-input v-model="dataForm.unitName" placeholder="单位"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="数量" prop="cnt">
|
|
|
+ <el-input-number v-model="dataForm.cnt" :min="0" placeholder="数量"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="visible = false">取消</el-button>
|
|
|
+ <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
|
|
|
+ </span>
|
|
|
+ </el-dialog>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ name: 'stock-add-or-update',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ dataForm: {
|
|
|
+ materialId: 0,
|
|
|
+ materialCode: '',
|
|
|
+ materialName: '',
|
|
|
+ materialTypeId: '',
|
|
|
+ specifications: '',
|
|
|
+ unitName: '',
|
|
|
+ cnt: '',
|
|
|
+ price: '',
|
|
|
+ amount: '',
|
|
|
+ warehouseId: '',
|
|
|
+ shelveId: '',
|
|
|
+ shelveName: '',
|
|
|
+ notes: ''
|
|
|
+ },
|
|
|
+ dataRule: {
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ init (id) {
|
|
|
+ this.dataForm.materialId = id || 0
|
|
|
+ if (this.dataForm.materialId) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/info/${this.dataForm.materialId}`),
|
|
|
+ method: 'get',
|
|
|
+ params: this.$http.adornParams()
|
|
|
+ }).then(({data}) => {
|
|
|
+ if (data.code === '200') {
|
|
|
+ this.visible = true
|
|
|
+ this.dataForm.materialId = data.data.materialId
|
|
|
+ this.dataForm.materialName = data.data.materialName
|
|
|
+ this.dataForm.materialTypeId = data.data.materialTypeId
|
|
|
+ this.dataForm.specifications = data.data.specifications
|
|
|
+ this.dataForm.unitName = data.data.unitName
|
|
|
+ this.dataForm.cnt = data.data.cnt
|
|
|
+ this.dataForm.price = data.data.price
|
|
|
+ this.dataForm.amount = data.data.amount
|
|
|
+ this.dataForm.warehouseId = data.data.warehouseId
|
|
|
+ this.dataForm.shelveName = data.data.shelveName
|
|
|
+ this.dataForm.notes = data.data.notes
|
|
|
+ } else {
|
|
|
+ this.$message.error(data.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 表单提交
|
|
|
+ dataFormSubmit () {
|
|
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.$http({
|
|
|
+ url: this.$http.adornUrl(`/biz-service/stock-mg-ctl/${!this.dataForm.materialId ? 'save' : 'update'}`),
|
|
|
+ method: !this.dataForm.materialId ? 'post' : 'put',
|
|
|
+ data: this.$http.adornData(!this.dataForm.materialId ? {
|
|
|
+ 'materialName': this.dataForm.materialName
|
|
|
+ } : {
|
|
|
+ 'materialId': this.dataForm.materialId,
|
|
|
+ 'materialName': this.dataForm.materialName,
|
|
|
+ 'amount': this.dataForm.amount,
|
|
|
+ 'cateId': this.dataForm.materialTypeId,
|
|
|
+ 'materialTypeId': this.dataForm.materialTypeId,
|
|
|
+ 'cnt': this.dataForm.cnt,
|
|
|
+ 'materialCode': this.dataForm.materialCode,
|
|
|
+ 'notes': this.dataForm.notes,
|
|
|
+ 'price': this.dataForm.price,
|
|
|
+ 'shelveId': this.dataForm.shelveId,
|
|
|
+ 'specifications': this.dataForm.specifications,
|
|
|
+ 'unitName': this.dataForm.unitName,
|
|
|
+ 'warehouseId': this.dataForm.warehouseId,
|
|
|
+ 'updaterId': this.$store.state.user.id
|
|
|
+ })
|
|
|
+ }).then(({data}) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ this.$message({
|
|
|
+ message: '操作成功',
|
|
|
+ type: 'success',
|
|
|
+ duration: 1500,
|
|
|
+ onClose: () => {
|
|
|
+ this.visible = false
|
|
|
+ this.$emit('refreshDataList')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.$message.error(data.msg)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ validateField (type) {
|
|
|
+ this.$refs.dataForm.validateField(type)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+
|
|
|
+</style>
|