“linengliang”
2023-09-14 c887bb7836b82573c0bc7d11b8dd46b4d7e522e1
src/views/eam/modules/predictiveWorkOrder/ActualWorkHoursEditTable.vue
@@ -1,5 +1,8 @@
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
  <a-card
    :bordered="false"
    :class="'cust-erp-sub-tab'"
  >
  <a-table
         ref="table"
         bordered
@@ -21,21 +24,29 @@
               @search="onSearchUser(index)"
               :value="text"
               :read-only="true"
            :disabled="orderStatus!='4'"
               @change="(e) => handleChange(e, record.key, col, index)"
              />
             <a-input-number
               :value="text"
               v-if="col.dataIndex == 'actualHour'"
               :min="1"
            v-if="col.dataIndex == 'actualWorkingHourQuota'"
            :min="0"
               :max="99999"
               @change="(e)=>handleChange(e, record.key, col, index)"
               :disabled="record.disabled"
            :disabled="record.disabled||orderStatus!='4'"
             />
          
           </div>
         </template>
         <span slot='action' slot-scope='text, record,index'>
                 <a @click="handleDeleteFake(index)">删除</a>
      <span
        slot='action'
        slot-scope='text, record,index'
      >
        <a
          v-has="'specialtyMaintenanceOrder:actualWorkHoursDelete'"
          v-if="orderStatus=='4'"
          @click="handleDelete(index)"
        >删除</a>
        </span>
       </a-table>
       <a-button
@@ -43,7 +54,7 @@
         type="dashed"
         icon="plus"
         @click="addHour"
         :disabled="repairOrderStatus!='3'"
      :disabled="orderStatus!='4'"
       >添加实际工时
       </a-button>
       <div :style="{width: '100%',border: '1px solid #e9e9e9',padding: '10px 16px',background: '#fff',}">
@@ -51,20 +62,21 @@
         <a-button
           :style="{marginRight: '8px'}"
           @click="handleCancel"
           :disabled="repairOrderStatus!='3'"
         >
          清空
          取消
         </a-button>
         <a-button
            @click="handleOk(1)"
            type="primary"
            :style="{marginRight: '8px'}"
            :disabled="repairOrderStatus!='3'"
          :disabled="orderStatus!='4'"
          v-has="'specialtyMaintenanceOrder:actualWorkHoursTS'"
          >暂存</a-button>
          <a-button
          @click="handleOk(0)"
          type="primary"
          :disabled="repairOrderStatus!='3'"
          :disabled="orderStatus!='4'"
          v-has="'specialtyMaintenanceOrder:actualWorkHoursSave'"
          >保存</a-button>
       </a-row>
       <!-- :disabled="false" -->
@@ -90,20 +102,30 @@
    ActualHourUserSelect
  },
  props:{
    repairOrderId:{
    orderId: {
      type:String,
      required:false,
      default:''
    },
    repairOrderStatus:{
    orderStatus: {
      type:String,
      required:false,
      default:''
    }
    },
    equipmentId: {
      type: String,
      required: false,
      default: ''
    },
    teamId: {
      type: String,
      required: false,
      default: ''
    },
  },
  data() {
    return {
      title: "工艺确认",
      title: "实际工时",
      flag: false,//主页面的标记位  用于区分是否确认过工单工艺 来区分table页展示 工单工序 还是产品工序
      visible: false,
      model: {},
@@ -166,10 +188,10 @@
          },
          {
            title: '*实际工时',
            dataIndex: 'actualHour',
          dataIndex: 'actualWorkingHourQuota',
            align: "center",
            className: 'red',
            scopedSlots: { customRender: 'actualHour' },
          scopedSlots: { customRender: 'actualWorkingHourQuota' },
            width: 250,
          },
          {
@@ -181,22 +203,34 @@
          }
        ],
      url: {
        list: "/eam/repairOrder/listRepairOrderActualWorkHoursByMainId",
        confirmHour:"/eam/repairOrder/addRepairOrderActualWorkHours"
        list: "/eam/maintenanceOrderActualWorkingHour/getMaintenanceOrderActualWorkingHourList",
        confirmHour: "/eam/maintenanceOrderActualWorkingHour/add"
      },
      changeIndex: 0
    }
  },
  created(){
    this.queryParam['repairOrderId'] = this.repairOrderId;
    this.queryParam['maintenanceOrderId'] = this.orderId;
    this.queryParam['equipmentId'] = this.equipmentId
    this.loadData(1);
  },
  watch: {
    orderId: {
      immediate: true,
      handler(val) {
        this.clearList();
        this.queryParam['maintenanceOrderId'] = val
        this.queryParam['equipmentId'] = this.equipmentId
        this.loadData(1);
      }
    },
  },
  methods: {
    addHour() {
      this.dataSource.push({userId:'',repairOrderId:this.repairOrderId,actualHour:0,username:'',realname:''})
      this.dataSource.push({ id: this.getUuiD(16), userId: '', maintenanceOrderId: this.dailyMaintenanceOrderId, actualWorkingHourQuota: 0, username: '', realname: '' })
    },
    handleCancel() {
      this.close()
      this.$bus.$emit('closeDrawer');
    },
    close() {
      this.$emit('close');
@@ -204,9 +238,13 @@
      this.disableSubmit = false;
      this.visible = false;
    },
    handleDeleteFake(index){
      this.dataSource.pop(index);
    // handleDeleteFake(index) {
    //   this.dataSource.splice(index,1);
    // },
    handleDelete(text, record, index) {
      this.dataSource.splice(index, 1);
    },
    handleOk(saveStatus) {
      const that = this
      if(saveStatus==0){
@@ -216,18 +254,23 @@
            that.$message.warning("请选择第"+(i+1)+"行维修人员!");
            return false;
          }
          if(workHoursDataSource[i].actualHour == undefined || workHoursDataSource[i].actualHour == null||workHoursDataSource[i].actualHour==''){
          if (workHoursDataSource[i].actualWorkingHourQuota == undefined || workHoursDataSource[i].actualWorkingHourQuota == null || workHoursDataSource[i].actualWorkingHourQuota == '') {
            that.$message.warning("请填写第"+(i+1)+"行实际工时!");
            return false;
          }
        }
      }
      if (that.dataSource.length === 0) {
        that.$message.warning("请选择人员!")
        return
      }
      this.form.validateFields((err, values) => {
        if (!err) {
          that.confirmLoading = true
          let formData = {}
          formData.repairOrderId = that.repairOrderId;
          formData.actualHourList = that.dataSource;
          formData.maintenanceOrderId = that.orderId;
          formData.maintenanceOrderActualWorkingHourList = that.dataSource;
          formData.equipmentId = that.equipmentId;
          let obj = obj = postAction(this.url.confirmHour, formData)
          obj.then((res) => {
            if (res.success) {
@@ -253,15 +296,15 @@
        if ('userId' == column.dataIndex) {
          target['userId'] = value;
        }
        if ('actualHour' == column.dataIndex) {
          target['actualHour'] = value;
        if ('actualWorkingHourQuota' == column.dataIndex) {
          target['actualWorkingHourQuota'] = value;
        }
        that.dataSource = temp;
      }
    },
    onSearchUser(index) {
      this.recordIndex = index
      this.$refs.actualUserSelect.list()
      this.$refs.actualUserSelect.list(this.teamId)
      this.$refs.actualUserSelect.title = '人员选择'
    },
    sendUserRecord(data, val) {
@@ -279,18 +322,16 @@
    clearList(){
        this.dataSource=[];
        this.ipagination.current = 1
    }
  },
  watch:{
    repairOrderId:{
      immediate: true,
        handler(val) {
            this.clearList();
            this.queryParam['repairOrderId'] = val
            this.loadData(1);
        }
    }
  }
    getUuiD(randomLength) {
      return Number(
        Math.random()
          .toString()
          .substr(2, randomLength) + Date.now()
      ).toString(36)
    },
  },
}
</script>