cuilei
2025-06-11 9488987332f2f4b8fa002a14f9717ed59e456852
工具管理-刀具准备单页面
已添加4个文件
1039 ■■■■■ 文件已修改
src/views/tms/PreparationOrderDetailList.vue 205 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tms/PreparationOrderList.vue 363 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tms/modules/preparationOrder/PreparationOrderDetailModal.vue 143 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tms/modules/preparationOrder/PreparationOrderModal.vue 328 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/tms/PreparationOrderDetailList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,205 @@
<template>
  <a-card :bordered="false" :class="'cust-erp-sub-tab'">
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>
    <!-- æŸ¥è¯¢åŒºåŸŸ-END -->
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
<!--    <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>-->
<!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
<!--        <a-menu slot="overlay">-->
<!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
<!--        </a-menu>-->
<!--        <a-button style="margin-left: 8px"> æ‰¹é‡æ“ä½œ <a-icon type="down" /></a-button>-->
<!--      </a-dropdown>-->
<!--    </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="null"
        @change="handleTableChange">
<!--        <template slot="htmlSlot" slot-scope="text">-->
<!--          <div v-html="text"></div>-->
<!--        </template>-->
<!--        <template slot="imgSlot" slot-scope="text,record">-->
<!--          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>-->
<!--          <img v-else :src="getImgView(text)" :preview="record.id" 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="action" slot-scope="text, record">-->
<!--          <a @click="handleEdit(record)">编辑</a>-->
<!--          <a-divider type="vertical" />-->
<!--          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--            <a>删除</a>-->
<!--          </a-popconfirm>-->
<!--        </span>-->
      </a-table>
    </div>
    <preparationOrderDetail-modal ref="modalForm" @ok="modalFormOk" :mainId="mainId"></preparationOrderDetail-modal>
  </a-card>
</template>
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import PreparationOrderDetailModal from './modules/preparationOrder/PreparationOrderDetailModal'
  export default {
    name: "PreparationOrderDetailList",
    mixins:[JeecgListMixin],
    components: { PreparationOrderDetailModal },
    props:{
      mainId:{
        type:String,
        default:'',
        required:false
      }
    },
    watch:{
      mainId:{
        immediate: true,
        handler(val) {
          if(!this.mainId){
            this.clearList()
          }else{
            this.queryParam['preparationOrderId'] = 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:"left",
            dataIndex: 'toolNum'
          },
          {
            title:'工具类型',
            align:"center",
            dataIndex: 'applicationType_dictText'
          },
          {
            title:'中文名称',
            align:"center",
            dataIndex: 'chineseName'
          },
          {
            title:'型号/图号',
            align:"left",
            dataIndex: 'toolModel'
          },
          {
            title:'刀具材料',
            align:"center",
            dataIndex: 'toolMaterial'
          },
          {
            title:'零件材料',
            align:"center",
            dataIndex: 'partMaterial'
          },
          {
            title:'厂家',
            align:"center",
            dataIndex: 'supplierId'
          },
          {
            title:'出库数量',
            align:"left",
            dataIndex: 'outboundQuantity',
            scopedSlots: { customRender: 'outboundQuantity' }
          }
        ],
        url: {
          list: "/tms/preparationOrder/listPreparationOrderDetailByMainId",
          delete: "/tms/preparationOrder/deletePreparationOrderDetail",
          deleteBatch: "/tms/preparationOrder/deleteBatchPreparationOrderDetail",
          exportXlsUrl: "/tms/preparationOrder/exportPreparationOrderDetail",
          importUrl: "/tms/preparationOrder/importPreparationOrderDetail",
        },
        dictOptions:{
        }
      }
    },
    created() {
    },
    computed: {
      importExcelUrl(){
        return `${window._CONFIG['domianURL']}/${this.url.importUrl}/${this.mainId}`;
      }
    },
    methods: {
      clearList(){
        this.dataSource=[]
        this.selectedRowKeys=[]
        this.ipagination.current = 1
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
src/views/tms/PreparationOrderList.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,363 @@
<template>
  <a-card :bordered="false">
    <!-- æŸ¥è¯¢åŒºåŸŸ -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="准备单编号">
              <a-input placeholder="请输入准备单编号" v-model="queryParam.preparationOrderNum"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="单据状态">
              <a-select placeholder="请输入准备单编号" v-model="queryParam.orderStatus">
                <a-select-option value="1">待审核</a-select-option>
                <a-select-option value="2">已审核</a-select-option>
                <a-select-option value="3">已转出</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
<!--              <a @click="handleToggleSearch" style="margin-left: 8px">-->
<!--                {{ toggleSearchStatus ? '收起' : '展开' }}-->
<!--                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>-->
<!--              </a>-->
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- æŸ¥è¯¢åŒºåŸŸ-END -->
    <!-- æ“ä½œæŒ‰é’®åŒºåŸŸ -->
    <div class="table-operator">
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
      <a-button @click="handleConvert" type="primary" icon="arrow-right">转出库申请单</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>-->
      <!-- é«˜çº§æŸ¥è¯¢åŒºåŸŸ -->
<!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
    </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"
        class="j-table-force-nowrap"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange, type:'checkbox'}"
        :customRow="clickThenSelect"
        @change="handleTableChange">
<!--        <template slot="htmlSlot" slot-scope="text">-->
<!--          <div v-html="text"></div>-->
<!--        </template>-->
<!--        <template slot="imgSlot" slot-scope="text,record">-->
<!--          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>-->
<!--          <img v-else :src="getImgView(text)" :preview="record.id" 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="action" slot-scope="text, record">
          <a @click="handleDetail(record)">详情</a>
          <span v-if="record.orderStatus === '1'">
            <a-divider type="vertical" />
            <a @click="handleConfirm(record)">审核</a>
            <a-divider type="vertical" />
            <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                    <a>删除</a>
            </a-popconfirm>
          </span>
<!--          <a-divider type="vertical" />-->
<!--          <a-dropdown>-->
<!--            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>-->
<!--            <a-menu slot="overlay">-->
<!--              <a-menu-item>-->
<!--                <a @click="handleEdit(record)">编辑</a>-->
<!--              </a-menu-item>-->
<!--              <a-menu-item>-->
<!--                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">-->
<!--                  <a>删除</a>-->
<!--                </a-popconfirm>-->
<!--              </a-menu-item>-->
<!--            </a-menu>-->
<!--          </a-dropdown>-->
        </span>
      </a-table>
    </div>
    <a-tabs defaultActiveKey="1">
      <a-tab-pane tab="刀具准备单明细" key="1" >
        <PreparationOrderDetailList :mainId="preparationOrderDetailMainId" />
      </a-tab-pane>
    </a-tabs>
    <preparationOrder-modal ref="modalForm" @ok="modalFormOk"></preparationOrder-modal>
  </a-card>
</template>
<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import PreparationOrderModal from './modules/preparationOrder/PreparationOrderModal'
  import { getAction } from '@/api/manage'
  import PreparationOrderDetailList from './PreparationOrderDetailList'
  import '@/assets/less/TableExpand.less'
  import { postAction } from '../../api/manage'
  export default {
    name: "PreparationOrderList",
    mixins:[JeecgListMixin],
    components: {
      PreparationOrderDetailList,
      PreparationOrderModal
    },
    data () {
      return {
        description: '刀具准备单管理页面',
        // è¡¨å¤´
        columns: [
          {
            title:'准备单编号',
            align:"left",
            dataIndex: 'preparationOrderNum'
          },
          {
            title:'零件图号',
            align:"center",
            dataIndex: 'partDrawingNo'
          },
          {
            title:'零件名称',
            align:"center",
            dataIndex: 'partName'
          },
          {
            title:'零件材料',
            align:"center",
            dataIndex: 'partMaterial'
          },
          {
            title:'工序',
            align:"center",
            dataIndex: 'productionProcessesNo'
          },
          {
            title:'加工批次',
            align:"center",
            dataIndex: 'batchCode'
          },
          {
            title:'加工数量',
            align:"left",
            dataIndex: 'machiningCount'
          },
          {
            title:'加工设备',
            align:"center",
            dataIndex: 'equipmentCode'
          },
          {
            title:'程序名',
            align:"center",
            dataIndex: 'ncName'
          },
          {
            title:'单子状态',
            align:"center",
            dataIndex: 'orderStatus_dictText'
          },
          {
            title:'提交时间(提交至出库申请)',
            align:"center",
            dataIndex: 'outboundTime'
          },
          {
            title:'备注',
            align:"center",
            dataIndex: 'remark'
          },
          {
            title:'创建人',
            align:"center",
            dataIndex: 'createBy'
          },
          {
            title:'创建时间(DNC推送时间)',
            align:"center",
            dataIndex: 'createTime'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        url: {
          list: "/tms/preparationOrder/list",
          convertToOutboundOrder: "/tms/preparationOrder/convertToOutboundOrder",
          delete: "/tms/preparationOrder/delete",
          deleteBatch: "/tms/preparationOrder/deleteBatch",
          exportXlsUrl: "/tms/preparationOrder/exportXls",
          importExcelUrl: "tms/preparationOrder/importExcel",
        },
        dictOptions:{
        },
        /* åˆ†é¡µå‚æ•° */
        ipagination:{
          current: 1,
          pageSize: 5,
          pageSizeOptions: ['5', '10', '50'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " å…±" + total + "条"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        selectedMainId:'',
        superFieldList:[],
        preparationOrderDetailMainId: '',
      }
    },
    created() {
      this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      handleConvert() {
        if (this.selectedRowKeys.length < 1) {
          this.$message.warning('请至少选择一条申请单数据!')
          return
        }
        console.log(this.selectionRows)
        console.log(this.selectedRowKeys)
        postAction(this.url.convertToOutboundOrder, this.selectedRowKeys).then((res) => {
          if (res.success) {
            this.$message.success(res.message)
            this.loadData(this.ipagination.current)
          } else {
            this.$message.warning(res.message)
          }
        })
      },
      handleConfirm(record) {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = "审核";
        this.$refs.modalForm.disableSubmit = false;
      },
      searchReset() {
        this.queryParam = {}
        this.preparationOrderDetailMainId = ''
        this.loadData(1)
      },
      initDictConfig(){
      },
      clickThenSelect(record) {
        return {
          on: {
            click: () => {
              this.onClickChange(record.id.split(","), [record]);
            }
          }
        }
      },
      onClickChange(selectedRowKeys, selectionRows) {
        this.preparationOrderDetailMainId = selectionRows[0]['id']
      },
      onClearSelected() {
        this.selectedRowKeys = [];
        this.selectionRows = [];
        this.selectedMainId=''
      },
      onSelectChange(selectedRowKeys, selectionRows) {
        this.selectedMainId=selectedRowKeys[0]
        this.selectedRowKeys = selectedRowKeys;
        this.selectionRows = selectionRows;
      },
      loadData(arg) {
        if(!this.url.list){
          this.$message.error("请设置url.list属性!")
          return
        }
        //加载数据 è‹¥ä¼ å…¥å‚æ•°1则加载第一页的内容
        if (arg === 1) {
          this.ipagination.current = 1;
        }
        this.onClearSelected()
        var params = this.getQueryParams();//查询条件
        this.loading = true;
        getAction(this.url.list, params).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records;
            this.ipagination.total = res.result.total;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
          this.loading = false;
        })
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'preparationOrderNum',text:'准备单编号',dictCode:''})
        fieldList.push({type:'string',value:'partDrawingNo',text:'零件图号',dictCode:''})
        fieldList.push({type:'string',value:'partName',text:'零件名称',dictCode:''})
        fieldList.push({type:'string',value:'partMaterial',text:'零件材料',dictCode:''})
        fieldList.push({type:'string',value:'productionProcessesNo',text:'工序(工步号)',dictCode:''})
        fieldList.push({type:'string',value:'batchCode',text:'加工批次',dictCode:''})
        fieldList.push({type:'string',value:'machiningCount',text:'加工数量',dictCode:''})
        fieldList.push({type:'string',value:'equipmentCode',text:'加工设备',dictCode:''})
        fieldList.push({type:'string',value:'ncName',text:'程序名',dictCode:''})
        fieldList.push({type:'BigDecimal',value:'outboundQuantity',text:'准备单出库数量',dictCode:''})
        fieldList.push({type:'string',value:'orderStatus',text:'单子状态;1.未审核;2.调机员已审核;3.已转出库申请',dictCode:''})
        fieldList.push({type:'date',value:'outboundTime',text:'准备单提交时间;提交至出库申请单的时间'})
        fieldList.push({type:'string',value:'remark',text:'备注',dictCode:''})
        fieldList.push({type:'string',value:'createBy',text:'创建人',dictCode:''})
        fieldList.push({type:'date',value:'createTime',text:'创建时间;DNC推送数据时间'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
src/views/tms/modules/preparationOrder/PreparationOrderDetailModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,143 @@
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row>
          <a-col :span="24">
            <a-form-model-item label="准备单号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="preparationOrderId">
              <a-input v-model="model.preparationOrderId"placeholder="请输入准备单号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="刀具编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="toolCode">
              <a-input v-model="model.toolCode"placeholder="请输入刀具编码" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="刀具编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="toolId">
              <a-input v-model="model.toolId"placeholder="请输入刀具编号" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="申请出库数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="outboundQuantity">
              <a-input-number v-model="model.outboundQuantity"placeholder="请输入申请出库数量" style="width: 100%" />
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="租户号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenantId">
              <a-input v-model="model.tenantId"placeholder="请输入租户号" ></a-input>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </j-modal>
</template>
<script>
  import { httpAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  export default {
    name: "PreparationOrderDetailModal",
    components: {
    },
    props:{
      mainId:{
        type:String,
        required:false,
        default:''
      }
    },
    data () {
      return {
        title:"操作",
        width:800,
        visible: false,
        model:{
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        confirmLoading: false,
        validatorRules: {
        },
        url: {
          add: "/tms/preparationOrder/addPreparationOrderDetail",
          edit: "/tms/preparationOrder/editPreparationOrderDetail",
        }
      }
    },
    created () {
    //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        this.visible = true;
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // è§¦å‘表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            this.model['preparationOrderId'] = this.mainId
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false
          }
        })
      },
      handleCancel () {
        this.close()
      },
    }
  }
</script>
src/views/tms/modules/preparationOrder/PreparationOrderModal.vue
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,328 @@
<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭">
    <a-spin :spinning="confirmLoading">
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row>
          <a-col :span="12">
            <a-form-model-item label="准备单编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="preparationOrderNum">
              <a-input v-model="model.preparationOrderNum" placeholder="请输入准备单编号" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="零件图号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partDrawingNo">
              <a-input v-model="model.partDrawingNo" placeholder="请输入零件图号" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="零件名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partName">
              <a-input v-model="model.partName" placeholder="请输入零件名称" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="零件材料" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="partMaterial">
              <a-input v-model="model.partMaterial" placeholder="请输入零件材料" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="工序(工步号)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="productionProcessesNo">
              <a-input v-model="model.productionProcessesNo" placeholder="请输入工序(工步号)" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="加工批次" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="batchCode">
              <a-input v-model="model.batchCode" placeholder="请输入加工批次" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="加工设备" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="equipmentCode">
              <a-input v-model="model.equipmentCode" placeholder="请输入加工设备" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="程序名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ncName">
              <a-input v-model="model.ncName" placeholder="请输入程序名" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="加工数量" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="machiningCount">
              <a-input v-model="model.machiningCount" placeholder="请输入加工数量" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remark">
              <a-textarea :disable="disableSubmit" v-model="model.remark" placeholder="请输入备注" ></a-textarea>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :scroll="{x:true}"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="null">
        <template v-for="col in columns" :slot="col.dataIndex" slot-scope="text, record, index">
          <div :key="col.dataIndex">
            <a-input-number
              v-if="col.dataIndex === 'outboundQuantity'"
              :value="text"
              @change="(e) => handleChange(e, record.key, col, index)"
              :min="1"
            />
          </div>
        </template>
        <span slot="action" v-if="disableSubmit === false" slot-scope="text, record, index">
        <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record, index)">
          <a>删除</a>
        </a-popconfirm>
      </span>
      </a-table>
    </a-spin>
    <template slot="footer">
      <a-button :style="{ marginRight: '8px' }" @click="handleCancel">关闭</a-button>
      <a-button @click="handleOk" v-if="disableSubmit === false" type="primary">确定</a-button>
    </template>
  </j-modal>
</template>
<script>
  import { httpAction } from '@/api/manage'
  import { validateDuplicateValue } from '@/utils/util'
  import { getAction } from '../../../../api/manage'
  export default {
    name: "PreparationOrderModal",
    components: {
    },
    data () {
      return {
        title: "操作",
        width: 1200,
        visible: false,
        model:{
        },
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
        loading: false,
        dataSource: [],
        /* åˆ†é¡µå‚æ•° */
        ipagination:{
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + "-" + range[1] + " å…±" + total + "条"
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        // è¡¨å¤´
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'工具编码',
            align:"left",
            dataIndex: 'toolNum'
          },
          {
            title:'工具类型',
            align:"center",
            dataIndex: 'applicationType_dictText'
          },
          {
            title:'中文名称',
            align:"center",
            dataIndex: 'chineseName'
          },
          {
            title:'型号/图号',
            align:"left",
            dataIndex: 'toolModel'
          },
          {
            title:'刀具材料',
            align:"center",
            dataIndex: 'toolMaterial'
          },
          {
            title:'零件材料',
            align:"center",
            dataIndex: 'partMaterial'
          },
          {
            title:'厂家',
            align:"center",
            dataIndex: 'supplierId'
          },
          {
            title:'出库数量',
            align:"left",
            dataIndex: 'outboundQuantity',
            scopedSlots: { customRender: 'outboundQuantity' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' },
          }
        ],
        confirmLoading: false,
        validatorRules: {
           outboundQuantity: [
              { required: true, message: '请输入准备单出库数量!'},
           ],
           orderStatus: [
              { required: true, message: '请输入单子状态;1.未审核;2.调机员已审核;3.已转出库申请!'},
           ],
           outboundTime: [
              { required: true, message: '请输入准备单提交时间;提交至出库申请单的时间!'},
           ],
        },
        url: {
          list: "/tms/preparationOrder/listPreparationOrderDetailByMainId",
          add: "/tms/preparationOrder/add",
          edit: "/tms/preparationOrder/editTotal",
          delete: "/tms/preparationOrder/deletePreparationOrderDetail"
        }
      }
    },
    created () {
    //备份model原始值
      this.modelDefault = JSON.parse(JSON.stringify(this.model));
    },
    methods: {
      handleChange(value, key, column, index) {
        console.log(value, key, column, index)
        const temp = [...this.dataSource]
        const target = temp.filter(item => key === item.key)[index];
        if (target) {
          target[column.dataIndex] = value
          this.dataSource = temp
          if(column.dataIndex === 'outboundQuantity'){
            if(target['quantity']<value){
              this.$message.error('申请出库数量不能大于可用库存!')
              this.isDisabled = true
            }else{
              this.isDisabled = false
            }
          }
          this.dataSource = temp
        }
      },
      add () {
        this.edit(this.modelDefault);
      },
      edit (record) {
        this.model = Object.assign({}, record);
        getAction(this.url.list, { preparationOrderId: record.id}).then(res => {
          if (res.success) {
            this.dataSource = res.result.records || res.result;
            if (res.result.total)
            {
              this.ipagination.total = res.result.total;
            } else {
              this.ipagination.total = 0;
            }
          } else {
            this.$message.warning(res.message)
          }
        })
        this.visible = true;
      },
      handleDelete(record, index) {
        deleteAction(this.url.delete, { id: record.id }).then((res) => {
          if (res.success) {
            this.dataSource.splice(index, 1);
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        });
      },
      close () {
        this.$emit('close');
        this.visible = false;
        this.$refs.form.clearValidate();
      },
      handleOk () {
        const that = this;
        // è§¦å‘表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            this.model.preparationOrderDetailList = this.dataSource
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
               if (this.title === '审核') {
                 this.model.orderStatus = '2';
               }
            }
            console.log(this.model)
            httpAction(httpurl,this.model,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })
          }else{
             return false
          }
        })
      },
      handleCancel () {
        this.close()
      },
    }
  }
</script>