From 077627b8f9f4d82db05eb073e3f6d35f03870d38 Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Tue, 9 Jan 2024 17:33:07 +0800 Subject: [PATCH] 1 --- package.json | 1 + src/api/dashboard.js | 51 ++++--- src/utils/createDialog.js | 2 +- src/views/assets/component/addLease.vue | 75 ++++++++-- src/views/assets/files.vue | 171 +++++++++++++++------- src/views/assets/lease.vue | 14 ++ src/views/component/detail.vue | 34 ++++- src/views/dashboard/components/drawer.vue | 15 +- src/views/dashboard/index.vue | 16 +- 9 files changed, 284 insertions(+), 95 deletions(-) diff --git a/package.json b/package.json index b8ba805..a74f64a 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "echarts": "^4.2.1", "element-ui": "2.15.13", "file-saver": "^2.0.5", + "html2canvas": "^1.4.1", "js-cookie": "2.2.0", "less-loader": "^5.0.0", "moment": "^2.29.2", diff --git a/src/api/dashboard.js b/src/api/dashboard.js index 858d041..bb12fae 100644 --- a/src/api/dashboard.js +++ b/src/api/dashboard.js @@ -1,26 +1,33 @@ -import request from '@/utils/request' - -export function getCounts() { - return request({ - url: '/api/admin/get-counts', - method: 'get' - }) -} - - -export function getChartsData(params) { - return request({ - url: '/api/admin/get-charts-data', - method: 'get', - params: params - }) +import request from '@/utils/request' + +export function getCounts() { + return request({ + url: '/api/admin/get-counts', + method: 'get' + }) } -export function getChartsHome(params) { - return request({ - url: '/api/admin/chart/home', - method: 'get', - params: params - }) + +export function getChartsData(params) { + return request({ + url: '/api/admin/get-charts-data', + method: 'get', + params: params + }) } +export function getChartsHome(params) { + return request({ + url: '/api/admin/chart/home', + method: 'get', + params: params + }) +} + +export function getNotice () { + return request({ + method: 'get', + url: '/api/admin/other/notice', + isLoading: false + }) +} diff --git a/src/utils/createDialog.js b/src/utils/createDialog.js index dc5a04e..34a3022 100644 --- a/src/utils/createDialog.js +++ b/src/utils/createDialog.js @@ -123,7 +123,7 @@ export class CreateDialog { class: "el-upload__tip", slot: "tip", }, - "文件不超过500kb" + "文件不超过50Mb" ), ]; } diff --git a/src/views/assets/component/addLease.vue b/src/views/assets/component/addLease.vue index a1d4ba5..1037c8c 100644 --- a/src/views/assets/component/addLease.vue +++ b/src/views/assets/component/addLease.vue @@ -93,7 +93,7 @@ export default { res[i._relations.link_with_name] instanceof Array ? res[i._relations.link_with_name].map((i) => { return { - name: i?.name, + name: i?.original_name, url: i?.url, response: i, }; @@ -134,6 +134,7 @@ export default { }); } let promiseAll = [] + let copyForm = deepCopy(this.form); this.formInfo.forEach((info) => { if ( info._relations?.link_relation === "newHasMany" || @@ -151,31 +152,87 @@ export default { } } + if (copyForm[info._relations?.link_with_name]?.length > 0) { + delete copyForm[info.field]; + } if ( info._relations?.link_relation === "newHasMany" || info._relations?.link_relation === "hasMany" ) { if (info.edit_input === "files") { - this.form[info._relations.link_with_name] = this.file[ + copyForm[info._relations.link_with_name] = this.file[ info.field ]?.map((i) => { let copyRelation = i?.response ? deepCopy(i?.response) : ""; - //TODO: 待修改 - if (/:\/\/:\/\//g.test(copyRelation?.url)) { - copyRelation.url.replace(/:\/\/:\/\//g,'://') - } delete copyRelation.id; return { - file_id: i?.response?.id, + upload_id: i?.response?.id, + ...copyRelation, + }; + }); + } else { + copyForm[info._relations.link_with_name] = copyForm[ + info.field + ]?.map((i) => { + let copyRelation = info._params.find( + (param) => param[info._relations?.foreign_key] === i + ) + ? deepCopy( + info._params.find( + (param) => param[info._relations?.foreign_key] === i + ) + ) + : ""; + delete copyRelation.id; + return { + [info._relations.foreign_key]: i, ...copyRelation, }; }); } + + delete copyForm[info.field]; } - }) + if ( + info._relations?.link_relation === "newHasOne" || + info._relations?.link_relation === "hasOne" + ) { + if (info.edit_input === "file") { + copyForm[info._relations.link_with_name] = [ + { + upload_id: this.file[info.field]?.response?.id, + ...this.file[info.field], + }, + ]; + } else { + let copyRelation = deepCopy( + info._params.find( + (param) => param.id == this.form[info.field] + ) + ); + if (copyRelation) { + delete copyRelation.id; + copyForm[info._relations.link_with_name] = [ + { + id: this.form[info._relations?.link_with_name]?.id, + [info.field === "shenhebumen" + ? "dept_id" + : info._relations.foreign_key]: this.form[info.field], + ...copyRelation, + }, + ]; + } + } + + delete copyForm[info.field]; + } + if (!copyForm[info._relations?.link_with_name]) { + delete copyForm[info._relations?.link_with_name]; + } + }); delete this.form['tupian'] - save(Object.assign(this.form, { table_name: 'leases' })).then(res => { + save(Object.assign(copyForm, { table_name: 'leases' })).then(res => { this.$Message.success({ content: `${this.type === "add" ? "新增" : "编辑"}成功`, }); diff --git a/src/views/assets/files.vue b/src/views/assets/files.vue index 4afba56..49eeb80 100644 --- a/src/views/assets/files.vue +++ b/src/views/assets/files.vue @@ -1,45 +1,66 @@ @@ -52,25 +73,45 @@ export default { props: {}, data() { return { + filterTag: [], + isShowModal: false, table: [ { key: 'original_name', title: '文件名称', - render: (h, { row }) => (h('span',row.response?.original_name)) + width: 180, + render: (h, { row }) => (h('div',[ + h('a',{ class: 'original-name-a', on: { click: () => this.openDownload(row) } },row.response?.original_name) + ])) }, { key: 'tag', - title: "标签" + title: "标签", + align: 'center', + render: (h, { row }) => (h('Tag',{ + props: { + color: 'primary' + } + },row.response?.tag)) }, { key: 'year', title: '年份', + align: 'center', render: (h, { row }) => (h('span',row.response?.year)) }, { - key: 'year', + key: 'nianxian', title: '年限', + align: 'center', render: (h, { row }) => (h('span',row.response?.nianxian)) + }, + { + key: 'btns', + title: '操作', + render: (h,{ row }) => (h('div',[ + h('Button',{ props: { type: 'error',size: 'small' },on: { click: ()=>this.deleteFile(row) } },'删除') + ])) } ], isShow: false, @@ -78,9 +119,12 @@ export default { type: '', action: process.env.VUE_APP_UPLOAD_API, fileList: [], + lists: [], form: { - file: [] + year: '', + tag: '', + nianxian: '', }, rules: { name: [ @@ -114,7 +158,9 @@ export default { }, init() { this.form = { - file: [] + year: '', + tag: '', + nianxian: '', } }, setId(id) { @@ -152,8 +198,6 @@ export default { //上传 successHandle(response, file, fileList) { this.fileList = fileList - - this.submit(response) }, removeHande(file, fileList) { this.fileList = fileList @@ -190,47 +234,49 @@ export default { } ] }) - this.fileList = res.data.map((item) => { + this.lists = res.data.map((item) => { return { name: item.original_name, url: item.url, response: item } }) - this.$integrateData(this.form, res) - console.log(this.fileList) }, - submit(response) { + submit() { save({ table_name: 'asset_file_files', - file_id: response.id, + file_id: this.fileList[0]?.response?.id, [/\/land/g.test(this.$route.path) ? 'land_id' : 'house_id']: this.id, - name: response.name, - original_name: response.original_name, + name: this.fileList[0]?.response?.name, + original_name: this.fileList[0]?.response?.original_name, //TODO: 待修改 - url: response.url.replace(/:\/\/:\/\//g, '://') + url: this.fileList[0]?.response?.url.replace(/:\/\/:\/\//g, '://'), + ...this.form }).then(res => { this.$message({ type: 'success', message: '附件上传成功' }) + this.getDetail() + this.isShowModal = false + this.init() }) }, - openDownload (file) { - window.open(file.url) + openDownload (row) { + window.open(row.url) }, - deleteFile (file) { + deleteFile (row) { this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(res => { - if (file.response?.id) { + if (row.response?.id) { destroy({ table_name: "asset_file_files", - id: file.response.id + id: row.response.id }).then(res => { this.$message({ type: 'success', @@ -242,6 +288,12 @@ export default { }) } }, + computed: { + fileData () { + if (this.filterTag.length === 0) return this.lists; + return this.lists.filter(i => (this.filterTag.find(j => j === i.response?.tag))) + } + }, watch: { isShow(val) { if (val) { @@ -308,4 +360,17 @@ export default { ::v-deep .el-input__inner { text-align: left; } + + + diff --git a/src/views/assets/lease.vue b/src/views/assets/lease.vue index 0490745..18e2e0a 100644 --- a/src/views/assets/lease.vue +++ b/src/views/assets/lease.vue @@ -89,6 +89,20 @@ export default { label: '用途', prop: 'yongtu', width: 160 + }, + { + label: "附件", + prop: 'file', + minWidth: 180, + customFn:row => { + return ( +
+ { + row.id_lease_file_files_lease_id_relation.map(i => ((window.open(i.url))}}>{i.original_name})) + } +
+ ) + } } ], }; diff --git a/src/views/component/detail.vue b/src/views/component/detail.vue index dd5e6db..b4b0f4b 100644 --- a/src/views/component/detail.vue +++ b/src/views/component/detail.vue @@ -15,7 +15,7 @@ - + + +