|
@@ -1,198 +1,291 @@
|
|
|
<!-- 出库申请 -->
|
|
|
<template>
|
|
|
- <div>
|
|
|
- <div class="my-title">出库申请</div>
|
|
|
- <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
|
|
|
- <el-row class="my-row my-row-1">
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="编码" prop="recordCode">
|
|
|
- <el-input v-model="dataForm.recordCode" :disabled="true" placeholder="编码系统自动生成"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <template v-for="(item, index) in dataList">
|
|
|
- <div :key="index" class="my-line">
|
|
|
- <el-row class="my-row" style="margin-bottom: 20px">
|
|
|
- <el-col :span="24" style="text-align: right;">
|
|
|
- <el-button @click="removeOne(index)" type="danger" icon="el-icon-delete" circle style="padding: 6px"></el-button>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row class="my-row">
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="类别" prop="cateId">
|
|
|
-<!-- <el-input v-model="item.categoryName" :disabled="true" placeholder="类别"></el-input>-->
|
|
|
- <material-type-component v-model="item.materialTypeId" :type-id.sync="item.materialTypeId"></material-type-component>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="名称" prop="materialName">
|
|
|
- <el-input v-if="id" v-model="item.materialName" :disabled="true" style="width: 200px; margin-right: 10px"/>
|
|
|
- <material-component v-else
|
|
|
- v-model="dataList[index]"
|
|
|
- :material-id.sync="item.materialId"
|
|
|
- :material-type.sync="item.materialTypeId">
|
|
|
- </material-component>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="出库依据类别" prop="sourceCategory">
|
|
|
- <el-select
|
|
|
- v-model="item.sourceCategory"
|
|
|
- placeholder="请选择"
|
|
|
- style="width: 100%"
|
|
|
+ <div>
|
|
|
+ <div class="my-title">出库申请</div>
|
|
|
+ <el-form
|
|
|
+ :model="dataForm"
|
|
|
+ :rules="dataRule"
|
|
|
+ ref="dataForm"
|
|
|
+ label-width="auto"
|
|
|
+ >
|
|
|
+ <el-row class="my-row my-row-1">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="编码" prop="recordCode">
|
|
|
+ <el-input
|
|
|
+ v-model="dataForm.recordCode"
|
|
|
+ :disabled="true"
|
|
|
+ placeholder="编码系统自动生成"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <template v-for="(item, index) in dataList">
|
|
|
+ <div :key="index" class="my-line">
|
|
|
+ <el-row class="my-row" style="margin-bottom: 20px">
|
|
|
+ <el-col :span="24" style="text-align: right">
|
|
|
+ <el-button
|
|
|
+ @click="removeOne(index)"
|
|
|
+ type="danger"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ circle
|
|
|
+ style="padding: 6px"
|
|
|
+ ></el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row class="my-row">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="名称" prop="materialName">
|
|
|
+ <el-input
|
|
|
+ v-if="id"
|
|
|
+ v-model="item.materialName"
|
|
|
+ :disabled="true"
|
|
|
+ style="width: 200px; margin-right: 10px"
|
|
|
+ />
|
|
|
+ <material-component
|
|
|
+ v-else
|
|
|
+ v-model="dataList[index]"
|
|
|
+ :material-id.sync="item.materialId"
|
|
|
+ :material-type.sync="item.materialTypeId"
|
|
|
+ >
|
|
|
+ </material-component>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="类别" prop="cateId">
|
|
|
+ <material-type-component
|
|
|
+ v-model="item.materialTypeId"
|
|
|
+ :type-id.sync="item.materialTypeId"
|
|
|
+ ></material-type-component>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="出库依据类别" prop="sourceCategory">
|
|
|
+ <el-select
|
|
|
+ v-model="item.sourceCategory"
|
|
|
+ placeholder="请选择"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in optionsCategory()"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
>
|
|
|
- <el-option
|
|
|
- v-for="item in optionsCategory()"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value">
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row class="my-row">
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="单位" prop="unitName">
|
|
|
- <el-input v-model="item.unitName" :disabled="true" placeholder="单位"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="规格" prop="specifications">
|
|
|
- <el-input v-model="item.specifications" :disabled="true" placeholder="规格"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- <el-col :span="8">
|
|
|
- <el-form-item label="数量" prop="cnt">
|
|
|
- <el-input-number v-model="item.cnt" :min="0" :max="item.cntLimit"></el-input-number>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-row class="my-row">
|
|
|
- <el-col :span="24">
|
|
|
- <el-form-item label="用途" prop="notes">
|
|
|
- <el-input v-model="item.notes" placeholder="出库用于(说明用途)"></el-input>
|
|
|
- </el-form-item>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <el-row style="text-align: center;">
|
|
|
- <el-button type="primary" icon="el-icon-plus" @click="addOne"></el-button>
|
|
|
- </el-row>
|
|
|
- </el-form>
|
|
|
- <span slot="footer" class="dialog-footer">
|
|
|
- <el-button @click="onChose">取消</el-button>
|
|
|
- <el-button type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row class="my-row">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="任务单" prop="orderId">
|
|
|
+ <el-select
|
|
|
+ v-model="item.orderId"
|
|
|
+ filterable
|
|
|
+ remote
|
|
|
+ reserve-keyword
|
|
|
+ placeholder="请输入关键词"
|
|
|
+ :remote-method="debouncedSearch"
|
|
|
+ :loading="loading"
|
|
|
+ style="width: 100%"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in orderOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row class="my-row">
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="单位" prop="unitName">
|
|
|
+ <el-input
|
|
|
+ v-model="item.unitName"
|
|
|
+ :disabled="true"
|
|
|
+ placeholder="单位"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="规格" prop="specifications">
|
|
|
+ <el-input
|
|
|
+ v-model="item.specifications"
|
|
|
+ :disabled="true"
|
|
|
+ placeholder="规格"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="8">
|
|
|
+ <el-form-item label="数量" prop="cnt">
|
|
|
+ <el-input-number
|
|
|
+ v-model="item.cnt"
|
|
|
+ :min="0"
|
|
|
+ :max="item.cntLimit"
|
|
|
+ ></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-row class="my-row">
|
|
|
+ <el-col :span="24">
|
|
|
+ <el-form-item label="用途" prop="notes">
|
|
|
+ <el-input
|
|
|
+ v-model="item.notes"
|
|
|
+ placeholder="出库用于(说明用途)"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <el-row style="text-align: center">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ @click="addOne"
|
|
|
+ ></el-button>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="onChose">取消</el-button>
|
|
|
+ <el-button type="primary" @click="dataFormSubmit()" v-reClick
|
|
|
+ >确定</el-button
|
|
|
+ >
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import UserComponent from '../common/user-component'
|
|
|
- import DictSelect from '../sys/dict-select'
|
|
|
- import {getBoundDetails, outboundBatch, updateBatch} from '@/api/warehouse'
|
|
|
- import {getUUID} from '@/utils'
|
|
|
- import MaterialComponent from '../common/material-component'
|
|
|
- import MaterialTypeComponent from '@/views/modules/common/material-type-component.vue'
|
|
|
- import {optionsCategory} from '@/utils/enums'
|
|
|
+import UserComponent from '../common/user-component'
|
|
|
+import DictSelect from '../sys/dict-select'
|
|
|
+import { getBoundDetails, outboundBatch, updateBatch } from '@/api/warehouse'
|
|
|
+import { getUUID } from '@/utils'
|
|
|
+import MaterialComponent from '../common/material-component'
|
|
|
+import MaterialTypeComponent from '@/views/modules/common/material-type-component.vue'
|
|
|
+import { optionsCategory } from '@/utils/enums'
|
|
|
+import { getOrderByCode } from '@/api/sale'
|
|
|
+import _ from 'lodash'
|
|
|
export default {
|
|
|
- name: 'stock-order-inbound',
|
|
|
- components: {MaterialTypeComponent, MaterialComponent, DictSelect, UserComponent},
|
|
|
- data () {
|
|
|
- return {
|
|
|
- visible: false,
|
|
|
- dataForm: {},
|
|
|
- dataList: [],
|
|
|
- dataRule: {
|
|
|
- }
|
|
|
- }
|
|
|
+ name: 'stock-order-inbound',
|
|
|
+ components: {
|
|
|
+ MaterialTypeComponent,
|
|
|
+ MaterialComponent,
|
|
|
+ DictSelect,
|
|
|
+ UserComponent
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ visible: false,
|
|
|
+ dataForm: {},
|
|
|
+ dataList: [],
|
|
|
+ dataRule: {},
|
|
|
+ loading: false,
|
|
|
+ orderOptions: []
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ // 创建防抖函数(500ms延迟)
|
|
|
+ this.debouncedSearch = _.debounce(this.remoteMethod, 500)
|
|
|
+ },
|
|
|
+ beforeDestroy () {
|
|
|
+ // 清除防抖定时器,避免内存泄漏
|
|
|
+ this.debouncedSearch.cancel()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ optionsCategory () {
|
|
|
+ return optionsCategory
|
|
|
+ },
|
|
|
+ onChose () {
|
|
|
+ this.$emit('onChose')
|
|
|
},
|
|
|
- methods: {
|
|
|
- optionsCategory () {
|
|
|
- return optionsCategory
|
|
|
- },
|
|
|
- onChose () {
|
|
|
- this.$emit('onChose')
|
|
|
- },
|
|
|
- async init (id) {
|
|
|
- this.visible = true
|
|
|
- this.id = id || 0
|
|
|
- this.dataForm = {}
|
|
|
- this.dataList = []
|
|
|
- if (id) {
|
|
|
- // 获取详情
|
|
|
- await getBoundDetails(id).then(({data}) => {
|
|
|
- if (data && data.code === '200') {
|
|
|
- if (data.data[0]) {
|
|
|
- this.dataForm = {
|
|
|
- recordCode: data.data[0].recordCode,
|
|
|
- applicant: data.data[0].applicant,
|
|
|
- orgName: data.data[0].orgName
|
|
|
- }
|
|
|
+ async init (id) {
|
|
|
+ this.visible = true
|
|
|
+ this.id = id || 0
|
|
|
+ this.dataForm = {}
|
|
|
+ this.dataList = []
|
|
|
+ if (id) {
|
|
|
+ // 获取详情
|
|
|
+ await getBoundDetails(id).then(({ data }) => {
|
|
|
+ if (data && data.code === '200') {
|
|
|
+ if (data.data[0]) {
|
|
|
+ this.dataForm = {
|
|
|
+ recordCode: data.data[0].recordCode,
|
|
|
+ applicant: data.data[0].applicant,
|
|
|
+ orgName: data.data[0].orgName
|
|
|
}
|
|
|
- this.dataForm.recordType = 1
|
|
|
- data.data.forEach((item) => {
|
|
|
- this.addOne(item)
|
|
|
- })
|
|
|
}
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.addOne()
|
|
|
- }
|
|
|
- },
|
|
|
- addOne (item) {
|
|
|
- if (item) {
|
|
|
- this.dataList.push({
|
|
|
- ...item
|
|
|
- })
|
|
|
- } else {
|
|
|
- this.dataList.push({
|
|
|
- id: '',
|
|
|
- code: getUUID(),
|
|
|
- amount: 0,
|
|
|
- applicant: '',
|
|
|
- approver: '',
|
|
|
- batchNumber: '',
|
|
|
- cnt: '',
|
|
|
- materialId: '',
|
|
|
- materialName: '',
|
|
|
- notes: '',
|
|
|
- orgId: '',
|
|
|
- price: '',
|
|
|
- recordType: '',
|
|
|
- source: '',
|
|
|
- state: 0,
|
|
|
- templateItemPlanId: '',
|
|
|
- usage: '',
|
|
|
- userId: '',
|
|
|
- orgName: '',
|
|
|
- sourceCategory: '1'
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- removeOne (index) {
|
|
|
- this.dataList.splice(index, 1)
|
|
|
- if (this.dataList.length === 0) {
|
|
|
- this.addOne()
|
|
|
- }
|
|
|
- },
|
|
|
- // 表单提交
|
|
|
- dataFormSubmit () {
|
|
|
- this.$refs['dataForm'].validate((valid) => {
|
|
|
- if (valid) {
|
|
|
- let postData = []
|
|
|
- this.dataList.forEach((item) => {
|
|
|
- postData.push({
|
|
|
- ...item,
|
|
|
- applicant: this.dataForm.userId,
|
|
|
- orgId: this.$store.state.user.orgId,
|
|
|
- recordCode: this.dataForm.recordCode,
|
|
|
- recordType: this.dataForm.recordType,
|
|
|
- creatorId: this.$store.state.user.id
|
|
|
- })
|
|
|
- });
|
|
|
- (!this.id ? outboundBatch(postData) : updateBatch(postData)).then(({data}) => {
|
|
|
+ this.dataForm.recordType = 1
|
|
|
+ data.data.forEach((item) => {
|
|
|
+ this.addOne(item)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.addOne()
|
|
|
+ }
|
|
|
+
|
|
|
+ this.remoteMethod()
|
|
|
+ },
|
|
|
+ addOne (item) {
|
|
|
+ this.remoteMethod()
|
|
|
+ if (item) {
|
|
|
+ this.dataList.push({
|
|
|
+ ...item
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.dataList.push({
|
|
|
+ id: '',
|
|
|
+ code: getUUID(),
|
|
|
+ amount: 0,
|
|
|
+ applicant: '',
|
|
|
+ approver: '',
|
|
|
+ batchNumber: '',
|
|
|
+ cnt: '',
|
|
|
+ materialId: '',
|
|
|
+ materialName: '',
|
|
|
+ notes: '',
|
|
|
+ orgId: '',
|
|
|
+ price: '',
|
|
|
+ recordType: '',
|
|
|
+ source: '',
|
|
|
+ state: 0,
|
|
|
+ templateItemPlanId: '',
|
|
|
+ usage: '',
|
|
|
+ userId: '',
|
|
|
+ orgName: '',
|
|
|
+ sourceCategory: '1'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ removeOne (index) {
|
|
|
+ this.dataList.splice(index, 1)
|
|
|
+ if (this.dataList.length === 0) {
|
|
|
+ this.addOne()
|
|
|
+ }
|
|
|
+
|
|
|
+ this.remoteMethod()
|
|
|
+ },
|
|
|
+ // 表单提交
|
|
|
+ dataFormSubmit () {
|
|
|
+ this.$refs['dataForm'].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ let postData = []
|
|
|
+ this.dataList.forEach((item) => {
|
|
|
+ postData.push({
|
|
|
+ ...item,
|
|
|
+ applicant: this.dataForm.userId,
|
|
|
+ orgId: this.$store.state.user.orgId,
|
|
|
+ recordCode: this.dataForm.recordCode,
|
|
|
+ recordType: this.dataForm.recordType,
|
|
|
+ creatorId: this.$store.state.user.id
|
|
|
+ })
|
|
|
+ });
|
|
|
+ (!this.id ? outboundBatch(postData) : updateBatch(postData)).then(
|
|
|
+ ({ data }) => {
|
|
|
if (data && data.code === '200') {
|
|
|
this.$message({
|
|
|
message: '操作成功',
|
|
@@ -206,23 +299,39 @@ export default {
|
|
|
} else {
|
|
|
this.$message.error(data.msg)
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- validateField (type) {
|
|
|
- this.$refs.dataForm.validateField(type)
|
|
|
- }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ validateField (type) {
|
|
|
+ this.$refs.dataForm.validateField(type)
|
|
|
+ },
|
|
|
+ remoteMethod (query) {
|
|
|
+ this.loading = true
|
|
|
+ this.getOrderByCode(query)
|
|
|
+ },
|
|
|
+ getOrderByCode (orderCode) {
|
|
|
+ getOrderByCode(orderCode).then(({ data }) => {
|
|
|
+ this.loading = false
|
|
|
+
|
|
|
+ if (data && data.code === '200' && data.data) {
|
|
|
+ this.orderOptions = data.data.map(item => {
|
|
|
+ return {label: item.orderCode, value: item.orderId}
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
|
-.my-line{
|
|
|
+.my-line {
|
|
|
border-bottom: 1px solid #c0c4cc;
|
|
|
margin-bottom: 10px;
|
|
|
}
|
|
|
-.my-row-1{
|
|
|
+.my-row-1 {
|
|
|
margin-bottom: 20px;
|
|
|
}
|
|
|
</style>
|