OrderPlanList.vue 6.9 KB
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- 操作按钮区域 -->
    <div class="table-operator" v-if="mainId">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('订单计划')">导出</a-button>
<!--      <a-upload-->
<!--        name="file"-->
<!--        :showUploadList="false"-->
<!--        :multiple="false"-->
<!--        :headers="tokenHeader"-->
<!--        :action="importExcelUrl"-->
<!--        @change="handleImportExcel">-->
<!--          <a-button type="primary" icon="import">导入</a-button>-->
<!--      </a-upload>-->

    </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"
        :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 v-if="record.status==0" slot="action" slot-scope="text, record">
          <a v-if="record" @click="handleEdit(record)">编辑</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a>删除</a>
          </a-popconfirm>
           <a-divider type="vertical" />
           <a @click="startOfproduction(record)">开始生产</a>

        </span>

      </a-table>
    </div>

    <orderPlan-modal ref="modalForm" @ok="modalFormOk" :mainId="mainId" :orderCode="orderCode" ></orderPlan-modal>
  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import OrderPlanModal from './modules/OrderPlanModal'
  import {creteScheduler} from '@/api/api'
  export default {
    name: "OrderPlanList",
    mixins:[JeecgListMixin],
    components: { OrderPlanModal },
    props:{
      mainId:{
        type:String,
        default:'',
        required:false
      },
      orderName:{
        type:String,
        default:'',
        required:false
      },
      orderCode:{
        type:String,
        default:'',
        required:false
      }
    },
    watch:{
      mainId:{
        immediate: true,
        handler(val) {
          if(!this.mainId){
            this.clearList()
          }else{
            this.queryParam['orderId'] = 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: 'orderNumber'
          },
          {
            title:'计划号',
            align:"center",
            dataIndex: 'planNumber'
          },
          {
            title:'客户名称',
            align:"center",
            dataIndex: 'productCode'
          },
          {
            title:'数量',
            align:"center",
            dataIndex: 'qty'
          },
          {
            title:'计划完成时间',
            align:"center",
            dataIndex: 'planTime'
          },
          {
            title:'实际完成时间',
            align:"center",
            dataIndex: 'completeTime'
          },
          {
            title:'状态',
            align:"center",
            dataIndex: 'status',
            customRender: function (text) {
              if (text === 0) {
                return "生产中"
              } else if (text === 1) {
                return "按时完成"
              } else if (text === 2) {
                return "超时完成"
              }
            }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/orders/orders/listOrderPlanByMainId",
          delete: "/orders/orders/deleteOrderPlan",
          deleteBatch: "/orders/orders/deleteBatchOrderPlan",
          exportXlsUrl: "/orders/orders/exportOrderPlan",
          importUrl: "/orders/orders/importOrderPlan",
        },
        dictOptions:{
        }
      }
    },
    created() {
    },
    computed: {
      importExcelUrl(){
        return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`;
      }
    },
    methods: {
      clearList(){
        this.dataSource=[]
        this.selectedRowKeys=[]
        this.ipagination.current = 1
      },
      startOfproduction(record){
        this.$confirm({
          title: '开始生产',
          content: (<div>
            <p>计划号: {record.planNumber} 确认开始生产吗?</p>

          </div>),
          centered: true,
          onOk: () => {
            let params = {
              'id': record.id,
              'productId':record.productId,
              'projectName':this.orderName,
              'planNumber':record.planNumber,
              'planTime':record.planTime,
              'productCode':record.productCode,
              'orderNumber':record.orderNumber,
              'orderId':record.orderId
            }
            creteScheduler(params).then((res) => {
              if (res.success) {
                this.$message.success(res.message)
              }else{
                this.$message.error(res.message)
              }

            })
          },
        })
      }

    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>