<template>
|
<div v-loading="formLoading" v-if="formShow">
|
<div style="margin-bottom: 10px; border-bottom: 1px solid #f6f6f6">
|
<el-button type="primary" @click="submitForm" :disabled="subDisabled"
|
>保 存</el-button
|
>
|
<el-button
|
type="primary"
|
@click="set_CheckBill(0)"
|
:disabled="CheckBillDisabled"
|
>审 核</el-button
|
>
|
<el-button
|
type="primary"
|
@click="set_CheckBill(1)"
|
:disabled="DeCheckBillDisabled"
|
>反审核</el-button
|
>
|
<el-button type="primary" @click="close">退 出</el-button>
|
</div>
|
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
|
<el-tabs v-model="activeName" type="card">
|
<el-tab-pane label="基本信息" name="first">
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="费用项目代码" prop="HNumber">
|
<el-input v-model="form.HNumber" placeholder="请输入费用项目代码" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="费用项目名称" prop="HName">
|
<el-input v-model="form.HName" placeholder="请输入费用项目名称" />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="助记码" prop="HHelpCode">
|
<el-input v-model="form.HHelpCode" placeholder="请输入助记码" />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="标准单价" prop="HPrice">
|
<el-input
|
v-model="form.HPrice"
|
placeholder="0.00"
|
type="text"
|
/>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="系数比率" prop="HRate">
|
<el-input
|
v-model="form.HRate"
|
placeholder="0.00"
|
type="text"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="使用状态" prop="HUseFlag">
|
<el-select v-model="form.HUseFlag" placeholder="请选择使用状态">
|
<el-option value="未检测" label="未检测"></el-option>
|
<el-option value="未使用" label="未使用"></el-option>
|
<el-option value="已使用" label="已使用"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="等级" prop="HLevel">
|
<el-input
|
v-model="form.HLevel"
|
placeholder="0"
|
type="text"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="末级标志" prop="HEndFlag">
|
<el-checkbox v-model="form.HEndFlag" disabled>是否末级</el-checkbox>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="禁用标记" prop="HStopflag">
|
<el-checkbox v-model="form.HStopflag" disabled>是否禁用</el-checkbox>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="使用组织" prop="HUSEORGID">
|
<el-select
|
v-model="form.HUSEORGID"
|
:disabled="useOrgDisabled"
|
@change="handleOrgChange"
|
placeholder="请选择使用组织"
|
>
|
<el-option
|
v-for="item in organizationList"
|
:key="item.ID"
|
:label="item.Name"
|
:value="item.ID"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12">
|
<el-form-item label="创建组织" prop="HCREATEORGID">
|
<el-select
|
v-model="form.HCREATEORGID"
|
:disabled="createOrgDisabled"
|
@change="handleCreateOrgChange"
|
placeholder="请选择创建组织"
|
>
|
<el-option
|
v-for="item in organizationList"
|
:key="item.ID"
|
:label="item.Name"
|
:value="item.ID"
|
>
|
</el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
<el-tab-pane label="其他信息" name="second">
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="备注" prop="HRemark">
|
<el-input
|
v-model="form.HRemark"
|
type="textarea"
|
placeholder="请输入备注信息"
|
:rows="4"
|
style="width: 80%"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
<el-tab-pane label="制单信息" name="third">
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="创建人" prop="HMakeEmp">
|
<el-input v-model="form.HMakeEmp" disabled />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="审核人" prop="HCheckEmp">
|
<el-input v-model="form.HCheckEmp" disabled />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="禁用人" prop="HStopEmp">
|
<el-input v-model="form.HStopEmp" disabled />
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="建立时间" prop="HMakeTime">
|
<el-date-picker
|
v-model="form.HMakeTime"
|
type="date"
|
disabled
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="审核时间" prop="HCheckTime">
|
<el-date-picker
|
v-model="form.HCheckTime"
|
type="date"
|
disabled
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="禁用时间" prop="HStopTime">
|
<el-date-picker
|
v-model="form.HStopTime"
|
type="date"
|
disabled
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="8">
|
<el-form-item label="修改人" prop="HModifyEmp">
|
<el-input v-model="form.HModifyEmp" disabled />
|
</el-form-item>
|
</el-col>
|
<el-col :span="8">
|
<el-form-item label="修改时间" prop="HModifyTime">
|
<el-date-picker
|
v-model="form.HModifyTime"
|
type="date"
|
disabled
|
>
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-tab-pane>
|
</el-tabs>
|
<el-input v-model="form.HItemID" type="hidden" />
|
<el-input v-model="form.HParentID" type="hidden" />
|
</el-form>
|
</div>
|
</template>
|
|
<script>
|
import axios from "axios";
|
import dayjs from "dayjs";
|
|
export default {
|
name: "gyCarTypeEdit",
|
components: {},
|
props: {
|
OperationType: { type: Number },
|
linterid: { type: Number },
|
HSouceBillType: { type: String },
|
copyType: { type: Number },
|
},
|
data() {
|
return {
|
formShow: false,
|
formLoading: true,
|
useOrgDisabled: false,
|
createOrgDisabled: false,
|
organizationList: [],
|
currentOrgId: "", // 当前组织ID
|
subDisabled: false,
|
CheckBillDisabled: true,
|
DeCheckBillDisabled: true,
|
baseURL: process.env.VUE_APP_BASE_API || "http://47.96.97.237/API/",
|
activeName: "first",
|
title: "",
|
open: false,
|
showSearch: true,
|
ids: [],
|
form: {
|
HItemID: 0,
|
HParentID: 0,
|
HNumber: "",
|
HName: "",
|
HHelpCode: "",
|
HPrice: "",
|
HRate: "",
|
HHeight: "",
|
HMaxVolume: "",
|
HUseFlag: "未检测",
|
HLevel: "",
|
HEndFlag: true,
|
HStopflag: false,
|
HShortNumber: "",
|
HUSEORGID: "", // 初始化为空
|
HCREATEORGID: "", // 初始化为空
|
HRemark: "",
|
HMakeEmp: "",
|
HMakeTime: null,
|
HCheckEmp: null,
|
HCheckTime: null,
|
HStopEmp: null,
|
HStopTime: null,
|
HModifyEmp: null,
|
HModifyTime: null,
|
},
|
rules: {
|
HNumber: [
|
{ required: true, message: "费用项目代码不能为空", trigger: "blur" },
|
],
|
HName: [
|
{ required: true, message: "费用项目名称不能为空", trigger: "blur" },
|
],
|
HPrice: [
|
{
|
pattern: /^\d+(\.\d+)?$/,
|
message: "必须为数字",
|
trigger: "blur",
|
},
|
],
|
HRate: [
|
{
|
pattern: /^\d+(\.\d+)?$/,
|
message: "必须为数字",
|
trigger: "blur",
|
},
|
],
|
HLevel: [
|
{
|
pattern: /^\d+$/,
|
message: "等级必须为数字",
|
trigger: "blur",
|
},
|
],
|
},
|
};
|
},
|
created() {
|
this.initCurrentOrgId();
|
},
|
activated() {
|
this.initCurrentOrgId();
|
},
|
methods: {
|
// 初始化当前组织ID - 与列表页保持一致
|
async initCurrentOrgId() {
|
try {
|
// 从sessionStorage获取当前组织ID,与列表页保持一致
|
this.currentOrgId = sessionStorage.getItem('currentOrgId') ||
|
(sessionStorage["OrganizationID"] - 0) ||
|
"";
|
|
// 从sessionStorage获取组织列表,与列表页保持一致
|
const savedOrgList = sessionStorage.getItem('organizationList');
|
if (savedOrgList) {
|
this.organizationList = JSON.parse(savedOrgList);
|
}
|
|
// 如果组织列表为空,则从接口获取(备用方案)
|
if (!this.organizationList || this.organizationList.length === 0) {
|
const response = await axios.get(this.baseURL + "/Web/GetOrganizations", {});
|
if (response.data.count == 1) {
|
this.organizationList = response.data.data;
|
}
|
}
|
|
this.getdata();
|
} catch (error) {
|
console.error("初始化组织数据失败:", error);
|
this.$modal.msgError("获取组织数据失败!");
|
this.formLoading = false;
|
}
|
},
|
|
// 获取表单数据
|
getdata() {
|
// 先调用reset设置默认值
|
this.reset();
|
|
if (this.OperationType == 1) {
|
// 新增 - 与列表页保持一致
|
this.useOrgDisabled = false;
|
this.createOrgDisabled = false;
|
|
// 设置创建时间和创建人
|
let date = new Date();
|
this.form.HMakeTime = dayjs(date).format("YYYY-MM-DD");
|
this.form.HMakeEmp = sessionStorage["HUserName"] || "";
|
|
// 关键修改:与列表页保持一致
|
// 使用组织:初始为空,用户需要选择
|
// 创建组织:默认为当前组织,用户可以修改
|
this.form.HCREATEORGID = this.currentOrgId;
|
this.form.HUSEORGID = this.currentOrgId; // 使用组织留空,让用户选择
|
|
this.$nextTick(() => {
|
this.formShow = true;
|
this.formLoading = false;
|
});
|
} else if (this.OperationType == 3 || this.OperationType == 4) {
|
// 编辑或浏览
|
this.useOrgDisabled = true;
|
this.createOrgDisabled = true;
|
|
if (this.OperationType == 4) {
|
// 浏览
|
this.subDisabled = true;
|
this.CheckBillDisabled = true;
|
this.DeCheckBillDisabled = true;
|
}
|
|
axios
|
.get(this.baseURL + "Web/GetGy_ItemMoneyDetail", {
|
params: {
|
HID: this.linterid,
|
|
},
|
})
|
.then((response) => {
|
console.log(response);
|
let result = response.data.data.h_v_Gy_ItemMoney_1[0];;
|
var data = result;
|
this.form = {
|
HItemID: data.HItemID,
|
HParentID: data.父级ID,
|
HNumber: data.费用项目代码,
|
HName: data.费用项目名称,
|
HHelpCode: data.助记码,
|
HPrice: data.标准单价,
|
HRate: data.系数比率,
|
|
HUseFlag: data.HUseFlag,
|
HLevel: data.等级,
|
HEndFlag: data.末级标志,
|
HStopflag: data.HStopflag,
|
HUSEORGID: data.HUSEORGID,
|
HCREATEORGID: data.HCREATEORGID,
|
HRemark: data.备注,
|
HMakeEmp: data.创建人,
|
HMakeTime: data.创建时间
|
? dayjs(new Date(data.创建时间)).format("YYYY-MM-DD")
|
: "",
|
HCheckEmp: data.审核人,
|
HCheckTime: data.审核时间
|
? dayjs(new Date(data.审核时间)).format("YYYY-MM-DD")
|
: "",
|
HStopEmp: data.HStopEmp,
|
HStopTime: data.HStopTime
|
? dayjs(new Date(data.HStopTime)).format("YYYY-MM-DD")
|
: "",
|
HModifyEmp: data.HModifyEmp,
|
HModifyTime: data.HModifyTime
|
? dayjs(new Date(data.HModifyTime)).format("YYYY-MM-DD")
|
: "",
|
};
|
|
if (this.OperationType == 3) {
|
if (!data.HCheckEmp) {
|
this.CheckBillDisabled = false;
|
} else {
|
this.DeCheckBillDisabled = false;
|
}
|
}
|
|
this.$nextTick(() => {
|
this.formShow = true;
|
this.formLoading = false;
|
});
|
})
|
.catch((error) => {
|
this.$modal.msgError("获取数据失败!");
|
this.formLoading = false;
|
});
|
}
|
},
|
|
// 重置表单 - 修改默认值设置
|
reset() {
|
this.form = {
|
HItemID: 0,
|
HParentID: 0,
|
HNumber: "",
|
HName: "",
|
HHelpCode: "",
|
HPrice: "",
|
HRate: "",
|
HUseFlag: "未检测",
|
HLevel: "",
|
HEndFlag: true,
|
HStopflag: false,
|
HUSEORGID: "", // 使用组织:初始为空,用户需要选择
|
HCREATEORGID: this.currentOrgId, // 创建组织:默认为当前组织
|
HRemark: "",
|
HMakeEmp: sessionStorage["HUserName"] || "",
|
HMakeTime: null,
|
HCheckEmp: null,
|
HCheckTime: null,
|
HStopEmp: null,
|
HStopTime: null,
|
HModifyEmp: null,
|
HModifyTime: null,
|
};
|
this.ids = [];
|
this.formShow = false;
|
this.subDisabled = false;
|
this.formLoading = true;
|
this.CheckBillDisabled = true;
|
this.DeCheckBillDisabled = true;
|
this.activeName = "first";
|
if (this.$refs.form) {
|
this.$refs.form.resetFields();
|
}
|
},
|
|
// 组织选择变化
|
handleOrgChange(value) {
|
this.form.HUSEORGID = value;
|
},
|
|
// 创建组织选择变化
|
handleCreateOrgChange(value) {
|
this.form.HCREATEORGID = value;
|
},
|
|
// 关闭表单
|
close() {
|
this.reset();
|
this.formShow = false;
|
this.$emit("editCloseGy", 0);
|
},
|
|
// 提交表单
|
submitForm() {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
// 必填字段验证
|
if (!this.form.HNumber) {
|
this.$modal.msgError("费用项目代码不能为空!");
|
return;
|
}
|
if (!this.form.HName) {
|
this.$modal.msgError("费用项目名称不能为空!");
|
return;
|
}
|
|
// 使用组织必填验证 - 与列表页保持一致
|
if (!this.form.HUSEORGID) {
|
this.$modal.msgError("使用组织不能为空!");
|
return;
|
}
|
|
if (!this.form.HCREATEORGID) {
|
this.$modal.msgError("创建组织不能为空!");
|
return;
|
}
|
|
// 数字字段验证
|
if (this.form.HPrice && isNaN(this.form.HPrice)) {
|
this.$modal.msgError("必须为数字!");
|
return;
|
}
|
|
if (this.form.HLevel && isNaN(this.form.HLevel)) {
|
this.$modal.msgError("等级必须为数字!");
|
return;
|
}
|
|
var sMainStr = JSON.stringify(this.form);
|
var oMain = sMainStr + ";" + sessionStorage["HUserName"];
|
|
axios({
|
method: "post",
|
url: this.baseURL + "/SaveGy_ItemMoney",
|
data: { msg: oMain },
|
})
|
.then((response) => {
|
if (response.data.count == 1) {
|
this.subDisabled = true;
|
this.CheckBillDisabled = false;
|
this.$modal.msgSuccess("保存成功!");
|
} else {
|
this.$modal.msgError(response.data.Message);
|
//this.$modal.msgError("6666");
|
}
|
})
|
.catch((error) => {
|
this.$modal.msgError("保存失败!");
|
});
|
}
|
});
|
},
|
|
// 审核/反审核
|
set_CheckBill(num) {
|
var HItemID = this.form.HItemID;
|
if (!HItemID || HItemID == "0") {
|
this.$modal.msgError("请先保存数据再进行审核操作!");
|
return;
|
}
|
|
axios
|
.get(this.baseURL + "/Gy_BadReason/AuditGy_ItemMoney", {
|
params: {
|
HInterID: HItemID,
|
IsAudit: num,
|
CurUserName: sessionStorage["HUserName"],
|
},
|
})
|
.then((response) => {
|
let result = response.data;
|
if (result.code == 1) {
|
this.$modal.msgSuccess(result.Message);
|
if (num == 0) {
|
this.CheckBillDisabled = true;
|
this.DeCheckBillDisabled = false;
|
} else {
|
this.CheckBillDisabled = false;
|
this.DeCheckBillDisabled = true;
|
}
|
} else {
|
this.$modal.msgError(result.Message);
|
}
|
})
|
.catch((error) => {
|
this.$modal.msgError("审核操作失败!");
|
});
|
},
|
},
|
};
|
</script>
|
|
<style>
|
.xsckdBox .el-date-editor.el-input {
|
width: 100%;
|
}
|
|
.form-inline > .el-form-item__content {
|
display: flex;
|
flex-direction: row;
|
}
|
</style>
|