|
|
@@ -16,28 +16,40 @@ |
|
|
|
模板样板文件 |
|
|
|
</div> |
|
|
|
<div class="template_files_right_list"> |
|
|
|
<div class="template_files_right_list_item"> |
|
|
|
<div>文件名</div> |
|
|
|
<div>文件扩展名</div> |
|
|
|
<div>文件大小</div> |
|
|
|
<div |
|
|
|
class="template_files_right_list_item" |
|
|
|
v-for="file in commonFileList" |
|
|
|
:key="file.id" |
|
|
|
> |
|
|
|
<div>{{file.fileName}}</div> |
|
|
|
<div>{{file.extension}}</div> |
|
|
|
<div>{{file.fileSize | resolveFileSize}}</div> |
|
|
|
<div /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="template_files_right_title"> |
|
|
|
新增样板文件 |
|
|
|
<file-uploader |
|
|
|
:on-success="uploadFileSuccess" |
|
|
|
> |
|
|
|
<el-button class="title_button" type="primary">上传文件</el-button> |
|
|
|
<file-uploader :on-success="uploadFileSuccess"> |
|
|
|
<el-button |
|
|
|
class="title_button" |
|
|
|
type="primary" |
|
|
|
>上传文件</el-button> |
|
|
|
</file-uploader> |
|
|
|
</div> |
|
|
|
<div class="template_files_right_list"> |
|
|
|
<div class="template_files_right_list_item"> |
|
|
|
<div>文件名</div> |
|
|
|
<div>文件扩展名</div> |
|
|
|
<div>文件大小</div> |
|
|
|
<div |
|
|
|
class="template_files_right_list_item" |
|
|
|
v-for="file in companyFileList" |
|
|
|
:key="file.id" |
|
|
|
> |
|
|
|
<div>{{file.fileName}}</div> |
|
|
|
<div>{{file.extension}}</div> |
|
|
|
<div>{{file.fileSize | resolveFileSize}}</div> |
|
|
|
<div> |
|
|
|
<el-button class="del_button" type="text">删除</el-button> |
|
|
|
<el-button |
|
|
|
class="del_button" |
|
|
|
type="text" |
|
|
|
>删除</el-button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@@ -46,9 +58,10 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { firstCharToLowerCase } from '@/utils/tool'; |
|
|
|
import FileUploader from '@/components/file-uploader'; |
|
|
|
import { wrapOssProtocol } from '@/services/oss'; |
|
|
|
import { firstCharToLowerCase, notify } from "@/utils/tool"; |
|
|
|
import FileUploader from "@/components/file-uploader"; |
|
|
|
import { wrapOssProtocol } from "@/services/oss"; |
|
|
|
import { addTemplateNodeModelFile, queryAllTemplateNodeModelFile } from "@/services/template"; |
|
|
|
|
|
|
|
export default { |
|
|
|
components: { |
|
|
@@ -64,49 +77,63 @@ export default { |
|
|
|
this.selectedNode = list[0]; |
|
|
|
}, |
|
|
|
selectedNode(node) { |
|
|
|
if(!node) { return; } |
|
|
|
this.commonFileList = []; |
|
|
|
this.companyFileList = []; |
|
|
|
if (!node) { |
|
|
|
return; |
|
|
|
} |
|
|
|
this.fetchNodeTemplateFiles(node); |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
selectedNode: this.nodeList[0], |
|
|
|
} |
|
|
|
commonFileList: [], |
|
|
|
companyFileList: [], |
|
|
|
}; |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
this.fetchNodeTemplateFiles(this.selectedNode); |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
async fetchNodeTemplateFiles(node) { |
|
|
|
// todo |
|
|
|
const res = await this.$fetchApi('template/queryAllTemplateNodeModelFile', { templateNodeId : node.id, companyId: this.companyId }); |
|
|
|
const fileList = (res.Data || []).map(firstCharToLowerCase); |
|
|
|
console.log(fileList); |
|
|
|
|
|
|
|
const filesRes = await queryAllTemplateNodeModelFile(node.id, this.companyId); |
|
|
|
const [commonFileList, companyFileList] = (filesRes.Data || []).reduce((cArr, upperFile) => { |
|
|
|
const file = firstCharToLowerCase(upperFile); |
|
|
|
if(file.companyId === '0') { |
|
|
|
cArr[0].push(file); |
|
|
|
} else if (file.companyId === this.companyId) { |
|
|
|
cArr[1].push(file); |
|
|
|
} |
|
|
|
return cArr; |
|
|
|
}, [[], []]); |
|
|
|
this.commonFileList = commonFileList; |
|
|
|
this.companyFileList = companyFileList; |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 上传成功保存文件 |
|
|
|
*/ |
|
|
|
async uploadFileSuccess (ossFile) { |
|
|
|
async uploadFileSuccess(ossFile) { |
|
|
|
const currentNode = this.selectedNode; |
|
|
|
const ossUrl = wrapOssProtocol(ossFile.ossUrl); |
|
|
|
const fileNameStrs = ossFile.name.split('.'); |
|
|
|
const fileNameStrs = ossFile.name.split("."); |
|
|
|
const extension = fileNameStrs.pop(); |
|
|
|
const param = { |
|
|
|
Extension: extension, |
|
|
|
FileName: fileNameStrs.join('.'), |
|
|
|
FileName: fileNameStrs.join("."), |
|
|
|
FileSize: ossFile.size, |
|
|
|
OssUrl: ossUrl, |
|
|
|
templateNodeId: currentNode.id, |
|
|
|
CompanyId: this.companyId, |
|
|
|
}; |
|
|
|
debugger; |
|
|
|
// const res = await services.addTemplateNodeModelFile(param); |
|
|
|
// if(res.Code !== 0) return; |
|
|
|
// notify.success('文件已上传。'); |
|
|
|
const res = await addTemplateNodeModelFile(param); |
|
|
|
if (res.Code !== 0) return; |
|
|
|
notify.success("文件已上传。"); |
|
|
|
this.fetchNodeTemplateFiles(currentNode); |
|
|
|
// this.nodeClick(currentNode); |
|
|
|
}, |
|
|
|
}, |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="scss" scoped> |
|
|
@@ -114,8 +141,9 @@ export default { |
|
|
|
display: flex; |
|
|
|
flex-direction: row; |
|
|
|
height: 100%; |
|
|
|
border-radius: 8px 8px 0 0 ; |
|
|
|
box-shadow: 0px 4px 10px 1px rgba(0, 0, 0, 0.1), 0px 1px 3px 0px rgba(0, 0, 0, 0.1); |
|
|
|
border-radius: 8px 8px 0 0; |
|
|
|
box-shadow: 0px 4px 10px 1px rgba(0, 0, 0, 0.1), |
|
|
|
0px 1px 3px 0px rgba(0, 0, 0, 0.1); |
|
|
|
overflow: hidden; |
|
|
|
&_left { |
|
|
|
flex: none; |
|
|
@@ -160,7 +188,7 @@ export default { |
|
|
|
height: 40px; |
|
|
|
line-height: 40px; |
|
|
|
border-bottom: 1px solid rgba(#111111, 0.1); |
|
|
|
>div { |
|
|
|
> div { |
|
|
|
position: relative; |
|
|
|
padding-left: 10px; |
|
|
|
font-size: 12px; |
|
|
@@ -168,13 +196,19 @@ export default { |
|
|
|
padding-left: 24px; |
|
|
|
flex: 407; |
|
|
|
} |
|
|
|
&:nth-child(2) { flex: 139; } |
|
|
|
&:nth-child(3) { flex: 140; } |
|
|
|
&:nth-child(4) { flex: 70; } |
|
|
|
&:nth-child(2) { |
|
|
|
flex: 139; |
|
|
|
} |
|
|
|
&:nth-child(3) { |
|
|
|
flex: 140; |
|
|
|
} |
|
|
|
&:nth-child(4) { |
|
|
|
flex: 70; |
|
|
|
} |
|
|
|
&:nth-child(2), |
|
|
|
&:nth-child(3) { |
|
|
|
&:before { |
|
|
|
content: ''; |
|
|
|
content: ""; |
|
|
|
position: absolute; |
|
|
|
top: 0; |
|
|
|
bottom: 0; |
|
|
@@ -201,7 +235,8 @@ export default { |
|
|
|
line-height: 28px; |
|
|
|
font-size: 12px; |
|
|
|
cursor: pointer; |
|
|
|
&:hover, &.item_active { |
|
|
|
&:hover, |
|
|
|
&.item_active { |
|
|
|
background-color: rgba(50, 50, 60, 0.1); |
|
|
|
} |
|
|
|
} |
|
|
|