Fixiaobai
2023-10-25 0a11dd47059e28f8978c758e83c07b8d93c0f75b
src/views/basic/part/index.vue
@@ -1,30 +1,29 @@
<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>
      <!-- 弹窗, 新增 / 修改 -->
      <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>
@@ -40,6 +39,8 @@
export default {
  data() {
    return {
      selectDate: null,
      dialogVisible: false,
      ajaxFun: fetchList,
      addOrUpdateVisible: false,
      multipleSelection: [],
@@ -363,9 +364,9 @@
            fun: this.addOrUpdateHandle
          },
          {
            text: '同步ERP',
            text: '获取IFS零件',
            type: 'primary',
            fun: this.syncIfs,
            fun: this.syncISDate,
            loading: false
          },
          {
@@ -427,6 +428,10 @@
    ...mapGetters(['permissions'])
  },
  methods: {
    handleClose() {
      this.selectDate=null;
      this.dialogVisible = false
    },
    // 获取数据列表
    getData() {
      this.$refs.partTable.getDataList()
@@ -446,7 +451,7 @@
        closeOnClickModal: false,
        type: 'warning'
      })
        .then(function() {
        .then(function () {
          return delObj(row.id)
        })
        .then((data) => {
@@ -627,14 +632,36 @@
    //     this.$message.warning('请先选择零件,再进行同步!')
    //   }
    // },
    syncISDate() {
      this.dialogVisible = true
      this.selectDate=null
    },
    syncIfs() {
      syncPart({})
      this.table.toolbar.find((e) => e.text === '同步IFS').loading = true
      this.dialogVisible = false
      let datas=new FormData()
      datas.set("date",this.selectDate)
      // 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) => {