Fixiaobai
2023-11-09 45e7495fe17c3b390a6d0e2461f0b8f965d46f6f
src/views/basic/part/index.vue
@@ -1,30 +1,33 @@
<template>
  <div class="mod-config">
    <basic-container>
      <ttable
        :table="table"
        @handleSelectionChange="handleSelectionChange"
        :uploadInfo="uploadInfo"
        :isShowHide="true"
        :prelang="prelang"
        :options="options"
        :bottomOffset="125"
        :ajaxFun="ajaxFun"
        ref="partTable"
      >
      <ttable :table="table" @handleSelectionChange="handleSelectionChange" :uploadInfo="uploadInfo" :isShowHide="true"
        :prelang="prelang" :options="options" :bottomOffset="125" :ajaxFun="ajaxFun" ref="partTable">
        <template #toolbar></template>
      </ttable>
      <!-- <el-upload :headers="{'Authorization': 'Bearer ' + yourToken}" class="upload-demo" action="/mes/part/uploadExcel" :on-preview="handlePreview"
        :on-remove="handleRemove" :file-list="fileList" :on-success="fileUpload"  :limit="1">
        <el-button size="small" type="primary">点击Excel导入</el-button>
      </el-upload> -->
      <!-- 弹窗, 新增 / 修改 -->
      <table-form
        v-if="addOrUpdateVisible"
        ref="addOrUpdate"
        @refreshDataList="getData"
      ></table-form>
      <PrintLabelForm
        :currshowlist.sync="showPrintLabelForm"
        :printLabelInfo="printLabelInfo"
      />
      <table-form v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getData"></table-form>
      <PrintLabelForm :currshowlist.sync="showPrintLabelForm" :printLabelInfo="printLabelInfo" />
    </basic-container>
    <el-dialog title="获取IFS零件" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
      <el-row>
        <el-col :span="6" style="height: 40px;line-height: 30px;">
          同步日期:
        </el-col>
        <el-col :span="18">
          <el-date-picker style="width: 100%;height: 100%;" v-model="selectDate" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取 消</el-button>
        <el-button type="primary" @click="syncIfs">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
@@ -34,19 +37,22 @@
import { mapGetters } from 'vuex'
import ttable from '@/views/common/ztt-table.vue'
import { remote } from '../../../api/admin/dict'
import { dateFormat } from '@/util/date'
import { dateFormat, dateFormatYearMonthDate, dateFormatPlus } from '@/util/date'
import PrintLabelForm from './print-label-form.vue'
export default {
  data() {
    return {
      fileList: [],
      selectDate: "",
      dialogVisible: false,
      ajaxFun: fetchList,
      addOrUpdateVisible: false,
      multipleSelection: [],
      yourToken: "",
      uploadInfo: {
        // 是否展示上传EXCEL以及对应的url
        isShow: true,
        url: '/mes/part/upload'
        url: '/mes/part/uploadExcel'
      },
      prelang: 'operation',
      options: {
@@ -60,6 +66,7 @@
        seqNo: true,
        isShowHide: true, // 是否显示显影按钮
        isSearch: false, // 高级查询按钮
        isRefresh: true,
        defaultOrderBy: { column: 'id', direction: 'desc' }
      },
      table: {
@@ -357,23 +364,29 @@
          }
        ],
        toolbar: [
          {
            text: '新增',
            type: 'primary',
            fun: this.addOrUpdateHandle
          },
          {
            text: '同步ERP',
            type: 'primary',
            fun: this.syncIfs,
            loading: false
          },
          {
            text: '大标签',
            type: 'primary',
            fun: this.printLabel,
            loading: false
          }
          // {
          //   text: '新增',
          //   type: 'primary',
          //   fun: this.addOrUpdateHandle
          // },
          // {
          //   text: '获取IFS零件',
          //   type: 'primary',
          //   fun: this.syncISDate,
          //   loading: false
          // },
          // {
          //   text: '大标签',
          //   type: 'primary',
          //   fun: this.printLabel,
          //   loading: false
          // },
          // {
          //   text: 'Excel导入',
          //   type: 'primary',
          //   fun: this.uploadPartExcel,
          //   loading: false
          // },
        ],
        operator: [
          {
@@ -412,6 +425,8 @@
    PrintLabelForm
  },
  created() {
    let token=JSON.parse(sessionStorage.getItem("ztt-access_token")).content
    this.yourToken=token
    this.table.column.find((e) => e.label === 'IFS启用批次管理').isTrue = false
    this.table.column.find((e) => e.label === '计划方法').isTrue = false
    this.getUnitType('unit')
@@ -427,6 +442,20 @@
    ...mapGetters(['permissions'])
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
    },
    fileUpload(){
      this.$message.success('后台正在导入中,请稍后刷新!')
      this.fileList=[]
    },
    handleClose() {
      this.selectDate = "";
      this.dialogVisible = false
    },
    // 获取数据列表
    getData() {
      this.$refs.partTable.getDataList()
@@ -446,7 +475,7 @@
        closeOnClickModal: false,
        type: 'warning'
      })
        .then(function() {
        .then(function () {
          return delObj(row.id)
        })
        .then((data) => {
@@ -627,19 +656,60 @@
    //     this.$message.warning('请先选择零件,再进行同步!')
    //   }
    // },
    syncISDate() {
      this.dialogVisible = true
      this.selectDate = ''
    },
    dateFormat(longTypeDate) {
      var dateTypeDate = "";
      var date = new Date();
      date.setTime(longTypeDate);
      dateTypeDate += date.getFullYear();   //年
      dateTypeDate += "-" + getMonth(date); //月
      dateTypeDate += "-" + getDay(date);   //日
      return dateTypeDate;
    },
    syncIfs() {
      syncPart({})
      this.table.toolbar.find((e) => e.text === '获取IFS零件').loading = true
      this.dialogVisible = false
      let datas = new FormData()
      let times = null;
      if (this.selectDate != '' && this.selectDate != null) {
        times = dateFormatPlus(this.selectDate)
      } else {
        times = null
      }
      datas.set("date", times)
      // console.log(datas.get("date"));
      // return ;np
      // console.log(datas.get("date"));
      // console.log(this.selectDate);
      // return
      syncPart(datas)
        .then((res) => {
          const data = res.data
          console.log(data);
          if (data.code === 0) {
            this.$message.success('开始同步')
            if (data.data > 0) {
              this.$message.success('同步成功' + data.data + "条数据")
            }
            if (data.data < 1) {
              this.$message.warning("该日期没有新的零件数据");
            }
            this.table.toolbar.find((e) => e.text === '获取IFS零件').loading = false
            this.getData()
          } else {
            this.$message.error('同步ERP失败')
            this.$message.error('同步IFS失败')
            this.table.toolbar.find((e) => e.text === '获取IFS零件').loading = false
            this.getData()
          }
        })
        .catch((e) => {
          // this.$message.error('同步ERP失败:' + e)
        })
    },
    uploadPartExcel() {
    },
    printLabel() {
      if (this.multipleSelection && this.multipleSelection.length > 0) {
@@ -680,3 +750,8 @@
  }
}
</script>
<style>
.el-upload-dragger {
  width: 300px !important;
}
</style>