1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300 |
- <script>
- import orderApi from "@/api/business/purchase/purchase-order";
- import {
- initColumns,
- initDicts,
- initRules,
- initParams,
- } from "@/utils/init/index.js";
- import judgeColumns from "./column";
- import { tax, currency } from "@/components/popover-select-v2/fetch";
- import VirtualScroll from "el-table-virtual-scroll";
- import { VirtualColumn } from "el-table-virtual-scroll";
- const { Columns, TabColumns } = judgeColumns();
- const NewColumns = initColumns(Columns);
- const NewTabColumns = TabColumns.map((element) => ({
- ...element,
- tableColumns: initColumns(element.tableColumns).map((item, index) => ({
- ...item,
- hidden: true,
- })),
- }));
- const SelectColumns = NewColumns.filter(
- (column) => column.inputType === "Select"
- );
- NewTabColumns.forEach((column) => {
- SelectColumns.push(
- ...column.tableColumns.filter((cColumn) => cColumn.inputType === "Select")
- );
- });
- export default {
- name: "AddPurchaseOrderDrawer",
- props: {},
- dicts: initDicts(SelectColumns),
- components: {
- "virtual-scroll": VirtualScroll,
- VirtualColumn,
- FileUploadCenter: () => import("../components/FileUploadCenter/index.vue"),
- popDialog: () => import("@/components/PopDialog/index.vue"),
- BatchImport: () => import("@/components/BatchImport/index.vue"),
- ButtonHide: () => import("../components/hide/index.vue"),
- },
- data() {
- return {
- visible: false,
- loading: false,
- tabLoading: false,
- columns: NewColumns,
- rules: initRules(NewColumns),
- count: 0,
- params: {
- ...initParams(NewColumns),
- puOrderItemList: [],
- // 执行结果
- // puOrderExecuteList: [],
- },
- tabColumns: NewTabColumns,
- tabName: "puOrderItemList",
- isCopy: false,
- tableData: [], //虚拟滚动加载显示的数据
- rowHeight: 60,
- size: "mini",
- };
- },
- computed: {
- role: {
- get() {
- let { roles } = this.$store.state.user;
- return (
- roles.find((item) => item === "syfz-purchaseorder") ||
- "procurementManager"
- );
- },
- set() {},
- },
- tabHeight: {
- get() {
- return `${
- this.params["puOrderItemList"].length
- ? this.params["puOrderItemList"].length > 8
- ? 500
- : this.params["puOrderItemList"].length * 36 + 120
- : 120
- }px`;
- },
- set() {},
- },
- innerColumns: {
- get() {
- let { tabName, tabColumns } = this;
- let obj = tabColumns.find(({ key }) => key === tabName).tableColumns;
- return obj;
- },
- set(value) {
- let { tabName, tabColumns } = this;
- this.tabColumns = tabColumns.map((item) => {
- if (item.key === tabName) {
- item.tableColumns = value;
- }
- return { ...item };
- });
- this.$nextTick(() => {
- this.$refs.puOrderItemList &&
- this.$refs.puOrderItemList[0].doLayout();
- });
- },
- },
- },
- watch: {
- // 同步物料信息与执行结果
- // "params.puOrderItemList": {
- // handler(nVal, oVal) {
- // this.visible &&
- // this.handleSynchronousMaterial(
- // "puOrderItemList",
- // "puOrderExecuteList"
- // );
- // },
- // deep: true,
- // },
- // 执行结果监听
- // "params.puOrderExecuteList": {
- // handler(nVal, oVal) {
- // this.visible &&
- // this.handleSynchronousMaterial(
- // "puOrderExecuteList",
- // "puOrderItemList"
- // );
- // },
- // deep: true,
- // },
- "params.billType": {
- handler(nVal, oVal) {
- let billList = ["21-Cxx-02", "21-Cxx-04", "21-Cxx-10", "21-Cxx-14"];
- this.params.warehouse = "";
- this.params.warehouseName = "";
- this.params.goodsAllocation = "";
- this.params.goodsAllocationName = "";
- this.params["puOrderItemList"] = this.params["puOrderItemList"].map(
- (item) => ({
- ...item,
- goodsAllocation: "",
- goodsAllocationName: "",
- })
- );
- if (billList.find((item) => item === nVal)) {
- this.rules.warehouseName = [
- {
- required: true,
- message: "WMS入库仓库不能为空",
- trigger: "change",
- },
- ];
- } else {
- this.rules.warehouseName = null;
- }
- this.rules.goodsAllocationName = null;
- this.count++;
- },
- },
- "params.isBack": {
- handler(nVal, oVal) {
- if (nVal === "Y") {
- this.rules.retReasonName = [
- { required: true, message: "退换原因不能为空", trigger: "change" },
- ];
- this.rules.processTypeName = [
- { required: true, message: "处理方式不能为空", trigger: "change" },
- ];
- } else {
- this.rules.retReasonName = null;
- this.rules.processTypeName = null;
- }
- this.count++;
- },
- },
- },
- methods: {
- beforeOpen() {
- if (!this.isCopy) {
- const { deptName, deptId, name, nickName, orgName, orgId } =
- this.$store.state.user;
- this.params.puOrg = orgId;
- this.params.puOrgName = orgName;
- this.params.buyer = name;
- this.params.buyerName = nickName;
- this.params.puDept = deptId;
- this.params.puDeptName = deptName;
- this.params.billDate = new Date().Format("yyyy-MM-dd");
- this.params.createTime = new Date().Format("yyyy-MM-dd HH:mm:ss");
- console.log(this.params, "this.params");
- // this.addTableRow();
- }
- },
- setVisible(prop, iscopy) {
- this.visible = prop;
- this.isCopy = iscopy;
- if (!this.visible) {
- this.$refs["orderAddForm"].clearValidate();
- }
- },
- // 复制赋值
- async setCopyParams(id) {
- try {
- this.loading = true;
- const { code, msg, data } = await orderApi.details(id);
- if (code === 200) {
- this.params = {
- ...data,
- id: "",
- code: "",
- isEnd: "N",
- status: "0",
- source: "3",
- isClose: "N",
- billDate: new Date().Format("yyyy-MM-dd"),
- createTime: new Date().Format("yyyy-MM-dd HH:mm:ss"),
- closeTime: "",
- oaDemandNo: "",
- isInvoice: "N",
- isSendWms: "N",
- rebateMoney: "",
- invoiceMoney: "",
- paymentMoney: "",
- applyPaymentMoney: "",
- erpOrderCode: "",
- closeReason: "",
- };
- try {
- const { code, rows } = await orderApi.REFER(
- {
- type: "WAREHOUSE_PARAM",
- search: this.params.warehouseName,
- isPage: true,
- },
- { pageNum: 1, pageSize: 10 }
- );
- if (code == 200) {
- this.judgeGoodsAllocation(rows[0].csFlag);
- }
- } catch (error) {}
- for (const key in this.params) {
- // if (Array.isArray(this.params[key])) {
- // if (key === "puOrderItemList" || key === "puOrderExecuteList") {
- if (key === "puOrderItemList") {
- this.params[key].forEach((v) => {
- v.id = "";
- v.demandCode = "";
- v.closeReason = "";
- v.goodsAllocation = "";
- v.goodsAllocationName = "";
- v.sourceBillDate = "";
- v.deliveryDate = "";
- v["isInvoice"] && (v["isInvoice"] = "N");
- v["isStorage"] && (v["isStorage"] = "N");
- v["isArrival"] && (v["isArrival"] = "N");
- v["isPayment"] && (v["isPayment"] = "N");
- });
- }
- }
- // 清空 累计本币开票金额、
- // 累计付款金额、累计付款申请金额、累计开票主数量、最终关闭时间
- // 、最终关闭、已同步WMS 、订单抵扣余额金额、订单使用返利金额、 发票标识
- }
- } catch (err) {
- //
- } finally {
- this.loading = false;
- }
- },
- // 增行
- addTableRow(prop) {
- for (const key in this.params) {
- // if (Array.isArray(this.params[key])) {
- // if (key === "puOrderItemList" || key === "puOrderExecuteList") {
- if (key === "puOrderItemList") {
- const arr = this.tabColumns.find(
- (element) => element.key === key
- ).tableColumns;
- let rowData = initParams(arr, "key", "value");
- console.log(rowData, "rowData");
- "rowno" in rowData &&
- (rowData["rowno"] = this.params[key].length
- ? this.params[key][this.params[key].length - 1]["rowno"] + 1
- : this.params[key].length + 1);
- // 物料
- if ("rowNo" in rowData) {
- rowData["rowNo"] = this.params[key].length
- ? this.params[key][this.params[key].length - 1]["rowNo"] + 1
- : this.params[key].length + 1;
- // 扣税类别
- rowData["taxDeductClassify"] = "1";
- // 折本汇率
- rowData["exchangeRate"] = "1";
- // 价格类型
- rowData["priceType"] = "order";
- // 币种
- rowData["currency"] = "1002Z0100000000001K1";
- rowData["currencyName"] = "人民币";
- }
- rowData["insertId"] = new Date().getTime();
- // 是否完成询价,新增明细行需默认明细为false
- // rowData["whetherCompleteInquiry"] = false;
- this.params[key].push(rowData);
- }
- }
- // const arr = this.tabColumns.find(
- // (element) => element.key === this.tabName
- // ).tableColumns;
- // prop.push(initParams(arr, "key", "value"));
- },
- // 删行
- // 删除行
- async delTableRow(prop, row, name) {
- let delNo = name === "puOrderItemList" ? "rowNo" : "rowno";
- if (prop.length === 1) {
- this.$alert("订单行不允许为空", "提示", {
- confirmButtonText: "确定",
- callback: (action) => {
- // this.$message({
- // type: 'info',
- // message: `action: ${ action }`
- // });
- },
- });
- } else {
- for (const key in this.params) {
- if (key === "puOrderItemList" || key === "puOrderExecuteList") {
- this.params[key].forEach((item, index) => {
- let flag = key === "puOrderItemList" ? "rowNo" : "rowno";
- // if(item.id && item.id === row.id){
- // console.log('删除已有ID的');
- // item['delFlag'] = '2';
- // }
- if (item[flag] && item[flag] === row[delNo]) {
- item.id
- ? (item["delFlag"] = "2")
- : this.params[key].splice(index, 1);
- }
- });
- // this.params[key][index].id ?
- // (this.params[key][index]['delFlag'] = '2') :
- // this.params[key].splice(index, 1);
- }
- }
- await this.handleGetPrice();
- }
- },
- // 同步子表物料
- handleSynchronousMaterial(tableOne, tableTwo) {
- let _this = this;
- // this.params[tableOne]-- -> this.params[tableTwo]
- this.params[tableOne] &&
- this.params[tableOne].forEach((item, index) => {
- for (const key in item) {
- if (!_this.params[tableTwo][index]) {
- const arr = _this.tabColumns.find(
- (element) => element.key === tableTwo
- ).tableColumns;
- _this.params[tableTwo].push(initParams(arr, "key", "value"));
- }
- if (key in _this.params[tableTwo][index]) {
- _this.params[tableTwo][index].material = item.material;
- key !== "id" && (_this.params[tableTwo][index][key] = item[key]);
- }
- }
- });
- },
- // 取消
- handleCancel() {
- this.params = {
- ...initParams(this.columns),
- puOrderItemList: [],
- // puOrderExecuteList: [],
- };
- this.setVisible(false);
- },
- // 判断保存条件
- judgeSaveCondition(cb) {
- this.$refs["orderAddForm"].validate(async (valid) => {
- if (valid) {
- if (
- !this.params["puOrderItemList"].length
- // || !this.params["puOrderExecuteList"].length
- ) {
- this.$notify.error({
- title: "错误",
- message: "请填写订单行!",
- });
- return false;
- }
- // puOrderItemList
- // let isPrice = this.params.puOrderItemList.filter(item => !item.whetherCompleteInquiry);
- // if(isPrice.length && this.role === 'procurementManager'){
- // this.$notify.error({
- // title: '错误',
- // message: '询价失败!'
- // });
- // return false
- // }
- cb();
- } else {
- this.$notify.error({
- title: "错误",
- message: "存在必填项未填写",
- });
- console.log("error submit!!");
- return false;
- }
- });
- },
- // 保存
- handleSava() {
- console.log(this.params, "this.params---------");
- this.judgeSaveCondition(async () => {
- try {
- this.loading = true;
- const { code, msg } = await orderApi.create(this.params);
- if (code === 200) {
- this.handleCancel();
- }
- } catch (err) {
- //
- } finally {
- this.loading = false;
- }
- });
- },
- judgeGoodsAllocation(porp) {
- if (porp === "Y") {
- this.rules.goodsAllocationName = [
- { required: true, message: "货位不能为空", trigger: "change" },
- ];
- } else {
- this.rules.goodsAllocationName = null;
- }
- this.count++;
- },
- // 主表参照改变之后
- async handleReferChange(val, type, source) {
- let page = { pageNum: 1, pageSize: 10 };
- // 供应商选择
- if (type === "SUPPLIER_PARAM") {
- let relevanceRefer = [
- {
- // 供应商联系人
- key: "supplierContacts",
- params: {
- type: "SUPPLIERCONTACTS_PARAM",
- supplierId: val.id,
- },
- },
- {
- // 供应商业务员
- key: "supplierPersonal",
- params: {
- type: "PSNLICENSE_PARAM",
- supplierId: val.id,
- pkOrg: source.puOrg,
- },
- },
- ];
- try {
- let promiseArr = relevanceRefer.map((refer) => {
- return new Promise((resolve, reject) => {
- orderApi
- .REFER(
- {
- ...refer.params,
- search: "",
- isPage: true,
- },
- page
- )
- .then((res) => {
- let { code, rows } = res;
- if (code === 200) {
- source[refer.key] = rows[0] ? rows[0].id : "";
- source[`${refer.key}Name`] = rows[0] ? rows[0].name : "";
- resolve();
- }
- });
- });
- });
- Promise.all(promiseArr).then(async () => {
- // 明细不为空的情况下进行询价
- let detailList = this.params["puOrderItemList"].filter(
- (item) => item.material && item.material != ""
- );
- if (detailList.length) {
- await this.handleGetPrice();
- }
- });
- } catch (error) {}
- }
- // 组织
- if (type === "ORG_PARAM") {
- for (const key in this.params) {
- // if (Array.isArray(this.params[key])) {
- if (key === "puOrderItemList" || key === "puOrderExecuteList") {
- this.params[key] = [];
- } else if (key === "sysFileRecordList") {
- this.params[key] = [];
- } else if (
- key != "puOrg" &&
- key != "puOrgName" &&
- // key != "buyer" &&
- // key != "buyerName" &&
- // key != "puDept" &&
- // key != "puDeptName" &&
- // key != "status" &&
- key != "billDate" &&
- key != "createTime"
- ) {
- this.params[key] = "";
- } else {
- }
- }
- }
- // WMS仓库
- if (type === "WAREHOUSE_PARAM") {
- // 货位在表头
- // this.judgeGoodsAllocation(val.csFlag);
- // source.goodsAllocation = "";
- // source.goodsAllocationName = "";
- // 货位在表体
- this.params.puOrderItemList = this.params.puOrderItemList.map(
- (item) => ({
- ...item,
- goodsAllocation: "",
- goodsAllocationName: "",
- })
- );
- }
- },
- // 下拉框选择改变
- handleSelectChange(val, typeName) {
- if (val === "billType") {
- this.params["billTypeName"] = this.dict.type[typeName].find(
- (item) => item.value == this.params[val]
- ).label;
- }
- },
- // 子表参照改变之后
- async handleTabReferChange(val, props, source) {
- // let { type, copy, dataMapping } = props;
- let { params, tabName } = this;
- console.log(val, "val", props, "props", source, "source");
- const DPtime = val.deliveryPeriod * 24 * 60 * 60 * 1000;
- source.deliveryDate = new Date(
- new Date(params.createTime).getTime() + DPtime
- ).Format("yyyy-MM-dd");
- // // 复制
- // if (copy) {
- // if (type == "MATERIAL_PARAM") {
- // for (let i = 1; i < val.length; i++) {
- // this.addTableRow(params[tabName]);
- // }
- // let value = val.map((item) => {
- // let columnValue = {};
- // for (let key in dataMapping) {
- // columnValue[key] = item[dataMapping[key]];
- // }
- // return columnValue;
- // });
- // }
- // }
- // 触发物料参照询价
- if (props == "MATERIAL_PARAM" && source.qty && source.qty != "") {
- source["qty"] = 0;
- // source['whetherCompleteInquiry'] = false;
- source["taxPrice"] = 0;
- source["money"] = 0;
- source["taxDeductMoneya"] = 0;
- source["price"] = 0;
- source["notaxMoney"] = 0;
- source["tax"] = 0;
- this.params["qty"] = 0;
- this.params["originalQty"] = 0;
- this.params["money"] = 0;
- this.params["originalMoney"] = 0;
- this.params["notaxMoney"] = 0;
- source.isDrug = val.materialMedcine.isDrug == "0" ? "Y" : "N";
- // await this.handleGetPrice();
- }
- // 物料触发税率
- if (props == "MATERIAL_PARAM") {
- let { rateCode } = source;
- console.log(rateCode, "rateCode-------");
- try {
- // try
- this.loading = true;
- const { ntaxrate } = await tax(rateCode);
- source.tax = ntaxrate === "0E-8" ? 0 : ntaxrate;
- } catch (err) {
- // catch
- console.error(err);
- } finally {
- // finally
- this.loading = false;
- }
- }
- },
- // 子表下拉框改变
- async handleTabSelectChange(type, row) {
- if (type == "priceType" && row.material && row.qty && row.qty != "") {
- // row['whetherCompleteInquiry'] = false;
- await this.handleGetPrice();
- }
- },
- // 子表inputNumber
- handleInputChange(row, type) {
- // 物料数量变化----询价
- if (
- (type == "qty" || type == "taxPrice" || type == "taxDeductMoneya") &&
- row.material
- ) {
- // row['whetherCompleteInquiry'] = false;
- this.handleGetPrice();
- }
- this.$refs.puOrderItemList[0].updateFooter();
- // this.$refs.puOrderExecuteList[0].updateFooter();
- // if(this.role === 'syfz-purchaseorder' && row.material && (type == "qty" ||type === "taxPrice" )){
- // row.money = row.qty * row.taxPrice;
- // }
- },
- // 子表多选框改变
- handleTabCheckbox(type, source) {
- // 勾选赠品,价税合计更新为0,含税单价、无税单价更新为0
- if (
- type === "isGift" &&
- source.material &&
- source.qty &&
- source.qty != ""
- ) {
- // source['whetherCompleteInquiry'] = false;
- this.handleGetPrice();
- }
- },
- // 询价 getPrice
- async handleGetPrice() {
- try {
- // action:insert(新增)、revise(修订)、update(编辑)
- let { code, data } = await orderApi.getPrice({
- ...this.params,
- action: "insert",
- });
- if (code == 200) {
- this.params = { ...data };
- }
- } catch (error) {}
- },
- async handelImport(fileList) {
- try {
- let formData = new FormData();
- formData.append("file", fileList[0].raw);
- let tabList = {
- puOrderItemList: [...this.params.puOrderItemList],
- warehouse: this.params.warehouse,
- // puOrderExecuteList: [...this.params.puOrderExecuteList],
- };
- const blob = new Blob([JSON.stringify(tabList)], {
- type: "application/json",
- });
- formData.append("tabList", blob);
- this.$modal.loading("正在上传文件,请稍候...");
- let {
- code,
- data: { puOrderItemList, puOrderExecuteList },
- } = await orderApi.orderImport(formData);
- if (code == 200) {
- // for (const key in data) {
- // this.params[key].push(...data[key]);
- // }
- this.params["puOrderItemList"] = [...puOrderItemList];
- this.params["puOrderExecuteList"] = [...puOrderExecuteList];
- let { setVisible } = this.$refs.batchImport;
- setVisible(false);
- this.handleGetPrice();
- }
- } catch (error) {
- } finally {
- this.$modal.closeLoading();
- }
- },
- async handleTemDownload() {
- this.download(
- "/pu/order/downloadFailData",
- {},
- `采购订单物料信息模板${new Date().getTime()}.xlsx`
- );
- },
- getSummaries({ columns, data }) {
- const means = []; // 合计
- let { tabColumns, tabName } = this;
- columns.forEach((column, columnIndex) => {
- if (columnIndex === 0) {
- means.push("合计");
- } else {
- const values = data.map((item) => Number(item[column.property]));
- let sumColumn = tabColumns
- .find((tab) => tab.key === tabName)
- .tableColumns.filter((item) => item.hidden)
- .filter(
- ({ key, isSummary }) => isSummary && key === column.property
- );
- // 合计
- // if (!values.every(value => isNaN(value))) {
- if (sumColumn.length) {
- means[columnIndex] = values.reduce((prev, curr) => {
- const value = Number(curr);
- if (!isNaN(value)) {
- return prev + curr;
- } else {
- return prev;
- }
- }, 0);
- means[columnIndex] = means[columnIndex].toFixed(2);
- } else {
- means[columnIndex] = "";
- }
- }
- });
- // sums[index] = sums[index] && sums[index].toFixed(2); // 保留2位小数,解决小数合计列
- return [means];
- },
- // 子表-批量复制
- async tabCopyChange(prop, { column, source }) {
- let { key, referName, dataMapping } = column;
- try {
- this.tabLoading = true;
- if (key === "materialCode") {
- let {
- code,
- data: { puOrderItemList },
- } = await orderApi.materialCopy({
- materialCode: prop,
- puOrderItemList: this.params.puOrderItemList.filter(
- (item) => item.rowNo != source.rowNo
- ),
- // puOrderExecuteList
- });
- if (code == 200) {
- this.params.puOrderItemList = [...puOrderItemList];
- // this.params.puOrderExecuteList = [...puOrderExecuteList];
- }
- } else {
- let params = {
- searchList: prop,
- type: referName,
- };
- key === "goodsAllocationName" &&
- (params["stordocId"] = this.params.warehouse);
- let { code, rows } = await orderApi.REFER(params);
- if (code == 200) {
- if (!rows.length) {
- this.$notify.warning({
- message: "粘贴数据检索为空,请检查是否符合要求!",
- });
- for (const key in dataMapping) {
- source[key] = "";
- }
- }
- rows = rows.map((item) => {
- let obj = {};
- for (const key in dataMapping) {
- obj[key] = item[dataMapping[key]];
- }
- return obj;
- });
- let invariant = this.params.puOrderItemList.filter(
- (item) => item.rowNo < source.rowNo
- );
- let change = this.params.puOrderItemList
- .filter((item) => !(item.rowNo < source.rowNo))
- .map((item, index) => {
- return {
- ...item,
- ...rows[index],
- };
- });
- this.params.puOrderItemList = [...invariant, ...change];
- }
- }
- } catch (error) {
- } finally {
- this.tabLoading = false;
- }
- },
- inputTabChange(prop, { column, source }) {
- let { key, copy } = column;
- // 数量-批量复制
- if (copy) {
- if (key === "qty") {
- let munList = prop.split(/,|,|\s+/);
- let invariant = this.params.puOrderItemList.filter(
- (item) => item.rowNo < source.rowNo
- );
- let change = this.params.puOrderItemList
- .filter((item) => !(item.rowNo < source.rowNo))
- .map((item, index) => {
- return {
- ...item,
- qty: munList[index] || item.qty,
- };
- });
- this.params.puOrderItemList = [...invariant, ...change];
- this.handleGetPrice();
- }
- }
- },
- onHide(prop) {
- this.innerColumns = prop;
- },
- },
- created() {
- console.log("ADD CREATED", this.params);
- },
- mounted() {},
- updated() {
- this.$nextTick(() => {
- // this.$refs.puOrderExecuteList &&
- // this.$refs.puOrderExecuteList[0].doLayout();
- this.$refs.puOrderItemList && this.$refs.puOrderItemList[0].doLayout();
- });
- },
- destroyed() {},
- };
- </script>
- <template>
- <el-drawer
- direction="btt"
- size="100%"
- :with-header="false"
- :visible.sync="visible"
- @open="beforeOpen"
- @close="$emit('close')"
- v-loading="loading"
- >
- <el-form
- :size="size"
- label-position="right"
- ref="orderAddForm"
- class="orderAddForm"
- label-width="140px"
- :model="params"
- :rules="rules"
- :key="count"
- >
- <el-card
- :body-style="{
- padding: '20px 20px 10px',
- display: 'flex',
- 'flex-wrap': 'wrap',
- }"
- style="margin: 10px"
- >
- <div
- slot="header"
- style="
- display: flex;
- justify-content: space-between;
- align-items: center;
- "
- >
- <h3>新增</h3>
- <div style="text-align: right">
- <el-button :size="size" type="primary" @click="handleSava"
- >保存</el-button
- >
- <el-button :size="size" @click="handleCancel">取消</el-button>
- </div>
- </div>
- <el-row style="display: flex; flex-wrap: wrap">
- <el-col
- v-for="(column, index) in columns"
- :key="index"
- :span="column.span || 6"
- >
- <el-form-item
- :prop="column.key"
- :label="column.title"
- v-if="column.isShow"
- >
- <el-input
- v-if="column.inputType === 'Input'"
- v-model="params[column.key]"
- :placeholder="column.placeholder"
- :clearable="column.clearable"
- :disabled="column.disabled"
- style="width: 100%"
- >
- </el-input>
- <dr-popover-select
- v-if="column.inputType === 'PopoverSelect'"
- v-model="params[column.key]"
- :value-key="column.valueKey"
- :source.sync="params"
- :title="column.title"
- :type="column.referName"
- :disabled="column.disabled"
- :clearable="column.clearable"
- :multiple="column.multiple"
- :placeholder="column.placeholder"
- :data-mapping="column.dataMapping"
- :query-params="column.queryParams"
- @change="handleReferChange"
- ></dr-popover-select>
- <el-input
- v-if="column.inputType === 'Textarea'"
- v-model="params[column.key]"
- type="textarea"
- :rows="column.rows"
- :placeholder="column.placeholder"
- :clearable="column.clearable"
- :disabled="column.disabled"
- style="width: 100%"
- ></el-input>
- <el-input-number
- v-if="column.inputType === 'InputNumber'"
- v-model="params[column.key]"
- :precision="column.precision"
- :controls-position="column.controlsPosition"
- :placeholder="column.placeholder"
- :clearable="column.clearable"
- :disabled="column.disabled"
- style="width: 100%"
- >
- </el-input-number>
- <el-select
- v-if="column.inputType === 'Select'"
- v-model="params[column.key]"
- :disabled="column.disabled"
- :clearable="column.clearable"
- :placeholder="column.placeholder"
- style="width: 100%"
- filterable
- @change="handleSelectChange(column.key, column.referName)"
- >
- <el-option
- v-for="item in dict.type[column.referName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <el-select
- v-if="column.inputType === 'TagSelect'"
- v-model="params[column.key]"
- multiple
- clearable
- collapse-tags
- :placeholder="column.placeholder"
- :clearable="column.clearable"
- :disabled="column.disabled"
- style="width: 100%"
- >
- <template #prefix>
- <el-icon
- class="el-icon-view"
- style="cursor: pointer"
- @click.stop="$message.info(234)"
- >
- </el-icon>
- </template>
- <el-option
- v-for="item in options"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <el-date-picker
- v-if="column.inputType === 'DatePicker'"
- v-model="params[column.key]"
- :type="column.type"
- :placeholder="column.placeholder"
- :clearable="column.clearable"
- :disabled="column.disabled"
- :picker-options="column.pickerOptions"
- style="width: 100%"
- ></el-date-picker>
- <el-checkbox
- v-if="column.inputType === 'Checkbox'"
- v-model="params[column.key]"
- :disabled="column.disabled"
- true-label="Y"
- false-label="N"
- ></el-checkbox>
- <file-upload-center
- v-if="column.inputType === 'Upload'"
- v-model="params[column.key]"
- :file-type="column.fileType"
- ></file-upload-center>
- </el-form-item>
- </el-col>
- </el-row>
- </el-card>
- <el-card
- :body-style="{
- padding: '20px',
- display: 'flex',
- 'flex-wrap': 'wrap',
- position: 'relative',
- }"
- style="margin: 10px"
- >
- <el-tabs v-model="tabName" style="width: 100%" v-loading="tabLoading">
- <el-tab-pane
- v-for="(column, index) in tabColumns"
- :key="index"
- :label="column.title"
- :name="column.key"
- >
- <ux-grid
- border
- use-virtual
- keep-source
- show-summary
- show-overflow
- beautify-table
- :ref="column.key"
- :size="size"
- :height="tabHeight"
- style="width: 100%"
- :data="params[column.key]"
- :summary-method="getSummaries"
- :header-row-style="{
- color: '#515a6e',
- }"
- >
- <template slot="empty">暂无数据</template>
- <ux-table-column
- v-for="(cColumn, cIndex) in column.tableColumns.filter(
- (item) => item.hidden
- )"
- :key="cColumn.key + cColumn.hidden"
- :title="cColumn.title"
- :width="cColumn.width || 80"
- :field="cColumn.key"
- resizable
- >
- <template slot="header" slot-scope="scope">
- <span v-if="cColumn.require" style="color: #ff4949">*</span>
- <span>
- {{ cColumn.title }}
- </span>
- </template>
- <template slot-scope="scope">
- <el-form-item label-width="0">
- <el-tag v-if="cColumn.key === 'index'">
- {{ scope.$index + 1 }}
- </el-tag>
- <el-input
- v-if="cColumn.inputType === 'Input'"
- v-model="scope.row[cColumn.key]"
- :placeholder="cColumn.placeholder"
- :clearable="cColumn.clearable"
- :disabled="cColumn.disabled"
- :size="size"
- style="width: 100%"
- @change="
- (prop) =>
- inputTabChange(prop, {
- column: cColumn,
- source: scope.row,
- })
- "
- ></el-input>
- <!-- copy -->
- <dr-popover-select
- v-if="cColumn.inputType === 'PopoverSelect'"
- v-model="scope.row[cColumn.key]"
- :source.sync="scope.row"
- :title="cColumn.title"
- :value-key="cColumn.valueKey"
- :type="cColumn.referName"
- :disabled="cColumn.disabled"
- :clearable="cColumn.clearable"
- :multiple="cColumn.multiple"
- :copy="cColumn.copy"
- :placeholder="cColumn.placeholder"
- :data-mapping="cColumn.dataMapping"
- :query-params="
- cColumn.key !== 'goodsAllocationName'
- ? cColumn.queryParams
- : () => ({
- stordocId: params.warehouse,
- pkOrg: params.puOrg,
- })
- "
- @change="handleTabReferChange"
- @copyChange="
- (prop) =>
- tabCopyChange(prop, {
- column: cColumn,
- source: scope.row,
- })
- "
- >
- </dr-popover-select>
- <el-input-number
- v-if="cColumn.inputType === 'InputNumber'"
- v-model="scope.row[cColumn.key]"
- :disabled="cColumn.disabled"
- :clearable="cColumn.clearable"
- :precision="cColumn.precision"
- :placeholder="cColumn.placeholder"
- :controls-position="cColumn.controlsPosition"
- :min="cColumn.key === 'reservedQty' ? 0 : -Infinity"
- :size="size"
- style="width: 100%"
- @change="handleInputChange(scope.row, cColumn.key)"
- ></el-input-number>
- <el-select
- v-if="cColumn.inputType === 'Select'"
- v-model="scope.row[cColumn.key]"
- filterable
- :size="size"
- :disabled="cColumn.disabled"
- :clearable="cColumn.clearable"
- :placeholder="cColumn.placeholder"
- style="width: 100%"
- @change="handleTabSelectChange(cColumn.key, scope.row)"
- >
- <el-option
- v-for="item in dict.type[cColumn.referName]"
- :key="item.value"
- :label="item.label"
- :value="item.value"
- ></el-option>
- </el-select>
- <el-checkbox
- v-if="cColumn.inputType === 'Checkbox'"
- v-model="scope.row[cColumn.key]"
- :disabled="cColumn.disabled"
- true-label="Y"
- false-label="N"
- @change="handleTabCheckbox(cColumn.key, scope.row)"
- ></el-checkbox>
- <el-date-picker
- v-if="cColumn.inputType === 'DatePicker'"
- v-model="scope.row[cColumn.key]"
- :size="size"
- :type="cColumn.type"
- :placeholder="cColumn.placeholder"
- :clearable="cColumn.clearable"
- :disabled="cColumn.disabled"
- :picker-options="cColumn.pickerOptions"
- style="width: 100%"
- ></el-date-picker>
- </el-form-item>
- </template>
- </ux-table-column>
- <ux-table-column fixed="right" label="操作" width="80">
- <template slot-scope="scope">
- <el-button
- @click.native.prevent="
- delTableRow(params[tabName], scope.row, tabName)
- "
- type="text"
- :size="size"
- >
- 删行
- </el-button>
- </template>
- </ux-table-column>
- </ux-grid>
- </el-tab-pane>
- </el-tabs>
- <el-row style="position: absolute; top: 20px; right: 20px">
- <el-button :size="size" @click="addTableRow(params[tabName])"
- >增行</el-button
- >
- <!-- v-if="role === 'procurementManager'" -->
- <BatchImport
- ref="batchImport"
- @import="handelImport"
- @temDownload="handleTemDownload"
- :fileSize="2"
- ></BatchImport>
- </el-row>
- <el-row style="margin-top: 10px">
- <el-col>
- <button-hide v-model="innerColumns" @change="onHide"></button-hide>
- </el-col>
- </el-row>
- </el-card>
- </el-form>
- </el-drawer>
- </template>
- <style scoped>
- .orderAddForm >>> .el-form-item {
- margin-bottom: 5px;
- }
- ::v-deep .singleTable .el-form-item {
- margin-bottom: 0px;
- }
- ::v-deep.uxbeautifyTableClass
- .elx-header--column
- .elx-resizable.is--line:before {
- height: 100%;
- background-color: #dfe6ec;
- }
- </style>
|