WorkOrderDetailList.vue 11 KB
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 操作按钮区域 -->
    <div class="table-operator" v-if="mainId">

      <!-- 高级查询区域 -->
      <j-super-query :fieldList="superFieldList" ref="superQueryModal"
                     @handleSuperQuery="handleSuperQuery"></j-super-query>
      <a-button @click="submitToWarehouse" type="primary" icon="plus">生产领料</a-button>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        @expand="onExpand"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action2" slot-scope="text, record">
<!--          <a @click="sendWorkToT100(record)">编辑</a>-->

        </span>


        <!--        <a-table-->
        <!--          slot="expandedRowRender"-->
        <!--          slot-scope="text"-->
        <!--          :columns="innerColumns"-->
        <!--          :data-source="innerData"-->
        <!--          :pagination="false"-->
        <!--        >-->
        <!--          <span slot="action" slot-scope="text, record">-->
        <!--            <a v-if="record.status==null||record.status=='0'" @click="editDetail(record)">转委外</a>-->
        <!--               <a-divider type="vertical" v-if="record.status==null||record.status=='0'"/>-->
        <!--             <a v-if="record.status==null||record.status=='0'" @click="workForm(record)">报工</a>-->
        <!--              <a-divider type="vertical" v-if="record.status==null||record.status=='0'"/>-->
        <!--                        <a @click="sendReceiptToT100(record)">委外单推送测试</a>-->
        <!--                         <a-divider type="vertical"/>-->
        <!--                        <a @click="sendWorkToT100(record)">推送报工测试</a>-->
        <!--          </span>-->


        <!--        </a-table>-->

      </a-table>
    </div>

    <workOrderDetail-modal ref="modalForm" @ok="modalFormOk" :mainId="mainId"></workOrderDetail-modal>
    <report-work ref="workForm"></report-work>
    <submit-warehouse ref="submitFrom"></submit-warehouse>
  </a-card>
</template>

<script>


import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import WorkOrderDetailModal from './modules/WorkOrderDetailModal'
import reportWork from "./modules/reportWork";
import {querySonDetailList, sendWork, sendWwReceipt} from "../../api/schedulerApi";
import submitWarehouse from "./modules/submitWarehouse";

export default {
  name: "WorkOrderDetailList",
  mixins: [JeecgListMixin],
  components: {WorkOrderDetailModal, reportWork, submitWarehouse},
  props: {
    mainId: {
      type: String,
      default: '',
      required: false
    },
    workCode: {
      type: String,
      default: '',
      required: false
    },
    projectCode: {
      type: String,
      default: '',
      required: false
    }
  },
  watch: {
    mainId: {
      immediate: true,
      handler(val) {
        if (!this.mainId) {
          this.clearList()
        } else {
          this.queryParam['workOrderId'] = val
          this.loadData(1);
        }
      }
    }
  },
  data() {
    return {
      description: '工单头表管理页面',
      disableMixinCreated: true,
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '项次',
          align: "center",
          dataIndex: 'sfbaseq'
        },
        // {
        //   title: '上阶料号',
        //   align: "center",
        //   dataIndex: 'sfba001'
        // },
        {
          title: 'bom料号',
          align: "center",
          dataIndex: 'sfba005'
        },
        {
          title: 'bom名称',
          align: "center",
          dataIndex: 'bomName'
        },
        {
          title: '发料料号',
          align: "center",
          dataIndex: 'sfba006'
        },
        {
          title: '发料名称',
          align: "center",
          dataIndex: 'materielName'
        },
        {
          title: '规格',
          align: "center",
          dataIndex: 'spec'
        },
        {
          title: '重量',
          align: "center",
          dataIndex: 'weight'
        },
        {
          title: '长度',
          align: "center",
          dataIndex: 'length'
        },
        {
          title: '总应发数量',
          align: "center",
          dataIndex: 'sfba013'
        },
        {
          title: '已发数量',
          align: "center",
          dataIndex: 'yfsl'
        },
        {
          title: '单位',
          align: "center",
          dataIndex: 'sfba014'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: {customRender: 'action2'},
        }
      ],
      innerColumns: [
        {
          title: '#', dataIndex: '', key: 'rowIndex', width: 60, align: 'center', customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {title: '名称', align: 'center', dataIndex: 'name'},
        {title: '工艺', align: 'center', dataIndex: 'technologyName'},
        {title: '准备工时(分钟)', align: 'center', dataIndex: 'readyTime'},
        {title: '操作工时(分钟)', align: 'center', dataIndex: 'technologyTime'},
        {
          title: '状态', align: 'center', dataIndex: 'status', customRender: function (text) {
            if (text === 0) {
              return '生产中'
            } else if (text === 1) {
              return '按时完成'
            } else if (text === 2) {
              return '超时完成'
            }
          }
        },
        {title: '排序', align: 'center', dataIndex: 'sequence'},
        {title: '生产数量', align: 'center', dataIndex: 'qty'},
        {title: '完成数量', align: 'center', dataIndex: 'completeQty'},
        {title: '完成人', align: 'center', dataIndex: 'completeBy'},
        {title: '是否报工', align: 'center', dataIndex: 'enable'},
        {
          title: '完成时间', align: 'center', dataIndex: 'completeDate', customRender: function (text) {
            return !text ? '' : (text.length > 10 ? text.substr(0, 10) : text)
          }
        },
        {title: '延误原因', align: 'center', dataIndex: 'delayReason'},
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 300,
          scopedSlots: {customRender: 'action'}
        }
      ],
      innerData: [],
      url: {
        list: "/work_order/workOrder/listWorkOrderDetailByMainId",
        delete: "/work_order/workOrder/deleteWorkOrderDetail",
        deleteBatch: "/work_order/workOrder/deleteBatchWorkOrderDetail",
        exportXlsUrl: "/work_order/workOrder/exportWorkOrderDetail",
        importUrl: "/work_order/workOrder/importWorkOrderDetail",
      },
      dictOptions: {},
      superFieldList: [],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl() {
      return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`;
    }
  },
  methods: {
    submitToWarehouse() {
      if (this.selectedRowKeys.length < 1) {
        this.$message.warning('至少选择一条记录!');
        return false;
      }
      let ids = this.selectedRowKeys.join(",");
      this.$refs.submitFrom.edit(ids, this.workCode, this.projectCode);
    },
    clearList() {
      this.dataSource = []
      this.selectedRowKeys = []
      this.ipagination.current = 1
    },
    editDetail(record) {
      this.$refs.modalForm.edit(record);
    },
    workForm(record) {
      this.$refs.workForm.edit(record, this.workCode);
    },
    onExpand(expanded, record) {
      if (expanded) {
        let params = {
          'id': record.id
        }
        querySonDetailList(params).then((res) => {
          if (res.success) {
            this.innerData = res.result
          }
        })
        this.expandedRowKeys = []
        this.expandedRowKeys.push(record.id)
      } else {
        this.expandedRowKeys = []
      }
    },
    sendWorkToT100(record) {
      let params = {
        'id': record.id
      }
      sendWork(params).then((res) => {
        alert(JSON.stringify(res))
      })
    },
    sendReceiptToT100(record) {
      let params = {
        'id': record.id
      }
      sendWwReceipt(params).then((res) => {
        alert(JSON.stringify(res))
      })
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({type: 'string', value: 'sfaasite', text: '营运据点', dictCode: ''})
      fieldList.push({type: 'string', value: 'sfaadocno', text: '单号', dictCode: ''})
      fieldList.push({type: 'date', value: 'sfaadocdt', text: '单据日期'})
      fieldList.push({type: 'string', value: 'sfaa002', text: '生管人员', dictCode: ''})
      fieldList.push({type: 'string', value: 'sfaa003', text: '工单类型', dictCode: ''})
      fieldList.push({type: 'string', value: 'sfaa005', text: '工单来源', dictCode: ''})
      fieldList.push({type: 'string', value: 'sfaa010', text: '生产料号', dictCode: ''})
      fieldList.push({type: 'BigDecimal', value: 'sfaa012', text: '生产数量', dictCode: ''})
      fieldList.push({type: 'string', value: 'sfaa013', text: '生产单位', dictCode: ''})
      fieldList.push({type: 'date', value: 'sfaa019', text: '预计开工日'})
      fieldList.push({type: 'date', value: 'sfaa020', text: '预计完工日'})
      fieldList.push({type: 'string', value: 'sfaa028', text: '项目编号', dictCode: ''})
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less'
</style>