1083 lines
27 KiB
Vue
1083 lines
27 KiB
Vue
<script setup>
|
||
import g3Group from "@/components/g3Group.vue";
|
||
import g3SelectDlg from "@/components/g3SelectDlg.vue";
|
||
import Report from "@/components/report/report.vue";
|
||
|
||
import { ElMessage } from "element-plus";
|
||
import { computed, onMounted, ref } from "vue";
|
||
import { useRoute } from "vue-router";
|
||
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,
|
||
getFieldString,
|
||
checkAllowRepeat,
|
||
initReserveData,
|
||
handleYsYfSummary,
|
||
handleDisabledState,
|
||
} from "@/utils/g3Funlib";
|
||
import { generateInvoice } from "../components";
|
||
import { loaddataApi } from "@/utils/doSql";
|
||
import { useTabStore } from "@/store/tab.js";
|
||
import { getDateAfter, getDateTime } from "@/utils/time";
|
||
import math from "@/utils/math";
|
||
|
||
/* ================= 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);
|
||
|
||
const ysyfSummary = handleYsYfSummary(subtable, "[]", {
|
||
currencyField: "mx_moneytype_id",
|
||
amountField: "mx_fee_amount",
|
||
rmbField: "mx_amount_rmb",
|
||
typeField: "mx_type_id",
|
||
});
|
||
/* ================= selected ================= */
|
||
const selectedsummary = computed(() => {
|
||
const data = subtable.value || [];
|
||
|
||
if (!data.length) {
|
||
return "";
|
||
}
|
||
|
||
const rows = tableRef.value?.getCheckboxRecords() || [];
|
||
|
||
const calcMoney = (list, field) => {
|
||
const money = {};
|
||
let rmb = math.add(0);
|
||
|
||
list.forEach((row) => {
|
||
const moneytype = row.mx_fee_money_id || "";
|
||
const amount = row[field] || 0;
|
||
const amountRmb = row.mx_amount_rmb || 0;
|
||
|
||
if (row.mx_type_id === "应收") {
|
||
money[moneytype] = math.add(money[moneytype] || 0, amount);
|
||
|
||
rmb = math.subtract(rmb, amountRmb);
|
||
} else if (row.mx_type_id === "应付") {
|
||
money[moneytype] = math.subtract(money[moneytype] || 0, amount);
|
||
|
||
rmb = math.add(rmb, amountRmb);
|
||
}
|
||
});
|
||
|
||
return {
|
||
money,
|
||
rmb,
|
||
};
|
||
};
|
||
|
||
const formatMoney = (data) => {
|
||
return Object.entries(data)
|
||
.filter(([_, amount]) => !amount.eq(0))
|
||
.map(([moneytype, amount]) => `${moneytype} ${amount.toFixed()}`)
|
||
.join(" ");
|
||
};
|
||
|
||
const formatResult = (title, data, showRmb = false) => {
|
||
const result = [];
|
||
|
||
const moneyText = formatMoney(data.money);
|
||
|
||
if (moneyText) {
|
||
result.push(moneyText);
|
||
}
|
||
|
||
if (showRmb) {
|
||
result.push(`折本币合计:${data.rmb.toFixed()}`);
|
||
}
|
||
|
||
return `${title}${result.join(" ")}`;
|
||
};
|
||
|
||
// 全部账单金额(全部subtable)
|
||
const bill = calcMoney(data, "mx_fee_amount");
|
||
|
||
// 选中金额
|
||
const selected = calcMoney(rows, "mx_fee_amount");
|
||
|
||
// 选中未销金额
|
||
const notwriteoff = calcMoney(rows, "mx_sfd_totalamount_not");
|
||
|
||
const result = [];
|
||
|
||
// result.push(formatResult("账单金额:", bill, true));
|
||
|
||
if (rows.length) {
|
||
result.push(formatResult("选中金额:", selected));
|
||
result.push(formatResult("选中未销:", notwriteoff));
|
||
}
|
||
|
||
return result.join(" ");
|
||
});
|
||
|
||
/* ================= 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 openDialog() {
|
||
if (!maintable.value.b_dw_id) {
|
||
ElMessage.warning("结算单位,不能为空!");
|
||
return;
|
||
}
|
||
dialogVisible.value = true;
|
||
}
|
||
|
||
async function handleBeforeConfirm(rows) {
|
||
const tmpdwid = rows[0]?.mx_dw_id || "";
|
||
|
||
for (const row of rows) {
|
||
if ((row.mx_dw_id || "") !== tmpdwid) {
|
||
ElMessage.warning("结算单位不一致,请检查!");
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
async function handleConfirm(subidCondition) {
|
||
await handleMappingConfig("cwtoyfbill", 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_amount = calcAmountTotal();
|
||
}
|
||
|
||
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_yfbill");
|
||
maintable.value.b_id = await getSFId();
|
||
id.value = "";
|
||
}
|
||
|
||
/* ================= 新建 ================= */
|
||
async function handleNew() {
|
||
const reserveData = await initReserveData(maintable.value, "v_cw_yfbill");
|
||
resetAll();
|
||
op.value = "new";
|
||
await initNew();
|
||
Object.assign(maintable.value, reserveData);
|
||
}
|
||
|
||
function prepareSubTables() {
|
||
fillSerialNoAndDefaults(subtable.value, {
|
||
father: maintable.value.b_id,
|
||
});
|
||
}
|
||
|
||
function generateAmountDesc() {
|
||
const amountData = subtable.value.reduce(
|
||
(result, row) => {
|
||
const moneytype = row.mx_moneytype_id || "";
|
||
|
||
const sign = row.mx_type_id === "应付" ? 1 : -1;
|
||
|
||
const feeAmount = math.multiply(row.mx_fee_amount || 0, sign);
|
||
|
||
const rmbAmount = math.multiply(row.mx_amount_rmb || 0, sign);
|
||
|
||
result.moneyMap[moneytype] = math.add(result.moneyMap[moneytype] || 0, feeAmount);
|
||
|
||
result.rmbTotal = math.add(result.rmbTotal, rmbAmount);
|
||
|
||
return result;
|
||
},
|
||
{
|
||
moneyMap: {},
|
||
rmbTotal: 0,
|
||
},
|
||
);
|
||
|
||
return [
|
||
...Object.entries(amountData.moneyMap).map(([type, amount]) => `${type}:${amount.toFixed(2)}`),
|
||
`本币种合计:${amountData.rmbTotal.toFixed(2)}`,
|
||
].join(";");
|
||
}
|
||
|
||
async function beforeSave() {
|
||
error.value = "";
|
||
|
||
maintable.value.b_amount_desc = generateAmountDesc();
|
||
|
||
const ok = await checkMustField(maintable.value, "v_cw_yfbill");
|
||
if (!ok) return false;
|
||
|
||
const isValid = await checkAllowRepeat(maintable.value, "v_cw_yfbill");
|
||
if (!isValid) return false;
|
||
|
||
maintable.value.b_yw_ids = getFieldString(subtable.value, "b_ywno");
|
||
prepareSubTables();
|
||
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_bill",
|
||
keyField: "b_id",
|
||
inserts: maintableChanges.insertdata,
|
||
updates: maintableChanges.updatedata,
|
||
deletes: [],
|
||
updateWhere: "ISNULL(b_state,'草拟') IN ('草拟','审核驳回')",
|
||
deleteWhere: "ISNULL(b_state,'草拟') IN ('草拟','审核驳回')",
|
||
},
|
||
{
|
||
tableName: "cw_billsub",
|
||
keyField: "subid",
|
||
inserts: subtableChanges.insertdata,
|
||
updates: subtableChanges.updatedata,
|
||
deletes: subtableChanges.deletedata,
|
||
insertCheck: {
|
||
table: "cw_bill",
|
||
sourceField: "father",
|
||
targetField: "b_id",
|
||
where: "ISNULL(b_state,'草拟') IN ('草拟','审核驳回')",
|
||
},
|
||
updateWhere: `
|
||
ISNULL(mx_writeoff_status,'0') <> '1'
|
||
AND EXISTS (
|
||
SELECT 1
|
||
FROM cw_bill
|
||
WHERE cw_bill.b_id = cw_billsub.father
|
||
AND ISNULL(cw_bill.b_state,'草拟') IN ('草拟','审核驳回')
|
||
)
|
||
`,
|
||
deleteWhere: `
|
||
ISNULL(mx_writeoff_status,'0') <> '1'
|
||
AND EXISTS (
|
||
SELECT 1
|
||
FROM cw_bill
|
||
WHERE cw_bill.b_id = cw_billsub.father
|
||
AND ISNULL(cw_bill.b_state,'草拟') IN ('草拟','审核驳回')
|
||
)
|
||
`,
|
||
},
|
||
];
|
||
}
|
||
|
||
async function afterSave() {
|
||
await getMainTable("v_cw_yfbill", maintable, maintableorg, maintable.value.b_id);
|
||
await getSubTable("v_cw_yfbillsub", 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;
|
||
}
|
||
|
||
const exrate = maintable.value.b_exrate;
|
||
}
|
||
|
||
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 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/billconfirm", 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/billrollback", 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_yfbillsub", 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("删除成功");
|
||
|
||
maintable.value.b_amount = calcAmountTotal();
|
||
}
|
||
|
||
/* ================= 删除 ================= */
|
||
|
||
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_v_cw_ysbillsub";
|
||
let cateid = "实付销账";
|
||
|
||
try {
|
||
let valuesql = [];
|
||
|
||
valuesql.push(`select * from rp_v_cw_ysbillsub 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 calcAmountTotal() {
|
||
return math
|
||
.add(
|
||
...subtable.value.map((row) => {
|
||
const amount = Number(row.mx_amount_rmb || 0);
|
||
|
||
return row.mx_type_id === "应付" ? amount : -amount;
|
||
}),
|
||
)
|
||
.toFixed(3);
|
||
}
|
||
/* ================= 金额汇总 ================= */
|
||
|
||
async function loadMod() {
|
||
await getMainTable("v_cw_yfbill", maintable, maintableorg, id.value);
|
||
await getColumnconfig("v_cw_yfbillsub", columns);
|
||
await getSubTable("v_cw_yfbillsub", subtable, subtableorg, `father = '${id.value}'`);
|
||
}
|
||
|
||
async function loadNew() {
|
||
await getDefaultValue(maintable, "v_cw_yfbill");
|
||
await getColumnconfig("v_cw_yfbillsub", columns);
|
||
maintable.value.b_id = await getSFId();
|
||
maintable.value.b_state = "草拟";
|
||
maintable.value.b_module_id = "应付";
|
||
maintableorg.value = {};
|
||
}
|
||
|
||
async function handleToInvoiceByBill() {
|
||
try {
|
||
if (!tableRef.value) {
|
||
return;
|
||
}
|
||
|
||
// 根据账单查询费用明细
|
||
const subdata = await loaddataApi("v_cw_yfbillsub", `father = '${maintable.value.b_id}'`);
|
||
|
||
if (!subdata.length) {
|
||
ElMessage.warning("未找到对应费用明细");
|
||
return;
|
||
}
|
||
|
||
// 收集费用ID
|
||
const subids = subdata.map((row) => row.mx_fee_id);
|
||
|
||
await generateInvoice(subids, "应付");
|
||
|
||
ElMessage.success("保存成功");
|
||
} catch (error) {
|
||
console.error(error);
|
||
ElMessage.warning(error.message || "操作失败");
|
||
}
|
||
}
|
||
|
||
const handleFieldUpdate = ({ column, value }) => {
|
||
if (column.prop === "v_dw_name") {
|
||
maintable.value.b_dw_invaccount = value.b_invaccount;
|
||
maintable.value.b_dw_bankacount = value.b_bankacount;
|
||
|
||
// 账期
|
||
let zl = value.b_zl || 0;
|
||
maintable.value.b_zl = zl;
|
||
|
||
let date = maintable.value.b_date || "";
|
||
|
||
maintable.value.b_plandate = getDateAfter(date, zl);
|
||
}
|
||
if (column.prop === "v_mycompanyname") {
|
||
maintable.value.b_my_invaccount = value.b_invaccount;
|
||
maintable.value.b_my_bankacount = value.b_bankacount;
|
||
}
|
||
};
|
||
|
||
onMounted(async () => {
|
||
tabStore.registerLeave({
|
||
isChange() {
|
||
return checkChange();
|
||
},
|
||
|
||
async onConfirm() {
|
||
await handleSave();
|
||
},
|
||
});
|
||
|
||
if (op.value === "mod") {
|
||
await loadMod();
|
||
} else {
|
||
await loadNew();
|
||
}
|
||
});
|
||
</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>
|
||
<el-button
|
||
:disabled="morePermission(21) || op !== 'mod'"
|
||
type="primary"
|
||
@click="handleToInvoiceByBill"
|
||
>
|
||
应付发票
|
||
</el-button>
|
||
</div>
|
||
<div class="main">
|
||
<div>
|
||
<template v-if="maintable">
|
||
<g3Group v-model="maintable" viewtable="v_cw_yfbill" @select="handleFieldUpdate" />
|
||
</template>
|
||
<div class="g3container">
|
||
<div class="g3toolbarsub">
|
||
<el-button style="margin-left: 5px" @click="openDialog" :disabled="morePermission(3)">
|
||
选择费用
|
||
</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_yfbillsub')"
|
||
>
|
||
栏位设定
|
||
</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-checkbox
|
||
v-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 class="g3subfooter">
|
||
<div class="g3summary">
|
||
<template v-if="selectedsummary">
|
||
{{ selectedsummary }}
|
||
</template>
|
||
</div>
|
||
<div class="g3footerfeesum" v-if="subtable?.length" v-html="ysyfSummary?.allHtml"></div>
|
||
</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="cwtoyfbill"
|
||
:wheresql="wheresql"
|
||
user-id=""
|
||
module-id="bs_business"
|
||
@confirm="handleConfirm"
|
||
:before-confirm="handleBeforeConfirm"
|
||
/>
|
||
<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;
|
||
}
|
||
|
||
.main > div {
|
||
order: 1;
|
||
display: flex;
|
||
flex: 1;
|
||
overflow-y: auto;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.g3-error-message {
|
||
order: 2;
|
||
margin: 15px 0;
|
||
}
|
||
|
||
:deep(.g3panel) {
|
||
grid-template-columns: repeat(4, 1fr);
|
||
}
|
||
|
||
.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;
|
||
}
|
||
|
||
.g3subfooter {
|
||
display: flex;
|
||
}
|
||
.g3summary {
|
||
display: flex;
|
||
align-items: center;
|
||
gap: 4px;
|
||
font-size: 12px;
|
||
margin-right: 20px;
|
||
}
|
||
|
||
/* ////////////// */
|
||
.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>
|