浏览代码

库存修改商品名称功能

lizhenhao 2 年之前
父节点
当前提交
a19674fd7c

+ 7 - 0
src/api/materialManagement/WareHouseService.js

@@ -127,4 +127,11 @@ export default class WareHouseService {
       data: {tradeName: tradeName, wareHouseType: wareHouseType, warnNum: warnNum}
     })
   }
+  saveTradeName (oldTradeName, tradeName) {
+    return request({
+      url: `/material/management/wareHouse/saveTradeName`,
+      method: 'post',
+      data: {oldTradeName: oldTradeName, tradeName: tradeName}
+    })
+  }
 }

+ 101 - 0
src/views/modules/materialManagement/wareHouseSummary/EditTradeNameForm.vue

@@ -0,0 +1,101 @@
+<template>
+  <div>
+    <el-dialog
+      title="修改商品名称"
+      :close-on-click-modal="false"
+      v-dialogDrag
+      width="500px"
+      @close="close"
+      append-to-body
+      @keyup.enter.native=""
+      :visible.sync="visible">
+      <div style="height: calc(100% - 80px);">
+        <el-form size="large" style="margin-top: 30px" ref="inputForm" :model="inputForm"  @submit.native.prevent>
+          <!-- 搜索框-->
+          <el-row :gutter="26">
+            <el-col :span="24">
+              <el-form-item prop="tradeName" :rules="[
+                        {required: true, message: '商品名称不能为空', trigger: 'blur'}
+                      ]">
+                <el-input v-model="inputForm.tradeName" placeholder="请输入商品名称" ></el-input>
+              </el-form-item>
+            </el-col>
+          </el-row>
+
+        </el-form>
+      </div>
+      <span slot="footer" class="dialog-footer">
+      <el-button size="small" @click="close()" icon="el-icon-circle-close">关闭</el-button>
+      <el-button size="small" type="primary" @click="submit()" icon="el-icon-circle-check" v-noMoreClick>确定</el-button>
+    </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+  import WareHouseService from '@/api/materialManagement/WareHouseService'
+  export default {
+    data () {
+      return {
+        title: '',
+        method: '',
+        visible: false,
+        loading: false,
+        dataList: [],
+        inputForm: {
+          tradeName: ''
+        },
+        oldTradeName: ''
+      }
+    },
+    wareHouseService: null,
+    created () {
+      this.wareHouseService = new WareHouseService()
+    },
+    components: {
+    },
+    methods: {
+      init (tradeName) {
+        this.visible = true
+        this.inputForm.tradeName = tradeName
+        this.oldTradeName = tradeName
+      },
+      // 表单提交
+      submit () {
+        this.$refs['inputForm'].validate((valid) => {
+          if (valid) {
+            this.$confirm('确定将商品名称为 ”' + this.oldTradeName + '“ 的入库商品全部改为 ”' + this.inputForm.tradeName + '“ 吗?', '提示', {
+              confirmButtonText: '确定',
+              cancelButtonText: '取消',
+              type: 'warning'
+            }).then(() => {
+              this.loading = true
+              this.wareHouseService.saveTradeName(this.oldTradeName, this.inputForm.tradeName).then(({data}) => {
+                this.$message.success(data)
+                this.close()
+                this.$emit('refreshList')
+                this.loading = false
+              }).catch(() => {
+                this.$refs.inputForm.resetFields()
+                this.loading = false
+              })
+            })
+          }
+        })
+      },
+      close () {
+        this.$refs.inputForm.resetFields()
+        this.inputForm = {
+          tradeName: ''
+        }
+        this.visible = false
+      }
+    }
+  }
+</script>
+<style scoped>
+  /deep/ .el-dialog__body {
+    padding-top: 0px;
+    padding-bottom: 15px;
+  }
+</style>

+ 13 - 2
src/views/modules/materialManagement/wareHouseSummary/WareHouseSummaryList.vue

@@ -125,7 +125,11 @@
             </template>
           </vxe-column>
 <!--          <vxe-column min-width="160" align="center" title="入库时间" field="wareHouseDate"></vxe-column>-->
-
+          <vxe-column title="操作" width="80px" fixed="right" align="center">
+            <template  slot-scope="scope">
+              <el-button v-if="hasPermission('material:summary:edit')" type="text"  size="small" @click="edit(scope.row.tradeName)">修改</el-button>
+            </template>
+          </vxe-column>
         </vxe-table>
         <vxe-pager
           background
@@ -141,6 +145,7 @@
         <WareHouseHistory ref="wareHouseHistory"></WareHouseHistory>
         <WareHouseHistoryPopup ref="wareHouseHistoryPopup"></WareHouseHistoryPopup>
         <SupplierChooseForm ref="supplierChooseForm" @getSupplier="getSupplier"></SupplierChooseForm>
+        <EditTradeNameForm ref="editTradeNameForm" @refreshList="refreshList"></EditTradeNameForm>
       </div>
     </div>
   </div>
@@ -161,6 +166,7 @@
   import UserService from '@/api/sys/UserService'
   import SelectUserTree from '@/views/modules/utils/treeUserSelect'
   import SupplierChooseForm from '@/views/modules/materialManagement/supplier/SupplierChooseForm'
+  import EditTradeNameForm from '@/views/modules/materialManagement/wareHouseSummary/EditTradeNameForm'
   export default {
     data () {
       return {
@@ -214,7 +220,8 @@
       WareHouseHistoryPopup,
       SelectTree,
       WareHouseAddForm,
-      SupplierChooseForm
+      SupplierChooseForm,
+      EditTradeNameForm
     },
     computed: {
       userName () {
@@ -238,6 +245,10 @@
         let detailId = this.commonJS.isNotEmpty(this.searchForm.supplierId) ? row.id : ''
         this.$refs.wareHouseHistory.init(row.tradeName, detailId)
       },
+      // 修改商品名称
+      edit (tradeName) {
+        this.$refs.editTradeNameForm.init(tradeName)
+      },
       // 查询当前用户是否是管理员用户
       checkIsAdmin () {
         this.userService.is().then(({data}) => {