deviceInventory.vue 13.6 KB
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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
<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-select v-model="formInline.devTypeId" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option v-for="item in deviceTypeList" :key="item.id" :value="item.id" :label="item.name">{{item.name}}</el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="请输入">
          <el-input v-model="formInline.searchKey" placeholder="请输入ICCID、IMEI、订单号、SN" style="width:250px" clearable/>
        </el-form-item>
        <el-form-item label="状态">
          <el-select v-model="formInline.status" placeholder="请选择">
            <el-option value="" label="全部">全部</el-option>
            <el-option value="IN" label="入库">入库</el-option>
            <el-option value="OUT" label="出库">出库</el-option>
          </el-select>
        </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-download" :loading="exportLoading" @click="exportInfo()">导出</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="iccid" label="ICCID" :width="tdWidth" />
          <el-table-column prop="imei" label="IMEI" :width="tdWidth" />
          <el-table-column prop="sn" label="SN" :width="tdWidth" />
          <el-table-column prop="attribCode" label="物料编码" :width="tdWidth" />
          <el-table-column prop="model" label="设备型号" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.devMnumName }}</template>
          </el-table-column>
          <el-table-column prop="batch" label="是否联网" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.orNetName }}</template>
          </el-table-column>
          <!-- <el-table-column prop="vcode" label="卡类型" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.cardSelfName }}</template>
          </el-table-column>
          <el-table-column prop="logisticsNo" label="是否带屏" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.screenName }}</template>
          </el-table-column>
          <el-table-column prop="attribMana" label="有源/无源" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.sourceName }}</template>
          </el-table-column>
          <el-table-column prop="typeName" label="机型" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.typeName }}</template>
          </el-table-column>
          <el-table-column prop="factoryName" label="裸机/整机" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.modelName }}</template>
          </el-table-column>
          <el-table-column prop="factoryName" label="配置" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.configureName }}</template>
          </el-table-column>
          <el-table-column prop="factoryName" label="尺寸" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.msizeName }}</template>
          </el-table-column>
          <el-table-column prop="factoryName" label="主板版本号" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.boardVersion }}</template>
          </el-table-column>
          <el-table-column prop="factoryName" label="软件版本号" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.attribMana.softVersion }}</template>
          </el-table-column> -->
          <el-table-column prop="batch" label="设备批次号" :width="tdWidth" />
          <el-table-column prop="status" label="状态" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.status == 'OUT'?'出库':'入库' }}</template>
          </el-table-column>
          <el-table-column prop="imei" label="入库工厂" :width="tdWidth">
            <template slot-scope="scoped">{{ scoped.row.wareHouseInfo.wareHouseName }}</template>
          </el-table-column>
          <el-table-column prop="imei" label="当前所在工厂/仓库" :width="tdWidth">
          <template slot-scope="scoped">{{ scoped.row.wareHouseInfo.wareHouseUpName }}</template>
          </el-table-column>
          <el-table-column prop="createdDate" label="入库时间" :width="tdWidth">
            <template slot-scope="scoped">{{ DATEFORMATE(scoped.row.createdDate,'YYYY-MM-DD HH:mm:ss') }}</template>
          </el-table-column>
          <el-table-column prop="updatedDate" label="出库时间" :width="tdWidth">
            <template slot-scope="scoped" v-if="scoped.row.status == 'OUT'">{{ DATEFORMATE(scoped.row.updatedDate,'YYYY-MM-DD HH:mm:ss') }}</template>
          </el-table-column>
          <el-table-column prop="orderCode" label="出库发货单号" :width="tdWidth" />
          <el-table-column label="操作" fixed="right" align="center">
            <template slot-scope="scope">
              <!-- <el-link type="primary" :underline="false" v-if="scope.row.status == 'IN'" @click="editEvent(scope.row)">修改</el-link> -->
              <el-button type="primary" size="mini" v-if="scope.row.status == 'IN'" @click="editEvent(scope.row)">修改</el-button>
            </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 -->
    
    <edit-inventory :deviceInfo="current" v-if="editShow" :show="editShow" @closed="closeDialog"/>

    <!-- 弹框 开始 -->
    <glsx-dialog :show="showDialog" title="导入设备" width="30%" usefooter @closed="closeImportDialog">
      <div class="upload_box">
        <h2 class="h2">
          请点击"
          <a :href="DOWNLOADEQUIPMENTDETAILSTEMPLATE" target="_blank">设备明细导入模板下载</a>", 并填写导入信息
        </h2>
        <div class="upload_cell">
          <span class="name">导入设备:</span>
          <div class="content">
            <el-input type="text" class="a_input" :value="uploadFile.name" readonly />
            <el-upload
              class="upload-demo"
              ref="upload"
              :action="IMPORTEQUIPMENTDETAILSCHECK"
              :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">选择文件</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 config from '@/http/config.js' // 倒入默认配置
import {
  GETLISTDEVICEINFO,
  GETDEVICETYPE,
  DOWNLOADEQUIPMENTDETAILSTEMPLATE,
  IMPORTEQUIPMENTDETAILSCHECK,
  IMPORTEQUIPMENTDETAILS,
} from '@/http/interface'
import {
  exportExcel,
} from '@/common/common'
import EditInventory from './editInventory'
import GlsxDialog from '@/components/dialog/index'
export default {
  name: 'fimsTable3',
  components: {
    'edit-inventory': EditInventory,
    '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, type) => { return this.$Util.dateFormate(str, type) },
      deviceTypeList: [],
      exportLoading: false,
      editShow:false,
      showDialog:false,
      current:{},
      uploadFile:{},
      DOWNLOADEQUIPMENTDETAILSTEMPLATE: DOWNLOADEQUIPMENTDETAILSTEMPLATE,
      IMPORTEQUIPMENTDETAILSCHECK:IMPORTEQUIPMENTDETAILSCHECK,
      uploadError:{},
      exportLoading: false
    }
  },
  created() {

  },

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

    /**
       * 查询列表
       */
    getList: function(current) {
      const _this = this
      const oParams = _this.getParams()
      console.log(current)
      oParams.pageNum = current || _this.currentPage
      _this.tableLoading = true
      GETLISTDEVICEINFO(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 oParams = this.formInline

      if (oParams.searchKey) {
        oParams.iccid = oParams.searchKey
        oParams.imei = oParams.searchKey
        oParams.orderCode = oParams.searchKey
        oParams.sn = oParams.searchKey
      } else {
        delete oParams.iccid
        delete oParams.imei
        delete oParams.orderCode
        delete oParams.sn
      }

      oParams.pageSize = this.pageSize
      return oParams
    },


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

    /**
     * 获取设备类型列表
     */
    getDeviceList: function() {
      let _this = this
      GETDEVICETYPE().then(res => {
        const { data } = res
        _this.deviceTypeList = data || []

      })
    },

    /**
     * 关闭弹框
     */
    closeDialog:function(){
      this.editShow = false;
    },

    /**
     * 修改
     */
    editEvent:function(row){
      this.editShow = true;
      this.current = row;
    },

    /**入库 */
    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 jsonO = JSON.parse(o);
      let oParams = {'deviceInfoImportList' : jsonO}
      this.exportLoading = true
      IMPORTEQUIPMENTDETAILS(oParams).then(res => {
        this.exportLoading = false
        if (res.returnCode == 0){
            this.$Util.Info({
            message: "成功导入 "+ res.data +" 数据!",
            type: "success"
          });
          this.closeImportDialog()
          this.getList() 
        }else{
          this.$Util.Info({
            message: "导入失败!",
            type: "error"
          });
        }
      })
    },

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

    /**
     * 导出列表
     */
    exportInfo: function(){
      const _this = this
      const _data = _this.getParams()
      const params = {'fileName':'设备库存列表'}
      params.url = config.baseURL + "/deviceInfo/exportExit"
      params.data = _data
      params.success = function(){
        _this.exportLoading = false
      }
      _this.exportLoading = true
      exportExcel(params)
    },

  }

}
</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: 80px;
    font-weight: bold;
  }
  .content {
    flex: 1;
    display: flex;
    .a_input {
      margin: 0 8px 0 0;
      width:217px;
    }
  }
}
</style>