schangxiang@126.com
2025-09-19 9be9c3784b2881a3fa25e93ae2033dc2803c0ed0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
 
<template>
  <div ref="container" class="page-list-container">
    <!--数据Table-->
    <yrt-data-list :ref="dataListRef" :editor-ref="editorRef" :data-options="dataOptions" :fields.sync="dataListOptions.fields" :buttons="dataListOptions.buttons" :button-click="buttonClick" :data-list-selections.sync="dataListSelections" :auth-nodes="authNodes">
 
    </yrt-data-list>
    <!--数据编辑器Editor-->
    <yrt-editor :ref="editorRef" :data-list-ref="dataListRef" v-bind="editorOptions" :data-options="dataOptions" :action.sync="editorOptions.action" :top.sync="editorOptions.top" :visible.sync="editorOptions.config.visible" :detail-button-click="detailButtonClick" :auth-nodes="authNodes" :btn-read-only="btnReadOnly" :use-detail-slot="['SortingStatus']">
 
    </yrt-editor>
 
    <el-dialog v-dialogDrag :visible.sync="dialogLandingTime" class="import-dialog-container">
      <el-form>
        <el-upload ref="upload" :on-preview="handlePreview" :on-remove="handleRemove" :on-success="handleSuccess" :file-list="fileList" :auto-upload="true" :action="upLoadUrl()" :limit="1" class="upload-bill">
          <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
          <el-button style="margin-left: 10px;" size="small" type="success" @click="submitImport()">开始导入</el-button>
          <el-button style="margin-left: 10px;" size="small" type="primary" plain>
            <a :href="common.ossDomain+'/node-wms/template/面单导入模板.xlsx'" style="color:while;font-size:12px;">下载模板</a>
          </el-button>
          <div slot="tip" class="el-upload__tip">只能上传扩展名为.xlsx的excel文件</div>
        </el-upload>
      </el-form>
      <el-scrollbar ref="scrollbar" :noresize="false" :native="false" wrap-class="scrollbar-wrap">
        <ul class="msg-container">
          <li v-for="(item, index) in msgList" :key="index" class="msg-item" v-html="item">
            {{ index + 1 }}、{{ item }}
          </li>
        </ul>
      </el-scrollbar>
      <div ref="loading"></div>
      <!-- <div slot="footer" class="dialog-footer"> -->
      <!-- <el-button type="primary" @click="EditlogLandingTimesave">确 定</el-button> -->
      <!-- </div> -->
    </el-dialog>
  </div>
</template>
<script>
import baseLayout from "@/components/common/base-layout.vue";
import yrtSelector from "@/components/common/yrtSelector.vue";
import stateFlow from "@/components/common/components/stateflow.vue";
import detailstateFlow from "@/components/common/components/detailstateflow.vue";
 
export default {
  name: "tms-way-billother",
 
  components: {
    yrtSelector,
    stateFlow,
    detailstateFlow
  },
  mixins: [baseLayout],
  // 自定义处理权限函数
  doAuth(the) {
    // 判断当前版本是否拥有导入权限
    var authList = [
      { name: "面单数据导入", auth: "allImport" }
      // { name: "打印预到货单", auth: "print" }
    ];
    const names = authList.map(item => {
      return item.name;
    });
    the.common.isSaaSAuth(names, res => {
      authList.forEach(node => {
        let hasAuth = res.result;
        if (hasAuth) {
          hasAuth = res.data.some(item => {
            return item.moduleName === node.name;
          });
        }
        the.authNodes[node.auth] = hasAuth;
      });
    });
  },
  data() {
    return {
      // 弹出导入框
      dialogLandingTime: false,
      fileList: [],
      // 消息内容
      msgList: [],
      // 导入获得消息interval handle
      intervalHandler: null,
      // 导入key
      uploadKey: null
    };
  },
  mounted() {
    this.uploadKey = this.common.getGUID();
  },
  methods: {
    // 点击文件时的钩子
    handlePreview(file) {},
    handleRemove(file, fileList) {
      this.fullFilePath = null;
    },
    // 上传附件Url
    upLoadUrl: function() {
      var domain = this.common.domain;
      // return domain + "/api/TMS_WayBillOther/UploadImport";
      return domain + "/api/common/uploadSingleFile";
    },
    // 上传成功后
    handleSuccess(res, file) {
      this.common.showMsg("上传成功!");
      this.fullFilePath = res.data.url;
    },
    // 列表页面按钮点击事件
    buttonClick(authNode) {
      switch (authNode) {
        case "myImport":
          // 批量导入
          this.allImport();
          return false;
      }
    },
    // 批量导入
    allImport() {
      this.msgList = [];
      this.dialogLandingTime = true;
    },
    // 导入
    submitImport() {
      this.msgList = [];
      if (!this.fullFilePath) {
        this.$message.error("请上传文件!");
        return;
      }
      const url = "/api/tMS/tMSWayBillOther/importExcel";
      const params = {
        url: this.fullFilePath,
        // StorageName: StorageName
        key: this.uploadKey
      };
      var callback = res => {
        if (res.result) {
          window.clearTimeout(this.intervalHandler);
          this.intervalHandler = false;
          this.getMsg();
          this.fileList = [];
          this.fullFilePath = null;
        }
      };
      this.common.ajax(url, params, callback, true);
    },
    // 获得导入消息
    getMsg() {
      // 获得同步消息
      const url = "/api/common/getUploadMsg";
      const params = {
        openNodeApi: true,
        key: this.uploadKey
      };
      // const ref = this.dataList;
      var callBack = res => {
        // 自动滚动到最后一行
        window.setTimeout(() => {
          const div = this.$refs.scrollbar.$refs.wrap;
          div.scrollTop = div.scrollHeight + 1000;
        }, 1500);
        if (!res.result) {
          window.clearTimeout(this.intervalHandler);
          this.intervalHandler = false;
          if (Array.isArray(res.data)) {
            this.msgList = this.msgList.concat(res.data);
          }
          return;
        }
 
        if (Array.isArray(res.data)) {
          this.msgList = this.msgList.concat(res.data.filter(item => item !== "-1"));
        }
        if (res.data.indexOf("-1") >= 0) {
          window.clearTimeout(this.intervalHandler);
          this.intervalHandler = null;
          return;
        }
        this.intervalHandler = window.setTimeout(this.getMsg, 1000);
      };
      this.common.ajax(url, params, callBack, this.$refs.loading);
    }
  }
};
</script>
 
<style lang="scss" scoped>
.page-list-container {
  min-height: calc(100vh - 110px);
  overflow: hidden;
  position: relative;
}
 
@media screen and (max-height: 900px) {
  .page-list-container {
    min-height: 600px;
  }
}
 
.import-dialog-container {
  .msg-container {
    margin: 0;
    padding: 0;
    .msg-item {
      margin: 0;
      padding: 5px 0;
      word-wrap: break-word;
    }
  }
  /deep/ .scrollbar-wrap {
    max-height: 400px !important;
    margin-top: 10px;
    font-size: 14px;
    .msg-container {
      margin: 0;
      padding: 0;
      .msg-item {
        margin: 0;
        padding: 5px 0;
        word-wrap: break-word;
      }
    }
  }
}
</style>