outManage.vue 10.6 KB
<template>
  <d2-container>
    <el-card shadow="never" slot="header">
      <el-form :inline="true" :model="formInline" class="demo-form-inline" size="small">

        <el-form-item label="发货单号">
          <el-input v-model="formInline.orderCode" placeholder="请输入发货单号" clearable/>
        </el-form-item>
        <el-form-item label="SN">
          <el-input v-model="formInline.sn" placeholder="请输入SN" clearable/>
        </el-form-item>
        <el-form-item label="操作标记">
          <el-input v-model="formInline.seedTag" placeholder="请输入操作标记" clearable/>
        </el-form-item>
        <el-form-item label="处理状态">
          <el-select v-model="formInline.result" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option value="UN" label="正在处理">正在处理</el-option>
            <el-option value="FA" label="处理失败">处理失败</el-option>
            <el-option value="SU" label="处理成功">处理成功</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="导入时间">
          <el-date-picker
            v-model="registerDate"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item label="发货时间">
          <el-date-picker
            v-model="sendTime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="yyyy-MM-dd"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" :loading="tableLoading" @click="getList()">搜索</el-button>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-upload2" @click="openDialog">导入</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 表格区域 开始 -->
    <div class="table_box">
        <el-table v-loading="tableLoading" :data="tableData" stripe style="width: 100%" size="small" border>
          <el-table-column type="index" :index="index => {return index+1}" label="序号" width="80" />
          <el-table-column prop="orderCode" label="发货单号" :width="tdWidth" />
          <el-table-column prop="simCardNo" label="SIM卡手机号码" :width="tdWidth" />
          <el-table-column prop="iccid" label="ICCID" :width="tdWidth" />
          <el-table-column prop="imsi" label="IMSI" :width="tdWidth" />
          <el-table-column prop="imei" label="IMEI" :width="tdWidth" />
          <el-table-column prop="sn" label="SN" :width="tdWidth" />
          <el-table-column prop="model" label="设备型号" :width="tdWidth" />
          <el-table-column prop="batch" label="批次号" :width="tdWidth" />
          <el-table-column prop="vcode" label="验证码" :width="tdWidth" />
          <el-table-column prop="logisticsCpy" label="物流公司" :width="tdWidth" />
          <el-table-column prop="logisticsNo" label="物流单号" :width="tdWidth" />
          <el-table-column prop="factoryName" label="工厂" :width="tdWidth" />
          <el-table-column prop="seedTag" label="操作标记" :width="tdWidth" />
          <el-table-column prop="result" label="处理状态" :width="tdWidth" >
             <template slot-scope="scoped">
              {{resultShow[scoped.row.result]}}
            </template>
          </el-table-column>
          <el-table-column prop="resultDesc" label="处理描述" :width="tdWidth" />
          <el-table-column prop="sendTime" label="发货时间" :width="tdWidth" />
          <el-table-column prop="createdDate" label="导入时间" :width="tdWidth" fixed="right">
            <template slot-scope="scoped">{{ DATEFORMATE(scoped.row.createdDate) }}</template>
          </el-table-column>
        </el-table>
        <div class="pagination_list">
          <el-pagination
            background
            layout="sizes, total,prev, pager, next, jumper"
            :total="pageTotal"
            :page-size="pageSize"
            :page-sizes="pageSizes"
            @current-change="getList"
            @size-change="changePageSize"
          />
        </div>
    </div>
    <!-- 表格区域 end -->

    <!-- 弹框 开始 -->
    <glsx-dialog :show="showDialog" title="导入设备" width="30%" usefooter @closed="closeImportDialog">
      <div class="upload_box">
        <h2 class="h2">
          请点击"
          <a :href="GPSDEVICEDOWNLOADTEMPLATE" target="_blank">下载GPS出库模板</a>", 并填写导入信息
        </h2>
        <div class="upload_cell">
          <span class="name">导入GPS出库模板:</span>
          <div class="content">
            <el-input type="text" class="a_input" :value="uploadFile.name" readonly />
            <el-upload
              class="upload-demo"
              ref="upload"
              :action="PREGPSDEVICEIMPORTCHECK"
              :limit="1"
              :data="uploadForm"
              :on-exceed="handleExceed"
              :file-list="fileList"
              :show-file-list="false"
              :on-change="uploadChange"
              :on-success="uploadSuccess"
            >
              <el-button size="small" type="primary" :loading="checkLoading">选择文件</el-button>
            </el-upload>
          </div>
        </div>
        <div class="upload_cell cell_center" v-if="uploadError.totalCount || uploadError.totalCount==0">
          <span>检验成功{{uploadError.successCount}}条,失败{{uploadError.failCount}}条,</span>
          <span>请下载</span>
          <a :href="uploadError.url" target="_blank">导出失败列表</a>
        </div>
      </div>
      <div slot="footer" class="btn_group">
        <el-button type="success" icon="el-icon-upload2" :loading="exportLoading" @click="uploadInfoToServer">导入</el-button>
        <el-button @click="closeImportDialog">取消</el-button>
      </div>
    </glsx-dialog>
    <!-- 弹框 end -->

  </d2-container>
</template>

<script>
import {
  LISTDEVICEGPSPREIMPORT,
  GPSDEVICEDOWNLOADTEMPLATE,
  PREGPSDEVICEIMPORTCHECK,
  DEVICEIMPORT
} from '@/http/interface'
import GlsxDialog from '@/components/dialog/index'
export default {
  name: 'fimsTable6',
  components: {
    'glsx-dialog': GlsxDialog
  },
  data() {
    return {
      formInline: {},
      tableData: [],
      dialogVisible: false,
      tableLoading: false,
      pageTotal: 0,
      userInfo: {},
      currentPage: 1,
      pageSizes: [10, 20, 30, 40],
      pageSize: 10,
      registerDate: [],
      tdWidth: 170,
      DATEFORMATE: str => {return this.$Util.dateFormate(str)},
      resultShow: {
        'UN': '正在处理',
        'FA': '处理失败',
        'SU': '处理成功'
      },
      showDialog: false,
      current:{},
      uploadFile:{},
      GPSDEVICEDOWNLOADTEMPLATE: GPSDEVICEDOWNLOADTEMPLATE,
      PREGPSDEVICEIMPORTCHECK: PREGPSDEVICEIMPORTCHECK,
      uploadError:{},
      // checkLoading: false,
      exportLoading: false,
      sendTime:[]
    }
  },
  created() {

  },

  mounted: function() {
    this.getList()
  },
  methods: {

    /**
       * 查询列表
       */
    getList: function(current) {
      const _this = this
      const oParams = _this.getParams()
      console.log(current)
      oParams.pageNum = current || _this.currentPage
      _this.tableLoading = true
      LISTDEVICEGPSPREIMPORT(oParams).then(res => {
        console.log(res)
        _this.tableLoading = false
        if (res.returnCode == 0) {
          const { data } = res
          const { total, list } = data
          _this.tableData = list || []
          _this.pageTotal = total
        }
      })
    },

    /**
       * 获取查询参数
       */
    getParams: function() {
      const n = this.formInline
      const m = this.registerDate
      let b = this.sendTime
      const oParams = {}
      if (m && m.length > 0) {
        n.startDate = m[0]
        n.endDate = m[1]
      } else {
        delete this.formInline.startDate
        delete this.formInline.endDate
      }
      if (b && b.length > 0) {
        n.sendTimeStart = b[0]
        n.sendTimeEnd = b[1]
      } else {
        delete this.formInline.sendTimeStart
        delete this.formInline.sendTimeEnd
      }
      oParams.pageSize = this.pageSize
      oParams.condition = n
      return oParams
    },


    /**
     * 每页展示
     */
    changePageSize: function(e) {
      this.pageSize = e
      this.getList()
    },

    /**入库 */
    openDialog: function () {
      this.showDialog = true;
    },

    /**监听文件改变 */
    uploadChange: function (file, fileList) {
      console.log(file);
      this.uploadFile = file;
    },

    /**监听文件上传成功 */
    uploadSuccess:function(res, file, fileList){
      console.log(res);
      //this.$refs.upload.submit();
      let o = res.data || [];
      let m = o[0]||{};

      this.uploadError = m;
      this.fileInfo = m.msg;
      if (m.url) {
        this.$refs.upload.clearFiles()
        return false
      }
    },

    /**手动上传文件 */
    uploadInfoToServer:function(){
      let o = this.fileInfo;
      if(!o){
        this.$message({
          message: '请导入有效数据!',
          type: 'error',
          duration: 2000,
          center: true
        });
        return false;
      }
      let oParams = JSON.parse(o);
      this.exportLoading = true
      DEVICEIMPORT(oParams).then(res => {
        this.exportLoading = false
        if (res.returnCode == 0){
            this.$Util.Info({
            message: "成功导入数据!",
            type: "success"
          });
          this.$refs.upload.clearFiles()
          this.uploadFile = {}
          this.uploadError = {}
          this.showDialog = false
          this.getList() 
        }else{
          this.$Util.Info({
            message: "导入失败!",
            type: "error"
          });
        }
      })
    },

    /**
     * 关闭弹框
     */
    closeImportDialog:function(){
      this.$refs.upload.clearFiles()
      this.uploadFile = {}
      this.uploadError = {}
      this.showDialog = false
    },
  }

}
</script>

<style lang="scss">
  .table_box {
    margin: 20px 0;
  }

  .upload_box {
  .h2 {
    font-size: 14px;
    font-weight: normal;
    a {
      color: #337ab7;
    }
  }
}
.upload_cell {
  display: flex;
  align-items: center;
  margin:10px 0;
  .name {
    width: 130px;
    font-weight: bold;
  }
  .content {
    flex: 1;
    display: flex;
    .a_input {
      margin: 0 8px 0 0;
      width:217px;
    }
  }
}
</style>