|  |  |  | 
|---|
|  |  |  | <el-input v-model="form.name" placeholder="请输入资料名称" v-trim/> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="资料类型" prop="categoryId"> | 
|---|
|  |  |  | <el-input v-model="form.categoryId" placeholder="请输入责任部门编码(关联company)" v-trim/> | 
|---|
|  |  |  | <el-select v-model="form.categoryId" clearable filterable placeholder="请选择"> | 
|---|
|  |  |  | <el-option v-for="item in cateList" :key="item.id" :label="item.name" :value="item.id"> | 
|---|
|  |  |  | </el-option> | 
|---|
|  |  |  | </el-select> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="责任部门" prop="companyId"> | 
|---|
|  |  |  | <el-input v-model="form.companyId" placeholder="请输入责任部门编码(关联company)" v-trim/> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="排序码" prop="sortnum"> | 
|---|
|  |  |  | <el-input v-model="form.sortnum" placeholder="请输入排序码" v-trim/> | 
|---|
|  |  |  | <treeselect | 
|---|
|  |  |  | v-model="form.companyId" | 
|---|
|  |  |  | placeholder="请选择" | 
|---|
|  |  |  | :options="companyList" | 
|---|
|  |  |  | :normalizer="normalizeOptions" | 
|---|
|  |  |  | :default-expand-level="1" | 
|---|
|  |  |  | noChildrenText="没有子选项" | 
|---|
|  |  |  | noOptionsText="没有可选项" | 
|---|
|  |  |  | noResultsText="没有匹配的结果" /> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="附件地址" prop="fileurl"> | 
|---|
|  |  |  | <el-input v-model="form.fileurl" placeholder="请输入附件地址" v-trim/> | 
|---|
|  |  |  | <UploadFile :uploadData="{ folder: 'company_documents',fileType:'.zip,.war,.pdf' }" :fileList="fileList"  @uploadSuccess="uploadFileBiz" /> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--        <UploadFile width="100px" height="100px" :list="[]"  folder="company_documents" @success="uploadFileBiz($event, 2)" />--> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="附件描述" prop="content"> | 
|---|
|  |  |  | <el-input type="textarea" v-model="form.content" placeholder="请输入附件描述" v-trim/> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | <el-form-item label="排序码(降序)" prop="sortnum"> | 
|---|
|  |  |  | <el-input type="number" v-model="form.sortnum" placeholder="请输入排序码" v-trim/> | 
|---|
|  |  |  | </el-form-item> | 
|---|
|  |  |  | </el-form> | 
|---|
|  |  |  | </GlobalWindow> | 
|---|
|  |  |  | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | import BaseOpera from '@/components/base/BaseOpera' | 
|---|
|  |  |  | import GlobalWindow from '@/components/common/GlobalWindow' | 
|---|
|  |  |  | import { fetchList as companyList } from '@/api/business/company' | 
|---|
|  |  |  | import UploadFile from '@/components/common/UploadFile' | 
|---|
|  |  |  | import { fetchList } from '@/api/business/category' | 
|---|
|  |  |  | export default { | 
|---|
|  |  |  | name: 'OperaCompanyDocumentsWindow', | 
|---|
|  |  |  | extends: BaseOpera, | 
|---|
|  |  |  | components: { GlobalWindow }, | 
|---|
|  |  |  | components: { GlobalWindow, UploadFile }, | 
|---|
|  |  |  | data () { | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | // 表单数据 | 
|---|
|  |  |  | form: { | 
|---|
|  |  |  | id: null, | 
|---|
|  |  |  | creator: '', | 
|---|
|  |  |  | createDate: '', | 
|---|
|  |  |  | editor: '', | 
|---|
|  |  |  | editDate: '', | 
|---|
|  |  |  | isdeleted: '', | 
|---|
|  |  |  | name: '', | 
|---|
|  |  |  | remark: '', | 
|---|
|  |  |  | status: '', | 
|---|
|  |  |  | status: '0', | 
|---|
|  |  |  | sortnum: '', | 
|---|
|  |  |  | fileurl: '', | 
|---|
|  |  |  | fileName: '', | 
|---|
|  |  |  | fileSize: '', | 
|---|
|  |  |  | categoryId: '', | 
|---|
|  |  |  | companyId: '', | 
|---|
|  |  |  | content: '' | 
|---|
|  |  |  | categoryId: null, | 
|---|
|  |  |  | companyId: null, | 
|---|
|  |  |  | content: '', | 
|---|
|  |  |  | fileurlFull: '' | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | fileList:[], | 
|---|
|  |  |  | cateList: [], | 
|---|
|  |  |  | companyList: [], | 
|---|
|  |  |  | // 验证规则 | 
|---|
|  |  |  | rules: { | 
|---|
|  |  |  | name: [{ required: true, message: '请输入资料名称', trigger: 'blur' }], | 
|---|
|  |  |  | companyId: [{ required: true, message: '请选择责任部门' }], | 
|---|
|  |  |  | categoryId: [{ required: true, message: '请选择资料类型' }], | 
|---|
|  |  |  | fileurl: [{ required: true, message: '请上传资料文件' }] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | 
|---|
|  |  |  | api: '/business/companyDocuments', | 
|---|
|  |  |  | 'field.id': 'id' | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | methods: { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 规范化选项数据的方法 | 
|---|
|  |  |  | normalizeOptions (node) { | 
|---|
|  |  |  | // node: 原始的选项数据 | 
|---|
|  |  |  | // 在这里根据需要进行选项数据的规范化操作,并返回规范化后的选项数据 | 
|---|
|  |  |  | // 例如,可以将原始的选项数据转换为符合插件要求的结构 | 
|---|
|  |  |  | if (node.childList && !node.childList.length) { | 
|---|
|  |  |  | // 去掉children=[]的children属性 | 
|---|
|  |  |  | delete node.childList | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return { | 
|---|
|  |  |  | id: node.id, | 
|---|
|  |  |  | label: node.name, | 
|---|
|  |  |  | children: node.childList | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | open (title, target) { | 
|---|
|  |  |  | this.title = title | 
|---|
|  |  |  | this.visible = true | 
|---|
|  |  |  | this.getCate() | 
|---|
|  |  |  | this.fileList = [] | 
|---|
|  |  |  | this.getCompany() | 
|---|
|  |  |  | // 新建组织 | 
|---|
|  |  |  | if (target == null) { | 
|---|
|  |  |  | this.$nextTick(() => { | 
|---|
|  |  |  | this.$refs.form.resetFields() | 
|---|
|  |  |  | this.form[this.configData['field.id']] = null | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | return | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // 编辑 | 
|---|
|  |  |  | this.$nextTick(() => { | 
|---|
|  |  |  | for (const key in this.form) { | 
|---|
|  |  |  | this.form[key] = target[key] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(this.form.fileurl){ | 
|---|
|  |  |  | this.fileList = [{ fileurl: this.form.fileurl, fileurlFull:this.form.fileurlFull, name: this.form.fileName,fileSize:this.form.fileSize }] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | uploadFileBiz (file) { | 
|---|
|  |  |  | // this.$emit('uploadSuccess', { fileurl: data.imgaddr, fileurlFull: data.url, name: data.originname }) | 
|---|
|  |  |  | this.form.fileurl = file.fileurl | 
|---|
|  |  |  | this.form.fileName = file.name | 
|---|
|  |  |  | this.form.fileurlFull = file.fileurlFull | 
|---|
|  |  |  | this.form.fileSize = file.fileSize | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | getCate () { | 
|---|
|  |  |  | fetchList({ | 
|---|
|  |  |  | model: { type: 2 }, | 
|---|
|  |  |  | capacity: 1000, | 
|---|
|  |  |  | page: 1 | 
|---|
|  |  |  | }).then(res => { | 
|---|
|  |  |  | if (res && res.records && res.records.length > 0) { | 
|---|
|  |  |  | this.cateList = res.records || [] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | getCompany () { | 
|---|
|  |  |  | companyList() | 
|---|
|  |  |  | .then(res => { | 
|---|
|  |  |  | if (res && res.length > 0) { | 
|---|
|  |  |  | this.companyList = this.getDepartmentTree(res) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | getDepartmentTree (tree) { | 
|---|
|  |  |  | if (tree == null) { | 
|---|
|  |  |  | return [] | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return tree.map(item => { | 
|---|
|  |  |  | const newItem = { ...item } | 
|---|
|  |  |  | if (newItem) { | 
|---|
|  |  |  | newItem.children = newItem.childList | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (item.children && item.children.length == 0) { | 
|---|
|  |  |  | this.$delete(newItem, 'children') | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | newItem.children = this.getDepartmentTree(newItem.children) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return newItem | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | </script> | 
|---|