| | |
| | | </div> |
| | | <div> |
| | | <el-button size="small" @click="exportFun">导 出</el-button> |
| | | <el-button size="small" type="primary" @click="importVisible = true">导 入</el-button> |
| | | <el-button size="small" type="primary" @click="openFormDia('add')">新 增</el-button> |
| | | </div> |
| | | </div> |
| | | <div class="table"> |
| | |
| | | :page="page" :tableLoading="tableLoading"></lims-table> |
| | | </div> |
| | | <form-dia v-if="formDia" ref="formDia" @closeYearDia="closeYearDia"></form-dia> |
| | | <borrow-dia v-if="borrowDia" ref="borrowDia" @closeYearDia="closeBorrowDia"></borrow-dia> |
| | | <return-dia v-if="returnDia" ref="returnDia" @closeYearDia="closeReturnDia"></return-dia> |
| | | <el-dialog title="标准物质导入" v-model="importVisible" width="500px" @closed="resetImport"> |
| | | <div style="margin-bottom: 12px;"> |
| | | 请使用标准物质导入模板填写数据,单个文件不超过10MB。 |
| | | <el-button link type="primary" @click="downloadTemplate">下载导入模板</el-button> |
| | | </div> |
| | | <el-upload ref="standardSubstanceUpload" drag name="file" accept=".xlsx" :action="importAction" |
| | | :headers="uploadHeader" :auto-upload="false" :limit="1" :file-list="importFiles" |
| | | :before-upload="beforeImport" :on-success="importSuccess" :on-error="importError"> |
| | | <lims-icon name="el-icon-upload"></lims-icon> |
| | | <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div> |
| | | </el-upload> |
| | | <template #footer><span class="dialog-footer"> |
| | | <el-button @click="importVisible = false">取消</el-button> |
| | | <el-button type="primary" :loading="importing" @click="submitImport">导入</el-button> |
| | | </span></template> |
| | | </el-dialog> |
| | | <borrow-dia v-if="borrowDia" ref="borrowDia" @closeBorrowDia="closeBorrowDia"></borrow-dia> |
| | | </div> |
| | | |
| | | </template> |
| | |
| | | import { |
| | | getPageStandardSubstance, |
| | | removeStandardSubstance, |
| | | exportOfStandardSubstanceList, |
| | | downloadStandardSubstanceImportTemplate |
| | | exportOfStandardSubstanceList |
| | | } from '@/api/cnas/resourceDemand/standardMaterial/standardMaterial' |
| | | import FormDia from '../standardMaterial/component/formDia.vue'; |
| | | import BorrowDia from '../standardMaterial/component/borrowDia.vue'; |
| | | import ReturnDia from '../standardMaterial/component/returnDia.vue'; |
| | | export default { |
| | | name: 'StandardMaterial', |
| | | components: { |
| | | limsTable, |
| | | FormDia, |
| | | BorrowDia, |
| | | ReturnDia |
| | | BorrowDia |
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | minWidth: '100' |
| | | }, |
| | | { |
| | | label: '供应商', |
| | | prop: 'supplier', |
| | | minWidth: '120' |
| | | }, |
| | | { |
| | | label: '出厂编号', |
| | | prop: 'factoryNum', |
| | | minWidth: '100' |
| | |
| | | minWidth: '100' |
| | | }, |
| | | { |
| | | label: '数量', |
| | | label: '原始数量', |
| | | prop: 'quantity', |
| | | minWidth: '100' |
| | | }, |
| | | { |
| | | label: '余量', |
| | | prop: 'remainingQuantity', |
| | | minWidth: '80' |
| | | }, |
| | | { |
| | | label: '单位', |
| | | prop: 'unit', |
| | | minWidth: '80' |
| | | }, |
| | | { |
| | | label: '购置日期', |
| | |
| | | }, |
| | | }, |
| | | { |
| | | name: '借用', |
| | | name: '领用', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.borrow(row); |
| | | }, |
| | | }, |
| | | { |
| | | name: '归还', |
| | | type: 'text', |
| | | clickFun: (row) => { |
| | | this.return(row); |
| | | } |
| | | disabled: (row) => { |
| | | return Number(row.remainingQuantity) <= 0; |
| | | }, |
| | | }, |
| | | { |
| | | name: '删除', |
| | |
| | | total: 0, |
| | | formDia: false, |
| | | borrowDia: false, |
| | | returnDia: false, |
| | | importVisible: false, |
| | | importing: false, |
| | | importFiles: [], |
| | | } |
| | | }, |
| | | computed: { |
| | | importAction() { |
| | | return this.javaApi + '/feStandardSubstance/importStandardSubstance' |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.searchList() |
| | | }, |
| | | methods: { |
| | | downloadTemplate() { |
| | | downloadStandardSubstanceImportTemplate().then(res => { |
| | | this.$download.saveAs(new Blob([res]), '标准物质导入模板.xlsx') |
| | | }) |
| | | }, |
| | | submitImport() { |
| | | if (!this.$refs.standardSubstanceUpload.uploadFiles.length) { |
| | | this.$message.warning('请选择需要导入的Excel文件') |
| | | return |
| | | } |
| | | this.$refs.standardSubstanceUpload.submit() |
| | | }, |
| | | beforeImport(file) { |
| | | if (!file.name.toLowerCase().endsWith('.xlsx')) { |
| | | this.$message.error('仅支持.xlsx格式文件') |
| | | return false |
| | | } |
| | | if (file.size > 10 * 1024 * 1024) { |
| | | this.$message.error('导入文件不能超过10MB') |
| | | return false |
| | | } |
| | | this.importing = true |
| | | return true |
| | | }, |
| | | importSuccess(response) { |
| | | this.importing = false |
| | | if (response.code !== 200) { |
| | | this.$message.error(response.message || response.msg || '导入失败') |
| | | return |
| | | } |
| | | this.$message.success(`成功导入${response.data}条标准物质`) |
| | | this.importVisible = false |
| | | this.searchList() |
| | | }, |
| | | importError() { |
| | | this.importing = false |
| | | this.$message.error('导入失败') |
| | | }, |
| | | resetImport() { |
| | | this.importing = false |
| | | this.importFiles = [] |
| | | if (this.$refs.standardSubstanceUpload) { |
| | | this.$refs.standardSubstanceUpload.clearFiles() |
| | | } |
| | | }, |
| | | exportFun() { |
| | | this.outLoading = true |
| | | exportOfStandardSubstanceList(this.searchForm).then(res => { |
| | | this.outLoading = false |
| | | const blob = new Blob([res], { type: 'application/octet-stream' }, false); |
| | | this.$download.saveAs(blob, '标准物质清单.xlsx') |
| | | this.$download.saveAs(blob, '标准物质台账.xlsx') |
| | | }) |
| | | }, |
| | | // 查询列表 |
| | |
| | | }, |
| | | closeBorrowDia() { |
| | | this.borrowDia = false |
| | | this.searchList() |
| | | }, |
| | | // 归还 |
| | | return(row) { |
| | | this.returnDia = true |
| | | this.$nextTick(() => { |
| | | this.$refs.returnDia.openDia(row) |
| | | }) |
| | | }, |
| | | closeReturnDia() { |
| | | this.returnDia = false |
| | | this.searchList() |
| | | }, |
| | | // 重置查询条件 |