approveDialog.vue 4.81 KB
<!-- 批量积分调整审批 -->
<template>
    <d2-dialog btn-ok-label="审核"
               class="adjustDialog"
               :is-visible.sync="visible"
               :title="dataInfo && dataInfo.id ? '积分调整审批' : '批量积分调整审批'"
               width="640px"
               @closeDialog="handleClose"
               @confirmDialog="handleConfirm">
        <div class="tip-text">
            审核通过后,将更新对应人员积分;<br />
            审核驳回后,不更新对应人员积分,需重新提交审核;
        </div>
        <glsx-combi-form ref="editFormRef"
                         class="edit-form-container"
                         :default-width="defaultWidth"
                         :form-data="editFormData"
                         :form-obj="editData"
                         :form-ref="editChildRef"
                         :form-rules="formRules"
                         :is-block="isBlock"
                         :label-width="labelWidth">

        </glsx-combi-form>
    </d2-dialog>
</template>

<script>
import { motivationAudit } from "@/api/point";
import { deepClone } from "@/common/util";

export default {
	name: "AdjustDialog",

	props: {
		visible: {
			type: Boolean,
			default: false,
		},
		dataInfo: {
			type: Object,
			default: () => {},
		},
	},
	data() {
		return {
			title: "",
			labelWidth: "110px",
			editChildRef: "editChildRef",
			isBlock: true,
			defaultWidth: "338px",
			isCodeDisabled: false,
			count: "",
			timer: null,
			editData: {
				auditResult: 0,
				operatorRemark: "",
			},
			editFormData: [
				{
					label: "审核结果",
					name: "auditResult",
					type: "radio",
					optionList: [],
					optionId: "confId",
					optionLabel: "confValue",
					optionsName: "approveOpt",
					handleRadioChange: (val) => {

					},
				},
				{
					label: "备注",
					name: "operatorRemark",
					type: "input",
					inputType: "textarea",
					maxlength: "200",
					width: "436px",
					rows: 4,
					showLimit: true,
				},
			],
			formRules: {
				auditResult: [{ required: true, message: "请选择审核结果", trigger: "change" }],
				operatorRemark: [{ required: true, message: "请输入备注", trigger: "blur" }],
			},
			baseData: {
				approveOpt: [
					{
						confId: 0,
						confValue: "审核通过",
					},
					{
						confId: 1,
						confValue: "审核驳回",
					},
				],
			},
		};
	},

	mounted() {
		this.getOptionsList(this, "editFormData", false);
	},

	methods: {

		handleConfirm() {
			this.$refs.editFormRef.$refs[this.editChildRef].validate((valid1) => {
				console.log(valid1);
				if (valid1) {
					let params = {
						auditResult: this.editData.auditResult,
						operatorRemark: this.editData.operatorRemark,
					};
					if (this.dataInfo && this.dataInfo.id) {
						params.id = this.dataInfo.id;
					}

					motivationAudit(params).then((res) => {
						if (res) {
							this.$message.success("操作成功");
							this.$emit("handleConfirm");
						}
					});
				}
			});
		},
		handleClose() {
			this.$emit("handleClose");
		},
		getOptionsList(that, formName, hasAll = true, refreshSigle) {
			if (refreshSigle) {
				let item = that[formName].find(k => k.name == refreshSigle);
				let index = that[formName].findIndex(k => k.name == refreshSigle);
				that.$set(
					that[formName][index],
					"optionList",
					deepClone(that.baseData[item.optionsName]),
				);
				if (
					hasAll
					&& that.baseData[item.optionsName].length
					&& that.baseData[item.optionsName][0][
						that[formName][index].optionLabel
					] !== "全部"
				) {
					const temp = {};
					temp[that[formName][index].optionId] = "";
					temp[that[formName][index].optionLabel] = "全部";
					that[formName][index].optionList.unshift(temp);
				}
			} else {
				that[formName].forEach((item, index) => {
					if (
						that.baseData[item.optionsName]?.length
					) {
						that.$set(
							that[formName][index],
							"optionList",
							deepClone(that.baseData[item.optionsName]),
						);
						if (
							hasAll
							&& that.baseData[item.optionsName].length
							&& that.baseData[item.optionsName][0][
								that[formName][index].optionLabel
							] !== "全部"
						) {
							const temp = {};
							temp[that[formName][index].optionId] = "";
							temp[that[formName][index].optionLabel] = "全部";
							that[formName][index].optionList.unshift(temp);
						}
					}
				});
			}
		},
	},
};
</script>

<style scoped lang="scss">
.adjustDialog {
	::v-deep {
		.el-dialog__header {
			border-bottom: 1px solid #e5e5e5;
		}
		.el-dialog__footer {
			border-top: 1px solid #e5e5e5;
		}
		.el-input__count {
			right: 12px;
			bottom: 1px;
		}
	}
}
.tip-text {
	border-radius: 4px;
	background: #f7f7f7;
	color: #333333;
	font-size: 14px;
	padding: 8px 0;
	text-align: center;
	margin-bottom: 26px;
	margin-top: -10px;
}
</style>