123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899 |
- <!-- 首序外协 -->
- <template>
- <el-drawer title="首序外协信息" :with-header="false" v-model="visible" direction="rtl" size="100%">
- <div class="form-container column-container">
- <div class="form-btns-container">
- <span class="title-label">
- <el-icon>
- <Document />
- </el-icon>
- <span>外协单信息</span>
- </span>
- <el-button v-show="editStatus && form.isSubmit == 1" type="primary" icon="Download" @click="handleExport"
- v-hasPermi="['business:firstOutsource:export']">导出</el-button>
- <el-button v-show="editStatus && form.isSubmit == 1" type="warning" icon="Download" @click="handlePrint"
- v-hasPermi="['business:firstOutsource:export']">
- 打印
- </el-button>
- <el-button v-if="editStatus" type="primary" icon="Finished" @click="handleSubmit">保存</el-button>
- <el-button v-if="editStatus && form.isSubmit == 1" type="info" icon="Calendar"
- @click="handleViewRecords">历史记录</el-button>
- <div class="close-btn" @click="cancel">
- <i class="fa fa-times" aria-hidden="true" />
- <!-- <span>关闭</span> -->
- </div>
- </div>
- <el-form ref="formRef" class="master-container" :model="form" v-loading="loading" :rules="rules"
- label-width="120px">
- <el-row :gutter="20">
- <el-col :span="6">
- <el-form-item label="单据号" prop="formCode">
- <el-input v-if="editStatus" v-model="form.formCode" disabled placeholder="系统自动生成" />
- <span v-else>{{ form.formCode }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="表单日期" prop="formDate">
- <el-date-picker v-if="editStatus && hasReturnReceiptDetailFlag" :clearable="false" v-model="form.formDate"
- type="date" value-format="YYYY-MM-DD" placeholder="请选择表单日期" style="width: 100%">
- </el-date-picker>
- <span v-else>{{ parseTime(form.formDate, "{y}-{m}-{d}") }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="外协商名称" prop="supplierName">
- <el-input v-if="
- editStatus && form.isSubmit == 0 && hasReturnReceiptDetailFlag
- " v-model="form.supplierName" readonly placeholder="请输入外协商名称">
- <template #append>
- <el-button icon="Search" @click="handleShowDialogSuppliers" />
- </template>
- </el-input>
- <span v-else>{{ form.supplierName }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="false">
- <el-form-item label="运费单价" prop="freightPrice">
- <el-input-number v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.freightPrice" :min="0"
- :precision="2" controls-position="right" />
- <span v-else>{{ form.freightPrice }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6" v-if="false">
- <el-form-item label="运费总价" prop="freightAmount">
- <el-input-number v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.freightAmount" :min="0"
- :precision="2" controls-position="right" />
- <span v-else>{{ form.freightAmount }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="送货方式" prop="deliveryMethod">
- <el-select v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.deliveryMethod" placeholder="请选择"
- @change="handleChangeDeliveryMethod">
- <el-option v-for="dict in deliveryMethod" :key="dict.value" :label="dict.label" :value="dict.value" />
- </el-select>
- <span v-else>{{
- selectText(form.deliveryMethod, deliveryMethod)
- }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="带箱方式" prop="packagingMethod">
- <el-select v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.packagingMethod"
- placeholder="请选择" @change="handleChangePackagingMethod">
- <el-option v-for="dict in packagingMethod" :key="dict.value" :label="dict.label" :value="dict.value" />
- </el-select>
- <span v-else>{{
- selectText(form.packagingMethod, packagingMethod)
- }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="结算方式" prop="settlementType">
- <el-select v-if="editStatus && hasReturnReceiptDetailFlag" v-model="form.settlementType"
- placeholder="请选择">
- <el-option v-for="dict in settlementType" :key="dict.value" :label="dict.label" :value="dict.value" />
- </el-select>
- <span v-else>{{
- selectText(form.settlementType, settlementType)
- }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="备注" prop="remark">
- <el-input v-if="editStatus" v-model.trim="form.remark" placeholder="请输入备注" />
- <span v-else>{{ form.remark }}</span>
- </el-form-item>
- </el-col>
- <el-col :span="6">
- <el-form-item label="总箱数" prop="remark">
- <span>{{ totalCarriersNum }}</span>
- </el-form-item>
- </el-col>
- </el-row>
- </el-form>
- <!-- 渲染数据区 -->
- <div class="form-details-btns-container">
- <el-button v-show="editStatus" type="primary" icon="Plus" @click="handleShowDialogProducts"
- v-hasPermi="['business:firstOutsource:add']">
- 添加外协产品明细
- </el-button>
- <el-button v-show="editStatus" type="primary" icon="Plus" @click="handleChoiceFurnaceNoInfo()">
- 批量选择炉号
- </el-button>
- <el-button v-show="editStatus" :disabled="selections.length === 0" type="primary" icon="Plus"
- @click="handleShowMultiDialogProcesses">
- 批量选择工序
- </el-button>
- </div>
- <div class="el-table-container">
- <div class="el-table-inner-container">
- <el-table v-loading="loading" :data="form.details" size="small" border height="100%"
- @selection-change="handleSelectionChange">
- <el-table-column type="selection" align="center" width="48" />
- <el-table-column label="行号" type="index" align="center" width="48" />
- <el-table-column label="批次号" align="center" prop="lotCode" width="104" />
- <el-table-column label="产品描述" align="center" prop="productDescription" width="320" />
- <el-table-column label="图纸版本" width="80" prop="technologyVersion" align="center" />
- <el-table-column label="产品数" align="center" width="160" prop="productNum">
- </el-table-column>
- <el-table-column label="箱数" align="center" prop="newCarrierCount" width="100">
- <template #default="scope">
- <el-input-number v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" :min="0"
- v-model="scope.row.newCarrierCount" :step="1" step-strictly :controls="false" placeholder="箱数"
- @blur="handleCarrierNumChange" />
- <span v-else>{{ scope.row.newCarrierCount }}</span>
- </template>
- </el-table-column>
- <el-table-column label="炉号" align="center" prop="" width="150">
- <template #default="scope">
- <el-button link type="primary" icon="Refresh" v-if="editStatus"
- @click="handleChoiceFurnaceNoInfo(scope.row)">
- {{
- scope.row.furnaceNoInfo != null
- ? scope.row.furnaceNoInfo.furnaceNumber
- : "选择炉号"
- }}
- </el-button>
- <span v-else>{{ scope.row.furnaceNoInfo.furnaceNumber }}</span>
- </template>
- </el-table-column>
- <el-table-column label="标识" width="300" align="center">
- <template #default="scope">
- <el-tag v-if="scope.row.isWaste == 1" class="spacing" type="danger">{{ "批废" }}</el-tag>
- <el-tag v-if="scope.row.isAmend == 1" class="spacing" type="danger">{{ "工艺修改" }}</el-tag>
- <el-tag v-if="scope.row.isWasteRecycling == 1" class="spacing" type="primary">{{ "废品回用" }}</el-tag>
- <el-tag v-if="scope.row.isSuperaddition == 1" class="spacing" type="warning">{{ "追增" }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="外协工序" align="center" prop="processNames" width="320">
- <template #default="scope">
- <el-input v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" v-model="scope.row.processNames"
- readonly placeholder="请选择工序">
- <template #append>
- <el-button icon="Search" @click="handleShowDialogProcesses(scope.row)" />
- </template>
- </el-input>
- <span v-else>{{ scope.row.processNames }}</span>
- </template>
- </el-table-column>
- <el-table-column label="备注" align="center" prop="remark" width="300">
- <template #default="scope">
- <el-input v-if="editStatus && scope.row.hasReturnReceiptDetailFlag" v-model="scope.row.remark"
- placeholder="备注" />
- <span v-else>{{ scope.row.remark }}</span>
- </template>
- </el-table-column>
- <el-table-column v-if="editStatus" label="操作" align="center" fixed="right"
- class-name="small-padding fixed-width" width="64">
- <template #default="scope">
- <el-button circle type="danger" v-if="scope.row.hasReturnReceiptDetailFlag" icon="Delete"
- @click="handleDelete(scope.$index)" v-hasPermi="['business:firstOutsource:remove']" />
- </template>
- </el-table-column>
- </el-table>
- </div>
- </div>
- </div>
- <!-- 外协商选择 -->
- <dialog-suppliers ref="dialogSuppliersRef" :single-selected="handleSingleSelectedSupplier" />
- <!-- 投产单选择 -->
- <dialog-products ref="dialogProductsRef" :supplier-id="form.supplierId"
- :multiple-selected="handleMultipleSelectedProducts" />
- <!-- 工序选择 -->
- <dialog-processes ref="dialogProcessesRef" :multiple-selected="handleMultipleSelectedProcesses" />
- <!-- 批量工序选择 -->
- <dialog-multiProcess ref="dialogMultiProcessRef" :multiple-selected="handleMultipleSetProcesses" />
- <!-- 新箱号选择 -->
- <DialogFurnaceNoInfo ref="dialogFurnaceNoInfoRef" :singleSelected="handleSingleSelectFurnaceNoInfo" />
- <!-- 历史记录弹窗 -->
- <dialog-outsourced-records ref="dialogOutsourcedRecordsRef" />
- <!-- 收回明细带回 -->
- <!-- <form-details-recycling ref="formDetailsRecyclingRef" :singleSelected="handleSingleSelectedRecycling"/> -->
- </el-drawer>
- </template>
- <script setup>
- import {
- getOrder,
- getFirstOrder,
- saveOrder,
- carrierForOutsource,
- submitOrder,
- exportOutsource,
- printOutsource,
- submitDetails,
- submitDetailsOnFirst,
- getLotByProductionPlanSub,
- } from "@/api/business/outsourcedOrder";
- import DialogFurnaceNoInfo from "./DialogFurnaceNoInfo";
- import dialogSuppliers from "./DialogSuppliers";
- import dialogProducts from "./DialogProducts";
- import dialogProcesses from "./DialogProcesses";
- import dialogMultiProcess from "./multiSingleChangeDialog";
- import dialogOutsourcedRecords from "./DialogOutsourcedRecords";
- // import FormDetailsRecycling from "./detailsRecyclingForm";
- const { proxy } = getCurrentInstance();
- /** 父组件传参 */
- const props = defineProps({
- getList: {
- type: Function,
- default: () => { },
- },
- deliveryMethod: {
- type: Array,
- default: [],
- },
- settlementType: {
- type: Array,
- default: [],
- },
- packagingMethod: {
- type: Array,
- default: [],
- },
- });
- const { getList, deliveryMethod, packagingMethod, settlementType } =
- toRefs(props);
- /** 字典数组区 */
- /** 表单抽屉 页变量 */
- const loading = ref(false);
- const multiple = ref(true);
- const visible = ref(false);
- const editStatus = ref(true);
- const hasReturnReceiptDetailFlag = ref(true);
- // 创建一个引用来存储最后一次请求的时间戳
- const lastRequestTimestamp = ref(0);
- const totalCarriersNum = ref(0);
- import { ElLoading } from "element-plus";
- import { file } from "jszip";
- const detailInfo = ref({});
- const loadingCarrier = ref(false);
- const carriers = ref([]);
- const webHost = import.meta.env.VITE_APP_BASE_API;
- const form = ref({});
- const selections = ref([]);
- // const formatDetails = ref([])
- const currentDetail = ref({});
- const dialogFurnaceNoInfoRef = ref(null);
- let submitValue = 0
- const rules = {
- supplierName: [
- { required: true, message: "外协商名称不能为空", trigger: "change" },
- ],
- };
- /*********************** 方法区 ****************************/
- /** 导出按钮操作 */
- function handleExport() {
- exportOutsource({ id: form.value.id });
- }
- /** 打印按钮操作 */
- function handlePrint() {
- printOutsource({ id: form.value.id });
- }
- /** 打开抽屉 */
- function open(row) {
- reset();
- totalCarriersNum.value = 0;
- visible.value = true;
- if (row) {
- editStatus.value = true;
- hasReturnReceiptDetailFlag.value = true;
- console.log(row);
- detailInfo.value = row;
- form.value.id = row.id;
- getForm();
- } else {
- editStatus.value = true;
- hasReturnReceiptDetailFlag.value = true;
- }
- }
- /** 查询表单信息 */
- function getForm() {
- loading.value = true;
- getFirstOrder(form.value.id).then((response) => {
- form.value = response.data;
- //如果发出单明细里收回单,主表除了备注之外不能编辑
- form.value.details.forEach((item) => {
- item.hasReturnReceiptDetailFlag = true;
- if (
- item.returnReceiptDetailList &&
- item.returnReceiptDetailList.length > 0
- ) {
- hasReturnReceiptDetailFlag.value = false;
- }
- if (
- item.returnReceiptDetailList &&
- item.returnReceiptDetailList.length > 0 &&
- item.returnReceiptDetailList[0].status == 1
- ) {
- item.hasReturnReceiptDetailFlag = false;
- }
- });
- form.value.details.forEach((item) => {
- item.editStatus = false;
- totalCarriersNum.value +=
- item.newCarrierCount == null ? 0 : item.newCarrierCount;
- });
- editStatus.value = form.value.isSubmit == 1;
- if (!detailInfo.value.flag) {
- editStatus.value = false;
- console.log(editStatus.value);
- }
- console.log(hasReturnReceiptDetailFlag.value);
- loading.value = false;
- });
- }
- //改变带箱方式
- function handleChangePackagingMethod() {
- totalCarriersNum.value = 0;
- if (!editStatus) {
- if (form.value.packagingMethod == 1 && form.value.details.length > 0) {
- form.value.details.forEach((item) => {
- item.newCarriers = [];
- item.carrierIds = [];
- item.carriers = carriers.value;
- });
- }
- if (form.value.packagingMethod == 0 && form.value.details.length > 0) {
- form.value.details.forEach((item) => {
- item.carriers = carriers.value;
- item.newCarriers = [];
- item.carrierIds = [];
- item.newCarriers.push(
- ...item.originalCarrierList.map((v) => ({
- id: v.carrierId,
- code: v.carrierCode,
- }))
- );
- item.carriers.push(
- ...item.originalCarrierList.map((v) => ({
- value: v.carrierId,
- label: v.carrierCode,
- }))
- );
- item.carrierIds = item.originalCarrierList.map((info) => {
- return info.carrierId;
- });
- });
- }
- } else {
- form.value.details.forEach((item) => {
- console.log(item.editStatus);
- if (item.editStatus) {
- item.newCarriers = [];
- item.carrierIds = [];
- item.carriers = carriers.value;
- }
- });
- }
- console.log(form.value.details);
- for (let i = 0; i < form.value.details.length; i++) {
- console.log(form.value.details);
- totalCarriersNum.value +=
- form.value.details[i].newCarrierCount == null
- ? 0
- : form.value.details[i].newCarrierCount;
- }
- }
- //改变送货方式
- function handleChangeDeliveryMethod() {
- if (form.value.deliveryMethod == 1) {
- form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
- } else {
- form.value.freightAmount = 0.0;
- }
- }
- //打开历史记录弹窗
- function handleViewRecords() {
- proxy.$refs.dialogOutsourcedRecordsRef.open(form.value.id);
- }
- function selectText(value, data) {
- if (value) {
- return data.filter((item) => item.value == value)[0].label;
- }
- }
- /** 取消按钮 */
- function cancel() {
- visible.value = false;
- // reset();
- }
- const handleDelete = (index) => {
- totalCarriersNum.value -=
- form.value.details[index].carrierNum == null
- ? 0
- : form.value.details[index].carrierNum;
- if (form.value.deliveryMethod == 1) {
- form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
- } else {
- form.value.freightAmount = 0.0;
- }
- form.value.details.splice(index, 1);
- handleCarrierNumChange();
- };
- /** 表单重置 */
- function reset() {
- // console.log(proxy.parseTime(new Date(), "{y}-{m}-{d}"))
- form.value = {
- id: null,
- tenantId: null,
- formCode: null,
- formDate: proxy.parseTime(new Date(), "{y}-{m}-{d}"),
- supplierId: "0",
- supplierName: "",
- deliveryMethod: "0",
- freightPrice: 0.0,
- freightAmount: 0.0,
- packagingMethod: "0",
- remark: null,
- details: [],
- isSubmit: 0,
- isFirstProcess: 1,
- };
- proxy.resetForm("formRef");
- }
- /** 保存 */
- function saveFrom() {
- if (!form.value.details || form.value.details.length == 0) {
- proxy.$modal.msgError("请添加产品明细");
- return;
- }
- proxy.$refs["formRef"].validate((valid) => {
- for (const item of form.value.details) {
- if (!item.processNames) {
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
- return;
- }
- }
- if (form.value.packagingMethod == 1) {
- console.log("form.value.details", form.value.details);
- for (const item of form.value.details) {
- if (item.newCarriers.length == 0) {
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
- return;
- }
- }
- }
- if (valid) {
- saveOrder(form.value).then((response) => {
- if (response.code == 200) {
- proxy.$modal.msgSuccess("保存成功");
- visible.value = false;
- getList.value();
- }
- });
- }
- });
- }
- /** 保存并提交 */
- function submitFrom() {
- console.log("from", form.value);
- proxy.$modal
- .confirm("是否确定提交,提交后不可修改,删除")
- .then(function () {
- return;
- })
- .then(() => {
- if (!form.value.details || form.value.details.length == 0) {
- proxy.$modal.msgError("请添加产品明细");
- return;
- }
- proxy.$refs["formRef"].validate((valid) => {
- for (const item of form.value.details) {
- if (!item.processNames) {
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
- return;
- }
- }
- if (form.value.packagingMethod == 1) {
- console.log("form.value.details", form.value.details);
- for (const item of form.value.details) {
- if (item.newCarriers.length == 0) {
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的新箱号");
- return;
- }
- }
- }
- if (valid) {
- console.log(form.value);
- submitOrder(form.value).then((response) => {
- proxy.$modal.msgSuccess("提交成功");
- visible.value = false;
- getList.value();
- });
- }
- });
- })
- .catch(() => { });
- }
- //5.29保存
- function handleSubmit() {
- if (form.value.isSubmit == 0) {
- proxy.$modal
- .confirm("是否确定保存,保存后外协商不可编辑!")
- .then(function () {
- return;
- })
- .then(() => {
- if (submitValue == 0) {
- submitValue++
- if (!form.value.details || form.value.details.length == 0) {
- proxy.$modal.msgError("请添加产品明细");
- submitValue = 0
- return;
- }
- proxy.$refs["formRef"].validate((valid) => {
- for (const item of form.value.details) {
- if (!item.processNames) {
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
- submitValue = 0
- return;
- }
- }
- // 判断是否有批次没有炉号
- const unfurnace = form.value.details.find(
- (v) => v.furnaceNoInfo == null
- );
- if (unfurnace != null) {
- proxy.$modal.msgError("请选择" + unfurnace.lotCode + "批次的炉号");
- submitValue = 0
- return;
- }
- if (totalCarriersNum.value == null || totalCarriersNum.value == 0) {
- proxy.$modal.msgError("请输入箱数");
- submitValue = 0
- return;
- }
- if (valid) {
- const currentTime = Date.now();
- // 检查是否已经过去了 2 秒
- // if (currentTime - lastRequestTimestamp.value < 2000) {
- // 如果在 2 秒 内已经有请求发出,那么不执行
- // return;
- // }
- lastRequestTimestamp.value = currentTime;
- console.log(form.value);
- // proxy.$modal.loading("正在保存...")
- const fillloading = ElLoading.service({
- lock: true,
- });
- console.log(fillloading)
- submitDetailsOnFirst(form.value).then((response) => {
- proxy.$modal.msgSuccess("提交成功");
- visible.value = false;
- getList.value();
- submitValue = 0
- fillloading.close()
- }).catch(err => {
- submitValue = 0
- fillloading.close()
- });
- } else {
- submitValue = 0
- }
- });
- }
- }).catch(_ => { });
- } else {
- if (!form.value.details || form.value.details.length == 0) {
- proxy.$modal.msgError("请添加产品明细");
- return;
- }
- proxy.$refs["formRef"].validate((valid) => {
- for (const item of form.value.details) {
- if (!item.processNames) {
- proxy.$modal.msgError("请选择" + item.lotCode + "批次的工序");
- return;
- }
- }
- // 判断是否有批次没有炉号
- const unfurnace = form.value.details.find((v) => v.furnaceNoInfo == null);
- if (unfurnace != null) {
- proxy.$modal.msgError("请选择" + unfurnace.lotCode + "批次的炉号");
- return;
- }
- if (totalCarriersNum.value == null || totalCarriersNum.value == 0) {
- proxy.$modal.msgError("请输入箱数");
- return;
- }
- if (valid) {
- // const currentTime = Date.now();
- // // 检查是否已经过去了 2 秒
- // if (currentTime - lastRequestTimestamp.value < 2000) {
- // // 如果在 2 秒 内已经有请求发出,那么不执行
- // return;
- // }
- // lastRequestTimestamp.value = currentTime;
- console.log(form.value);
- submitDetailsOnFirst(form.value).then((response) => {
- proxy.$modal.msgSuccess("提交成功");
- visible.value = false;
- getList.value();
- });
- }
- });
- }
- }
- /***************************** 外协商对话框相关 *****************************/
- // 打开外协商选择对话框
- const handleShowDialogSuppliers = () => {
- proxy.$refs.dialogSuppliersRef.open();
- };
- // 外协商选择带回
- const handleSingleSelectedSupplier = (data) => {
- console.log(data);
- form.value.supplierId = data.id;
- form.value.lossLimit = data.lossLimit;
- form.value.supplierName = data.name;
- // form.value.supplierCode = data.code
- form.value.supplierCode = data.mnemonicCode;
- form.value.deliveryMethod = data.deliveryMethod;
- form.value.freightPrice = data.freightPrice;
- form.value.settlementType = data.settlementType;
- if (form.value.deliveryMethod == 1) {
- form.value.freightAmount = form.value.freightPrice * totalCarriersNum.value;
- } else {
- form.value.freightAmount = 0.0;
- }
- };
- /***************************** 外协收回明细相关 *****************************/
- //打开收回明细表单
- function handleDetailsRecycling() {
- proxy.$refs.formDetailsRecyclingRef.open(row);
- }
- function handleSingleSelectedRecycling() { }
- /***************************** 产品对话框相关 *****************************/
- // 打开产品选择对话框
- const handleShowDialogProducts = () => {
- // const dayworkIds = form.value.details.map((item) => item.dayworkId);
- // console.log(dayworkIds);
- proxy.$refs.dialogProductsRef.open();
- };
- // 产品选择带回
- const handleMultipleSelectedProducts = (selection) => {
- // 获取所有批次信息
- const requestData = {
- planDetails: selection,
- supplierId: form.value.supplierId,
- supplierName: form.value.supplierName,
- masterId: form.value.id,
- };
- getLotByProductionPlanSub(requestData).then((res) => {
- // console.log(res)
- if (res.code === 200) {
- form.value.details.push(
- ...res.data
- .filter(
- (e) => form.value.details.findIndex((t) => t.lotId === e.lotId) < 0
- )
- .map((e) => ({ ...e, hasReturnReceiptDetailFlag: true }))
- );
- }
- });
- };
- /***************************** 外协工序对话框相关 *****************************/
- // 打开外协工序选择对话框
- const handleShowDialogProcesses = (row) => {
- currentDetail.value = row;
- proxy.$refs.dialogProcessesRef.open(row);
- };
- function handleShowMultiDialogProcesses() {
- if (selections.value.every((item) => item.isWaste == 1)) {
- proxy.$message.error("批废不能再进行操作");
- return;
- }
- //判断是否同产品、同计划、同工艺版本
- let isConsistent =
- selections.value.every(
- (item) => item.productionPlanDetailId === selections.value[0].productionPlanDetailId
- ) &&
- selections.value.every(
- (item) => item.technologyVersion === selections.value[0].technologyVersion
- ) &&
- selections.value.every(
- (item) => item.productId === selections.value[0].productId
- );
- if (!isConsistent) {
- proxy.$modal.msgError("请选择同产品、同计划、同工艺版本的数据");
- return;
- }
- //判断是否未修改过的批次
- isConsistent =
- selections.value.every((item) => item.isAmend == 0) &&
- selections.value.every((item) => item.isWaste == 0) &&
- selections.value.every((item) => item.isWasteRecycling == 0);
- if (!isConsistent) {
- proxy.$modal.msgError("只能选择标准工艺的数据进行批量操作");
- return;
- }
- console.log(selections.value)
- if (selections.value.filter(
- (item) => !item.hasReturnReceiptDetailFlag
- ).length > 0) {
- proxy.$modal.msgError("已经收回审核数据不能进行批量选择工序操作");
- return;
- }
- console.log(selections.value)
- proxy.$refs.dialogMultiProcessRef.open(selections.value)
- }
- // 工序选择带回
- const handleMultipleSelectedProcesses = (selection) => {
- const oldProcesses =
- currentDetail.value.processes == null
- ? []
- : [...currentDetail.value.processes];
- if (
- currentDetail.value.returnReceiptDetailList &&
- currentDetail.value.returnReceiptDetailList.length > 0 &&
- selection.findIndex(
- (e) => !oldProcesses.some((v) => v.technologicalProcessDetailId == e.id)
- ) >= 0
- ) {
- proxy.$modal.msgError("已收回批次不能添加新工序");
- return;
- }
- currentDetail.value.processes = [];
- console.log(selection);
- const processNames = selection
- .sort((a, b) => a.processStepNumber - b.processStepNumber)
- .map((item) => item.processAlias);
- // 使用join方法将数组转换为以逗号分隔的字符串
- let commaSeparatedString = processNames.join(",");
- currentDetail.value.processes = [];
- currentDetail.value.processNames = commaSeparatedString;
- selection.forEach((item) => {
- const newProcess = {
- processId: item.processId,
- processCode: item.processCode,
- processAlias: item.processAlias,
- processStepNumber: item.processStepNumber,
- technologicalProcessDetailId: item.id,
- };
- currentDetail.value.processes.push(newProcess);
- });
- };
- const handleMultipleSetProcesses = (selection) => {
- console.log(selections.value)
- console.log(form.value.details)
- for (let i = 0; i < selections.value.length; i++) {
- console.log(selections.value[i])
- let currentOriginal = form.value.details.filter(
- (item) => (item.lotId == selections.value[i].lotId)
- );
- console.log(currentOriginal)
- let flag = true;
- if (
- currentOriginal[0].returnReceiptDetailList &&
- currentOriginal[0].returnReceiptDetailList.length > 0
- ) {
- selection.forEach((item) => {
- if (
- currentOriginal[0].processes.findIndex(
- (info) => info.processStepNumber == item.processStepNumber
- ) < 0
- ) {
- flag = false;
- }
- });
- }
- if (flag) {
- const processNames = selection
- .sort((a, b) => a.processStepNumber - b.processStepNumber)
- .map((item) => item.processAlias);
- // 使用join方法将数组转换为以逗号分隔的字符串
- let commaSeparatedString = processNames.join(",");
- currentOriginal.processes = [];
- form.value.details.filter(
- (item) => (item.lotId == selections.value[i].lotId)
- )[0].processNames = commaSeparatedString;
- selection.forEach((item) => {
- const newProcess = {
- processId: item.processId,
- processCode: item.processCode,
- processAlias: item.processAlias,
- processStepNumber: item.processStepNumber,
- technologicalProcessDetailId: item.id,
- };
- currentOriginal.processes.push(newProcess);
- });
- form.value.details.filter(
- (item) => (item.lotId == selections.value[i].lotId)
- )[0].processes = currentOriginal.processes;
- console.log(form.value.details)
- } else {
- proxy.$modal.msgError("外协厂/德迈仕已收回,不可添加新工序");
- }
- }
- }
- function handleSelectionChange(selection) {
- selections.value = selection;
- }
- // 选择炉号
- const handleChoiceFurnaceNoInfo = (row) => {
- // 判断选择的产品是不是同一个
- const changeFurnaceNoInfo = row ? [row] : selections.value;
- let checkSame = true;
- changeFurnaceNoInfo.forEach((l) => {
- checkSame = checkSame && l.productId == changeFurnaceNoInfo[0].productId;
- });
- console.log(checkSame);
- if (!checkSame) {
- proxy.$modal.msgError("请选择相同计划单批量选择炉号");
- return;
- }
- if (changeFurnaceNoInfo.length === 0) {
- proxy.$modal.msgError("请选择需要变更炉号的计划单");
- return;
- }
- dialogFurnaceNoInfoRef.value.open({
- details: changeFurnaceNoInfo,
- queryParams: { ...changeFurnaceNoInfo[0] },
- });
- };
- const handleSingleSelectFurnaceNoInfo = (details, info) => {
- details.forEach((l) => {
- l.furnaceNoInfo = info;
- });
- };
- function handleCarrierNumChange() {
- let sumNum = 0;
- form.value.details.forEach((v) => {
- sumNum += v.newCarrierCount == null ? 0 : v.newCarrierCount;
- });
- totalCarriersNum.value = sumNum;
- }
- /** 暴露给父组件的方法 */
- defineExpose({
- open,
- });
- </script>
|