Fixiaobai
2023-10-27 87ac437f65b5595c4f17c4474c525cf48623065c
	modified:   src/util/date.js
modified: src/views/basic/part/index.vue
已修改2个文件
99 ■■■■ 文件已修改
src/util/date.js 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/basic/part/index.vue 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/util/date.js
@@ -84,3 +84,53 @@
  year = (year + '').substring(2, 4)
  return year + month
}
export function dateFormatPlus(longTypeDate) {
  var dateTypeDate = "";
  var date = new Date();
  date.setTime(longTypeDate);
  dateTypeDate += date.getFullYear();   //年
  dateTypeDate += "-" + getMonth(date); //月
  dateTypeDate += "-" + getDay(date);   //日
  return dateTypeDate;
}
//返回 01-12 的月份值
function getMonth(date) {
  var month = "";
  month = date.getMonth() + 1; //getMonth()得到的月份是0-11
  if (month < 10) {
      month = "0" + month;
  }
  return month;
}
//返回01-30的日期
function getDay(date) {
  var day = "";
  day = date.getDate();
  if (day < 10) {
      day = "0" + day;
  }
  return day;
}
function datetimeFormat(longTypeDate) {
  var dateTypeDate = "";
  var date = new Date();
  date.setTime(longTypeDate);
  dateTypeDate += date.getFullYear();   //年
  dateTypeDate += "-" + this.getMonth(date); //月
  dateTypeDate += "-" + this.getDay(date);   //日
  return dateTypeDate;
}
function format(d) {
  var y = d.getFullYear();
  var m = d.getMonth() + 1;
  if (m < 10) {
      m = "0" + m;
  }
  var day = d.getDate();
  if (day < 10) {
      day = "0" + day;
  }
  return y + "-" + m + "-" + day;
}
src/views/basic/part/index.vue
@@ -9,14 +9,14 @@
      <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-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-date-picker>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
@@ -33,13 +33,12 @@
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 {
      selectDate: null,
      selectDate: "",
      dialogVisible: false,
      ajaxFun: fetchList,
      addOrUpdateVisible: false,
@@ -428,8 +427,8 @@
    ...mapGetters(['permissions'])
  },
  methods: {
    handleClose() {
      this.selectDate=null;
    handleClose() {
      this.selectDate = "";
      this.dialogVisible = false
    },
    // 获取数据列表
@@ -634,15 +633,31 @@
    // },
    syncISDate() {
      this.dialogVisible = true
      this.selectDate=null
      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() {
      this.table.toolbar.find((e) => e.text === '同步IFS').loading = true
      this.table.toolbar.find((e) => e.text === '获取IFS零件').loading = true
      this.dialogVisible = false
      let datas=new FormData()
      datas.set("date",this.selectDate)
      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)
@@ -650,17 +665,17 @@
          const data = res.data
          console.log(data);
          if (data.code === 0) {
            if(data.data>0){
              this.$message.success('同步成功'+data.data+"条数据")
            if (data.data > 0) {
              this.$message.success('同步成功' + data.data + "条数据")
            }
            if(data.data<1){
            if (data.data < 1) {
              this.$message.warning("该日期没有新的零件数据");
            }
            this.table.toolbar.find((e) => e.text === '同步IFS').loading = false
            this.table.toolbar.find((e) => e.text === '获取IFS零件').loading = false
            this.getData()
          } else {
            this.$message.error('同步IFS失败')
            this.table.toolbar.find((e) => e.text === '同步IFS').loading = false
            this.table.toolbar.find((e) => e.text === '获取IFS零件').loading = false
            this.getData()
          }
        })