123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- <template>
- <div class="pageIndexClass">
- <div class="content">
- <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
- highlight-current-row :action-list="[
- {
- text: '添加发票',
- action: () => openModal('add'),
- },
- ]" @get-list="getList">
- </byTable>
- </div>
- <el-dialog :title="modalType == 'add' ? '添加发票' : '编辑发票'" v-if="dialogVisible" v-model="dialogVisible" width="1000" v-loading="loadingDialog">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="submit">
- <template #information>
- <el-table :data="formData.data.invoiceDetailsList" style="width: 100%; margin-top: 16px">
- <el-table-column prop="code" label="采购合同" min-width="140" />
- <el-table-column prop="amount" label="合同金额" width="120" />
- <el-table-column prop="sumInvoiceMoney" label="已收发票金额" width="120" />
- <el-table-column label="关联金额" width="140">
- <template #default="{ row, $index }">
- <el-form-item :prop="'invoiceDetailsList.' + $index + '.money'" :rules="rules.money" :inline-message="true">
- <el-input-number onmousewheel="return false;" v-model="row.money" placeholder="请输入关联金额" style="width: 100%" :precision="2"
- :controls="false" :min="0" />
- </el-form-item>
- </template>
- </el-table-column>
- </el-table>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="default">取 消</el-button>
- <el-button type="primary" @click="submitForm()" size="default">确 定</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
- <script setup>
- import { computed, ref } from "vue";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import useUserStore from "@/store/modules/user";
- import { ElMessage, ElMessageBox } from "element-plus";
- const { proxy } = getCurrentInstance();
- const invoiceType = ref([]);
- const supplierList = ref([]);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 0,
- pageNum: 1,
- pageSize: 10,
- keyword: "",
- invoiceType: "",
- },
- });
- const loading = ref(false);
- const selectConfig = computed(() => {
- return [
- {
- label: "发票类型",
- prop: "invoiceType",
- data: invoiceType.value,
- },
- ];
- });
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "业务公司",
- prop: "companyName",
- width: 110,
- },
- },
- {
- attrs: {
- label: "供应商",
- prop: "supplyName",
- width: 250,
- },
- },
- {
- attrs: {
- label: "发票类型",
- prop: "type",
- width: 160,
- },
- render(type) {
- let text = "";
- if (invoiceType.value && invoiceType.value.length > 0) {
- let data = invoiceType.value.filter((item) => item.value == type);
- if (data && data.length > 0) {
- text = data[0].label;
- }
- }
- return text;
- },
- },
- {
- attrs: {
- label: "发票金额",
- prop: "money",
- width: 160,
- },
- },
- {
- attrs: {
- label: "关联合同",
- prop: "purchaseCodes",
- },
- },
- {
- attrs: {
- label: "操作",
- width: "120",
- align: "center",
- },
- renderHTML(row) {
- return proxy.isCurrentCompanyData(row.companyId)
- ? [
- {
- attrs: {
- label: "修改",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- update(row);
- },
- },
- {
- attrs: {
- label: "删除",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- ElMessageBox.confirm(
- "此操作将永久删除该数据, 是否继续?",
- "提示",
- {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }
- ).then(() => {
- proxy
- .post("/invoice/delete", {
- id: row.id,
- })
- .then(() => {
- ElMessage({
- message: "删除成功",
- type: "success",
- });
- getList();
- });
- });
- },
- },
- ]
- : [];
- },
- },
- ];
- });
- const getDict = () => {
- proxy
- .post("/dictTenantData/page", {
- pageNum: 1,
- pageSize: 999,
- dictCode: "invoice_type",
- tenantId: useUserStore().user.tenantId,
- })
- .then((res) => {
- if (res.rows && res.rows.length > 0) {
- invoiceType.value = res.rows.map((item) => {
- return {
- label: item.dictValue,
- value: item.dictKey,
- };
- });
- }
- });
- proxy
- .post("/supplierInfo/page", { pageNum: 1, pageSize: 999 })
- .then((res) => {
- if (res.rows && res.rows.length > 0) {
- supplierList.value = res.rows.map((item) => {
- return {
- label: item.name,
- value: item.id,
- };
- });
- }
- });
- };
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy.post("/invoice/page", sourceList.value.pagination).then((res) => {
- sourceList.value.data = res.rows;
- sourceList.value.pagination.total = res.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- getDict();
- getList();
- const modalType = ref("add");
- const dialogVisible = ref(false);
- const loadingDialog = ref(false);
- const uploadData = ref({});
- const submit = ref(null);
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const formConfig = computed(() => {
- return [
- {
- type: "treeSelect",
- prop: "companyId",
- label: "业务公司",
- data: proxy.useUserStore().allDict["tree_company_data"],
- propsTreeLabel: "deptName",
- propsTreeValue: "deptId",
- itemWidth: 50,
- },
- {
- type: "select",
- label: "供应商",
- prop: "supplyId",
- data: supplierList.value,
- fn: (val) => {
- changeSupply(val);
- },
- disabled: formData.data.id,
- itemWidth: 50,
- },
- {
- type: "select",
- label: "发票类型",
- prop: "type",
- data: invoiceType.value,
- itemWidth: 50,
- },
- {
- type: "number",
- prop: "money",
- label: "开票金额",
- precision: 2,
- min: 0,
- controls: false,
- itemWidth: 50,
- },
- {
- type: "upload",
- listType: "text",
- accept: "",
- prop: "fileList",
- label: "上传附件",
- },
- {
- type: "slot",
- prop: "information",
- slotName: "information",
- label: "发票信息",
- },
- ];
- });
- const rules = ref({
- supplyId: [{ required: true, message: "请选择供应商", trigger: "change" }],
- type: [{ required: true, message: "请选择发票类型", trigger: "change" }],
- money: [{ required: true, message: "请输入金额", trigger: "blur" }],
- companyId: [{ required: true, message: "请选择业务公司", trigger: "change" }],
- });
- const formData = reactive({
- data: {
- invoiceDetailsList: [],
- },
- });
- const openModal = (val) => {
- modalType.value = val;
- formData.data = {
- invoiceDetailsList: [],
- fileList: [],
- };
- loadingDialog.value = false;
- dialogVisible.value = true;
- };
- const changeSupply = (val) => {
- if (val) {
- proxy
- .get("/ehsdPurchase/getNoInvoiceListBySupplyId", { supplyId: val })
- .then((res) => {
- if (res.data && res.data.length > 0) {
- formData.data.invoiceDetailsList = res.data.map((item) => {
- return {
- purchaseId: item.id,
- code: item.code,
- amount: item.amount,
- sumInvoiceMoney: item.sumInvoiceMoney,
- money: 0,
- remark: "",
- };
- });
- } else {
- formData.data.invoiceDetailsList = [];
- }
- });
- } else {
- formData.data.invoiceDetailsList = [];
- }
- };
- const uploadFile = async (file) => {
- const res = await proxy.post("/fileInfo/getSing", { fileName: file.name });
- uploadData.value = res.uploadBody;
- file.id = res.id;
- file.fileName = res.fileName;
- file.fileUrl = res.fileUrl;
- return true;
- };
- const onPreviewFile = (file) => {
- window.open(file.raw.fileUrl, "_blank");
- };
- const submitForm = () => {
- submit.value.handleSubmit(() => {
- if (
- !(
- formData.data.invoiceDetailsList &&
- formData.data.invoiceDetailsList.length > 0
- )
- ) {
- return ElMessage("该供应商暂无关联合同");
- }
- let money = 0;
- for (let i = 0; i < formData.data.invoiceDetailsList.length; i++) {
- money = parseFloat(
- Number(money) + Number(formData.data.invoiceDetailsList[i].money)
- ).toFixed(2);
- }
- if (money != formData.data.money) {
- return ElMessage("开票金额不等于关联金额");
- }
- loadingDialog.value = true;
- proxy.post("/invoice/" + modalType.value, formData.data).then(
- () => {
- ElMessage({
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
- type: "success",
- });
- dialogVisible.value = false;
- getList();
- },
- (err) => {
- console.log(err);
- loadingDialog.value = false;
- }
- );
- });
- };
- const update = (row) => {
- modalType.value = "edit";
- loadingDialog.value = true;
- dialogVisible.value = true;
- proxy.post("/invoice/detail", { id: row.id }).then((res) => {
- if (res.invoiceDetailsVoList && res.invoiceDetailsVoList.length > 0) {
- res.invoiceDetailsList = res.invoiceDetailsVoList.map((item) => {
- return {
- code: item.purchaseCode,
- purchaseId: item.purchaseId,
- amount: item.purchaseAmount,
- sumInvoiceMoney: item.sumMoney,
- money: item.money,
- };
- });
- }
- if (res.type) {
- res.type = res.type + "";
- }
- res.fileList = [];
- delete res.invoiceDetailsVoList;
- formData.data = res;
- loadingDialog.value = false;
- loadingDialog.value = false;
- proxy
- .post("/fileInfo/getList", { businessIdList: [row.id] })
- .then((fileObj) => {
- if (fileObj[row.id] && fileObj[row.id].length > 0) {
- formData.data.fileList = fileObj[row.id].map((item) => {
- return {
- ...item,
- name: item.fileName,
- url: item.fileUrl,
- };
- });
- } else {
- formData.data.fileList = [];
- }
- });
- });
- };
- </script>
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- ::v-deep(.el-input-number .el-input__inner) {
- text-align: left;
- }
- </style>
|