Explorar o código

新增导入重打文件

gongwencan hai 3 meses
pai
achega
f78e2481b5

+ 13 - 0
src/api/PrintCodeApi.js

@@ -15,6 +15,19 @@ class PrintCodeApi extends BaseCurdApi {
     method: 'POST',
     data
   })
+
+  importData = (data) => {
+    const formData = new FormData()
+    formData.append('file', data.file)
+    return this.api({
+      url: `${this.basePath}/reprint/send/import`,
+      method: 'POST',
+      data: formData,
+      headers: {
+        'Content-Type': 'multipart/form-data'
+      }
+    })
+  }
 }
 
 export default new PrintCodeApi()

+ 122 - 0
src/components/DialogImportRePrint.vue

@@ -0,0 +1,122 @@
+<template>
+    <el-dialog
+      :visible.sync="visible"
+      title="导入重打数据"
+      append-to-body
+      width="500px"
+      :close-on-click-modal="false"
+    >
+      <el-form
+        ref="form"
+        :model="uploadData"
+        label-width="80px"
+      >
+      <div class="overflow-auto">
+        <el-row :gutter="0">
+              <el-col :span="24">
+                <el-form-item prop="file" label="上传文件" :rules="[{
+                  required: true,
+                  message: '请选择需要上传的文件'
+                }]">
+                  <el-input :value="uploadData.file ? uploadData.file.name : ''" read-only>
+                    <template #append>
+                      <el-upload
+                        ref="upload"
+                        action=""
+                        :auto-upload="false"
+                        :multiple="false"
+                        :show-file-list="false"
+                        accept=".xls,.xlsx, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"
+                        :on-change="onFileChange"
+                      >
+                        <div class="el-button el-button--primary" style="border-radius: 0 4px 4px 0;">浏览</div>
+                      </el-upload>
+                    </template>
+                  </el-input>
+                </el-form-item>
+              </el-col>
+            </el-row>
+        </div>
+      </el-form>
+
+      <template #footer>
+        <div class="flex center dialog-footer">
+          <el-button
+            @click="onCloseBtnClick"
+          >取消</el-button>
+
+          <el-button
+            type="primary"
+            @click="onImportDataBtnClick"
+          >确定</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </template>
+
+<script>
+// import BasePage from '@@/utils/BasePage'
+import BaseCurdList from '@@/utils/BaseCurdList'
+import PrintCode from '@@/entries/PrintCode'
+
+export default {
+  name: 'DialogImportReprint',
+  //   extends: BasePage,
+  extends: BaseCurdList(PrintCode),
+  data: () => ({
+    visible: false,
+    activeCollapseName: '1',
+    uploadData: {
+      file: null
+    }
+  }),
+  methods: {
+    open () {
+      this.uploadData = {
+        file: null
+      }
+
+      this.visible = true
+      this.$nextTick(() => {
+        this.$refs.upload.clearFiles()
+        this.$refs.form.resetFields()
+      })
+    },
+    onFileChange (event) {
+      this.uploadData.file = event.raw
+      const uploadEl = this.$refs.upload
+      const { uploadFiles } = uploadEl
+      uploadFiles.splice(0, uploadFiles.length, event)
+    },
+    onImportDataBtnClick () {
+      this.$refs.form.validate(flag => {
+        if (!flag) {
+          return
+        }
+
+        this.$$request(this.$$api.importData, this.uploadData).then((data) => {
+          if (typeof data === 'number') {
+            this.$notify({
+              title: '成功',
+              message: `成功导入重打印标签 ${data}个`,
+              type: 'success',
+              position: 'bottom-right'
+            })
+            this.close()
+          }
+        }).catch(console.error).finally(() => {})
+      })
+    },
+    close () {
+      this.$refs.upload.clearFiles()
+      this.uploadData.file = null
+      this.visible = false
+    },
+    onCloseBtnClick () {
+      this.close()
+    }
+  }
+}
+</script>
+
+  <style lang="scss"></style>

+ 1 - 1
src/components/DialogTagDistributeDetail.vue

@@ -145,7 +145,7 @@
                 header-align="center"
               ></el-table-column>
               <el-table-column
-                v-if="oData.tagApplyStateId === '5'"
+                v-if=" oData && oData.tagApplyStateId === '5'"
                 label="操作栏"
                 min-width="100"
                 header-align="center"

+ 12 - 0
src/views/TagDistribute.vue

@@ -24,6 +24,11 @@
           </el-form-item>
         </el-col>
             <el-col :span="8" class="text-right">
+              <el-button
+                type="primary"
+                class="filter-button"
+                @click="onImportRePrintBtnClick"
+              >重打导入</el-button>
               <el-button
                 plain
                 class="filter-button"
@@ -140,6 +145,10 @@
       :optionGroup1="optionGroup"
       @saveDistribute="onsaveDistribute"
     ></dialog-tag-distribute-operate>
+
+    <dialog-import-reprint
+      ref="dialogImportRePrint"
+    ></dialog-import-reprint>
     </div>
   </template>
 
@@ -165,6 +174,9 @@ export default {
     },
     onsaveDistribute () {
       this.loadList()
+    },
+    onImportRePrintBtnClick () {
+      this.$refs.dialogImportRePrint.open()
     }
   }
 }

+ 15 - 0
src/views/TagNullify.vue

@@ -64,6 +64,13 @@
                 header-align="center"
                 align="center"
               ></el-table-column>
+              <el-table-column
+                label="作废类型"
+                prop="status"
+                header-align="center"
+                align="center"
+                :formatter="formatStatus"
+              ></el-table-column>
               <el-table-column
                 label="作废时间"
                 prop="cTime"
@@ -100,6 +107,14 @@ export default {
     },
     onSaveTagCancel () {
       this.loadList()
+    },
+    formatStatus (row, column, cellValue, index) {
+      if (cellValue === '0') {
+        return '手动作废'
+      } else if (cellValue === '1') {
+        return '重打作废'
+      }
+      return '未知作废类型'
     }
   }
 }