zss
2024-03-01 d3a486a2f3ae5e76b7bbf9e3d6a8c1e36ed73de7
src/views/basic/part/index.vue
@@ -12,7 +12,12 @@
        :ajaxFun="ajaxFun"
        ref="partTable"
      >
        <template #toolbar></template>
        <template #toolbar>
          <!-- <el-button type="primary" @click="addOrUpdateHandle"
          v-if="permissions.basic_part_add">新增</el-button> -->
          <!-- <el-button text="同步MDM" type="primary" @click=""
          v-if="permissions.basic_part_mdm">同步MDM</el-button> -->
        </template>
      </ttable>
      <!-- 弹窗, 新增 / 修改 -->
      <table-form
@@ -25,11 +30,36 @@
        :printLabelInfo="printLabelInfo"
      />
    </basic-container>
    <el-dialog title="选择同步日期" :visible.sync="syncDateVisible" width="21%">
      <div style="display: flex;justify-content: center">
        <el-form
          :model="dataForm"
          :inline="true"
          :rules="dataRule"
          ref="dataForm"
          class="l-mes"
        >
          <el-form-item label="日期" prop="selectTime">
            <el-date-picker
              v-model="dataForm.selectTime"
              type="datetime"
              placeholder="选择日期时间"
              value-format="yyyy-MM-dd HH:mm:ss"
            >
            </el-date-picker>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="syncDateVisible = false">取 消</el-button>
        <el-button type="primary" @click="syncIfs">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import { fetchList, delObj, syncIfs, syncPart } from '@/api/basic/part'
import { fetchList, delObj, syncPart } from '@/api/basic/part'
import TableForm from './part-form'
import { mapGetters } from 'vuex'
import ttable from '@/views/common/ztt-table.vue'
@@ -40,12 +70,23 @@
export default {
  data() {
    return {
      dataRule: {
        selectTime: [
          { required: true, message: '同步日期不能为空', trigger: 'change' }
        ]
      },
      dataForm: {
        selectTime: null
      },
      syncDateVisible: false,
      ajaxFun: fetchList,
      addOrUpdateVisible: false,
      multipleSelection: [],
      uploadInfo: {
        // 是否展示上传EXCEL以及对应的url
        isShow: true,
        download: true,
        fileName: '已申请物料编码模板',
        url: '/mes/part/upload'
      },
      prelang: 'operation',
@@ -59,7 +100,8 @@
        multiSelect: true, //
        seqNo: true,
        isShowHide: true, // 是否显示显影按钮
        isSearch: false, // 高级查询按钮
        isSearch: false, // 高级查询按钮,
        isRefresh: true, // 是否显示刷新按钮
        defaultOrderBy: { column: 'id', direction: 'desc' }
      },
      table: {
@@ -135,7 +177,7 @@
          {
            minWidth: '120',
            prop: 'sunit',
            label: '单位2',
            label: '重量单位',
            sort: true,
            isTrue: true,
            isSearch: true,
@@ -156,7 +198,7 @@
            searchInfoType: 'text'
          },
          // 一级分类
          {
           {
            minWidth: '120',
            prop: 'assortment',
            label: '一级分类',
@@ -205,7 +247,7 @@
            searchInfoType: 'text'
          },
          // 型号
          {
          /* {
            minWidth: '140',
            prop: 'partModel',
            label: '型号',
@@ -267,7 +309,7 @@
            optList: () => {
              return this.lotTrackingIfsOptions
            }
          },
          }, */
          // 版本号
          {
            minWidth: '140',
@@ -277,7 +319,7 @@
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          }/* ,
          // 计划方法
          {
            minWidth: '140',
@@ -291,9 +333,9 @@
            optList: () => {
              return this.planningMethodOptions
            }
          },
          }, */
          // 图号
          {
         /*  {
            minWidth: '140',
            prop: 'drawingNumber',
            label: '图号',
@@ -321,9 +363,9 @@
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          },
          }, */
          // 检验员
          {
          /* {
            minWidth: '140',
            prop: 'examiner',
            label: '检验员',
@@ -354,35 +396,17 @@
            isTrue: true,
            isSearch: true,
            searchInfoType: 'text'
          }
          } */
        ],
        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.printLabel,
          //   loading: false
          // }
        ],
        operator: [
          {
            text: '删除',
            type: 'text',
            size: 'small',
            fun: this.deleteHandle
          }
        ],
        operator: null,
        operatorConfig: {
          fixed: 'right',
          label: '操作',
@@ -412,16 +436,39 @@
    PrintLabelForm
  },
  created() {
if(this.permissions.basic_part_mdm){
        this.table.toolbar.push(
          {
            text: '同步MDM',
            type: 'primary',
            fun: () => this.syncDateVisible = true,
            loading: false
          }
        )
    }
    if(this.permissions.basic_part_del){
      this.table.operator = [
          {
            text: '删除',
            type: 'text',
            size: 'small',
            fun: this.deleteHandle
          }
        ]
    }
    this.uploadInfo.isShow = this.permissions.basic_part_upload
    this.table.column.find((e) => e.label === 'IFS启用批次管理').isTrue = false
    this.table.column.find((e) => e.label === '计划方法').isTrue = false
    this.getUnitType('unit')
    this.getMaterialType('material_type')
    this.getCategoryType('category')
    this.getAssortmentType('assortment')
    this.getPlanningMethodType('planning_method_type')
    this.getThreeLevelClassificationType('three_classification_type')
    this.getMaterialAttributeType()
    this.getExaminerDict('examiner_type')
  },
  mounted(){
    this.getUnitType('unit')
    this.getMaterialType('material_type')
    this.getMaterialAttributeType()
  },
  computed: {
    ...mapGetters(['permissions'])
@@ -433,6 +480,10 @@
    },
    // 新增 / 修改
    addOrUpdateHandle(row) {
      if(!this.permissions.basic_part_edit && row.id!=null){
        this.$message.error("该角色没有操作权限")
        return
      }
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(row == null ? null : row.id)
@@ -628,18 +679,28 @@
    //   }
    // },
    syncIfs() {
      syncPart({})
        .then((res) => {
          const data = res.data
          if (data.code === 0) {
            this.$message.success('开始同步')
          } else {
            this.$message.error('同步ERP失败')
          }
        })
        .catch((e) => {
          // this.$message.error('同步ERP失败:' + e)
        })
      this.$refs.dataForm.validate((valid) => {
        if (valid) {
          this.syncDateVisible = false
          this.table.toolbar.find((e) => e.text === '同步MDM').loading = true
          syncPart({ updateTime: this.dataForm.selectTime })
            .then((res) => {
              const data = res.data
              if (data.code === 0) {
                this.$message.success(data.msg)
              } else {
                this.$message.error('同步MDM失败')
              }
              this.getData()
              this.table.toolbar.find(
                (e) => e.text === '同步MDM'
              ).loading = false
            })
            .catch((e) => {
              this.$message.error('同步MDM失败:' + e)
            })
        }
      })
    },
    printLabel() {
      if (this.multipleSelection && this.multipleSelection.length > 0) {
@@ -677,6 +738,13 @@
        this.$message.error('请选择零件')
      }
    }
  },
  watch: {
    syncDateVisible(newVal) {
      if (!newVal) {
        this.$refs.dataForm.resetFields()
      }
    }
  }
}
</script>