123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487 |
- import { ref, reactive, computed, toRefs, nextTick, inject } from "vue";
- import { Table } from "@/hooks/interface";
- import { ColumnProps } from "@/components/LjVxeTable/interface";
- import { ALLOW_EDIT_STATE } from "@/config/index";
- import { GetMattressInterfaceList, RefreshMattressInterface, RefreshMattressInterfaceQd } from "@/api/modules/quote";
- import { getConfigureTypeList, getConfigureCodeList, getConfigureCodeMxList } from "@/api/modules/basicinfo";
- import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
- import {
- CommonDynamicSelect,
- GetERPMtrldefList,
- GetERPWrkGrpList,
- GetERPMtrlTypeList,
- CreatMtrlPf,
- CreatPrdPf,
- DelMtrlPf
- } from "@/api/modules/common";
- import { transformTreeData, autoMergeCells, isFilterPrice } from "@/utils/index";
- import { floatSub, floatAdd, floatMul, floatDiv, formatFixedNumber } from "@/utils/index";
- import MtrldefErpSelect from "@/views/system/selector/mtrldefErp/select.vue";
- import CodemxSelect from "@/views/system/selector/codemx/select.vue";
- import { isFixedColumn } from "element-plus/es/components/table/src/util";
- import * as Exceljs from "exceljs";
- import { saveAs } from "file-saver";
- import { MattressYWAudit, MattressJSAudit, MattressJS2Audit } from "@/api/modules/quote";
- import { useRouter } from "vue-router";
- interface defaultState {
- initParams: any;
- /**
- * @description 单据当前状态
- */
- orderStatus: string;
- /**
- * @description 列表Ref
- */
- VxeTableRef: any;
- /**
- * @description 详情页Ref
- */
- LjDetailRef: any;
- mainData: any;
- mattressYWList: any[];
- mattressQDList: any[];
- /**
- * @description //1 业务补充 2--技术1 3--技术2
- */
- editType: number;
- MattressDialogRef: any;
- MattressDialogProps: any;
- MtrldefErpDialogRef: any;
- MtrldefErpDialogProps: any;
- workgrpEnum: any;
- workgrpEnum2: any;
- configureTypeEnum: any;
- VxeTableMxRef: any;
- YwTableRef: any;
- QdTableRef: any;
- CodeMxDialogProps: any;
- CodeMxDialogRef: any;
- }
- /**
- * @description 表格多选数据操作
- * @param {String} rowKey 当表格可以多选时,所指定的 id
- * */
- export const useHooks = (t?: any) => {
- const state = reactive<defaultState>({
- initParams: {},
- orderStatus: "",
- VxeTableRef: null,
- VxeTableMxRef: null,
- YwTableRef: null,
- QdTableRef: null,
- LjDetailRef: null,
- mainData: [],
- mattressYWList: [],
- mattressQDList: [],
- editType: 0,
- MattressDialogRef: null,
- MattressDialogProps: {},
- MtrldefErpDialogRef: null,
- MtrldefErpDialogProps: {},
- workgrpEnum: [],
- workgrpEnum2: [],
- configureTypeEnum: [],
- CodeMxDialogProps: null,
- CodeMxDialogRef: null
- });
- const QdAddRowList = [
- {
- itemname: "补充物料",
- bj_pzname: "边带",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "海绵芯",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "裥棉面线",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "裥棉底线",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "车位面线",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "车位底线",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "打底枪钉",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "胶水",
- bj_pzname_mx: ""
- },
- {
- itemname: "补充物料",
- bj_pzname: "围边用线",
- bj_pzname_mx: ""
- }
- ];
- const funcAddRowQd = async () => {
- const $table = state.QdTableRef?.element;
- if ($table) {
- $table.insertAt(QdAddRowList, -1);
- const { visibleData } = $table.getTableData();
- visibleData.map((o, idx) => {
- o.printid = idx + 1;
- return o;
- });
- $table.reloadData(visibleData);
- resetMergeCellsQd();
- }
- };
- const funcCmpCC = async () => {
- const $table = state.VxeTableMxRef?.element;
- if ($table) {
- $table.clearEdit();
- const mainData = state.LjDetailRef._mainData;
- const { visibleData } = $table.getTableData();
- console.log("visibleData :>> ", visibleData);
- visibleData.map((o, idx) => {
- if (["面层裥棉", "底层裥棉"].includes(o.bj_pzname)) {
- //生产尺寸:((规格长)+2)*((规格宽)+2)
- //锁边尺寸:((规格长)-1)*((规格宽)-1)
- o.actual_size = mainData.mattress_width + 2 + "*" + (mainData.mattress_length + 2);
- o.sb_craft = mainData.mattress_width - 1 + "*" + (mainData.mattress_length - 1);
- }
- });
- await $table.reloadData(visibleData);
- resetMergeCells();
- ElMessage.success("操作成功!");
- }
- };
- const toCreateORDelMtrlPf = (type: number, list: any) => {
- if (type === 1) {
- if (state.QdTableRef) {
- const $table = state.QdTableRef.element;
- if ($table) {
- $table.clearEdit();
- const { visibleData } = $table.getTableData();
- console.log("visibleData :>> ", visibleData);
- try {
- visibleData.map((o, idx) => {
- if (!o.erp_mtrlid && o.actual_useqty > 0) {
- state.QdTableRef.scrollTo(o, "erp_mtrlid");
- throw new Error(`第${idx + 1}行:产品补充未填入L1物料信息,请先选择L1物料修改`);
- }
- });
- } catch (error) {
- ElMessage.error(error.message);
- return false;
- }
- }
- }
- ElMessageBox.confirm(`是否确定要生成金蝶清单?`, "询问", {
- confirmButtonText: t("common.okText"),
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- CreatPrdPf({ list }).then(() => {
- ElNotification({
- title: "金蝶清单",
- message: "生成成功!",
- type: "success"
- });
- });
- })
- .catch((e: TypeError) => {
- console.log("e :>> ", e);
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- } else {
- ElMessageBox.confirm(`是否确定要删除金蝶清单?`, "询问", {
- confirmButtonText: t("common.delText"),
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- DelMtrlPf({ list }).then(() => {
- ElMessage.success("删除成功!");
- });
- })
- .catch((e: TypeError) => {
- console.log("e :>> ", e);
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- }
- };
- const toCreateMtrl = (type: number, list: any) => {
- ElMessageBox.confirm(`是否确定要生成/更新物料?`, "询问", {
- confirmButtonText: t("common.okText"),
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- CreatMtrlPf({ list }).then(res => {
- console.log("toCreateMtrl, res :>> ", res);
- if (state.LjDetailRef) {
- state.LjDetailRef._mainData.erp_mtrlid = res.mattress.erp_mtrlid;
- state.LjDetailRef._mainData.creatmtrl_flag = res.mattress.creatmtrl_flag;
- state.LjDetailRef._mainData.erp_mtrlcode = res.mattress.erp_mtrlcode;
- }
- ElNotification({
- title: "物料",
- message: "生成/更新成功!",
- type: "success"
- });
- });
- })
- .catch((e: TypeError) => {
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- };
- // const toUpdateL1Planprice = (mattressid: number) => {
- // ElMessageBox.confirm(`是否确定要更新计划价?`, "询问", {
- // confirmButtonText: t("common.okText"),
- // cancelButtonText: "否",
- // type: "warning"
- // })
- // .then(() => {
- // CreatMtrlPf({ mattressid }).then(() => {
- // ElNotification({
- // title: "更新计划价",
- // message: "更新成功!",
- // type: "success"
- // });
- // });
- // })
- // .catch((e: TypeError) => {
- // console.log("e :>> ", e);
- // ElMessage({
- // type: "info",
- // message: "操作取消"
- // });
- // });
- // };
- const ywFlagChange = (value: any) => {
- console.log("value :>> ", value);
- // console.log("Lj :>> ", state.LjDetailRef._mainData);
- value = parseInt(value ?? 0);
- // handleSelMxData(value);
- // fChangeBedNetType(value);
- switch (value) {
- case 2: // 待业务审
- state.initParams.yw_flag = 0;
- state.initParams.js1_flag = 0;
- state.initParams.js2_flag = 0;
- state.initParams.creatmtrl_flag = 0;
- state.initParams.creatmtrlqd_flag = 0;
- break;
- case 3: //待产品补充审
- state.initParams.yw_flag = 1;
- state.initParams.js1_flag = 0;
- state.initParams.js2_flag = 0;
- state.initParams.creatmtrl_flag = 0;
- state.initParams.creatmtrlqd_flag = 0;
- break;
- case 4: //待清单补充审
- state.initParams.yw_flag = 1;
- state.initParams.js1_flag = 1;
- state.initParams.js2_flag = 0;
- state.initParams.creatmtrl_flag = -1;
- state.initParams.creatmtrlqd_flag = -1;
- break;
- case 5: //待生成erp产品
- state.initParams.yw_flag = 1;
- state.initParams.js1_flag = 1;
- state.initParams.js2_flag = 1;
- state.initParams.creatmtrl_flag = 1;
- state.initParams.creatmtrlqd_flag = -1;
- break;
- case 6: //待生成erp清单
- state.initParams.yw_flag = 1;
- state.initParams.js1_flag = 1;
- state.initParams.js2_flag = 1;
- state.initParams.creatmtrl_flag = 1;
- state.initParams.creatmtrlqd_flag = 0;
- break;
- default:
- state.initParams.yw_flag = -1;
- state.initParams.js1_flag = -1;
- state.initParams.js2_flag = -1;
- state.initParams.creatmtrl_flag = -1;
- state.initParams.creatmtrlqd_flag = -1;
- break;
- }
- };
- /**
- * @description 选择物料弹窗
- */
- const fModelChoseMtrlErp = (data: any, params: any) => {
- return new Promise((resolve, reject) => {
- // if (!ALLOW_EDIT_STATE.includes(status)) return;
- console.log("fModelChoseMtrl fModelChoseMtrl params :>> ", params);
- let _params = {
- keyword: "",
- ...params
- // arg_mtrltype: params.mtrltype,
- // arg_pricelistid: _pricelistid
- };
- state.MtrldefErpDialogProps = {
- onSubmit: (res: any) => {
- // submit
- console.log("openCustDialog res", res);
- nextTick(() => {
- // cb(data, res.value[0]);
- rModelSetMtrlErp(data, res.value[0]);
- resolve(1);
- });
- },
- onCancel: (error: any) => {
- // cancel 回调
- console.log("openCustDialog error", error);
- }
- };
- state.MtrldefErpDialogRef.show(_params);
- });
- };
- const rModelSetMtrlErp = (data: any, item: any) => {
- console.log("rModelSetMtrlErp item :>> ", item);
- if (item) {
- data.erp_mtrlid = item.mtrlid;
- data.erp_mtrlname = item.mtrlname;
- data.erp_mtrlmode = item.mtrlmode;
- data.erp_mtrlcode = item.mtrlcode;
- data.erp_unit = item.unit;
- data.erp_mtrlengname = item.zxmtrlmode;
- }
- };
- const rModelClearMtrlErp = (data: any, type: number) => {
- if (type == 1) {
- // 清空配置选项
- if (Number(data.erp_inputtype) != 2) {
- data.bj_namemx = "";
- }
- } else if (type == 2) {
- // 清空配置选项
- // if (Number(data.erp_inputtype) == 2) {
- data.erp_mtrlid = 0;
- data.erp_mtrlcode = "";
- data.erp_mtrlname = "";
- data.erp_mtrlmode = "";
- data.erp_unit = "";
- data.erp_mtrlengname = "";
- // }
- }
- };
- const rModelSetCodemx = (data: any, item: any, $table?: any) => {
- if (item) {
- data.bj_namemx = item.namemx;
- } else {
- data.bj_namemx = "";
- }
- // cb && cb();
- if ($table) {
- $table.clearEdit();
- nextTick(() => {
- $table.setActiveRow(data);
- });
- }
- };
- const rModelClearCodemx = (data: any, $table?: any) => {
- data.bj_namemx = "";
- if ($table) {
- $table.clearEdit();
- }
- };
- // 表格配置项
- const columns: ColumnProps<any>[] = [
- { type: "checkbox", width: 40, fixed: "left" },
- { title: "#", type: "seq", fixed: "left", width: 80 },
- {
- field: "yw_flag",
- title: "业务审核",
- search: {
- // el: "select",
- render: scope => {
- // let _keys = Object.keys(scope);
- // let _data = _keys.includes("row") ? scope.row : _keys.includes("searchParam") ? scope.searchParam : scope;
- return (
- <el-select v-model={scope.searchParam.status_flag} placeholder="全部" clearable onChange={ywFlagChange}>
- <el-option label="待业务审" value="2" />
- <el-option label="待产品补充审" value="3" />
- <el-option label="待清单补充审" value="4" />
- <el-option label="待生成erp产品" value="5" />
- <el-option label="待生成erp清单" value="6" />
- </el-select>
- );
- }
- }
- },
- {
- field: "js1_flag",
- title: "产品补充审核"
- },
- {
- field: "js2_flag",
- title: "清单补充审核"
- },
- {
- field: "creatmtrl_flag",
- title: "生成L1产品"
- },
- {
- field: "creatmtrlqd_flag",
- title: "生成L1清单"
- },
- {
- field: "erp_mtrlcode",
- title: "L1物料编码",
- search: {
- el: "input",
- key: "arg_search"
- }
- },
- {
- field: "deptid",
- title: "部门",
- width: 120,
- search: {
- el: "select",
- key: "arg_deptid",
- props: {
- filterable: true,
- onChange: (value: any) => {
- state.initParams.arg_deptid = value;
- }
- },
- order: 1
- }
- },
- {
- field: "mattresscode",
- title: "报价唯一码"
- },
- {
- field: "mattressrelcode",
- title: "核价编码"
- },
- {
- field: "mattressname",
- title: "核价名称",
- treeNode: true,
- render: scope => {
- return !scope.row?.child_count && !scope.row?.parentid ? (
- scope.row?.mattressname
- ) : scope.row?.parentid ? (
- <div class="flx-justify-between">
- <span class="mle">{scope.row?.mattressname}</span>
- <el-tag type="warning" effect="light" disable-transitions size="small" round class="ml-4">
- 副
- </el-tag>
- </div>
- ) : (
- <div class="flx-justify-between">
- <span class="mle">{scope.row?.mattressname}</span>
- <el-tag type="primary" effect="light" disable-transitions size="small" round class="ml-4">
- 主
- </el-tag>
- </div>
- );
- }
- },
- {
- field: "mattresstypeid",
- title: "床垫类别"
- },
- {
- field: "mattress_width",
- title: "床垫宽/CM"
- },
- {
- field: "mattress_length",
- title: "床垫长/CM"
- },
- {
- field: "mattress_height",
- title: "床垫高/CM"
- },
- {
- field: "createby",
- title: "登记人"
- },
- {
- field: "createtime",
- title: "登记时间"
- },
- {
- field: "yw_auditingrep",
- title: "业务审核人"
- },
- {
- field: "yw_auditingdate",
- title: "业务审核时间"
- // table: "u_mattress_interface",
- // enum: [
- // { label: "业务审核时间", value: 0 },
- // { label: "产品补充审核时间", value: 1 },
- // { label: "清单补充审核时间", value: 2 }
- // ],
- // search: {
- // el: "select",
- // key: "arg_datetype",
- // props: {
- // filterable: true,
- // defaultFirstOption: true
- // }
- // }
- },
- {
- field: "js1_auditingrep",
- title: "产品补充审核人"
- },
- {
- field: "js1_auditingdate",
- title: "产品补充审核时间"
- // table: "u_mattress_interface",
- // search: {
- // el: "date-picker",
- // key: "arg_firstdate",
- // props: {
- // type: "date"
- // }
- // }
- },
- {
- field: "js2_auditingrep",
- title: "清单补充审核人"
- },
- {
- field: "js2_auditingdate",
- title: "清单补充审核时间"
- // table: "u_mattress_interface",
- // search: {
- // el: "date-picker",
- // key: "arg_enddate",
- // props: {
- // type: "date"
- // }
- // }
- },
- {
- field: "creatmtrl_auditingrep",
- title: "生成L1产品人"
- },
- {
- field: "creatmtrl_auditingdate",
- title: "生成L1产品时间"
- },
- {
- field: "creatmtrlqd_auditingrep",
- title: "生成L1清单人"
- },
- {
- field: "creatmtrlqd_auditingdate",
- title: "生成L1清单时间"
- },
- {
- field: "dijia_cost",
- title: "底价"
- },
- {
- field: "yongjin",
- title: "佣金",
- render: (scope: any) => {
- let result = floatSub(floatDiv(scope.row.dijia_cost, floatSub(1, scope.row.commission - 1)), scope.row.dijia_cost);
- result = formatFixedNumber({ val: result });
- return result;
- }
- },
- {
- field: "taxrate",
- title: "税率"
- },
- {
- field: "fob",
- title: "FOB"
- },
- {
- field: "taxes",
- title: "税金"
- },
- {
- field: "erp_mtrlengname",
- title: "原物料编码"
- },
- {
- field: "erp_configcodetype",
- title: "ERP配置类型"
- }
- ];
- const columns_detail: ColumnProps<any>[] = [
- {
- field: "erp_mtrlcode",
- title: "系统物料编码",
- basicinfo: {
- el: "input",
- // props: {
- // clearable: true,
- // onClick: (scope: any) => {
- // console.log("columns_detail scope :>> ", scope);
- // // fModelChoseMtrl()
- // }
- // },
- // editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 1,
- span: 1
- }
- },
- {
- field: "erp_mtrlname",
- title: "系统物料名称",
- basicinfo: {
- el: "input",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 4,
- span: 1
- }
- },
- {
- field: "erp_mtrlmode",
- title: "物料规格",
- basicinfo: {
- el: "input",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 2,
- span: 1
- }
- },
- {
- field: "erp_mtrlunit",
- title: "物料单位",
- basicinfo: {
- el: "input",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 5,
- span: 1,
- rules: [{ required: true, message: "物料单位不能为空" }]
- }
- },
- {
- field: "erp_mtrltypeid",
- title: "物料类别",
- basicinfo: {
- el: "tree-select",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 3,
- span: 1,
- props: {
- filterable: true
- // onChange: ()=> {
- // },
- // renderContent: data => {
- // console.log("erp_mtrltypeid value data :>> ", data);
- // return <div>321</div>;
- // }
- }
- },
- enum: async () => {
- const data = await GetERPMtrlTypeList();
- console.log("GetERPMtrlTypeList data :>> ", data?.reList);
- return transformTreeData(data.reList);
- },
- fieldNames: {
- label: "mtrltype",
- value: "mtrltypeid",
- children: "children"
- }
- },
- {
- field: "erp_configcodetype",
- title: "配置类型",
- basicinfo: {
- el: "select",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 6,
- span: 1
- },
- enum: async () => {
- const data = await getConfigureTypeList({});
- console.log("data configureTypeEnum:>> ", data);
- // let dataEnum = data.datatable.map(item => {
- // return {
- // label: item.configuretypename,
- // value: item.configuretypeid
- // };
- // });
- return data.datatable;
- },
- fieldNames: {
- label: "contfigtypename",
- value: "contfigtypeid"
- }
- },
- {
- field: "mattresscode",
- title: "图号(床垫唯一码)",
- basicinfo: {
- el: "input",
- editable: () => {
- return false;
- },
- group: "单据信息",
- order: 9,
- span: 1
- }
- },
- {
- field: "erp_mtrlengname",
- title: "旧床垫编码",
- basicinfo: {
- el: "input",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 7,
- span: 1
- }
- },
- {
- field: "old_mtrlname",
- title: "旧物料名称",
- basicinfo: {
- el: "input",
- editable: ALLOW_EDIT_STATE,
- group: "单据信息",
- order: 8,
- span: 1
- }
- }
- ];
- const columns_yw: ColumnProps<any>[] = [
- {
- field: "printid",
- title: "排序",
- width: 80
- },
- {
- field: "itemname",
- title: "项目",
- width: 120
- },
- {
- field: "bj_pzname",
- title: "核价_配置名称"
- },
- {
- field: "erp_pzcode",
- title: "ERP配置编码",
- width: 100
- },
- {
- field: "erp_pzname",
- title: "ERP配置名称",
- width: 120
- },
- {
- field: "bj_inputtype",
- title: "录入类型",
- width: 80,
- enum: [
- {
- value: 0,
- label: "选择"
- },
- {
- value: 1,
- label: "录入"
- },
- {
- value: 2,
- label: "带出"
- }
- ],
- editRender: {
- name: "$select",
- options: [
- {
- value: 0,
- label: "选择"
- },
- {
- value: 1,
- label: "录入"
- },
- {
- value: 2,
- label: "带出"
- }
- ]
- }
- },
- {
- field: "bj_namemx",
- title: "明细名称",
- width: 280,
- editRender: {},
- editColRender: (scope: any) => {
- const { $table, column, row, status } = scope;
- // console.log("bj_namemx scope :>> ", scope);
- let params = {
- pzid: row.erp_pzid
- };
- if (row.bj_inputtype == 0) {
- return (
- <CodemxSelect
- value={scope.row.bj_namemx}
- {...params}
- clearable
- placeholder="请选择配置"
- onOpenModal={() => fModelChoseCodeMx(row, params, rModelSetCodemx, scope.row.bj_namemx, $table)}
- onSelect={val => rModelSetCodemx(scope.row, val, $table)}
- onClear={() => rModelClearCodemx(scope.row, $table)}
- ></CodemxSelect>
- );
- } else if (row.bj_inputtype == 1) {
- return <el-input v-model={scope.row.bj_namemx} />;
- } else {
- return <span>{row.bj_namemx}</span>;
- }
- }
- },
- {
- field: "actual_size",
- title: "生产尺寸",
- limited: () => {
- return state.editType == 1;
- },
- editRender: {
- name: "$input"
- }
- },
- {
- field: "sb_craft",
- title: "锁边工艺",
- limited: () => {
- return state.editType == 1;
- },
- editRender: {
- name: "$input"
- }
- },
- {
- field: "actual_size_sb",
- title: "锁边后尺寸",
- limited: () => {
- return state.editType == 1;
- },
- editRender: {
- name: "$input"
- }
- },
- {
- field: "ss_rate",
- title: "收缩率",
- limited: () => {
- return state.editType == 1;
- },
- datatype: "number",
- editRender: {
- name: "$input"
- }
- },
- {
- field: "ls_rate",
- title: "拉伸率",
- limited: () => {
- return state.editType == 1;
- },
- datatype: "number",
- editRender: {
- name: "$input"
- }
- }
- ];
- const columns_yw_qd: ColumnProps<any>[] = [
- {
- field: "bj_pzname",
- title: "核价_配置名称"
- },
- {
- field: "bj_namemx",
- title: "明细名称"
- },
- {
- field: "actual_size",
- title: "生产尺寸",
- limited: () => {
- return state.editType == 1;
- }
- },
- {
- field: "printid",
- title: "排序",
- width: 80
- },
- {
- field: "erp_pzcode",
- title: "ERP配置编码"
- },
- {
- field: "erp_pzname",
- title: "ERP配置名称"
- },
- {
- field: "bj_inputtype",
- title: "录入类型",
- width: 80,
- enum: [
- {
- value: "0",
- label: "选择"
- },
- {
- value: "1",
- label: "录入"
- },
- {
- value: "2",
- label: "带出"
- }
- ]
- },
- {
- field: "itemname",
- title: "项目"
- },
- {
- field: "sb_craft",
- title: "锁边工艺",
- limited: () => {
- return state.editType == 1;
- }
- },
- {
- field: "actual_size_sb",
- title: "锁边后尺寸",
- limited: () => {
- return state.editType == 1;
- }
- },
- {
- field: "ss_rate",
- title: "收缩率",
- limited: () => {
- return state.editType == 1;
- },
- datatype: "number"
- },
- {
- field: "ls_rate",
- title: "拉伸率",
- limited: () => {
- return state.editType == 1;
- },
- datatype: "number"
- }
- ];
- const enumMap = inject("enumMap", ref(new Map()));
- const workgrpEnum = computed(() => {
- console.log('领用工组领用工组领用工组领用工组 enumMap.value.get("wrkgrpid") :>> ', enumMap.value.get("wrkgrpid"));
- return enumMap.value.get("wrkgrpid");
- });
- const wipTypeEnum = [
- {
- label: "面裥绵",
- value: "面裥绵"
- },
- {
- label: "底裥绵",
- value: "底裥绵"
- },
- {
- label: "大侧裥绵",
- value: "大侧裥绵"
- },
- {
- label: "小侧裥绵1",
- value: "小侧裥绵1"
- },
- {
- label: "小侧裥棉2",
- value: "小侧裥棉2"
- },
- {
- label: "V侧裥绵1",
- value: "V侧裥绵1"
- },
- {
- label: "V侧裥绵2",
- value: "V侧裥绵2"
- },
- {
- label: "顶布1",
- value: "顶布1"
- },
- {
- label: "顶布2",
- value: "顶布2"
- },
- {
- label: "顶布3",
- value: "顶布3"
- }
- ];
- const columns_qd = ref<ColumnProps<any>[]>([
- { title: "#", type: "seq", fixed: "left", width: 60, dragSort: true },
- // {
- // field: "printid",
- // title: "排序",
- // width: 80,
- // fixed: "left",
- // dragSort: true
- // },
- {
- field: "itemname",
- title: "项目",
- width: 100,
- fixed: "left"
- },
- {
- field: "bj_pzname",
- title: "二级项目",
- fixed: "left",
- width: 120
- },
- {
- field: "bj_pzname_mx",
- title: "明细项目",
- width: 100,
- fixed: "left"
- },
- {
- field: "bj_pzname_mx_mx",
- title: "二级明细项目",
- fixed: "left"
- },
- {
- field: "wip_type",
- title: "半成品归属",
- width: 120,
- editRender: {
- autoFocus: true
- },
- editColRender: (scope: any) => {
- // console.log("formulakind editColRender scope :>> ", scope);
- return (
- <el-select v-model={scope.row.wip_type} filterable clearable>
- {{
- default: () => {
- let rs = [];
- wipTypeEnum.map((t: any) => {
- rs.push(<el-option label={t.label} value={t.value} />);
- });
- return rs;
- }
- // label: ({ label, value }) => label
- }}
- </el-select>
- );
- }
- },
- {
- field: "erp_mtrlcode",
- title: "L1物料编码",
- // limited: () => {
- // return state.editType == 1 || state.editType == 2;
- // },
- // editRender: {
- // name: "$input"
- // }
- editRender: {
- // name: "$select"
- autoFocus: "input"
- },
- editColRender: (scope: any) => {
- // console.log("mtrlname hooks render scope :>> ", scope);
- // console.log("mtrlname hooks render LjDetailRef.value._mainData :>> ", state.LjDetailRef);
- const { $table, column, row, status } = scope;
- let field = column.field;
- let _label = column.title;
- // if (column?.format) {
- // _label = handleRowAccordingToProp(searchParam, field, column?.format);
- // }
- let params = {
- keyword: row.erp_mtrlcode
- };
- return (
- <MtrldefErpSelect
- value={row.erp_mtrlid}
- {...params}
- clearable
- placeholder={_label}
- onOpenModal={() => fModelChoseMtrlErp(row, params)}
- onSelect={val => rModelSetMtrlErp(row, val)}
- onClear={() => rModelClearMtrlErp(row, 2)}
- >
- {{
- label: () => row.erp_mtrlcode
- }}
- </MtrldefErpSelect>
- );
- }
- },
- {
- field: "dscrp",
- title: "备注",
- editRender: {
- name: "$input"
- }
- },
- {
- field: "erp_mtrlengname",
- title: "旧物料名称",
- limited: () => {
- return state.editType == 1 || state.editType == 2;
- },
- editRender: {},
- editColRender: (scope: any) => {
- const { $table, column, row, status } = scope;
- let field = column.field;
- let _label = column.title;
- return (
- <MtrldefErpSelect
- value={row.erp_mtrlid}
- searchKey="mtrlengname"
- clearable
- placeholder={_label}
- onOpenModal={() => fModelChoseMtrlErp(row, {})}
- onSelect={val => rModelSetMtrlErp(row, val)}
- onClear={() => rModelClearMtrlErp(row, 2)}
- >
- {{
- label: () => row.erp_mtrlengname
- }}
- </MtrldefErpSelect>
- );
- }
- },
- {
- field: "erp_mtrlname",
- title: "L1物料名称",
- limited: () => {
- return state.editType == 1 || state.editType == 2;
- }
- },
- {
- field: "ss_rate",
- title: "收缩率",
- datatype: "number",
- editRender: {
- name: "$input"
- }
- },
- {
- field: "erp_mtrlmode",
- title: "L1物料规格",
- limited: () => {
- return state.editType == 1 || state.editType == 2;
- }
- },
- {
- field: "qd_actual_size",
- title: "实际尺寸",
- editRender: {
- name: "$input"
- }
- },
- {
- field: "qd_pfgroupqty",
- title: "条数",
- width: 80,
- editRender: {
- name: "$input"
- }
- },
- {
- field: "ls_rate",
- title: "拉伸率",
- datatype: "number",
- editRender: {
- name: "$input"
- }
- },
- {
- field: "erp_unit",
- title: "L1物料单位",
- limited: () => {
- return state.editType == 1 || state.editType == 2;
- }
- },
- {
- field: "sh_rate",
- title: "损耗率",
- datatype: "number",
- editRender: {
- name: "$input"
- }
- },
- {
- field: "useqty",
- title: "参考用料量",
- datatype: "number",
- limited: () => {
- return state.editType == 1 || state.editType == 2;
- }
- },
- {
- field: "actual_useqty",
- title: "实际用量",
- datatype: "number",
- editRender: {
- name: "$input"
- },
- limited: () => {
- return state.editType == 1 || state.editType == 2;
- }
- },
- {
- field: "wrkgrpid",
- title: "领用工组",
- // enum: async () => {
- // const data = await GetERPWrkGrpList();
- // console.log("领用工组领用工组领用工组领用工组 data :>> ", data);
- // return { data: data.workgroupList };
- // },
- // fieldNames: { label: "wrkgrpname", value: "wrkgrpid" },
- // enum: async () => {
- // console.log("领用工组领用工组领用工组领用工组 state.workgrpEnum :>> ", state.workgrpEnum);
- // return { data: state.workgrpEnum };
- // },
- isFilterEnum: true,
- editRender: {
- // name: "$select"
- autoFocus: true
- },
- editColRender: (scope: any) => {
- // console.log("formulakind editColRender scope :>> ", scope);
- return (
- <el-select v-model={scope.row.wrkgrpid} filterable clearable onChange={val => rModelSetWrkgrp1(val, scope.row)}>
- {{
- default: () => {
- let rs = [];
- if (state.workgrpEnum.length) {
- state.workgrpEnum.map((t: any) => {
- rs.push(<el-option label={`${t.code} - ${t.label}`} value={t.value} />);
- });
- }
- return rs;
- },
- label: ({ label, value }) => label
- }}
- </el-select>
- );
- },
- render: scope => {
- let item = state.workgrpEnum.find(t => t.value == scope.row.wrkgrpid);
- if (item) {
- return item.code + " - " + item.label;
- } else {
- return "";
- }
- }
- },
- {
- field: "wrkgrpid2",
- title: "领用工组(新L1)",
- // enum: async () => {
- // const data = await GetERPWrkGrpList();
- // console.log("领用工组领用工组领用工组领用工组 data :>> ", data);
- // return { data: data.workgroupList };
- // },
- // fieldNames: { label: "wrkgrpname", value: "wrkgrpid" },
- // enum: async () => {
- // console.log("领用工组领用工组领用工组领用工组 state.workgrpEnum :>> ", state.workgrpEnum);
- // return { data: state.workgrpEnum };
- // },
- isFilterEnum: true,
- editRender: {
- // name: "$select"
- autoFocus: "input"
- },
- editColRender: (scope: any) => {
- // console.log("formulakind editColRender scope :>> ", scope);
- return (
- <el-select v-model={scope.row.wrkgrpid2} filterable clearable onChange={val => rModelSetWrkgrp2(val, scope.row)}>
- {{
- default: () => {
- let rs = [];
- if (state.workgrpEnum2.length) {
- state.workgrpEnum2.map((t: any) => {
- rs.push(<el-option label={`${t.code} - ${t.label}`} value={t.value} />);
- });
- }
- return rs;
- },
- label: ({ label, value }) => label
- }}
- </el-select>
- );
- },
- render: scope => {
- let item = state.workgrpEnum2.find(t => t.value == scope.row.wrkgrpid2);
- if (item) {
- return item.code + " - " + item.label;
- } else {
- return "";
- }
- }
- }
- ]);
- const rModelSetWrkgrp1 = (value: any, data: any) => {
- let item = state.workgrpEnum.find(t => t.value == value);
- if (item) {
- data.wrkgrpcode1 = item.code;
- }
- };
- const rModelSetWrkgrp2 = (value: any, data: any) => {
- let item = state.workgrpEnum2.find(t => t.value == value);
- if (item) {
- data.wrkgrpcode2 = item.code;
- }
- };
- // const columns_export = [
- // {
- // name: "行号",
- // field: "pid",
- // },
- // {
- // name: "层",
- // field: "lp",
- // },
- // {
- // name: "",
- // field: "lp_tree",
- // },
- // {
- // name: "序",
- // field: "u_prdpf_printid",
- // },
- // {
- // name: "工艺模板编码",
- // field: "mb_mtrlcode",
- // },
- // {
- // name: "物料编码",
- // field: "u_mtrldef_mtrlcode",
- // },
- // {
- // name: "来源",
- // field: "u_mtrldef_mtrlorigin",
- // },
- // {
- // name: "物料属性",
- // field: "u_mtrldef_mtrlprp",
- // },
- // {
- // name: "物料名称",
- // field: "u_mtrldef_mtrlname",
- // },
- // {
- // name: "物料规格",
- // field: "u_mtrldef_mtrlmode",
- // },
- // {
- // name: "库存 单位",
- // field: "u_mtrldef_unit",
- // },
- // {
- // name: "物料类别",
- // field: "u_mtrldef_mtrltypeid",
- // },
- // {
- // name: "弹簧数",
- // field: "u_mtrldef_mtrlsectype",
- // },
- // {
- // name: "旧编码",
- // field: "u_mtrldef_zxmtrlmode",
- // },
- // {
- // name: "旧产品名称",
- // field: "u_mtrldef_usermtrlmode",
- // },
- // {
- // name: "图号",
- // field: "u_mtrldef_piccode",
- // },
- // {
- // name: "排产属性",
- // field: "u_mtrldef_ifselforder",
- // },
- // {
- // name: "计划属性",
- // field: "u_mtrldef_ordertype",
- // },
- // {
- // name: "默认 制造分部",
- // field: "u_mtrldef_scid",
- // },
- // {
- // name: "默认 制造车间",
- // field: "u_mtrldef_dftwrkgrpid",
- // },
- // {
- // name: "板件属性",
- // field: "u_mtrldef_bantype",
- // },
- // {
- // name: "安装序号",
- // field: "u_prdpf_azcode",
- // },
- // {
- // name: "部件名称",
- // field: "u_prdpf_pfgroup",
- // },
- // {
- // name: "部件 数",
- // field: "u_prdpf_pfgroupqty",
- // },
- // {
- // name: "部件规格",
- // field: "u_prdpf_pfgroupmode",
- // },
- // {
- // name: "部件代号",
- // field: "u_prdpf_promode",
- // },
- // {
- // name: "开料规格",
- // field: "u_prdpf_pfklmode",
- // },
- // {
- // name: "领料组",
- // field: "u_prdpf_wrkgrpid",
- // },
- // {
- // name: "用料量",
- // field: "u_prdpf_sonscale",
- // },
- // {
- // name: "损耗率",
- // field: "u_prdpf_sonloss",
- // },
- // {
- // name: "损附加",
- // field: "u_prdpf_sondecloss",
- // },
- // {
- // name: "配置",
- // field: "u_prdpf_status",
- // },
- // {
- // name: "配置1",
- // field: "u_prdpf_woodcode",
- // },
- // {
- // name: "配置2",
- // field: "u_prdpf_pcode",
- // },
- // {
- // name: "生产 提前期(天)",
- // field: "u_prdpf_sonahead",
- // },
- // {
- // name: "清单",
- // field: "u_prdpf_sonpfcode",
- // },
- // {
- // name: "说明",
- // field: "u_prdpf_dscrp",
- // },
- // {
- // name: "发料用 损耗率",
- // field: "u_prdpf_scllloss",
- // },
- // {
- // name: "发料用 损耗附加",
- // field: "u_prdpf_sclldecloss",
- // },
- // {
- // name: "按配置 拆装",
- // field: "u_prdpf_ifover",
- // },
- // {
- // name: "拆装 运算配置",
- // field: "u_prdpf_dipztype",
- // },
- // {
- // name: "采购 参数",
- // field: "u_prdpf_buyarg",
- // },
- // {
- // name: "生产 保险期(天)",
- // field: "u_mtrldef_orderdays",
- // },
- // {
- // name: "采购 周期(天)",
- // field: "u_mtrldef_buydays",
- // },
- // {
- // name: "外协 周期(天)",
- // field: "u_mtrldef_wfjgdays",
- // },
- // {
- // name: "出仓类型",
- // field: "u_mtrldef_outtype",
- // },
- // {
- // name: "密度(kg/m³)",
- // field: "u_mtrldef_midu",
- // },
- // {
- // name: "物料备注",
- // field: "u_mtrldef_dscrp",
- // },
- // {
- // name: "单件体积(m³)",
- // field: "cubage",
- // },
- // {
- // name: "长度(mm)",
- // field: "length",
- // },
- // {
- // name: "宽度(mm)",
- // field: "width",
- // },
- // {
- // name: "工艺路线模板(双击选择)",
- // field: "u_prdpf_modlename",
- // },
- // {
- // name: "清单-纹理方向",
- // field: "u_prdpf_wenli",
- // },
- // {
- // name: "清单-封边信息",
- // field: "u_prdpf_fengbian",
- // },
- // {
- // name: "清单-排孔信息",
- // field: "u_prdpf_paikong",
- // },
- // {
- // name: "清单-锣机信息",
- // field: "u_prdpf_luoji",
- // },
- // {
- // name: "清单-喷油(吸塑)信",
- // field: "u_prdpf_penyou",
- // },
- // {
- // name: "包件",
- // field: "u_mtrldef_ifpack",
- // },
- // {
- // name: "物料-部件代号",
- // field: "u_mtrldef_ban_promode",
- // },
- // {
- // name: "物料-开料规格",
- // field: "u_mtrldef_ban_pfklmode",
- // },
- // {
- // name: "物料-纹理方向",
- // field: "u_mtrldef_ban_wenli",
- // },
- // {
- // name: "物料-封边信息",
- // field: "u_mtrldef_ban_fengbian",
- // },
- // {
- // name: "物料-排孔信息",
- // field: "u_mtrldef_ban_paikong",
- // },
- // {
- // name: "物料-锣机信息",
- // field: "u_mtrldef_ban_luoji",
- // },
- // {
- // name: "物料-喷油(吸塑)信息",
- // field: "u_mtrldef_ban_penyou",
- // },
- // {
- // name: "物料-工艺备注",
- // field: "u_mtrldef_ban_gydscrp",
- // },
- // {
- // name: "摆放方向",
- // field: "u_mtrldef_ban_direction",
- // },
- // {
- // name: "物料ID",
- // field: "u_mtrldef_mtrlid",
- // },
- // {
- // name: "虚拟进出",
- // field: "u_mtrldef_xninoutflag",
- // },
- // {
- // name: "产品选配值",
- // field: "config_val",
- // },
- // {
- // name: "当前物料开料规格",
- // field: "u_mtrldef_pfklmode_son",
- // },
- // {
- // name: "上级物料开料规格",
- // field: "u_mtrldef_pfklmode_p",
- // },
- // ];
- const tableProps_mx = ref<any>({
- height: "auto",
- align: "left",
- // height: "",
- sortConfig: {
- trigger: "manual"
- },
- editConfig: {
- trigger: "click",
- mode: "cell",
- enabled: false
- // afterEditMethod: ({ row, rowIndex, column, columnIndex }) => {
- // console.log("afterEditMethod :>> ", row);
- // }
- // beforeEditMethod: ({ row, rowIndex, column, columnIndex }) => {
- // console.log("state.editType == 1 :>> ", state.editType, column.field);
- // if (state.editType == 1) {
- // if (["bj_inputtype"].includes(column.field)) {
- // return false;
- // }
- // }
- // return true;
- // }
- },
- showOverflow: false,
- // exportConfig: {
- // filename: t("menu.saleTaskCrmDetail") + formatToDate(new Date(), "YYYY-MM-DDHH:mm:ss")
- // }
- keyboardConfig: {
- isEdit: true,
- isArrow: true,
- isEnter: true,
- isTab: true,
- isDel: true,
- isBack: true,
- isEsc: true,
- editMethod({ $table, row, column }) {
- // 先清空原先的值
- row[column.field] = "";
- // 再激活编辑状态并输入新值
- $table.setEditCell(row, column);
- }
- },
- mouseConfig: {
- selected: true
- }
- });
- const tableProps_qd = ref<any>({
- height: "auto",
- align: "left",
- // height: "",
- sortConfig: {
- trigger: "manual"
- },
- editConfig: {
- trigger: "click",
- mode: "cell",
- enabled: false,
- // afterEditMethod: ({ row, rowIndex, column, columnIndex }) => {
- // console.log("afterEditMethod :>> ", row);
- // }
- beforeEditMethod: ({ row, rowIndex, column, columnIndex }) => {
- console.log("state.editType == 1 :>> ", state.editType, column.field);
- if (state.editType == 1) {
- if (["bj_inputtype"].includes(column.field)) {
- return false;
- }
- }
- return true;
- }
- },
- showOverflow: false,
- // exportConfig: {
- // filename: t("menu.saleTaskCrmDetail") + formatToDate(new Date(), "YYYY-MM-DDHH:mm:ss")
- // }
- keyboardConfig: {
- isEdit: true,
- isArrow: true,
- isEnter: true,
- isTab: true,
- isDel: true,
- isBack: true,
- isEsc: true,
- editMethod({ $table, row, column }) {
- // 先清空原先的值
- row[column.field] = "";
- // 再激活编辑状态并输入新值
- $table.setEditCell(row, column);
- }
- },
- mouseConfig: {
- selected: true
- },
- rowConfig: {
- drag: true
- },
- rowDragConfig: {
- trigger: "cell",
- showGuidesStatus: true
- }
- });
- const resetMergeCells = (cb?: any) => {
- nextTick(() => {
- const $table = state.YwTableRef.element;
- const $table2 = state.VxeTableMxRef.element;
- if ($table) {
- let mergeCells = autoMergeCells($table, ["itemname"]);
- $table.setMergeCells(mergeCells);
- }
- if ($table2) {
- let mergeCells = autoMergeCells($table2, ["itemname"]);
- $table2.setMergeCells(mergeCells);
- cb && cb();
- }
- });
- };
- const resetMergeCellsQd = (cb?: any) => {
- setTimeout(() => {
- nextTick(() => {
- const $table = state.QdTableRef?.element;
- if ($table) {
- let mergeCells = autoMergeCells($table, ["itemname", "bj_pzname", "bj_pzname_mx_mx"]);
- // console.log("autoMergeCells mergeCells :>> ", mergeCells);
- $table.setMergeCells(mergeCells);
- cb && cb();
- }
- });
- }, 200);
- };
- /**
- * 获取产品配置,产品清单
- * @param mattressid 床垫ID
- */
- const RetriveMattressInterface = async (mattressid: number) => {
- let res = await GetMattressInterfaceList({ mattressid, isEdit: Number(state.orderStatus != "") });
- if (res.ErrMsg) {
- ElNotification({
- title: "温馨提示",
- message: res.ErrMsg,
- type: "error"
- });
- }
- state.mainData = [res.mattress];
- state.mattressYWList = res.interfaceList;
- state.mattressQDList = res.qdList;
- resetMergeCells();
- resetMergeCellsQd();
- };
- /**
- * 刷新产品配置
- * @param mattressid 床垫ID
- * @param isPz 类型 0 - 刷新 1 - 复制 2 - 重新生成
- */
- const RefreshMattressInterfaceList = async (mattressid: number, isPz: number, configcodetype: number = 0) => {
- let res = await RefreshMattressInterface({ mattressid, isPz: isPz, configcodetype });
- const $table = state.YwTableRef?.element;
- let { visibleData } = $table.getTableData();
- const copyMap = new Map();
- // inputtype 0 - 选择 1 - 录入 2 - 带出
- if (isPz === 0) {
- // 刷新配置 FEAT: 只刷新带出类型的配置,只刷新明细名称列,如果有新增的,需要补齐。
- visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
- const PRESERVE_PROPS = [
- "bj_inputtype",
- "erp_pzname",
- "erp_pzcode",
- "bj_pzname",
- "itemname",
- "actual_size",
- "sb_craft",
- "actual_size_sb",
- "ss_rate",
- "ls_rate"
- ];
- state.mattressYWList = res.mxList.map(mx => {
- const key = `${mx.erp_pzid}`;
- if (copyMap.has(key)) {
- PRESERVE_PROPS.forEach(prop => {
- mx[prop] = copyMap.get(key)[prop];
- });
- }
- return mx;
- });
- } else if (isPz === 1) {
- // 复制配置 FEAT:只复制录入和选择类型的配置,生产信息不覆盖
- const NEED_PROPS = ["bj_inputtype", "bj_namemx"];
- res.mxList.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
- visibleData.forEach(mx => {
- const key = `${mx.erp_pzid}`;
- if (copyMap.has(key) && (mx.bj_inputtype === 1 || mx.bj_inputtype === 0)) {
- NEED_PROPS.forEach(prop => {
- mx[prop] = copyMap.get(key)[prop];
- });
- }
- });
- state.mattressQDList = visibleData.map((mx: any) => mx);
- } else {
- const PRESERVE_PROPS = ["actual_size", "sb_craft", "actual_size_sb", "ss_rate", "ls_rate"];
- visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
- state.mattressYWList = res.mxList.map(mx => {
- const key = `${mx.erp_pzid}`;
- if (copyMap.has(key)) {
- PRESERVE_PROPS.forEach(prop => {
- mx[prop] = copyMap.get(key)[prop];
- });
- }
- return mx;
- });
- }
- // $table.reloadData(visibleData);
- resetMergeCells();
- ElNotification({
- title: "刷新成功",
- type: "success"
- });
- };
- /**
- * 刷新产品清单
- * @param mattressid 床垫ID
- * @param isPz 类型 0 - 刷新 1 - 复制 2 - 重新生成
- */
- const RefreshMattressInterfaceQdList = async (mattressid: number, isPz: number, isCheck?: number) => {
- isCheck = isCheck ?? 1;
- let res = await RefreshMattressInterfaceQd({ mattressid, isPz, isCheck });
- const interfaceMap = {};
- state.mattressYWList.forEach(mb => {
- interfaceMap[mb.bj_pzname] = mb;
- });
- // 遍历 qdList 并使用哈希表来查找和赋值
- res.mxList.forEach(mx => {
- const mb = interfaceMap[mx.bj_pzname];
- if (mb) {
- mx.bj_pzname_mx_mx = mb.bj_namemx;
- if (mx.ss_rate === 0) {
- mx.ss_rate = mb.ss_rate;
- }
- if (mx.ls_rate === 0) {
- mx.ls_rate = mb.ls_rate;
- }
- }
- });
- const $table = state.QdTableRef?.element;
- let { visibleData } = $table.getTableData();
- const copyMap = new Map();
- // qd_actual_size字段不修改
- const PRESERVE_PROPS = ["qd_actual_size"];
- if (isPz === 0) {
- // 刷新清单
- visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
- state.mattressQDList = res.mxList.map(mx => {
- const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
- if (copyMap.has(key)) {
- PRESERVE_PROPS.forEach(prop => {
- mx[prop] = copyMap.get(key)[prop];
- });
- }
- return mx;
- });
- } else if (isPz === 1) {
- // 复制清单
- const NEED_PROPS = [
- "erp_mtrlid",
- "erp_mtrlcode",
- "erp_mtrlname",
- "erp_mtrlmode",
- "erp_unit",
- "useqty",
- "actual_useqty",
- "wrkgrpid",
- "qd_pfgroupqty",
- "dscrp"
- ];
- res.mxList.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
- visibleData.forEach(mx => {
- const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
- if (copyMap.has(key)) {
- NEED_PROPS.forEach(prop => {
- mx[prop] = copyMap.get(key)[prop];
- });
- }
- });
- state.mattressQDList = visibleData.map((mx: any) => mx);
- } else {
- // 重新刷新清单
- visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
- state.mattressQDList = res.mxList.map(mx => {
- const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
- if (copyMap.has(key)) {
- PRESERVE_PROPS.forEach(prop => {
- mx[prop] = copyMap.get(key)[prop];
- });
- }
- return mx;
- });
- }
- // $table.reloadData(visibleData);
- resetMergeCellsQd();
- ElNotification({
- title: "刷新成功",
- type: "success"
- });
- };
- /**
- * @description 弹窗模块:床垫选择
- * @param data 当前数据
- * @param status 当前订单状态
- * @returns Promise
- */
- const fModelChoseMattress = (label?: string) => {
- return new Promise((resolve, reject) => {
- let _params = {
- arg_deptid: state.mainData[0].deptid
- };
- state.MattressDialogProps = {
- onSubmit: (res: any) => {
- // submit
- console.log("openCustDialog res", res);
- nextTick(() => {
- resolve(res.value[0]);
- });
- },
- onCancel: (error: any) => {
- // cancel 回调
- console.log("openCustDialog error", error);
- }
- };
- state.MattressDialogRef.show(_params, label);
- });
- };
- const toExcel = (fileName: string) => {
- // const { data, mxdata } = params;
- const data = state.mattressQDList;
- console.log("mainData :>> ", data);
- let default_font = { size: 12, name: "宋体" };
- let default_alignment: any = {
- vertical: "middle", // 垂直居中
- horizontal: "left", // 水平居左
- wrapText: true // 自动换行
- };
- const workbook = new Exceljs.Workbook(); // 创建工作簿
- const workST = workbook.addWorksheet("沙头工厂清单"); // 创建工作表(sheet1)
- // 冻结前7行
- workST.views = [{ state: "frozen", xSplit: 0, ySplit: 1 }];
- // let _columns = columns_qd.map((itm: any) => {
- // return {
- // name: itm.label
- // };
- // });
- // _columns.unshift({
- // name: ""
- // });
- // _columns.unshift({
- // name: "层"
- // });
- // let _rows = [];
- // // 第一层
- // let firstRow = [];
- // firstRow.push(0);
- // firstRow.push("--------------------");
- // _columns.map((col: any) => {
- // firstRow.push(col.);
- // });
- // _rows.push(firstRow);
- // 第二层
- // state.mattressQDList.map((itm: any) => {
- // let _row = [];
- // _row.push(1);
- // _row.push("├--------------------");
- // _columns.map((col: any) => {
- // _row.push(itm[col.field]);
- // });
- // _rows.push(_row);
- // });
- // console.log('toExcel _rows :>> ', _rows);
- // workST.addTable({
- // name: "workSTTable",
- // ref: "A1",
- // headerRow: true,
- // totalsRow: true,
- // // style: {
- // // theme: 'TableStyleDark3',
- // // showRowStripes: true,
- // // },
- // columns: _columns,
- // rows: _rows
- // });
- const worksLJ = workbook.addWorksheet("龙江总部清单"); // 创建工作表(sheet1)
- // // // 设置整个工作表的背景颜色为白色
- // // worksheet.eachRow(row => {
- // // // row.eachCell(cell => {
- // // // cell.fill = {
- // // // type: "pattern",
- // // // pattern: "solid",
- // // // bgColor: { argb: "FFFFFFFF" } // 白色
- // // // };
- // // // });
- // // row.eachCell({ includeEmpty: true }, function (cell, rowNumber) {
- // // cell.fill = {
- // // type: "pattern",
- // // pattern: "solid",
- // // bgColor: { argb: "FFFFFF" } // 白色
- // // };
- // // });
- // // });
- // // 宽度设置
- // const ACol = worksheet.getColumn("A");
- // ACol.width = 0.78;
- // const BCol = worksheet.getColumn("B");
- // BCol.width = 13.55;
- // BCol.key = "label";
- // BCol.style = {
- // font: default_font,
- // alignment: { ...default_alignment, vertical: "top" }
- // };
- // const CCol = worksheet.getColumn("C");
- // CCol.width = 49.33;
- // CCol.key = "dscrp";
- // CCol.style = {
- // font: default_font,
- // alignment: default_alignment
- // };
- // const DCol = worksheet.getColumn("D");
- // DCol.width = 5.69;
- // DCol.key = "qty";
- // DCol.style = {
- // font: default_font,
- // alignment: { ...default_alignment, horizontal: "center" }
- // };
- // const ECol = worksheet.getColumn("E");
- // ECol.width = 10;
- // ECol.key = "costamt";
- // ECol.style = {
- // font: default_font,
- // alignment: { ...default_alignment, horizontal: "right" }
- // };
- // const FCol = worksheet.getColumn("F");
- // FCol.width = 13;
- // FCol.key = "useqty";
- // FCol.style = {
- // font: default_font,
- // alignment: { ...default_alignment, horizontal: "right" }
- // };
- // const GCol = worksheet.getColumn("G");
- // GCol.width = 12.48;
- // GCol.key = "price";
- // GCol.style = {
- // font: default_font,
- // alignment: { ...default_alignment, horizontal: "right" }
- // };
- // //======================================= 第一行 =================================
- // // 合并A1到L1的单元格 (大标题)
- // worksheet.mergeCells("B1:F1");
- // const cellB1 = worksheet.getCell("B1");
- // let foreign_cost = formatAmount(data?.foreign_cost);
- // let currency = Number(data?.moneyrate) != 1 ? "美金" : "人民币";
- // cellB1.value = `报价日期:${formatTime(data.createtime, "{y}-{m}-{d}", false)} 报价金额:${foreign_cost}${currency}报价清单`;
- // // 设置第一行的单元格样式
- // cellB1.font = { size: 15, bold: true, name: "宋体" };
- // cellB1.alignment = default_alignment;
- // worksheet.getRow(1).height = 26; // 设置行高
- // //======================================= 第二行 =================================
- // worksheet.mergeCells("B2:F2");
- // const cellB2 = worksheet.getCell("B2");
- // cellB2.value = `财务底价:${formatAmount(data.nottax_dept_cost)} 佣金点数:${formatAmount(
- // data.commission
- // )} 税率:${formatAmount(data.taxrate)} `;
- // cellB2.font = default_font;
- // cellB2.alignment = default_alignment;
- // worksheet.getRow(2).height = 39;
- // //======================================= 第三行 =================================
- // worksheet.mergeCells("B3:F3");
- // const cellB3 = worksheet.getCell("B3");
- // cellB3.value = `额外点数:${formatAmount(data.other_rate)} 额外费用:${formatAmount(
- // data.extras_cost
- // )} 汇率:${formatAmount(data.moneyrate)} `;
- // cellB3.font = default_font;
- // cellB3.alignment = default_alignment;
- // worksheet.getRow(3).height = 18;
- // //======================================= 第四行 =================================
- // worksheet.mergeCells("B4:F4");
- // const cellB4 = worksheet.getCell("B4");
- // cellB4.value = `款式费用:${formatAmount(data.hrcost)} 边带费用:${formatAmount(
- // data.biandaicost
- // )} 总成本:${formatAmount(data.total_cost)} `;
- // cellB4.font = default_font;
- // cellB4.alignment = default_alignment;
- // worksheet.getRow(4).height = 18;
- // //======================================= 第五行 =================================
- // worksheet.mergeCells("B5:F5");
- // const cellB5 = worksheet.getCell("B5");
- // cellB5.value = `工厂利润率${formatAmount(data.profitrate)} 工艺点数:${formatAmount(
- // data.profitrate_point
- // )} 不含税出厂价:${formatAmount(data.nottax_factory_cost)} `;
- // cellB5.font = default_font;
- // cellB5.alignment = default_alignment;
- // worksheet.getRow(5).height = 18;
- // //======================================= 第六行 =================================
- // worksheet.mergeCells("B6:F6");
- // const cellB6 = worksheet.getCell("B6");
- // cellB6.value = `部门利润率:${formatAmount(data.dept_profitrate)} FOB费用:${formatAmount(
- // data.fob
- // )} 部门售价:${formatAmount(data.nottax_dept_cost)} `;
- // cellB6.font = default_font;
- // cellB6.alignment = default_alignment;
- // worksheet.getRow(6).height = 18;
- // //======================================= 第七行 =================================
- // worksheet.mergeCells("B7:F7");
- // const cellB7 = worksheet.getCell("B7");
- // cellB7.value = `让利点数:${formatAmount(data.dept_profitrate_rangli)} 海绵款扣点:${formatAmount(data.haimian_point)} `;
- // cellB7.font = default_font;
- // cellB7.alignment = default_alignment;
- // worksheet.getRow(7).height = 18;
- // //======================================= 第八行 =================================
- // // wf_retrieve_qingdan(params);
- // const headerRows = worksheet.insertRow(
- // 8,
- // { label: "项目", dscrp: "内容", qty: "数量", costamt: "金额", useqty: "用量", price: "单价" },
- // "n"
- // );
- // const insertedRows = worksheet.insertRows(9, state.tableData, "n");
- // // const cellBSum = worksheet.getCell(`B${9 + state.tableData.length}`);
- // // cellBSum.value = "材料合计:";
- // // const cellESum = worksheet.getCell(`E${9 + state.tableData.length}`);
- // // cellESum.value = getSummaries(state.tableData, "costamt");
- // const footerRows = worksheet.insertRow(
- // 9 + state.tableData.length,
- // { label: "材料合计:", dscrp: "", qty: "", costamt: getSummaries(state.tableData, "costamt"), useqty: "", price: "" },
- // "n"
- // );
- // // 设置单元格边框
- // let default_border: any = {
- // top: { style: "thin", color: { argb: "FF000000" } },
- // left: { style: "thin", color: { argb: "FF000000" } },
- // bottom: { style: "thin", color: { argb: "FF000000" } },
- // right: { style: "thin", color: { argb: "FF000000" } }
- // };
- // headerRows.eachCell(cell => {
- // cell.border = default_border;
- // });
- // footerRows.eachCell(cell => {
- // cell.border = default_border;
- // });
- // insertedRows.map(row => {
- // row.eachCell(cell => {
- // cell.border = default_border;
- // });
- // });
- // // label列内容相同时合并单元格
- // let same = 0;
- // state.tableData.map((t, i) => {
- // // label列内容相同的时候,多行合并单元格
- // if (i > 0 && t.label === state.tableData[i - 1].label) {
- // same++;
- // } else {
- // if (same > 0) {
- // worksheet.mergeCells(`B${9 + i - 1}:B${9 + i - 1 - same}`);
- // }
- // same = 0;
- // }
- // });
- // 下载工作簿
- workbook.xlsx.writeBuffer().then(buffer => {
- saveAs(new Blob([buffer], { type: "application/octet-stream" }), fileName + state.mainData[0].erp_mtrlcode + ".xlsx");
- });
- };
- const YWAudit = (type: any, curRecords: any, cb?: any) => {
- if (!curRecords.length) {
- ElMessage.warning(t("business.tips.mattress.records"));
- return;
- }
- let list = curRecords.map((item: any) => {
- return {
- mattressid: Number(item.mattressid)
- };
- });
- ElMessageBox.confirm(`是否确定要${type ? "审核" : "撤审"}${curRecords.length}张床垫报价单吗?`, "询问", {
- confirmButtonText: t("common.okText"),
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- MattressYWAudit({ list, type }).then(() => {
- ElMessage.success(`业务${type ? "审核" : "撤审"}成功!`);
- cb && cb();
- // vxeTableRef.value.refresh();
- });
- })
- .catch((e: TypeError) => {
- console.log("e :>> ", e);
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- };
- const JSAudit = (type: any, curRecords: any, cb?: any) => {
- if (!curRecords.length) {
- ElMessage.warning(t("business.tips.mattress.records"));
- return;
- }
- let list = curRecords.map((item: any) => {
- return {
- mattressid: Number(item.mattressid)
- };
- });
- ElMessageBox.confirm(`是否确定要${type ? "审核" : "撤审"}${curRecords.length}张床垫报价单吗?`, "询问", {
- confirmButtonText: t("common.okText"),
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- MattressJSAudit({ list, type }).then(() => {
- ElMessage.success(`产品补充${type ? "审核" : "撤审"}成功!`);
- cb && cb();
- // vxeTableRef.value.refresh();
- });
- })
- .catch((e: TypeError) => {
- console.log("e :>> ", e);
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- };
- const JS2Audit = (type: any, curRecords: any, cb?: any) => {
- if (!curRecords.length) {
- ElMessage.warning(t("business.tips.mattress.records"));
- return;
- }
- let list = curRecords.map((item: any) => {
- return {
- mattressid: Number(item.mattressid)
- };
- });
- ElMessageBox.confirm(`是否确定要${type ? "审核" : "撤审"}${curRecords.length}张床垫报价单吗?`, "询问", {
- confirmButtonText: t("common.okText"),
- cancelButtonText: "否",
- type: "warning"
- })
- .then(() => {
- MattressJS2Audit({ list, type }).then(() => {
- ElMessage.success(`清单补充${type ? "审核" : "撤审"}成功!`);
- cb && cb();
- // vxeTableRef.value.refresh();
- });
- })
- .catch((e: TypeError) => {
- console.log("e :>> ", e);
- ElMessage({
- type: "info",
- message: "操作取消"
- });
- });
- };
- /**
- * @description 弹窗模块:物料选择
- * @param data 当前数据
- * @param status 当前订单状态
- * @returns Promise
- */
- const fModelChoseCodeMx = (data: any, params: any, cb: any, label?: string, $table?: any) => {
- return new Promise((resolve, reject) => {
- // if (!ALLOW_EDIT_STATE.includes(status)) return;
- let _params = {
- keyword: "",
- pzid: params.pzid
- };
- state.CodeMxDialogProps = {
- onSubmit: (res: any) => {
- // submit
- console.log("openCustDialog res", res);
- nextTick(() => {
- cb(data, res.value[0], $table);
- resolve(1);
- });
- },
- onCancel: (error: any) => {
- // cancel 回调
- console.log("openCustDialog error", error);
- }
- };
- state.CodeMxDialogRef.show(_params, label);
- });
- };
- const dynamicRef = name => {
- return state[name]; // 获取ref的值
- };
- const wf_fine_erp_pz = () => {};
- return {
- ...toRefs(state),
- columns,
- columns_detail,
- columns_yw,
- columns_yw_qd,
- columns_qd,
- tableProps_mx,
- tableProps_qd,
- RetriveMattressInterface,
- RefreshMattressInterfaceList,
- RefreshMattressInterfaceQdList,
- fModelChoseMattress,
- toExcel,
- toCreateMtrl,
- toCreateORDelMtrlPf,
- // toUpdateL1Planprice,
- YWAudit,
- JSAudit,
- JS2Audit,
- resetMergeCellsQd,
- resetMergeCells,
- funcAddRowQd,
- funcCmpCC,
- dynamicRef
- };
- };
|