managerReviewBatchReview.vue 6.07 KB
<template>
    <d2-container v-loading="loading">
        <div v-for="(item, index) in selectList"
             :key="index"
             class="edit-page edit-tmpl"
             style="padding: 20px">
            <glsx-combi-form :ref="`editFormRef${index}`"
                             class="edit-form-container"
                             label-width="150px"
                             default-width="414px"
                             :form-ref="editChildRef"
                             :form-obj="item"
                             :form-data="editFormData"
                             :form-rules="formRules">
            </glsx-combi-form>
        </div>
        <div class="footer">
            <el-button type="primary"
                       :loading="loading"
                       @click="handleConfirm">
                确定
            </el-button>
            <el-button @click="handleCancel">
                取消
            </el-button>
        </div>
    </d2-container>
</template>

<script>
import { getShippingEntityInfoAll } from "@api/serviceManage";
import {
	managerBatchAudit,
} from "@/api/purchaseShopping.js";
import { deepClone, Util } from "@/common/util";

export default {
	name: "BatchReview",
	data() {
		const editItemStyle = {
			width: "50%",
			marginRight: "0px",
		};
		const lineItemStyle = {
			width: "100%",
			marginRight: "0px",
		};
		return {
			loading: false,
			editChildRef: "editChildRef",
			formRules: {
				sendOutMerchantId: [
					{ required: true, message: "请选择发货主体", trigger: "change" },
				],
			},
			selectList: [],
			editFormData: [
				{
					label: "订单编号",
					name: "orderCode",
					type: "showTxt",
					style: editItemStyle,
				},
				{
					label: "下单门店",
					name: "merchantName",
					type: "showTxt",
					style: editItemStyle,
				},
				{
					label: "订单总价/元",
					name: "totalPrice",
					type: "showTxt",
					style: editItemStyle,
					formatter: (cellValue) => {
						return "¥" + cellValue.totalPrice;
					},
				},
				{
					label: "下单时间",
					name: "orderTime",
					type: "showTxt",
					style: editItemStyle,
					formatter: (cellValue) => {
						return cellValue.orderTime ? Util.dateFormate(cellValue.orderTime, "YYYY-MM-DD HH:mm:ss") : "--";
					},
				},
				{
					label: "运营审核时间",
					name: "operatorReviewDate",
					type: "showTxt",
					isHide: true,
					style: editItemStyle,
					formatter: (cellValue) => {
						return cellValue.operatorReviewDate ? Util.dateFormate(cellValue.operatorReviewDate, "YYYY-MM-DD HH:mm:ss") : "--";
					},
				},
				{
					label: "发货主体",
					name: "sendOutMerchantId",
					isHide: true,
					style: lineItemStyle,
					type: "select",
					optionList: [],
					optionId: "shippingEntityId",
					optionLabel: "shippingEntity",
					optionsName: "shippingEntityList",
				},
				{
					label: "备注",
					name: "remark",
					type: "input",
					placeholder: "请输入",
					style: lineItemStyle,
					inputType: "textarea",
					maxlength: "200",
					rows: 4,
					showLimit: true,
				},
			],
			baseData: {
				shippingEntityList: [],
			},
		};
	},
	mounted() {
		this.fromPage = this.$route.query.fromPage || "procurementReview";
		this.selectList = deepClone(this.$route.query.list || "[]");
		this.showOrHideAttr("editFormData", "发货主体", this.fromPage == "procurementBusiness");
		this.showOrHideAttr("editFormData", "运营审核时间", this.fromPage == "procurementReview");
		this.getShippingEntityInfoAll();
	},
	methods: {
		showOrHideAttr(formName, label, isHide) {
			const idx = this[formName].findIndex(item => item.label == label);
			this[formName][idx].isHide = isHide;
		},
		getShippingEntityInfoAll() {
			// 获取发货主体数据
			getShippingEntityInfoAll({}).then((res) => {
				this.baseData.shippingEntityList = res || [];
				this.getOptionsList("editFormData", false);
			});
		},
		getOptionsList(formName, hasAll = true, refreshSigle) {
			if (refreshSigle) {
				let item = this[formName].find(k => k.name == refreshSigle);
				let index = this[formName].findIndex(k => k.name == refreshSigle);
				this.$set(this[formName][index], "optionList", deepClone(this.baseData[item.optionsName]));
				if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== "全部") {
					const temp = {};
					temp[this[formName][index].optionId] = "";
					temp[this[formName][index].optionLabel] = "全部";
					this[formName][index].optionList.unshift(temp);
				}
			} else {
				this[formName].forEach((item, index) => {
					if (["select", "radio"].includes(item.type) && this.baseData[item.optionsName].length) {
						this.$set(this[formName][index], "optionList", deepClone(this.baseData[item.optionsName]));
						if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== "全部") {
							const temp = {};
							temp[this[formName][index].optionId] = "";
							temp[this[formName][index].optionLabel] = "全部";
							this[formName][index].optionList.unshift(temp);
						}
					}
				});
			}
		},

		handleConfirm() {
			if (this.loading) {
				return true;
			}
			const _api = managerBatchAudit;
			this.loading = true;
			const params = {
				json: JSON.stringify({ auditList: this.selectList }),
			};
			_api(params).then((res) => {
				this.notice.okTips("批量审核成功");
				this.handleCancel();
			}).finally(() => {
				this.loading = false;
			});
		},

		// 取消按钮返回列表页
		handleCancel() {
			this.$router.push({
				name: "managerReview",
			});
		},
	},
};
</script>

<style lang="scss" scoped>
.edit-page.edit-tmpl {
	margin: 0 20px 20px;
	background: #ffffff;

	.title {
		height: 50px;
		line-height: 50px;
		padding: 0 20px;
		border-bottom: 1px solid #e5e5e5;
		font-size: 16px;
		font-weight: 600;
		color: #333333;
	}
}
::v-deep .el-form-item--small .el-form-item__label,
::v-deep .el-form-item--small .el-form-item__content {
	line-height: 20px;
}
.edit-tmpl {
	.add-mer-btn {
		margin-left: 12px;
	}
}
.footer {
	text-align: center;
}
</style>