xiongchao 3 tahun lalu
induk
melakukan
30894e844b

+ 18 - 0
src/api/store/store.js

@@ -1,6 +1,24 @@
 import { axios } from '@/utils/request'
 import { stringify } from 'qs'
 
+/**
+ * add batch func
+ * parameter: { }
+ * @param parameter
+ * @returns {*}
+ */
+export function changeStore (parameter) {
+  return axios({
+    url: '/store/stores/change',
+    method: 'POST',
+    headers: {
+      'Accept': 'application/json',
+      'Content-Type': 'application/json;charset=UTF-8'
+    },
+    data: parameter
+  })
+}
+
 /**
  * page func
  * parameter: { }

+ 10 - 4
src/views/store/store/Store.vue

@@ -85,6 +85,8 @@
           <a-popconfirm v-if="$auth('store-stores-del')" title="删除仓库,将清空仓库所有物资数据??" @confirm="batchDelete(record.id)">
             <a>删除</a>
           </a-popconfirm>
+          <a-divider type="vertical" />
+          <a @click="changeStore(record)">迁移仓库</a>
           <!-- <a-divider type="vertical" />
            <a @click="doExportSpareStore(record)">导出库存</a>
            <a-divider type="vertical" />
@@ -104,6 +106,7 @@
     <base-form ref="baseModal" @ok="handleOk"/>
     <detail ref="detailModal"/>
     <import-form-add ref="importModal" @ok="handleOk"/>
+    <change-form ref="changeModal" @ok="handleOk"/>
   </a-card>
 </template>
 
@@ -111,11 +114,10 @@
 import { STable, Ellipsis } from '@/components'
 import BaseForm from './modules/BaseForm'
 import Detail from './modules/Detail'
-import { fetchStoreTableTree, deleteStores, fetchStore, exportStore, fetchStoreTree } from '@/api/store/store'
-import { queryDept, getDeptsAllByParentId } from '@/api/upms/dept'
+import { fetchStoreTableTree, deleteStores, fetchStore, exportStore } from '@/api/store/store'
 import ImportFormAdd from './modules/ImportFormAdd'
 import { exportSpareStore } from '@/api/store/sparestore'
-import { fetchSbTypeTableTree } from '@/api/sb/type'
+import ChangeForm from './modules/ChangeForm'
 
 export default {
   name: 'StoreList',
@@ -124,7 +126,8 @@ export default {
     Ellipsis,
     BaseForm,
     Detail,
-    ImportFormAdd
+    ImportFormAdd,
+    ChangeForm
   },
   props: {
     filter: {
@@ -276,6 +279,9 @@ export default {
     doImport (record) {
       this.$refs.importModal.base(record.id)
     },
+    changeStore (record) {
+      this.$refs.changeModal.base(record)
+    },
     handleOk () {
       fetchStoreTableTree()
         .then(res => {

+ 119 - 0
src/views/store/store/modules/ChangeForm.vue

@@ -0,0 +1,119 @@
+<template>
+  <a-modal
+    :title="modalTitle"
+    :width="640"
+    :visible="visible"
+    :confirmLoading="confirmLoading"
+    @cancel="handleCancel"
+  >
+    <a-form :form="form">
+      <a-form-item
+        label="原仓库"
+        :labelCol="BaseTool.Constant.labelCol"
+        :wrapperCol="BaseTool.Constant.wrapperCol"
+      >
+        <a-input
+          disabled
+          v-model="sourceStoreName" />
+      </a-form-item>
+      <a-form-item
+        label="目的仓库"
+        :labelCol="BaseTool.Constant.labelCol"
+        :wrapperCol="BaseTool.Constant.wrapperCol"
+      >
+        <a-input
+          disabled
+          style="width:70%"
+          v-decorator="['destStoreName', {rules: [{required: true, message: '仓库不能为空'}]}]" />
+        <a-button type="primary" @click="handleStoreSelect">选择仓库</a-button>
+      </a-form-item>
+    </a-form>
+    <p style="color: red">注意事项:<br/>
+      1:将某个仓库的备件库存全部转移到另外的仓库<br/>
+      2:原仓库库存清空为0,<br/>
+      3:原仓库为0的备件不迁移<br/>
+      4:新仓库已存在的备件直接增加数量<br/>
+      5:新仓库已不存在的备件,则新增该备件<br/>
+    </p>
+    <template slot="footer">
+      <a-button :loading="confirmLoading" type="primary" @click="save()">确定</a-button>
+    </template>
+    <store-select-modal ref="storeSelectModal" @selected="handleStoreSelected"/>
+  </a-modal>
+</template>
+
+<script>
+import { changeStore } from '@/api/store/store'
+import StoreSelectModal from '@/views/store/store/modules/StoreSelectModal'
+export default {
+  name: 'SbModelBomImportForm',
+  components: {
+    StoreSelectModal
+  },
+  data () {
+    return {
+      confirmLoading: false,
+      modalTitle: null,
+      form: this.$form.createForm(this),
+      visible: false,
+      sourceStoreId: null,
+      sourceStoreName: null,
+      destStoreId: null
+    }
+  },
+  methods: {
+    base (record) {
+      this.visible = true
+      this.sourceStoreId = record.id
+      this.sourceStoreName = record.name
+      this.modalTitle = '仓库迁移'
+    },
+    save () {
+      const { form: { validateFieldsAndScroll } } = this
+      this.confirmLoading = true
+      validateFieldsAndScroll((errors, values) => {
+        if (errors) {
+          this.confirmLoading = false
+          return
+        }
+        const formData = new FormData()
+        formData.append('sourceStoreId', this.sourceStoreId)
+        formData.append('destStoreId', this.destStoreId)
+        changeStore(formData)
+          .then((res) => {
+            this.$message.success(res.data)
+            this.handleCancel(values)
+          }).catch(() => {
+            this.confirmLoading = false
+          })
+      })
+    },
+    handleCancel (values) {
+      this.visible = false
+      this.confirmLoading = false
+      this.fileList = []
+      this.form.resetFields()
+      this.storeId = null
+      this.$emit('ok', values)
+    },
+    handleStoreSelect () {
+      this.$refs.storeSelectModal.base({}, { filter: 0 })
+    },
+    handleStoreSelected (record, keys, rows) {
+      // 重新选择了仓库,则明细需要全部清空
+      this.data = []
+      const [ key ] = keys
+      const [ row ] = rows
+      const { form: { setFieldsValue } } = this
+      this.destStoreId = key
+      // 日期处理
+      this.$nextTick(() => {
+        setFieldsValue(Object.assign({
+          'destStoreName': row.name
+        }))
+      })
+    }
+
+  }
+}
+</script>