Browse Source

企业后台 完成模板添加企业模板文件的设置

dev
zhengzhou 4 years ago
parent
commit
7af547f373
4 changed files with 83 additions and 44 deletions
  1. +5
    -2
      src/services/template.js
  2. +2
    -1
      src/views/main_web/workspace/components/add-file-button.vue
  3. +1
    -1
      src/views/main_web/workspace/workspace.new.vue
  4. +75
    -40
      src/views/manage_company/template/components/template-files.vue

+ 5
- 2
src/services/template.js View File

@@ -125,8 +125,11 @@ export async function fileExchange(unit) {
* 查询模板节点下的所有样本文件
* @param {string} nodeId
*/
export async function queryAllTemplateNodeModelFile(nodeId) {
const res = await fetchApi('template/queryAllTemplateNodeModelFile', { templateNodeId: nodeId });
export async function queryAllTemplateNodeModelFile(nodeId, companyId) {
const res = await fetchApi('template/queryAllTemplateNodeModelFile', { templateNodeId: nodeId, companyId: companyId ? undefined : '0' });
if(companyId && res.Data) {
res.Data = res.Data.filter(file => file.CompanyId === '0' || file.CompanyId === companyId);
}
return wrapErrorHint(res);
}
/**


+ 2
- 1
src/views/main_web/workspace/components/add-file-button.vue View File

@@ -101,6 +101,7 @@ export default {
isShowNewFiledialog: false,
isShowNewTemplateFileDialog: false,//新建样板文件弹窗
listTempFiles: [],
companyId: sessionStorage.companyId,
}
},
mounted() {
@@ -133,7 +134,7 @@ export default {
const currentNodeFolderId = this.currentNodeFolder?.nodeId;
if(!currentNodeFolderId) { return; }

const res = await queryAllTemplateNodeModelFile(currentNodeFolderId);
const res = await queryAllTemplateNodeModelFile(currentNodeFolderId, this.companyId);
if (res.Code !== 0) return;
this.listTempFiles = (res.Data || []).map(f => firstCharToLowerCase(f));
},


+ 1
- 1
src/views/main_web/workspace/workspace.new.vue View File

@@ -520,7 +520,7 @@ import AddFileButton from './components/add-file-button';
import vuetify from "vuetify";
import system from '@/services/system';
import { getUserInfo, getUserListByNode } from '@/services/user.js';
import { queryAllTemplateNodeModelFile, queryNestTemplateByProjectId } from '@/services/template.js';
import { queryNestTemplateByProjectId } from '@/services/template.js';
import * as services from './service';
import { firstCharToLowerCase, firstCharToUpperCase, notify } from '@/utils/tool';
import FileItem from './components/file-item';


+ 75
- 40
src/views/manage_company/template/components/template-files.vue View File

@@ -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);
}
}


Loading…
Cancel
Save