刘翔宇-旅管家 2 years ago
parent 938fc5d2f2
commit 9995d26cdd

@ -2,8 +2,8 @@
ENV = 'development' ENV = 'development'
# base api # base api
#VUE_APP_DOMIAN=http://192.168.60.99:9003/ VUE_APP_DOMIAN=http://192.168.60.99:9003/
VUE_APP_DOMIAN=http://hdcontract.ali251.langye.net/ #VUE_APP_DOMIAN=http://hdcontract.ali251.langye.net/
VUE_APP_BASE_API = '' VUE_APP_BASE_API = ''
VUE_APP_UPLOAD=http://hdcontract.ali251.langye.net/api/admin/upload-file VUE_APP_UPLOAD=http://hdcontract.ali251.langye.net/api/admin/upload-file

@ -1,330 +1,348 @@
<template> <template>
<div> <div>
<Modal v-model="isShow" title="附件" footer-hide :width="64"> <Modal v-model="isShow" title="附件" footer-hide :width="64">
<Button v-if="role === 1 || role === 0" type="primary" shape="circle" icon="ios-add" @click="add" <Button v-if="role === 1 || role === 0" type="primary" shape="circle" icon="ios-add" @click="add"></Button>
>新增</Button
> <Table style="margin-top: 10px" :height="320" :data="detail.attachment" :columns="columns">
</Table>
<Table </Modal>
style="margin-top: 10px" </div>
:height="320" </template>
:data="detail.attachment"
:columns="columns" <script>
> import {
</Table> getToken
</Modal> } from "@/utils/auth";
</div> import {
</template> show,
save,
<script> store
import { getToken } from "@/utils/auth"; } from "@/api/propertyPlan";
import { show, save, store } from "@/api/propertyPlan"; export default {
export default { props: {
props: { role: Number
role: Number },
}, data() {
data() { return {
return { fileList: [],
fileList: [], action: process.env.VUE_APP_UPLOAD,
action: process.env.VUE_APP_UPLOAD, key: 1,
key: 1, isShowModal: false,
isShowModal: false, isShow: false,
isShow: false, id: "",
id: "", type: "",
type: "",
detail: {},
detail: {}, columns: [{
columns: [ key: "file",
{ title: "文件(点击下载)",
key: "file", width: 200,
title: "文件(点击下载)", render: (h, {
width: 200, row
render: (h, { row }) => { }) => {
return h( return h(
"a", "a", {
{ attrs: {
attrs: { download: row.file.original_name, href: row.file.url }, download: row.file.original_name,
}, href: row.file.url
row.file.original_name },
); },
}, row.file.original_name
}, );
{ },
key: "content", },
title: "内容", {
minWidth: 220, key: "content",
align: "left", title: "内容",
}, minWidth: 220,
{ align: "left",
key: "date", },
title: "日期", {
width: 160, key: "date",
}, title: "日期",
{ width: 160,
key: "operate", },
title: "操作", {
width: 100, key: "operate",
align: "left", title: "操作",
render: (h, { row }) => { width: 100,
if (this.role == 0 || this.role == 1) align: "left",
return h("Poptip", { render: (h, {
props: { row
transfer: true, }) => {
confirm: true, if (this.role == 0 || this.role == 1)
title: "确认要删除吗", return h("Poptip", {
}, props: {
scopedSlots: { transfer: true,
default: () => { confirm: true,
return h( title: "确认要删除吗",
"Button", },
{ scopedSlots: {
props: { default: () => {
ghost: true, return h(
size: "small", "Button", {
type: "error", props: {
}, ghost: true,
}, size: "small",
"删除" type: "error",
); },
}, },
}, "删除"
on: { );
["on-ok"]: (_) => { },
let attachments = this.detail.attachment },
.filter((i) => i.id !== row.id) on: {
.map((i) => { ["on-ok"]: (_) => {
return { let attachments = this.detail.attachment
file: i.file.id, .filter((i) => i.id !== row.id)
date: i.date, .map((i) => {
content: i.content, return {
}; file: i.file.id,
}); date: i.date,
save({ content: i.content,
...this.detail, };
attachment_list: attachments, });
content_list: this.detail.content.map((i) => { save({
return { ...this.detail,
title: i.title, attachment_list: attachments,
content: i.content, content_list: this.detail.content.map((i) => {
date: i.date, return {
}; title: i.title,
}), content: i.content,
}).then((_) => { date: i.date,
this.$message({ };
type: "success", }),
message: "删除成功", }).then((_) => {
}); this.$message({
this.getDetail(); type: "success",
}); message: "删除成功",
}, });
}, this.getDetail();
}); });
}, },
}, },
], });
}; },
}, },
methods: { ],
show() { };
this.isShow = true; },
}, methods: {
hidden() { show() {
this.isShow = false; this.isShow = true;
}, },
init() { hidden() {
for (let key in this.form) { this.isShow = false;
if (this.form[key] instanceof Array) { },
this.form[key] = []; init() {
} else { for (let key in this.form) {
this.form[key] = ""; if (this.form[key] instanceof Array) {
} this.form[key] = [];
} } else {
this.$refs["dialog"].clearValidate(); this.form[key] = "";
}, }
setId(id) { }
if (typeof id == "number") { this.$refs["dialog"].clearValidate();
this.id = id; },
} else { setId(id) {
console.error("error typeof id: " + typeof id); if (typeof id == "number") {
} this.id = id;
}, } else {
getId() { console.error("error typeof id: " + typeof id);
return this.id; }
}, },
setType(type = "add") { getId() {
let types = ["add", "editor"]; return this.id;
if (types.includes(type)) { },
this.type = type; setType(type = "add") {
} else { let types = ["add", "editor"];
console.warn("Unknown type: " + type); if (types.includes(type)) {
} this.type = type;
}, } else {
setForm(key = [], value = []) { console.warn("Unknown type: " + type);
if (key instanceof Array) { }
key.forEach((key, index) => { },
this.form[key] = value[index] ?? ""; setForm(key = [], value = []) {
}); if (key instanceof Array) {
} key.forEach((key, index) => {
if (typeof key === "string") { this.form[key] = value[index] ?? "";
this.form[key] = value; });
} }
if (!key) { if (typeof key === "string") {
this.init(); this.form[key] = value;
} }
}, if (!key) {
this.init();
async getDetail() { }
const res = await show({ id: this.getId() }); },
this.detail = res;
console.log(res); async getDetail() {
}, const res = await show({
id: this.getId()
async add() { });
let form = { this.detail = res;
date: this.$moment(new Date()).format("YYYY-MM-DD"), console.log(res);
file: "", },
content: "",
}; async add() {
const h = this.$createElement; let form = {
this.$msgbox({ date: this.$moment(new Date()).format("YYYY-MM-DD"),
title: "新增附件", file: "",
message: h( content: "",
"el-form", };
{ key: ++this.key, props: { model: form, "label-width": "80px" } },
[ this.fileList = [];
h("el-form-item", { const h = this.$createElement;
props: { label: "文件", required: true }, this.$msgbox({
scopedSlots: { title: "新增附件",
default: () => message: h(
h( "el-form", {
"el-upload", key: ++this.key,
{ props: {
props: { model: form,
action: this.action, "label-width": "80px"
"file-list": this.fileList, }
limit: 1, },
headers: { [
Authorization: "Bearer " + getToken(), h("el-form-item", {
}, props: {
accept: label: "文件",
".rar,.zip,.doc,.docx,.pdf,.jpg,.png,.gif,.xls,.xlsx", required: true
"on-success": (response, file, fileList) => { },
this.fileList = fileList; scopedSlots: {
form.file = response?.id; default: () =>
}, h(
"before-upload": (file) => { "el-upload", {
if (file.size / 1000 > 50 * 1024) { props: {
this.$message({ action: this.action,
type: "warning", "file-list": this.fileList,
message: "上传文件大小超过5M", limit: 1,
}); headers: {
return false; Authorization: "Bearer " + getToken(),
} },
}, accept: ".rar,.zip,.doc,.docx,.pdf,.jpg,.png,.gif,.xls,.xlsx",
"on-remove": (file, fileList) => { "on-success": (response, file, fileList) => {
this.fileList = fileList; this.fileList = fileList;
}, form.file = response?.id;
}, },
}, "before-upload": (file) => {
[ if (file.size / 1000 > 50 * 1024) {
h( this.$message({
"el-button", type: "warning",
{ message: "上传文件大小超过5M",
props: { });
type: "primary", return false;
size: "small", }
}, },
slot: "trigger", "on-remove": (file, fileList) => {
}, this.fileList = fileList;
"选取文件" },
), },
h( },
"div", [
{ h(
class: "el-upload__tip", "el-button", {
slot: "tip", props: {
}, type: "primary",
"支持文件格式:.docx.xlsx.pdf.png.jpg\n单个文件不能超过50M" size: "small",
), },
] slot: "trigger",
), },
}, "选取文件"
}), ),
h("el-form-item", { h(
props: { label: "内容" }, "div", {
scopedSlots: { class: "el-upload__tip",
default: () => slot: "tip",
h("textarea", { },
key: this.key, "支持文件格式:.docx.xlsx.pdf.png.jpg\n单个文件不能超过50M"
class: "el-textarea__inner", ),
props: { value: form.content }, ]
on: { ),
["input"]: (e) => { },
form.content = e.target.value; }),
}, h("el-form-item", {
}, props: {
}), label: "内容"
}, },
}), scopedSlots: {
] default: () =>
), h("textarea", {
showCancelButton: true, key: this.key,
confirmButtonText: "确定", class: "el-textarea__inner",
cancelButtonText: "取消", props: {
beforeClose: (action, instance, done) => { value: form.content
if (action === "confirm") { },
if (!form.file) { on: {
this.$message({ ["input"]: (e) => {
type: "warning", form.content = e.target.value;
message: "请上传附件", },
}); },
return; }),
} },
instance.confirmButtonLoading = true; }),
instance.confirmButtonText = "保存中..."; ]
this.detail.attachment_list = [ ),
...this.detail.attachment?.map((i) => { showCancelButton: true,
return { file: i.file.id, content: i.content, date: i.date }; confirmButtonText: "确定",
}), cancelButtonText: "取消",
form, beforeClose: (action, instance, done) => {
]; if (action === "confirm") {
save(this.detail) if (!form.file) {
.then((_) => { this.$message({
this.$message({ type: "warning",
type: "success", message: "请上传附件",
message: "保存成功", });
}); return;
instance.confirmButtonLoading = false; }
done(); instance.confirmButtonLoading = true;
this.getDetail(); instance.confirmButtonText = "保存中...";
this.fileList = []; this.detail.attachment_list = [
}) ...this.detail.attachment?.map((i) => {
.catch((_) => { return {
instance.confirmButtonLoading = false; file: i.file.id,
}); content: i.content,
} else { date: i.date
done(); };
} }),
}, form,
}); ];
}, save(this.detail)
}, .then((_) => {
watch: { this.$message({
isShow(val) { type: "success",
if (val) { message: "保存成功",
this.getDetail(); });
} else { instance.confirmButtonLoading = false;
this.id = ""; done();
this.fileList = []; this.getDetail();
} this.fileList = [];
}, })
}, .catch((_) => {
created() {}, instance.confirmButtonLoading = false;
}; });
</script> } else {
done();
<style scoped lang="scss"> }
::v-deep .el-input__inner { },
text-align: left; });
} },
},
watch: {
isShow(val) {
if (val) {
this.getDetail();
} else {
this.id = "";
}
},
},
created() {},
};
</script>
<style scoped lang="scss">
::v-deep .el-input__inner {
text-align: left;
}
</style> </style>

Loading…
Cancel
Save