|
|
|
|
@ -0,0 +1,326 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div>
|
|
|
|
|
<xy-dialog
|
|
|
|
|
ref="dialog"
|
|
|
|
|
:is-show.sync="isShow"
|
|
|
|
|
type="form"
|
|
|
|
|
:title="type === 'add' ? '新增收入登记' : '编辑收入登记'"
|
|
|
|
|
:form="form"
|
|
|
|
|
:rules="rules"
|
|
|
|
|
@submit="submit"
|
|
|
|
|
>
|
|
|
|
|
<template v-slot:name>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">收入事项 :</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.name"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请输入收入事项"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
></el-input>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:type_id>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">
|
|
|
|
|
<span style="color: red; font-weight: 600; padding-right: 4px"
|
|
|
|
|
>*</span
|
|
|
|
|
>
|
|
|
|
|
收入类型 :
|
|
|
|
|
</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.type_id"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请选择收入类型"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in type_ids"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.value"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:way_id>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">收入方式 :</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="form.way_id"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请选择收入方式"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
>
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in way_ids"
|
|
|
|
|
:key="item.id"
|
|
|
|
|
:label="item.value"
|
|
|
|
|
:value="item.id"
|
|
|
|
|
></el-option>
|
|
|
|
|
</el-select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:from>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">收入来源 :</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="form.from"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请输入收入来源"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
></el-input>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:remark>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">备注 :</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-input
|
|
|
|
|
type="textarea"
|
|
|
|
|
:autosize="{ minRows: 2 }"
|
|
|
|
|
v-model="form.remark"
|
|
|
|
|
clearable
|
|
|
|
|
placeholder="请输入备注"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
></el-input>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:money>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">收入金额 :</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-input-number
|
|
|
|
|
v-model="form.money"
|
|
|
|
|
clearable
|
|
|
|
|
:precision="2"
|
|
|
|
|
placeholder="请输入收入金额"
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
:controls="false"
|
|
|
|
|
></el-input-number>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<template v-slot:file_ids>
|
|
|
|
|
<div class="xy-table-item">
|
|
|
|
|
<div class="xy-table-item-label">附件 :</div>
|
|
|
|
|
<div class="xy-table-item-content">
|
|
|
|
|
<el-upload
|
|
|
|
|
style="width: 300px"
|
|
|
|
|
ref="upload"
|
|
|
|
|
multiple
|
|
|
|
|
:on-success="
|
|
|
|
|
(response, file, fileList) =>
|
|
|
|
|
successHandle(response, file, fileList, 'file_ids')
|
|
|
|
|
"
|
|
|
|
|
:before-upload="uploadBefore"
|
|
|
|
|
accept=".rar,.zip,.doc,.docx,.pdf,.jpg,.png,.gif,.mp4,.xls,.xlsx"
|
|
|
|
|
:action="action"
|
|
|
|
|
:file-list="file_ids"
|
|
|
|
|
:auto-upload="false"
|
|
|
|
|
:on-remove="
|
|
|
|
|
(file, fileList) => removeHande(file, fileList, 'file_ids')
|
|
|
|
|
"
|
|
|
|
|
>
|
|
|
|
|
<el-button slot="trigger" size="small" type="primary"
|
|
|
|
|
>选取文件</el-button
|
|
|
|
|
>
|
|
|
|
|
<el-button
|
|
|
|
|
style="margin-left: 10px"
|
|
|
|
|
size="small"
|
|
|
|
|
type="success"
|
|
|
|
|
@click="$refs['upload'].submit()"
|
|
|
|
|
>开始上传</el-button
|
|
|
|
|
>
|
|
|
|
|
<div slot="tip" class="el-upload__tip">
|
|
|
|
|
支持文件格式:.rar .zip .doc .docx .pdf .jpg .png .gif .mp4 .xls
|
|
|
|
|
.xlsx
|
|
|
|
|
<br />单个文件不能超过20M
|
|
|
|
|
</div>
|
|
|
|
|
</el-upload>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</xy-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { show, save } from "@/api/income";
|
|
|
|
|
export default {
|
|
|
|
|
props: {
|
|
|
|
|
type_ids: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => [],
|
|
|
|
|
},
|
|
|
|
|
way_ids: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => [],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
isShow: false,
|
|
|
|
|
id: "",
|
|
|
|
|
type: "",
|
|
|
|
|
action: process.env.VUE_APP_UPLOAD_API,
|
|
|
|
|
file_ids: [],
|
|
|
|
|
|
|
|
|
|
form: {
|
|
|
|
|
name: "",
|
|
|
|
|
type_id: "",
|
|
|
|
|
way_id: "",
|
|
|
|
|
from: "",
|
|
|
|
|
remark: "",
|
|
|
|
|
status: 1,
|
|
|
|
|
money: "",
|
|
|
|
|
file_ids: "",
|
|
|
|
|
},
|
|
|
|
|
rules: {
|
|
|
|
|
type_id: [
|
|
|
|
|
{
|
|
|
|
|
required: true,
|
|
|
|
|
message: "请填写收入类型",
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
show() {
|
|
|
|
|
this.isShow = true;
|
|
|
|
|
},
|
|
|
|
|
hidden() {
|
|
|
|
|
this.isShow = false;
|
|
|
|
|
},
|
|
|
|
|
init() {
|
|
|
|
|
for (let key in this.form) {
|
|
|
|
|
if (this.form[key] instanceof Array) {
|
|
|
|
|
this.form[key] = [];
|
|
|
|
|
} else {
|
|
|
|
|
this.form[key] = "";
|
|
|
|
|
}
|
|
|
|
|
this.form.status = 1;
|
|
|
|
|
}
|
|
|
|
|
this.$refs["dialog"].clearValidate();
|
|
|
|
|
},
|
|
|
|
|
setId(id) {
|
|
|
|
|
if (typeof id == "number") {
|
|
|
|
|
this.id = id;
|
|
|
|
|
} else {
|
|
|
|
|
console.error("error typeof id: " + typeof id);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getId() {
|
|
|
|
|
return this.id;
|
|
|
|
|
},
|
|
|
|
|
setType(type = "add") {
|
|
|
|
|
let types = ["add", "editor"];
|
|
|
|
|
if (types.includes(type)) {
|
|
|
|
|
this.type = type;
|
|
|
|
|
} else {
|
|
|
|
|
console.warn("Unknown type: " + type);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setForm(key = [], value = []) {
|
|
|
|
|
if (key instanceof Array) {
|
|
|
|
|
key.forEach((key, index) => {
|
|
|
|
|
this.form[key] = value[index] ?? "";
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (typeof key === "string") {
|
|
|
|
|
this.form[key] = value;
|
|
|
|
|
}
|
|
|
|
|
if (!key) {
|
|
|
|
|
this.init();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
//上传
|
|
|
|
|
successHandle(response, file, fileList, key) {
|
|
|
|
|
this[key] = fileList;
|
|
|
|
|
},
|
|
|
|
|
removeHande(file, fileList, key) {
|
|
|
|
|
this[key] = fileList;
|
|
|
|
|
},
|
|
|
|
|
uploadBefore(file) {
|
|
|
|
|
console.log(file);
|
|
|
|
|
if (file.size / 1000 > 20 * 1024) {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "warning",
|
|
|
|
|
message: "上传图片大小超过20MB!",
|
|
|
|
|
});
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
async getDetail() {
|
|
|
|
|
const res = await show({ id: this.id });
|
|
|
|
|
this.$integrateData(this.form, res);
|
|
|
|
|
this.file_ids = res.files.map((i) => {
|
|
|
|
|
return {
|
|
|
|
|
name: i.original_name,
|
|
|
|
|
url: i.url,
|
|
|
|
|
response: i,
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
|
if (this.type === "add") {
|
|
|
|
|
if (this.form.hasOwnProperty("id")) {
|
|
|
|
|
delete this.form.id;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (this.type === "editor") {
|
|
|
|
|
Object.defineProperty(this.form, "id", {
|
|
|
|
|
value: this.id,
|
|
|
|
|
enumerable: true,
|
|
|
|
|
configurable: true,
|
|
|
|
|
writable: true,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
this.form.file_ids = this.file_ids.map((i) => i.response.id);
|
|
|
|
|
save(this.form).then((res) => {
|
|
|
|
|
this.$message({
|
|
|
|
|
type: "success",
|
|
|
|
|
message:
|
|
|
|
|
this.type === "add" ? "新增收入登记" : "编辑收入登记" + "成功",
|
|
|
|
|
});
|
|
|
|
|
this.isShow = false;
|
|
|
|
|
this.$emit("refresh");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
isShow(val) {
|
|
|
|
|
if (val) {
|
|
|
|
|
if (this.type === "editor") {
|
|
|
|
|
this.getDetail();
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
this.id = "";
|
|
|
|
|
this.type = "";
|
|
|
|
|
this.init();
|
|
|
|
|
this.$refs["dialog"].clearValidate();
|
|
|
|
|
delete this.form.id;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
::v-deep .el-input__inner {
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
</style>
|