|
@@ -0,0 +1,152 @@
|
|
|
+<template>
|
|
|
+ <a-modal
|
|
|
+ centered
|
|
|
+ class="transferTypeManagementEdit-modal"
|
|
|
+ :footer="null"
|
|
|
+ :maskClosable="false"
|
|
|
+ :title="modalTit"
|
|
|
+ v-model="isShow"
|
|
|
+ @cancle="isShow=false"
|
|
|
+ :width="800">
|
|
|
+ <!-- 表单 -->
|
|
|
+ <div>
|
|
|
+ <a-form-model
|
|
|
+ id="transferTypeManagementEdit-form"
|
|
|
+ ref="ruleForm"
|
|
|
+ :model="form"
|
|
|
+ :rules="rules"
|
|
|
+ :label-col="formItemLayout.labelCol"
|
|
|
+ :wrapper-col="formItemLayout.wrapperCol"
|
|
|
+ >
|
|
|
+ <a-form-model-item label="调拨类别" prop="allocateCategory">
|
|
|
+ <v-select code="ALLOCATE_CATEGORY" id="transferTypeManagementEdit-allocateCategory" v-model="form.allocateCategory" allowClear placeholder="请选择调拨类别"></v-select>
|
|
|
+ </a-form-model-item>
|
|
|
+ <a-form-model-item label="调拨类型名称" prop="name">
|
|
|
+ <a-input
|
|
|
+ id="transferTypeManagementEdit-name"
|
|
|
+ :maxLength="30"
|
|
|
+ v-model.trim="form.name"
|
|
|
+ @change="filterEmpty"
|
|
|
+ placeholder="请输入调拨类型名称(最多30个字符)"
|
|
|
+ allowClear />
|
|
|
+ </a-form-model-item>
|
|
|
+ </a-form-model>
|
|
|
+ <div class="btn-cont">
|
|
|
+ <a-button type="primary" id="storeTransferOut-type-edit-modal-save" @click="handleSave">保存</a-button>
|
|
|
+ <a-button id="storeTransferOut-type-edit-modal-back" @click="isShow = false" style="margin-left: 15px;">返回列表</a-button>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </a-modal>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { VSelect } from '@/components'
|
|
|
+import { allocateTypeSave } from '@/api/allocateType'
|
|
|
+export default {
|
|
|
+ name: 'TransferTypeManagementEditModal',
|
|
|
+ components: { VSelect },
|
|
|
+ props: {
|
|
|
+ openModal: { // 弹框显示状态
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
+ itemSn: {
|
|
|
+ type: [Number, String],
|
|
|
+ default: ''
|
|
|
+ },
|
|
|
+ nowData: {
|
|
|
+ type: Object,
|
|
|
+ default: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ modalTit () {
|
|
|
+ return (this.itemSn ? '编辑' : '新增') + '调拨类型'
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ isShow: this.openModal, // 是否打开弹框
|
|
|
+ detailsData: null, // 品牌数据
|
|
|
+ formItemLayout: {
|
|
|
+ labelCol: { span: 6 },
|
|
|
+ wrapperCol: { span: 16 }
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ name: '', // 调拨类型名称
|
|
|
+ allocateCategory: undefined // 调拨类别
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入调拨类型名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ allocateCategory: [
|
|
|
+ { required: true, message: '请选择调拨类别', trigger: 'change' }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ filterEmpty () {
|
|
|
+ let str = this.form.name
|
|
|
+ str = str.replace(/\ +/g, '')
|
|
|
+ str = str.replace(/[ ]/g, '')
|
|
|
+ str = str.replace(/[\r\n]/g, '')
|
|
|
+ this.form.name = str
|
|
|
+ },
|
|
|
+ // 保存
|
|
|
+ handleSave () {
|
|
|
+ const _this = this
|
|
|
+ this.$refs.ruleForm.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const form = _this.form
|
|
|
+ form.id = _this.itemSn ? _this.itemSn : null
|
|
|
+ allocateTypeSave(form).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$message.success(res.message)
|
|
|
+ _this.isShow = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log('error submit!!')
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ // 父页面传过来的弹框状态
|
|
|
+ openModal (newValue, oldValue) {
|
|
|
+ this.isShow = newValue
|
|
|
+ },
|
|
|
+ // 重定义的弹框状态
|
|
|
+ isShow (newValue, oldValue) {
|
|
|
+ if (!newValue) {
|
|
|
+ this.$emit('close')
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ itemSn (newValue, oldValue) {
|
|
|
+ if (this.isShow && newValue) { // 编辑
|
|
|
+ this.form.name = this.nowData && this.nowData.name ? this.nowData.name : ''
|
|
|
+ this.form.allocateCategory = this.nowData && this.nowData.allocateCategory ? this.nowData.allocateCategory : ''
|
|
|
+ } else { // 添加
|
|
|
+ this.form.name = ''
|
|
|
+ this.form.allocateCategory = undefined
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="less">
|
|
|
+ .transferTypeManagementEdit-modal{
|
|
|
+ .ant-modal-body {
|
|
|
+ padding: 40px 40px 24px;
|
|
|
+ }
|
|
|
+ .btn-cont {
|
|
|
+ text-align: center;
|
|
|
+ margin: 35px 0 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+</style>
|