123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615 |
- <template>
- <div class="tenant">
- <!-- <Banner /> -->
- <div class="content">
- <byTable
- :source="sourceList.data"
- :pagination="sourceList.pagination"
- :config="config"
- :loading="loading"
- highlight-current-row
- :selectConfig="selectConfig"
- :table-events="{
- select: select,
- }"
- :action-list="[
- {
- text: '导出Excel',
- action: () => deriveExcel(),
- },
- ]"
- @moreSearch="moreSearch"
- @get-list="getList">
- <template #amount="{ item }">
- <div :style="'color: ' + (item.status === '10' ? '#04cb04;' : 'red;')">
- <span style="padding-right: 4px">{{ item.currency }}</span>
- <span v-if="item.status === '20'">-</span>
- <span>{{ moneyFormat(item.amount, 2) }}</span>
- </div>
- </template>
- </byTable>
- </div>
- <el-dialog title="拆分" v-if="dialogVisible" v-model="dialogVisible" width="800" v-loading="loading">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
- <template #money>
- <div style="width: 100%">
- <el-row :gutter="10">
- <el-col :span="6">
- <el-form-item>
- <el-select v-model="formData.data.status" style="width: 100%" disabled>
- <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value" />
- </el-select>
- </el-form-item>
- </el-col>
- <el-col :span="12">
- <el-form-item>
- <el-input v-model="formData.data.amount" placeholder="请输入金额" class="input-with-select" disabled>
- <template #prepend>
- <el-select v-model="formData.data.currency" placeholder="请选择币种" style="width: 100px" disabled>
- <el-option v-for="item in accountCurrency" :key="item.value" :label="item.value" :value="item.value" />
- </el-select>
- </template>
- </el-input>
- </el-form-item>
- </el-col>
- </el-row>
- </div>
- </template>
- <template #slot>
- <div style="width: 100%">
- <el-button type="primary" @click="addRow"> 添加 </el-button>
- <br />
- <el-table :data="formData.data.accountDeptRunningWaterDetailList">
- <el-table-column prop="deptId" label="部门">
- <template #default="{ row, $index }">
- <el-form-item :prop="'accountDeptRunningWaterDetailList.' + $index + '.deptId'" :rules="rules.deptId" :inline-message="true">
- <el-cascader
- v-model="row.deptId"
- :options="deptTreeData"
- :props="{
- value: 'deptId',
- }"
- clearable
- filterable
- style="width: 100%" />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="amount" label="分拆金额">
- <template #default="{ row, $index }">
- <el-form-item :prop="'accountDeptRunningWaterDetailList.' + $index + '.amount'" :rules="rules.amount" :inline-message="true">
- <el-input-number
- onmousewheel="return false;"
- v-model="row.amount"
- placeholder="请输入金额"
- style="width: 100%"
- :precision="2"
- :controls="false"
- :min="0" />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="remarks" label="备注">
- <template #default="{ row, $index }">
- <el-form-item :prop="'accountDeptRunningWaterDetailList.' + $index + '.remarks'" :rules="rules.remarks" :inline-message="true">
- <el-input v-model="row.remarks" placeholder="请输入" />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="zip" align="center" label="操作" width="80">
- <template #default="{ $index }">
- <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="large" :loading="submitLoading"> 确 定 </el-button>
- </template>
- </el-dialog>
- <el-dialog title="调整部门" v-if="depModal" v-model="depModal" width="600" v-loading="loading">
- <p>部门名称</p>
- <el-cascader
- v-model="departmentId"
- :options="deptTreeData"
- :props="{
- value: 'deptId',
- }"
- clearable
- filterable
- style="width: 100%" />
- <template #footer>
- <el-button @click="depModal = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitDeptForm(departmentId)" size="large" :loading="submitLoading"> 确 定 </el-button>
- </template>
- </el-dialog>
- <el-dialog title="高级检索" v-if="openSearch" v-model="openSearch" width="600" :before-close="cancelSearch">
- <byForm :formConfig="formSearchConfig" :formOption="formOption" v-model="sourceList.pagination">
- <template #deptId>
- <div>
- <el-tree-select
- v-model="sourceList.pagination.deptId"
- :data="deptTreeData"
- check-strictly
- :render-after-expand="false"
- node-key="deptId"
- style="width: 100%"
- :props="defaultProps"
- clearable />
- </div>
- </template>
- <template #time>
- <div style="width: 100%">
- <el-row :gutter="10">
- <el-col :span="11">
- <el-date-picker
- v-model="sourceList.pagination.beginTime"
- type="datetime"
- placeholder="请选择"
- style="width: 100%"
- value-format="YYYY-MM-DD HH:mm:ss" />
- </el-col>
- <el-col :span="2" style="text-align: center">到</el-col>
- <el-col :span="11">
- <el-date-picker
- v-model="sourceList.pagination.endTime"
- type="datetime"
- placeholder="请选择"
- style="width: 100%"
- value-format="YYYY-MM-DD HH:mm:ss" />
- </el-col>
- </el-row>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="cancelSearch()" size="large">取 消</el-button>
- <el-button type="primary" @click="submitSearch()" size="large">确 定</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { ElMessage } from "element-plus";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import { computed, ref } from "vue";
- import useUserStore from "@/store/modules/user";
- const loading = ref(false);
- const submitLoading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- status: "",
- currency: "",
- type: "",
- corporationId: "",
- remarks: "",
- beginTime: "",
- endTime: "",
- },
- });
- let dialogVisible = ref(false);
- let modalType = ref("add");
- let rules = ref({
- type: [{ required: true, message: "请选择类型", trigger: "change" }],
- contactNumber: [{ required: true, message: "请输入联系号码", trigger: "blur" }],
- amount: [{ required: true, message: "请输入金额", trigger: "blur" }],
- });
- const status = ref([
- {
- label: "收入",
- value: "10",
- },
- {
- label: "支出",
- value: "20",
- },
- ]);
- const accountCurrency = ref([]);
- import Cookies from "js-cookie";
- const { proxy } = getCurrentInstance();
- const selectConfig = [];
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "部门",
- prop: "deptName",
- },
- },
- {
- attrs: {
- label: "交易时间",
- prop: "transactionTime",
- },
- },
- {
- attrs: {
- label: "交易金额",
- slot: "amount",
- },
- },
- // {
- // attrs: {
- // prop: "accountOpening",
- // label: "对方账户",
- // },
- // },
- // {
- // attrs: {
- // prop: "openingBank",
- // label: "对方银行",
- // },
- // },
- // {
- // attrs: {
- // prop: "name",
- // label: "对方账号",
- // },
- // },
- {
- attrs: {
- prop: "remarks",
- label: "摘要",
- "min-width": "200",
- },
- },
- // {
- // attrs: {
- // label: "操作",
- // width: "200",
- // align: "right",
- // },
- // renderHTML(row) {
- // return [
- // {
- // attrs: {
- // label: "调整部门",
- // type: "primary",
- // text: true,
- // },
- // el: "button",
- // click() {
- // depModal.value = true;
- // dtlData.value = row;
- // departmentId.value = [];
- // },
- // },
- // {
- // attrs: {
- // label: "分拆",
- // type: "primary",
- // text: true,
- // },
- // el: "button",
- // click() {
- // getDtl(row);
- // },
- // },
- // ];
- // },
- // },
- ];
- });
- const dtlData = ref({});
- let formData = reactive({
- data: {
- type: "1",
- },
- treeData: [],
- });
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const submit = ref(null);
- const depModal = ref(false);
- let deptTreeData = ref([]);
- let departmentId = ref([]);
- const getDept = async () => {
- // 部门树
- proxy
- .get("/tenantDept/list", {
- pageNum: 1,
- pageSize: 9999,
- tenantId: Cookies.get("tenantId"),
- })
- .then((message) => {
- recursive(message.data);
- deptTreeData.value = proxy.handleTree(message.data, "corporationId");
- });
- };
- getDept();
- const submitDeptForm = async (departmentId) => {
- if (departmentId.length == 0) {
- ElMessage.error("请选择部门");
- return;
- }
- let params = {
- deptId: departmentId[departmentId.length - 1],
- accountDeptRunningWaterId: dtlData.value.accountDeptRunningWaterId,
- id: dtlData.value.id,
- amount: dtlData.value.amount,
- };
- proxy
- .post("/accountDeptRunningWaterDetail/add", params)
- .then(() => {
- ElMessage.success("调整部门成功");
- depModal.value = false;
- getList();
- })
- .catch((error) => {
- ElMessage.error(error);
- });
- };
- const recursive = (data) => {
- data.map((item) => {
- item.label = item.deptName;
- item.id = item.corporationId;
- if (item.children) {
- recursive(item.children);
- } else {
- item.children = [];
- }
- });
- };
- const formConfig = computed(() => {
- return [
- {
- type: "select",
- prop: "accountManagementId",
- label: "付款账户",
- required: true,
- disabled: true,
- isLoad: {
- url: "/accountManagement/page",
- req: {
- pageNum: 1,
- pageSize: 9999,
- },
- labelKey: "name",
- labelVal: "id",
- method: "post",
- resUrl: "rows",
- },
- },
- {
- type: "date",
- prop: "transactionTime",
- label: "交易时间",
- disabled: true,
- },
- // {
- // type: "selectInput",
- // label: "交易金额",
- // itemWidth: 60,
- // data: accountCurrency.value,
- // placeholder: "请输入",
- // selectPlaceholder: "币种",
- // selectProp: "currency",
- // prop: "amount",
- // disabled: true,
- // },
- {
- type: "slot",
- prop: "money",
- slotName: "money",
- label: "交易金额",
- },
- {
- type: "input",
- prop: "remarks",
- label: "摘要",
- disabled: true,
- itemType: "textarea",
- disabled: true,
- },
- {
- type: "slot",
- label: "拆分明细",
- slotName: "slot",
- },
- ];
- });
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy.post("/accountDeptRunningWater/page", sourceList.value.pagination).then((message) => {
- sourceList.value.data = message.rows;
- sourceList.value.pagination.total = message.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- proxy.getDict(["account_currency"]).then((res) => {
- accountCurrency.value = res.account_currency.map((item) => {
- return {
- label: item.dictValue,
- value: item.dictKey,
- };
- });
- });
- const submitForm = async () => {
- submit.value.handleSubmit(() => {
- if (!(formData.data.accountDeptRunningWaterDetailList && formData.data.accountDeptRunningWaterDetailList.length > 0)) {
- return ElMessage("请添加拆分明细!");
- }
- let money = 0;
- for (let i = 0; i < formData.data.accountDeptRunningWaterDetailList.length; i++) {
- if (formData.data.accountDeptRunningWaterDetailList[i].amount && Number(formData.data.accountDeptRunningWaterDetailList[i].amount) !== 0) {
- money = Number(parseFloat(Number(money) + Number(formData.data.accountDeptRunningWaterDetailList[i].amount)));
- } else {
- return ElMessage("金额不能为0");
- }
- }
- if (Number(money) !== Number(formData.data.amount)) {
- return ElMessage("分拆总金额需等于交易金额");
- }
- submitLoading.value = true;
- let params = {
- id: formData.data.id,
- deptRunningWaterDetailList: formData.data.accountDeptRunningWaterDetailList,
- accountDeptRunningWaterId: formData.data.accountDeptRunningWaterId,
- };
- params.deptRunningWaterDetailList.map((item) => {
- item.deptId = item.deptId[item.deptId.length - 1];
- });
- proxy
- .post("/accountDeptRunningWaterDetail/add", {
- ...params,
- })
- .then(
- () => {
- ElMessage({
- message: "拆分成功",
- type: "success",
- });
- dialogVisible.value = false;
- submitLoading.value = false;
- getList();
- },
- (err) => (submitLoading.value = false)
- );
- });
- };
- const getDtl = (row) => {
- modalType.value = "edit";
- dialogVisible.value = true;
- proxy.post("/accountDeptRunningWaterDetail/detail", { id: row.id }).then((res) => {
- if (res.deptRunningWaterDetailList && res.deptRunningWaterDetailList.length > 0) {
- res.accountDeptRunningWaterDetailList = res.deptRunningWaterDetailList.map((item) => {
- item.deptId = [item.deptId];
- return item;
- });
- } else {
- res.accountDeptRunningWaterDetailList = [];
- }
- formData.data = res;
- dialogVisible.value = true;
- });
- };
- const addRow = () => {
- formData.data.accountDeptRunningWaterDetailList.push({
- remarks: "",
- amount: null,
- deptId: [],
- });
- };
- const handleRemove = (index) => {
- formData.data.accountDeptRunningWaterDetailList.splice(index, 1);
- return ElMessage({
- message: "删除成功!",
- type: "success",
- });
- };
- getList();
- const defaultProps = {
- children: "children",
- label: "deptName",
- };
- const openSearch = ref(false);
- const formSearchConfig = computed(() => {
- return [
- {
- type: "select",
- prop: "status",
- label: "收支类型",
- data: status.value,
- clearable: true,
- },
- {
- type: "select",
- prop: "currency",
- label: "币种",
- data: accountCurrency.value,
- clearable: true,
- },
- {
- type: "slot",
- slotName: "deptId",
- label: "归属部门",
- itemWidth: 50,
- },
- {
- type: "slot",
- slotName: "time",
- label: "交易时间",
- },
- {
- type: "input",
- itemType: "textarea",
- prop: "remarks",
- label: "摘要",
- },
- ];
- });
- let copySearch = ref({});
- const moreSearch = () => {
- copySearch.value = proxy.deepClone(sourceList.value.pagination);
- openSearch.value = true;
- };
- const cancelSearch = () => {
- sourceList.value.pagination = copySearch.value;
- openSearch.value = false;
- };
- const submitSearch = () => {
- if (
- sourceList.value.pagination.beginTime &&
- sourceList.value.pagination.endTime &&
- sourceList.value.pagination.beginTime > sourceList.value.pagination.endTime
- ) {
- return ElMessage("开始时间不能大于结束时间");
- }
- openSearch.value = false;
- sourceList.value.pagination.keyword = "";
- sourceList.value.pagination.pageNum = 1;
- getList();
- };
- const deriveExcel = () => {
- let queryParams = proxy.deepClone(sourceList.value.pagination);
- proxy.postTwo("/accountDeptRunningWater/export", queryParams).then((res) => {
- exportData(res, "部门费用管理.xlsx");
- });
- };
- const exportData = (res, name) => {
- const content = res;
- const blob = new Blob([content], { type: "application/ms-excel" });
- const fileName = name;
- if ("download" in document.createElement("a")) {
- // 非IE下载
- const elink = document.createElement("a");
- elink.download = fileName;
- elink.style.display = "none";
- elink.href = URL.createObjectURL(blob);
- document.body.appendChild(elink);
- elink.click();
- URL.revokeObjectURL(elink.href); // 释放URL 对象
- document.body.removeChild(elink);
- } else {
- navigator.msSaveBlob(blob, fileName);
- }
- };
- </script>
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- </style>
|