1129 lines
29 KiB
Vue
1129 lines
29 KiB
Vue
<script setup>
|
||
import { ElMessage } from "element-plus";
|
||
import { computed, onMounted, ref } from "vue";
|
||
|
||
import { useRoute } from "vue-router";
|
||
import g3SelectDlg from "@/components/g3SelectDlg.vue";
|
||
import Report from "@/components/report/report.vue";
|
||
import { useUserStore } from "@/store";
|
||
import { morePermission } from "@/utils/auth";
|
||
import axios from "@/utils/axios";
|
||
import { formatValueByFormat, getAlignByFormat } from "@/utils/column";
|
||
import { getSFId } from "@/utils/common";
|
||
import { diffData, fillSerialNoAndDefaults } from "@/utils/dataDiffUtils";
|
||
import {
|
||
getColumnconfig,
|
||
getMainTable,
|
||
getSubTable,
|
||
handleMappingConfig,
|
||
handleSaveColumnEdit,
|
||
} from "@/utils/dodata";
|
||
import { confirmDelete, delBefore } from "@/utils/doDel";
|
||
import {
|
||
getDefaultValue,
|
||
checkMustField,
|
||
getMoneyExRate,
|
||
getFieldString,
|
||
checkAllowRepeat,
|
||
initReserveData,
|
||
handleDisabledState,
|
||
} from "@/utils/g3Funlib";
|
||
import hldlg from "@/views/cw/components/hldlg.vue";
|
||
import G3Field from "@/components/g3Field.vue";
|
||
import { useTabStore } from "@/store/tab.js";
|
||
import math from "@/utils/math";
|
||
import { getDateTime } from "@/utils/time";
|
||
|
||
/* ================= store & route ================= */
|
||
const tabStore = useTabStore();
|
||
const userStore = useUserStore();
|
||
const route = useRoute();
|
||
|
||
/* ================= state ================= */
|
||
|
||
const loading = ref(false);
|
||
const saving = ref(false);
|
||
const error = ref("");
|
||
|
||
const maintable = ref({});
|
||
const maintableorg = ref({});
|
||
|
||
const subtable = ref([]);
|
||
const subtableorg = ref([]);
|
||
|
||
const columns = ref([]);
|
||
|
||
const id = ref(route.query.id ?? "");
|
||
const op = ref(String(route.query.op ?? ""));
|
||
|
||
const tableRef = ref(null);
|
||
|
||
const { approved } = handleDisabledState(() => maintable.value?.b_state);
|
||
|
||
/* ================= dialog ================= */
|
||
|
||
const dialogVisible = ref(false);
|
||
|
||
/** 已选子表ID(纯计算,禁止手动赋值) */
|
||
const subidlist = computed(() =>
|
||
subtable.value
|
||
.map((r) => r.mx_fee_id)
|
||
.filter(Boolean)
|
||
.map((id) => `'${id}'`),
|
||
);
|
||
|
||
const wheresql = computed(() => {
|
||
const customerWhere = maintable.value?.b_dw_id
|
||
? ` and mx_dw_id='${maintable.value.b_dw_id}'`
|
||
: "";
|
||
|
||
const excludeWhere = subidlist.value.length
|
||
? ` and subid not in (${subidlist.value.join(",")})`
|
||
: "";
|
||
|
||
return customerWhere + excludeWhere;
|
||
});
|
||
|
||
/* ================= utils ================= */
|
||
|
||
function safeNum(v, digits = 3) {
|
||
return Math.round((Number(v) || 0) * 10 ** digits) / 10 ** digits;
|
||
}
|
||
|
||
/* ================= 选择费用 ================= */
|
||
|
||
function openDialog() {
|
||
dialogVisible.value = true;
|
||
}
|
||
|
||
async function handleBeforeConfirm(rows) {
|
||
const dwid = rows[0]?.mx_dw_id || "";
|
||
|
||
for (const row of rows) {
|
||
if ((row.mx_dw_id || "") !== dwid) {
|
||
ElMessage.warning("结算单位不一致,请检查!");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
async function handleConfirm(subidCondition) {
|
||
await handleMappingConfig("cwtofkd", subidCondition, subtable);
|
||
|
||
if (!subtable.value.length) return;
|
||
|
||
if (!subtable.value.length) return;
|
||
subtable.value.forEach((r, index) => {
|
||
r.mx_xh = index + 1;
|
||
});
|
||
|
||
const first = subtable.value[0];
|
||
maintable.value.v_dw_name = first.mx_dw_name;
|
||
maintable.value.b_dw_id = first.mx_dw_id;
|
||
maintable.value.b_money_id = first.mx_fee_money_id;
|
||
maintable.value.b_exrate = await loadMoneyExRate();
|
||
}
|
||
|
||
async function loadMoneyExRate() {
|
||
return await getMoneyExRate({
|
||
rows: subtable.value,
|
||
});
|
||
}
|
||
|
||
/* ================= 汇总 ================= */
|
||
|
||
function resetAll() {
|
||
maintable.value = {};
|
||
maintableorg.value = {};
|
||
maintable.value.b_state = "草拟";
|
||
maintable.value.b_module_id = "实付";
|
||
resetSubs();
|
||
}
|
||
|
||
function resetSubs() {
|
||
subtable.value = [];
|
||
subtableorg.value = [];
|
||
}
|
||
|
||
async function initNew() {
|
||
await getDefaultValue(maintable, "v_cw_fkd");
|
||
maintable.value.b_id = await getSFId();
|
||
id.value = "";
|
||
}
|
||
|
||
/* ================= 新建 ================= */
|
||
async function handleNew() {
|
||
const reserveData = await initReserveData(maintable.value, "v_cw_fkd");
|
||
resetAll();
|
||
op.value = "new";
|
||
await initNew();
|
||
Object.assign(maintable.value, reserveData);
|
||
}
|
||
|
||
function prepareSubTables() {
|
||
fillSerialNoAndDefaults(subtable.value, {
|
||
father: maintable.value.b_id,
|
||
});
|
||
}
|
||
|
||
async function beforeSave() {
|
||
// 校验
|
||
// 子表核销金额不能大于主表核销金额
|
||
const mainAmount = maintable.value.b_amount || 0;
|
||
|
||
const subAmount = subtable.value.reduce(
|
||
(sum, row) => {
|
||
return math.add(sum, row.mx_sf_amount || 0);
|
||
},
|
||
math.add(0, 0),
|
||
);
|
||
|
||
// 子表合计 > 主表金额
|
||
if (subAmount.gt(math.add(mainAmount, 0))) {
|
||
ElMessage.warning("明细核销金额不能大于主表核销金额");
|
||
return false;
|
||
}
|
||
|
||
error.value = "";
|
||
|
||
const ok = await checkMustField(maintable.value, "v_cw_fkd");
|
||
if (!ok) return false;
|
||
|
||
const isValid = await checkAllowRepeat(maintable.value, "v_cw_fkd");
|
||
if (!isValid) return false;
|
||
|
||
prepareSubTables();
|
||
maintable.value.b_yw_ids = getFieldString(subtable.value, "b_ywno");
|
||
maintable.value.b_bill_ids = getFieldString(subtable.value, "mx_bill_ywno");
|
||
maintable.value.b_inv_ids = getFieldString(subtable.value, "mx_invoice_ywno");
|
||
return true;
|
||
}
|
||
|
||
function checkChange() {
|
||
const maintableChanges = diffData(maintable.value, maintableorg.value, "b_id", {
|
||
isSingle: true,
|
||
});
|
||
|
||
const subtableChanges = diffData(subtable.value, subtableorg.value, "subid");
|
||
|
||
// 无变更检测
|
||
if (!maintableChanges.hasChanges && !subtableChanges.hasChanges) {
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
function buildSaveData() {
|
||
const maintableChanges = diffData(maintable.value, maintableorg.value, "b_id", {
|
||
isSingle: true,
|
||
});
|
||
|
||
const subtableChanges = diffData(subtable.value, subtableorg.value, "subid");
|
||
|
||
// 无变更检测
|
||
if (!maintableChanges.hasChanges && !subtableChanges.hasChanges) {
|
||
return null;
|
||
}
|
||
|
||
return [
|
||
{
|
||
tableName: "cw_sfd",
|
||
keyField: "b_id",
|
||
inserts: maintableChanges.insertdata,
|
||
updates: maintableChanges.updatedata,
|
||
deletes: [],
|
||
updateWhere: "ISNULL(b_state,'草拟') IN ('草拟','审核驳回')",
|
||
deleteWhere: "ISNULL(b_state,'草拟') IN ('草拟','审核驳回')",
|
||
},
|
||
{
|
||
tableName: "cw_sfdsub",
|
||
keyField: "subid",
|
||
inserts: subtableChanges.insertdata,
|
||
updates: subtableChanges.updatedata,
|
||
deletes: subtableChanges.deletedata,
|
||
insertCheck: {
|
||
table: "cw_sfd",
|
||
sourceField: "father",
|
||
targetField: "b_id",
|
||
where: "ISNULL(b_state,'草拟') IN ('草拟','审核驳回')",
|
||
},
|
||
updateWhere: `
|
||
ISNULL(mx_writeoff_status,'0') <> '1'
|
||
AND EXISTS (
|
||
SELECT 1
|
||
FROM cw_sfd
|
||
WHERE cw_sfd.b_id = cw_sfdsub.father
|
||
AND ISNULL(cw_sfd.b_state,'草拟') IN ('草拟','审核驳回')
|
||
)
|
||
`,
|
||
deleteWhere: `
|
||
ISNULL(mx_writeoff_status,'0') <> '1'
|
||
AND EXISTS (
|
||
SELECT 1
|
||
FROM cw_sfd
|
||
WHERE cw_sfd.b_id = cw_sfdsub.father
|
||
AND ISNULL(cw_sfd.b_state,'草拟') IN ('草拟','审核驳回')
|
||
)
|
||
`,
|
||
},
|
||
];
|
||
}
|
||
|
||
// updateWhere mx_bill_id == ''
|
||
|
||
async function afterSave() {
|
||
await getMainTable("v_cw_fkd", maintable, maintableorg, maintable.value.b_id);
|
||
await getSubTable("v_cw_fkdsub", subtable, subtableorg, `father = '${maintable.value.b_id}'`);
|
||
op.value = "mod";
|
||
}
|
||
|
||
/* ================= 保存 ================= */
|
||
|
||
async function handleSave() {
|
||
try {
|
||
saving.value = true;
|
||
error.value = "";
|
||
if (!(await beforeSave())) return;
|
||
|
||
const requestData = buildSaveData();
|
||
|
||
if (!requestData) {
|
||
ElMessage.info("没有数据变更");
|
||
return;
|
||
}
|
||
|
||
const response = await axios.post("/saveobjectV5", requestData, {
|
||
headers: { "Content-Type": "application/json" },
|
||
});
|
||
|
||
if (response.data?.success) {
|
||
showSaveResultMessage(response);
|
||
id.value = maintable.value.b_id;
|
||
|
||
await afterSave();
|
||
} else {
|
||
throw new Error(response.data?.message || "保存失败");
|
||
}
|
||
} catch (err) {
|
||
error.value = `保存失败: ${err.message}`;
|
||
ElMessage.error("保存失败");
|
||
} finally {
|
||
saving.value = false;
|
||
}
|
||
}
|
||
|
||
/* ================= 核销 / 回撤(略作精简) ================= */
|
||
|
||
function showSaveResultMessage(response) {
|
||
const data = response.data?.data || {};
|
||
const { insert, update, delete: del, insertBlocked, updateBlocked, deleteBlocked } = data;
|
||
|
||
const totalSuccess = (insert || 0) + (update || 0) + (del || 0);
|
||
const totalBlocked = (insertBlocked || 0) + (updateBlocked || 0) + (deleteBlocked || 0);
|
||
|
||
// 完全没有成功,也没有拦截(一般不会走到)
|
||
if (totalSuccess === 0 && totalBlocked === 0) {
|
||
ElMessage.info("没有数据发生变化");
|
||
return;
|
||
}
|
||
|
||
// ✅ 完全成功
|
||
if (totalBlocked === 0) {
|
||
ElMessage.success(`保存成功(新增 ${insert || 0},更新 ${update || 0},删除 ${del || 0})`);
|
||
return;
|
||
}
|
||
|
||
// ⚠️ 有拦截(重点)
|
||
let msg = "保存成功,但部分数据被业务规则拦截";
|
||
|
||
const parts = [];
|
||
if (insertBlocked > 0) parts.push(`新增 ${insertBlocked} 条`);
|
||
if (updateBlocked > 0) parts.push(`更新 ${updateBlocked} 条`);
|
||
if (deleteBlocked > 0) parts.push(`删除 ${deleteBlocked} 条`);
|
||
|
||
msg += `(${parts.join(",")})`;
|
||
|
||
// ✅ 用 warning 而不是 error
|
||
ElMessage.warning(msg);
|
||
}
|
||
|
||
async function handleWriteoff() {
|
||
const $table = tableRef.value;
|
||
if (!$table) {
|
||
ElMessage.warning("表格未初始化");
|
||
return;
|
||
}
|
||
|
||
// 1️⃣ 获取勾选行
|
||
const checkedRows = $table.getCheckboxRecords();
|
||
if (!checkedRows.length) {
|
||
ElMessage.warning("请先勾选要核销的费用");
|
||
return;
|
||
}
|
||
|
||
// 2️⃣ 过滤:未核销的费用
|
||
const canWriteoffRows = checkedRows.filter((row) => row.mx_writeoff_status !== "1");
|
||
|
||
if (!canWriteoffRows.length) {
|
||
ElMessage.warning("勾选的费用均已核销,无需重复核销");
|
||
return;
|
||
}
|
||
|
||
// 3️⃣ 组装 fee_ids(逗号分隔)
|
||
const feeIds = canWriteoffRows
|
||
.map((row) => row.mx_fee_id)
|
||
.filter(Boolean)
|
||
.join(",");
|
||
|
||
if (!feeIds) {
|
||
ElMessage.warning("无可核销的费用ID");
|
||
return;
|
||
}
|
||
|
||
// 4️⃣ 构造参数(✅ 与后端 SP 完全一致)
|
||
const params = {
|
||
b_id: maintable.value.b_id,
|
||
fee_ids: feeIds,
|
||
};
|
||
|
||
try {
|
||
const response = await axios.post("fee/feewriteoffbatch", params);
|
||
|
||
if (response.data.success === true) {
|
||
ElMessage.success(response.data.message || "核销成功");
|
||
} else {
|
||
ElMessage.warning(response.data.message || "核销失败");
|
||
}
|
||
} catch (error) {
|
||
ElMessage.error("请求失败:" + error.message);
|
||
} finally {
|
||
await loadMod(); // 刷新数据
|
||
}
|
||
}
|
||
|
||
async function handleRollback() {
|
||
const $table = tableRef.value;
|
||
if (!$table) {
|
||
ElMessage.warning("表格未初始化");
|
||
return;
|
||
}
|
||
|
||
// 1️⃣ 获取勾选行
|
||
const checkedRows = $table.getCheckboxRecords();
|
||
if (!checkedRows.length) {
|
||
ElMessage.warning("请先勾选要反核销的费用");
|
||
return;
|
||
}
|
||
|
||
// 2️⃣ 过滤:只保留已核销的费用
|
||
const canCancelRows = checkedRows.filter((row) => row.mx_writeoff_status === "1");
|
||
|
||
if (!canCancelRows.length) {
|
||
ElMessage.warning("勾选的费用中无可反核销的记录");
|
||
return;
|
||
}
|
||
|
||
// 3️⃣ 组装 fee_ids
|
||
const feeIds = canCancelRows
|
||
.map((row) => row.mx_fee_id)
|
||
.filter(Boolean)
|
||
.join(",");
|
||
|
||
if (!feeIds) {
|
||
ElMessage.warning("无可反核销的费用ID");
|
||
return;
|
||
}
|
||
|
||
// 4️⃣ 构造参数(✅ 与后端 SP 完全一致)
|
||
const params = {
|
||
b_id: maintable.value.b_id,
|
||
fee_ids: feeIds,
|
||
};
|
||
|
||
try {
|
||
const response = await axios.post("fee/writeoffcancelbatch", params);
|
||
|
||
if (response.data?.success) {
|
||
ElMessage.success(response.data.message || "反核销成功");
|
||
|
||
// 如有明细失败信息,可打印或弹窗展示
|
||
if (response.data.data) {
|
||
console.warn("反核销明细:", response.data.data);
|
||
}
|
||
|
||
await loadMod(); // 刷新数据
|
||
} else {
|
||
ElMessage.warning(response.data?.message || "反核销失败");
|
||
}
|
||
} catch (error) {
|
||
ElMessage.error("请求失败:" + error.message);
|
||
}
|
||
}
|
||
/* ================= 删除 ================= */
|
||
|
||
async function deleteRows(rows) {
|
||
if (!rows.length) return;
|
||
const dbRows = rows.filter((r) => r.subid);
|
||
|
||
for (const r of dbRows) {
|
||
const res = await delBefore("cw_fkdsub", r.subid);
|
||
if (!res.success) {
|
||
ElMessage.error(res.message);
|
||
return;
|
||
}
|
||
}
|
||
|
||
if (!(await confirmDelete(rows))) return;
|
||
|
||
subtable.value = subtable.value.filter((r) => !rows.includes(r));
|
||
|
||
ElMessage.success("删除成功");
|
||
}
|
||
|
||
/* ================= 删除 ================= */
|
||
|
||
function handleDelRow(row) {
|
||
deleteRows([row]);
|
||
}
|
||
|
||
function handleDelAllRow() {
|
||
const $table = tableRef.value;
|
||
if (!$table) {
|
||
ElMessage.warning("表格未初始化");
|
||
return;
|
||
}
|
||
|
||
const rows = $table.getCheckboxRecords();
|
||
deleteRows(rows);
|
||
}
|
||
|
||
const showReport = ref(false);
|
||
const reportForm = ref({
|
||
cateid: "",
|
||
valuesql: "",
|
||
djid: "",
|
||
});
|
||
|
||
async function handleReport() {
|
||
if (op.value != "mod") {
|
||
ElMessage.warning("请先保存,再打印报表!");
|
||
return;
|
||
}
|
||
|
||
let sid = maintable.value.b_id;
|
||
|
||
let subviewtable = "v_cw_fkdsub";
|
||
let cateid = "实付销账";
|
||
|
||
try {
|
||
let valuesql = [];
|
||
|
||
valuesql.push(`select * from rp_v_cw_skd where b_id='${sid}'`);
|
||
valuesql.push(`select * from ${subviewtable} where father='${sid}'`);
|
||
|
||
let valuesql1 = valuesql.join("|");
|
||
|
||
reportForm.value.cateid = cateid;
|
||
reportForm.value.valuesql = valuesql1;
|
||
reportForm.value.djid = sid;
|
||
|
||
showReport.value = true;
|
||
} catch (error) {
|
||
console.error("获取 num 失败:", error);
|
||
ElMessage.error(`获取 num 失败:${error.message || error}`);
|
||
}
|
||
}
|
||
|
||
/* ================= 金额联动 ================= */
|
||
|
||
function handleMaintableChange(field) {
|
||
if (!field) {
|
||
return;
|
||
}
|
||
|
||
if (field === "b_amount_other" || field === "b_amount_sj") {
|
||
maintable.value.b_amount = math
|
||
.add(maintable.value.b_amount_other, maintable.value.b_amount_sj)
|
||
.toFixed(3);
|
||
|
||
maintable.value.b_amount_nothx = math
|
||
.subtract(maintable.value.b_amount, maintable.value.b_amount_hx)
|
||
.toFixed(3);
|
||
} else if (field === "b_amount") {
|
||
maintable.value.b_amount_nothx = math
|
||
.subtract(maintable.value.b_amount, maintable.value.b_amount_hx)
|
||
.toFixed(3);
|
||
}
|
||
}
|
||
|
||
function handleSubtableChange(row, field) {
|
||
const fee = row.mx_fee_amount || 0;
|
||
const sf = row.mx_sf_amount || 0;
|
||
const ex = row.mx_exrate || 0;
|
||
|
||
// 防止除0
|
||
const safeEx = math.toFixed(ex) === "0" ? 1 : ex;
|
||
|
||
if (field === "mx_fee_amount") {
|
||
// 费用金额变动 → 反推收款金额
|
||
row.mx_sf_amount = math.divide(fee, safeEx).toFixed(3);
|
||
} else if (field === "mx_sf_amount") {
|
||
// 收款金额变动 → 反推费用金额
|
||
row.mx_exrate = math.divide(fee, sf).toFixed(3);
|
||
} else if (field === "mx_exrate") {
|
||
// 汇率变动 → 重新计算收款金额
|
||
row.mx_sf_amount = math.divide(fee, safeEx).toFixed(3);
|
||
}
|
||
|
||
maintable.value.b_amount_hx = subtable.value
|
||
.reduce((sum, row) => {
|
||
return math.add(sum, row.mx_sf_amount || 0);
|
||
}, 0)
|
||
.toFixed(3);
|
||
|
||
maintable.value.b_amount_nothx = math
|
||
.subtract(maintable.value.b_amount, maintable.value.b_amount_hx)
|
||
.toFixed(3);
|
||
}
|
||
|
||
/* ================= 下拉回调 ================= */
|
||
|
||
function handleUpdateExrate(val) {
|
||
maintable.value.b_exrate = val.b_hl;
|
||
}
|
||
|
||
function handlebanknameSelect(val) {
|
||
maintable.value.b_account_id = val?.b_account ?? "";
|
||
}
|
||
|
||
// --------------
|
||
const hlDialogVisible = ref(false);
|
||
const hlParams = ref({
|
||
moneyId: "",
|
||
feeMoneyIds: [],
|
||
});
|
||
function hlOpenDialog() {
|
||
hlParams.value = {
|
||
moneyId: maintable.value.b_money_id,
|
||
feeMoneyIds: [...new Set(subtable.value.map((item) => item.mx_fee_money_id).filter(Boolean))],
|
||
};
|
||
|
||
hlDialogVisible.value = true;
|
||
}
|
||
const handleConfirmHl = (data) => {
|
||
const exrateMap = {};
|
||
|
||
data.forEach((item) => {
|
||
exrateMap[item.feeMoneyId] = {
|
||
exrate: Number(item.exrate),
|
||
moneyId: item.moneyId,
|
||
};
|
||
});
|
||
|
||
subtable.value.forEach((row) => {
|
||
const rateInfo = exrateMap[row.mx_fee_money_id];
|
||
if (rateInfo) {
|
||
row.mx_exrate = rateInfo.exrate;
|
||
row.mx_sf_money_id = rateInfo.moneyId;
|
||
row.mx_sf_amount = math.divide(row.mx_fee_amount || 0, rateInfo.exrate || 1).toFixed(3);
|
||
}
|
||
});
|
||
|
||
maintable.value.b_amount_hx = subtable.value
|
||
.reduce((sum, row) => {
|
||
return math.add(sum, row.mx_sf_amount || 0);
|
||
}, 0)
|
||
.toFixed(3);
|
||
|
||
maintable.value.b_amount_nothx = math
|
||
.subtract(maintable.value.b_amount, maintable.value.b_amount_hx)
|
||
.toFixed(3);
|
||
};
|
||
// --------------
|
||
|
||
/* ================= lifecycle ================= */
|
||
|
||
onMounted(async () => {
|
||
tabStore.registerLeave({
|
||
isChange() {
|
||
return checkChange();
|
||
},
|
||
|
||
async onConfirm() {
|
||
await handleSave();
|
||
},
|
||
});
|
||
|
||
if (op.value === "mod") {
|
||
await loadMod();
|
||
} else {
|
||
await loadNew();
|
||
}
|
||
});
|
||
|
||
async function loadMod() {
|
||
await getMainTable("v_cw_fkd", maintable, maintableorg, id.value);
|
||
await getColumnconfig("v_cw_fkdsub", columns);
|
||
await getSubTable("v_cw_fkdsub", subtable, subtableorg, `father = '${id.value}'`);
|
||
}
|
||
|
||
async function loadNew() {
|
||
await getDefaultValue(maintable, "v_cw_fkd");
|
||
await getColumnconfig("v_cw_fkdsub", columns);
|
||
maintable.value.b_id = await getSFId();
|
||
maintable.value.b_state = "草拟";
|
||
maintable.value.b_module_id = "实付";
|
||
maintableorg.value = {};
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="g3pagecontainer">
|
||
<div class="g3toolbar">
|
||
<el-button
|
||
:disabled="approved || morePermission(3)"
|
||
type="success"
|
||
:loading="saving"
|
||
@click="handleSave"
|
||
>
|
||
保存
|
||
</el-button>
|
||
<el-button :disabled="morePermission(5)" type="primary" @click="handleReport()">
|
||
报表
|
||
</el-button>
|
||
<el-button :disabled="morePermission(1)" type="primary" @click="handleNew"> 新建 </el-button>
|
||
<el-button
|
||
:disabled="morePermission(30) || op !== 'mod' || approved"
|
||
type="primary"
|
||
@click="handleWriteoff"
|
||
>
|
||
核销
|
||
</el-button>
|
||
<el-button
|
||
:disabled="morePermission(31) || op !== 'mod' || approved"
|
||
type="primary"
|
||
@click="handleRollback"
|
||
>
|
||
回撤
|
||
</el-button>
|
||
</div>
|
||
<div class="main">
|
||
<div class="g3panel">
|
||
<div v-if="maintable" class="g3header">
|
||
<G3Field v-model="maintable.b_id" label="系统编号" type="input" disabled="disabled" />
|
||
<G3Field v-model="maintable.b_date" label="日期" type="date" />
|
||
|
||
<G3Field v-model="maintable.b_ywno" label="付款单号" type="input" />
|
||
<G3Field
|
||
v-model="maintable.b_type_id"
|
||
label="付款类型"
|
||
type="select"
|
||
:query-params="{ dataset: 'b_ystype' }"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.v_dw_name"
|
||
v-model:model-id="maintable.b_dw_id"
|
||
label="结算单位"
|
||
type="select"
|
||
:pycode="true"
|
||
:mustmatch="true"
|
||
:query-params="{ dataset: 'v_b_othercompany_customer' }"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.b_amount_sj"
|
||
label="实付金额"
|
||
type="g3Number"
|
||
@input="handleMaintableChange('b_amount_sj')"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.b_money_id"
|
||
label="币种"
|
||
type="select"
|
||
:query-params="{ dataset: 'b_money' }"
|
||
@select="handleUpdateExrate"
|
||
/>
|
||
<G3Field v-model="maintable.b_exrate" label="汇率" type="input" />
|
||
|
||
<G3Field
|
||
v-model="maintable.b_amount_other"
|
||
label="手续费"
|
||
type="g3Number"
|
||
@input="handleMaintableChange('b_amount_other')"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.b_amount"
|
||
label="销账金额"
|
||
type="g3Number"
|
||
@input="handleMaintableChange('b_amount')"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.b_amount_hx"
|
||
label="已销金额"
|
||
type="g3Number"
|
||
disabled="disabled"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.b_amount_nothx"
|
||
label="未销金额"
|
||
type="g3Number"
|
||
disabled="disabled"
|
||
/>
|
||
|
||
<G3Field
|
||
v-model="maintable.v_mycompanyname"
|
||
v-model:model-id="maintable.b_mycompany_id"
|
||
label="我方公司"
|
||
type="select"
|
||
:pycode="true"
|
||
:mustmatch="true"
|
||
:query-params="{ dataset: 'v_b_othercompany_my' }"
|
||
/>
|
||
<G3Field
|
||
v-model="maintable.b_bankname"
|
||
label="付款账户"
|
||
type="select"
|
||
:query-params="{ dataset: 'v_cw_account' }"
|
||
@select="handlebanknameSelect"
|
||
/>
|
||
<G3Field v-model="maintable.b_account_id" label="付款账号" type="input" />
|
||
|
||
<G3Field v-model="maintable.b_state" label="审核状态" type="input" disabled="disabled" />
|
||
<G3Field v-model="maintable.b_bz" label="备注" type="g3memo" />
|
||
</div>
|
||
<div class="g3container">
|
||
<div class="g3toolbarsub">
|
||
<el-button style="margin-left: 5px" @click="openDialog" :disabled="morePermission(3)">
|
||
选择费用
|
||
</el-button>
|
||
<el-button @click="hlOpenDialog"> 汇率 </el-button>
|
||
<el-dropdown>
|
||
<div class="el-dropdown-link">
|
||
更多
|
||
<el-icon class="el-icon--right">
|
||
<ArrowDown />
|
||
</el-icon>
|
||
</div>
|
||
<template #dropdown>
|
||
<el-dropdown-menu>
|
||
<el-dropdown-item @click="handleDelAllRow" :disabled="morePermission(3)">
|
||
删除
|
||
</el-dropdown-item>
|
||
</el-dropdown-menu>
|
||
<el-dropdown-menu>
|
||
<el-dropdown-item
|
||
:disabled="morePermission(9)"
|
||
@click="handleSaveColumnEdit(tableRef, 'v_cw_fkdsub')"
|
||
>
|
||
栏位设定
|
||
</el-dropdown-item>
|
||
</el-dropdown-menu>
|
||
</template>
|
||
</el-dropdown>
|
||
</div>
|
||
<div class="g3subgrid">
|
||
<vxe-table
|
||
ref="tableRef"
|
||
border
|
||
stripe
|
||
header-align="center"
|
||
:data="subtable"
|
||
:filter-config="{
|
||
showIcon: false,
|
||
}"
|
||
:column-drag-config="{
|
||
showIcon: false,
|
||
trigger: 'cell',
|
||
}"
|
||
:row-config="{
|
||
// useKey: true,
|
||
// keyField: 'mx_xh',
|
||
// isCurrent: false,
|
||
// isHover: true,
|
||
}"
|
||
:cell-config="{
|
||
height: 26,
|
||
}"
|
||
:column-config="{
|
||
resizable: true,
|
||
drag: true,
|
||
}"
|
||
:edit-config="{
|
||
trigger: 'click',
|
||
mode: 'row',
|
||
autoClear: false,
|
||
showStatus: false,
|
||
showIcon: false,
|
||
}"
|
||
show-overflow
|
||
show-header-overflow
|
||
show-footer-overflow
|
||
height="100%"
|
||
>
|
||
<vxe-column type="seq" width="40" align="center" title=" " />
|
||
<vxe-column type="checkbox" width="50" align="center" />
|
||
|
||
<vxe-column
|
||
v-for="column in columns"
|
||
:key="column.prop"
|
||
:field="column.prop"
|
||
:title="column.label"
|
||
:width="column.edit_width || column.width"
|
||
:align="getAlignByFormat(column.displayFormat)"
|
||
:edit-render="{ autoFocus: true, enabled: true }"
|
||
>
|
||
<template #default="{ row }">
|
||
<div :class="{ cellreadonly: column.readOnly === '1' }">
|
||
<template v-if="['selectid', 'selectname'].includes(column.edit_type)">
|
||
{{ row[column.prop] }}
|
||
</template>
|
||
<template v-else-if="column.edit_type === 'checkbox'">
|
||
<el-checkbox :checked="row[column.prop] === '1'" />
|
||
</template>
|
||
<template v-else>
|
||
{{ formatValueByFormat(row[column.prop], column.displayFormat) }}
|
||
</template>
|
||
</div>
|
||
</template>
|
||
<template #edit="{ row }">
|
||
<el-input
|
||
v-if="column.edit_type === 'calculate'"
|
||
v-model="row[column.prop]"
|
||
size="small"
|
||
:disabled="column.readOnly === '1'"
|
||
@input="handleSubtableChange(row, column.prop)"
|
||
/>
|
||
<el-checkbox
|
||
v-else-if="column.edit_type === 'checkbox'"
|
||
:checked="row[column.prop] === '1'"
|
||
:disabled="column.readOnly === '1'"
|
||
/>
|
||
<el-input
|
||
v-else
|
||
v-model="row[column.prop]"
|
||
size="small"
|
||
:disabled="column.readOnly === '1'"
|
||
/>
|
||
</template>
|
||
</vxe-column>
|
||
|
||
<!-- 操作列 -->
|
||
<vxe-column title="操作" width="120" fixed="right" align="center">
|
||
<template #default="{ row }">
|
||
<div class="tableactions">
|
||
<el-button
|
||
:disabled="maintable.b_writeoff === '1'"
|
||
size="small"
|
||
type="danger"
|
||
@click="handleDelRow(row)"
|
||
>
|
||
删除
|
||
</el-button>
|
||
</div>
|
||
</template>
|
||
</vxe-column>
|
||
</vxe-table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 错误提示 -->
|
||
<el-alert
|
||
v-if="error"
|
||
class="g3-error-message"
|
||
:title="error"
|
||
type="error"
|
||
show-icon
|
||
closable
|
||
@close="error = ''"
|
||
/>
|
||
</div>
|
||
</div>
|
||
|
||
<g3SelectDlg
|
||
v-model:visible="dialogVisible"
|
||
title="请选择要核销的费用"
|
||
selectid="cwtofkd"
|
||
:wheresql="wheresql"
|
||
user-id=""
|
||
module-id="bs_business"
|
||
:before-confirm="handleBeforeConfirm"
|
||
@confirm="handleConfirm"
|
||
/>
|
||
<hldlg
|
||
v-model:visible="hlDialogVisible"
|
||
title="汇率"
|
||
:params="hlParams"
|
||
@confirm="handleConfirmHl"
|
||
/>
|
||
<Report
|
||
v-model="showReport"
|
||
:cateid="reportForm.cateid"
|
||
:valuesql="reportForm.valuesql"
|
||
:djid="reportForm.djid"
|
||
/>
|
||
</template>
|
||
|
||
<style lang="scss" scoped>
|
||
.g3pagecontainer {
|
||
box-sizing: border-box;
|
||
display: flex;
|
||
background-color: #f2f3f5;
|
||
width: 100%;
|
||
height: 100%;
|
||
flex-direction: column;
|
||
|
||
.g3toolbar {
|
||
display: flex;
|
||
width: 100%;
|
||
padding: 10px;
|
||
height: 50px;
|
||
margin-bottom: 4px;
|
||
border-bottom: 1px solid #e4e7ed;
|
||
background-color: #fff;
|
||
}
|
||
}
|
||
|
||
.main {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
width: 100%;
|
||
padding: 10px;
|
||
overflow-y: auto;
|
||
background-color: #fff;
|
||
border-bottom: 1px solid #e4e7ed;
|
||
min-height: 0;
|
||
}
|
||
|
||
.g3panel {
|
||
order: 1;
|
||
display: flex;
|
||
flex: 1;
|
||
overflow-y: auto;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.g3-error-message {
|
||
order: 2;
|
||
margin: 15px 0;
|
||
}
|
||
|
||
.g3header {
|
||
display: grid;
|
||
grid-template-columns: repeat(4, 1fr);
|
||
gap: 2px;
|
||
width: 1200px;
|
||
}
|
||
|
||
.g3header .field-remark {
|
||
grid-column: span 2;
|
||
height: 72px;
|
||
}
|
||
|
||
.g3header .field-remark :deep(textarea) {
|
||
height: 100%;
|
||
min-height: 100%;
|
||
resize: none;
|
||
box-sizing: border-box;
|
||
}
|
||
.g3header .field-remark :deep(.g3content) {
|
||
width: 100%;
|
||
}
|
||
|
||
.g3container {
|
||
display: flex;
|
||
flex-direction: column;
|
||
flex: 1;
|
||
background: #ffffff;
|
||
margin-top: 3px;
|
||
min-height: 0;
|
||
}
|
||
|
||
.g3toolbarsub {
|
||
display: flex;
|
||
align-items: center;
|
||
border: 1px solid #ebeef5;
|
||
padding: 3px 0px;
|
||
}
|
||
|
||
.g3subgrid {
|
||
flex: 1;
|
||
background: #ffffff;
|
||
overflow: auto;
|
||
min-height: 0;
|
||
}
|
||
|
||
:deep(.g3subgrid .vxe-cell) {
|
||
padding: 0px !important;
|
||
}
|
||
|
||
/* ////////////// */
|
||
.tableactions {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
}
|
||
:deep(.tableactions .el-button--small) {
|
||
font-size: 13px;
|
||
font-family:
|
||
-apple-system,
|
||
BlinkMacSystemFont,
|
||
Segoe UI,
|
||
PingFang SC,
|
||
Hiragino Sans GB,
|
||
Microsoft YaHei,
|
||
Helvetica Neue,
|
||
Helvetica,
|
||
Arial,
|
||
sans-serif,
|
||
Apple Color Emoji,
|
||
Segoe UI Emoji,
|
||
Segoe UI Symbol;
|
||
}
|
||
|
||
/**下拉 */
|
||
.el-dropdown-link {
|
||
cursor: pointer;
|
||
display: flex;
|
||
align-items: center;
|
||
margin-left: 14px;
|
||
justify-content: center;
|
||
color: #606266;
|
||
border-radius: 3px;
|
||
border: 1px solid #dcdfe6;
|
||
padding: 8px 15px;
|
||
}
|
||
|
||
.el-dropdown .g3-svg-query:focus,
|
||
.el-dropdown-link:focus {
|
||
outline: none !important;
|
||
}
|
||
.cellreadonly {
|
||
background-color: #f5f7fa;
|
||
height: 24px;
|
||
line-height: 24px;
|
||
color: #a8abb2;
|
||
}
|
||
:deep(.el-checkbox) {
|
||
height: 24px !important;
|
||
cursor: default;
|
||
}
|
||
:deep(.el-checkbox__inner) {
|
||
cursor: default !important;
|
||
}
|
||
|
||
/* ---------------添加disabled 修改效果 */
|
||
:deep(.el-input.is-disabled .el-input__inner) {
|
||
cursor: default;
|
||
}
|
||
|
||
:deep(.el-button.is-disabled) {
|
||
cursor: default;
|
||
}
|
||
|
||
/* ------------------ */
|
||
</style>
|