| | |
| | | <!-- |
| | | * @Date: 2024-05-16 22:40:01 |
| | | * @LastEditors: Sneed |
| | | * @LastEditTime: 2024-06-11 19:19:41 |
| | | * @LastEditTime: 2024-06-17 23:43:44 |
| | | * @FilePath: /belleson-frontend/Users/mache/Documents/demo/cps-web/src/views/dnc/document/index.vue |
| | | --> |
| | | <template> |
| | |
| | | <el-aside width="200px"> |
| | | <el-container> |
| | | <el-main> |
| | | <el-tree default-expand-all ref="tree" node-key="id" :data="treeData" :props="{ |
| | | label: 'name', |
| | | }" @node-click="nodeClick" highlight-current :current-node-key="selectNode.id"> |
| | | <el-tree :expand-on-click-node="false" default-expand-all ref="tree" node-key="id" |
| | | :data="treeData" :props="{ |
| | | label: 'name', |
| | | }" @node-click="nodeClick" highlight-current :current-node-key="selectNode.id"> |
| | | <template #default="{ node, data }"> |
| | | <span :class="data.isGroup ? 'active' : ''" class="custom-tree-node"> |
| | | <span>{{ |
| | |
| | | <template #dropdown> |
| | | <el-dropdown-menu> |
| | | <el-dropdown-item @click="addFolder">文件夹</el-dropdown-item> |
| | | <el-dropdown-item>文件</el-dropdown-item> |
| | | <el-dropdown-item @click="addFile">文件</el-dropdown-item> |
| | | </el-dropdown-menu> |
| | | </template> |
| | | </el-dropdown> |
| | | <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload" |
| | | <!-- <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload" |
| | | action="/api/blade-resource/oss/endpoint/put-file"> |
| | | <el-button type="primary">上传文件</el-button> |
| | | </el-upload> --> |
| | | <el-upload style="margin-left: 8px;" :show-file-list="false" class="upload" |
| | | :http-request="request"> |
| | | <el-button type="primary">上传文件</el-button> |
| | | </el-upload> |
| | | <!-- <el-button type="primary" style="margin-left: 8px;">上传文件</el-button> --> |
| | |
| | | <el-button-group> |
| | | <el-button text type="primary" size="small" |
| | | @click="table_edit(scope.row, scope.$index)">编辑</el-button> |
| | | <el-button text type="primary" size="small" |
| | | @click="del([scope.row])">删除</el-button> |
| | | <el-popconfirm width="220" title="确定将选择的数据删除" @confirm="del([scope.row], '0')"> |
| | | <template #reference> |
| | | <el-button text type="primary" size="small">删除</el-button> |
| | | </template> |
| | | </el-popconfirm> |
| | | <!-- <el-button text type="primary" size="small" |
| | | @click="del([scope.row])">删除</el-button> --> |
| | | </el-button-group> |
| | | </template> |
| | | </el-table-column> |
| | |
| | | </div> |
| | | </template> |
| | | </el-dialog> |
| | | <scDialog v-model="visible"> |
| | | <scForm ref="form" :config="config" :rules="rules1" v-model="form1" @submit="submit1"> |
| | | </scForm> |
| | | </scDialog> |
| | | </el-main> |
| | | </template> |
| | | |
| | |
| | | export default { |
| | | data() { |
| | | return { |
| | | visible: false, |
| | | rules1: { |
| | | name: [{ |
| | | required: true, message: '必填' |
| | | }], |
| | | content: [{ |
| | | required: true, message: '必填' |
| | | }] |
| | | }, |
| | | form1: {}, |
| | | config: { |
| | | labelWidth: 120, |
| | | formItems: [ |
| | | { |
| | | component: 'input', |
| | | label: '文件名称', |
| | | name: 'name', |
| | | options: { |
| | | placeholder: '', |
| | | maxlength: 100, |
| | | } |
| | | }, |
| | | { |
| | | component: 'input', |
| | | label: '文件内容', |
| | | type: 'textarea', |
| | | name: 'content', |
| | | options: { |
| | | multiple: false, |
| | | data: [] |
| | | }, |
| | | disabled: false |
| | | } |
| | | ] |
| | | }, |
| | | treeData: [], |
| | | selectNode: {}, |
| | | visible: false, |
| | |
| | | this.init() |
| | | }, |
| | | methods: { |
| | | request(options) { |
| | | const formData = new FormData() |
| | | formData.append('file', options.file) |
| | | console.log(options) |
| | | this.$HTTP.post(`/api/blade-resource/oss/endpoint/put-file`, formData).then(resFile => { |
| | | if (resFile.success) { |
| | | this.$HTTP.post(`/api/blade-dnc/file/batch-save`, [{ |
| | | name: options.file.name, |
| | | targetId: this.selectNode.id, |
| | | ossFile: { |
| | | attachId: resFile.data.attachId, |
| | | domain: resFile.data.domain, |
| | | link: resFile.data.link, |
| | | name: resFile.data.name, |
| | | originalName: resFile.data.originalName |
| | | } |
| | | }]).then(res => { |
| | | if (res.success) { |
| | | this.visible = false |
| | | this.search() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | }) |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | |
| | | }) |
| | | }, |
| | | addFile() { |
| | | this.form1 = {} |
| | | this.$refs?.form?.resetFields() |
| | | this.visible = true |
| | | }, |
| | | submit1() { |
| | | // 创建文本内容 |
| | | const textContent = "这里是文本内容"; |
| | | |
| | | // 创建Blob对象 |
| | | const blob = new Blob([this.form1.content], { type: 'text/plain' }); |
| | | // 创建File对象 |
| | | const file = new File([blob], this.form1.name, { type: 'text/plain', lastModified: new Date().getTime() }); |
| | | const data = new FormData() |
| | | data.append("file", file); |
| | | this.$HTTP.post(`/api/blade-resource/oss/endpoint/put-file`, data).then(res => { |
| | | if (res.success) { |
| | | this.$HTTP.post(`/api/blade-dnc/file/batch-save`, [{ |
| | | name: `${this.form1.name}.txt`, |
| | | targetId: this.selectNode.id, |
| | | ossFile: { |
| | | attachId: res.data.attachId, |
| | | domain: res.data.domain, |
| | | link: res.data.link, |
| | | name: res.data.name, |
| | | originalName: res.data.originalName |
| | | } |
| | | }]).then(res => { |
| | | if (res.success) { |
| | | this.visible = false |
| | | this.search() |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | }) |
| | | } else { |
| | | this.$message.error(res.msg) |
| | | } |
| | | }) |
| | | }, |
| | | init() { |
| | | this.selectNode = { |
| | | id: '' |