Files
JY1.0/src/views/PurchasingCenter/OfflineContract/index.vue
2020-04-07 10:04:01 +08:00

1748 lines
75 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<el-card>
<el-row id="PurchasingCenter/OfflineContract">
<el-col :span="24">
<el-tabs v-model="tabName" type="border-card" @tab-click="tabClick">
<el-tab-pane label="三表" name="标准件">
<el-row>
<el-input v-model="materialName" style="width: 150px;margin-left: 5px" placeholder="名称规格型号" size="small" clearable @keyup.enter.native="pageCurrent11=1;pageSize11=20;total11=0;searchTable11()"/>
<el-select v-model="machineValue" style="width:150px;margin-left: 5px" placeholder="机床图号" size="small" clearable filterable @change="pageCurrent11=1;pageSize11=20;total11=0;searchTable11()">
<el-option
v-for="item in machine"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<el-date-picker
v-model="startTime"
size="small"
type="daterange"
align="center"
value-format="yyyy-MM-dd"
format="yyyy-MM-dd"
range-separator=""
style="width:250px;margin-left: 5px"
start-placeholder="开始日期"
end-placeholder="结束日期"/>
<el-button type="primary" size="small" icon="el-icon-search" plain style="margin-left: 5px" @click="pageCurrent11=1;pageSize11=20;total11=0;searchTable11()">查询</el-button>
<el-button type="primary" size="small" plain style="float: right;margin-right: 20px" @click="tiaozheng1">调整采购任务</el-button>
<el-select v-model="PersonValue" style="width:100px; float: right" placeholder="人员" size="small" filterable clearable>
<el-option
v-for="item in Person"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</el-row>
<!--:row-class-name="tableRowClassName"-->
<el-table
v-loading="loading1"
:data="tableData00"
border
style="width: 100%;max-height: 500px;"
height="300px"
size="mini"
@selection-change="handleSelectionChange1"
@select="handleSelection">
<el-table-column :selectable="selectable" align="center" width="43" type="selection"/>
<el-table-column label="名称" align="center" prop="物料名称" width="100" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料名称 }}
</template>
</el-table-column>
<el-table-column label="规格" align="center" prop="物料规格" width="120" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料规格 }}
</template>
</el-table-column>
<el-table-column label="型号" prop="物料型号" align="center" width="100" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料型号 }}
</template>
</el-table-column>
<el-table-column :filters="supplierFilters" :filter-method="filterHandler" prop="供货商" label="供货商" align="center" width="120" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.供货商 === '0' ? '-' : scope.row.供货商 }}
</template>
</el-table-column>
<el-table-column label="机床图号" prop="机床图号" align="center" width="100" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.机床图号 }}
</template>
</el-table-column>
<el-table-column label="组号" prop="组号" align="center" width="50">
<template slot-scope="scope">
{{ scope.row.组号 }}
</template>
</el-table-column>
<el-table-column label="物料类别" align="center" width="80" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料类别 }}
</template>
</el-table-column>
<el-table-column label="物料品种" prop="物料品种" align="center" width="100" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料品种 }}
</template>
</el-table-column>
<el-table-column label="分配数量" align="center" width="80" prop="零件数量">
<template slot-scope="scope">
{{ scope.row.零件数量 }}
</template>
</el-table-column>
<el-table-column label="库存(BZ)" align="center" width="80" prop="库存">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 1 ? scope.row.库存 = Number(scope.row.货位存量 ? scope.row.货位存量 : 0) - Number(scope.row.占用数量) : '-' }}
</template>
</el-table-column>
<el-table-column label="使用库存数量" align="center" width="110" prop="使用库存数">
<template slot-scope="scope">
<span v-if="Number(scope.row.零件类型) !== 1 || (Number(scope.row.货位存量 ? scope.row.货位存量 : 0) - Number(scope.row.占用数量)) === 0">-</span>
<el-input-number v-if="Number(scope.row.零件类型) === 1 && (Number(scope.row.货位存量 ? scope.row.货位存量 : 0) - Number(scope.row.占用数量)) !== 0" v-model="scope.row.使用库存数" :min="0" :max="Number(scope.row.零件数量) > (Number(scope.row.货位存量) - Number(scope.row.占用数量)) ? (Number(scope.row.货位存量) - Number(scope.row.占用数量) + Number(scope.row.使用库存数)) : Number(scope.row.零件数量)" :disabled="(Number(scope.row.货位存量) - Number(scope.row.占用数量)) === 0 || parseInt(scope.row.采购状态编号)===3" size="mini" style="width: 90px" @change="changeNumber(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="待采数量" align="center" width="80" prop="待采购数量">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 1 ? scope.row.待采购数量 = Number(scope.row.零件数量) - Number(scope.row.使用库存数) : scope.row.待采购数量 = Number(scope.row.零件数量) - Number(scope.row.使用滞货数量) }}
</template>
</el-table-column>
<el-table-column label="使用滞货数量" align="center" width="110" prop="使用滞货数量">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 1 ? Number(scope.row.使用滞货数量) : '-' }}
</template>
</el-table-column>
<el-table-column label="使用滞货" align="center" width="80">
<template slot-scope="scope">
<template v-if="parseInt(scope.row.询价状态编号)!==1||parseInt(scope.row.是否确认)!==1||Number(scope.row.滞货数量)===0">
</template>
<el-button v-else :disabled="parseInt(scope.row.询价状态编号)!==1||parseInt(scope.row.是否确认)!==1||Number(scope.row.滞货数量)===0" icon="el-icon-goods" plain type="primary" size="mini" @click="useInventory(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="可用滞货数量" align="center" width="110">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 2 ? Number(scope.row.滞货数量) : '-' }}
</template>
</el-table-column>
<el-table-column :filters="remarkFilters" :filter-method="filterHandler0" label="备注" align="center" min-width="100" prop="备注筛选" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.备注 }}
</template>
</el-table-column>
<el-table-column :filters="source" :filter-method="filterSource" align="center" label="来源" width="70px" prop="零件类型筛选">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 1 ? 'BZ' : 'WG' }}
</template>
</el-table-column>
<el-table-column label="分配时间" prop="任务分配时间" align="center" min-width="120">
<template slot-scope="scope">
{{ scope.row.任务分配时间 ? (scope.row.任务分配时间.split(' ')[0] === '1900/1/4' ? '-' : scope.row.任务分配时间.split(' ')[0]) : '-' }}
</template>
</el-table-column>
</el-table>
<el-tooltip :open-delay="100" effect="dark" content="将勾选的物料库中物料选入到选中的离线合同" placement="top">
<el-button type="primary" size="small" icon="el-icon-bottom" plain style="margin: 0px 40px 0px 0px; display: inline-block" @click="addMateriel">选入物料</el-button>
</el-tooltip>
<div class="block" style="margin: 10px 0 0 0;display: inline-block">
<el-pagination
:current-page="pageCurrent11"
:page-sizes="[10, 20, 30, 40, 100]"
:page-size="pageSize11"
:total="total11"
style="display:inline-block;width:800px"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange11"
@current-change="handleCurrentChange11"/>
</div>
<!--:row-class-name="tableRowClassName2"-->
</el-tab-pane>
<el-tab-pane label="仓库" name="仓库">
<el-row>
<el-input v-model="materialName" style="width: 180px;margin-left: 10px" placeholder="名称规格型号" size="small" clearable @keyup.enter.native="pageCurrent22=1;pageSize22=20;total22=0;searchTable22()"/>
<el-button type="primary" size="small" icon="el-icon-search" plain style="margin-left: 10px" @click="searchTable22()">查询</el-button>
</el-row>
<el-table
v-loading="loading2"
:data="tableData22"
border
stripe
style="width: 680px;max-height: 500px;"
height="300px"
size="mini"
@selection-change="handleSelectionChange1"
@select="handleSelection1">
<el-table-column align="center" width="43" type="selection"/>
<el-table-column label="名称" align="center" prop="物料名称" width="170" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料名称 }}
</template>
</el-table-column>
<el-table-column label="图号或型号" prop="物料型号" align="center" width="150" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料型号 }}
</template>
</el-table-column>
<el-table-column label="规格" align="center" prop="物料规格" width="140" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料规格 }}
</template>
</el-table-column>
<el-table-column :filters="supplierFilters" :filter-method="filterHandler" prop="供货商" label="供货商" align="center" width="160">
<template slot-scope="scope">
{{ scope.row.供货商 }}
</template>
</el-table-column>
</el-table>
<el-tooltip :open-delay="100" effect="dark" content="将勾选的物料库中物料选入到选中的离线合同" placement="top">
<el-button type="primary" size="small" icon="el-icon-bottom" plain style="margin: 5px 40px 0px 0px; display: inline-block" @click="addMateriel">选入物料</el-button>
</el-tooltip>
<div class="block" style="display: inline-block">
<el-pagination
:current-page="pageCurrent22"
:page-sizes="[20, 50, 100, 150]"
:page-size="pageSize22"
:total="total22"
style="display:inline-block;width:50%"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange22"
@current-change="handleCurrentChange22"/>
</div>
</el-tab-pane>
</el-tabs>
</el-col>
</el-row>
</el-card>
<el-card>
<el-card>
<div slot="header">
<el-input v-model="offlineContract" placeholder="离线合同号/供应商" size="small" style="width: 170px;margin-left: 5px" clearable/>
<!--<el-input v-model="supplierName0" placeholder="供应商" size="small" style="width: 140px" clearable/>-->
<el-button type="primary" size="small" icon="el-icon-search" plain style="margin-left: 10px" @click="pageCurrent2=1;pageSize2=10000;total2=0;searchTable2()">查询</el-button>
<el-button type="warning" size="small" icon="el-icon-circle-plus-outline" plain style="margin-right:30px;margin-left:100px;" @click="addOfflineContract">离线合同</el-button>
<el-tooltip :open-delay="1000" effect="dark" content="生成合同" placement="top">
<el-button type="success" size="small" plain style="margin-left:10px;margin-right: 10px" @click="doneOfflineContact">生成离线合同</el-button>
</el-tooltip>
<!--<el-button :disabled="disable" type="info" size="mini" style="float:right" @click="saveContract">保存</el-button>-->
<el-tooltip :content="hasTax" placement="top" style="margin-right: 370px">
<el-switch v-model="hasTax" active-color="#13ce66" inactive-color="#ff4949" active-value="含税" inactive-value="未税" style="margin: 3px;float:right"/>
</el-tooltip>
<el-input v-model="taxRate" style="float:right;width:60px;" placeholder="税率" size="mini"/>
<h4 style="float:right;width: 40px;margin: 5px">税率:</h4>
<!--<el-button v-if="quickChangePrice" size="mini" style="float:right; width: 100px" @click="quickChangePrice=!quickChangePrice">快速修改价格</el-button>-->
<!--<el-button v-else size="mini" style="float:right;" @click="quickChangePrice=!quickChangePrice">还原</el-button>-->
</div>
<el-table v-loading="loading3" :data="tableData2" border style="max-height: 460px;" size="mini" highlight-current-row @row-click="searchTable3">
<!-- <el-table-column label="详情" type="expand" fixed="left" width="50px">-->
<!-- <template slot-scope="scope">-->
<!-- <el-form label-position="left" inline class="demo-table-expand">-->
<!-- <el-form-item label="离线合同备注">-->
<!-- {{ scope.row.离线合同备注 }}-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="合同状态" align="center" width="80" fixed="left">
<template slot-scope="scope">
<span v-if="editing(scope.row)" style="color: #E6A23C" size="small">编辑中</span>
<span v-if="purchasing(scope.row)" style="color: #409eff" size="small">已采购</span>
<span v-if="arrival(scope.row)" style="color: #67c23a" size="small">全部到货</span>
</template>
</el-table-column>
<el-table-column label="离线合同编号" prop="离线合同编号" align="center" width="120">
<template slot-scope="scope">
{{ scope.row.离线合同编号 }}
</template>
</el-table-column>
<el-table-column label="离线合同名称" align="center" width="130" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.离线合同名称 }}
</template>
</el-table-column>
<el-table-column label="供应商" prop="供应商名称" align="center" width="320" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.供应商名称 }}
</template>
</el-table-column>
<el-table-column label="采购员" prop="采购员" align="center" width="90">
<template slot-scope="scope">
{{ scope.row.采购员 }}
</template>
</el-table-column>
<el-table-column label="创建日期" prop="创建日期" align="center" width="100">
<template slot-scope="scope">
{{ scope.row.创建日期.split(' ')[0] }}
</template>
</el-table-column>
<el-table-column label="规定到货时间" align="center" width="120">
<template slot-scope="scope">
{{ scope.row.规定到货时间.split(' ')[0] }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="120">
<template slot-scope="scope">
<el-button :disabled="arrival(scope.row)" type="text" icon="el-icon-edit" plain size="mini" @click="editOfflineContract(scope.row)"/>
<el-button :disabled="arrival(scope.row)" type="text" icon="el-icon-delete" plain size="mini" @click="deleteOfflineContract(scope.row)"/>
<el-tooltip :open-delay="1000" effect="dark" content="打印合同" placement="top">
<el-button type="text" size="mini" icon="el-icon-printer" plain @click="exportExcel(scope.row)"/>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<!-- <div class="block" style="margin: 10px 0;">-->
<!-- <el-pagination-->
<!-- :current-page="pageCurrent2"-->
<!-- :page-sizes="[10, 20, 30, 40]"-->
<!-- :page-size="pageSize2"-->
<!-- :total="total2"-->
<!-- style="display:inline-block;width:50%"-->
<!-- layout="total"-->
<!-- @size-change="handleSizeChange2"-->
<!-- @current-change="handleCurrentChange2"/>-->
<!-- </div>-->
</el-card>
<el-card>
<!--<h3>合同详细信息</h3>-->
<el-table v-loading="" :data="tableData3" :summary-method="getSummaries" border stripe style="max-height: 500px;" height="450px" size="mini" show-summary>
<el-table-column label="物料名称" align="center" width="120" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料名称 ? scope.row.物料名称 : scope.row.零件名称 }}
</template>
</el-table-column>
<el-table-column label="规格" align="center" width="100" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料规格 ? scope.row.物料规格 : scope.row.规格 }}
</template>
</el-table-column>
<el-table-column label="图号或型号" align="center" width="140" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料型号 ? scope.row.物料型号 : scope.row.零件图号 }}
</template>
</el-table-column>
<el-table-column label="采购数" align="center" width="100">
<template slot-scope="scope">
<el-input v-direction="{x: 0, y: scope.$index}" v-if="quickChangePrice" v-model="scope.row.数量" :disabled="disable" size="mini" style="width:60px" @change="saveContract()"/>
<b v-else>{{ scope.row.数量 }}</b>
</template>
</el-table-column>
<el-table-column label="单位" align="center" min-width="50">
<template slot-scope="scope">
{{ scope.row.计量单位 }}
</template>
</el-table-column>
<el-table-column label="参考价格" align="center" width="80">
<template slot-scope="scope">
{{ scope.row.参考价格 }}
</template>
</el-table-column>
<el-table-column label="单价(未税)元" align="center" width="110" prop="单价">
<template slot-scope="scope">
<el-input v-direction="{x: 1, y: scope.$index}" v-if="hasTax==='未税'" v-model="scope.row.未税单价" :disabled="disable" size="mini" style="width:70px" @change="saveContract()"/>
<b v-show="hasTax!=='未税'">{{ (scope.row.单价 / (1 + taxRate)).toFixed(2) }}</b>
</template>
</el-table-column>
<el-table-column label="单价(含税)元" align="center" width="120" prop="单价">
<template slot-scope="scope">
<el-input v-direction="{x: 1, y: scope.$index}" v-if="hasTax==='含税'" v-model="scope.row.单价" :disabled="disable" size="mini" style="width:80px" @change="saveContract()"/>
<b v-show="hasTax!=='含税'">{{ (scope.row.未税单价 * (1 + taxRate)).toFixed(2) }}</b>
</template>
</el-table-column>
<el-table-column label="总额(未税)元" align="center" width="110" prop="合计">
<template slot-scope="scope">
{{ hasTax==='未税' ? scope.row.未税总额 = (Number(scope.row.数量) * Number(scope.row.未税单价)).toFixed(2) : scope.row.未税总额 = (scope.row.含税总额 / (1+taxRate)).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="总额(含税)元" align="center" width="110" prop="合计">
<template slot-scope="scope">
{{ hasTax==='含税' ? scope.row.含税总额 = (Number(scope.row.数量) * Number(scope.row.单价)).toFixed(2) : scope.row.含税总额 = (scope.row.未税总额 * (1+taxRate)).toFixed(2) }}
</template>
</el-table-column>
<el-table-column label="备注" align="center" min-width="120" prop="备注">
<template slot-scope="scope">
<el-input v-direction="{x: 3, y: scope.$index}" v-if="quickChangePrice" v-model="scope.row.备注" :disabled="disable" size="mini" style="width:100px" @change="saveContract()"/>
<b v-else>{{ scope.row.备注 || '' }}</b>
</template>
</el-table-column>
<el-table-column label="交货期要求" align="center" min-width="130" prop="交货期要求">
<template slot-scope="scope">
<el-input v-direction="{x: 2, y: scope.$index}" v-if="quickChangePrice" v-model="scope.row.交货要求" :disabled="disable" size="mini" style="width:90px" @change="saveContract()"/>
<b v-else>{{ scope.row.交货期要求 || '' }}</b>
</template>
</el-table-column>
<el-table-column v-if="disable" label="到货数量" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.到货数量 }}
</template>
</el-table-column>
<el-table-column label="操作" align="center" min-width="50">
<template slot-scope="scope">
<!--<el-button :disabled="arrival(scope.row)" type="text" icon="el-icon-delete" plain size="mini" @click="deleteOfflineContract(scope.row)"/>-->
<el-button v-if="quickChangePrice" :disabled="disable" type="text" plain size="mini" icon="el-icon-right" @click="deleteMateriel(scope.row)"/>
<b v-else>移除</b>
</template>
</el-table-column>
</el-table>
</el-card>
</el-card>
<div id="offlineContract" style="width: 800px;margin: 0 auto;display: none">
<table class="offlineContract" cellspacing="0px" align="center" border="1 solid black" width="100%">
<tr>
<th colspan="14"><h1>离线合同</h1></th>
</tr>
<tr>
<td colspan="3" rowspan="2" style="text-align:center;font-size: 30px;font-weight: bold">GAOJING</td>
<td width="80px">合同名称</td>
<td id="contractName" colspan="2" style="text-align: left;"/>
<td width="80px">供应商</td>
<td id="supplier" colspan="5" style="text-align: left;"/>
<td id="qrCode" colspan="2" rowspan="2">二维码粘贴处</td>
</tr>
<tr>
<td width="80px">合同编号</td>
<td id="contractNum" colspan="2" style="text-align: left;"/>
<td width="80px">采购员</td>
<td id="buyer" colspan="5" style="text-align: left;"/>
</tr>
<tr id="tablehead">
<td>序号</td>
<td colspan="2">名称</td>
<td>规格</td>
<td colspan="2">型号</td>
<td>数量</td>
<td>单价</td>
<td>单位</td>
<td colspan="2">合计</td>
<td>交货要求</td>
<td colspan="2">备注</td>
</tr>
<tr>
<td>总计</td>
<td id="remark" colspan="10"/>
<td id="total" colspan="2" style="text-align: left;"/>
<td/>
</tr>
</table>
</div>
<el-dialog v-el-drag-dialog :visible.sync="dialogVisible1" title="供应商选择" center style="min-height: 300px" width="700px">
<el-form ref="form1" :model="form1" label-position="left" label-width="90px" class="searchForm">
<el-row>
<el-col :span="12">
<el-form-item label="供应商名称">
<el-input v-model="supplierName" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="法人">
<el-input v-model="enterpriseNature" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="邮编">
<el-input v-model="goodTime" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="受托人">
<el-input v-model="registeredCapital" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="税号">
<el-input v-model="taxNum" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电子邮箱">
<el-input v-model="EMail" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="地址">
<el-input v-model="address" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="账号">
<el-input v-model="account" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="开户行">
<el-input v-model="openingBank" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电话号码">
<el-input v-model="phone" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="传真">
<el-input v-model="fax" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-button
type="success"
size="small"
icon="el-icon-search"
@click="searchSupplier">查询</el-button>
<el-button
type="primary"
size="small"
icon="el-icon-check"
@click="submitSelectSupplier">确定</el-button>
<el-button
type="danger"
size="small"
icon="el-icon-delete"
@click="emptySupplierDetail">清空</el-button>
</el-col>
</el-row>
<el-table :data="tableData01" size="mini" style="width: 97%;max-height: 300px;margin-top:15px" height="200px" border @row-click="showSupplierDetail">
<el-table-column align="center" label="供应商名称" min-width="250">
<template slot-scope="scope">
{{ scope.row.供应商名称 }}
</template>
</el-table-column>
<el-table-column align="center" label="法人" min-width="100">
<template slot-scope="scope">
{{ scope.row.企业性质 }}
</template>
</el-table-column>
<el-table-column align="center" label="受托人" min-width="100">
<template slot-scope="scope">
{{ scope.row.注册资本 }}
</template>
</el-table-column>
</el-table>
</el-form>
</el-dialog>
<el-dialog v-el-drag-dialog :title="title2" :visible.sync="dialogVisible2" center style="min-height: 300px" width="750px">
<el-form ref="form2" :model="form2" :rules="rules2" label-position="right" label-width="120px">
<el-row>
<el-col :span="12">
<el-form-item label="离线合同编号" prop="离线合同编号">
<el-input v-model="form2.离线合同编号" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="离线合同名称" prop="离线合同名称">
<el-input v-model="form2.离线合同名称" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="供应商名称" prop="供应商流水号">
<el-select v-model="form2.供应商流水号" style="width:150px" placeholder="供应商" size="small" filterable>
<el-option
v-for="item in supplierNames"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</el-form-item>
<!-- <el-form-item label="供应商名称" prop="供应商名称">-->
<!-- <el-input v-model="form2.供应商名称" size="small" readonly>-->
<!-- <el-button slot="append" icon="el-icon-search" @click="dialogVisible1=true"/>-->
<!-- </el-input>-->
<!-- </el-form-item>-->
</el-col>
<el-col :span="12">
<el-form-item label="规定到货时间" prop="规定到货时间">
<el-date-picker
v-model="form2.规定到货时间"
size="small"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="选择日期"/>
</el-form-item>
</el-col>
</el-row>
<!-- <el-row>-->
<!-- <el-col :span="12">-->
<!-- <el-form-item label="离线合同备注" prop="离线合同备注">-->
<!-- <el-input v-model="form2.离线合同备注" size="small" type="textarea" style="width: 550px"/>-->
<!-- </el-form-item>-->
<!-- </el-col>-->
<!-- </el-row>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button
v-show="title2==='创建离线合同'"
type="distribution"
size="small"
icon="el-icon-circle-check"
@click="submitAddOfflineContract">确定</el-button>
<el-button
v-show="title2==='编辑离线合同'"
type="distribution"
size="small"
icon="el-icon-circle-check"
@click="submitEditOfflineContract">确定</el-button>
</div>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogVisible4" title="使用滞货" center style="min-height: 300px;" width="400px">
<span>使用滞货数量</span>
<el-input-number :min="0" :max="maxUseNumber" v-model="useNumber" controls-position="right"/>
<div style="margin: 10px 0 0 10px;color: red">注意确定后将不可取消使用滞货</div>
<div slot="footer" class="dialog-footer">
<el-button size="small" @click="dialogVisible4=false">取消</el-button>
<el-button :disabled="Number(useNumber)===0" type="primary" size="small" @click="submitUseInventory">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { tiaozheng2, tiaozheng1, searchOfflineContract, searchOfflineContract2, searchSupplier, addOfflineContract, editOfflineContract, deleteOfflineContract, searchMateriel, searchMaterial1,
addMateriel, deleteMateriel, saveOfflineContact, doneOfflineContact, searchMaterial22, searchMachine, searchGroup, initProject, changeNum, submitUseInventory, getBillNum,
searchPart, getPerson, searchSupplier1 } from '@/api/PurchasingCenter/OfflineContract'
import QRCode from 'qrcode'
import $ from 'jquery'
import { mapGetters } from 'vuex'
export default {
name: '', // 离线合同
data() {
return {
supplierNames: [],
startTime: '',
标准件和外购件流水号: [],
基本件流水号: [],
quickChangePrice: true,
hasTax: '含税',
taxRate: 0.13,
source: [
{
text: 'BZ',
value: 1
},
{
text: 'WG',
value: 2
}
],
remarkFilters: [],
supplierFilters: [],
groupPartNumGroup: [], // 组件零件流水号组
groupBasicPartNumGroup: [], // 组件零件基本件流水号组
materielNumGroup: [], // 物料流水号组
idNumGroup: [], // id组
NumGroup: [], // 数量组
offlineContractsValue: '',
offlineContracts: [],
tableData02: [],
tableData22: [],
dialogVisible0: false,
materialStatusValue: [3], // 物料状态
materialStatus: [
{
value: 0,
label: '全部'
},
{
value: 1,
label: '未分配'
},
{
value: 2,
label: '已分配',
children: [{
value: 3,
label: '未询价'
}, {
value: 4,
label: '已询价',
children: [{
value: 5,
label: '未采购'
}, {
value: 6,
label: '已采购'
}]
}]
}
], // 物料状态
total00: 0,
pageCurrent00: 1,
pageSize00: 40,
tableData00: [],
total11: 0,
pageCurrent11: 1,
pageSize11: 20,
tableData12: [], // 基本件列表
total12: 0,
pageCurrent12: 1,
pageSize12: 100,
partNum: '',
partName: '',
partSpec: '',
endTime: '',
Person: [],
PersonValue: '',
showMaterialTable: true,
loading1: false,
loading2: false,
loading3: false,
loading4: false,
title2: '',
purchaseStateValue: 2, // 采购状态 全部
purchaseState: [
{
label: '未采购',
value: 1
}, {
label: '全部',
value: 2
}
],
check1: 0,
check2: 0,
check3: 0,
check4: 0,
materialName: '',
materialSpec: '',
materialModel: '',
inventoryStateValue: '', // 库存状态
inventoryState: [
{
label: '充足',
value: 2
},
{
label: '不足',
value: 1
}
],
tableData1: [],
pageCurrent1: 1,
pageSize1: 10,
total1: 0,
offlineContractNum: '', // 离线合同流水号
offlineContract: '', // 离线合同号
supplierName0: '', // 供应商名称(外面的)
supplierName: '', // 供应商名称
payTime: [], // 付款时间节点
tableData2: [],
projectValue: '',
project: [],
machineValue: '',
machine: [],
groupValue: '',
group: [],
total2: 0,
pageCurrent2: 1,
pageSize2: 10000,
dialogVisible1: false,
form1: {},
supplierCheck1: 0,
supplierCheck2: 0,
supplierCheck3: 0,
supplierCheck4: 0,
supplierCheck5: 0,
supplierCheck6: 0,
supplierCheck7: 0,
supplierCheck8: 0,
supplierCheck9: 0,
supplierCheck10: 0,
supplierCheck11: 0,
supplierCheck12: 0,
supplierValue: '', // 供应商流水号
goodTime: '', // 货期
enterpriseNature: '', // 企业性质
createDate: '', // 创立日期
registeredCapital: '', // 注册资本
taxNum: '', // 税号
EMail: '', // 电子邮箱
address: '', // 地址
account: '', // 账号
openingBank: '', // 开户行
phone: '', // 电话号码
fax: '', // 传真
tableData01: [],
partType: 1,
dialogVisible2: false,
visible: false,
visible1: false,
visible2: false,
form2: {
离线合同流水号: '',
离线合同编号: '',
离线合同名称: '',
供应商流水号: '',
供应商名称: '',
规定到货时间: '',
离线合同备注: '付款方式:;付款时间:;到货时间:;开票信息:;其他说明:;'
},
rules2: { // 离线合同表单验证规则
离线合同编号: [{ required: true, message: '请填写离线合同编号' }],
离线合同名称: [{ required: true, message: '请填写离线合同名称' }],
供应商流水号: [{ required: true, message: '请选择供应商' }],
规定到货时间: [{ required: true, message: '请选择规定到货时间' }],
运费: [{ required: true, message: '请填写运费' }],
付款方式: [{ required: true, message: '请选择付款方式' }]
},
backlogGroupPartNum: '',
backlogMaterialNum: '',
tableData3: [],
useNumber: '',
maxUseNumber: '',
dialogVisible4: false,
materielGroup: [], // 物料流水号组
partGroup: [], // 离线合同明细流水号组
numGroup: [], // 数量组
priceGroup: [], // 单价组
totalPrice: 0, // 合同总额
tableData4: [], // 合同模板
stipulateArrivalTime: '', // 规定到货时间
离线合同状态: '',
numbers: [],
numbers1: [],
paramRow: '', // 参数row
disable: true, // 其他的禁用
tabName: '标准件',
total22: 0,
pageCurrent22: 1,
pageSize22: 20
}
},
computed: {
...mapGetters([
'name',
'id' // 人员编号
])
},
created() {
this.getPerson()
this.projectChange()
this.getSupplier1()
// this.searchTable2()
// this.searchTable11()
this.initDirection()
},
methods: {
handleSelection(val, row) {
console.log(row, 123)
this.tableData00.forEach((item, i) => {
if (item.组件零件流水号 === row.组件零件流水号 && row.组件零件流水号 !== '0') {
if (this.numbers.indexOf(i) === -1) {
this.numbers.push(i)
} else {
this.numbers.splice(this.numbers.indexOf(i), 1)
}
} else if (item.组件零件基本件流水号 === row.组件零件基本件流水号 && row.组件零件基本件流水号 !== '0') {
if (this.numbers.indexOf(i) === -1) {
this.numbers.push(i)
} else {
this.numbers.splice(this.numbers.indexOf(i), 1)
}
}
console.log(this.numbers, 123)
})
},
handleSelection1(val, row) {
this.tableData22.forEach((item, i) => {
if (item.物料流水号 === row.物料流水号) {
console.log(this.numbers1.indexOf(i), 234)
if (this.numbers1.indexOf(i) === -1) {
this.numbers1.push(i)
} else {
this.numbers1.splice(this.numbers1.indexOf(i), 1)
}
}
})
},
tableRowClassName({ row, rowIndex }) {
let color = ''
this.numbers.forEach((r, i) => {
if (rowIndex === r) {
color = 'MistyRose'
}
})
return color
},
tableRowClassName2({ row, rowIndex }) {
let color = ''
this.numbers1.forEach((r, i) => {
if (rowIndex === r) {
color = 'MistyRose'
}
})
return color
},
initDirection() {
const direction = this.$getDirection()
direction.on('keyup', function(e, val) {
if (e.keyCode === 39) {
direction.next()
}
if (e.keyCode === 37) {
direction.previous()
}
if (e.keyCode === 38) {
direction.previousLine()
}
if (e.keyCode === 40) {
direction.nextLine()
}
})
},
projectChange() {
this.machine = []
this.machineValue = ''
this.group = []
this.groupValue = ''
searchMachine(this.projectValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.machine.push({
value: response.data[i].机床流水号,
label: response.data[i].机床图号
})
}
})
},
machineChange() {
this.group = []
this.groupValue = ''
searchGroup(this.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
value: response.data[i].组件流水号,
label: response.data[i].组号
})
}
})
},
tiaozheng1() {
if (this.标准件和外购件流水号.length !== 0) {
if (this.PersonValue) {
tiaozheng1(this.PersonValue, this.标准件和外购件流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('调整成功')
this.searchTable11()
} else {
this.$message.warning('调整失败')
}
})
} else {
this.$message.warning('请选择人员')
}
} else {
this.$message.warning('请选择物料')
}
},
tiaozheng2() {
if (this.基本件流水号.length !== 0) {
if (this.PersonValue) {
tiaozheng2(this.PersonValue, this.基本件流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('调整成功')
this.searchTable12()
} else {
this.$message.warning('调整失败')
}
})
} else {
this.$message.warning('请选择人员')
}
} else {
this.$message.warning('请选择物料')
}
},
getPerson() {
getPerson().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.Person.push({
value: response.data[i].人员编号,
label: response.data[i].姓名
})
}
})
},
submitUseInventory() {
submitUseInventory(this.backlogMaterialNum, this.useNumber, this.backlogGroupPartNum, this.id).then(response => {
if (response.data[0].result === '1') {
this.searchTable11()
this.dialogVisible4 = false
this.$message.success('操作成功')
} else { this.$message.error('操作失败') }
})
},
useInventory(row) { // 使用滞货
this.useNumber = 0
row.滞货数量 < row.待询价数量 ? this.maxUseNumber = Number(row.滞货数量) : this.maxUseNumber = Number(row.待询价数量)
this.backlogMaterialNum = row.物料流水号
this.backlogGroupPartNum = row.组件零件流水号
this.dialogVisible4 = true
},
filterHandler0(value, row) { // 筛选备注
return row['备注'].trim() === value
},
filterHandler(value, row) { // 筛选供货商
return row['供货商'].trim() === value
},
filterSource(value, row) {
return Number(row['零件类型']) === Number(value)
},
unInquiry(row) {
return parseInt(row.询价状态编号) === 1
},
inquiry(row) {
return parseInt(row.询价状态编号) === 3 && parseInt(row.采购状态编号) === 1
},
approval(row) {
return parseInt(row.询价状态编号) !== 1 && parseInt(row.采购状态编号) === 2
},
purchased(row) {
return parseInt(row.询价状态编号) !== 1 && parseInt(row.采购状态编号) === 3
},
editing(row) {
return Number(row.离线合同状态) === 1
},
purchasing(row) {
return Number(row.离线合同状态) === 2 && Number(row.总采购数量) > Number(row.总到货数量)
},
arrival(row) {
return Number(row.总采购数量) <= Number(row.总到货数量) && Number(row.总采购数量) !== 0
},
useqrcode(contractNum) {
const opts = {
errorCorrectionLevel: 'H',
type: 'image/jpeg',
rendererOpts: {
quality: 0.3
}
}
QRCode.toDataURL(contractNum, opts, function(err, url) {
if (err) throw err
const img = document.getElementById('img')
img.src = url
})
},
fetchData() {
initProject().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.project.push({
label: response.data[i].项目名称,
value: response.data[i].项目流水号
})
}
})
},
tabClick(tab) {
console.log(tab.name, 1111)
if (tab.name === '外购件') {
this.tabName = '外购件'
this.searchTable11()
} else if (tab.name === '标准件') {
this.tabName = '标准件'
// this.searchTable11()
} else if (tab.name === '基本件') {
this.tabName = '基本件'
this.searchTable12()
} else {
this.tabName = '仓库'
// this.searchTable22()
}
},
searchTable2() { // 查询离线合同列表
this.offlineContract ? this.check3 = 1 : this.check3 = 0
this.supplierName0 ? this.check4 = 1 : this.check4 = 0
this.loading3 = true
this.tableData3 = []
searchOfflineContract(this.pageCurrent2, this.pageSize2, this.check3, this.offlineContract, this.check4, this.supplierName0).then(response => {
console.log(response.data.rows, 99)
this.tableData2 = response.data.rows
this.total2 = response.data.total
this.loading3 = false
})
},
handleSizeChange2(val) { // 离线合同列表分页
this.pageSize2 = val
this.searchTable2()
},
handleCurrentChange2(val) { // 离线合同列表分页
this.pageCurrent2 = val
this.searchTable2()
},
changeNumber(row) {
changeNum(row.物料流水号, row.使用库存数, row.机床流水号, row.组件零件流水号, row.零件数量).then(response => {
if (response.data[0].result === '1') {
this.$message.success('使用成功')
this.searchTable11()
} else {
this.$message.success('使用失败')
}
})
},
addOfflineContract() { // 创建离线合同
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
}
this.title2 = '创建离线合同'
getBillNum().then(response => { // 查询询价单号
this.form2.离线合同编号 = response.data[0].单号
this.form2.离线合同名称 = ''
this.form2.供应商流水号 = ''
this.form2.供应商名称 = ''
this.form2.规定到货时间 = ''
this.form2.离线合同备注 = '付款方式:;付款时间:;到货时间:;开票信息:;其他说明:;'
this.dialogVisible2 = true
})
},
getSupplier1() {
searchSupplier1(0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '', 0, '').then(response => {
for (let i = 0; i < response.data.length; i++) {
this.supplierNames.push({
label: response.data[i].供应商名称,
value: response.data[i].供应商流水号
})
}
})
},
submitAddOfflineContract() { // 新建离线合同
this.$refs['form2'].validate((valid) => {
if (valid) {
const numGroup1 = [] // 空数组,放现有的询价单号
searchOfflineContract2().then(response => { // 先查询判断是否存在
for (let i = 0; i < response.data.length; i++) {
numGroup1.push(response.data[i].离线合同编号)
}
}).then(() => {
if (numGroup1.indexOf(this.form2.离线合同编号) !== -1) {
this.$message.error('该离线合同编号已存在')
} else {
addOfflineContract(this.form2.离线合同编号, this.form2.离线合同名称, this.form2.供应商流水号, this.id, this.form2.规定到货时间, this.form2.离线合同备注).then(response => {
if (response.data[0].result === '1') {
this.$message.success('新建离线合同成功')
this.offlineContract = this.form2.离线合同编号
this.searchTable2(this.offlineContract)
this.dialogVisible2 = false
} else { this.$message.error('新建离线合同失败') }
})
}
})
} else {
console.log('error submit!!')
return false
}
})
},
editOfflineContract(row) {
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
}
this.title2 = '编辑离线合同'
this.form2.离线合同流水号 = row.离线合同流水号
this.form2.离线合同编号 = row.离线合同编号
this.form2.离线合同名称 = row.离线合同名称
this.form2.供应商流水号 = parseInt(row.供应商流水号)
this.form2.供应商名称 = row.供应商名称
this.form2.规定到货时间 = row.规定到货时间
this.form2.离线合同备注 = row.离线合同备注
this.dialogVisible2 = true
},
submitEditOfflineContract() {
this.$refs['form2'].validate((valid) => {
if (valid) {
const numGroup1 = [] // 空数组,放现有的离线合同号
const numGroup2 = [] // 空数组,放现有的离线合同流水号
searchOfflineContract2().then(response => { // 先查询判断是否存在
for (let i = 0; i < response.data.length; i++) {
numGroup1.push(response.data[i].离线合同编号)
numGroup2.push(response.data[i].离线合同流水号)
}
}).then(() => {
if (numGroup1.indexOf(this.form2.离线合同编号) !== -1 && numGroup1.indexOf(this.form2.离线合同编号) !== numGroup2.indexOf(parseInt(this.form2.离线合同流水号))) {
this.$message.error('该离线合同编号已存在')
} else {
editOfflineContract(this.form2.离线合同流水号, this.form2.离线合同编号, this.form2.离线合同名称, this.form2.供应商流水号, this.id, this.form2.规定到货时间, this.form2.离线合同备注).then(response => {
if (response.data[0].result === '1') {
this.$message.success('修改离线合同成功')
this.searchTable2()
this.dialogVisible2 = false
} else { this.$message.error('修改离线合同失败') }
})
}
})
} else {
console.log('error submit!!')
return false
}
})
},
deleteOfflineContract(row) { // 删除离线合同
this.$confirm('确定删除该合同?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteOfflineContract(row.离线合同流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('删除成功')
this.searchTable2()
this.disable = true
searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data
this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
})
})
} else { this.$message.error('数据占用,删除失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
})
})
},
searchSupplier() { // 查询创立日期和注册资本大于符合条件的数据
this.supplierName ? this.supplierCheck1 = 1 : (this.supplierCheck1 = 0, this.supplierName = '')
this.enterpriseNature ? this.supplierCheck2 = 1 : (this.supplierCheck2 = 0, this.enterpriseNature = '')
this.createDate ? this.supplierCheck3 = 1 : (this.supplierCheck3 = 0, this.createDate = '')
this.registeredCapital ? this.supplierCheck4 = 1 : (this.supplierCheck4 = 0, this.registeredCapital = '')
this.taxNum ? this.supplierCheck5 = 1 : (this.supplierCheck5 = 0, this.taxNum = '')
this.EMail ? this.supplierCheck6 = 1 : (this.supplierCheck6 = 0, this.EMail = '')
this.address ? this.supplierCheck7 = 1 : (this.supplierCheck7 = 0, this.address = '')
this.account ? this.supplierCheck8 = 1 : (this.supplierCheck8 = 0, this.account = '')
this.openingBank ? this.supplierCheck9 = 1 : (this.supplierCheck9 = 0, this.openingBank = '')
this.phone ? this.supplierCheck10 = 1 : (this.supplierCheck10 = 0, this.phone = '')
this.fax ? this.supplierCheck11 = 1 : (this.supplierCheck11 = 0, this.fax = '')
this.goodTime ? this.supplierCheck12 = 1 : (this.supplierCheck12 = 0, this.goodTime = '')
searchSupplier(this.supplierCheck1, this.supplierName, this.supplierCheck2, this.enterpriseNature, this.supplierCheck3, this.createDate, this.supplierCheck4, this.registeredCapital, this.supplierCheck5, this.taxNum, this.supplierCheck6, this.EMail, this.supplierCheck7, this.address, this.supplierCheck8, this.account, this.supplierCheck9, this.openingBank, this.supplierCheck10, this.phone, this.supplierCheck11, this.fax, this.supplierCheck12, this.goodTime).then(response => {
this.tableData01 = response.data
})
},
showSupplierDetail(row) {
this.form2.供应商流水号 = row.供应商流水号
this.form2.供应商名称 = row.供应商名称
this.supplierValue = row.供应商流水号
this.supplierName = row.供应商名称
this.enterpriseNature = row.企业性质
this.createDate = row.创立日期
this.registeredCapital = row.注册资本
this.taxNum = row.税号
this.EMail = row.电子信箱
this.address = row.地址
this.account = row.帐号
this.openingBank = row.开户行
this.phone = row.电话号码
this.fax = row.传真
this.goodTime = row.货期
},
emptySupplierDetail() {
this.supplierValue = ''
this.supplierName = ''
this.enterpriseNature = ''
this.createDate = ''
this.registeredCapital = ''
this.taxNum = ''
this.EMail = ''
this.address = ''
this.account = ''
this.openingBank = ''
this.phone = ''
this.fax = ''
this.goodTime = ''
},
submitSelectSupplier() { // 确定选择供应商
this.dialogVisible1 = false
},
searchTable3(row) { // 查询离线合同明细
this.stipulateArrivalTime = row.规定到货时间.split(' ')[0]
this.offlineContractNum = row.离线合同流水号
this.离线合同状态 = row.离线合同状态
this.loading4 = true
searchMateriel(this.offlineContractNum).then(response => {
console.log(response.data)
this.tableData3 = response.data
this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
})
this.loading4 = false
console.log(response.data.length, 1231231233)
})
this.arrival(row) || this.purchasing(row) ? this.disable = true : this.disable = false // 是否为编辑模式
},
getSummaries(param) { // 合计
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '总价'
} else if (index === 8) {
const values = data.map(item => Number(item['未税总额']))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return Number((prev + curr).toFixed(2))
} else {
return Number((prev).toFixed(2))
}
}, 0)
sums[index] += ' 元'
} else {
sums[index] = 'N/A'
}
} else if (index === 9) {
const values = data.map(item => Number(item['含税总额']))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return Number((prev + curr).toFixed(2))
} else {
return Number((prev).toFixed(2))
}
}, 0)
sums[index] += ' 元'
} else {
sums[index] = 'N/A'
}
}
})
return sums
},
addMateriel() { // 将物料选入离线合同
if (!this.offlineContractNum) {
this.$message.warning('请选择离线合同')
} else if (Number(this.离线合同状态) !== 1) {
this.$message.warning('请选择可编辑的离线合同')
} else if (this.materielNumGroup.length === 0) {
this.$message.warning('请勾选物料')
} else {
addMateriel(this.offlineContractNum, this.groupPartNumGroup, this.groupBasicPartNumGroup, this.materielNumGroup, this.idNumGroup, this.NumGroup).then(response => {
if (response.data[0].result === '1') {
this.$message.success('选入成功')
if (this.tabName === '外购件' || this.tabName === '标准件') {
this.searchTable11()
} else if (this.tabName === '基本件') {
this.searchTable12()
} else {
this.searchTable22()
}
searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data
this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
})
})
} else { this.$message.error('选入失败') }
})
}
},
deleteMateriel(row) { // 移除物料
this.$confirm('确定移除该物料?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
console.log(row.离线合同明细流水号, 1111)
deleteMateriel(row.离线合同明细流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('移除成功')
searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data
this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
})
})
if (this.tabName === '外购件' || this.tabName === '标准件') {
this.searchTable11()
} else if (this.tabName === '基本件') {
this.searchTable12()
} else if (this.tabName === '仓库') {
this.searchTable22()
}
} else { this.$message.error('移除失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消移除'
})
})
},
saveContract() {
console.log(11111)
this.totalPrice = 0
this.partGroup = []
this.numGroup = []
this.priceGroup = []
const dateGroup = []
const remarkGroup = []
for (let i = 0; i < this.tableData3.length; i++) {
this.totalPrice += this.tableData3[i].数量 * this.tableData3[i].单价
this.partGroup.push(this.tableData3[i].离线合同明细流水号)
this.numGroup.push(this.tableData3[i].数量)
this.hasTax === '含税' ? this.priceGroup.push(this.tableData3[i].单价) : this.priceGroup.push(this.tableData3[i].未税单价 * (1 + this.taxRate))
dateGroup.push(this.tableData3[i].交货期要求)
remarkGroup.push(this.tableData3[i].备注)
}
saveOfflineContact(this.offlineContractNum, this.totalPrice, this.partGroup, this.numGroup, this.priceGroup, dateGroup, remarkGroup, this.taxRate * 100).then(response => {
if (response.data[0].result !== '1') {
this.$message.error('离线合同保存失败')
// this.$message.success('离线合同保存成功')
// this.searchTable2()
// searchMateriel(this.offlineContractNum).then(response => {
// this.tableData3 = response.data
// this.tableData3.map(v => {
// this.$set(v, '未税总额', 0)
// this.$set(v, '含税总额', 0)
// !v.单价 ? v.单价 = v.参考价格 : v.单价
// this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
// })
// })
}
})
// this.$confirm('确定保存合同?', '提示', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
// }).catch(() => {
// this.$message({
// type: 'info',
// message: '已取消操作'
// })
// })
},
doneOfflineContact() { // 生成离线合同
if (this.tableData3.length === 0) {
this.$message.error('无法生成空合同,请先选入物料!')
} else {
let judge = true
this.tableData3.map(v => {
judge = judge && v.数量
})
if (judge) {
this.$confirm('确定生成合同?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.totalPrice = 0
this.partGroup = []
this.numGroup = []
this.priceGroup = []
const dateGroup = []
const remarkGroup = []
for (let i = 0; i < this.tableData3.length; i++) {
this.totalPrice += this.tableData3[i].数量 * this.tableData3[i].单价
this.partGroup.push(this.tableData3[i].离线合同明细流水号)
this.numGroup.push(this.tableData3[i].数量)
this.hasTax === '含税' ? this.priceGroup.push(this.tableData3[i].单价) : this.priceGroup.push(this.tableData3[i].未税单价 * (1 + this.taxRate))
dateGroup.push(this.tableData3[i].交货期要求)
remarkGroup.push(this.tableData3[i].备注)
}
doneOfflineContact(this.offlineContractNum, this.totalPrice, this.partGroup, this.numGroup, this.priceGroup, dateGroup, remarkGroup, this.taxRate * 100).then(response => {
if (response.data[0].result === '1') {
this.$message.success('离线合同生成成功')
this.searchTable2()
this.tableData3 = []
// searchMateriel(this.offlineContractNum).then(response => {
// this.tableData3 = response.data
// this.tableData3.map(v => {
// this.$set(v, '未税总额', 0)
// this.$set(v, '含税总额', 0)
// !v.单价 ? v.单价 = v.参考价格 : v.单价
// this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
// })
// this.disable = true // 是否为编辑模式
// })
} else { this.$message.error('离线合同生成失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
} else {
this.$message.error('数量不正确')
}
}
},
exportExcel(row) {
this.$confirm('确定打印该合同?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
const children = document.getElementsByClassName('tableData')
const parent = document.getElementsByClassName('offlineContract')[0]
if (children.length !== 0) {
for (let i = children.length - 1; i >= 0; i--) {
parent.removeChild(children[i])
}
}
const tr = []
let length = 0
this.tableData3.length < 15 ? length = 15 : length = this.tableData3.length
for (let i = 0; i < length; i++) {
tr[i] = document.createElement('tr')
tr[i].setAttribute('class', 'tableData')
tr[i].innerHTML = `<td style="height: 40px"/><td colspan="2" style="height: 40px"/><td style="height: 40px"/><td colspan="2" style="height: 40px"/><td style="height: 40px"/><td style="height: 40px"/><td style="height: 40px"/><td colspan="2" style="height: 40px"/><td style="height: 40px"/><td colspan="2" style="height: 40px"/>`
$('#tablehead').after(tr[i])
}
let total = 0
for (let j = 0; j < this.tableData3.length; j++) {
document.getElementsByClassName('tableData')[j].children[0].innerHTML = j + 1
document.getElementsByClassName('tableData')[j].children[1].innerHTML = this.tableData3[j].物料名称 ? this.tableData3[j].物料名称 : this.tableData3[j].零件名称
document.getElementsByClassName('tableData')[j].children[2].innerHTML = this.tableData3[j].物料规格 ? this.tableData3[j].物料规格 : this.tableData3[j].规格 ? this.tableData3[j].规格 : ''
document.getElementsByClassName('tableData')[j].children[3].innerHTML = this.tableData3[j].物料型号 ? this.tableData3[j].物料型号 : this.tableData3[j].零件图号
document.getElementsByClassName('tableData')[j].children[4].innerHTML = this.tableData3[j].数量
document.getElementsByClassName('tableData')[j].children[5].innerHTML = this.tableData3[j].单价
document.getElementsByClassName('tableData')[j].children[6].innerHTML = this.tableData3[j].计量单位
document.getElementsByClassName('tableData')[j].children[7].innerHTML = (this.tableData3[j].数量 * this.tableData3[j].单价).toFixed(2)
document.getElementsByClassName('tableData')[j].children[8].innerHTML = this.tableData3[j].交货期要求
document.getElementsByClassName('tableData')[j].children[9].innerHTML = this.tableData3[j].备注
total += Number(this.tableData3[j].数量 * this.tableData3[j].单价)
}
total = total.toFixed(2)
document.getElementById('contractNum').innerHTML = row.离线合同编号
document.getElementById('contractName').innerHTML = row.离线合同名称
document.getElementById('supplier').innerHTML = row.供应商名称
document.getElementById('buyer').innerHTML = row.采购员
document.getElementById('total').innerHTML = total
document.getElementById('remark').innerHTML = row.离线合同备注
$('#qrCode').html(`<img id="img" style="display: block;margin: 0 auto">`)
this.useqrcode(row.离线合同流水号) // 显示二维码
}).then(() => {
const htmlNode = $('#offlineContract').html()
const body = $('body').attr('style', 'padding: 20px;margin: 0 auto;display: block;width: 800px;background: #fff;')
body.children().hide()
const printNode = $(htmlNode)
body.append(printNode)
window.print()
body.removeAttr('style')
body.children().not('script').show()
body.children().not('#app').hide()
printNode.remove()
}).catch(res => {
console.log(res)
this.$message({
type: 'info',
message: '已取消操作'
})
})
},
handleSelectionChange1(val) { // 标准件和外购件多选
this.标准件和外购件流水号 = []
this.基本件流水号 = []
this.groupPartNumGroup = []
this.groupBasicPartNumGroup = []
this.materielNumGroup = []
this.idNumGroup = []
this.NumGroup = []
for (let i = 0; i < val.length; i++) {
this.标准件和外购件流水号.push(val[i].标准件和外购件流水号)
this.基本件流水号.push(val[i].基本件流水号)
this.groupPartNumGroup.push(val[i].组件零件流水号)
this.groupBasicPartNumGroup.push(val[i].组件零件基本件流水号)
this.materielNumGroup.push(val[i].物料流水号)
this.idNumGroup.push(val[i].id)
this.NumGroup.push(val[i].待采购数量)
}
console.log(this.materielNumGroup, 222)
},
selectable(row, index) { // 控制某行是否可选
return Number(row.采购状态编号) < 3 && Number(row.是否确认) === 1 // 未采购&&确认物料修改
},
searchTable11() { // 查询外购件列表
let check1, check5, check7
this.loading1 = true
this.materialName ? check1 = 1 : check1 = 0
this.machineValue ? check5 = 1 : check5 = 0
this.startTime ? check7 = 1 : (check7 = 0, this.startTime = '')
if (this.tabName === '外购件') { this.partType = 2 }
if (this.tabName === '标准件') { this.partType = 1 }
searchMaterial1(this.pageCurrent11, this.pageSize11, check1, this.materialName, this.id, check5, this.machineValue, check7, this.startTime[0], this.startTime[1]).then(response => {
this.tableData00 = response.data.rows
this.total11 = response.data.total
const remark = []
const supplier = []
this.remarkFilters = []
this.supplierFilters = []
response.data.rows.map(v => {
if (v.备注 === null) { v.备注 = '' }
if (v.供货商 === null) { v.供货商 = '' }
if (!remark.includes(v.备注)) {
remark.push(v.备注)
this.remarkFilters.push({ text: v.备注, value: v.备注 })
}
if (!supplier.includes(v.供货商)) {
supplier.push(v.供货商)
this.supplierFilters.push({ text: v.供货商, value: v.供货商 })
}
})
this.loading1 = false
}).catch(() => {
this.loading1 = false
})
},
handleSizeChange11(val) { // 标准件和外购件列表分页
this.pageSize11 = val
this.pageCurrent11 = 1
this.searchTable11()
},
handleCurrentChange11(val) { // 标准件和外购件列表分页
this.pageCurrent11 = val
this.searchTable11()
},
// 查询基本件列表
searchTable12() {
let check1, check2, check3, check4, check5, check6, check7
this.partNum ? check1 = 1 : check1 = 0
this.partName ? check2 = 1 : check2 = 0
this.partSpec ? check3 = 1 : check3 = 0
this.projectValue ? check4 = 1 : check4 = 0
this.machineValue ? check5 = 1 : check5 = 0
this.groupValue ? check6 = 1 : check6 = 0
this.startTime ? check7 = 1 : (check7 = 0, this.startTime = '')
this.loading2 = true
searchPart(this.pageCurrent12, this.pageSize12, this.materialStatusValue[this.materialStatusValue.length - 1], check1, this.partNum, check2, this.partName, check3, this.partSpec, this.id, check4, this.projectValue, check5, this.machineValue, check6, this.groupValue, check7, this.startTime[0], this.startTime[1]).then(response => {
this.tableData12 = response.data.rows
this.total12 = response.data.total
const remark = []
const supplier = []
this.remarkFilters = []
this.supplierFilters = []
console.log(response.data.rows, 111)
response.data.rows.map(v => {
if (!remark.includes(v.备注)) {
remark.push(v.备注)
supplier.push(v.供货商)
this.remarkFilters.push({ text: v.备注, value: v.备注 })
this.supplierFilters.push({ text: v.供货商, value: v.供货商 })
}
})
this.loading2 = false
}).catch(() => {
this.loading2 = false
})
},
handleSizeChange12(val) { // 基本件列表分页
this.pageSize12 = val
this.pageCurrent12 = 1
this.searchTable12()
},
handleCurrentChange12(val) { // 基本件列表分页
this.pageCurrent12 = val
this.searchTable12()
},
searchTable22() {
let check1
this.materialName ? check1 = 1 : check1 = 0
this.loading2 = true
searchMaterial22(check1, this.materialName, this.pageCurrent22, this.pageSize22).then(response => {
console.log(response.data, 3333)
this.tableData22 = response.data.result
this.total22 = parseInt(response.data.output[0].ItemCount)
const supplier = []
this.remarkFilters = []
this.supplierFilters = []
response.data.result.map(v => {
if (v.供货商 === null) { v.供货商 = '' }
if (!supplier.includes(v.供货商)) {
supplier.push(v.供货商)
this.supplierFilters.push({ text: v.供货商, value: v.供货商 })
}
})
this.loading2 = false
}).catch(() => {
this.loading2 = false
})
},
handleSizeChange22(val) { // 仓库表分页
this.pageSize22 = val
this.pageCurrent22 = 1
this.searchTable22()
},
handleCurrentChange22(val) { // 仓库表分页
this.pageCurrent22 = val
this.searchTable22()
}
}
}
</script>
<style scoped>
.offlineContract td{
height: 40px;
text-align: center;
}
.el-card{
margin-bottom: 1px;
}
.el-date-editor{
width:150px;
margin-right: 10px;
}
span{
margin: 10px 0 10px 10px;
}
.el-tag{
margin: 0
}
.searchForm .el-form-item{
margin-bottom: 5px;
}
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 5px;
}
.el-select{
width:150px;
margin-right: 10px;
}
.el-input{
width:150px;
margin-right: 10px;
}
.el-cascader{
width:150px;
margin-right: 10px;
}
</style>
<style>
.el-table .MistyRose {
background: #9BD7FC!important;
}
</style>