aXin-0810 1 год назад
Родитель
Сommit
f9778674eb

+ 4 - 0
src/api/goodsPurchasedStored.js

@@ -95,3 +95,7 @@ export function goodsPurchaseItemDelCode(params) {
     params
   })
 }
+
+export function goodsPurchaseItemImportCode(data) {
+  return handleImport('/goods/purchase/item/import/code', data.formdata, data.id || '')
+}

+ 39 - 39
src/components/template/import_mixin.js

@@ -3,49 +3,49 @@ export default {
     //导入按钮
     importButton(func, name = '导入', params, fun1, fun2) {
       return (
-          <el-upload
-            action={'_'}
-            show-file-list={false}
-            http-request={data => {
-              const loading = this.$loading({
-                lock: true,
-                text: '正在导入',
-                spinner: 'el-icon-loading',
-                background: 'rgba(0, 0, 0, 0.7)'
-              })
-              fun1 && fun1()
-              var formdata = new FormData()
-              formdata.append('file', data.file)
-              if (!!params) {
-                for (const key in params) {
-                  if (Object.hasOwnProperty.call(params, key)) {
-                    formdata.append(key, params[key])
-                  }
+        <el-upload
+          action={'_'}
+          show-file-list={false}
+          http-request={data => {
+            const loading = this.$loading({
+              lock: true,
+              text: '正在导入',
+              spinner: 'el-icon-loading',
+              background: 'rgba(0, 0, 0, 0.7)'
+            })
+            fun1 && fun1()
+            var formdata = new FormData()
+            formdata.append('file', data.file)
+            if (!!params) {
+              for (const key in params) {
+                if (Object.hasOwnProperty.call(params, key)) {
+                  formdata.append(key, params[key])
                 }
               }
-              func({ formdata })
-                .then(res => {
-                  fun2 && fun2()
-                  this.$refs.pageRef.refreshList()
-                  loading.close()
-                  this.$message({
-                    type: 'success',
-                    message: '导入成功!'
-                  })
+            }
+            func({ formdata })
+              .then(res => {
+                fun2 && fun2()
+                this.$refs.pageRef.refreshList()
+                loading.close()
+                this.$message({
+                  type: 'success',
+                  message: '导入成功!'
                 })
-                .catch(err => {
-                  fun2 && fun2()
-                  loading.close()
-                  this.$message({
-                    type: 'error',
-                    message: err.message || '导入失败'
-                  })
+              })
+              .catch(err => {
+                fun2 && fun2()
+                loading.close()
+                this.$message({
+                  type: 'error',
+                  message: err.message || '导入失败'
                 })
-            }}
-          >
-            <span class="teshudeshangchuananniu">{name}</span>
-          </el-upload>
-        )
+              })
+          }}
+        >
+          <span class="teshudeshangchuananniu">{name}</span>
+        </el-upload>
+      )
     }
   }
 }

+ 3 - 0
src/views/salesPurchasing/goodsPurchasedStored/index.vue

@@ -290,4 +290,7 @@ export default {
 .tab {
   padding: 20px 20px 0 20px;
 }
+::v-deep .teshudeshangchuananniu {
+  color: #409eff !important;
+}
 </style>

+ 35 - 36
src/views/salesPurchasing/mixins/storage_goods.js

@@ -2,6 +2,7 @@ import { required, mobileRequired, mobile } from '@/components/template/rules_ve
 import { getBrandList } from '@/api/miniapp'
 import { getClassifyList } from '@/api/goods'
 import { goodsMaterialList, goodsMaterialDetail } from '@/api/commercialMaterial.js'
+import { goodsPurchaseDetail, goodsPurchaseItemImportCode } from '@/api/goodsPurchasedStored.js'
 export default {
   data() {
     return {
@@ -358,49 +359,47 @@ export default {
                 render: (h, { row, column, index }) => {
                   return (
                     <div style="padding:0 6px" class="operation-btns">
-                      {!~['SAVE', 'WAIT', 'OK', 'FAIL'].indexOf(this.formData.status) ? (
-                        [
-                          this.isEditIndex == index ? (
-                            <el-button
-                              type="text"
-                              onClick={() => {
-                                this.$refs.formRef.validateField(
-                                  this.getVfyKey(this.isEditIndex),
-                                  (valid, invalidFields, errLabels) => {
-                                    if (valid && this.eidtItems()) {
-                                      this.isEditIndex = -1
+                      {!~['SAVE', 'WAIT', 'OK', 'FAIL'].indexOf(this.formData.status)
+                        ? [
+                            this.isEditIndex == index ? (
+                              <el-button
+                                type="text"
+                                onClick={() => {
+                                  this.$refs.formRef.validateField(
+                                    this.getVfyKey(this.isEditIndex),
+                                    (valid, invalidFields, errLabels) => {
+                                      if (valid && this.eidtItems()) {
+                                        this.isEditIndex = -1
+                                      }
                                     }
-                                  }
-                                )
-                              }}
-                            >
-                              保存
-                            </el-button>
-                          ) : null,
-                          this.isEditIndex == -1 ? (
+                                  )
+                                }}
+                              >
+                                保存
+                              </el-button>
+                            ) : null,
+                            this.isEditIndex == -1 ? (
+                              <el-button
+                                type="text"
+                                onClick={() => {
+                                  this.isEditIndex = index
+                                }}
+                              >
+                                编辑
+                              </el-button>
+                            ) : null,
                             <el-button
                               type="text"
                               onClick={() => {
-                                this.isEditIndex = index
+                                this.delGoodsInfo(row, index)
                               }}
                             >
-                              编辑
+                              删除
                             </el-button>
-                          ) : null,
-                          <el-button
-                            type="text"
-                            onClick={() => {
-                              this.delGoodsInfo(row, index)
-                            }}
-                          >
-                            删除
-                          </el-button>
-                        ]
-                      ) : !!~['SAVE'].indexOf(this.formData.status) ? (
-                        <el-button type="text" onClick={() => {}}>
-                          导入条码
-                        </el-button>
-                      ) : null}
+                          ]
+                        : !!~['SAVE'].indexOf(this.formData.status)
+                        ? this.importButton(goodsPurchaseItemImportCode, '导入条码', { purchaseItemId: row.id })
+                        : null}
                     </div>
                   )
                 }

+ 22 - 2
src/views/salesPurchasing/mixins/storage_table.js

@@ -1,4 +1,5 @@
-import { goodsPurchaseDetail } from '@/api/goodsPurchasedStored.js'
+import { goodsPurchaseDetail, goodsPurchaseItemImportCode } from '@/api/goodsPurchasedStored.js'
+import { commonTemplateDownload } from '@/api/common.js'
 export default {
   data() {
     return {}
@@ -27,6 +28,12 @@ export default {
                             添加
                           </el-button>
                         </div>
+                      ) : this.formDialogType == 1 ? (
+                        <div style="margin-bottom:10px">
+                          <el-button type="primary" onClick={this.domlMban}>
+                            下载导入模板
+                          </el-button>
+                        </div>
                       ) : null,
                       <zj-table
                         columns={this.storage_goods}
@@ -84,5 +91,18 @@ export default {
       }
     }
   },
-  methods: {}
+  methods: {
+    domlMban() {
+      commonTemplateDownload({ name: '商品采购条码模板.xlsx' }, `${this.$route.meta.title}`)
+        .then(res => {
+          this.$message({
+            message: '下载成功',
+            type: 'success'
+          })
+        })
+        .catch(err => {
+          this.$message.error('下载失败')
+        })
+    }
+  }
 }